@testsprite/testsprite-cli 0.8.0 → 0.10.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 +51 -47
- package/dist/commands/agent.d.ts +3 -0
- package/dist/commands/agent.js +32 -7
- package/dist/commands/ci.js +4 -1
- package/dist/commands/init.d.ts +45 -2
- package/dist/commands/init.js +190 -29
- package/dist/commands/project.d.ts +21 -0
- package/dist/commands/project.js +118 -12
- package/dist/commands/test.d.ts +32 -3
- package/dist/commands/test.js +157 -29
- package/dist/lib/agent-detect.d.ts +53 -0
- package/dist/lib/agent-detect.js +198 -0
- package/dist/lib/dry-run/samples.js +16 -9
- package/dist/lib/http.d.ts +10 -0
- package/dist/lib/http.js +6 -2
- package/dist/lib/response-schemas.js +14 -0
- package/dist/lib/runs.types.d.ts +26 -0
- package/dist/lib/skill-nudge.d.ts +13 -5
- package/dist/lib/skill-nudge.js +40 -14
- package/dist/lib/target-url.d.ts +10 -1
- package/dist/lib/target-url.js +28 -11
- package/dist/lib/tunnel-session.d.ts +12 -3
- package/dist/lib/tunnel-session.js +23 -6
- package/dist/vendor/tunnel-client/client.d.ts +2 -3
- package/dist/vendor/tunnel-client/client.js +60 -7
- package/dist/vendor/tunnel-client/config.d.ts +8 -0
- package/dist/vendor/tunnel-client/config.js +8 -0
- package/dist/vendor/tunnel-client/types.d.ts +5 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/testsprite-onboard.skill.md +6 -0
- package/skills/testsprite-verify.skill.md +5 -1
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/
|
|
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
|
|
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
|
|
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
|
|
|
@@ -126,46 +130,46 @@ Prefer to configure each step by hand (or learn the surface offline with `--dry-
|
|
|
126
130
|
|
|
127
131
|
## Commands
|
|
128
132
|
|
|
129
|
-
| Group | Command | What it does
|
|
130
|
-
| -------------- | ---------------------------------------------------------- |
|
|
131
|
-
| **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill
|
|
132
|
-
| | `doctor` | Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure
|
|
133
|
-
| **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes
|
|
134
|
-
| | `auth remove` | Remove the active profile from the credentials file
|
|
135
|
-
| | `usage` (alias `credits`) | Account pre-flight: identity, plus credit balance / plan info when the backend supplies them
|
|
136
|
-
| **Read** | `project list` / `project get` | List projects / fetch one by id
|
|
137
|
-
| | `test list` / `test get` | List tests under a project / fetch one by id
|
|
138
|
-
| | `test code get` | Print (or write) the generated test source
|
|
139
|
-
| | `test steps` | List the latest run's steps with screenshot / DOM pointers
|
|
140
|
-
| | `test result` | Latest result; `--history` lists a test's prior runs
|
|
141
|
-
| | `test failure get` | The agent entry point: one self-contained latest-failure bundle
|
|
142
|
-
| | `test failure summary` | One-screen triage card (no media download)
|
|
143
|
-
| | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift
|
|
144
|
-
| **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials
|
|
145
|
-
| | `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
|
|
146
|
-
| | `test update` / `test delete` / `test delete-batch` | Edit metadata, set/clear the step timeout (`--step-timeout` / `--clear-step-timeout`), or permanently delete (`--confirm` required)
|
|
147
|
-
| | `test code put` | Replace generated code (etag-guarded)
|
|
148
|
-
| | `test plan put` | Replace a frontend test's plan-steps
|
|
149
|
-
| | `project create` / `project update` / `project delete` | Manage projects; `delete` removes a project and everything under it (`--confirm` required, no restore window)
|
|
150
|
-
| | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro)
|
|
151
|
-
| **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
|
|
152
|
-
| | `test plan accept` | Turn staged proposals into real tests — all of them, or a subset with `--only`
|
|
153
|
-
| | `project docs upload` | Upload an API spec or PRD as a project source, so generation has something to read
|
|
154
|
-
| **Run** | `test run` | Trigger a fresh run; `--wait` blocks until terminal; `--all --project <id>` runs all tests in a project in wave order
|
|
155
|
-
| | `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
|
|
156
|
-
| | `test flaky` | Replay a test several times (auto-heal off) and report a stability score
|
|
157
|
-
| | `test wait` | Block on one or more `runId`s until terminal
|
|
158
|
-
| | `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)
|
|
159
|
-
| | `test artifact get` | Download the failure bundle for a specific `runId`
|
|
160
|
-
| **Test lists** | `testlist list` / `testlist get` | Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only)
|
|
161
|
-
| | `testlist create` / `update` / `add` / `remove` / `delete` | Manage a list and its cases; `--project-env <id>:<env>` pins environments; `delete` requires `--confirm`
|
|
162
|
-
| | `testlist run` | Run every case (or a `--case` subset) through its pinned environment; `--wait` polls all runs, `--report junit` writes a CI sidecar
|
|
163
|
-
| **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)
|
|
164
|
-
| | `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
|
|
165
|
-
| | `schedule update` | Retime or rename a schedule, change its recipients, `--pause` / `--resume` it
|
|
166
|
-
| | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window)
|
|
167
|
-
| | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts
|
|
168
|
-
| **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; `--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) |
|
|
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` |
|
|
169
173
|
|
|
170
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).
|
|
171
175
|
|
|
@@ -178,7 +182,7 @@ Prefer to configure each step by hand (or learn the surface offline with `--dry-
|
|
|
178
182
|
- ♻️ **A loop, not a one-shot.** `create → run → failure get → fix → rerun` — every pass is banked, not thrown away.
|
|
179
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.
|
|
180
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)
|
|
181
|
-
- 🔌 **One command to onboard your agent.** `testsprite
|
|
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.
|
|
182
186
|
|
|
183
187
|
## How it works
|
|
184
188
|
|
|
@@ -224,7 +228,7 @@ That's the point of all of this: you no longer need the biggest, most expensive
|
|
|
224
228
|
- 📚 **CLI reference** — [DOCUMENTATION.md](./DOCUMENTATION.md)
|
|
225
229
|
- 🌐 **Platform docs** — [testsprite.com/docs](https://www.testsprite.com/docs)
|
|
226
230
|
- 🐛 **Issues & feature requests** — [GitHub issues](https://github.com/TestSprite/testsprite-cli/issues)
|
|
227
|
-
- 💬 **Quick questions** — [Discord](https://discord.gg/
|
|
231
|
+
- 💬 **Quick questions** — [Discord](https://discord.gg/GXWFjCe4an), or `testsprite --help` / `testsprite test run --help` right in your terminal
|
|
228
232
|
- 📝 **Changelog** — [CHANGELOG.md](./CHANGELOG.md)
|
|
229
233
|
|
|
230
234
|
## Contributing
|
|
@@ -242,7 +246,7 @@ npm run typecheck # tsc --noEmit
|
|
|
242
246
|
|
|
243
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).
|
|
244
248
|
|
|
245
|
-
**Support** — if you need any help, we're responsive on [Discord](https://discord.gg/
|
|
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.
|
|
246
250
|
|
|
247
251
|
## License
|
|
248
252
|
|
package/dist/commands/agent.d.ts
CHANGED
|
@@ -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 {
|
package/dist/commands/agent.js
CHANGED
|
@@ -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
|
|
@@ -261,19 +262,38 @@ export async function runInstall(opts, deps = {}) {
|
|
|
261
262
|
.map(s => s.trim())
|
|
262
263
|
.filter(Boolean);
|
|
263
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();
|
|
264
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(',');
|
|
265
277
|
const isTTY = deps.isTTY ?? Boolean(process.stdin.isTTY);
|
|
266
278
|
if (!isTTY) {
|
|
267
|
-
stderrFn(
|
|
268
|
-
|
|
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];
|
|
269
283
|
}
|
|
270
284
|
else {
|
|
285
|
+
fromPrompt = true;
|
|
271
286
|
const promptFn = deps.prompt ?? ((q) => promptText(q));
|
|
272
|
-
const answer = (await promptFn(
|
|
273
|
-
const defaulted = answer ||
|
|
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.
|
|
274
294
|
resolvedTargetStrings = defaulted
|
|
275
295
|
.split(',')
|
|
276
|
-
.map(s => s.trim())
|
|
296
|
+
.map(s => s.trim().toLowerCase())
|
|
277
297
|
.filter(Boolean);
|
|
278
298
|
}
|
|
279
299
|
}
|
|
@@ -284,6 +304,12 @@ export async function runInstall(opts, deps = {}) {
|
|
|
284
304
|
const validTargets = Object.keys(TARGETS);
|
|
285
305
|
for (const t of resolvedTargetStrings) {
|
|
286
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
|
+
}
|
|
287
313
|
throw localValidationError('target', `unknown target "${t}"; supported: ${validTargets.join(', ')}`);
|
|
288
314
|
}
|
|
289
315
|
}
|
|
@@ -314,8 +340,7 @@ export async function runInstall(opts, deps = {}) {
|
|
|
314
340
|
seenSkill.add(s);
|
|
315
341
|
return true;
|
|
316
342
|
});
|
|
317
|
-
// 3. Resolve dir
|
|
318
|
-
const dir = opts.dir ?? deps.cwd ?? process.cwd();
|
|
343
|
+
// 3. Resolve dir (computed above, where detection also needed it)
|
|
319
344
|
const root = path.resolve(dir);
|
|
320
345
|
// 4. Lazy asset loaders — only touch disk if a target actually needs it.
|
|
321
346
|
// own-file bodies come from the shared per-target resolver; the codex section
|
package/dist/commands/ci.js
CHANGED
|
@@ -295,7 +295,10 @@ export async function runCiInit(opts, deps = {}) {
|
|
|
295
295
|
let endpointWarning = null;
|
|
296
296
|
if (endpointUrl) {
|
|
297
297
|
try {
|
|
298
|
-
assertNotLocal(endpointUrl
|
|
298
|
+
assertNotLocal(endpointUrl, {
|
|
299
|
+
field: 'endpoint-url',
|
|
300
|
+
helpCommand: 'testsprite ci init',
|
|
301
|
+
});
|
|
299
302
|
}
|
|
300
303
|
catch {
|
|
301
304
|
endpointWarning = `the workflow pins ${endpointUrl}, which a GitHub-hosted runner cannot reach — pass --endpoint-url <public-url>, or run this workflow on a self-hosted runner.`;
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* `testsprite init` — one-shot onboarding orchestrator.
|
|
3
3
|
*
|
|
4
4
|
* Chains, in order:
|
|
5
|
+
* 0. Agent-target resolution + confirmation prompt — the chosen install
|
|
6
|
+
* targets are settled here, before anything is written
|
|
5
7
|
* 1. runConfigure — writes the API-key profile (validates via GET /me first)
|
|
6
8
|
* 2. runWhoami — fetches identity for the post-configure banner
|
|
7
9
|
* 3. runInstall — installs the TestSprite verification-loop skill (unless --no-agent)
|
|
@@ -14,6 +16,7 @@ import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factor
|
|
|
14
16
|
import type { AuthDeps } from './auth.js';
|
|
15
17
|
import type { AgentFs } from './agent.js';
|
|
16
18
|
import { type AgentTarget } from '../lib/agent-targets.js';
|
|
19
|
+
import { type AgentDetection, type DetectAgentDeps } from '../lib/agent-detect.js';
|
|
17
20
|
import type { FetchImpl } from '../lib/http.js';
|
|
18
21
|
type CommonOptions = FactoryCommonOptions;
|
|
19
22
|
/**
|
|
@@ -35,11 +38,18 @@ export interface InitDeps {
|
|
|
35
38
|
isTTY?: boolean;
|
|
36
39
|
/** Injected for agent install prompt (plain function, not {secret: fn}) */
|
|
37
40
|
agentPrompt?: (question: string) => Promise<string>;
|
|
41
|
+
/** Injected fs/env for caller detection; defaults to the real repo under `cwd`. */
|
|
42
|
+
detect?: DetectAgentDeps;
|
|
38
43
|
}
|
|
39
44
|
interface InitOptions extends CommonOptions {
|
|
40
45
|
apiKey?: string;
|
|
41
46
|
fromEnv: boolean;
|
|
42
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The target the caller explicitly chose. Absent means "decide from what this
|
|
49
|
+
* repo shows", so it must stay unset unless `--agent` was really passed —
|
|
50
|
+
* a default filled in here would suppress detection for every run.
|
|
51
|
+
*/
|
|
52
|
+
agent?: AgentTarget;
|
|
43
53
|
noAgent: boolean;
|
|
44
54
|
force: boolean;
|
|
45
55
|
dir?: string;
|
|
@@ -63,12 +73,40 @@ export interface InitSummary {
|
|
|
63
73
|
* Agent skill install outcome. `action` is an AGGREGATE across the installed
|
|
64
74
|
* skills (setup installs {@link DEFAULT_SKILLS}); `skills` lists which skills
|
|
65
75
|
* landed. `null` when --no-agent.
|
|
76
|
+
*
|
|
77
|
+
* `targets` holds every agent installed for; `target` repeats the first so a
|
|
78
|
+
* reader of the single-target field keeps working.
|
|
66
79
|
*/
|
|
67
80
|
agent: {
|
|
68
81
|
target: string;
|
|
82
|
+
targets: string[];
|
|
83
|
+
/**
|
|
84
|
+
* How the SET was arrived at: `flag` when `--agent` named it, `fallback`
|
|
85
|
+
* when nothing was found, otherwise `detected`.
|
|
86
|
+
*
|
|
87
|
+
* Deliberately not `'env' | 'trace'`: resolution is a UNION of both
|
|
88
|
+
* signals, so a single word would label a five-target set by whichever
|
|
89
|
+
* signal happened to fire first. Per-target provenance lives in
|
|
90
|
+
* `detections` below.
|
|
91
|
+
*/
|
|
92
|
+
detectedBy: 'flag' | 'detected' | 'fallback';
|
|
93
|
+
/**
|
|
94
|
+
* One row per detected target, so a JSON consumer can tell which signal
|
|
95
|
+
* produced which install. Empty for `flag` and `fallback`.
|
|
96
|
+
*/
|
|
97
|
+
detections: Array<{
|
|
98
|
+
target: string;
|
|
99
|
+
source: AgentDetection['source'];
|
|
100
|
+
signal: string;
|
|
101
|
+
}>;
|
|
69
102
|
action: string;
|
|
70
103
|
skills?: string[];
|
|
71
104
|
} | null;
|
|
105
|
+
/**
|
|
106
|
+
* Why `agent` is null: `flag` for `--no-agent`, `prompt` when the
|
|
107
|
+
* confirmation prompt was answered `none`. Absent when skills were installed.
|
|
108
|
+
*/
|
|
109
|
+
agentSkippedBy?: 'flag' | 'prompt';
|
|
72
110
|
status: 'initialized';
|
|
73
111
|
}
|
|
74
112
|
export declare function runInit(opts: InitOptions, deps?: InitDeps): Promise<void>;
|
|
@@ -88,7 +126,12 @@ export interface SetupCmdOpts {
|
|
|
88
126
|
yes?: boolean;
|
|
89
127
|
skipIfConfigured?: boolean;
|
|
90
128
|
}
|
|
91
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* Attach the onboarding flags shared by `setup` and the `init`/`auth configure`
|
|
131
|
+
* aliases. `--agent` deliberately carries NO default: its absence is the signal
|
|
132
|
+
* that setup should detect the agent, and a default value here is
|
|
133
|
+
* indistinguishable from the caller naming that same target.
|
|
134
|
+
*/
|
|
92
135
|
export declare function addSetupOptions(cmd: Command, validTargets: AgentTarget[], defaultAgent: AgentTarget): Command;
|
|
93
136
|
export declare function createSetupCommand(deps?: InitDeps): Command;
|
|
94
137
|
/**
|