@testsprite/testsprite-cli 0.7.0 → 0.9.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.
Files changed (74) hide show
  1. package/README.md +62 -45
  2. package/dist/commands/agent.d.ts +3 -0
  3. package/dist/commands/agent.js +79 -10
  4. package/dist/commands/ci.d.ts +88 -0
  5. package/dist/commands/ci.js +432 -0
  6. package/dist/commands/doctor.js +100 -1
  7. package/dist/commands/init.d.ts +45 -2
  8. package/dist/commands/init.js +198 -29
  9. package/dist/commands/project.d.ts +78 -0
  10. package/dist/commands/project.js +439 -5
  11. package/dist/commands/test.d.ts +193 -4
  12. package/dist/commands/test.js +1948 -398
  13. package/dist/commands/testlist.js +15 -9
  14. package/dist/commands/tunnel.d.ts +72 -0
  15. package/dist/commands/tunnel.js +367 -0
  16. package/dist/index.js +107 -38
  17. package/dist/lib/agent-detect.d.ts +53 -0
  18. package/dist/lib/agent-detect.js +198 -0
  19. package/dist/lib/dry-run/samples.d.ts +9 -0
  20. package/dist/lib/dry-run/samples.js +116 -0
  21. package/dist/lib/gh-output.d.ts +7 -0
  22. package/dist/lib/gh-output.js +50 -7
  23. package/dist/lib/http.d.ts +104 -0
  24. package/dist/lib/http.js +126 -7
  25. package/dist/lib/interrupt.d.ts +38 -13
  26. package/dist/lib/interrupt.js +130 -15
  27. package/dist/lib/local-target.d.ts +95 -0
  28. package/dist/lib/local-target.js +184 -0
  29. package/dist/lib/plan-poll.d.ts +171 -0
  30. package/dist/lib/plan-poll.js +442 -0
  31. package/dist/lib/plans.types.d.ts +130 -0
  32. package/dist/lib/plans.types.js +31 -0
  33. package/dist/lib/poll-support.d.ts +26 -0
  34. package/dist/lib/poll-support.js +65 -0
  35. package/dist/lib/poll.d.ts +1 -0
  36. package/dist/lib/poll.js +2 -40
  37. package/dist/lib/response-schemas.d.ts +13 -0
  38. package/dist/lib/response-schemas.js +46 -0
  39. package/dist/lib/run-progress.d.ts +41 -0
  40. package/dist/lib/run-progress.js +56 -0
  41. package/dist/lib/runs.types.d.ts +50 -0
  42. package/dist/lib/skill-nudge.d.ts +13 -5
  43. package/dist/lib/skill-nudge.js +40 -14
  44. package/dist/lib/target-url-preflight.js +3 -3
  45. package/dist/lib/target-url.d.ts +54 -8
  46. package/dist/lib/target-url.js +274 -68
  47. package/dist/lib/telemetry.d.ts +11 -0
  48. package/dist/lib/telemetry.js +1 -0
  49. package/dist/lib/ticker.d.ts +8 -0
  50. package/dist/lib/ticker.js +3 -0
  51. package/dist/lib/tunnel-session.d.ts +138 -0
  52. package/dist/lib/tunnel-session.js +249 -0
  53. package/dist/lib/tunnel.types.d.ts +54 -0
  54. package/dist/lib/tunnel.types.js +8 -0
  55. package/dist/vendor/tunnel-client/client.d.ts +82 -0
  56. package/dist/vendor/tunnel-client/client.js +924 -0
  57. package/dist/vendor/tunnel-client/config.d.ts +49 -0
  58. package/dist/vendor/tunnel-client/config.js +50 -0
  59. package/dist/vendor/tunnel-client/index.d.ts +9 -0
  60. package/dist/vendor/tunnel-client/index.js +9 -0
  61. package/dist/vendor/tunnel-client/lodash-lite.d.ts +14 -0
  62. package/dist/vendor/tunnel-client/lodash-lite.js +24 -0
  63. package/dist/vendor/tunnel-client/protocol.d.ts +60 -0
  64. package/dist/vendor/tunnel-client/protocol.js +143 -0
  65. package/dist/vendor/tunnel-client/types.d.ts +101 -0
  66. package/dist/vendor/tunnel-client/types.js +10 -0
  67. package/dist/vendor/tunnel-client/ws-compat.d.ts +206 -0
  68. package/dist/vendor/tunnel-client/ws-compat.js +316 -0
  69. package/dist/version.d.ts +1 -1
  70. package/dist/version.js +1 -1
  71. package/package.json +2 -1
  72. package/skills/testsprite-onboard.skill.md +60 -4
  73. package/skills/testsprite-verify.codex.md +22 -16
  74. package/skills/testsprite-verify.skill.md +27 -18
