@testsprite/testsprite-cli 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -147
- package/dist/commands/agent.d.ts +12 -4
- package/dist/commands/agent.js +48 -63
- package/dist/commands/auth.d.ts +6 -10
- package/dist/commands/auth.js +40 -56
- package/dist/commands/ci.d.ts +23 -100
- package/dist/commands/ci.js +293 -487
- package/dist/commands/conversation.d.ts +27 -0
- package/dist/commands/conversation.js +741 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +129 -34
- package/dist/commands/init.d.ts +4 -45
- package/dist/commands/init.js +108 -66
- package/dist/commands/project-env.d.ts +62 -2
- package/dist/commands/project-env.js +434 -43
- package/dist/commands/project-sign-in.d.ts +0 -48
- package/dist/commands/project-sign-in.js +1 -229
- package/dist/commands/project.d.ts +19 -186
- package/dist/commands/project.js +108 -926
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +216 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +28 -87
- package/dist/commands/test.d.ts +301 -1838
- package/dist/commands/test.js +1880 -13917
- package/dist/commands/testlist.d.ts +130 -5
- package/dist/commands/testlist.js +300 -342
- package/dist/commands/tunnel.d.ts +3 -3
- package/dist/commands/tunnel.js +23 -20
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +50 -131
- package/dist/index.js +191 -110
- package/dist/lib/agent-detect.js +9 -5
- package/dist/lib/agent-targets.d.ts +21 -2
- package/dist/lib/agent-targets.js +88 -11
- package/dist/lib/args.d.ts +13 -0
- package/dist/lib/args.js +49 -0
- package/dist/lib/basic-auth.d.ts +3 -0
- package/dist/lib/basic-auth.js +15 -0
- package/dist/lib/billing-refusal.js +4 -3
- package/dist/lib/ci-linkage.d.ts +4 -82
- package/dist/lib/ci-linkage.js +4 -157
- package/dist/lib/ci-run.js +1 -1
- package/dist/lib/client-factory.d.ts +12 -4
- package/dist/lib/client-factory.js +41 -30
- package/dist/lib/commit-signal.d.ts +65 -0
- package/dist/lib/commit-signal.js +305 -0
- package/dist/lib/concurrency-limiter.d.ts +6 -0
- package/dist/lib/concurrency-limiter.js +29 -0
- package/dist/lib/config.js +10 -5
- package/dist/lib/conflict-reason.d.ts +9 -3
- package/dist/lib/conflict-reason.js +6 -3
- package/dist/lib/conversation/answers.d.ts +9 -0
- package/dist/lib/conversation/answers.js +49 -0
- package/dist/lib/conversation/api.d.ts +75 -0
- package/dist/lib/conversation/api.js +151 -0
- package/dist/lib/conversation/change.d.ts +31 -0
- package/dist/lib/conversation/change.js +124 -0
- package/dist/lib/conversation/context.d.ts +29 -0
- package/dist/lib/conversation/context.js +82 -0
- package/dist/lib/conversation/environment.d.ts +16 -0
- package/dist/lib/conversation/environment.js +21 -0
- package/dist/lib/conversation/follow.d.ts +24 -0
- package/dist/lib/conversation/follow.js +42 -0
- package/dist/lib/conversation/render.d.ts +33 -0
- package/dist/lib/conversation/render.js +318 -0
- package/dist/lib/conversation/title.d.ts +2 -0
- package/dist/lib/conversation/title.js +18 -0
- package/dist/lib/conversation/types.d.ts +158 -0
- package/dist/lib/conversation/types.js +6 -0
- package/dist/lib/credentials.js +67 -11
- package/dist/lib/cron.d.ts +1 -1
- package/dist/lib/cron.js +2 -2
- package/dist/lib/dispatch-stop.d.ts +20 -0
- package/dist/lib/dispatch-stop.js +30 -0
- package/dist/lib/download.d.ts +100 -0
- package/dist/lib/download.js +408 -0
- package/dist/lib/dry-run/fetch.d.ts +10 -0
- package/dist/lib/dry-run/fetch.js +20 -0
- package/dist/lib/dry-run/samples.d.ts +6 -34
- package/dist/lib/dry-run/samples.js +375 -747
- package/dist/lib/environment-tunnel.d.ts +19 -30
- package/dist/lib/environment-tunnel.js +168 -202
- package/dist/lib/errors.d.ts +20 -4
- package/dist/lib/errors.js +36 -16
- package/dist/lib/facade.d.ts +7 -29
- package/dist/lib/facade.js +7 -36
- package/dist/lib/failing-fe-resolver.d.ts +13 -58
- package/dist/lib/failing-fe-resolver.js +47 -132
- package/dist/lib/first-suite-hint.d.ts +20 -30
- package/dist/lib/first-suite-hint.js +57 -72
- package/dist/lib/gh-output.d.ts +76 -21
- package/dist/lib/gh-output.js +171 -90
- package/dist/lib/git-utils.d.ts +56 -0
- package/dist/lib/git-utils.js +212 -0
- package/dist/lib/github-context.d.ts +2 -0
- package/dist/lib/github-context.js +40 -8
- package/dist/lib/history-retention.d.ts +6 -2
- package/dist/lib/history-retention.js +10 -7
- package/dist/lib/http.d.ts +58 -134
- package/dist/lib/http.js +354 -291
- package/dist/lib/interrupt.d.ts +14 -8
- package/dist/lib/interrupt.js +28 -10
- package/dist/lib/junit-report.d.ts +57 -4
- package/dist/lib/junit-report.js +202 -32
- package/dist/lib/local-target.d.ts +8 -7
- package/dist/lib/local-target.js +14 -13
- package/dist/lib/output.d.ts +2 -41
- package/dist/lib/output.js +13 -51
- package/dist/lib/pagination.d.ts +2 -5
- package/dist/lib/pagination.js +2 -5
- package/dist/lib/presigned-url.d.ts +22 -0
- package/dist/lib/presigned-url.js +90 -0
- package/dist/lib/prompt.js +36 -2
- package/dist/lib/proxy.js +2 -1
- package/dist/lib/redact.d.ts +2 -2
- package/dist/lib/redact.js +3 -4
- package/dist/lib/removed-commands.d.ts +18 -0
- package/dist/lib/removed-commands.js +170 -0
- package/dist/lib/render-error.d.ts +31 -6
- package/dist/lib/render-error.js +88 -25
- package/dist/lib/response-schemas.d.ts +38 -30
- package/dist/lib/response-schemas.js +207 -207
- package/dist/lib/result/api.d.ts +24 -0
- package/dist/lib/result/api.js +28 -0
- package/dist/lib/result/evidence.d.ts +73 -0
- package/dist/lib/result/evidence.js +422 -0
- package/dist/lib/result/render.d.ts +20 -0
- package/dist/lib/result/render.js +194 -0
- package/dist/lib/result/types.d.ts +122 -0
- package/dist/lib/result/types.js +19 -0
- package/dist/lib/run-output.d.ts +275 -0
- package/dist/lib/run-output.js +227 -0
- package/dist/lib/run-render.d.ts +101 -0
- package/dist/lib/run-render.js +183 -0
- package/dist/lib/run-wait.d.ts +192 -0
- package/dist/lib/run-wait.js +452 -0
- package/dist/lib/runs.types.d.ts +118 -367
- package/dist/lib/runs.types.js +0 -14
- package/dist/lib/secret-file.d.ts +1 -1
- package/dist/lib/secret-file.js +11 -2
- package/dist/lib/skill-nudge.d.ts +7 -27
- package/dist/lib/skill-nudge.js +9 -37
- package/dist/lib/target-path.d.ts +15 -0
- package/dist/lib/target-path.js +35 -0
- package/dist/lib/target-url-advisory.d.ts +19 -0
- package/dist/lib/target-url-advisory.js +31 -0
- package/dist/lib/target-url-preflight.d.ts +9 -0
- package/dist/lib/target-url-preflight.js +214 -106
- package/dist/lib/target-url.d.ts +8 -8
- package/dist/lib/target-url.js +14 -24
- package/dist/lib/telemetry.d.ts +35 -15
- package/dist/lib/telemetry.js +38 -9
- package/dist/lib/terminal-text.d.ts +41 -0
- package/dist/lib/terminal-text.js +127 -0
- package/dist/lib/testlist.types.d.ts +16 -8
- package/dist/lib/testlist.types.js +1 -1
- package/dist/lib/text-equality.d.ts +2 -0
- package/dist/lib/text-equality.js +5 -0
- package/dist/lib/text-file.d.ts +16 -0
- package/dist/lib/text-file.js +41 -0
- package/dist/lib/text-table.d.ts +46 -0
- package/dist/lib/text-table.js +72 -4
- package/dist/lib/ticker.d.ts +9 -2
- package/dist/lib/ticker.js +16 -3
- package/dist/lib/transport-failure.d.ts +22 -0
- package/dist/lib/transport-failure.js +126 -0
- package/dist/lib/tunnel-session.d.ts +8 -2
- package/dist/lib/tunnel-session.js +24 -11
- package/dist/lib/update-check.js +3 -2
- package/dist/lib/url-template.d.ts +43 -0
- package/dist/lib/url-template.js +151 -0
- package/dist/lib/validate.d.ts +0 -64
- package/dist/lib/validate.js +2 -131
- package/dist/lib/version-notice.js +4 -3
- package/dist/lib/wait-exit.d.ts +37 -2
- package/dist/lib/wait-exit.js +88 -30
- package/dist/lib/workspace-status.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/skills/testsprite-ci.skill.md +52 -23
- package/skills/testsprite-onboard.skill.md +70 -153
- package/skills/testsprite-verify.codex.md +54 -58
- package/skills/testsprite-verify.skill.md +189 -358
- package/dist/lib/browser.d.ts +0 -6
- package/dist/lib/browser.js +0 -54
- package/dist/lib/bundle.d.ts +0 -234
- package/dist/lib/bundle.js +0 -781
- package/dist/lib/deprecate.d.ts +0 -32
- package/dist/lib/deprecate.js +0 -39
- package/dist/lib/flaky.d.ts +0 -91
- package/dist/lib/flaky.js +0 -71
- package/dist/lib/plan-poll.d.ts +0 -171
- package/dist/lib/plan-poll.js +0 -441
- package/dist/lib/plans.types.d.ts +0 -130
- package/dist/lib/plans.types.js +0 -31
- package/dist/lib/poll.d.ts +0 -100
- package/dist/lib/poll.js +0 -290
- package/dist/lib/rate-throttle.d.ts +0 -49
- package/dist/lib/rate-throttle.js +0 -75
- package/dist/lib/run-progress.d.ts +0 -41
- package/dist/lib/run-progress.js +0 -56
- package/dist/lib/v3-advisory.d.ts +0 -55
- package/dist/lib/v3-advisory.js +0 -74
- package/schemas/plan.schema.json +0 -61
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ AI ships code in minutes — verifying it hasn't. `testsprite` opens your live a
|
|
|
44
44
|
|
|
45
45
|
[TestSprite](https://www.testsprite.com) is the AI testing platform 100,000+ teams use to test their software, frontend and backend — in the cloud, against the live product, not mocks. This repo is its official CLI.
|
|
46
46
|
|
|
47
|
-
It puts that platform in your coding agent's hands: the agent verifies every behavior it ships, and what broke comes back as **one
|
|
47
|
+
It puts that platform in your coding agent's hands: the agent verifies every behavior it ships, and what broke comes back as **one result** — the failed step, its cause and a fix — it can act on, with no dashboard scraping. Humans drive the same surface from a terminal or CI.
|
|
48
48
|
|
|
49
49
|
## ⭐️ Star the Repository
|
|
50
50
|
|
|
@@ -54,187 +54,92 @@ If you find `testsprite` useful, a GitHub Star ⭐️ would be greatly appreciat
|
|
|
54
54
|
|
|
55
55
|
## Quickstart
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
You need Node.js 20.19+ on the 20.x line, 22.13+ on 22.x, or 24 or later. [Using 0.16? Read its command reference.](https://github.com/TestSprite/testsprite-cli/blob/v0.16.0/DOCUMENTATION.md)
|
|
58
|
+
|
|
59
|
+
From your app's repository, install the CLI and run setup. It prompts for your [workspace API key](https://www.testsprite.com/dashboard-v3/settings/apikey) and installs the skills for the coding agents it detects.
|
|
58
60
|
|
|
59
61
|
```bash
|
|
60
62
|
npm install -g @testsprite/testsprite-cli
|
|
63
|
+
testsprite --version
|
|
61
64
|
testsprite setup
|
|
65
|
+
testsprite auth status
|
|
62
66
|
```
|
|
63
67
|
|
|
64
|
-
`testsprite
|
|
65
|
-
|
|
66
|
-
**Which agent it installs for.** Each of the eight supported targets — `claude`, `cursor`, `cline`, `windsurf`, `antigravity`, `kiro`, `copilot`, `codex` — lands its skill in a different place, so `setup` works out which you use: the agent calling it, if it identifies itself, together with every agent whose config is already in the project. It installs for all of them and prints what it found — in a terminal it shows you that list first, so you can accept it or narrow it before anything is written. If nothing identifies an agent, it installs for `claude` and says so — that is the one case where you want `--agent <target>` to name one yourself. Check the result any time with `testsprite agent status`.
|
|
67
|
-
|
|
68
|
-
Non-interactive (CI / onboarding scripts):
|
|
68
|
+
**Choose your project and target.** Run `testsprite project list` to find an existing project. For a new frontend project, create it and add the URL where your app is running. Replace the URL below with yours and set `PROJECT_ID` to the ID printed by `project create`.
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
|
-
|
|
71
|
+
testsprite project create --type frontend --name "Checkout"
|
|
72
|
+
PROJECT_ID=your-project-id
|
|
73
|
+
testsprite project env create "$PROJECT_ID" --name staging --url https://staging.example.com
|
|
72
74
|
```
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
> **Privacy note:** interactive runs check the npm registry at most once per 24 h to offer a "new version available" notice — package name only, never your key or data; `TESTSPRITE_NO_UPDATE_NOTIFIER=1` disables it. The backend also advertises its minimum supported CLI version — a below-floor CLI prints a one-line upgrade advisory on stderr, and a too-old client may be rejected with exit 14 (`CLIENT_TOO_OLD`). Details in [DOCUMENTATION.md → Update notice](./DOCUMENTATION.md#update-notice).
|
|
77
|
-
|
|
78
|
-
From there, the loop runs on its own — an example session, typed by the coding agent:
|
|
76
|
+
**Get your first test.** Ask the project's agent to propose coverage. If it asks a question in a text message, answer with `testsprite reply "your answer"`. For a question card, submit all the numbered answers together with `testsprite apply --answer 1=b --answer 2=a,c`. Review the proposed steps in the terminal and apply the plan when they match what you want to verify. For a backend project, attach the API specification with `--file ./openapi.yaml`.
|
|
79
77
|
|
|
80
78
|
```bash
|
|
81
|
-
|
|
82
|
-
testsprite test create --project proj_8f0f6 --type frontend \
|
|
83
|
-
--plan-from ./checkout-flow.plan.json --run --wait --output json
|
|
84
|
-
# → exits 1: the run failed
|
|
85
|
-
|
|
86
|
-
# 2 — pull ONE self-consistent failure bundle
|
|
87
|
-
testsprite test failure get test_3a9f21c7 --out ./.testsprite/failure
|
|
88
|
-
|
|
89
|
-
# 3 — the agent reads the bundle, fixes the code, then replays
|
|
90
|
-
testsprite test run test_3a9f21c7 --wait --output json
|
|
91
|
-
# → exits 0: passed. The test now lives in your durable suite.
|
|
79
|
+
testsprite plan "Verify that a guest can place an order with a test card" --project "$PROJECT_ID" --steps
|
|
92
80
|
```
|
|
93
81
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
"$schema": "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.4.0/schemas/plan.schema.json",
|
|
99
|
-
"projectId": "prj_abc123",
|
|
100
|
-
"type": "frontend",
|
|
101
|
-
"name": "Login rejects an empty password",
|
|
102
|
-
"planSteps": [
|
|
103
|
-
{
|
|
104
|
-
"type": "action",
|
|
105
|
-
"description": "Navigate to /login and submit the form with an empty password"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"type": "assertion",
|
|
109
|
-
"description": "Verify an inline error says the password is required"
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
}
|
|
82
|
+
```bash
|
|
83
|
+
testsprite apply
|
|
84
|
+
testsprite test list --project "$PROJECT_ID"
|
|
113
85
|
```
|
|
114
86
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
> The `$schema` URL above is pinned to the CLI version that generated this doc (`v0.4.0`) — `--plan-template`'s live output always pins to **your installed version** instead, which is what actually resolves. If you're reading this on a later release, run the command yourself rather than trusting this snippet verbatim.
|
|
118
|
-
|
|
119
|
-
**Don't want to write the first tests yourself?** For a deployed target, ask TestSprite to propose them. Local projects use the authored-plan flow below. `testsprite test plan generate --project <id>` explores your app (or reads the API spec you uploaded with `project docs upload`), drafts test cases, and stages them for review — nothing is written to your disk. You read the printed table and keep what you want:
|
|
87
|
+
**Run and inspect.** A project run waits for the suite when you pass `--wait`. Exit 0 means it passed. On exit 1, look for a failed or blocked row in `results[]` and copy its `resultId` to inspect the error and available evidence. If no row failed, check `runFailures` for an execution-level error such as cancellation. Without `--output json`, each run also prints a `Dashboard:` link that opens it in the Portal.
|
|
120
88
|
|
|
121
89
|
```bash
|
|
122
|
-
testsprite
|
|
123
|
-
testsprite test plan accept --project proj_8f0f6 # → real tests
|
|
124
|
-
testsprite test plan accept --project proj_8f0f6 --only prop_2 prop_5 # or just these
|
|
90
|
+
testsprite run --project "$PROJECT_ID" --wait --output json
|
|
125
91
|
```
|
|
126
92
|
|
|
127
|
-
|
|
93
|
+
```bash
|
|
94
|
+
RESULT_ID=your-result-id
|
|
95
|
+
testsprite result get "$RESULT_ID" --out ".testsprite/results/$RESULT_ID"
|
|
96
|
+
```
|
|
128
97
|
|
|
129
|
-
|
|
98
|
+
After deploying a fix, run the affected test again with `testsprite run "$TEST_ID" --wait`, using its ID from `test list`. To resume waiting for a run you already started, use its **run ID** with `testsprite run wait "$RUN_ID"`. The [scripting example](./DOCUMENTATION.md#output--scripting) shows how to extract both IDs and preserve the verdict in CI.
|
|
130
99
|
|
|
131
100
|
## Testing an environment on your machine
|
|
132
101
|
|
|
133
|
-
|
|
134
|
-
Use an API key with `run:tunnel`; the CLI names the missing scope if the key cannot open a tunnel. Existing keys receive this scope on backend v0.18.0 or later unless deliberately narrowed.
|
|
102
|
+
Start your frontend app on port 3000 and save it as the project's environment. A run on that environment opens a tunnel from this machine and waits for the cloud runner.
|
|
135
103
|
|
|
136
104
|
```bash
|
|
137
|
-
testsprite project create
|
|
138
|
-
testsprite
|
|
139
|
-
testsprite test run <test-id> # the saved loopback URL opens a tunnel and waits
|
|
140
|
-
testsprite test run <id> <id> --max-concurrency 5
|
|
141
|
-
testsprite test run --all --project <project-id>
|
|
142
|
-
# Or keep one tunnel open in terminal A (no port argument)
|
|
143
|
-
testsprite tunnel start --ttl 3600
|
|
144
|
-
# Terminal B: borrow the clientId printed above; keep terminal A running
|
|
145
|
-
testsprite test run <test-id> --tunnel-client <client-uuid>
|
|
146
|
-
testsprite tunnel list
|
|
147
|
-
testsprite tunnel stop <client-uuid>
|
|
148
|
-
# Stop every live tunnel on this account only when you intend to revoke them all
|
|
149
|
-
testsprite tunnel stop --all --confirm
|
|
105
|
+
testsprite project env create "$PROJECT_ID" --name local --url http://localhost:3000
|
|
106
|
+
testsprite run --project "$PROJECT_ID" --env local
|
|
150
107
|
```
|
|
151
108
|
|
|
152
|
-
|
|
153
|
-
Hit the tunnel limit? Run `testsprite tunnel list`, then `testsprite tunnel stop <client-uuid>` for an unused binding, or `testsprite tunnel stop --all --confirm` to revoke them all. An older server without listing returns exit 4; a key without `run:tunnel` returns exit 3.
|
|
154
|
-
A second `tunnel start` or process using the same credential takes over, and the first exits **10**.
|
|
155
|
-
An environment is one origin (scheme, host and port) plus its sign-in configuration. Frontend runs automatically open a tunnel for a saved `localhost`, `127.0.0.1` or `[::1]` URL: `test run`, `test create --run`, `test create-batch --run` and `testlist run` use this behavior. `--env <name>` selects the environment; omit it for the project default. `--no-wait` disables automatic tunnels; drop it to run through one. If environment reads are unavailable, the command keeps the previous server behavior. Several fresh-run IDs require a tunnel; public targets retain the exit-5 refusal. A named public environment used against a local origin prints a sign-in advisory on stderr. Test-list runs share one timeout including capacity waits and require the server to confirm tunnel support; an older server triggers a cancellation attempt and a clear error.
|
|
156
|
-
|
|
157
|
-
`--local <port>` saves new project and environment URLs as `http://localhost:<port>`. Use `--url http://127.0.0.1:<port>` or `--url http://[::1]:<port>` when the host matters (`--local-host` is deprecated). Dev servers can be slow through a tunnel, so for heavy apps test a production build (`npm run build` plus your framework's preview or start command).
|
|
158
|
-
|
|
159
|
-
The tunnel uses verified TLS. On a network that re-signs TLS, set `NODE_EXTRA_CA_CERTS=/path/to/ca.pem` to your organisation's root CA. If the tunnel keeps failing to connect for 60 seconds, the command exits **10**, and an owned run is cancelled and refunded.
|
|
160
|
-
|
|
161
|
-
On an owned tunnel, Ctrl-C or a timeout cancels unfinished runs by default, and a run cancelled before it finishes is refunded. A run on a borrowed `--tunnel-client` detaches on Ctrl-C instead. Local projects skip plan generation, so write plans with `test create --plan-from`. Portal runs stay blocked, at no charge, until the project has a public URL. See [the local-testing reference](./DOCUMENTATION.md#local-frontend-testing-and-tunnels) for the details.
|
|
109
|
+
The project's agent explores the app through the same kind of tunnel: ask it with `testsprite plan`, and when it asks for a tunnel, run `testsprite tunnel start` in another terminal and `testsprite reply "The tunnel is running."`. Review and apply the test plan, then run with `--env local`. An ordinary Ctrl-C detaches a public run. With a tunnel this command opened, Ctrl-C cancels unfinished work by default and closes the tunnel. [Local frontend testing and tunnels](./DOCUMENTATION.md#local-frontend-testing-and-tunnels)
|
|
162
110
|
|
|
163
111
|
## Commands
|
|
164
112
|
|
|
165
|
-
|
|
|
166
|
-
|
|
|
167
|
-
|
|
|
168
|
-
|
|
|
169
|
-
|
|
|
170
|
-
|
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
| | `test result` | Latest result; `--history` lists a test's prior runs (ENV column; `--env <name>` filters by environment) |
|
|
178
|
-
| | `test failure get` | The agent entry point: one self-contained latest-failure bundle |
|
|
179
|
-
| | `test failure summary` | One-screen triage card (no media download) |
|
|
180
|
-
| | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift |
|
|
181
|
-
| | `test open` | Open a test in the dashboard (`--no-browser` prints the URL only) |
|
|
182
|
-
| **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials |
|
|
183
|
-
| | `test create` / `test create-batch` | Create a test (or bulk-create from a plan file); `--step-timeout <ms>` sets a per-test timeout; dependency flags wire BE metadata |
|
|
184
|
-
| | `test update` / `test delete` / `test delete-batch` | Edit metadata, set/clear the step timeout (`--step-timeout` / `--clear-step-timeout`), or permanently delete (`--confirm` required) |
|
|
185
|
-
| | `test code put` | Replace generated code (etag-guarded) |
|
|
186
|
-
| | `test plan put` | Replace a frontend test's plan-steps |
|
|
187
|
-
| | `project create` / `project update` / `project delete` | Manage projects; `--test-id-attributes <list>` registers the app's own test-hook attributes (priority order) for exported locators, `--clear-test-id-attributes` reverts; `delete` removes a project and everything under it (`--confirm` required, no restore window) |
|
|
188
|
-
| | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro) |
|
|
189
|
-
| | `project env list` / `get` / `create` / `update` / `delete` / `set-default` | Manage a project's named URL + login bundles. `get` shows safe login details and variables; `create` / `update` accept repeatable `--var KEY=VALUE` (plain text — not for secrets, use `--username`/`--password`), and `update --clear-credentials` disables account login. Use `--url http://localhost:<port>` or `--local <port>` for an app on this machine; runs open its tunnel automatically. `delete` refuses the default environment. |
|
|
190
|
-
| | `project sign-in get` / `set` | Inspect or change an environment's app sign-in mode; choose OTP with `project env create --sign-in otp`. SSO selection requires the per-account manual-login feature flag; capture the session in the Portal. |
|
|
191
|
-
| **Generate** | `test plan generate` | Ask TestSprite to propose test cases for a project — proposals are staged server-side for review, never written to disk; only the stages the project is missing actually run |
|
|
192
|
-
| | `test plan accept` | Turn staged proposals into real tests — all of them, or a subset with `--only` |
|
|
193
|
-
| | `project docs upload` | Upload an API spec or PRD as a project source, so generation has something to read |
|
|
194
|
-
| **Run** | `test run` | Trigger a fresh run; saved loopback environments open a tunnel and wait automatically; `--wait` blocks until terminal; several ids or `--all --project <id>` run a batch in wave order (`--status`/`--filter` narrow `--all`; `--skip-dependencies` for backend); `--env <name>` runs against a named environment. |
|
|
195
|
-
| | `test rerun` | **Deprecated** — use `test run` (same flags; several ids and `--all --status` are supported there). Removed in 0.17.0. |
|
|
196
|
-
| | `test flaky` | **Deprecated** — no replacement; run `test run <id>` again to sample a test. Removed in 0.17.0. |
|
|
197
|
-
| | `test wait` | Block on one or more `runId`s until terminal |
|
|
198
|
-
| | `test cancel` | Cancel one or more in-flight runs (Ctrl-C during `--wait` only detaches, `cancel` is the real stop — except a run with an owned tunnel, which Ctrl-C cancels by default) |
|
|
199
|
-
| | `test artifact get` | Download the failure bundle for a specific `runId` |
|
|
200
|
-
| **Test lists** | `testlist list` / `testlist get` | Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only) |
|
|
201
|
-
| | `testlist create` / `update` / `add` / `remove` / `delete` | Manage a list and its cases; `--project-env <id>:<env>` pins environments; `delete` requires `--confirm` |
|
|
202
|
-
| | `testlist run` | Run every case (or a `--case` subset) through its pinned environment; loopback environments open a tunnel automatically; `--wait` polls all runs, `--report junit` writes a CI sidecar |
|
|
203
|
-
| **Schedule** | `schedule list` / `schedule get` | List schedules visible to the key / fetch one by id, including a project schedule's pinned or inherited environment (status is `ENABLED`, `PAUSED`, or `AUTO_PAUSED` after repeated failures) |
|
|
204
|
-
| | `schedule create` | Run a project or test list on a 5-field cron; `--env <name>` pins a project schedule, while omission inherits the live default; states frequency and estimated cost |
|
|
205
|
-
| | `schedule update` | Retime or rename a schedule, change recipients, pin a project schedule with `--env <name>`, or `--pause` / `--resume` it |
|
|
206
|
-
| | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window) |
|
|
207
|
-
| | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts |
|
|
208
|
-
| **CI** | `ci init github` | Write a GitHub Actions PR gate that runs `ci run` against each pull request's preview deployment — one placeholder step to fill in: your platform deploys every PR (`on: deployment_status`) or the workflow deploys |
|
|
209
|
-
| | `ci run` | The CI gate in one command: every project test (or `--filter`) against `--target-url`, signed in as `--env`, in a temporary `github-pr-<N>` environment, one execution; waits and exits with the verdict. Job summary = the execution report (the GitHub App comment); `--summary-file`, `--report junit`, step outputs |
|
|
210
|
-
| **Agent** | `agent install` / `agent list` / `agent status` | Add, list, or health-check coding-agent skills (pure-local): `claude`, `codex`, `cursor`, `cline`, `antigravity`, `kiro`, `windsurf`, `copilot` |
|
|
211
|
-
| **CI** | `ci init github` | Write a GitHub Actions workflow that runs your tests |
|
|
212
|
-
| | `ci doctor` | Check that deployment events reach this repo |
|
|
213
|
-
| | `ci connect` | Link your deploy platform (Vercel) to this repo |
|
|
214
|
-
| **Tunnel** | `tunnel start` / `list` / `status` / `stop` | Hold one tunnel open for several `--local` runs; list, check, or stop tunnels |
|
|
215
|
-
|
|
216
|
-
> The earlier command names — `init`, `auth configure`, `auth whoami`, `auth logout` — still work as hidden, deprecated aliases (each prints a one-line notice pointing at the new name), so existing scripts keep running. `auth configure` now runs the full `setup` (it also installs the skill).
|
|
217
|
-
|
|
218
|
-
📚 **Full reference — every command, flag, and example:** [DOCUMENTATION.md](./DOCUMENTATION.md), including [configuration & profiles](./DOCUMENTATION.md#configuration), [scripting](./DOCUMENTATION.md#output--scripting), and [exit codes](./DOCUMENTATION.md#exit-codes).
|
|
219
|
-
|
|
220
|
-
Exit codes: `0` success, `1` failure (including a run that did not pass), `7` timeout, `12` insufficient credits, `13` feature gated, `14` CLI too old; the rest are in [DOCUMENTATION.md](./DOCUMENTATION.md#exit-codes).
|
|
113
|
+
| Task | Command |
|
|
114
|
+
| ------------------------------------------------ | -------------------------------------------------------------------------------------- |
|
|
115
|
+
| Check credentials or install coding-agent skills | `auth status`, `setup`, `agent status` |
|
|
116
|
+
| Manage a project and its targets | `project list`, `project create`, `project env` |
|
|
117
|
+
| Propose tests, review them and save them | `plan`, `status`, `reply`, `reject`, `apply` |
|
|
118
|
+
| Find the ID or steps of a saved test | `test list --project <id>`, `test get <test-id>` |
|
|
119
|
+
| Launch a project, named tests or a saved list | `run --project <id>`, `run <test-id...>`, `run --testlist <list-id>` |
|
|
120
|
+
| Follow or cancel an execution | `run wait <run-id...>`, `run cancel <run-id...>` |
|
|
121
|
+
| Read results and download evidence | `result list --run <run-id>`, `result list --test <test-id>`, `result get <result-id>` |
|
|
122
|
+
| Automate scheduled tests or a pull-request gate | `schedule`, `ci init github`, `ci run` |
|
|
123
|
+
|
|
124
|
+
For test lists, tunnel management, usage, diagnostics, profiles and exit codes, see the [command reference](./DOCUMENTATION.md#command-reference). To migrate shell scripts or previously installed agent skills from 0.16, see [Upgrading from 0.16](./DOCUMENTATION.md#upgrading-from-016).
|
|
221
125
|
|
|
222
126
|
## Why a CLI for coding agents?
|
|
223
127
|
|
|
224
128
|
- 🧪 **Tests like a real user.** Runs against a live browser or API in the cloud — real clicks, real navigation, real assertions. Not a mock.
|
|
225
|
-
- 🤖 **Agent-shaped output.** `test
|
|
226
|
-
-
|
|
227
|
-
-
|
|
228
|
-
-
|
|
129
|
+
- 🤖 **Agent-shaped output.** `run` names the run (`runId`) and each test's result in it (`resultId`). `result get <result-id>` returns that one result — the verdict, the error, its cause and fix, the failed step with its screenshot, a backend test's traceback and output, and every step — and `--out <dir>` downloads its video and each step's screenshot and page. The agent reads the run it just started, never an older one.
|
|
130
|
+
- **Whole-run results.** Every selector and `run wait` use the same JSON: `runs[]` describes executions, `results[]` lists individual results, and `summary` counts outcomes when waiting. A complete run can fail. Only a timeout or interruption that leaves work unfinished adds `partial: true`. A cancelled execution fails even if its existing results passed. Read detailed evidence with `result get <result-id>`.
|
|
131
|
+
- ♻️ **A loop, not a one-shot.** `plan → apply → run → result get → fix → run` — every pass is banked, not thrown away.
|
|
132
|
+
- 📐 **Scriptable & deterministic.** Stable `--output json` contract, predictable [exit codes](./DOCUMENTATION.md#exit-codes), and a `--dry-run` for previewing commands. A credentialed run preview can read environment metadata to determine whether it would open a tunnel.
|
|
133
|
+
- 🚦 **CI-native.** `testsprite ci init github` writes a PR gate; `testsprite ci run --project "$PROJECT_ID" --env <name> --target-url "$PREVIEW_URL"` tests each pull request's preview deployment as one run and exits with the verdict. The job summary is the execution report — the same content as the GitHub App's PR comment — plus `::error::` annotations on the checks tab, step outputs, `--summary-file` for a machine summary and `--report junit` for a JUnit sidecar. In any other CI, `testsprite ci run --project <id> --env <name> --target-url <url>` still runs the suite as one run and makes the exit code the verdict — the pull-request context, draft skip and job summary are GitHub Actions only. [Details →](./DOCUMENTATION.md#continuous-integration)
|
|
229
134
|
- 🔌 **One command to onboard your agent.** `testsprite setup` drops ready-made skill files into your repo — for the agents it detects you using — so your coding agent knows how to drive the loop on its own.
|
|
230
135
|
|
|
231
136
|
## How it works
|
|
232
137
|
|
|
233
138
|
Every time your agent changes code, it asks one question: **is this behavior already covered by the suite?**
|
|
234
139
|
|
|
235
|
-
- **Not yet covered** → `testsprite
|
|
236
|
-
- **Already covered** → `testsprite
|
|
237
|
-
- **Something fails** → `testsprite
|
|
140
|
+
- **Not yet covered** → `testsprite plan` — the project's agent writes a test for the new behavior; `testsprite apply` saves it, then run it.
|
|
141
|
+
- **Already covered** → `testsprite run --project <project-id> --wait` — run the existing tests, so nothing that used to work breaks silently.
|
|
142
|
+
- **Something fails** → `testsprite result get <result-id>` — the failed step, its cause and a fix; the agent fixes the code and runs again.
|
|
238
143
|
|
|
239
144
|
Every pass is banked into a durable suite, so coverage compounds as the project grows — a lasting record of every requirement it has ever gotten right, far bigger than any context window.
|
|
240
145
|
|
|
@@ -242,20 +147,20 @@ Every pass is banked into a durable suite, so coverage compounds as the project
|
|
|
242
147
|
flowchart TD
|
|
243
148
|
A["🤖 Your coding agent<br/>Claude Code · Codex · Antigravity · Kimi · Cursor · Trae …"]
|
|
244
149
|
D{"behavior already<br/>covered by the suite?"}
|
|
245
|
-
B["<b>testsprite
|
|
246
|
-
R["<b>testsprite
|
|
150
|
+
B["<b>testsprite plan → apply</b><br/>the project's agent writes a test<br/>for the new behavior"]
|
|
151
|
+
R["<b>testsprite run --project <project-id> --wait</b><br/>run the existing tests"]
|
|
247
152
|
C{{"☁️ TestSprite testing agent<br/>runs the test like a real user against<br/>real browsers & real APIs on Cloud"}}
|
|
248
|
-
F["<b>testsprite
|
|
153
|
+
F["<b>testsprite result get</b><br/>one test's result in the run:<br/>failed step · screenshots · video ·<br/>cause · fix"]
|
|
249
154
|
S[("📚 Durable integration suite<br/>grows with every pass")]
|
|
250
155
|
|
|
251
156
|
A -->|"writes / changes code"| D
|
|
252
157
|
D -->|"no — new behavior"| B
|
|
253
158
|
D -->|"yes"| R
|
|
254
|
-
B -->
|
|
159
|
+
B --> R
|
|
255
160
|
R --> C
|
|
256
161
|
C -->|"pass ✅"| S
|
|
257
162
|
C -->|"fail ❌"| F
|
|
258
|
-
F -->|"agent reads the
|
|
163
|
+
F -->|"agent reads the result<br/>& fixes the code"| A
|
|
259
164
|
S -.->|"defines what's covered"| D
|
|
260
165
|
```
|
|
261
166
|
|
|
@@ -272,7 +177,7 @@ That's the point of all of this: you no longer need the biggest, most expensive
|
|
|
272
177
|
- 📚 **CLI reference** — [DOCUMENTATION.md](./DOCUMENTATION.md)
|
|
273
178
|
- 🌐 **Platform docs** — [docs.testsprite.com](https://docs.testsprite.com)
|
|
274
179
|
- 🐛 **Issues & feature requests** — [GitHub issues](https://github.com/TestSprite/testsprite-cli/issues)
|
|
275
|
-
- 💬 **Quick questions** — [Discord](https://discord.gg/GXWFjCe4an), or `testsprite --help` / `testsprite
|
|
180
|
+
- 💬 **Quick questions** — [Discord](https://discord.gg/GXWFjCe4an), or `testsprite --help` / `testsprite run --help` right in your terminal
|
|
276
181
|
- 📝 **Changelog** — [CHANGELOG.md](./CHANGELOG.md)
|
|
277
182
|
|
|
278
183
|
## Contributing
|
package/dist/commands/agent.d.ts
CHANGED
|
@@ -71,10 +71,12 @@ export declare function runList(opts: CommonOptions, deps?: AgentDeps): Promise<
|
|
|
71
71
|
* - 'unmarked' : artifact present but carries no testsprite-skill marker
|
|
72
72
|
* (installed before markers existed), or the landing path is
|
|
73
73
|
* occupied by a non-regular file (never followed).
|
|
74
|
-
* - 'stale' : marker present, but its hash differs from the current
|
|
75
|
-
* canonical body
|
|
76
|
-
*
|
|
77
|
-
*
|
|
74
|
+
* - 'stale' : marker present, but either its hash differs from the current
|
|
75
|
+
* canonical body, or the bytes are exactly a legacy (v0.15.0)
|
|
76
|
+
* render of that body: a re-install would change the content
|
|
77
|
+
* and repair it without --force. Edits on top of an OLD install
|
|
78
|
+
* also read stale (older renders cannot be reproduced); the
|
|
79
|
+
* remedy is the same re-install.
|
|
78
80
|
* - 'modified' : marker hash matches the current body, but the artifact bytes
|
|
79
81
|
* differ from the canonical render carrying that same marker
|
|
80
82
|
* line: the user edited the artifact after install.
|
|
@@ -101,6 +103,12 @@ interface StatusOptions extends CommonOptions {
|
|
|
101
103
|
* (exit 0) when every row is 'ok' or 'absent'; throws CLIError exit 1 when any
|
|
102
104
|
* row is stale/modified/unmarked/corrupt, so the command can gate CI.
|
|
103
105
|
*/
|
|
106
|
+
/**
|
|
107
|
+
* Each target's state for each default skill under `root`: what `agent
|
|
108
|
+
* status` prints and `doctor` reads. Absent artifacts never touch the skill
|
|
109
|
+
* assets.
|
|
110
|
+
*/
|
|
111
|
+
export declare function skillStates(root: string, agentFs?: AgentFs): Promise<StatusResult[]>;
|
|
104
112
|
export declare function runStatus(opts: StatusOptions, deps?: AgentDeps): Promise<void>;
|
|
105
113
|
export declare function createAgentCommand(deps?: AgentDeps): Command;
|
|
106
114
|
export {};
|
package/dist/commands/agent.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
+
import { equalIgnoringCrlf } from '../lib/text-equality.js';
|
|
4
5
|
import { resolveProfileName } from '../lib/config.js';
|
|
5
6
|
import { CLIError, localValidationError } from '../lib/errors.js';
|
|
6
7
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
8
|
+
import { inspectTargetPath } from '../lib/target-path.js';
|
|
7
9
|
import { promptText } from '../lib/prompt.js';
|
|
8
10
|
import { FALLBACK_TARGET, resolveAgentTargets } from '../lib/agent-detect.js';
|
|
9
|
-
import { TARGETS, SKILLS, DEFAULT_SKILLS, MARKER_SKILL_SEPARATOR, pathFor, ownFileBodyFor, bodyHash12, buildCodexAggregate, buildSkillMarker, parseSkillMarker, renderForTarget, renderOwnFileWithMarker, MANAGED_SECTION_BEGIN, MANAGED_SECTION_END, } from '../lib/agent-targets.js';
|
|
11
|
+
import { TARGETS, SKILLS, DEFAULT_SKILLS, MARKER_SKILL_SEPARATOR, pathFor, ownFileBodyFor, bodyHash12, buildCodexAggregate, buildSkillMarker, parseSkillMarker, renderForTarget, renderOwnFileWithMarker, isLegacyOwnFileRender, MANAGED_SECTION_BEGIN, MANAGED_SECTION_END, } from '../lib/agent-targets.js';
|
|
12
|
+
import { terminalSafeWriter } from '../lib/terminal-text.js';
|
|
10
13
|
// ---------------------------------------------------------------------------
|
|
11
14
|
// Constants
|
|
12
15
|
// ---------------------------------------------------------------------------
|
|
@@ -43,44 +46,6 @@ const defaultAgentFs = {
|
|
|
43
46
|
// ---------------------------------------------------------------------------
|
|
44
47
|
// Path safety
|
|
45
48
|
// ---------------------------------------------------------------------------
|
|
46
|
-
/**
|
|
47
|
-
* Walk each component of `relPath` beneath `root`, refusing to traverse or
|
|
48
|
-
* write through a symlink. `fs.mkdir`/`writeFile` follow symlinks, so a planted
|
|
49
|
-
* symlink at any existing path component (e.g. `.claude` -> /etc, or the final
|
|
50
|
-
* `SKILL.md` -> ~/.bashrc) could place or clobber files outside `--dir`. The
|
|
51
|
-
* lexical containment guard in `runInstall` is a string compare and cannot see
|
|
52
|
-
* this; only an `lstat`-per-component walk can. Fail-closed: any symlink is
|
|
53
|
-
* rejected (exit 5).
|
|
54
|
-
*
|
|
55
|
-
* Returns the target's `{ isFile }` when it already exists, or `null` when it
|
|
56
|
-
* (or any ancestor) does not yet exist — in which case the missing tail is
|
|
57
|
-
* created fresh and cannot be a pre-planted symlink. A small TOCTOU window
|
|
58
|
-
* remains between this check and the write; that is acceptable for a local,
|
|
59
|
-
* single-user CLI and avoids non-portable O_NOFOLLOW / rename gymnastics.
|
|
60
|
-
*/
|
|
61
|
-
async function inspectTargetPath(agentFs, root, relPath) {
|
|
62
|
-
const segments = relPath.split(/[/\\]+/).filter(Boolean);
|
|
63
|
-
let current = root;
|
|
64
|
-
let finalIsFile = false;
|
|
65
|
-
for (const [i, seg] of segments.entries()) {
|
|
66
|
-
current = path.join(current, seg);
|
|
67
|
-
const ls = await agentFs.lstat(current);
|
|
68
|
-
if (ls === null) {
|
|
69
|
-
// This component and everything below it does not exist yet.
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
if (ls.isSymbolicLink) {
|
|
73
|
-
const shown = segments.slice(0, i + 1).join('/');
|
|
74
|
-
throw new CLIError(`refusing to write through a symlink: "${shown}" — installing here could place files outside --dir. Remove the symlink or choose a different --dir.`, 5);
|
|
75
|
-
}
|
|
76
|
-
if (i < segments.length - 1 && ls.isFile) {
|
|
77
|
-
const shown = segments.slice(0, i + 1).join('/');
|
|
78
|
-
throw new CLIError(`cannot create ${relPath}: "${shown}" exists and is not a directory.`, 5);
|
|
79
|
-
}
|
|
80
|
-
finalIsFile = ls.isFile;
|
|
81
|
-
}
|
|
82
|
-
return { isFile: finalIsFile };
|
|
83
|
-
}
|
|
84
49
|
/**
|
|
85
50
|
* Back up the current bytes at `abs` next to it without clobbering any existing
|
|
86
51
|
* backup or writing through a symlink. Exclusive create (`wx`) fails with
|
|
@@ -192,7 +157,7 @@ function classifySection(existing, section) {
|
|
|
192
157
|
const before = existing.slice(0, beginByteIdx);
|
|
193
158
|
const after = existing.slice(endOfEndByte + trailingNewline);
|
|
194
159
|
const currentSection = existing.slice(beginByteIdx, endOfEndByte + trailingNewline);
|
|
195
|
-
if (currentSection
|
|
160
|
+
if (equalIgnoringCrlf(currentSection, section)) {
|
|
196
161
|
return { kind: 'unchanged' };
|
|
197
162
|
}
|
|
198
163
|
return { kind: 'replace', existing, before, after };
|
|
@@ -255,7 +220,7 @@ function makeOwnFileBodyResolver() {
|
|
|
255
220
|
// ---------------------------------------------------------------------------
|
|
256
221
|
export async function runInstall(opts, deps = {}) {
|
|
257
222
|
const agentFs = deps.fs ?? defaultAgentFs;
|
|
258
|
-
const stderrFn = deps.stderr
|
|
223
|
+
const stderrFn = terminalSafeWriter(deps.stderr);
|
|
259
224
|
const out = makeOutput(opts.output, deps);
|
|
260
225
|
// 1. Parse targets
|
|
261
226
|
const rawTargets = opts.target
|
|
@@ -564,24 +529,30 @@ export async function runInstall(opts, deps = {}) {
|
|
|
564
529
|
}
|
|
565
530
|
else {
|
|
566
531
|
const existing = await agentFs.readFile(abs);
|
|
567
|
-
|
|
532
|
+
// A v0.15.0 render whose canonical body is unchanged is a stale
|
|
533
|
+
// install, not a user edit: repair it without --force.
|
|
534
|
+
const legacyRender = isLegacyOwnFileRender(t, skill, existing);
|
|
535
|
+
if (equalIgnoringCrlf(existing, content)) {
|
|
568
536
|
// Byte-identical — skip
|
|
569
537
|
results.push({ target: t, path: relPath, action: 'skipped', skills: [skill] });
|
|
570
538
|
}
|
|
571
|
-
else if (!opts.force) {
|
|
539
|
+
else if (!opts.force && !legacyRender) {
|
|
572
540
|
// Differs and no --force → blocked
|
|
573
541
|
results.push({ target: t, path: relPath, action: 'blocked', skills: [skill] });
|
|
574
542
|
}
|
|
575
543
|
else {
|
|
576
|
-
//
|
|
577
|
-
// (never clobbering an existing backup or following a symlink)
|
|
578
|
-
//
|
|
579
|
-
//
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
544
|
+
// Overwrite. With --force, back up the current bytes to a fresh slot
|
|
545
|
+
// (never clobbering an existing backup or following a symlink) first;
|
|
546
|
+
// a legacy render needs no backup because nothing of the user's is
|
|
547
|
+
// lost. The overwrite itself can follow a symlink swapped in after the
|
|
548
|
+
// check — an accepted TOCTOU residual for a local, single-user CLI.
|
|
549
|
+
if (opts.force) {
|
|
550
|
+
const backupPath = await writeBackup(agentFs, abs, existing);
|
|
551
|
+
if (opts.output === 'text') {
|
|
552
|
+
stderrFn(`backed up ${relPath} to ${path.relative(root, backupPath)}`);
|
|
553
|
+
}
|
|
584
554
|
}
|
|
555
|
+
await agentFs.writeFile(abs, content);
|
|
585
556
|
results.push({ target: t, path: relPath, action: 'updated', skills: [skill] });
|
|
586
557
|
}
|
|
587
558
|
}
|
|
@@ -635,7 +606,7 @@ function agentDisplayName(target, status) {
|
|
|
635
606
|
}
|
|
636
607
|
export async function runList(opts, deps = {}) {
|
|
637
608
|
const out = makeOutput(opts.output, deps);
|
|
638
|
-
const stderrFn = deps.stderr
|
|
609
|
+
const stderrFn = terminalSafeWriter(deps.stderr);
|
|
639
610
|
// One row per (target × default skill). Own-file targets land each skill at a
|
|
640
611
|
// distinct path; the codex managed-section target merges all skills into the
|
|
641
612
|
// single AGENTS.md (so every codex row shares that path — truthful, since both
|
|
@@ -699,7 +670,13 @@ async function classifyOwnFileState(agentFs, abs, target, skill, canonicalBody)
|
|
|
699
670
|
// render carrying its own marker line, so a marker whose version string lags
|
|
700
671
|
// behind an unchanged body still reads ok.
|
|
701
672
|
const reRender = renderOwnFileWithMarker(target, skill, marker.line, body);
|
|
702
|
-
|
|
673
|
+
if (equalIgnoringCrlf(existing, reRender))
|
|
674
|
+
return 'ok';
|
|
675
|
+
// v0.15.0 wrote the same body with an unquoted frontmatter description; that
|
|
676
|
+
// is a stale install a plain re-install repairs, not a user edit.
|
|
677
|
+
if (isLegacyOwnFileRender(target, skill, existing, body))
|
|
678
|
+
return 'stale';
|
|
679
|
+
return 'modified';
|
|
703
680
|
}
|
|
704
681
|
/**
|
|
705
682
|
* Classify the codex managed section per skill. The section is ONE artifact
|
|
@@ -765,16 +742,12 @@ async function classifyManagedSectionStates(agentFs, abs) {
|
|
|
765
742
|
* (exit 0) when every row is 'ok' or 'absent'; throws CLIError exit 1 when any
|
|
766
743
|
* row is stale/modified/unmarked/corrupt, so the command can gate CI.
|
|
767
744
|
*/
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
throw localValidationError('dir', 'must not be empty');
|
|
775
|
-
}
|
|
776
|
-
const dir = opts.dir !== undefined ? opts.dir.trim() : (deps.cwd ?? process.cwd());
|
|
777
|
-
const root = path.resolve(dir);
|
|
745
|
+
/**
|
|
746
|
+
* Each target's state for each default skill under `root`: what `agent
|
|
747
|
+
* status` prints and `doctor` reads. Absent artifacts never touch the skill
|
|
748
|
+
* assets.
|
|
749
|
+
*/
|
|
750
|
+
export async function skillStates(root, agentFs = defaultAgentFs) {
|
|
778
751
|
// The SAME resolver the installer stamps its marker hashes from — a
|
|
779
752
|
// separate copy here is exactly how install and status end up disagreeing.
|
|
780
753
|
const ownFileBodyFor = makeOwnFileBodyResolver();
|
|
@@ -800,6 +773,18 @@ export async function runStatus(opts, deps = {}) {
|
|
|
800
773
|
});
|
|
801
774
|
}
|
|
802
775
|
}
|
|
776
|
+
return results;
|
|
777
|
+
}
|
|
778
|
+
export async function runStatus(opts, deps = {}) {
|
|
779
|
+
const agentFs = deps.fs ?? defaultAgentFs;
|
|
780
|
+
const out = makeOutput(opts.output, deps);
|
|
781
|
+
// An explicit but empty --dir must not silently resolve to cwd
|
|
782
|
+
// (path.resolve('') === cwd).
|
|
783
|
+
if (opts.dir !== undefined && opts.dir.trim() === '') {
|
|
784
|
+
throw localValidationError('dir', 'must not be empty');
|
|
785
|
+
}
|
|
786
|
+
const dir = opts.dir !== undefined ? opts.dir.trim() : (deps.cwd ?? process.cwd());
|
|
787
|
+
const results = await skillStates(path.resolve(dir), agentFs);
|
|
803
788
|
out.print(results, data => {
|
|
804
789
|
const items = data;
|
|
805
790
|
const header = `${'TARGET'.padEnd(14)} ${'SKILL'.padEnd(20)} ${'STATE'.padEnd(10)} PATH`;
|
package/dist/commands/auth.d.ts
CHANGED
|
@@ -20,21 +20,17 @@ export interface MeResponse {
|
|
|
20
20
|
/** Human-readable display name for the bound account. Absent-safe (dogfood L1866). */
|
|
21
21
|
displayName?: string;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Legacy per-user billing projections. Absent-safe; superseded by
|
|
29
|
-
* `activeOrg` when both are present. Declared so shared fixtures typed as
|
|
30
|
-
* `MeResponse` can carry them (the `usage` command has its own richer view).
|
|
23
|
+
* The org wallet flattened (`credits` = `activeOrg.remaining`, `subPlan` =
|
|
24
|
+
* `activeOrg.plan`); present iff `activeOrg` is. Declared so shared fixtures
|
|
25
|
+
* typed as `MeResponse` can carry them (the `usage` command renders the
|
|
26
|
+
* wallet from `activeOrg`).
|
|
31
27
|
*/
|
|
32
28
|
credits?: number;
|
|
33
29
|
subPlan?: string;
|
|
34
30
|
creditsPerRun?: number;
|
|
35
31
|
/**
|
|
36
32
|
* The caller's organization (org-based billing subject). Absent-safe:
|
|
37
|
-
* rendered as a single `org:` line when present
|
|
33
|
+
* rendered as a single `org:` line when present.
|
|
38
34
|
*/
|
|
39
35
|
activeOrg?: {
|
|
40
36
|
id: string;
|
|
@@ -80,7 +76,7 @@ export interface AuthDeps {
|
|
|
80
76
|
* it is sent as the `X-CLI-Command` request header on the key-validation
|
|
81
77
|
* `GET /me` so the backend can attribute the call for product analytics —
|
|
82
78
|
* e.g. `init` is counted as `cli.initialized` instead of the generic
|
|
83
|
-
* `cli.session_started`.
|
|
79
|
+
* `cli.session_started`. Left unset, no header is sent.
|
|
84
80
|
* Advisory only: it never changes behavior, and the backend honors only a
|
|
85
81
|
* known allowlist value.
|
|
86
82
|
*/
|