Skip to content

Commit 7182dbe

Browse files
committed
docs(readme): enhance usage instructions and clarify action setup
Updated the README to improve clarity on using the Cursor GitHub Action. Added a Quickstart section, revised input and output descriptions, and emphasized the use of the main branch for action usage. Adjusted examples for better readability and consistency.
1 parent a3a1b20 commit 7182dbe

1 file changed

Lines changed: 82 additions & 62 deletions

File tree

README.md

Lines changed: 82 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# Cursor Action
22

3-
> **GitHub Action**Install the [Cursor](https://cursor.com) CLI and run `cursor-agent` in your CI pipelines.
3+
Install the [Cursor](https://cursor.com) CLI in GitHub Actions and run `cursor-agent` in CI.
44

55
[![CI](https://github.com/PunGrumpy/cursor-action/actions/workflows/ci.yml/badge.svg)](https://github.com/PunGrumpy/cursor-action/actions/workflows/ci.yml)
66
[![Release](https://github.com/PunGrumpy/cursor-action/actions/workflows/release.yml/badge.svg)](https://github.com/PunGrumpy/cursor-action/actions/workflows/release.yml)
77

8-
---
8+
## Quickstart
99

10-
## Usage
10+
1. Add a repository secret named `CURSOR_API_KEY`.
11+
2. Use the action in a workflow job.
12+
3. Read `steps.<id>.outputs.summary` for the model response.
1113

1214
```yaml
1315
- name: Run Cursor Agent
14-
uses: PunGrumpy/cursor-action@v1
1516
id: cursor
17+
uses: PunGrumpy/cursor-action@main
1618
with:
1719
api-key: ${{ secrets.CURSOR_API_KEY }}
1820
prompt: "Review this PR for security issues and summarize your findings."
@@ -21,33 +23,32 @@
2123
run: echo "${{ steps.cursor.outputs.summary }}"
2224
```
2325
24-
---
25-
2626
## Inputs
2727
28-
| Input | Required | Default | Description |
29-
| ------------------- | -------- | ----------- | ---------------------------------------------------------------------------------------------------- |
30-
| `api-key` | ✅ | — | Your Cursor API key. Store as a secret. |
31-
| `prompt` | ✅ | — | The prompt to pass to `cursor-agent`. |
32-
| `cursor-version` | ❌ | `latest` | Cursor CLI build to install. Use `latest` or an exact Cursor lab build id like `2026.03.20-44cb435`. |
33-
| `model` | ❌ | `auto` | Model for the agent to use. |
34-
| `working-directory` | ❌ | `.` | Directory the agent operates in. |
35-
| `permissions` | ❌ | `read-only` | Agent permissions: `read-only`, `read-write`, or `full`. |
36-
| `timeout` | ❌ | `300` | Timeout in seconds before the agent is killed. |
28+
> Pre-release note: this repository has not published a stable release tag yet.
29+
> Use `uses: PunGrumpy/cursor-action@main` (or a pinned commit SHA) until the first `v1` release is published.
3730

38-
## Outputs
31+
| Input | Required | Default | Description |
32+
| ------------------- | -------- | ----------- | ----------------------------------------------------------------------------------- |
33+
| `api-key` | ✅ | — | Cursor API key (store in GitHub Secrets). |
34+
| `prompt` | ✅ | — | Prompt passed to `cursor-agent`. |
35+
| `cursor-version` | ❌ | `latest` | Cursor lab build to install (`latest` or exact build id like `2026.03.20-44cb435`). |
36+
| `model` | ❌ | `auto` | Model name for `cursor-agent`. |
37+
| `working-directory` | ❌ | `.` | Working directory used when running the agent. |
38+
| `permissions` | ❌ | `read-only` | Agent permissions: `read-only`, `read-write`, or `full`. |
39+
| `timeout` | ❌ | `300` | Timeout in seconds for each agent invocation attempt. |
3940

40-
| Output | Description |
41-
| ----------- | ----------------------------------------------------------- |
42-
| `summary` | Text response from the agent. |
43-
| `exit-code` | Raw exit code from the `cursor-agent` process. |
44-
| `cache-hit` | `"true"` if the Cursor CLI install was restored from cache. |
41+
## Outputs
4542

46-
---
43+
| Output | Description |
44+
| ----------- | -------------------------------------------------- |
45+
| `summary` | Agent text output (used for step-to-step handoff). |
46+
| `exit-code` | Exit code returned by `cursor-agent`. |
47+
| `cache-hit` | `"true"` when CLI install came from cache. |
4748

4849
## Examples
4950

50-
### PR code review
51+
### PR review comment
5152

5253
```yaml
5354
name: Cursor Code Review
@@ -59,18 +60,18 @@ jobs:
5960
review:
6061
runs-on: ubuntu-latest
6162
steps:
62-
- uses: actions/checkout@v4
63+
- uses: actions/checkout@v6
6364
6465
- name: Run Cursor Agent
65-
uses: PunGrumpy/cursor-action@v1
6666
id: review
67+
uses: PunGrumpy/cursor-action@main
6768
with:
6869
api-key: ${{ secrets.CURSOR_API_KEY }}
70+
permissions: read-only
6971
prompt: |
7072
Review the staged changes in this repository.
71-
Focus on: correctness, security, and performance.
73+
Focus on correctness, security, and performance.
7274
Be concise.
73-
permissions: read-only
7475
7576
- name: Comment on PR
7677
uses: actions/github-script@v7
@@ -84,68 +85,71 @@ jobs:
8485
})
8586
```
8687

87-
### Pin a specific CLI version
88+
### Pin a specific Cursor CLI build
8889

8990
```yaml
90-
- uses: PunGrumpy/cursor-action@v1
91+
- uses: PunGrumpy/cursor-action@main
9192
with:
9293
api-key: ${{ secrets.CURSOR_API_KEY }}
9394
prompt: "Generate a changelog entry for the latest commit."
9495
cursor-version: "2026.03.20-44cb435"
9596
```
9697
97-
### Read-write permissions (agent can modify files)
98+
### Allow file edits
9899
99100
```yaml
100-
- uses: PunGrumpy/cursor-action@v1
101+
- uses: PunGrumpy/cursor-action@main
101102
with:
102103
api-key: ${{ secrets.CURSOR_API_KEY }}
103-
prompt: "Fix any TypeScript type errors in src/"
104+
prompt: "Fix TypeScript type errors in src/."
104105
permissions: read-write
105106
working-directory: ./src
106107
```
107108
108-
---
109-
110-
## Version Resolution
109+
## How this action behaves
111110
112-
`cursor-version: latest` resolves to the current published Cursor lab build before download. The action first checks Cursor's lab `latest-version` endpoint and, if that endpoint is unavailable or returns an access error, falls back to parsing the official [`https://cursor.com/install`](https://cursor.com/install) installer script.
111+
### Version resolution
113112
114-
If you want reproducible installs, pin `cursor-version` to an exact lab build id such as `2026.03.20-44cb435`. Values like `1.2.3` are not published Cursor lab artifact versions and will fail to download.
113+
- `cursor-version: latest` resolves to a concrete Cursor lab build before download.
114+
- Resolution order:
115+
1. `https://downloads.cursor.com/lab/latest-version`
116+
2. Fallback to parsing `https://cursor.com/install`
117+
- For reproducible installs, pin an exact lab build id.
115118

116-
---
119+
### Invocation strategy
117120

118-
## Caching
121+
- Primary invocation: `cursor-agent chat ...`
122+
- If chat fails with a likely CLI mismatch (for example `unknown command`) or empty output, the action retries with headless print mode (`-p --output-format text`).
123+
- A preflight print probe is also run to improve auth/entitlement diagnostics in job summary output.
119124

120-
The action caches the extracted Cursor CLI package across jobs using `@actions/cache`. The cache key includes the platform, architecture, and resolved version, so:
125+
### Caching
121126

122-
- `latest` resolves to a concrete version before caching — it won't re-download on every run once cached.
123-
- Pinning a version (e.g. `2026.03.20-44cb435`) gives you a stable, reproducible cache hit every time.
124-
- The full installed package is cached, not just the `cursor-agent` launcher.
127+
- The extracted CLI package is cached by platform, architecture, and resolved version.
128+
- Using `latest` still hits cache after it resolves to a concrete build.
129+
- Pinning a build id gives stable cache keys across runs.
125130

126-
---
131+
## Local development
127132

128-
## Troubleshooting (CI / smoke tests)
133+
### Prerequisites
129134

130-
### `cursor-agent` exits with code 1 and little or no output
135+
- Node.js 24 (matches CI and release workflows)
136+
- Bun
131137

132-
- **API key & billing**: Ensure `CURSOR_API_KEY` is set and valid. Agent / headless features may require an eligible Cursor plan; some errors only show up once the CLI talks to Cursor’s API.
133-
- **Model**: The default `model: auto` should work for most accounts. If you pin `model`, confirm that model is available for your subscription.
134-
- **CI model override**: In this repo's CI workflow, `smoke-test.env.CURSOR_SMOKE_TEST_MODEL` controls the model used by the smoke test. Set it to a known-good model for your account if `auto` fails.
135-
- **CLI contract changes**: This action first runs `cursor-agent chat …` (with `--allow-*` flags from `permissions`). If that fails with no output or an “unknown command”-style error, it automatically retries using headless **print mode** (`-p`, `--output-format text`) as documented in the [Cursor headless CLI](https://cursor.com/docs/cli/headless) docs.
136-
- **Debugging**: On failure, check the **job summary** — it includes `cursor-agent --version`, which invocation mode was used (`chat` vs `print`), an auth/entitlement preflight result, merged stderr, and a **Diagnostics** section when both attempts fail.
137-
138-
### Reproduce locally
138+
### Validate changes locally
139139

140140
```bash
141-
export CURSOR_API_KEY='your-key'
142-
cursor-agent --version
143-
cursor-agent -p --no-interactive --output-format text --model auto "Say 'smoke test passed' and nothing else."
141+
bun install
142+
bun run typecheck
143+
bun run test
144+
bun run build
144145
```
145146

146-
To run the action entrypoint locally from this repo:
147+
If you changed source files, commit updated `dist/` as well (`CI` fails when `dist/` is out of date).
148+
149+
### Run action entrypoint locally
147150

148151
```bash
152+
export CURSOR_API_KEY='your-key'
149153
export GITHUB_STEP_SUMMARY="$(mktemp)"
150154
export GITHUB_OUTPUT="$(mktemp)"
151155
export RUNNER_TOOL_CACHE="$(mktemp -d)"
@@ -160,15 +164,31 @@ env "INPUT_API-KEY=$CURSOR_API_KEY" \
160164
node dist/index.js
161165
```
162166

163-
---
167+
## CI and release notes
164168

165-
## Versioning
169+
- `CI` workflow runs `typecheck`, `test`, and `build` on pushes and pull requests.
170+
- On pushes to `main`, CI also runs a smoke test job using this action (`uses: ./`).
171+
- `Release` workflow runs on pushes to `main`, executes tests/build, then uses Changesets to open/update a release PR or publish.
172+
- After the first stable release, major tags (`v1`, `v2`, ...) are managed by the release flow so `@v1` tracks the latest `v1.x.x`.
173+
174+
## Troubleshooting
166175

167-
This project uses [changesets](https://github.com/changesets/changesets) for versioning. See [`.changeset/README.md`](.changeset/README.md) for how to add a changeset when contributing.
176+
### `cursor-agent` exits non-zero
168177

169-
Major version tags (`v1`, `v2`, …) are kept up-to-date automatically by the release workflow, so `uses: PunGrumpy/cursor-action@v1` always resolves to the latest `v1.x.x` release.
178+
- Confirm `CURSOR_API_KEY` is present and valid.
179+
- If you set `model`, verify your account can access it (try `auto` first).
180+
- Check the job summary for:
181+
- `cursor-agent --version`
182+
- invocation mode used (`chat` or fallback `print`)
183+
- preflight/auth diagnostics and merged stderr
184+
185+
### Smoke test model issues in this repo
186+
187+
This repository's smoke test uses `CURSOR_SMOKE_TEST_MODEL` (default: `auto`) in `.github/workflows/ci.yml`. If smoke tests fail due to model access, set it to a known-good model for your account.
188+
189+
## Versioning
170190

171-
---
191+
This project uses [Changesets](https://github.com/changesets/changesets). See [`.changeset/README.md`](.changeset/README.md) for contribution workflow details.
172192

173193
## License
174194

0 commit comments

Comments
 (0)