package/README.md CHANGED
@@ -27,7 +27,7 @@ AI ships code in minutes — verifying it hasn't. `testsprite` opens your live a
27
27
  <a href="https://www.testsprite.com/docs"><img src="https://img.shields.io/badge/Docs-0A0A0A?style=for-the-badge" alt="Docs"></a>
28
28
  <a href="https://x.com/Test_Sprite"><img src="https://img.shields.io/badge/Follow%20on%20X-000000?style=for-the-badge&logo=x&logoColor=white" alt="Follow on X"></a>
29
29
  <a href="https://www.linkedin.com/company/testsprite"><img src="https://img.shields.io/badge/LinkedIn-0A66C2?style=for-the-badge&logo=linkedin&logoColor=white" alt="LinkedIn"></a>
30
- <a href="https://discord.gg/W4JDrZfdB"><img src="https://img.shields.io/badge/Join%20our%20Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Join our Discord"></a>
30
+ <a href="https://discord.gg/GXWFjCe4an"><img src="https://img.shields.io/badge/Join%20our%20Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Join our Discord"></a>
31
31
  </p>
32
32
 
33
33
  ⭐ _Help us reach more developers and grow the TestSprite community. Star this repo!_
@@ -61,13 +61,17 @@ npm install -g @testsprite/testsprite-cli
61
61
  testsprite setup
62
62
  ```
63
63
 
64
- `testsprite setup` prompts for your [API key](https://www.testsprite.com), verifies it, and installs the verification-loop skill for your coding agent (`claude`, `cursor`, `cline`, `windsurf`, `antigravity`, `codex`, etc.) — one command, so your agent is wired to verify its own work. Non-interactive (CI / onboarding scripts):
64
+ `testsprite setup` prompts for your [API key](https://www.testsprite.com), verifies it, and installs the verification-loop skill for the coding agents this project uses — one command, so your agent is wired to verify its own work.
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):
65
69
 
66
70
  ```bash
