@testsprite/testsprite-cli 0.1.1 → 0.2.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 +16 -13
- package/dist/commands/agent.d.ts +9 -0
- package/dist/commands/agent.js +145 -79
- package/dist/commands/auth.d.ts +10 -0
- package/dist/commands/auth.js +30 -16
- package/dist/commands/init.d.ts +21 -1
- package/dist/commands/init.js +134 -61
- package/dist/commands/project.js +6 -1
- package/dist/commands/test.d.ts +26 -11
- package/dist/commands/test.js +226 -97
- package/dist/index.js +87 -19
- package/dist/lib/agent-targets.d.ts +102 -19
- package/dist/lib/agent-targets.js +156 -35
- package/dist/lib/bundle.d.ts +17 -1
- package/dist/lib/bundle.js +110 -53
- package/dist/lib/client-factory.d.ts +18 -0
- package/dist/lib/client-factory.js +42 -2
- package/dist/lib/credentials.d.ts +7 -0
- package/dist/lib/credentials.js +30 -0
- package/dist/lib/deprecate.d.ts +10 -0
- package/dist/lib/deprecate.js +13 -0
- package/dist/lib/dry-run/samples.js +26 -9
- package/dist/lib/errors.js +3 -3
- package/dist/lib/http.js +2 -1
- package/dist/lib/render-error.d.ts +13 -0
- package/dist/lib/render-error.js +27 -6
- package/dist/lib/skill-nudge.d.ts +73 -0
- package/dist/lib/skill-nudge.js +115 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +3 -1
- package/package.json +4 -1
- package/skills/testsprite-onboard.skill.md +162 -0
- package/{dist/assets/agent-skill → skills}/testsprite-verify.codex.md +4 -2
- package/{dist/assets/agent-skill → skills}/testsprite-verify.skill.md +19 -1
package/dist/index.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
import { Command, CommanderError } from 'commander';
|
|
3
3
|
import { createAgentCommand } from './commands/agent.js';
|
|
4
4
|
import { createAuthCommand } from './commands/auth.js';
|
|
5
|
-
import {
|
|
5
|
+
import { createDeprecatedInitCommand, createSetupCommand, runConfigureViaSetup, } from './commands/init.js';
|
|
6
6
|
import { createProjectCommand } from './commands/project.js';
|
|
7
7
|
import { createTestCommand } from './commands/test.js';
|
|
8
8
|
import { createUsageCommand } from './commands/usage.js';
|
|
9
9
|
import { ApiError, CLIError, RequestTimeoutError } from './lib/errors.js';
|
|
10
10
|
import { Output, isOutputMode } from './lib/output.js';
|
|
11
|
-
import { rephraseUnknownOption } from './lib/render-error.js';
|
|
11
|
+
import { renderCommanderError, rephraseUnknownOption } from './lib/render-error.js';
|
|
12
|
+
import { maybeEmitSkillNudge } from './lib/skill-nudge.js';
|
|
12
13
|
import { VERSION } from './version.js';
|
|
13
14
|
const program = new Command();
|
|
14
15
|
// exitOverride() causes Commander to throw CommanderError instead of calling
|
|
@@ -28,30 +29,80 @@ program
|
|
|
28
29
|
.option('--request-timeout <seconds>', 'Client-side per-request timeout in seconds (default: 120). Aborts any single fetch that does not complete within this deadline. ' +
|
|
29
30
|
'Override via TESTSPRITE_REQUEST_TIMEOUT_MS env var (milliseconds). ' +
|
|
30
31
|
'Range: 1–600. Does not affect the --timeout polling ceiling for `test run/wait`.');
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
// `setup` is the primary onboarding command, listed FIRST in --help so a coding
|
|
33
|
+
// agent reaches it before anything else. `init` is kept as a hidden, deprecated
|
|
34
|
+
// alias (invisible to --help; still works for existing scripts/agents).
|
|
35
|
+
program.addCommand(createSetupCommand({}));
|
|
36
|
+
program.addCommand(createDeprecatedInitCommand({}), { hidden: true });
|
|
37
|
+
// `auth configure` is a hidden, deprecated alias that runs FULL `setup`
|
|
38
|
+
// (configure + skill install), so an agent reaching for the old command still
|
|
39
|
+
// ends up with the skill. `setup` remains the ONLY path that writes credentials.
|
|
40
|
+
const authCommand = createAuthCommand();
|
|
41
|
+
authCommand
|
|
42
|
+
.command('configure', { hidden: true })
|
|
43
|
+
.option('--from-env', 'Read TESTSPRITE_API_KEY (and optionally TESTSPRITE_API_URL) from the environment instead of prompting', false)
|
|
44
|
+
.action(async (cmdOpts, command) => {
|
|
45
|
+
process.stderr.write('[deprecated] `testsprite auth configure` now runs full setup (configure + skill install) — ' +
|
|
46
|
+
'use `testsprite setup` (add --no-agent to skip the skill).\n');
|
|
47
|
+
await runConfigureViaSetup(command, {}, Boolean(cmdOpts.fromEnv));
|
|
48
|
+
});
|
|
49
|
+
program.addCommand(authCommand);
|
|
34
50
|
program.addCommand(createProjectCommand({}));
|
|
35
51
|
program.addCommand(createTestCommand());
|
|
52
|
+
program.addCommand(createAgentCommand({}));
|
|
36
53
|
program.addCommand(createUsageCommand());
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
//
|
|
54
|
+
// Buffer Commander error messages instead of writing immediately. The catch
|
|
55
|
+
// block re-emits in the correct format (JSON or text) once the requested
|
|
56
|
+
// output mode is known. Safe because applyExitOverrideDeep ensures every
|
|
57
|
+
// command throws CommanderError rather than calling process.exit directly.
|
|
58
|
+
let pendingCommanderErrorMsg = null;
|
|
59
|
+
// Propagate exitOverride AND the buffered outputError config to every
|
|
60
|
+
// subcommand in the tree. Commander's addCommand() does NOT inherit either
|
|
61
|
+
// from the parent, so commands built externally (createTestCommand, etc.) and
|
|
62
|
+
// attached via addCommand() still have _exitCallback = null and a default
|
|
63
|
+
// outputError that writes immediately. Both must be applied after the full
|
|
64
|
+
// command tree is assembled so every leaf subcommand behaves consistently.
|
|
43
65
|
function applyExitOverrideDeep(cmd) {
|
|
44
66
|
cmd.exitOverride();
|
|
67
|
+
cmd.configureOutput({
|
|
68
|
+
outputError(str, _write) {
|
|
69
|
+
const rephrased = rephraseUnknownOption(str);
|
|
70
|
+
pendingCommanderErrorMsg = rephrased !== null ? `${rephrased}\n` : str;
|
|
71
|
+
},
|
|
72
|
+
});
|
|
45
73
|
for (const child of cmd.commands) {
|
|
46
74
|
applyExitOverrideDeep(child);
|
|
47
75
|
}
|
|
48
76
|
}
|
|
49
77
|
applyExitOverrideDeep(program);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Render a leaf command's full path (group + leaf), e.g. `test run` /
|
|
80
|
+
* `auth whoami`, by walking parents up to (but not including) the root program.
|
|
81
|
+
*/
|
|
82
|
+
function commandPathOf(cmd) {
|
|
83
|
+
const names = [];
|
|
84
|
+
let cur = cmd;
|
|
85
|
+
while (cur && cur.parent) {
|
|
86
|
+
names.unshift(cur.name());
|
|
87
|
+
cur = cur.parent;
|
|
88
|
+
}
|
|
89
|
+
return names.join(' ');
|
|
90
|
+
}
|
|
91
|
+
// Best-effort onboarding nudge (see lib/skill-nudge.ts): when a configured
|
|
92
|
+
// caller drives a verify-loop command in a project with no installed skill,
|
|
93
|
+
// point it at `testsprite setup`. A preAction hook runs before every leaf
|
|
94
|
+
// action; the helper self-gates (text-only, non-dry-run, a small command
|
|
95
|
+
// allowlist, opt-out via TESTSPRITE_NO_SKILL_WARNING) and never throws.
|
|
96
|
+
program.hook('preAction', (_thisCommand, actionCommand) => {
|
|
97
|
+
const globals = actionCommand.optsWithGlobals();
|
|
98
|
+
maybeEmitSkillNudge({
|
|
99
|
+
commandPath: commandPathOf(actionCommand),
|
|
100
|
+
output: isOutputMode(globals.output) ? globals.output : 'text',
|
|
101
|
+
dryRun: globals.dryRun ?? false,
|
|
102
|
+
profile: globals.profile ?? 'default',
|
|
103
|
+
cwd: process.cwd(),
|
|
104
|
+
env: process.env,
|
|
105
|
+
});
|
|
55
106
|
});
|
|
56
107
|
try {
|
|
57
108
|
await program.parseAsync(process.argv);
|
|
@@ -115,9 +166,8 @@ catch (err) {
|
|
|
115
166
|
process.exit(err.exitCode);
|
|
116
167
|
}
|
|
117
168
|
if (err instanceof CommanderError) {
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
// help / version → 0 (user asked for it — no error)
|
|
169
|
+
// Map exit codes per the CLI taxonomy:
|
|
170
|
+
// help / version → 0 (user asked for it; Commander already wrote the text)
|
|
121
171
|
// parse errors → 5 (VALIDATION_ERROR family: missing arg, invalid
|
|
122
172
|
// option, unknown command, etc.)
|
|
123
173
|
//
|
|
@@ -134,6 +184,24 @@ catch (err) {
|
|
|
134
184
|
err.code === 'commander.version') {
|
|
135
185
|
process.exit(0);
|
|
136
186
|
}
|
|
187
|
+
// For parse errors, write the buffered message in the correct format.
|
|
188
|
+
// rawMode from program.opts() is reliable when --output was parsed before
|
|
189
|
+
// the error. When the error occurs first (e.g. `testsprite badcmd --output
|
|
190
|
+
// json`), rawMode is the default 'text'; scan argv as a best-effort
|
|
191
|
+
// fallback so machine consumers still receive a JSON envelope.
|
|
192
|
+
const commanderMode = (() => {
|
|
193
|
+
if (rawMode === 'json')
|
|
194
|
+
return 'json';
|
|
195
|
+
for (let i = 2; i < process.argv.length; i++) {
|
|
196
|
+
const arg = process.argv[i];
|
|
197
|
+
if (arg === '--output' && process.argv[i + 1] === 'json')
|
|
198
|
+
return 'json';
|
|
199
|
+
if (arg === '--output=json')
|
|
200
|
+
return 'json';
|
|
201
|
+
}
|
|
202
|
+
return mode;
|
|
203
|
+
})();
|
|
204
|
+
process.stderr.write(renderCommanderError(pendingCommanderErrorMsg, err.message, commanderMode));
|
|
137
205
|
process.exit(5);
|
|
138
206
|
}
|
|
139
207
|
if (err instanceof CLIError) {
|
|
@@ -1,49 +1,132 @@
|
|
|
1
1
|
export type AgentTarget = 'claude' | 'cursor' | 'cline' | 'antigravity' | 'codex';
|
|
2
2
|
export interface TargetSpec {
|
|
3
3
|
status: 'ga' | 'experimental';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Repo-relative landing path for the CANONICAL skill (`testsprite-verify`),
|
|
6
|
+
* POSIX separators. Kept for back-compat: `skill-nudge.ts` reads this to detect
|
|
7
|
+
* a verify install, and `agent list`/tests reference it. For any skill, derive
|
|
8
|
+
* the real path via {@link pathFor} — this field is `pathFor(target, SKILL_NAME)`.
|
|
9
|
+
*/
|
|
5
10
|
path: string;
|
|
6
11
|
/**
|
|
7
|
-
* 'own-file': the CLI owns the whole file (
|
|
12
|
+
* 'own-file': the CLI owns the whole file (claude/cursor/cline/antigravity).
|
|
8
13
|
* 'managed-section': the CLI writes only a sentinel-delimited section inside
|
|
9
14
|
* a potentially user-authored file (codex target, AGENTS.md).
|
|
10
15
|
*/
|
|
11
16
|
mode: 'own-file' | 'managed-section';
|
|
12
|
-
/**
|
|
13
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Wrap a skill body in this target's frontmatter/header. Takes the skill's
|
|
19
|
+
* `name`+`description` (own-file targets emit them as frontmatter) and the body.
|
|
20
|
+
* No-op for cline (body verbatim) and codex (managed-section authors plain
|
|
21
|
+
* Markdown with no frontmatter).
|
|
22
|
+
*/
|
|
23
|
+
wrap(name: string, description: string, body: string): string;
|
|
14
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* How a skill contributes to the codex target's always-on `AGENTS.md` section.
|
|
27
|
+
*
|
|
28
|
+
* - 'full': inject the skill's trimmed codex body (a `*.codex.md` asset). Used by
|
|
29
|
+
* `testsprite-verify` (~6 KiB).
|
|
30
|
+
* - 'line': inject a single short line authored inline here. Used by
|
|
31
|
+
* `testsprite-onboard` — the full 6-step flow doesn't belong in an always-on,
|
|
32
|
+
* 32 KiB-budgeted file, but a one-line signal does.
|
|
33
|
+
* - 'none': skill is not represented in AGENTS.md at all (reserved).
|
|
34
|
+
*/
|
|
35
|
+
export type CodexContribution = {
|
|
36
|
+
kind: 'full';
|
|
37
|
+
file: string;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'line';
|
|
40
|
+
text: string;
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'none';
|
|
43
|
+
};
|
|
44
|
+
export interface SkillSpec {
|
|
45
|
+
/** Skill name — appears in own-file frontmatter and the landing path. */
|
|
46
|
+
name: string;
|
|
47
|
+
/** ≤1536 chars (claude description cap). Byte-identical to its template doc. */
|
|
48
|
+
description: string;
|
|
49
|
+
/** Own-file body asset basename under `skills/`, e.g. 'testsprite-verify.skill.md'. */
|
|
50
|
+
bodyFile: string;
|
|
51
|
+
/** How this skill contributes to the codex AGENTS.md managed section. */
|
|
52
|
+
codex: CodexContribution;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* `testsprite-onboard` codex contribution — a single always-on line. Kept here
|
|
56
|
+
* (not in a `*.codex.md` asset) because it is one line; see {@link CodexContribution}.
|
|
57
|
+
*/
|
|
58
|
+
export declare const ONBOARD_CODEX_LINE = "**First-time setup:** if this repo has no TestSprite tests yet, seed a *broad* first suite across its main user flows \u2014 not just one test \u2014 each with a concrete, observable assertion, before reporting setup as done.";
|
|
59
|
+
/**
|
|
60
|
+
* The skill registry. Each entry owns its name, description (drift-guarded by a
|
|
61
|
+
* byte-identity unit test against a template doc), own-file body asset, and codex
|
|
62
|
+
* contribution. `agent install` / `setup` install {@link DEFAULT_SKILLS}; the
|
|
63
|
+
* codex target aggregates every installed skill's codex contribution into ONE
|
|
64
|
+
* AGENTS.md section.
|
|
65
|
+
*/
|
|
66
|
+
export declare const SKILLS: Record<string, SkillSpec>;
|
|
67
|
+
/**
|
|
68
|
+
* Skills installed by `setup` and by `agent install` when no `--skill` subset is
|
|
69
|
+
* given. Order is significant for the codex aggregate (verify first, then the
|
|
70
|
+
* onboard line as a short addendum).
|
|
71
|
+
*/
|
|
72
|
+
export declare const DEFAULT_SKILLS: readonly ["testsprite-verify", "testsprite-onboard"];
|
|
73
|
+
/** @deprecated The canonical skill name. New code: iterate {@link SKILLS}. */
|
|
15
74
|
export declare const SKILL_NAME = "testsprite-verify";
|
|
16
75
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
76
|
+
* @deprecated The canonical skill's description. New code:
|
|
77
|
+
* `SKILLS['testsprite-verify'].description`. Kept so existing importers and the
|
|
78
|
+
* byte-identity unit test keep working.
|
|
79
|
+
*/
|
|
80
|
+
export declare const SKILL_DESCRIPTION: string;
|
|
81
|
+
/**
|
|
82
|
+
* Repo-relative landing path for a given skill on a given target (POSIX
|
|
83
|
+
* separators). Own-file targets embed the skill name in the path so multiple
|
|
84
|
+
* skills coexist; the codex target always lands at the single shared `AGENTS.md`
|
|
85
|
+
* (every skill's codex contribution is merged into one managed section there).
|
|
19
86
|
*/
|
|
20
|
-
export declare
|
|
87
|
+
export declare function pathFor(target: AgentTarget, skill: string): string;
|
|
21
88
|
export declare const TARGETS: Record<AgentTarget, TargetSpec>;
|
|
22
89
|
/** Sentinel pair that bounds our managed section in AGENTS.md. */
|
|
23
90
|
export declare const MANAGED_SECTION_BEGIN = "<!-- BEGIN TESTSPRITE AGENT SECTION (testsprite agent install codex) -->";
|
|
24
91
|
export declare const MANAGED_SECTION_END = "<!-- END TESTSPRITE AGENT SECTION -->";
|
|
25
92
|
type ReadFn = (url: URL) => string;
|
|
93
|
+
/** Load a skill's own-file body by skill name (frontmatter is added by `wrap`). */
|
|
94
|
+
export declare function loadSkillBodyFor(skill: string, read?: ReadFn): string;
|
|
26
95
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
96
|
+
* Resolve a skill's codex (AGENTS.md) contribution as a Markdown string.
|
|
97
|
+
* 'full' → read the `*.codex.md` asset; 'line' → the inline one-liner; 'none' → ''.
|
|
98
|
+
*/
|
|
99
|
+
export declare function codexContentFor(skill: string, read?: ReadFn): string;
|
|
100
|
+
/**
|
|
101
|
+
* Compose the codex managed-section BODY (sans sentinels) from several skills:
|
|
102
|
+
* each skill's codex contribution, trimmed, joined by a blank line, in the given
|
|
103
|
+
* order. A single `['testsprite-verify']` aggregate is byte-identical to the old
|
|
104
|
+
* single-skill codex body, so existing AGENTS.md installs round-trip unchanged.
|
|
105
|
+
*/
|
|
106
|
+
export declare function buildCodexAggregate(skills: readonly string[], read?: ReadFn): string;
|
|
107
|
+
/**
|
|
108
|
+
* Back-compat: the canonical verify skill body (own-file). Kept so existing
|
|
109
|
+
* importers and the `loadSkillBody(read)` unit-test signature keep working.
|
|
110
|
+
* @deprecated Use {@link loadSkillBodyFor}.
|
|
32
111
|
*/
|
|
33
112
|
export declare function loadSkillBody(read?: ReadFn): string;
|
|
34
113
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
114
|
+
* Back-compat: the canonical verify skill's trimmed codex body. Kept so existing
|
|
115
|
+
* importers and the `loadCodexSkillBody(read)` unit-test signature keep working.
|
|
116
|
+
* @deprecated Use {@link codexContentFor}.
|
|
37
117
|
*/
|
|
38
118
|
export declare function loadCodexSkillBody(read?: ReadFn): string;
|
|
39
119
|
/**
|
|
40
|
-
*
|
|
120
|
+
* The exact bytes to write for one skill on one target.
|
|
41
121
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
122
|
+
* - own-file targets: `body` defaults to the skill's own-file asset, wrapped in
|
|
123
|
+
* the target's frontmatter/header.
|
|
124
|
+
* - codex (managed-section): returns the skill's codex contribution unwrapped
|
|
125
|
+
* (plain Markdown, no frontmatter). The real install does NOT call this for
|
|
126
|
+
* codex — it aggregates all skills via {@link buildCodexAggregate} — but it is
|
|
127
|
+
* kept single-skill here for tests and parity. Pass an explicit `body` to override.
|
|
45
128
|
*/
|
|
46
|
-
export declare function renderForTarget(t: AgentTarget, body?: string): {
|
|
129
|
+
export declare function renderForTarget(t: AgentTarget, skill: string, body?: string): {
|
|
47
130
|
path: string;
|
|
48
131
|
content: string;
|
|
49
132
|
};
|
|
@@ -1,40 +1,103 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
+
/**
|
|
3
|
+
* `testsprite-onboard` codex contribution — a single always-on line. Kept here
|
|
4
|
+
* (not in a `*.codex.md` asset) because it is one line; see {@link CodexContribution}.
|
|
5
|
+
*/
|
|
6
|
+
export const ONBOARD_CODEX_LINE = '**First-time setup:** if this repo has no TestSprite tests yet, seed a *broad* first suite across its main user flows — not just one test — each with a concrete, observable assertion, before reporting setup as done.';
|
|
7
|
+
/**
|
|
8
|
+
* The skill registry. Each entry owns its name, description (drift-guarded by a
|
|
9
|
+
* byte-identity unit test against a template doc), own-file body asset, and codex
|
|
10
|
+
* contribution. `agent install` / `setup` install {@link DEFAULT_SKILLS}; the
|
|
11
|
+
* codex target aggregates every installed skill's codex contribution into ONE
|
|
12
|
+
* AGENTS.md section.
|
|
13
|
+
*/
|
|
14
|
+
export const SKILLS = {
|
|
15
|
+
'testsprite-verify': {
|
|
16
|
+
name: 'testsprite-verify',
|
|
17
|
+
description: 'TestSprite verification loop — after finishing a feature or fix in a TestSprite-tested repo, use the `testsprite` CLI to run the relevant TestSprite tests against the change and inspect any failure artifacts before reporting the work as done. Use whenever code has changed outside docs/config and is about to be reported complete — by running an existing test that covers the change, or by creating a new TestSprite test (a frontend plan, or a backend Python assertion) and running it to a terminal verdict.',
|
|
18
|
+
bodyFile: 'testsprite-verify.skill.md',
|
|
19
|
+
codex: { kind: 'full', file: 'testsprite-verify.codex.md' },
|
|
20
|
+
},
|
|
21
|
+
'testsprite-onboard': {
|
|
22
|
+
name: 'testsprite-onboard',
|
|
23
|
+
description: 'Stand up a complete, runnable TestSprite test suite for the current repo at first use — create a project (with a target URL and auth), derive a coherent set of tests from the codebase, batch-create them, and smoke-run a few to a green verdict so the user immediately has something worth running. Use ONLY when a repo has no TestSprite tests yet (a fresh project), right after `testsprite setup`, or when the user asks to "set up / bootstrap / seed tests". This is first-run setup, NOT change verification — once a project already has tests, use the testsprite-verify skill instead.',
|
|
24
|
+
bodyFile: 'testsprite-onboard.skill.md',
|
|
25
|
+
codex: { kind: 'line', text: ONBOARD_CODEX_LINE },
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Skills installed by `setup` and by `agent install` when no `--skill` subset is
|
|
30
|
+
* given. Order is significant for the codex aggregate (verify first, then the
|
|
31
|
+
* onboard line as a short addendum).
|
|
32
|
+
*/
|
|
33
|
+
export const DEFAULT_SKILLS = ['testsprite-verify', 'testsprite-onboard'];
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Back-compat single-skill exports (= the canonical `testsprite-verify` skill)
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
/** @deprecated The canonical skill name. New code: iterate {@link SKILLS}. */
|
|
2
38
|
export const SKILL_NAME = 'testsprite-verify';
|
|
3
39
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
40
|
+
* @deprecated The canonical skill's description. New code:
|
|
41
|
+
* `SKILLS['testsprite-verify'].description`. Kept so existing importers and the
|
|
42
|
+
* byte-identity unit test keep working.
|
|
6
43
|
*/
|
|
7
|
-
export const SKILL_DESCRIPTION = '
|
|
8
|
-
|
|
9
|
-
|
|
44
|
+
export const SKILL_DESCRIPTION = SKILLS['testsprite-verify'].description;
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Wrappers
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
function wrapSkill(name, description, body) {
|
|
49
|
+
return `---\nname: ${name}\ndescription: ${description}\n---\n\n${body}\n`;
|
|
10
50
|
}
|
|
11
|
-
function wrapMdc(body) {
|
|
12
|
-
return `---\ndescription: ${
|
|
51
|
+
function wrapMdc(_name, description, body) {
|
|
52
|
+
return `---\ndescription: ${description}\nalwaysApply: false\n---\n\n${body}\n`;
|
|
53
|
+
}
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// Landing paths
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
/**
|
|
58
|
+
* Repo-relative landing path for a given skill on a given target (POSIX
|
|
59
|
+
* separators). Own-file targets embed the skill name in the path so multiple
|
|
60
|
+
* skills coexist; the codex target always lands at the single shared `AGENTS.md`
|
|
61
|
+
* (every skill's codex contribution is merged into one managed section there).
|
|
62
|
+
*/
|
|
63
|
+
export function pathFor(target, skill) {
|
|
64
|
+
switch (target) {
|
|
65
|
+
case 'claude':
|
|
66
|
+
return `.claude/skills/${skill}/SKILL.md`;
|
|
67
|
+
case 'antigravity':
|
|
68
|
+
return `.agents/skills/${skill}/SKILL.md`;
|
|
69
|
+
case 'cursor':
|
|
70
|
+
return `.cursor/rules/${skill}.mdc`;
|
|
71
|
+
case 'cline':
|
|
72
|
+
return `.clinerules/${skill}.md`;
|
|
73
|
+
case 'codex':
|
|
74
|
+
return 'AGENTS.md';
|
|
75
|
+
}
|
|
13
76
|
}
|
|
14
77
|
export const TARGETS = {
|
|
15
78
|
claude: {
|
|
16
79
|
status: 'ga',
|
|
17
|
-
path: '
|
|
80
|
+
path: pathFor('claude', SKILL_NAME),
|
|
18
81
|
mode: 'own-file',
|
|
19
82
|
wrap: wrapSkill,
|
|
20
83
|
},
|
|
21
84
|
antigravity: {
|
|
22
85
|
status: 'experimental',
|
|
23
|
-
path: '
|
|
86
|
+
path: pathFor('antigravity', SKILL_NAME),
|
|
24
87
|
mode: 'own-file',
|
|
25
88
|
wrap: wrapSkill,
|
|
26
89
|
},
|
|
27
90
|
cursor: {
|
|
28
91
|
status: 'experimental',
|
|
29
|
-
path: '
|
|
92
|
+
path: pathFor('cursor', SKILL_NAME),
|
|
30
93
|
mode: 'own-file',
|
|
31
94
|
wrap: wrapMdc,
|
|
32
95
|
},
|
|
33
96
|
cline: {
|
|
34
97
|
status: 'experimental',
|
|
35
|
-
path: '
|
|
98
|
+
path: pathFor('cline', SKILL_NAME),
|
|
36
99
|
mode: 'own-file',
|
|
37
|
-
wrap: body => body,
|
|
100
|
+
wrap: (_name, _description, body) => body,
|
|
38
101
|
},
|
|
39
102
|
/**
|
|
40
103
|
* codex target — managed-section mode.
|
|
@@ -43,7 +106,9 @@ export const TARGETS = {
|
|
|
43
106
|
* for the whole file). Unlike own-file targets, we must NOT clobber a user's
|
|
44
107
|
* existing AGENTS.md: we write only a sentinel-delimited section so other
|
|
45
108
|
* project instructions coexist. The sentinel pair is the canonical identity
|
|
46
|
-
* marker; the content between them is ours to replace.
|
|
109
|
+
* marker; the content between them is ours to replace. EVERY installed skill's
|
|
110
|
+
* codex contribution is aggregated into this one section (see
|
|
111
|
+
* {@link buildCodexAggregate}).
|
|
47
112
|
*
|
|
48
113
|
* --force with managed-section: replaces the section unconditionally but
|
|
49
114
|
* NEVER destroys content outside the sentinels. No whole-file .bak is written
|
|
@@ -52,48 +117,104 @@ export const TARGETS = {
|
|
|
52
117
|
*/
|
|
53
118
|
codex: {
|
|
54
119
|
status: 'experimental',
|
|
55
|
-
path: '
|
|
120
|
+
path: pathFor('codex', SKILL_NAME),
|
|
56
121
|
mode: 'managed-section',
|
|
57
122
|
// wrap is a no-op for managed-section — content is authored as plain Markdown
|
|
58
123
|
// with no frontmatter (AGENTS.md is plain prose, not a skill schema).
|
|
59
|
-
wrap: body => body,
|
|
124
|
+
wrap: (_name, _description, body) => body,
|
|
60
125
|
},
|
|
61
126
|
};
|
|
62
127
|
/** Sentinel pair that bounds our managed section in AGENTS.md. */
|
|
63
128
|
export const MANAGED_SECTION_BEGIN = '<!-- BEGIN TESTSPRITE AGENT SECTION (testsprite agent install codex) -->';
|
|
64
129
|
export const MANAGED_SECTION_END = '<!-- END TESTSPRITE AGENT SECTION -->';
|
|
65
130
|
const defaultRead = (url) => readFileSync(url, 'utf8');
|
|
131
|
+
// ---------------------------------------------------------------------------
|
|
132
|
+
// Asset loaders
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
66
134
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* Injectable `read`
|
|
135
|
+
* Resolve a `skills/<file>` asset. `../../skills/...` resolves to the repo-root
|
|
136
|
+
* `skills/` directory in BOTH source (vitest: `src/lib/` → `../../skills`) and
|
|
137
|
+
* the built/published package (`dist/lib/` → `../../skills` = package root). The
|
|
138
|
+
* directory ships verbatim via package.json `files`, so no build-time copy step
|
|
139
|
+
* is needed. Injectable `read` keeps unit tests off disk.
|
|
140
|
+
*/
|
|
141
|
+
function readSkillAsset(file, read) {
|
|
142
|
+
return read(new URL(`../../skills/${file}`, import.meta.url));
|
|
143
|
+
}
|
|
144
|
+
/** Load a skill's own-file body by skill name (frontmatter is added by `wrap`). */
|
|
145
|
+
export function loadSkillBodyFor(skill, read = defaultRead) {
|
|
146
|
+
const spec = SKILLS[skill];
|
|
147
|
+
if (!spec)
|
|
148
|
+
throw new Error(`unknown skill: ${skill}`);
|
|
149
|
+
return readSkillAsset(spec.bodyFile, read);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Resolve a skill's codex (AGENTS.md) contribution as a Markdown string.
|
|
153
|
+
* 'full' → read the `*.codex.md` asset; 'line' → the inline one-liner; 'none' → ''.
|
|
154
|
+
*/
|
|
155
|
+
export function codexContentFor(skill, read = defaultRead) {
|
|
156
|
+
const spec = SKILLS[skill];
|
|
157
|
+
if (!spec)
|
|
158
|
+
throw new Error(`unknown skill: ${skill}`);
|
|
159
|
+
const c = spec.codex;
|
|
160
|
+
if (c.kind === 'full')
|
|
161
|
+
return readSkillAsset(c.file, read);
|
|
162
|
+
if (c.kind === 'line')
|
|
163
|
+
return c.text;
|
|
164
|
+
return '';
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Compose the codex managed-section BODY (sans sentinels) from several skills:
|
|
168
|
+
* each skill's codex contribution, trimmed, joined by a blank line, in the given
|
|
169
|
+
* order. A single `['testsprite-verify']` aggregate is byte-identical to the old
|
|
170
|
+
* single-skill codex body, so existing AGENTS.md installs round-trip unchanged.
|
|
171
|
+
*/
|
|
172
|
+
export function buildCodexAggregate(skills, read = defaultRead) {
|
|
173
|
+
return skills
|
|
174
|
+
.map(s => codexContentFor(s, read).trimEnd())
|
|
175
|
+
.filter(Boolean)
|
|
176
|
+
.join('\n\n');
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Back-compat: the canonical verify skill body (own-file). Kept so existing
|
|
180
|
+
* importers and the `loadSkillBody(read)` unit-test signature keep working.
|
|
181
|
+
* @deprecated Use {@link loadSkillBodyFor}.
|
|
72
182
|
*/
|
|
73
183
|
export function loadSkillBody(read = defaultRead) {
|
|
74
|
-
return
|
|
184
|
+
return loadSkillBodyFor(SKILL_NAME, read);
|
|
75
185
|
}
|
|
76
186
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
187
|
+
* Back-compat: the canonical verify skill's trimmed codex body. Kept so existing
|
|
188
|
+
* importers and the `loadCodexSkillBody(read)` unit-test signature keep working.
|
|
189
|
+
* @deprecated Use {@link codexContentFor}.
|
|
79
190
|
*/
|
|
80
191
|
export function loadCodexSkillBody(read = defaultRead) {
|
|
81
|
-
return
|
|
192
|
+
return codexContentFor(SKILL_NAME, read);
|
|
82
193
|
}
|
|
194
|
+
// ---------------------------------------------------------------------------
|
|
195
|
+
// renderForTarget
|
|
196
|
+
// ---------------------------------------------------------------------------
|
|
83
197
|
/**
|
|
84
|
-
*
|
|
198
|
+
* The exact bytes to write for one skill on one target.
|
|
85
199
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
200
|
+
* - own-file targets: `body` defaults to the skill's own-file asset, wrapped in
|
|
201
|
+
* the target's frontmatter/header.
|
|
202
|
+
* - codex (managed-section): returns the skill's codex contribution unwrapped
|
|
203
|
+
* (plain Markdown, no frontmatter). The real install does NOT call this for
|
|
204
|
+
* codex — it aggregates all skills via {@link buildCodexAggregate} — but it is
|
|
205
|
+
* kept single-skill here for tests and parity. Pass an explicit `body` to override.
|
|
89
206
|
*/
|
|
90
|
-
export function renderForTarget(t, body) {
|
|
207
|
+
export function renderForTarget(t, skill, body) {
|
|
91
208
|
const spec = TARGETS[t];
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
209
|
+
const skillSpec = SKILLS[skill];
|
|
210
|
+
if (!skillSpec)
|
|
211
|
+
throw new Error(`unknown skill: ${skill}`);
|
|
212
|
+
const path = pathFor(t, skill);
|
|
213
|
+
if (spec.mode === 'managed-section') {
|
|
214
|
+
const resolvedBody = body !== undefined ? body : codexContentFor(skill);
|
|
215
|
+
return { path, content: spec.wrap(skillSpec.name, skillSpec.description, resolvedBody) };
|
|
216
|
+
}
|
|
217
|
+
const resolvedBody = body !== undefined ? body : loadSkillBodyFor(skill);
|
|
218
|
+
return { path, content: spec.wrap(skillSpec.name, skillSpec.description, resolvedBody) };
|
|
98
219
|
}
|
|
99
220
|
//# sourceMappingURL=agent-targets.js.map
|
package/dist/lib/bundle.d.ts
CHANGED
|
@@ -36,6 +36,10 @@ import type { CliFailureContext } from '../commands/test.js';
|
|
|
36
36
|
import type { FetchImpl } from './http.js';
|
|
37
37
|
/** Schema version stamped into `meta.json`. Bumps with the contract. */
|
|
38
38
|
export declare const BUNDLE_SCHEMA_VERSION: "cli-v1";
|
|
39
|
+
/** Max fetch attempts for each presigned URL (initial + retries). */
|
|
40
|
+
export declare const STREAM_URL_MAX_RETRIES = 3;
|
|
41
|
+
/** Delay between retries for transient transport failures (ms). */
|
|
42
|
+
export declare const STREAM_URL_RETRY_DELAY_MS = 1000;
|
|
39
43
|
/** Default radius around the failed step when `--failed-only` is set. */
|
|
40
44
|
export declare const FAILED_ONLY_RADIUS = 1;
|
|
41
45
|
/**
|
|
@@ -141,6 +145,12 @@ export declare function pickCodeExtension(language: string, framework: string):
|
|
|
141
145
|
* naturally without breaking existing fixtures.
|
|
142
146
|
*/
|
|
143
147
|
export declare function stepFilenamePrefix(stepIndex: number): string;
|
|
148
|
+
/**
|
|
149
|
+
* Refuse a composed artifact path that escapes `baseDir`. Step filenames are
|
|
150
|
+
* built from response-controlled fields, so this is the final containment
|
|
151
|
+
* check before any write. Returns the validated absolute path.
|
|
152
|
+
*/
|
|
153
|
+
export declare function assertNoEscape(baseDir: string, segment: string): string;
|
|
144
154
|
/**
|
|
145
155
|
* Build the §7.1 meta.json given a context. Pure function, no I/O —
|
|
146
156
|
* lets specs assert the meta shape without touching disk.
|
|
@@ -174,5 +184,11 @@ export declare function writeBundle(ctx: CliFailureContext, options: WriteBundle
|
|
|
174
184
|
* the upstream reader rather than buffering chunks in V8 heap. This
|
|
175
185
|
* matters for video files (multi-MB) and for very large HTML
|
|
176
186
|
* snapshots.
|
|
187
|
+
*
|
|
188
|
+
* Transport failures (network reset, DNS blip, mid-stream EOF) are
|
|
189
|
+
* retried up to STREAM_URL_MAX_RETRIES times with a fixed delay.
|
|
190
|
+
* Presigned URLs are valid for 15 minutes, so retries are safe.
|
|
177
191
|
*/
|
|
178
|
-
export declare function streamUrlToFile(url: string, filePath: string, fetchImpl: FetchImpl
|
|
192
|
+
export declare function streamUrlToFile(url: string, filePath: string, fetchImpl: FetchImpl, deps?: {
|
|
193
|
+
sleep?: (ms: number) => Promise<void>;
|
|
194
|
+
}): Promise<void>;
|