@testsprite/testsprite-cli 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -147
- package/dist/commands/agent.d.ts +12 -4
- package/dist/commands/agent.js +48 -63
- package/dist/commands/auth.d.ts +6 -10
- package/dist/commands/auth.js +38 -54
- package/dist/commands/ci.d.ts +23 -100
- package/dist/commands/ci.js +293 -487
- package/dist/commands/conversation.d.ts +27 -0
- package/dist/commands/conversation.js +702 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +129 -34
- package/dist/commands/init.d.ts +4 -45
- package/dist/commands/init.js +108 -66
- package/dist/commands/project-env.d.ts +62 -2
- package/dist/commands/project-env.js +388 -37
- package/dist/commands/project-sign-in.d.ts +0 -48
- package/dist/commands/project-sign-in.js +1 -229
- package/dist/commands/project.d.ts +15 -186
- package/dist/commands/project.js +89 -924
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +215 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +28 -87
- package/dist/commands/test.d.ts +301 -1816
- package/dist/commands/test.js +1951 -13902
- package/dist/commands/testlist.d.ts +128 -5
- package/dist/commands/testlist.js +269 -339
- package/dist/commands/tunnel.d.ts +2 -2
- package/dist/commands/tunnel.js +23 -19
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +50 -131
- package/dist/index.js +182 -104
- package/dist/lib/agent-detect.js +9 -5
- package/dist/lib/agent-targets.d.ts +21 -2
- package/dist/lib/agent-targets.js +88 -11
- package/dist/lib/args.d.ts +13 -0
- package/dist/lib/args.js +49 -0
- package/dist/lib/basic-auth.d.ts +3 -0
- package/dist/lib/basic-auth.js +15 -0
- package/dist/lib/billing-refusal.js +4 -3
- package/dist/lib/ci-linkage.d.ts +4 -82
- package/dist/lib/ci-linkage.js +4 -157
- package/dist/lib/ci-run.js +1 -1
- package/dist/lib/client-factory.d.ts +10 -2
- package/dist/lib/client-factory.js +38 -26
- package/dist/lib/commit-signal.d.ts +65 -0
- package/dist/lib/commit-signal.js +305 -0
- package/dist/lib/concurrency-limiter.d.ts +6 -0
- package/dist/lib/concurrency-limiter.js +29 -0
- package/dist/lib/config.js +10 -5
- package/dist/lib/conflict-reason.d.ts +9 -3
- package/dist/lib/conflict-reason.js +6 -3
- package/dist/lib/conversation/answers.d.ts +9 -0
- package/dist/lib/conversation/answers.js +49 -0
- package/dist/lib/conversation/api.d.ts +71 -0
- package/dist/lib/conversation/api.js +150 -0
- package/dist/lib/conversation/change.d.ts +31 -0
- package/dist/lib/conversation/change.js +124 -0
- package/dist/lib/conversation/context.d.ts +19 -0
- package/dist/lib/conversation/context.js +70 -0
- package/dist/lib/conversation/environment.d.ts +15 -0
- package/dist/lib/conversation/environment.js +33 -0
- package/dist/lib/conversation/follow.d.ts +24 -0
- package/dist/lib/conversation/follow.js +42 -0
- package/dist/lib/conversation/render.d.ts +33 -0
- package/dist/lib/conversation/render.js +315 -0
- package/dist/lib/conversation/title.d.ts +2 -0
- package/dist/lib/conversation/title.js +18 -0
- package/dist/lib/conversation/types.d.ts +156 -0
- package/dist/lib/conversation/types.js +6 -0
- package/dist/lib/credentials.js +67 -11
- package/dist/lib/cron.d.ts +1 -1
- package/dist/lib/cron.js +2 -2
- package/dist/lib/dispatch-stop.d.ts +20 -0
- package/dist/lib/dispatch-stop.js +30 -0
- package/dist/lib/download.d.ts +71 -0
- package/dist/lib/download.js +274 -0
- package/dist/lib/dry-run/fetch.d.ts +10 -0
- package/dist/lib/dry-run/fetch.js +20 -0
- package/dist/lib/dry-run/samples.d.ts +6 -34
- package/dist/lib/dry-run/samples.js +375 -747
- package/dist/lib/environment-tunnel.d.ts +16 -27
- package/dist/lib/environment-tunnel.js +161 -154
- package/dist/lib/errors.d.ts +20 -4
- package/dist/lib/errors.js +36 -16
- package/dist/lib/facade.d.ts +7 -29
- package/dist/lib/facade.js +7 -36
- package/dist/lib/failing-fe-resolver.d.ts +13 -58
- package/dist/lib/failing-fe-resolver.js +47 -132
- package/dist/lib/first-suite-hint.d.ts +16 -22
- package/dist/lib/first-suite-hint.js +38 -47
- package/dist/lib/gh-output.d.ts +76 -21
- package/dist/lib/gh-output.js +171 -90
- package/dist/lib/git-utils.d.ts +56 -0
- package/dist/lib/git-utils.js +212 -0
- package/dist/lib/github-context.d.ts +2 -0
- package/dist/lib/github-context.js +40 -8
- package/dist/lib/history-retention.d.ts +6 -2
- package/dist/lib/history-retention.js +10 -7
- package/dist/lib/http.d.ts +58 -134
- package/dist/lib/http.js +352 -289
- package/dist/lib/interrupt.d.ts +14 -8
- package/dist/lib/interrupt.js +28 -10
- package/dist/lib/junit-report.d.ts +57 -4
- package/dist/lib/junit-report.js +202 -32
- package/dist/lib/local-target.d.ts +3 -3
- package/dist/lib/local-target.js +3 -3
- package/dist/lib/output.d.ts +1 -40
- package/dist/lib/output.js +11 -49
- package/dist/lib/pagination.d.ts +2 -5
- package/dist/lib/pagination.js +2 -5
- package/dist/lib/presigned-url.d.ts +22 -0
- package/dist/lib/presigned-url.js +90 -0
- package/dist/lib/prompt.js +36 -2
- package/dist/lib/proxy.js +2 -1
- package/dist/lib/redact.d.ts +2 -2
- package/dist/lib/redact.js +3 -4
- package/dist/lib/removed-commands.d.ts +18 -0
- package/dist/lib/removed-commands.js +154 -0
- package/dist/lib/render-error.d.ts +31 -6
- package/dist/lib/render-error.js +88 -25
- package/dist/lib/response-schemas.d.ts +38 -30
- package/dist/lib/response-schemas.js +207 -207
- package/dist/lib/result/api.d.ts +24 -0
- package/dist/lib/result/api.js +28 -0
- package/dist/lib/result/evidence.d.ts +71 -0
- package/dist/lib/result/evidence.js +420 -0
- package/dist/lib/result/render.d.ts +20 -0
- package/dist/lib/result/render.js +194 -0
- package/dist/lib/result/types.d.ts +122 -0
- package/dist/lib/result/types.js +19 -0
- package/dist/lib/run-output.d.ts +275 -0
- package/dist/lib/run-output.js +227 -0
- package/dist/lib/run-render.d.ts +101 -0
- package/dist/lib/run-render.js +183 -0
- package/dist/lib/run-wait.d.ts +192 -0
- package/dist/lib/run-wait.js +452 -0
- package/dist/lib/runs.types.d.ts +118 -367
- package/dist/lib/runs.types.js +0 -14
- package/dist/lib/secret-file.d.ts +1 -1
- package/dist/lib/secret-file.js +11 -2
- package/dist/lib/skill-nudge.d.ts +7 -27
- package/dist/lib/skill-nudge.js +9 -37
- package/dist/lib/target-path.d.ts +15 -0
- package/dist/lib/target-path.js +35 -0
- package/dist/lib/target-url-advisory.d.ts +19 -0
- package/dist/lib/target-url-advisory.js +31 -0
- package/dist/lib/target-url-preflight.d.ts +9 -0
- package/dist/lib/target-url-preflight.js +214 -106
- package/dist/lib/target-url.d.ts +1 -1
- package/dist/lib/target-url.js +6 -16
- package/dist/lib/telemetry.d.ts +31 -11
- package/dist/lib/telemetry.js +37 -8
- package/dist/lib/terminal-text.d.ts +41 -0
- package/dist/lib/terminal-text.js +127 -0
- package/dist/lib/testlist.types.d.ts +16 -8
- package/dist/lib/testlist.types.js +1 -1
- package/dist/lib/text-equality.d.ts +2 -0
- package/dist/lib/text-equality.js +5 -0
- package/dist/lib/text-file.d.ts +16 -0
- package/dist/lib/text-file.js +41 -0
- package/dist/lib/text-table.d.ts +46 -0
- package/dist/lib/text-table.js +72 -4
- package/dist/lib/ticker.d.ts +9 -2
- package/dist/lib/ticker.js +16 -3
- package/dist/lib/transport-failure.d.ts +22 -0
- package/dist/lib/transport-failure.js +126 -0
- package/dist/lib/tunnel-session.d.ts +7 -1
- package/dist/lib/tunnel-session.js +22 -9
- package/dist/lib/update-check.js +3 -2
- package/dist/lib/url-template.d.ts +43 -0
- package/dist/lib/url-template.js +151 -0
- package/dist/lib/validate.d.ts +0 -64
- package/dist/lib/validate.js +2 -131
- package/dist/lib/version-notice.js +4 -3
- package/dist/lib/wait-exit.d.ts +37 -2
- package/dist/lib/wait-exit.js +88 -30
- package/dist/lib/workspace-status.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/skills/testsprite-ci.skill.md +48 -18
- package/skills/testsprite-onboard.skill.md +66 -151
- package/skills/testsprite-verify.codex.md +50 -52
- package/skills/testsprite-verify.skill.md +184 -351
- package/dist/lib/browser.d.ts +0 -6
- package/dist/lib/browser.js +0 -54
- package/dist/lib/bundle.d.ts +0 -234
- package/dist/lib/bundle.js +0 -781
- package/dist/lib/deprecate.d.ts +0 -32
- package/dist/lib/deprecate.js +0 -39
- package/dist/lib/flaky.d.ts +0 -91
- package/dist/lib/flaky.js +0 -71
- package/dist/lib/plan-poll.d.ts +0 -171
- package/dist/lib/plan-poll.js +0 -441
- package/dist/lib/plans.types.d.ts +0 -130
- package/dist/lib/plans.types.js +0 -31
- package/dist/lib/poll.d.ts +0 -100
- package/dist/lib/poll.js +0 -290
- package/dist/lib/rate-throttle.d.ts +0 -49
- package/dist/lib/rate-throttle.js +0 -75
- package/dist/lib/run-progress.d.ts +0 -41
- package/dist/lib/run-progress.js +0 -56
- package/dist/lib/v3-advisory.d.ts +0 -55
- package/dist/lib/v3-advisory.js +0 -74
- package/schemas/plan.schema.json +0 -61
package/dist/index.js
CHANGED
|
@@ -3,26 +3,30 @@ import { Command, CommanderError } from 'commander';
|
|
|
3
3
|
import { createAgentCommand } from './commands/agent.js';
|
|
4
4
|
import { createAuthCommand } from './commands/auth.js';
|
|
5
5
|
import { createCiCommand } from './commands/ci.js';
|
|
6
|
+
import { createConversationCommands } from './commands/conversation.js';
|
|
6
7
|
import { createCompletionCommand } from './commands/completion.js';
|
|
7
8
|
import { createDoctorCommand } from './commands/doctor.js';
|
|
8
|
-
import {
|
|
9
|
+
import { createSetupCommand } from './commands/init.js';
|
|
9
10
|
import { createProjectCommand } from './commands/project.js';
|
|
11
|
+
import { createResultCommand } from './commands/result.js';
|
|
10
12
|
import { createScheduleCommand } from './commands/schedule.js';
|
|
11
13
|
import { createTunnelCommand } from './commands/tunnel.js';
|
|
12
|
-
import { createTestCommand } from './commands/test.js';
|
|
14
|
+
import { createTestCommand, createRunCommand } from './commands/test.js';
|
|
13
15
|
import { createTestListCommand } from './commands/testlist.js';
|
|
14
16
|
import { createUsageCommand } from './commands/usage.js';
|
|
15
17
|
import { resolveProfileName } from './lib/config.js';
|
|
16
18
|
import { classifyBillingRefusal } from './lib/billing-refusal.js';
|
|
17
|
-
import {
|
|
19
|
+
import { validatePositionalArgs } from './lib/args.js';
|
|
18
20
|
import { ApiError, CLIError, InterruptError, RequestTimeoutError, extractNodeErrorCode, } from './lib/errors.js';
|
|
19
21
|
import { armInterruptExitBackstop, installBrokenPipeGuard, installSignalHandlers, } from './lib/interrupt.js';
|
|
20
22
|
import { Output, isOutputMode } from './lib/output.js';
|
|
21
23
|
import { maybeInstallProxyAgent } from './lib/proxy.js';
|
|
22
24
|
import { redactDeep } from './lib/redact.js';
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
25
|
+
import { removedCommandPointer, removedOptionPointer } from './lib/removed-commands.js';
|
|
26
|
+
import { jsonForTerminal, terminalSafe, terminalSafeLine } from './lib/terminal-text.js';
|
|
27
|
+
import { buildInterruptEnvelope, renderAmbiguousOrgCandidates, renderTunnelBindingLimitIds, redactUnknownOptionValue, renderCommanderError, rephraseUnknownOption, } from './lib/render-error.js';
|
|
28
|
+
import { maybeEmitSkillNudge } from './lib/skill-nudge.js';
|
|
29
|
+
import { classifyCliError, isTelemetryOptedOut, recordOutcome, recordTelemetryExtras, tryResolveTelemetryAuth, } from './lib/telemetry.js';
|
|
26
30
|
import { maybeNotifyUpdate } from './lib/update-check.js';
|
|
27
31
|
import { VERSION } from './version.js';
|
|
28
32
|
import { rejectUnsupportedNodeVersion } from './version-guard.js';
|
|
@@ -43,36 +47,25 @@ program
|
|
|
43
47
|
.option('--endpoint-url <url>', 'API base URL (a full http(s) URL)')
|
|
44
48
|
.option('--verbose', 'Log HTTP retry / backoff / polling transitions to stderr (lighter than --debug)')
|
|
45
49
|
.option('--debug', 'Print HTTP method/path, request id, latency, retry decisions to stderr')
|
|
46
|
-
.option('--dry-run', 'Skip the network and credentials; emit a canned sample matching the OpenAPI contract. Exception: run
|
|
50
|
+
.option('--dry-run', 'Skip the network and credentials; emit a canned sample matching the OpenAPI contract. Exception: run launches (`run --project`, `run <test-id...>`, `run --testlist`) with credentials and no explicit target may make read-only GETs to preview an automatic tunnel target; nothing is created or started.')
|
|
47
51
|
.option('--request-timeout <seconds>', 'Per-request timeout in seconds (default 120; range 1–600, values outside are clamped). ' +
|
|
48
|
-
'Does not affect the --timeout polling ceiling for `
|
|
52
|
+
'Does not affect the --timeout polling ceiling for `run` or `run wait`.');
|
|
49
53
|
// `setup` is the primary onboarding command, listed FIRST in --help so a coding
|
|
50
|
-
// agent reaches it before anything else.
|
|
51
|
-
// alias (invisible to --help; still works for existing scripts/agents).
|
|
54
|
+
// agent reaches it before anything else.
|
|
52
55
|
program.addCommand(createSetupCommand({}));
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Attach the SAME flag set `setup` has (previously only
|
|
58
|
-
// `--from-env` was wired up, so README's "runs the full setup" claim didn't
|
|
59
|
-
// hold — `--yes`/`--agent`/`--api-key`/`--force`/`--dir`/`--no-agent` were all
|
|
60
|
-
// rejected as `unknown option`).
|
|
61
|
-
const authCommand = createAuthCommand();
|
|
62
|
-
const authConfigureValidTargets = Object.keys(TARGETS);
|
|
63
|
-
addSetupOptions(authCommand.command('configure', { hidden: true }), authConfigureValidTargets, 'claude').action(async (cmdOpts, command) => {
|
|
64
|
-
process.stderr.write('[deprecated] `testsprite auth configure` now runs full setup (configure + skill install) — ' +
|
|
65
|
-
'use `testsprite setup` (add --no-agent to skip the skill).\n');
|
|
66
|
-
await runConfigureViaSetup(command, {}, cmdOpts);
|
|
67
|
-
});
|
|
68
|
-
program.addCommand(authCommand);
|
|
56
|
+
// The project's agent: the same conversations, cards and memory the portal has.
|
|
57
|
+
for (const command of createConversationCommands())
|
|
58
|
+
program.addCommand(command);
|
|
59
|
+
program.addCommand(createAuthCommand());
|
|
69
60
|
program.addCommand(createProjectCommand({}));
|
|
70
61
|
let waitTimeoutTelemetry = {};
|
|
71
|
-
program.addCommand(
|
|
62
|
+
program.addCommand(createRunCommand({
|
|
72
63
|
onWaitTimeout: context => {
|
|
73
64
|
waitTimeoutTelemetry = context;
|
|
74
65
|
},
|
|
75
66
|
}));
|
|
67
|
+
program.addCommand(createTestCommand());
|
|
68
|
+
program.addCommand(createResultCommand());
|
|
76
69
|
program.addCommand(createTestListCommand());
|
|
77
70
|
program.addCommand(createCiCommand({
|
|
78
71
|
onWaitTimeout: context => {
|
|
@@ -85,6 +78,35 @@ program.addCommand(createAgentCommand({}));
|
|
|
85
78
|
program.addCommand(createUsageCommand());
|
|
86
79
|
program.addCommand(createDoctorCommand());
|
|
87
80
|
program.addCommand(createCompletionCommand(() => buildCompletionSpec()));
|
|
81
|
+
// The root accepts global flags anywhere. Its ordinary parser also collects
|
|
82
|
+
// child operands before the first unknown option. Feed the whole run tail to
|
|
83
|
+
// the hybrid parser together, so it can stop at wait/cancel before consuming
|
|
84
|
+
// their flags. Other groups retain Commander's existing parsing behavior.
|
|
85
|
+
const parseRootOptions = program.parseOptions.bind(program);
|
|
86
|
+
program.parseOptions = args => {
|
|
87
|
+
const parsed = parseRootOptions(args);
|
|
88
|
+
if (parsed.operands[0] !== 'run')
|
|
89
|
+
return parsed;
|
|
90
|
+
const tail = [...parsed.operands.slice(1), ...parsed.unknown];
|
|
91
|
+
// Commander consumes a terminator encountered before any unknown option.
|
|
92
|
+
// Reinsert it before reprocessing operands, so literal IDs cannot turn into
|
|
93
|
+
// project/list launch flags. A required global option may itself take `--`
|
|
94
|
+
// as its value; that occurrence is not an option terminator.
|
|
95
|
+
for (let index = 0; index < args.length; index++) {
|
|
96
|
+
const arg = args[index];
|
|
97
|
+
if (arg === '--') {
|
|
98
|
+
if (parsed.unknown.length === 0) {
|
|
99
|
+
const literalCount = args.length - index - 1;
|
|
100
|
+
tail.splice(Math.max(0, parsed.operands.length - 1 - literalCount), 0, '--');
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
const option = program.options.find(option => option.long === arg || option.short === arg);
|
|
105
|
+
if (option?.required)
|
|
106
|
+
index++;
|
|
107
|
+
}
|
|
108
|
+
return { operands: ['run'], unknown: tail };
|
|
109
|
+
};
|
|
88
110
|
// Derive the shell-completion spec from the fully-assembled command tree at call
|
|
89
111
|
// time (not module-load), so `testsprite completion` can never drift from the
|
|
90
112
|
// real commands, subcommands, and global flags.
|
|
@@ -117,8 +139,8 @@ let pendingCommanderErrorMsg = null;
|
|
|
117
139
|
// skips those. Read by the success + error telemetry emits around parseAsync.
|
|
118
140
|
let ranCommandPath = '';
|
|
119
141
|
// Whether the command that ran should emit telemetry. `completion` (its stdout
|
|
120
|
-
// is eval'd by shells)
|
|
121
|
-
//
|
|
142
|
+
// is eval'd by shells) is kept off the beacon, same as the update notice. Set by
|
|
143
|
+
// the preAction hook.
|
|
122
144
|
let telemetryEmit = false;
|
|
123
145
|
// Auth resolved in the preAction hook, before the command's action runs, so
|
|
124
146
|
// `auth remove` (which deletes the profile) is still reported on the key it used.
|
|
@@ -136,8 +158,9 @@ function applyExitOverrideDeep(cmd) {
|
|
|
136
158
|
cmd.exitOverride();
|
|
137
159
|
cmd.configureOutput({
|
|
138
160
|
outputError(str, _write) {
|
|
139
|
-
const
|
|
140
|
-
|
|
161
|
+
const safe = redactUnknownOptionValue(str);
|
|
162
|
+
const rephrased = rephraseUnknownOption(safe);
|
|
163
|
+
pendingCommanderErrorMsg = rephrased !== null ? `${rephrased}\n` : safe;
|
|
141
164
|
},
|
|
142
165
|
});
|
|
143
166
|
for (const child of cmd.commands) {
|
|
@@ -145,33 +168,74 @@ function applyExitOverrideDeep(cmd) {
|
|
|
145
168
|
}
|
|
146
169
|
}
|
|
147
170
|
applyExitOverrideDeep(program);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
171
|
+
/** The subcommand of `group` that `name` names, by name or alias. */
|
|
172
|
+
function subcommandNamed(group, name) {
|
|
173
|
+
return group.commands.find(command => command.name() === name || command.aliases().includes(name));
|
|
151
174
|
}
|
|
152
175
|
/**
|
|
153
|
-
* Commander checks its implicit help option before reporting an unknown
|
|
154
|
-
* command
|
|
155
|
-
*
|
|
156
|
-
*
|
|
176
|
+
* Commander checks its implicit help option before reporting an unknown
|
|
177
|
+
* command, at every level: `<group> <unknown> --help` prints the group's
|
|
178
|
+
* help, and `help <group> <unknown>` or `<group> help <unknown>` fall back to
|
|
179
|
+
* it too.
|
|
180
|
+
* Walk the command names the program was given, from the root down, while
|
|
181
|
+
* help is being rendered: the first name that is not a subcommand of the
|
|
182
|
+
* group before it is the unknown command, and that error wins before any
|
|
183
|
+
* misleading help is written. Only groups are walked; a leaf's arguments
|
|
184
|
+
* are its own. `-h` / `--help` is skipped wherever it stands, so the order of
|
|
185
|
+
* the words does not matter; the walk stops at any other option, so a flag's
|
|
186
|
+
* value is never read as a command. Returns the unknown name and the group it
|
|
187
|
+
* was looked up in; the error handler walks the same way to name where a
|
|
188
|
+
* removed command went.
|
|
157
189
|
*/
|
|
158
|
-
function
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
190
|
+
function unknownCommandIn(args) {
|
|
191
|
+
let group = program;
|
|
192
|
+
// `help <name>…` at the root names the path to describe.
|
|
193
|
+
let explicitHelpPath = args[0] === 'help';
|
|
194
|
+
for (const name of explicitHelpPath ? args.slice(1) : args) {
|
|
195
|
+
if (group.commands.length === 0)
|
|
196
|
+
return undefined;
|
|
197
|
+
// The help flag asks for help wherever it stands; the names after it still
|
|
198
|
+
// have to exist (`test --help result`).
|
|
199
|
+
if (name === '-h' || name === '--help')
|
|
200
|
+
continue;
|
|
201
|
+
if (name.startsWith('-'))
|
|
202
|
+
return undefined;
|
|
203
|
+
// A group's own `help` subcommand: the name after it is its subcommand.
|
|
204
|
+
if (name === 'help') {
|
|
205
|
+
explicitHelpPath = true;
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const next = subcommandNamed(group, name);
|
|
209
|
+
if (next === undefined) {
|
|
210
|
+
if (group.name() === 'run' && group.parent === program && !explicitHelpPath)
|
|
211
|
+
return undefined;
|
|
212
|
+
return { group, name };
|
|
213
|
+
}
|
|
214
|
+
group = next;
|
|
162
215
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The command the leading names reach, which is the one that parses the
|
|
220
|
+
* options after them. The walk stops at the first option or the first word
|
|
221
|
+
* that is not a subcommand (an argument), like the walk above.
|
|
222
|
+
*/
|
|
223
|
+
function commandNamedBy(args) {
|
|
224
|
+
let command = program;
|
|
225
|
+
for (const name of args) {
|
|
226
|
+
const next = name.startsWith('-') ? undefined : subcommandNamed(command, name);
|
|
227
|
+
if (next === undefined)
|
|
228
|
+
break;
|
|
229
|
+
command = next;
|
|
230
|
+
}
|
|
231
|
+
return command;
|
|
166
232
|
}
|
|
167
233
|
program.addHelpText('after', '\nEnvironment:\n' +
|
|
168
234
|
' TESTSPRITE_API_KEY (overrides stored credentials), TESTSPRITE_NO_UPDATE_NOTIFIER (disables\n' +
|
|
169
235
|
' the version check); TESTSPRITE_API_URL, TESTSPRITE_PROFILE and TESTSPRITE_REQUEST_TIMEOUT_MS\n' +
|
|
170
236
|
' (milliseconds) mirror --endpoint-url, --profile and --request-timeout.');
|
|
171
|
-
program.addHelpText('beforeAll',
|
|
172
|
-
|
|
173
|
-
return '';
|
|
174
|
-
const unknownCommand = unknownRootCommandMaskedByHelp(program.args);
|
|
237
|
+
program.addHelpText('beforeAll', () => {
|
|
238
|
+
const unknownCommand = unknownCommandIn(program.args)?.name;
|
|
175
239
|
if (unknownCommand) {
|
|
176
240
|
program.error(`error: unknown command '${unknownCommand}'`, {
|
|
177
241
|
code: 'commander.unknownCommand',
|
|
@@ -180,8 +244,8 @@ program.addHelpText('beforeAll', context => {
|
|
|
180
244
|
return '';
|
|
181
245
|
});
|
|
182
246
|
/**
|
|
183
|
-
* Render a leaf command's full path (group + leaf), e.g. `
|
|
184
|
-
* `auth
|
|
247
|
+
* Render a leaf command's full path (group + leaf), e.g. `run` /
|
|
248
|
+
* `auth status`, by walking parents up to (but not including) the root program.
|
|
185
249
|
*/
|
|
186
250
|
function commandPathOf(cmd) {
|
|
187
251
|
const names = [];
|
|
@@ -203,10 +267,10 @@ function telemetryGlobals() {
|
|
|
203
267
|
// action; the helper self-gates (text-only, non-dry-run, a small command
|
|
204
268
|
// allowlist, opt-out via TESTSPRITE_NO_SKILL_WARNING) and never throws.
|
|
205
269
|
program.hook('preAction', (_thisCommand, actionCommand) => {
|
|
206
|
-
const globals = actionCommand.optsWithGlobals();
|
|
207
270
|
const commandPath = commandPathOf(actionCommand);
|
|
208
271
|
// Record which leaf command ran, for the telemetry emit around parseAsync.
|
|
209
272
|
ranCommandPath = commandPath;
|
|
273
|
+
const globals = actionCommand.optsWithGlobals();
|
|
210
274
|
// Preserve explicit --local attempts, including refusals and borrowed tunnels;
|
|
211
275
|
// only flag presence is recorded. Automatic tunnel paths record the same fact.
|
|
212
276
|
if (globals.local !== undefined)
|
|
@@ -214,43 +278,45 @@ program.hook('preAction', (_thisCommand, actionCommand) => {
|
|
|
214
278
|
telemetryLocalProject =
|
|
215
279
|
commandPath === 'project create' &&
|
|
216
280
|
(globals.local !== undefined || globals.localHost !== undefined);
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
//
|
|
221
|
-
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
|
|
281
|
+
// Telemetry gate, same reason as the update notice below: skip `completion`
|
|
282
|
+
// (its stdout is eval'd by shells). Resolve auth now, before the command's
|
|
283
|
+
// action runs, so `auth remove` still reports on the key it used; skip the
|
|
284
|
+
// read for opt-out / dry-run.
|
|
285
|
+
telemetryEmit = commandPath !== 'completion';
|
|
286
|
+
// Refuse an empty or whitespace-only positional before the action runs.
|
|
287
|
+
// This sits below the telemetry gate so the refusal is still reported as a
|
|
288
|
+
// VALIDATION_ERROR outcome, as it was when each command checked for itself,
|
|
289
|
+
// and above the auth read so a bad profile cannot replace this error.
|
|
290
|
+
validatePositionalArgs(actionCommand);
|
|
291
|
+
// The auth read is best-effort: an unreadable credentials file must not end
|
|
292
|
+
// the process here, before the command could run — `doctor` exists to
|
|
293
|
+
// diagnose exactly that, and offline commands never need the key. On failure
|
|
294
|
+
// the command runs as if telemetry were off (no event, and no fallback read
|
|
295
|
+
// at exit either).
|
|
225
296
|
if (telemetryEmit && !isTelemetryOptedOut(process.env) && globals.dryRun !== true) {
|
|
226
|
-
telemetryAuth =
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
if (!isPlanTemplate) {
|
|
232
|
-
maybeEmitSkillNudge({
|
|
233
|
-
commandPath,
|
|
234
|
-
output: isOutputMode(globals.output) ? globals.output : 'text',
|
|
235
|
-
dryRun: globals.dryRun ?? false,
|
|
236
|
-
profile: resolveProfileName(globals.profile),
|
|
237
|
-
cwd: process.cwd(),
|
|
238
|
-
env: process.env,
|
|
239
|
-
debug: globals.debug ?? false,
|
|
297
|
+
telemetryAuth = tryResolveTelemetryAuth({ profile: globals.profile, endpointUrl: globals.endpointUrl }, {
|
|
298
|
+
onError: globals.debug
|
|
299
|
+
? error => process.stderr.write(`[debug] telemetry skipped: ${error instanceof Error ? error.message : String(error)}\n`)
|
|
300
|
+
: undefined,
|
|
240
301
|
});
|
|
302
|
+
if (telemetryAuth === undefined)
|
|
303
|
+
telemetryEmit = false;
|
|
241
304
|
}
|
|
305
|
+
maybeEmitSkillNudge({
|
|
306
|
+
commandPath,
|
|
307
|
+
output: isOutputMode(globals.output) ? globals.output : 'text',
|
|
308
|
+
dryRun: globals.dryRun ?? false,
|
|
309
|
+
profile: resolveProfileName(globals.profile),
|
|
310
|
+
cwd: process.cwd(),
|
|
311
|
+
env: process.env,
|
|
312
|
+
debug: globals.debug ?? false,
|
|
313
|
+
});
|
|
242
314
|
// Best-effort update notice (see lib/update-check.ts): self-gates on the
|
|
243
315
|
// opt-out env, CI, TTY, and a 24h cache; the wiring adds the flag-level
|
|
244
316
|
// gates the lib cannot see. Skipped for `completion` (its stdout is eval'd
|
|
245
|
-
// by shells), under --output json
|
|
246
|
-
//
|
|
247
|
-
|
|
248
|
-
// contradict "no network" for this flag). Deliberately not awaited: an
|
|
249
|
-
// advisory must never delay the real command.
|
|
250
|
-
if (globals.output !== 'json' &&
|
|
251
|
-
globals.dryRun !== true &&
|
|
252
|
-
commandPath !== 'completion' &&
|
|
253
|
-
!isPlanTemplate) {
|
|
317
|
+
// by shells), under --output json and under --dry-run. Deliberately not
|
|
318
|
+
// awaited: an advisory must never delay the real command.
|
|
319
|
+
if (globals.output !== 'json' && globals.dryRun !== true && commandPath !== 'completion') {
|
|
254
320
|
void maybeNotifyUpdate();
|
|
255
321
|
}
|
|
256
322
|
});
|
|
@@ -323,45 +389,46 @@ catch (err) {
|
|
|
323
389
|
const output = new Output(mode);
|
|
324
390
|
if (err instanceof ApiError) {
|
|
325
391
|
const billingRefusal = classifyBillingRefusal(err);
|
|
326
|
-
const message
|
|
327
|
-
err.getDetail('reason') === 'tunnel-unsupported-for-backend-test'
|
|
328
|
-
? '--local only supports frontend tests today. Re-run without --local, or point the test at a reachable base URL.'
|
|
329
|
-
: err.message;
|
|
392
|
+
const { message, nextAction, details } = err;
|
|
330
393
|
if (mode === 'json') {
|
|
331
394
|
const envelope = {
|
|
332
395
|
error: {
|
|
333
396
|
code: err.code,
|
|
334
397
|
message,
|
|
335
|
-
nextAction
|
|
398
|
+
nextAction,
|
|
336
399
|
requestId: err.requestId,
|
|
337
400
|
// `err.details` is already redacted at ApiError construction (see
|
|
338
401
|
// `errors.ts`); redacting again here is defence in depth for this
|
|
339
402
|
// hand-built envelope specifically, independent of that.
|
|
340
|
-
details: redactDeep(
|
|
403
|
+
details: redactDeep(details),
|
|
341
404
|
...(billingRefusal ? { links: billingRefusal.links } : {}),
|
|
342
405
|
},
|
|
343
406
|
};
|
|
344
|
-
process.stderr.write(`${
|
|
407
|
+
process.stderr.write(`${jsonForTerminal(envelope, 2)}\n`);
|
|
345
408
|
}
|
|
346
409
|
else {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
410
|
+
// Server text on a terminal: escape sequences and other control
|
|
411
|
+
// characters are removed, and the message and request id stay on their
|
|
412
|
+
// own line, so the server cannot write a line of its own beneath them.
|
|
413
|
+
// The JSON envelope above keeps what the server sent.
|
|
414
|
+
process.stderr.write(`Error: ${terminalSafeLine(message)}\n`);
|
|
415
|
+
if (nextAction)
|
|
416
|
+
process.stderr.write(`${terminalSafe(nextAction)}\n`);
|
|
350
417
|
if (billingRefusal) {
|
|
351
418
|
for (const line of billingRefusal.lines)
|
|
352
419
|
process.stderr.write(`${line}\n`);
|
|
353
420
|
}
|
|
354
421
|
if (err.requestId && err.requestId !== 'local')
|
|
355
|
-
process.stderr.write(`requestId: ${err.requestId}\n`);
|
|
422
|
+
process.stderr.write(`requestId: ${terminalSafeLine(err.requestId)}\n`);
|
|
356
423
|
// C1: surface requiredScopes / grantedScopes on AUTH_FORBIDDEN
|
|
357
424
|
if (err.code === 'AUTH_FORBIDDEN') {
|
|
358
425
|
const required = err.getDetail('requiredScopes');
|
|
359
426
|
const granted = err.getDetail('grantedScopes');
|
|
360
427
|
if (Array.isArray(required) && required.length > 0) {
|
|
361
|
-
process.stderr.write(` required: ${required.join(', ')}\n`);
|
|
428
|
+
process.stderr.write(` required: ${terminalSafeLine(required.join(', '))}\n`);
|
|
362
429
|
}
|
|
363
430
|
if (Array.isArray(granted)) {
|
|
364
|
-
process.stderr.write(` granted: ${granted.join(', ')}\n`);
|
|
431
|
+
process.stderr.write(` granted: ${terminalSafeLine(granted.join(', '))}\n`);
|
|
365
432
|
}
|
|
366
433
|
}
|
|
367
434
|
// Surface the version gap on CLIENT_TOO_OLD so the user sees exactly what
|
|
@@ -371,7 +438,7 @@ catch (err) {
|
|
|
371
438
|
const your = err.getDetail('yourVersion');
|
|
372
439
|
const min = err.getDetail('minVersion');
|
|
373
440
|
if (typeof your === 'string' && typeof min === 'string') {
|
|
374
|
-
process.stderr.write(` your version: ${your}, minimum supported: ${min}\n`);
|
|
441
|
+
process.stderr.write(` your version: ${terminalSafeLine(your)}, minimum supported: ${terminalSafeLine(min)}\n`);
|
|
375
442
|
}
|
|
376
443
|
}
|
|
377
444
|
// AMBIGUOUS_ORG: the same testId resolved inside more than one of the
|
|
@@ -395,10 +462,10 @@ catch (err) {
|
|
|
395
462
|
// A disarmed request has no run ID, so its JSON hint describes checking
|
|
396
463
|
// current state before retrying. Both use the conventional 128+signum code.
|
|
397
464
|
if (mode === 'json') {
|
|
398
|
-
process.stderr.write(`${
|
|
465
|
+
process.stderr.write(`${jsonForTerminal(buildInterruptEnvelope(err), 2)}\n`);
|
|
399
466
|
}
|
|
400
467
|
else {
|
|
401
|
-
process.stderr.write(`Error: ${err.message}\n`);
|
|
468
|
+
process.stderr.write(`Error: ${terminalSafeLine(err.message)}\n`);
|
|
402
469
|
}
|
|
403
470
|
await flushThenSetExitCode(err.exitCode);
|
|
404
471
|
armInterruptExitBackstop(err.exitCode);
|
|
@@ -411,16 +478,17 @@ catch (err) {
|
|
|
411
478
|
error: {
|
|
412
479
|
code: 'REQUEST_TIMEOUT',
|
|
413
480
|
message: err.message,
|
|
414
|
-
nextAction:
|
|
415
|
-
'
|
|
481
|
+
nextAction: err.nextAction ??
|
|
482
|
+
'Increase --request-timeout <seconds> or set TESTSPRITE_REQUEST_TIMEOUT_MS. ' +
|
|
483
|
+
'Check that the backend is reachable and not overloaded.',
|
|
416
484
|
requestId: err.requestId,
|
|
417
485
|
details: { timeoutMs: err.timeoutMs },
|
|
418
486
|
},
|
|
419
487
|
};
|
|
420
|
-
process.stderr.write(`${
|
|
488
|
+
process.stderr.write(`${jsonForTerminal(envelope, 2)}\n`);
|
|
421
489
|
}
|
|
422
490
|
else {
|
|
423
|
-
process.stderr.write(`Error: ${err.message}\n`);
|
|
491
|
+
process.stderr.write(`Error: ${terminalSafeLine(err.message)}\n`);
|
|
424
492
|
}
|
|
425
493
|
await flushThenSetExitCode(err.exitCode);
|
|
426
494
|
}
|
|
@@ -461,7 +529,17 @@ catch (err) {
|
|
|
461
529
|
}
|
|
462
530
|
return mode;
|
|
463
531
|
})();
|
|
464
|
-
|
|
532
|
+
// A removed command also says where it went, by the
|
|
533
|
+
// same walk that found the unknown name (Commander's own error and the
|
|
534
|
+
// one raised before a group's help both arrive here). A removed option
|
|
535
|
+
// does too, from the command the arguments name and the message it wrote.
|
|
536
|
+
const unknown = err.code === 'commander.unknownCommand' ? unknownCommandIn(program.args) : undefined;
|
|
537
|
+
const removedPointer = unknown !== undefined
|
|
538
|
+
? removedCommandPointer(commandPathOf(unknown.group), unknown.name)
|
|
539
|
+
: err.code === 'commander.unknownOption'
|
|
540
|
+
? removedOptionPointer(commandPathOf(commandNamedBy(program.args)), err.message)
|
|
541
|
+
: undefined;
|
|
542
|
+
process.stderr.write(renderCommanderError(pendingCommanderErrorMsg, err.message, commanderMode, removedPointer));
|
|
465
543
|
await flushThenSetExitCode(5);
|
|
466
544
|
}
|
|
467
545
|
}
|
package/dist/lib/agent-detect.js
CHANGED
|
@@ -51,15 +51,19 @@ function truthy(value) {
|
|
|
51
51
|
/**
|
|
52
52
|
* Every relative path this CLI writes for a target, across all default skills.
|
|
53
53
|
*
|
|
54
|
-
* Includes the
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
54
|
+
* Includes the backup siblings `agent install --force` leaves behind —
|
|
55
|
+
* `writeBackup` walks `.bak`, `.bak.1`, … `.bak.99` before giving up. Without
|
|
56
|
+
* them a repeated forced reinstall makes that target permanently "detected"
|
|
57
|
+
* from its own backups — the self-reinforcement `hasForeignContent` exists to
|
|
58
|
+
* prevent, just one file over.
|
|
58
59
|
*/
|
|
59
60
|
function ownPaths(target) {
|
|
60
61
|
return DEFAULT_SKILLS.flatMap(skill => {
|
|
61
62
|
const p = pathFor(target, skill).replace(/\\/g, '/');
|
|
62
|
-
|
|
63
|
+
const backups = [`${p}.bak`];
|
|
64
|
+
for (let n = 1; n <= 99; n++)
|
|
65
|
+
backups.push(`${p}.bak.${n}`);
|
|
66
|
+
return [p, ...backups];
|
|
63
67
|
});
|
|
64
68
|
}
|
|
65
69
|
/**
|
|
@@ -30,7 +30,7 @@ export interface TargetSpec {
|
|
|
30
30
|
* No-op for cline (body verbatim) and codex (managed-section authors plain
|
|
31
31
|
* Markdown with no frontmatter).
|
|
32
32
|
*/
|
|
33
|
-
wrap(name: string, description: string, body: string): string;
|
|
33
|
+
wrap(name: string, description: string, body: string, quote?: boolean): string;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* How a skill contributes to the codex target's always-on `AGENTS.md` section.
|
|
@@ -65,7 +65,7 @@ export interface SkillSpec {
|
|
|
65
65
|
* `testsprite-onboard` codex contribution — a single always-on line. Kept here
|
|
66
66
|
* (not in a `*.codex.md` asset) because it is one line; see {@link CodexContribution}.
|
|
67
67
|
*/
|
|
68
|
-
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.
|
|
68
|
+
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. Ask the project's agent with `testsprite plan --project <id> \"<the main user flows>\"`, review what it proposes, then `testsprite apply`.";
|
|
69
69
|
/**
|
|
70
70
|
* `testsprite-ci` codex contribution — one always-on line; the full onboarding
|
|
71
71
|
* flow lives in the own-file body and the docs.
|
|
@@ -93,6 +93,12 @@ export declare const SKILL_NAME = "testsprite-verify";
|
|
|
93
93
|
* byte-identity unit test keep working.
|
|
94
94
|
*/
|
|
95
95
|
export declare const SKILL_DESCRIPTION: string;
|
|
96
|
+
/**
|
|
97
|
+
* Emit a frontmatter scalar: unchanged when a plain scalar is safe, otherwise a
|
|
98
|
+
* double-quoted YAML string (JSON escapes are a subset of YAML's). Keeps the
|
|
99
|
+
* verify/onboard renders byte-identical while making any description safe.
|
|
100
|
+
*/
|
|
101
|
+
export declare function yamlScalar(value: string): string;
|
|
96
102
|
/**
|
|
97
103
|
* Repo-relative landing path for a given skill on a given target (POSIX
|
|
98
104
|
* separators). Own-file targets embed the skill name in the path so multiple
|
|
@@ -193,6 +199,19 @@ export declare function loadCodexSkillBody(read?: ReadFn): string;
|
|
|
193
199
|
* string lags but the body is unchanged, the artifact still compares pristine.
|
|
194
200
|
*/
|
|
195
201
|
export declare function renderOwnFileWithMarker(target: AgentTarget, skill: string, markerLine: string, body?: string): string;
|
|
202
|
+
/**
|
|
203
|
+
* Render an own-file artifact the way v0.15.0 did: the description interpolated
|
|
204
|
+
* as an unquoted plain scalar. Kept only so install/status can recognise those
|
|
205
|
+
* files as pristine-but-outdated instead of user edits — never written.
|
|
206
|
+
*/
|
|
207
|
+
export declare function renderLegacyOwnFileWithMarker(target: AgentTarget, skill: string, markerLine: string, body?: string): string;
|
|
208
|
+
/**
|
|
209
|
+
* True when `content` is exactly what v0.15.0 wrote for this (target, skill):
|
|
210
|
+
* the marker's hash still matches the canonical body, but the bytes only match
|
|
211
|
+
* the legacy unquoted render. Such files are stale installs, not user edits, so
|
|
212
|
+
* a plain `agent install` may repair them without `--force`.
|
|
213
|
+
*/
|
|
214
|
+
export declare function isLegacyOwnFileRender(target: AgentTarget, skill: string, content: string, body?: string): boolean;
|
|
196
215
|
/**
|
|
197
216
|
* The exact bytes to write for one skill on one target.
|
|
198
217
|
*
|