67
- TESTSPRITE_API_KEY=sk-... testsprite setup --from-env --yes --agent claude
71
+ TESTSPRITE_API_KEY=sk-... testsprite setup --from-env --yes
68
72
  ```
69
73
 
70
- > **Pointing a coding agent (Claude Code, Cursor, Codex, Cline, …) at TestSprite?** Have it run `testsprite setup` first — that installs the verification skill, so the agent knows how to create, run, and triage tests on its own (instead of guessing from this README). New here? Start with the **[getting-started overview](https://docs.testsprite.com/cli/getting-started/overview)**.
74
+ > **Pointing a coding agent (Claude Code, Cursor, Codex, Cline, …) at TestSprite?** Have it run `testsprite setup` first — that installs the verification skill, so the agent knows how to create, run, and triage tests on its own (instead of guessing from this README). `setup` reports which agents it installed for; add `--agent <target>` if that list is not the one you wanted. New here? Start with the **[getting-started overview](https://docs.testsprite.com/cli/getting-started/overview)**.
71
75
 
72
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).
73
77
 
@@ -112,47 +116,60 @@ Get this exact skeleton without hand-copying it (and without the risk of it drif
112
116
 
113
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.
114
118
 
119
+ **Don't want to write the first tests yourself?** Ask TestSprite to propose them. `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:
120
+
121
+ ```bash
122
+ testsprite test plan generate --project proj_8f0f6 # stages proposals for review
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
125
+ ```
126
+
127
+ It only runs what the project is still missing, so a second call picks up where the first left off. Generation spends workspace credits per stage that actually runs (the result line reports the spend), and a PRD uploaded with `project docs upload --role prd` bills 0.5 credits for its embedding — an API spec is free. Full walkthrough, including what happens on Ctrl-C and every precondition error: [Generate commands](./DOCUMENTATION.md#generate-commands).
128
+
115
129
  Prefer to configure each step by hand (or learn the surface offline with `--dry-run` first)? See [Manual setup](./DOCUMENTATION.md#manual-setup) and [Install & verify](./DOCUMENTATION.md#install--verify).
116
130
 
117
131
  ## Commands
118
132
 
119
- | Group | Command | What it does |
120
- | -------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
121
- | **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill |
122
- | | `doctor` | Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure |
123
- | **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes |
124
- | | `auth remove` | Remove the active profile from the credentials file |
125
- | | `usage` (alias `credits`) | Account pre-flight: identity, plus credit balance / plan info when the backend supplies them |
126
- | **Read** | `project list` / `project get` | List projects / fetch one by id |
127
- | | `test list` / `test get` | List tests under a project / fetch one by id |
128
- | | `test code get` | Print (or write) the generated test source |
129
- | | `test steps` | List the latest run's steps with screenshot / DOM pointers |
130
- | | `test result` | Latest result; `--history` lists a test's prior runs |
131
- | | `test failure get` | The agent entry point: one self-contained latest-failure bundle |
132
- | | `test failure summary` | One-screen triage card (no media download) |
133
- | | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift |
134
- | **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials |
135
- | | `test create` / `test create-batch` | Create a test (or bulk-create from a plan file); `--produces` / `--needs` / `--category` wire BE dependency metadata |
136
- | | `test update` / `test delete` / `test delete-batch` | Edit metadata and BE dependency declarations (`--produces` / `--needs` / `--category`) / permanently delete (no restore window; `--confirm` required) |
137
- | | `test code put` | Replace generated code (etag-guarded) |
138
- | | `test plan put` | Replace a frontend test's plan-steps |
139
- | | `project create` / `project update` / `project delete` | Manage projects; `delete` removes a project and everything under it (`--confirm` required, no restore window) |
140
- | | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro) |
141
- | **Run** | `test run` | Trigger a fresh run; `--wait` blocks until terminal; `--all --project <id>` runs all tests in a project in wave order |
142
- | | `test rerun` | Replay one/many tests (FE verbatim; BE with deps); billed as a run (0.5 credits FE / 0.2 BE); `--all --project <id>` reruns all tests |
143
- | | `test flaky` | Replay a test several times (auto-heal off) and report a stability score |
144
- | | `test wait` | Block on one or more `runId`s until terminal |
145
- | | `test cancel` | Cancel one or more in-flight runs (Ctrl-C during `--wait` only detaches — `cancel` is the real stop) |
146
- | | `test artifact get` | Download the failure bundle for a specific `runId` |
147
- | **Test lists** | `testlist list` / `testlist get` | Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only) |
148
- | | `testlist create` / `update` / `add` / `remove` / `delete` | Manage a list and its cases; `--project-env <id>:<env>` pins environments; `delete` requires `--confirm` |
149
- | | `testlist run` | Run every case (or a `--case` subset) through its pinned environment; `--wait` polls all runs, `--report junit` writes a CI sidecar |
150
- | **Schedule** | `schedule list` / `schedule get` | List schedules visible to the key / fetch one by id (status is `ENABLED`, `PAUSED`, or `AUTO_PAUSED` after repeated failures) |
151
- | | `schedule create` | Run a project or test list on a 5-field cron; states the frequency before sending and the per-run / monthly credit cost once priced |
152
- | | `schedule update` | Retime or rename a schedule, change its recipients, `--pause` / `--resume` it |
153
- | | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window) |
154
- | | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts |
155
- | **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` |
133
+ | Group | Command | What it does |
134
+ | -------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
135
+ | **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill |
136
+ | | `doctor` | Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure |
137
+ | **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes |
138
+ | | `auth remove` | Remove the active profile from the credentials file |
139
+ | | `usage` (alias `credits`) | Account pre-flight: identity, plus credit balance / plan info when the backend supplies them |
140
+ | **Read** | `project list` / `project get` | List projects / fetch one by id |
141
+ | | `test list` / `test get` | List tests under a project / fetch one by id |
142
+ | | `test code get` | Print (or write) the generated test source |
143
+ | | `test steps` | List the latest run's steps with screenshot / DOM pointers |
144
+ | | `test result` | Latest result; `--history` lists a test's prior runs |
145
+ | | `test failure get` | The agent entry point: one self-contained latest-failure bundle |
146
+ | | `test failure summary` | One-screen triage card (no media download) |
147
+ | | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift |
148
+ | **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials |
149
+ | | `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 |
150
+ | | `test update` / `test delete` / `test delete-batch` | Edit metadata, set/clear the step timeout (`--step-timeout` / `--clear-step-timeout`), or permanently delete (`--confirm` required) |
151
+ | | `test code put` | Replace generated code (etag-guarded) |
152
+ | | `test plan put` | Replace a frontend test's plan-steps |
153
+ | | `project create` / `project update` / `project delete` | Manage projects; `delete` removes a project and everything under it (`--confirm` required, no restore window) |
154
+ | | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro) |
155
+ | **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 |
156
+ | | `test plan accept` | Turn staged proposals into real tests — all of them, or a subset with `--only` |
157
+ | | `project docs upload` | Upload an API spec or PRD as a project source, so generation has something to read |
158
+ | **Run** | `test run` | Trigger a fresh run; `--wait` blocks until terminal; `--all --project <id>` runs all tests in a project in wave order |
159
+ | | `test rerun` | Replay one/many tests (FE verbatim; BE with deps); billed as a run (0.5 credits FE / 0.2 BE); `--all --project <id>` reruns all tests |
160
+ | | `test flaky` | Replay a test several times (auto-heal off) and report a stability score |
161
+ | | `test wait` | Block on one or more `runId`s until terminal |
162
+ | | `test cancel` | Cancel one or more in-flight runs (Ctrl-C during `--wait` only detaches, `cancel` is the real stop — except a `--local` run, which Ctrl-C cancels by default) |
163
+ | | `test artifact get` | Download the failure bundle for a specific `runId` |
164
+ | **Test lists** | `testlist list` / `testlist get` | Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only) |
165
+ | | `testlist create` / `update` / `add` / `remove` / `delete` | Manage a list and its cases; `--project-env <id>:<env>` pins environments; `delete` requires `--confirm` |
166
+ | | `testlist run` | Run every case (or a `--case` subset) through its pinned environment; `--wait` polls all runs, `--report junit` writes a CI sidecar |
167
+ | **Schedule** | `schedule list` / `schedule get` | List schedules visible to the key / fetch one by id (status is `ENABLED`, `PAUSED`, or `AUTO_PAUSED` after repeated failures) |
168
+ | | `schedule create` | Run a project or test list on a 5-field cron; states the frequency before sending and the per-run / monthly credit cost once priced |
169
+ | | `schedule update` | Retime or rename a schedule, change its recipients, `--pause` / `--resume` it |
170
+ | | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window) |
171
+ | | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts |
172
+ | **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` |
156
173
 
157
174
  > 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).
158
175
 
@@ -164,8 +181,8 @@ Prefer to configure each step by hand (or learn the surface offline with `--dry-
164
181
  - 🤖 **Agent-shaped output.** `test failure get` returns **one bundle** — the failing step, its neighbors, screenshots, DOM snapshots, the test source, a root-cause hypothesis, and a recommended fix target — all sharing a single `snapshotId`. The CLI _refuses_ to stitch data from two different runs, so an agent never reasons over a frankenstein context.
