@testsprite/testsprite-cli 0.1.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +34 -26
  2. package/dist/commands/agent.d.ts +52 -0
  3. package/dist/commands/agent.js +341 -93
  4. package/dist/commands/auth.js +29 -27
  5. package/dist/commands/doctor.d.ts +49 -0
  6. package/dist/commands/doctor.js +211 -0
  7. package/dist/commands/init.d.ts +7 -1
  8. package/dist/commands/init.js +66 -26
  9. package/dist/commands/project.d.ts +50 -1
  10. package/dist/commands/project.js +257 -43
  11. package/dist/commands/test.d.ts +214 -12
  12. package/dist/commands/test.js +1310 -174
  13. package/dist/commands/usage.js +13 -12
  14. package/dist/index.js +71 -18
  15. package/dist/lib/agent-targets.d.ts +169 -22
  16. package/dist/lib/agent-targets.js +335 -34
  17. package/dist/lib/bundle.d.ts +51 -1
  18. package/dist/lib/bundle.js +146 -55
  19. package/dist/lib/client-factory.d.ts +43 -0
  20. package/dist/lib/client-factory.js +89 -2
  21. package/dist/lib/config.d.ts +2 -0
  22. package/dist/lib/config.js +11 -2
  23. package/dist/lib/credentials.d.ts +7 -0
  24. package/dist/lib/credentials.js +40 -1
  25. package/dist/lib/dry-run/samples.d.ts +5 -0
  26. package/dist/lib/dry-run/samples.js +54 -9
  27. package/dist/lib/flaky.d.ts +80 -0
  28. package/dist/lib/flaky.js +76 -0
  29. package/dist/lib/http.d.ts +20 -0
  30. package/dist/lib/http.js +216 -132
  31. package/dist/lib/interrupt.d.ts +61 -0
  32. package/dist/lib/interrupt.js +97 -0
  33. package/dist/lib/junit-report.d.ts +58 -0
  34. package/dist/lib/junit-report.js +210 -0
  35. package/dist/lib/output.d.ts +16 -1
  36. package/dist/lib/output.js +24 -2
  37. package/dist/lib/pagination.d.ts +4 -3
  38. package/dist/lib/pagination.js +34 -6
  39. package/dist/lib/prompt.js +52 -8
  40. package/dist/lib/proxy.d.ts +29 -0
  41. package/dist/lib/proxy.js +30 -0
  42. package/dist/lib/render-error.d.ts +13 -0
  43. package/dist/lib/render-error.js +30 -7
  44. package/dist/lib/skill-nudge.d.ts +2 -2
  45. package/dist/lib/skill-nudge.js +13 -4
  46. package/dist/lib/target-url.js +8 -1
  47. package/dist/lib/ticker.d.ts +11 -1
  48. package/dist/lib/ticker.js +33 -1
  49. package/dist/lib/update-check.d.ts +67 -0
  50. package/dist/lib/update-check.js +246 -0
  51. package/dist/version-guard.d.ts +33 -0
  52. package/dist/version-guard.js +39 -0
  53. package/dist/version.d.ts +1 -1
  54. package/dist/version.js +1 -1
  55. package/package.json +3 -2
  56. package/skills/testsprite-onboard.skill.md +183 -0
  57. package/skills/testsprite-verify.codex.md +2 -0
  58. package/skills/testsprite-verify.skill.md +52 -1
@@ -13,10 +13,10 @@
13
13
  * `GET /api/cli/v1/usage` endpoint returning `{ credits, subPlan, creditsPerRun }`.
14
14
  */
15
15
  import { Command } from 'commander';
16
- import { emitDryRunBanner, makeHttpClient, } from '../lib/client-factory.js';
16
+ import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
17
17
  import { loadConfig } from '../lib/config.js';
18
18
  import { resolvePortalBase } from '../lib/facade.js';
19
- import { GLOBAL_OPTS_HINT, Output } from '../lib/output.js';
19
+ import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
20
20
  /** Dry-run canned response — matches what the real /me + User lookup would return. */
