@testsprite/testsprite-cli 0.6.0 → 0.8.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 -31
- package/dist/commands/agent.js +91 -45
- package/dist/commands/ci.d.ts +88 -0
- package/dist/commands/ci.js +429 -0
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.js +104 -8
- package/dist/commands/init.js +8 -0
- package/dist/commands/project.d.ts +78 -0
- package/dist/commands/project.js +429 -5
- package/dist/commands/schedule.d.ts +120 -0
- package/dist/commands/schedule.js +487 -0
- package/dist/commands/test.d.ts +176 -2
- package/dist/commands/test.js +2235 -609
- package/dist/commands/testlist.d.ts +88 -0
- package/dist/commands/testlist.js +753 -0
- package/dist/commands/tunnel.d.ts +72 -0
- package/dist/commands/tunnel.js +367 -0
- package/dist/index.js +113 -40
- package/dist/lib/agent-targets.d.ts +13 -4
- package/dist/lib/agent-targets.js +11 -2
- package/dist/lib/conflict-reason.d.ts +30 -0
- package/dist/lib/conflict-reason.js +45 -0
- package/dist/lib/credentials.js +42 -1
- package/dist/lib/cron.d.ts +40 -0
- package/dist/lib/cron.js +190 -0
- package/dist/lib/dry-run/samples.d.ts +9 -0
- package/dist/lib/dry-run/samples.js +293 -55
- package/dist/lib/errors.d.ts +9 -0
- package/dist/lib/errors.js +11 -0
- package/dist/lib/gh-output.d.ts +33 -1
- package/dist/lib/gh-output.js +97 -27
- package/dist/lib/http.d.ts +119 -0
- package/dist/lib/http.js +243 -2
- package/dist/lib/interrupt.d.ts +38 -13
- package/dist/lib/interrupt.js +130 -15
- package/dist/lib/junit-report.d.ts +20 -2
- package/dist/lib/junit-report.js +38 -5
- package/dist/lib/local-target.d.ts +95 -0
- package/dist/lib/local-target.js +184 -0
- package/dist/lib/plan-poll.d.ts +171 -0
- package/dist/lib/plan-poll.js +442 -0
- package/dist/lib/plans.types.d.ts +130 -0
- package/dist/lib/plans.types.js +31 -0
- package/dist/lib/poll-support.d.ts +26 -0
- package/dist/lib/poll-support.js +65 -0
- package/dist/lib/poll.d.ts +1 -0
- package/dist/lib/poll.js +2 -40
- package/dist/lib/proxy.d.ts +16 -0
- package/dist/lib/proxy.js +19 -1
- package/dist/lib/response-schemas.d.ts +20 -0
- package/dist/lib/response-schemas.js +55 -1
- package/dist/lib/run-progress.d.ts +41 -0
- package/dist/lib/run-progress.js +56 -0
- package/dist/lib/runs.types.d.ts +32 -3
- package/dist/lib/secret-file.d.ts +15 -0
- package/dist/lib/secret-file.js +82 -0
- package/dist/lib/target-url-preflight.d.ts +91 -0
- package/dist/lib/target-url-preflight.js +259 -0
- package/dist/lib/target-url.d.ts +63 -9
- package/dist/lib/target-url.js +283 -62
- package/dist/lib/telemetry.d.ts +11 -0
- package/dist/lib/telemetry.js +1 -0
- package/dist/lib/testlist.types.d.ts +77 -0
- package/dist/lib/testlist.types.js +9 -0
- package/dist/lib/ticker.d.ts +8 -0
- package/dist/lib/ticker.js +3 -0
- package/dist/lib/tunnel-session.d.ts +129 -0
- package/dist/lib/tunnel-session.js +232 -0
- package/dist/lib/tunnel.types.d.ts +54 -0
- package/dist/lib/tunnel.types.js +8 -0
- package/dist/lib/v3-advisory.d.ts +35 -22
- package/dist/lib/v3-advisory.js +44 -24
- package/dist/lib/wait-exit.d.ts +29 -0
- package/dist/lib/wait-exit.js +103 -0
- package/dist/vendor/tunnel-client/client.d.ts +83 -0
- package/dist/vendor/tunnel-client/client.js +871 -0
- package/dist/vendor/tunnel-client/config.d.ts +41 -0
- package/dist/vendor/tunnel-client/config.js +42 -0
- package/dist/vendor/tunnel-client/index.d.ts +9 -0
- package/dist/vendor/tunnel-client/index.js +9 -0
- package/dist/vendor/tunnel-client/lodash-lite.d.ts +14 -0
- package/dist/vendor/tunnel-client/lodash-lite.js +24 -0
- package/dist/vendor/tunnel-client/protocol.d.ts +60 -0
- package/dist/vendor/tunnel-client/protocol.js +143 -0
- package/dist/vendor/tunnel-client/types.d.ts +96 -0
- package/dist/vendor/tunnel-client/types.js +10 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +206 -0
- package/dist/vendor/tunnel-client/ws-compat.js +316 -0
- package/dist/version-guard.d.ts +10 -7
- package/dist/version-guard.js +37 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
- package/skills/testsprite-onboard.skill.md +60 -4
- package/skills/testsprite-verify.codex.md +22 -16
- package/skills/testsprite-verify.skill.md +27 -18
package/README.md
CHANGED
|
@@ -112,39 +112,60 @@ Get this exact skeleton without hand-copying it (and without the risk of it drif
|
|
|
112
112
|
|
|
113
113
|
> 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
114
|
|
|
115
|
+
**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:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
testsprite test plan generate --project proj_8f0f6 # stages proposals for review
|
|
119
|
+
testsprite test plan accept --project proj_8f0f6 # → real tests
|
|
120
|
+
testsprite test plan accept --project proj_8f0f6 --only prop_2 prop_5 # or just these
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
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).
|
|
124
|
+
|
|
115
125
|
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
126
|
|
|
117
127
|
## Commands
|
|
118
128
|
|
|
119
|
-
| Group
|
|
120
|
-
|
|
|
121
|
-
| **Setup**
|
|
122
|
-
|
|
|
123
|
-
| **Auth**
|
|
124
|
-
|
|
|
125
|
-
|
|
|
126
|
-
| **Read**
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
|
|
|
133
|
-
|
|
|
134
|
-
| **Write**
|
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
-
|
|
|
138
|
-
|
|
|
139
|
-
|
|
|
140
|
-
|
|
|
141
|
-
| **
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
|
|
|
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` |
|
|
148
169
|
|
|
149
170
|
> 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).
|
|
150
171
|
|
|
@@ -156,7 +177,7 @@ Prefer to configure each step by hand (or learn the surface offline with `--dry-
|
|
|
156
177
|
- 🤖 **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.
|
|
157
178
|
- ♻️ **A loop, not a one-shot.** `create → run → failure get → fix → rerun` — every pass is banked, not thrown away.
|
|
158
179
|
- 📐 **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.
|
|
159
|
-
- 🚦 **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#
|
|
180
|
+
- 🚦 **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)
|
|
160
181
|
- 🔌 **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.
|
|
161
182
|
|
|
162
183
|
## How it works
|
|
@@ -219,7 +240,7 @@ npm run lint:fix # ESLint
|
|
|
219
240
|
npm run typecheck # tsc --noEmit
|
|
220
241
|
```
|
|
221
242
|
|
|
222
|
-
Pull requests target the `
|
|
243
|
+
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).
|
|
223
244
|
|
|
224
245
|
**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.
|
|
225
246
|
|
package/dist/commands/agent.js
CHANGED
|
@@ -4,7 +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 { TARGETS, SKILLS, DEFAULT_SKILLS, MARKER_SKILL_SEPARATOR, pathFor,
|
|
7
|
+
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
8
|
// ---------------------------------------------------------------------------
|
|
9
9
|
// Constants
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
@@ -212,6 +212,42 @@ function composeManagedFile(state, section) {
|
|
|
212
212
|
// replace
|
|
213
213
|
return `${state.before}${section}${state.after}`;
|
|
214
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Actions that mean bytes actually changed on disk — the trigger set for the
|
|
217
|
+
* post-install reload hint (DEV-279). Covers both write modes: own-file
|
|
218
|
+
* (`written`/`updated`) and codex managed-section (`section-*`).
|
|
219
|
+
*/
|
|
220
|
+
const CHANGED_ACTIONS = new Set([
|
|
221
|
+
'written',
|
|
222
|
+
'updated',
|
|
223
|
+
'section-installed',
|
|
224
|
+
'section-updated',
|
|
225
|
+
]);
|
|
226
|
+
// ---------------------------------------------------------------------------
|
|
227
|
+
// Shared canonical-body resolution
|
|
228
|
+
// ---------------------------------------------------------------------------
|
|
229
|
+
/**
|
|
230
|
+
* Per-invocation cache in front of {@link ownFileBodyFor}, so each (target, skill)
|
|
231
|
+
* pair reads its asset once. `agent install` (which stamps the body's hash into the
|
|
232
|
+
* marker) and `agent status` (which re-derives it) share this rather than keeping
|
|
233
|
+
* private copies — they didn't, hence DEV-672.
|
|
234
|
+
*/
|
|
235
|
+
function makeOwnFileBodyResolver() {
|
|
236
|
+
// Keyed on the pair: the same skill resolves to different bytes per target.
|
|
237
|
+
// NUL separates them because no target or skill name can contain one; written
|
|
238
|
+
// as an escape, since a raw NUL in the source makes grep treat this file as
|
|
239
|
+
// binary and skip it.
|
|
240
|
+
const cache = new Map();
|
|
241
|
+
return (target, skill) => {
|
|
242
|
+
const key = `${target}\u0000${skill}`;
|
|
243
|
+
let body = cache.get(key);
|
|
244
|
+
if (body === undefined) {
|
|
245
|
+
body = ownFileBodyFor(target, skill);
|
|
246
|
+
cache.set(key, body);
|
|
247
|
+
}
|
|
248
|
+
return body;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
215
251
|
// ---------------------------------------------------------------------------
|
|
216
252
|
// runInstall
|
|
217
253
|
// ---------------------------------------------------------------------------
|
|
@@ -282,31 +318,9 @@ export async function runInstall(opts, deps = {}) {
|
|
|
282
318
|
const dir = opts.dir ?? deps.cwd ?? process.cwd();
|
|
283
319
|
const root = path.resolve(dir);
|
|
284
320
|
// 4. Lazy asset loaders — only touch disk if a target actually needs it.
|
|
285
|
-
// own-file bodies
|
|
286
|
-
// installed skill's contribution into ONE managed section.
|
|
287
|
-
const
|
|
288
|
-
const bodyForSkill = (skill) => {
|
|
289
|
-
let b = skillBodyCache.get(skill);
|
|
290
|
-
if (b === undefined) {
|
|
291
|
-
b = loadSkillBodyFor(skill);
|
|
292
|
-
skillBodyCache.set(skill, b);
|
|
293
|
-
}
|
|
294
|
-
return b;
|
|
295
|
-
};
|
|
296
|
-
// Budget-capped own-file targets (e.g. windsurf) render the compact per-skill
|
|
297
|
-
// body so the rule file isn't truncated by the agent. Cached separately; must
|
|
298
|
-
// match renderForTarget's default selection so written bytes equal the asserted
|
|
299
|
-
// render.
|
|
300
|
-
const compactBodyCache = new Map();
|
|
301
|
-
const compactBodyForSkill = (skill) => {
|
|
302
|
-
let b = compactBodyCache.get(skill);
|
|
303
|
-
if (b === undefined) {
|
|
304
|
-
b = compactBodyFor(skill);
|
|
305
|
-
compactBodyCache.set(skill, b);
|
|
306
|
-
}
|
|
307
|
-
return b;
|
|
308
|
-
};
|
|
309
|
-
const ownFileBodyFor = (t, skill) => TARGETS[t].compactBody ? compactBodyForSkill(skill) : bodyForSkill(skill);
|
|
321
|
+
// own-file bodies come from the shared per-target resolver; the codex section
|
|
322
|
+
// aggregates EVERY installed skill's contribution into ONE managed section.
|
|
323
|
+
const ownFileBodyFor = makeOwnFileBodyResolver();
|
|
310
324
|
let codexSectionCache;
|
|
311
325
|
const getCodexSection = () => {
|
|
312
326
|
if (codexSectionCache === undefined) {
|
|
@@ -566,13 +580,36 @@ export async function runInstall(opts, deps = {}) {
|
|
|
566
580
|
const items = data;
|
|
567
581
|
return items.map(r => `${r.target.padEnd(12)} ${r.action.padEnd(12)} ${r.path}`).join('\n');
|
|
568
582
|
});
|
|
583
|
+
// 8b. Reload hint (DEV-279). A coding agent reads its skill/rule files at
|
|
584
|
+
// session start, so a session already open when we wrote the file won't pick
|
|
585
|
+
// it up. Fire only when something actually changed on disk — silent on
|
|
586
|
+
// skipped/unchanged/blocked/dry-run and in --output json. Targets are
|
|
587
|
+
// de-duplicated (own-file targets produce one result per skill).
|
|
588
|
+
if (opts.output === 'text') {
|
|
589
|
+
const changedTargets = [
|
|
590
|
+
...new Set(results.filter(r => CHANGED_ACTIONS.has(r.action)).map(r => r.target)),
|
|
591
|
+
];
|
|
592
|
+
if (changedTargets.length > 0) {
|
|
593
|
+
stderrFn(`[hint] Reopen (or restart) your coding agent (${changedTargets.join(', ')}) so it picks up the newly installed TestSprite skill(s).`);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
569
596
|
// 9. Exit with 6 if any blocked
|
|
570
597
|
if (results.some(r => r.action === 'blocked')) {
|
|
571
598
|
throw new CLIError('one or more targets already exist and differ; re-run with --force to overwrite (a .bak is kept).', 6);
|
|
572
599
|
}
|
|
573
600
|
}
|
|
601
|
+
/**
|
|
602
|
+
* Display name for the AGENT column. Experimental targets get an "(exp.)" tag so
|
|
603
|
+
* support maturity stays visible without a dedicated STATUS column — a bare
|
|
604
|
+
* `ga`/`experimental` column reads like install state, which is `agent status`'s
|
|
605
|
+
* job, not this catalog's (DEV-279).
|
|
606
|
+
*/
|
|
607
|
+
function agentDisplayName(target, status) {
|
|
608
|
+
return status === 'experimental' ? `${target} (exp.)` : target;
|
|
609
|
+
}
|
|
574
610
|
export async function runList(opts, deps = {}) {
|
|
575
611
|
const out = makeOutput(opts.output, deps);
|
|
612
|
+
const stderrFn = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
576
613
|
// One row per (target × default skill). Own-file targets land each skill at a
|
|
577
614
|
// distinct path; the codex managed-section target merges all skills into the
|
|
578
615
|
// single AGENTS.md (so every codex row shares that path — truthful, since both
|
|
@@ -589,19 +626,34 @@ export async function runList(opts, deps = {}) {
|
|
|
589
626
|
});
|
|
590
627
|
}
|
|
591
628
|
}
|
|
629
|
+
// The text table shows only what someone choosing an agent needs: the agent
|
|
630
|
+
// (with an "(exp.)" maturity tag), the skill, and where it lands. STATUS and
|
|
631
|
+
// MODE stay in the JSON shape for back-compat but are dropped from the human
|
|
632
|
+
// table — MODE is an internal write strategy, and STATUS (ga/experimental)
|
|
633
|
+
// reads like install state, which lives in `agent status` (DEV-279).
|
|
592
634
|
out.print(results, data => {
|
|
593
635
|
const items = data;
|
|
594
|
-
const header = `${'
|
|
595
|
-
const rows = items.map(r => `${r.target
|
|
636
|
+
const header = `${'AGENT'.padEnd(20)} ${'SKILL'.padEnd(20)} PATH`;
|
|
637
|
+
const rows = items.map(r => `${agentDisplayName(r.target, r.status).padEnd(20)} ${r.skill.padEnd(20)} ${r.path}`);
|
|
596
638
|
return [header, ...rows].join('\n');
|
|
597
639
|
});
|
|
640
|
+
// Point at the command that answers "is it installed here?" (text mode only —
|
|
641
|
+
// never pollute the JSON stream).
|
|
642
|
+
if (opts.output === 'text') {
|
|
643
|
+
stderrFn('Run `testsprite agent status` to see which of these skills are installed in this project.');
|
|
644
|
+
}
|
|
598
645
|
}
|
|
599
646
|
/**
|
|
600
647
|
* Classify one own-file artifact per the {@link SkillArtifactState} contract.
|
|
601
648
|
* Comparisons are byte-exact, matching the installer's own skipped/blocked
|
|
602
649
|
* comparison for own-file targets.
|
|
650
|
+
*
|
|
651
|
+
* `canonicalBody` is already bound to THIS target by the caller and takes no
|
|
652
|
+
* arguments, so the per-skill-only lookup that caused DEV-672 cannot be expressed
|
|
653
|
+
* here. It is called only once an artifact is known to exist and carry a marker,
|
|
654
|
+
* so a row with nothing installed never touches the skill assets.
|
|
603
655
|
*/
|
|
604
|
-
async function classifyOwnFileState(agentFs, abs, target, skill,
|
|
656
|
+
async function classifyOwnFileState(agentFs, abs, target, skill, canonicalBody) {
|
|
605
657
|
const stat = await agentFs.lstat(abs);
|
|
606
658
|
if (stat === null)
|
|
607
659
|
return 'absent';
|
|
@@ -613,13 +665,13 @@ async function classifyOwnFileState(agentFs, abs, target, skill, bodyForSkill) {
|
|
|
613
665
|
const marker = parseSkillMarker(existing);
|
|
614
666
|
if (marker === null)
|
|
615
667
|
return 'unmarked';
|
|
616
|
-
const
|
|
617
|
-
if (marker.hash12 !== bodyHash12(
|
|
668
|
+
const body = canonicalBody();
|
|
669
|
+
if (marker.hash12 !== bodyHash12(body))
|
|
618
670
|
return 'stale';
|
|
619
671
|
// Hash matches the current body: pristine iff the file equals the canonical
|
|
620
672
|
// render carrying its own marker line, so a marker whose version string lags
|
|
621
673
|
// behind an unchanged body still reads ok.
|
|
622
|
-
const reRender = renderOwnFileWithMarker(target, skill, marker.line,
|
|
674
|
+
const reRender = renderOwnFileWithMarker(target, skill, marker.line, body);
|
|
623
675
|
return existing === reRender ? 'ok' : 'modified';
|
|
624
676
|
}
|
|
625
677
|
/**
|
|
@@ -696,17 +748,8 @@ export async function runStatus(opts, deps = {}) {
|
|
|
696
748
|
}
|
|
697
749
|
const dir = opts.dir !== undefined ? opts.dir.trim() : (deps.cwd ?? process.cwd());
|
|
698
750
|
const root = path.resolve(dir);
|
|
699
|
-
//
|
|
700
|
-
|
|
701
|
-
const skillBodyCache = new Map();
|
|
702
|
-
const bodyForSkill = (skill) => {
|
|
703
|
-
let cachedBody = skillBodyCache.get(skill);
|
|
704
|
-
if (cachedBody === undefined) {
|
|
705
|
-
cachedBody = loadSkillBodyFor(skill);
|
|
706
|
-
skillBodyCache.set(skill, cachedBody);
|
|
707
|
-
}
|
|
708
|
-
return cachedBody;
|
|
709
|
-
};
|
|
751
|
+
// The SAME resolver the installer stamps its marker hashes from (DEV-672).
|
|
752
|
+
const ownFileBodyFor = makeOwnFileBodyResolver();
|
|
710
753
|
const results = [];
|
|
711
754
|
for (const [target, spec] of Object.entries(TARGETS)) {
|
|
712
755
|
if (spec.mode === 'managed-section') {
|
|
@@ -722,7 +765,10 @@ export async function runStatus(opts, deps = {}) {
|
|
|
722
765
|
target,
|
|
723
766
|
skill,
|
|
724
767
|
path: relPath,
|
|
725
|
-
state: await classifyOwnFileState(agentFs, path.resolve(root, relPath), target, skill,
|
|
768
|
+
state: await classifyOwnFileState(agentFs, path.resolve(root, relPath), target, skill,
|
|
769
|
+
// Deferred, not resolved here: an absent artifact must not need the
|
|
770
|
+
// skill assets at all, as it didn't before DEV-672.
|
|
771
|
+
() => ownFileBodyFor(target, skill)),
|
|
726
772
|
});
|
|
727
773
|
}
|
|
728
774
|
}
|
|
@@ -776,7 +822,7 @@ export function createAgentCommand(deps = {}) {
|
|
|
776
822
|
});
|
|
777
823
|
agent
|
|
778
824
|
.command('list')
|
|
779
|
-
.description('List
|
|
825
|
+
.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)')
|
|
780
826
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
781
827
|
.action(async (_o, command) => {
|
|
782
828
|
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 {};
|