165
182
  - ♻️ **A loop, not a one-shot.** `create → run → failure get → fix → rerun` — every pass is banked, not thrown away.
166
183
  - 📐 **Scriptable & deterministic.** Stable `--output json` contract, predictable [exit codes](./DOCUMENTATION.md#exit-codes), and a `--dry-run` that exercises the full code path offline with canned data.
167
- - 🚦 **CI-native.** On GitHub Actions, `--wait` runs annotate the PR checks tab with one `::error::` per failure and append a results table to the job summary — automatically. Add `--report junit` for a JUnit XML sidecar, `--summary-file` for a machine summary, or `--gh-output` to preview the annotations locally. [Details →](./DOCUMENTATION.md#run-commands)
168
- - 🔌 **One command to onboard your agent.** `testsprite agent install claude` drops a ready-made skill file into your repo so your coding agent knows how to drive the loop on its own.
184
+ - 🚦 **CI-native.** On GitHub Actions, `--wait` runs annotate the PR checks tab with one `::error::` per failure and append a results table to the job summary — automatically. Add `--report junit` for a JUnit XML sidecar, `--summary-file` for a machine summary, or `--gh-output` to preview the annotations locally. Runs in any CI, not just GitHub. [Details →](./DOCUMENTATION.md#continuous-integration)
185
+ - 🔌 **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.
169
186
 
170
187
  ## How it works
171
188
 
@@ -211,7 +228,7 @@ That's the point of all of this: you no longer need the biggest, most expensive
211
228
  - 📚 **CLI reference** — [DOCUMENTATION.md](./DOCUMENTATION.md)
212
229
  - 🌐 **Platform docs** — [testsprite.com/docs](https://www.testsprite.com/docs)
213
230
  - 🐛 **Issues & feature requests** — [GitHub issues](https://github.com/TestSprite/testsprite-cli/issues)
214
- - 💬 **Quick questions** — [Discord](https://discord.gg/W4JDrZfdB), or `testsprite --help` / `testsprite test run --help` right in your terminal
231
+ - 💬 **Quick questions** — [Discord](https://discord.gg/GXWFjCe4an), or `testsprite --help` / `testsprite test run --help` right in your terminal
215
232
  - 📝 **Changelog** — [CHANGELOG.md](./CHANGELOG.md)
216
233
 
217
234
  ## Contributing
@@ -229,7 +246,7 @@ npm run typecheck # tsc --noEmit
229
246
 
230
247
  Pull requests target the `main` branch. The full guide — build from source, test tiers, CI checks, branches, project layout — is in [CONTRIBUTING.md](./CONTRIBUTING.md).
231
248
 
232
- **Support** — if you need any help, we're responsive on [Discord](https://discord.gg/W4JDrZfdB), and feel free to email us at [contact@testsprite.com](mailto:contact@testsprite.com) too.
249
+ **Support** — if you need any help, we're responsive on [Discord](https://discord.gg/GXWFjCe4an), and feel free to email us at [contact@testsprite.com](mailto:contact@testsprite.com) too.
233
250
 
234
251
  ## License
235
252
 
@@ -1,5 +1,6 @@
1
1
  import { Command } from 'commander';
2
2
  import type { CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
3
+ import { type DetectAgentDeps } from '../lib/agent-detect.js';
3
4
  import { type AgentTarget } from '../lib/agent-targets.js';
4
5
  /**
5
6
  * Codex loads AGENTS.md files lazily and has a documented 32 KiB load budget
@@ -26,6 +27,8 @@ export interface AgentDeps {
26
27
  stderr?: (line: string) => void;
27
28
  isTTY?: boolean;
28
29
  prompt?: (question: string) => Promise<string>;
30
+ /** Injected fs/env for detecting which agents the project uses. */
31
+ detect?: DetectAgentDeps;
29
32
  }
30
33
  export type InstallAction = 'written' | 'skipped' | 'blocked' | 'updated' | 'dry-run' | 'section-installed' | 'section-updated' | 'section-unchanged';
31
34
  export interface InstallResult {
@@ -4,6 +4,7 @@ import { Command } from 'commander';
4
4
  import { CLIError, localValidationError } from '../lib/errors.js';
5
5
  import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
6
6
  import { promptText } from '../lib/prompt.js';
7
+ import { FALLBACK_TARGET, resolveAgentTargets } from '../lib/agent-detect.js';
7
8
  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';
8
9
  // ---------------------------------------------------------------------------
9
10
  // Constants
@@ -212,6 +213,17 @@ function composeManagedFile(state, section) {
212
213
  // replace
213
214
  return `${state.before}${section}${state.after}`;
214
215
  }
216
+ /**
217
+ * Actions that mean bytes actually changed on disk — the trigger set for the
218
+ * post-install reload hint (DEV-279). Covers both write modes: own-file
219
+ * (`written`/`updated`) and codex managed-section (`section-*`).
220
+ */
221
+ const CHANGED_ACTIONS = new Set([
222
+ 'written',
223
+ 'updated',
224
+ 'section-installed',
225
+ 'section-updated',
226
+ ]);
215
227
  // ---------------------------------------------------------------------------
216
228
  // Shared canonical-body resolution
217
229
  // ---------------------------------------------------------------------------
@@ -250,19 +262,38 @@ export async function runInstall(opts, deps = {}) {
250
262
  .map(s => s.trim())
251
263
  .filter(Boolean);
252
264
  let resolvedTargetStrings;
265
+ // Whether the target came from the interactive prompt rather than a flag.
266
+ // Decides which of the two the refusal below names — telling someone their
267
+ // `--target` is invalid when they never typed one sends them to the wrong
268
+ // place.
269
+ let fromPrompt = false;
270
+ // Where the install lands, and so where detection looks (reused at step 3).
271
+ const dir = opts.dir ?? deps.cwd ?? process.cwd();
253
272
  if (rawTargets.length === 0) {
273
+ // No target named: install for the agents this project shows rather than a
274
+ // fixed one, so an unnamed install cannot land where the caller cannot read.
275
+ const detected = resolveAgentTargets(undefined, dir, { ...deps.detect });
276
+ const suggestion = detected.targets.join(',');
254
277
  const isTTY = deps.isTTY ?? Boolean(process.stdin.isTTY);
255
278
  if (!isTTY) {
256
- stderrFn('[info] --target not specified; defaulting to claude. Pass --target=<target> to select a different agent.');
257
- resolvedTargetStrings = ['claude'];
279
+ stderrFn(detected.source === 'fallback'
280
+ ? `[info] no coding agent detected; installing for ${FALLBACK_TARGET}. Pass --target=<target> to select a different agent.`
281
+ : `[info] --target not specified; installing for ${suggestion}.`);
282
+ resolvedTargetStrings = [...detected.targets];
258
283
  }
259
284
  else {
285
+ fromPrompt = true;
260
286
  const promptFn = deps.prompt ?? ((q) => promptText(q));
261
- const answer = (await promptFn('Targets to install (comma-separated) [claude]: ')).trim();
262
- const defaulted = answer || 'claude';
287
+ const answer = (await promptFn(`Targets to install (comma-separated) [${suggestion}]: `)).trim();
288
+ const defaulted = answer || suggestion;
289
+ // Lower-cased for the same reason `setup`'s prompt does it: every target
290
+ // name is lower case, so `Cursor` is a typo only in the sense that the
291
+ // shift key was down. Accepting it in one prompt and refusing it in the
292
+ // other is an inconsistency the user has no way to predict. A `--target`
293
+ // value is left alone on both sides — that is a flag, not an answer.
263
294
  resolvedTargetStrings = defaulted
264
295
  .split(',')
265
- .map(s => s.trim())
296
+ .map(s => s.trim().toLowerCase())
266
297
  .filter(Boolean);
267
298
  }
268
299
  }
@@ -273,6 +304,12 @@ export async function runInstall(opts, deps = {}) {
273
304
  const validTargets = Object.keys(TARGETS);
274
305
  for (const t of resolvedTargetStrings) {
275
306
  if (!validTargets.includes(t)) {
307
+ if (fromPrompt) {
308
+ // Not `localValidationError('target', …)`: that renders as "Flag
309
+ // --target is invalid", and on this path the caller passed no flag.
310
+ throw new CLIError(`unknown target "${t}"; supported: ${validTargets.join(', ')}. ` +
311
+ 'Re-run and answer with one of those, or pass --target <target>.', 5);
312
+ }
276
313
  throw localValidationError('target', `unknown target "${t}"; supported: ${validTargets.join(', ')}`);
277
314
  }
278
315
  }
@@ -303,8 +340,7 @@ export async function runInstall(opts, deps = {}) {
303
340
  seenSkill.add(s);
304
341
  return true;
305
342
  });
306
- // 3. Resolve dir
307
- const dir = opts.dir ?? deps.cwd ?? process.cwd();
343
+ // 3. Resolve dir (computed above, where detection also needed it)
308
344
  const root = path.resolve(dir);
309
345
  // 4. Lazy asset loaders — only touch disk if a target actually needs it.
310
346
  // own-file bodies come from the shared per-target resolver; the codex section
@@ -569,13 +605,36 @@ export async function runInstall(opts, deps = {}) {
569
605
  const items = data;
570
606
  return items.map(r => `${r.target.padEnd(12)} ${r.action.padEnd(12)} ${r.path}`).join('\n');
571
607
  });
608
+ // 8b. Reload hint (DEV-279). A coding agent reads its skill/rule files at
609
+ // session start, so a session already open when we wrote the file won't pick
610
+ // it up. Fire only when something actually changed on disk — silent on
611
+ // skipped/unchanged/blocked/dry-run and in --output json. Targets are
612
+ // de-duplicated (own-file targets produce one result per skill).
613
+ if (opts.output === 'text') {
614
+ const changedTargets = [
615
+ ...new Set(results.filter(r => CHANGED_ACTIONS.has(r.action)).map(r => r.target)),
616
+ ];
617
+ if (changedTargets.length > 0) {
618
+ stderrFn(`[hint] Reopen (or restart) your coding agent (${changedTargets.join(', ')}) so it picks up the newly installed TestSprite skill(s).`);
619
+ }
620
+ }
572
621
  // 9. Exit with 6 if any blocked
573
622
  if (results.some(r => r.action === 'blocked')) {
574
623
  throw new CLIError('one or more targets already exist and differ; re-run with --force to overwrite (a .bak is kept).', 6);
575
624
  }
576
625
  }
626
+ /**
627
+ * Display name for the AGENT column. Experimental targets get an "(exp.)" tag so
628
+ * support maturity stays visible without a dedicated STATUS column — a bare
629
+ * `ga`/`experimental` column reads like install state, which is `agent status`'s
630
+ * job, not this catalog's (DEV-279).
631
+ */
632
+ function agentDisplayName(target, status) {
633
+ return status === 'experimental' ? `${target} (exp.)` : target;
634
+ }
577
635
  export async function runList(opts, deps = {}) {
578
636
  const out = makeOutput(opts.output, deps);
637
+ const stderrFn = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
579
638
  // One row per (target × default skill). Own-file targets land each skill at a
580
639
  // distinct path; the codex managed-section target merges all skills into the
581
640
  // single AGENTS.md (so every codex row shares that path — truthful, since both
@@ -592,12 +651,22 @@ export async function runList(opts, deps = {}) {
592
651
  });
593
652
  }
594
653
  }
654
+ // The text table shows only what someone choosing an agent needs: the agent
655
+ // (with an "(exp.)" maturity tag), the skill, and where it lands. STATUS and
656
+ // MODE stay in the JSON shape for back-compat but are dropped from the human
657
+ // table — MODE is an internal write strategy, and STATUS (ga/experimental)
658
+ // reads like install state, which lives in `agent status` (DEV-279).
595
659
  out.print(results, data => {
596
660
  const items = data;
597
- const header = `${'TARGET'.padEnd(14)} ${'SKILL'.padEnd(20)} ${'STATUS'.padEnd(12)} ${'MODE'.padEnd(18)} PATH`;
598
- const rows = items.map(r => `${r.target.padEnd(14)} ${r.skill.padEnd(20)} ${r.status.padEnd(12)} ${r.mode.padEnd(18)} ${r.path}`);
661
+ const header = `${'AGENT'.padEnd(20)} ${'SKILL'.padEnd(20)} PATH`;
662
+ const rows = items.map(r => `${agentDisplayName(r.target, r.status).padEnd(20)} ${r.skill.padEnd(20)} ${r.path}`);
599
663
  return [header, ...rows].join('\n');
600
664
  });
665
+ // Point at the command that answers "is it installed here?" (text mode only —
666
+ // never pollute the JSON stream).
667
+ if (opts.output === 'text') {
668
+ stderrFn('Run `testsprite agent status` to see which of these skills are installed in this project.');
669
+ }
601
670
  }
602
671
  /**
603
672
  * Classify one own-file artifact per the {@link SkillArtifactState} contract.
@@ -778,7 +847,7 @@ export function createAgentCommand(deps = {}) {
778
847
  });
779
848
  agent
780
849
  .command('list')
781
- .description('List supported agent targets and skills, their status, and landing paths')
850
+ .description('List the agent targets and skills this CLI can install and where each lands (run `testsprite agent status` to see what is installed here)')
782
851
  .addHelpText('after', GLOBAL_OPTS_HINT)
783
852
  .action(async (_o, command) => {
784
853
  await runList(resolveCommonOptions(command), deps);
@@ -0,0 +1,88 @@
1
+ import { type SpawnSyncReturns } from 'node:child_process';
2
+ import { Command } from 'commander';
3
+ import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
4
+ import { type FetchImpl } from '../lib/http.js';
5
+ /** Platforms `ci init` can scaffold. One today; the positional arg leaves room. */
6
+ declare const SUPPORTED_PLATFORMS: readonly ["github"];
7
+ type Platform = (typeof SUPPORTED_PLATFORMS)[number];
8
+ /**
9
+ * Minimal fs seam (mirrors `agent.ts`'s `AgentFs` semantics: exclusive writes to
10
+ * refuse clobbering, recursive mkdir to create parent dirs). Kept local so `ci`
11
+ * doesn't couple to the agent-install internals.
12
+ */
13
+ export interface CiFs {
14
+ writeFile(target: string, data: string, opts?: {
15
+ exclusive?: boolean;
16
+ }): Promise<void>;
17
+ mkdir(dir: string): Promise<void>;
18
+ readFile(target: string): Promise<string>;
19
+ }
20
+ /** Injectable subprocess runner (defaults to a real `spawnSync`), so tests never
21
+ * shell out. Runs `git` (default-branch detection) and `gh` (optional secret set). */
22
+ export type SpawnImpl = (cmd: string, args: string[], opts: {
23
+ input?: string;
24
+ cwd?: string;
25
+ }) => SpawnSyncReturns<string>;
26
+ export interface CiDeps {
27
+ env?: NodeJS.ProcessEnv;
28
+ credentialsPath?: string;
29
+ fetchImpl?: FetchImpl;
30
+ stdout?: (line: string) => void;
31
+ stderr?: (line: string) => void;
32
+ cwd?: string;
33
+ fs?: CiFs;
34
+ spawn?: SpawnImpl;
35
+ }
36
+ type CommonOptions = FactoryCommonOptions;
37
+ export interface CiInitOptions extends CommonOptions {
38
+ platform: string;
39
+ project?: string;
40
+ filter?: string;
41
+ timeoutSeconds: number;
42
+ workflowPath: string;
43
+ force: boolean;
44
+ setSecret: boolean;
45
+ repo?: string;
46
+ }
47
+ /** Machine summary emitted under `--output json`. */
48
+ export interface CiInitSummary {
49
+ platform: Platform;
50
+ path: string;
51
+ action: string;
52
+ projectId: string;
53
+ wrote: boolean;
54
+ /** Distinguishes the two `wrote: false` cases a scripted caller can't otherwise
55
+ * tell apart: `preview` (a --dry-run) vs `unchanged` (the file was already
56
+ * byte-identical). `written` is the wrote-true case. */
57
+ status: 'written' | 'unchanged' | 'preview';
58
+ backupPath: string | null;
59
+ filter: string | null;
60
+ endpointUrl: string | null;
61
+ endpointWarning: string | null;
62
+ timeoutSeconds: number;
63
+ secret: {
64
+ name: string;
65
+ attempted: boolean;
66
+ set: boolean;
67
+ reason: string | null;
68
+ };
69
+ }
70
+ export declare function parseTimeoutSeconds(raw: unknown): number;
71
+ /**
72
+ * Build the GitHub Actions workflow. It delegates to the published
73
+ * `TestSprite/testsprite-action` (design A) rather than inlining the CLI, so the
74
+ * partial-run guard (`allow-partial: false` by default), the JUnit upload, the
75
+ * annotations, and the CLI-version pin all come from one maintained place.
76
+ */
77
+ export declare function buildGithubWorkflow(input: {
78
+ projectId: string;
79
+ filter?: string;
80
+ timeoutSeconds: number;
81
+ endpointUrl?: string;
82
+ cliVersion: string;
83
+ defaultBranch: string;
84
+ }): string;
85
+ export declare function runCiInit(opts: CiInitOptions, deps?: CiDeps): Promise<void>;
86
+ export declare function renderCiInitText(s: CiInitSummary): string;
87
+ export declare function createCiCommand(deps?: CiDeps): Command;
88
+ export {};