21
21
  export const DRY_RUN_USAGE_SAMPLE = {
22
22
  userId: '11111111-1111-4111-8111-111111111111',
@@ -91,7 +91,11 @@ function renderUsage(u, portalBase) {
91
91
  }
92
92
  if (u.creditsPerRun !== undefined) {
93
93
  lines.push(`cost per frontend run: ${u.creditsPerRun} credit(s)`);
94
- lines.push(`cost per backend run: 0 credit(s) (backend tests bill at code-generation, not at run time)`);
94
+ // Backend runs DO consume credits (confirmed by design 2026-06-30 / DEV-289).
95
+ // The API exposes no backend-specific per-run cost field, and it differs from
96
+ // the frontend rate, so state that it bills without asserting a possibly-wrong
97
+ // number — check your balance before/after, or see the billing page.
98
+ lines.push(`cost per backend run: also consumes credits (exact amount not reported by the API)`);
95
99
  }
96
100
  // Pre-flight hint: how many runs the current balance can fund
97
101
  if (u.credits !== undefined && u.creditsPerRun !== undefined && u.creditsPerRun > 0) {
@@ -122,7 +126,12 @@ export function createUsageCommand(deps = {}) {
122
126
  .addHelpText('after', '\nExamples:\n' +
123
127
  ' testsprite usage # show balance + plan\n' +
124
128
  ' testsprite usage --output json # machine-readable balance\n' +
129
+ ' testsprite usage --debug # trace HTTP method/path, request id, latency\n' +
125
130
  ' testsprite credits # alias for usage\n' +
131
+ '\nExit codes:\n' +
132
+ ' 0 success (or --dry-run)\n' +
133
+ ' 3 auth error — run `testsprite setup` to configure credentials\n' +
134
+ ' 10 transport/network failure (UNAVAILABLE) — retry the command\n' +
126
135
  '\nNote: credit balance requires a backend update to /me. Until shipped,\n' +
127
136
  " check your portal's Billing page (/dashboard/settings/billing) for your balance.")
128
137
  .action(async (_cmdOpts, command) => {
@@ -134,7 +143,7 @@ function resolveCommonOptions(command) {
134
143
  const globals = command.optsWithGlobals();
135
144
  return {
136
145
  profile: globals.profile ?? 'default',
137
- output: globals.output ?? 'text',
146
+ output: resolveOutputMode(globals.output),
138
147
  endpointUrl: globals.endpointUrl,
139
148
  debug: globals.debug ?? false,
140
149
  verbose: globals.verbose ?? false,
@@ -142,14 +151,6 @@ function resolveCommonOptions(command) {
142
151
  requestTimeoutMs: parseRequestTimeoutFlag(globals.requestTimeout),
143
152
  };
144
153
  }
145
- function parseRequestTimeoutFlag(raw) {
146
- if (raw === undefined)
147
- return undefined;
148
- const n = Number(raw);
149
- if (!Number.isFinite(n) || n <= 0)
150
- return undefined;
151
- return Math.round(n * 1000);
152
- }
153
154
  function makeOutput(mode, deps) {
154
155
  return new Output(mode, { stdout: deps.stdout, stderr: deps.stderr });
155
156
  }
package/dist/index.js CHANGED
@@ -2,15 +2,26 @@
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 { createDoctorCommand } from './commands/doctor.js';
5
6
  import { createDeprecatedInitCommand, createSetupCommand, runConfigureViaSetup, } from './commands/init.js';
6
7
  import { createProjectCommand } from './commands/project.js';
7
8
  import { createTestCommand } from './commands/test.js';
8
9
  import { createUsageCommand } from './commands/usage.js';
9
10
  import { ApiError, CLIError, RequestTimeoutError } from './lib/errors.js';
11
+ import { installBrokenPipeGuard, installSignalHandlers } from './lib/interrupt.js';
10
12
  import { Output, isOutputMode } from './lib/output.js';
11
- import { rephraseUnknownOption } from './lib/render-error.js';
13
+ import { maybeInstallProxyAgent } from './lib/proxy.js';
14
+ import { renderCommanderError, rephraseUnknownOption } from './lib/render-error.js';
12
15
  import { maybeEmitSkillNudge } from './lib/skill-nudge.js';
16
+ import { maybeNotifyUpdate } from './lib/update-check.js';
13
17
  import { VERSION } from './version.js';
18
+ import { shouldRejectNodeVersion } from './version-guard.js';
19
+ // Guard: exit early with a clear message on unsupported Node.js versions,
20
+ // rather than failing later with a cryptic ESM/runtime error.
21
+ if (shouldRejectNodeVersion(process.versions.node)) {
22
+ process.stderr.write(`Error: testsprite requires Node.js >= 20 (found ${process.versions.node}).\nInstall the latest LTS from https://nodejs.org\n`);
23
+ process.exit(1);
24
+ }
14
25
  const program = new Command();
15
26
  // exitOverride() causes Commander to throw CommanderError instead of calling
16
27
  // process.exit() directly, giving our catch block a chance to remap error
@@ -25,7 +36,7 @@ program
25
36
  .option('--endpoint-url <url>', 'Override the API endpoint host')
26
37
  .option('--verbose', 'Emit human-readable HTTP retry / backoff / polling-mode transitions to stderr. Less noisy than --debug; useful for diagnosing hangs without the full trace.')
27
38
  .option('--debug', 'Print HTTP method/path, request id, latency, retry decisions to stderr')
28
- .option('--dry-run', 'Skip the network, credentials, and filesystem; emit a canned sample matching the OpenAPI contract. Useful for learning the CLI surface without an API key.')
39
+ .option('--dry-run', 'Skip the network and credentials; emit a canned sample matching the OpenAPI contract. Useful for learning the CLI surface without an API key. Note: file inputs you pass (--plan-from/--plans/--steps) are still read and validated locally; only --code-file uses a placeholder.')
29
40
  .option('--request-timeout <seconds>', 'Client-side per-request timeout in seconds (default: 120). Aborts any single fetch that does not complete within this deadline. ' +
30
41
  'Override via TESTSPRITE_REQUEST_TIMEOUT_MS env var (milliseconds). ' +
31
42
  'Range: 1–600. Does not affect the --timeout polling ceiling for `test run/wait`.');
@@ -51,25 +62,31 @@ program.addCommand(createProjectCommand({}));
51
62
  program.addCommand(createTestCommand());
52
63
  program.addCommand(createAgentCommand({}));
53
64
  program.addCommand(createUsageCommand());
54
- // Propagate exitOverride to every subcommand in the tree.
55
- // Commander's addCommand() does NOT inherit exitOverride from the parent,
56
- // so commands built externally (createTestCommand, createProjectCommand, …)
57
- // and attached via addCommand() still have _exitCallback = null and call
58
- // process.exit directly. Recursively set exitOverride so CommanderError
59
- // bubbles up to our catch block for every leaf subcommand.
65
+ program.addCommand(createDoctorCommand());
66
+ // Buffer Commander error messages instead of writing immediately. The catch
67
+ // block re-emits in the correct format (JSON or text) once the requested
68
+ // output mode is known. Safe because applyExitOverrideDeep ensures every
69
+ // command throws CommanderError rather than calling process.exit directly.
70
+ let pendingCommanderErrorMsg = null;
71
+ // Propagate exitOverride AND the buffered outputError config to every
72
+ // subcommand in the tree. Commander's addCommand() does NOT inherit either
73
+ // from the parent, so commands built externally (createTestCommand, etc.) and
74
+ // attached via addCommand() still have _exitCallback = null and a default
75
+ // outputError that writes immediately. Both must be applied after the full
76
+ // command tree is assembled so every leaf subcommand behaves consistently.
60
77
  function applyExitOverrideDeep(cmd) {
61
78
  cmd.exitOverride();
79
+ cmd.configureOutput({
80
+ outputError(str, _write) {
81
+ const rephrased = rephraseUnknownOption(str);
82
+ pendingCommanderErrorMsg = rephrased !== null ? `${rephrased}\n` : str;
83
+ },
84
+ });
62
85
  for (const child of cmd.commands) {
63
86
  applyExitOverrideDeep(child);
64
87
  }
65
88
  }
66
89
  applyExitOverrideDeep(program);
67
- program.configureOutput({
68
- outputError(str, write) {
69
- const rephrased = rephraseUnknownOption(str);
70
- write(rephrased !== null ? `${rephrased}\n` : str);
71
- },
72
- });
73
90
  /**
74
91
  * Render a leaf command's full path (group + leaf), e.g. `test run` /
75
92
  * `auth whoami`, by walking parents up to (but not including) the root program.
@@ -90,15 +107,34 @@ function commandPathOf(cmd) {
90
107
  // allowlist, opt-out via TESTSPRITE_NO_SKILL_WARNING) and never throws.
91
108
  program.hook('preAction', (_thisCommand, actionCommand) => {
92
109
  const globals = actionCommand.optsWithGlobals();
110
+ const commandPath = commandPathOf(actionCommand);
93
111
  maybeEmitSkillNudge({
94
- commandPath: commandPathOf(actionCommand),
112
+ commandPath,
95
113
  output: isOutputMode(globals.output) ? globals.output : 'text',
96
114
  dryRun: globals.dryRun ?? false,
97
115
  profile: globals.profile ?? 'default',
98
116
  cwd: process.cwd(),
99
117
  env: process.env,
100
118
  });
119
+ // Best-effort update notice (see lib/update-check.ts): self-gates on the
120
+ // opt-out env, CI, TTY, and a 24h cache; the wiring adds the flag-level
121
+ // gates the lib cannot see. Skipped for `completion` (its stdout is eval'd
122
+ // by shells), under --output json, and under --dry-run. Deliberately not
123
+ // awaited: an advisory must never delay the real command.
124
+ if (globals.output !== 'json' && globals.dryRun !== true && commandPath !== 'completion') {
125
+ void maybeNotifyUpdate();
126
+ }
101
127
  });
128
+ // Clean process lifecycle: a clear message + conventional exit code on SIGINT /
129
+ // SIGTERM / SIGHUP (instead of Node's silent abrupt kill) so an interrupted
130
+ // `test run --wait` explains the run continues server-side; plus an EPIPE guard
131
+ // so piping to a reader that closes early (`| head`) exits cleanly instead of
132
+ // dumping a raw `write EPIPE` stack.
133
+ installSignalHandlers();
134
+ installBrokenPipeGuard();
135
+ // Corporate/CI proxies: honor HTTPS_PROXY/HTTP_PROXY/NO_PROXY (Node's fetch
136
+ // ignores them by default). No-op when no proxy variable is set.
137
+ maybeInstallProxyAgent();
102
138
  try {
103
139
  await program.parseAsync(process.argv);
104
140
  }
@@ -161,9 +197,8 @@ catch (err) {
161
197
  process.exit(err.exitCode);
162
198
  }
163
199
  if (err instanceof CommanderError) {
164
- // Commander already wrote the error message (via configureOutput) or the
165
- // help/version text to stdout. Map exit codes per the CLI taxonomy:
166
- // help / version → 0 (user asked for it — no error)
200
+ // Map exit codes per the CLI taxonomy:
201
+ // help / version → 0 (user asked for it; Commander already wrote the text)
167
202
  // parse errors → 5 (VALIDATION_ERROR family: missing arg, invalid
168
203
  // option, unknown command, etc.)
169
204
  //
@@ -180,6 +215,24 @@ catch (err) {
180
215
  err.code === 'commander.version') {
181
216
  process.exit(0);
182
217
  }
218
+ // For parse errors, write the buffered message in the correct format.
219
+ // rawMode from program.opts() is reliable when --output was parsed before
220
+ // the error. When the error occurs first (e.g. `testsprite badcmd --output
221
+ // json`), rawMode is the default 'text'; scan argv as a best-effort
222
+ // fallback so machine consumers still receive a JSON envelope.
223
+ const commanderMode = (() => {
224
+ if (rawMode === 'json')
225
+ return 'json';
226
+ for (let i = 2; i < process.argv.length; i++) {
227
+ const arg = process.argv[i];
228
+ if (arg === '--output' && process.argv[i + 1] === 'json')
229
+ return 'json';
230
+ if (arg === '--output=json')
231
+ return 'json';
232
+ }
233
+ return mode;
234
+ })();
235
+ process.stderr.write(renderCommanderError(pendingCommanderErrorMsg, err.message, commanderMode));
183
236
  process.exit(5);
184
237
  }
185
238
  if (err instanceof CLIError) {
@@ -1,51 +1,198 @@
1
- export type AgentTarget = 'claude' | 'cursor' | 'cline' | 'antigravity' | 'codex';
1
+ export type AgentTarget = 'claude' | 'cursor' | 'cline' | 'antigravity' | 'codex' | 'kiro' | 'windsurf' | 'copilot';
2
2
  export interface TargetSpec {
3
3
  status: 'ga' | 'experimental';
4
- /** repo-relative landing path, POSIX separators */
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 (existing 4 targets).
12
+ * 'own-file': the CLI owns the whole file (claude/cursor/cline/antigravity/windsurf).
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
- /** wrap the canonical body in this target's frontmatter/header */
13
- wrap(body: string): string;
17
+ /**
18
+ * When true, render the budget-friendly body (see {@link compactBodyFor})
19
+ * instead of the full own-file skill body. Used for own-file targets whose
20
+ * rule files are size-capped — currently `windsurf` (`.windsurf/rules/*.md`
21
+ * files cap at ~12 K characters and Cascade silently truncates beyond that,
22
+ * which would cut the full ~22 KB verify skill in half).
23
+ */
24
+ compactBody?: boolean;
25
+ /**
26
+ * Wrap a skill body in this target's frontmatter/header. Takes the skill's
27
+ * `name`+`description` (own-file targets emit them as frontmatter) and the body.
28
+ * No-op for cline (body verbatim) and codex (managed-section authors plain
29
+ * Markdown with no frontmatter).
30
+ */
31
+ wrap(name: string, description: string, body: string): string;
14
32
  }
33
+ /**
34
+ * How a skill contributes to the codex target's always-on `AGENTS.md` section.
35
+ *
36
+ * - 'full': inject the skill's trimmed codex body (a `*.codex.md` asset). Used by
37
+ * `testsprite-verify` (~6 KiB).
38
+ * - 'line': inject a single short line authored inline here. Used by
39
+ * `testsprite-onboard` — the full 6-step flow doesn't belong in an always-on,
40
+ * 32 KiB-budgeted file, but a one-line signal does.
41
+ * - 'none': skill is not represented in AGENTS.md at all (reserved).
42
+ */
43
+ export type CodexContribution = {
44
+ kind: 'full';
45
+ file: string;
46
+ } | {
47
+ kind: 'line';
48
+ text: string;
49
+ } | {
50
+ kind: 'none';
51
+ };
52
+ export interface SkillSpec {
53
+ /** Skill name — appears in own-file frontmatter and the landing path. */
54
+ name: string;
55
+ /** ≤1536 chars (claude description cap). Byte-identical to its template doc. */
56
+ description: string;
57
+ /** Own-file body asset basename under `skills/`, e.g. 'testsprite-verify.skill.md'. */
58
+ bodyFile: string;
59
+ /** How this skill contributes to the codex AGENTS.md managed section. */
60
+ codex: CodexContribution;
61
+ }
62
+ /**
63
+ * `testsprite-onboard` codex contribution — a single always-on line. Kept here
64
+ * (not in a `*.codex.md` asset) because it is one line; see {@link CodexContribution}.
65
+ */
66
+ 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.";
67
+ /**
68
+ * The skill registry. Each entry owns its name, description (drift-guarded by a
69
+ * byte-identity unit test against a template doc), own-file body asset, and codex
70
+ * contribution. `agent install` / `setup` install {@link DEFAULT_SKILLS}; the
71
+ * codex target aggregates every installed skill's codex contribution into ONE
72
+ * AGENTS.md section.
73
+ */
74
+ export declare const SKILLS: Record<string, SkillSpec>;
75
+ /**
76
+ * Skills installed by `setup` and by `agent install` when no `--skill` subset is
77
+ * given. Order is significant for the codex aggregate (verify first, then the
78
+ * onboard line as a short addendum).
79
+ */
80
+ export declare const DEFAULT_SKILLS: readonly ["testsprite-verify", "testsprite-onboard"];
81
+ /** @deprecated The canonical skill name. New code: iterate {@link SKILLS}. */
15
82
  export declare const SKILL_NAME = "testsprite-verify";
16
83
  /**
17
- * Mirrors skill-template.md frontmatter `description`. ≤1536 chars (claude cap).
18
- * A unit test asserts byte-identity with the template file.
84
+ * @deprecated The canonical skill's description. New code:
85
+ * `SKILLS['testsprite-verify'].description`. Kept so existing importers and the
86
+ * byte-identity unit test keep working.
87
+ */
88
+ export declare const SKILL_DESCRIPTION: string;
89
+ /**
90
+ * Repo-relative landing path for a given skill on a given target (POSIX
91
+ * separators). Own-file targets embed the skill name in the path so multiple
92
+ * skills coexist; the codex target always lands at the single shared `AGENTS.md`
93
+ * (every skill's codex contribution is merged into one managed section there).
19
94
  */
20
- export declare const SKILL_DESCRIPTION = "TestSprite verification loop \u2014 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 \u2014 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.";
95
+ export declare function pathFor(target: AgentTarget, skill: string): string;
21
96
  export declare const TARGETS: Record<AgentTarget, TargetSpec>;
22
97
  /** Sentinel pair that bounds our managed section in AGENTS.md. */
23
98
  export declare const MANAGED_SECTION_BEGIN = "<!-- BEGIN TESTSPRITE AGENT SECTION (testsprite agent install codex) -->";
24
99
  export declare const MANAGED_SECTION_END = "<!-- END TESTSPRITE AGENT SECTION -->";
100
+ /**
101
+ * When one marker covers several skills (the codex managed section aggregates
102
+ * every installed skill), their names are joined with this separator in the
103
+ * marker's skill field. Skill names never contain '+' (see {@link SKILLS} keys).
104
+ */
105
+ export declare const MARKER_SKILL_SEPARATOR = "+";
106
+ /**
107
+ * First {@link MARKER_HASH_HEX_LENGTH} hex chars of the SHA-256 of a canonical
108
+ * skill body. The hash covers the CANONICAL BODY ONLY (pre-wrap, pre-marker),
109
+ * so writing the marker into the rendered artifact never changes the hash the
110
+ * marker itself carries.
111
+ */
112
+ export declare function bodyHash12(canonicalBody: string): string;
113
+ /**
114
+ * Build the provenance marker line for a skill (or a
115
+ * {@link MARKER_SKILL_SEPARATOR}-joined skill set) and its canonical body.
116
+ * `agent status` compares this fingerprint against the bodies the running CLI
117
+ * ships to detect silently stale installs.
118
+ */
119
+ export declare function buildSkillMarker(skillName: string, canonicalBody: string): string;
120
+ /** A marker line parsed back into its fields. */
121
+ export interface ParsedSkillMarker {
122
+ /** Skill name, or several names joined with {@link MARKER_SKILL_SEPARATOR}. */
123
+ skill: string;
124
+ /** CLI version that wrote the artifact. */
125
+ version: string;
126
+ /** First 12 hex chars of the canonical body's SHA-256 at install time. */
127
+ hash12: string;
128
+ /** The exact marker line (trailing CR/whitespace stripped) as found. */
129
+ line: string;
130
+ }
131
+ /**
132
+ * Find the first testsprite-skill marker line in `content`, or null when the
133
+ * content carries none (a pre-marker install). Lines are matched whole with
134
+ * trailing CR/whitespace stripped, so CRLF checkouts parse identically.
135
+ */
136
+ export declare function parseSkillMarker(content: string): ParsedSkillMarker | null;
25
137
  type ReadFn = (url: URL) => string;
138
+ /** Load a skill's own-file body by skill name (frontmatter is added by `wrap`). */
139
+ export declare function loadSkillBodyFor(skill: string, read?: ReadFn): string;
26
140
  /**
27
- * Load the canonical skill body. `../../skills/...` resolves to the repo-root
28
- * `skills/` directory in BOTH source (vitest: `src/lib/` → `../../skills`) and
29
- * the built/published package (`dist/lib/` → `../../skills` = package root). The
30
- * directory ships verbatim via package.json `files`, so no build-time copy step
31
- * is needed (unlike the old `src/assets` → `dist/assets` mirror).
32
- *
33
- * Injectable `read` fn keeps unit tests off disk.
141
+ * Budget-friendly body for an own-file target whose rule files are size-capped
142
+ * (e.g. windsurf). For a skill that ships a trimmed codex asset (`codex.kind ===
143
+ * 'full'`, e.g. `testsprite-verify` — full body ~22 KB, codex ~5 KB) we render
144
+ * that compact asset so the wrapped file stays under the cap. For skills whose
145
+ * codex contribution is only a one-liner (`'line'`/`'none'`, e.g.
146
+ * `testsprite-onboard`), the one-liner is useless as a standalone rule and the
147
+ * full own-file body (~6.5 KB) already fits the budget — so the full body is
148
+ * used.
149
+ */
150
+ export declare function compactBodyFor(skill: string, read?: ReadFn): string;
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 declare function codexContentFor(skill: string, read?: ReadFn): string;
156
+ /**
157
+ * Compose the codex managed-section BODY (sans sentinels) from several skills:
158
+ * each skill's codex contribution, trimmed, joined by a blank line, in the given
159
+ * order. A single `['testsprite-verify']` aggregate is byte-identical to the old
160
+ * single-skill codex body, so existing AGENTS.md installs round-trip unchanged.
161
+ */
162
+ export declare function buildCodexAggregate(skills: readonly string[], read?: ReadFn): string;
163
+ /**
164
+ * Back-compat: the canonical verify skill body (own-file). Kept so existing
165
+ * importers and the `loadSkillBody(read)` unit-test signature keep working.
166
+ * @deprecated Use {@link loadSkillBodyFor}.
34
167
  */
35
168
  export declare function loadSkillBody(read?: ReadFn): string;
36
169
  /**
37
- * Load the trimmed codex skill body (plain Markdown, no frontmatter).
38
- * Designed for AGENTS.md managed-section injection.
170
+ * Back-compat: the canonical verify skill's trimmed codex body. Kept so existing
171
+ * importers and the `loadCodexSkillBody(read)` unit-test signature keep working.
172
+ * @deprecated Use {@link codexContentFor}.
39
173
  */
40
174
  export declare function loadCodexSkillBody(read?: ReadFn): string;
41
175
  /**
42
- * Convenience for piece-2: returns the exact bytes to write for a target.
176
+ * Exact own-file bytes for a skill on a target, carrying the GIVEN marker line.
177
+ * `agent status` uses this to re-render the current canonical body with a
178
+ * file's own (possibly older-versioned) marker: when only the marker's version
179
+ * string lags but the body is unchanged, the artifact still compares pristine.
180
+ */
181
+ export declare function renderOwnFileWithMarker(target: AgentTarget, skill: string, markerLine: string, body?: string): string;
182
+ /**
183
+ * The exact bytes to write for one skill on one target.
43
184
  *
44
- * For own-file targets, `body` defaults to the full skill body.
45
- * For the codex managed-section target, the trimmed codex body is used instead —
46
- * pass an explicit `body` to override in tests.
185
+ * - own-file targets: `body` defaults to the skill's own-file asset, wrapped in
186
+ * the target's frontmatter/header, and carrying a provenance marker line so
187
+ * `agent status` can tell fresh, stale, and hand-edited installs apart.
188
+ * - codex (managed-section): returns the skill's codex contribution unwrapped
189
+ * and marker-free (plain Markdown, no frontmatter). The real install does NOT
190
+ * call this for codex: it aggregates all skills via
191
+ * {@link buildCodexAggregate} and writes ONE marker just inside the BEGIN
192
+ * sentinel. It is kept single-skill here for tests and parity. Pass an
193
+ * explicit `body` to override.
47
194
  */
48
- export declare function renderForTarget(t: AgentTarget, body?: string): {
195
+ export declare function renderForTarget(t: AgentTarget, skill: string, body?: string): {
49
196
  path: string;
50
197
  content: string;
51
198
  };