@testsprite/testsprite-cli 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -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 +40 -56
- 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 +741 -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 +434 -43
- 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 +19 -186
- package/dist/commands/project.js +108 -926
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +216 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +28 -87
- package/dist/commands/test.d.ts +301 -1838
- package/dist/commands/test.js +1880 -13917
- package/dist/commands/testlist.d.ts +130 -5
- package/dist/commands/testlist.js +300 -342
- package/dist/commands/tunnel.d.ts +3 -3
- package/dist/commands/tunnel.js +23 -20
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +50 -131
- package/dist/index.js +191 -110
- 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 +12 -4
- package/dist/lib/client-factory.js +41 -30
- 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 +75 -0
- package/dist/lib/conversation/api.js +151 -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 +29 -0
- package/dist/lib/conversation/context.js +82 -0
- package/dist/lib/conversation/environment.d.ts +16 -0
- package/dist/lib/conversation/environment.js +21 -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 +318 -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 +158 -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 +100 -0
- package/dist/lib/download.js +408 -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 +19 -30
- package/dist/lib/environment-tunnel.js +168 -202
- 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 +20 -30
- package/dist/lib/first-suite-hint.js +57 -72
- 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 +354 -291
- 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 +8 -7
- package/dist/lib/local-target.js +14 -13
- package/dist/lib/output.d.ts +2 -41
- package/dist/lib/output.js +13 -51
- 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 +170 -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 +73 -0
- package/dist/lib/result/evidence.js +422 -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 +8 -8
- package/dist/lib/target-url.js +14 -24
- package/dist/lib/telemetry.d.ts +35 -15
- package/dist/lib/telemetry.js +38 -9
- 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 +8 -2
- package/dist/lib/tunnel-session.js +24 -11
- 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 +52 -23
- package/skills/testsprite-onboard.skill.md +70 -153
- package/skills/testsprite-verify.codex.md +54 -58
- package/skills/testsprite-verify.skill.md +189 -358
- 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
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Command, CommanderError } from 'commander';
|
|
2
|
+
import { Command, CommanderError, Option } 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';
|
|
@@ -40,39 +44,30 @@ program
|
|
|
40
44
|
.version(VERSION)
|
|
41
45
|
.option('--output <mode>', 'Output format (json|text)', 'text')
|
|
42
46
|
.option('--profile <name>', 'Configuration profile to use')
|
|
43
|
-
|
|
47
|
+
// For TestSprite's own use (pointing the CLI at a non-production API): it
|
|
48
|
+
// works, and no help page, completion script or "did you mean" names it.
|
|
49
|
+
.addOption(new Option('--endpoint-url <url>', 'API base URL (a full http(s) URL)').hideHelp())
|
|
44
50
|
.option('--verbose', 'Log HTTP retry / backoff / polling transitions to stderr (lighter than --debug)')
|
|
45
51
|
.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
|
|
52
|
+
.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
53
|
.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 `
|
|
54
|
+
'Does not affect the --timeout polling ceiling for `run` or `run wait`.');
|
|
49
55
|
// `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).
|
|
56
|
+
// agent reaches it before anything else.
|
|
52
57
|
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);
|
|
58
|
+
// The project's agent: the same conversations, cards and memory the portal has.
|
|
59
|
+
for (const command of createConversationCommands())
|
|
60
|
+
program.addCommand(command);
|
|
61
|
+
program.addCommand(createAuthCommand());
|
|
69
62
|
program.addCommand(createProjectCommand({}));
|
|
70
63
|
let waitTimeoutTelemetry = {};
|
|
71
|
-
program.addCommand(
|
|
64
|
+
program.addCommand(createRunCommand({
|
|
72
65
|
onWaitTimeout: context => {
|
|
73
66
|
waitTimeoutTelemetry = context;
|
|
74
67
|
},
|
|
75
68
|
}));
|
|
69
|
+
program.addCommand(createTestCommand());
|
|
70
|
+
program.addCommand(createResultCommand());
|
|
76
71
|
program.addCommand(createTestListCommand());
|
|
77
72
|
program.addCommand(createCiCommand({
|
|
78
73
|
onWaitTimeout: context => {
|
|
@@ -85,6 +80,35 @@ program.addCommand(createAgentCommand({}));
|
|
|
85
80
|
program.addCommand(createUsageCommand());
|
|
86
81
|
program.addCommand(createDoctorCommand());
|
|
87
82
|
program.addCommand(createCompletionCommand(() => buildCompletionSpec()));
|
|
83
|
+
// The root accepts global flags anywhere. Its ordinary parser also collects
|
|
84
|
+
// child operands before the first unknown option. Feed the whole run tail to
|
|
85
|
+
// the hybrid parser together, so it can stop at wait/cancel before consuming
|
|
86
|
+
// their flags. Other groups retain Commander's existing parsing behavior.
|
|
87
|
+
const parseRootOptions = program.parseOptions.bind(program);
|
|
88
|
+
program.parseOptions = args => {
|
|
89
|
+
const parsed = parseRootOptions(args);
|
|
90
|
+
if (parsed.operands[0] !== 'run')
|
|
91
|
+
return parsed;
|
|
92
|
+
const tail = [...parsed.operands.slice(1), ...parsed.unknown];
|
|
93
|
+
// Commander consumes a terminator encountered before any unknown option.
|
|
94
|
+
// Reinsert it before reprocessing operands, so literal IDs cannot turn into
|
|
95
|
+
// project/list launch flags. A required global option may itself take `--`
|
|
96
|
+
// as its value; that occurrence is not an option terminator.
|
|
97
|
+
for (let index = 0; index < args.length; index++) {
|
|
98
|
+
const arg = args[index];
|
|
99
|
+
if (arg === '--') {
|
|
100
|
+
if (parsed.unknown.length === 0) {
|
|
101
|
+
const literalCount = args.length - index - 1;
|
|
102
|
+
tail.splice(Math.max(0, parsed.operands.length - 1 - literalCount), 0, '--');
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
const option = program.options.find(option => option.long === arg || option.short === arg);
|
|
107
|
+
if (option?.required)
|
|
108
|
+
index++;
|
|
109
|
+
}
|
|
110
|
+
return { operands: ['run'], unknown: tail };
|
|
111
|
+
};
|
|
88
112
|
// Derive the shell-completion spec from the fully-assembled command tree at call
|
|
89
113
|
// time (not module-load), so `testsprite completion` can never drift from the
|
|
90
114
|
// real commands, subcommands, and global flags.
|
|
@@ -96,6 +120,7 @@ function buildCompletionSpec() {
|
|
|
96
120
|
subcommands[command.name()] = subs;
|
|
97
121
|
}
|
|
98
122
|
const flags = program.options
|
|
123
|
+
.filter(option => !option.hidden)
|
|
99
124
|
.map(option => option.long)
|
|
100
125
|
.filter((long) => typeof long === 'string');
|
|
101
126
|
if (!flags.includes('--help'))
|
|
@@ -117,14 +142,14 @@ let pendingCommanderErrorMsg = null;
|
|
|
117
142
|
// skips those. Read by the success + error telemetry emits around parseAsync.
|
|
118
143
|
let ranCommandPath = '';
|
|
119
144
|
// Whether the command that ran should emit telemetry. `completion` (its stdout
|
|
120
|
-
// is eval'd by shells)
|
|
121
|
-
//
|
|
145
|
+
// is eval'd by shells) is kept off the beacon, same as the update notice. Set by
|
|
146
|
+
// the preAction hook.
|
|
122
147
|
let telemetryEmit = false;
|
|
123
148
|
// Auth resolved in the preAction hook, before the command's action runs, so
|
|
124
149
|
// `auth remove` (which deletes the profile) is still reported on the key it used.
|
|
125
150
|
let telemetryAuth;
|
|
126
151
|
// Local project admission failures must exit without any TestSprite HTTP,
|
|
127
|
-
// including telemetry.
|
|
152
|
+
// including telemetry.
|
|
128
153
|
let telemetryLocalProject = false;
|
|
129
154
|
// Propagate exitOverride AND the buffered outputError config to every
|
|
130
155
|
// subcommand in the tree. Commander's addCommand() does NOT inherit either
|
|
@@ -136,8 +161,9 @@ function applyExitOverrideDeep(cmd) {
|
|
|
136
161
|
cmd.exitOverride();
|
|
137
162
|
cmd.configureOutput({
|
|
138
163
|
outputError(str, _write) {
|
|
139
|
-
const
|
|
140
|
-
|
|
164
|
+
const safe = redactUnknownOptionValue(str);
|
|
165
|
+
const rephrased = rephraseUnknownOption(safe);
|
|
166
|
+
pendingCommanderErrorMsg = rephrased !== null ? `${rephrased}\n` : safe;
|
|
141
167
|
},
|
|
142
168
|
});
|
|
143
169
|
for (const child of cmd.commands) {
|
|
@@ -145,33 +171,74 @@ function applyExitOverrideDeep(cmd) {
|
|
|
145
171
|
}
|
|
146
172
|
}
|
|
147
173
|
applyExitOverrideDeep(program);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
174
|
+
/** The subcommand of `group` that `name` names, by name or alias. */
|
|
175
|
+
function subcommandNamed(group, name) {
|
|
176
|
+
return group.commands.find(command => command.name() === name || command.aliases().includes(name));
|
|
151
177
|
}
|
|
152
178
|
/**
|
|
153
|
-
* Commander checks its implicit help option before reporting an unknown
|
|
154
|
-
* command
|
|
155
|
-
*
|
|
156
|
-
*
|
|
179
|
+
* Commander checks its implicit help option before reporting an unknown
|
|
180
|
+
* command, at every level: `<group> <unknown> --help` prints the group's
|
|
181
|
+
* help, and `help <group> <unknown>` or `<group> help <unknown>` fall back to
|
|
182
|
+
* it too.
|
|
183
|
+
* Walk the command names the program was given, from the root down, while
|
|
184
|
+
* help is being rendered: the first name that is not a subcommand of the
|
|
185
|
+
* group before it is the unknown command, and that error wins before any
|
|
186
|
+
* misleading help is written. Only groups are walked; a leaf's arguments
|
|
187
|
+
* are its own. `-h` / `--help` is skipped wherever it stands, so the order of
|
|
188
|
+
* the words does not matter; the walk stops at any other option, so a flag's
|
|
189
|
+
* value is never read as a command. Returns the unknown name and the group it
|
|
190
|
+
* was looked up in; the error handler walks the same way to name where a
|
|
191
|
+
* removed command went.
|
|
157
192
|
*/
|
|
158
|
-
function
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
193
|
+
function unknownCommandIn(args) {
|
|
194
|
+
let group = program;
|
|
195
|
+
// `help <name>…` at the root names the path to describe.
|
|
196
|
+
let explicitHelpPath = args[0] === 'help';
|
|
197
|
+
for (const name of explicitHelpPath ? args.slice(1) : args) {
|
|
198
|
+
if (group.commands.length === 0)
|
|
199
|
+
return undefined;
|
|
200
|
+
// The help flag asks for help wherever it stands; the names after it still
|
|
201
|
+
// have to exist (`test --help result`).
|
|
202
|
+
if (name === '-h' || name === '--help')
|
|
203
|
+
continue;
|
|
204
|
+
if (name.startsWith('-'))
|
|
205
|
+
return undefined;
|
|
206
|
+
// A group's own `help` subcommand: the name after it is its subcommand.
|
|
207
|
+
if (name === 'help') {
|
|
208
|
+
explicitHelpPath = true;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
const next = subcommandNamed(group, name);
|
|
212
|
+
if (next === undefined) {
|
|
213
|
+
if (group.name() === 'run' && group.parent === program && !explicitHelpPath)
|
|
214
|
+
return undefined;
|
|
215
|
+
return { group, name };
|
|
216
|
+
}
|
|
217
|
+
group = next;
|
|
162
218
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The command the leading names reach, which is the one that parses the
|
|
223
|
+
* options after them. The walk stops at the first option or the first word
|
|
224
|
+
* that is not a subcommand (an argument), like the walk above.
|
|
225
|
+
*/
|
|
226
|
+
function commandNamedBy(args) {
|
|
227
|
+
let command = program;
|
|
228
|
+
for (const name of args) {
|
|
229
|
+
const next = name.startsWith('-') ? undefined : subcommandNamed(command, name);
|
|
230
|
+
if (next === undefined)
|
|
231
|
+
break;
|
|
232
|
+
command = next;
|
|
233
|
+
}
|
|
234
|
+
return command;
|
|
166
235
|
}
|
|
167
236
|
program.addHelpText('after', '\nEnvironment:\n' +
|
|
168
237
|
' TESTSPRITE_API_KEY (overrides stored credentials), TESTSPRITE_NO_UPDATE_NOTIFIER (disables\n' +
|
|
169
|
-
' the version check);
|
|
170
|
-
'
|
|
171
|
-
program.addHelpText('beforeAll',
|
|
172
|
-
|
|
173
|
-
return '';
|
|
174
|
-
const unknownCommand = unknownRootCommandMaskedByHelp(program.args);
|
|
238
|
+
' the version check); TESTSPRITE_PROFILE and TESTSPRITE_REQUEST_TIMEOUT_MS (milliseconds)\n' +
|
|
239
|
+
' mirror --profile and --request-timeout.');
|
|
240
|
+
program.addHelpText('beforeAll', () => {
|
|
241
|
+
const unknownCommand = unknownCommandIn(program.args)?.name;
|
|
175
242
|
if (unknownCommand) {
|
|
176
243
|
program.error(`error: unknown command '${unknownCommand}'`, {
|
|
177
244
|
code: 'commander.unknownCommand',
|
|
@@ -180,8 +247,8 @@ program.addHelpText('beforeAll', context => {
|
|
|
180
247
|
return '';
|
|
181
248
|
});
|
|
182
249
|
/**
|
|
183
|
-
* Render a leaf command's full path (group + leaf), e.g. `
|
|
184
|
-
* `auth
|
|
250
|
+
* Render a leaf command's full path (group + leaf), e.g. `run` /
|
|
251
|
+
* `auth status`, by walking parents up to (but not including) the root program.
|
|
185
252
|
*/
|
|
186
253
|
function commandPathOf(cmd) {
|
|
187
254
|
const names = [];
|
|
@@ -203,54 +270,56 @@ function telemetryGlobals() {
|
|
|
203
270
|
// action; the helper self-gates (text-only, non-dry-run, a small command
|
|
204
271
|
// allowlist, opt-out via TESTSPRITE_NO_SKILL_WARNING) and never throws.
|
|
205
272
|
program.hook('preAction', (_thisCommand, actionCommand) => {
|
|
206
|
-
const globals = actionCommand.optsWithGlobals();
|
|
207
273
|
const commandPath = commandPathOf(actionCommand);
|
|
208
274
|
// Record which leaf command ran, for the telemetry emit around parseAsync.
|
|
209
275
|
ranCommandPath = commandPath;
|
|
210
|
-
|
|
276
|
+
const globals = actionCommand.optsWithGlobals();
|
|
277
|
+
// Preserve explicit --local attempts (project env create), including refusals;
|
|
211
278
|
// only flag presence is recorded. Automatic tunnel paths record the same fact.
|
|
212
279
|
if (globals.local !== undefined)
|
|
213
280
|
recordTelemetryExtras({ local: true });
|
|
214
281
|
telemetryLocalProject =
|
|
215
282
|
commandPath === 'project create' &&
|
|
216
283
|
(globals.local !== undefined || globals.localHost !== undefined);
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
//
|
|
221
|
-
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
|
|
284
|
+
// Telemetry gate, same reason as the update notice below: skip `completion`
|
|
285
|
+
// (its stdout is eval'd by shells). Resolve auth now, before the command's
|
|
286
|
+
// action runs, so `auth remove` still reports on the key it used; skip the
|
|
287
|
+
// read for opt-out / dry-run.
|
|
288
|
+
telemetryEmit = commandPath !== 'completion';
|
|
289
|
+
// Refuse an empty or whitespace-only positional before the action runs.
|
|
290
|
+
// This sits below the telemetry gate so the refusal is still reported as a
|
|
291
|
+
// VALIDATION_ERROR outcome, as it was when each command checked for itself,
|
|
292
|
+
// and above the auth read so a bad profile cannot replace this error.
|
|
293
|
+
validatePositionalArgs(actionCommand);
|
|
294
|
+
// The auth read is best-effort: an unreadable credentials file must not end
|
|
295
|
+
// the process here, before the command could run — `doctor` exists to
|
|
296
|
+
// diagnose exactly that, and offline commands never need the key. On failure
|
|
297
|
+
// the command runs as if telemetry were off (no event, and no fallback read
|
|
298
|
+
// at exit either).
|
|
225
299
|
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,
|
|
300
|
+
telemetryAuth = tryResolveTelemetryAuth({ profile: globals.profile, endpointUrl: globals.endpointUrl }, {
|
|
301
|
+
onError: globals.debug
|
|
302
|
+
? error => process.stderr.write(`[debug] telemetry skipped: ${error instanceof Error ? error.message : String(error)}\n`)
|
|
303
|
+
: undefined,
|
|
240
304
|
});
|
|
305
|
+
if (telemetryAuth === undefined)
|
|
306
|
+
telemetryEmit = false;
|
|
241
307
|
}
|
|
308
|
+
maybeEmitSkillNudge({
|
|
309
|
+
commandPath,
|
|
310
|
+
output: isOutputMode(globals.output) ? globals.output : 'text',
|
|
311
|
+
dryRun: globals.dryRun ?? false,
|
|
312
|
+
profile: resolveProfileName(globals.profile),
|
|
313
|
+
cwd: process.cwd(),
|
|
314
|
+
env: process.env,
|
|
315
|
+
debug: globals.debug ?? false,
|
|
316
|
+
});
|
|
242
317
|
// Best-effort update notice (see lib/update-check.ts): self-gates on the
|
|
243
318
|
// opt-out env, CI, TTY, and a 24h cache; the wiring adds the flag-level
|
|
244
319
|
// 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) {
|
|
320
|
+
// by shells), under --output json and under --dry-run. Deliberately not
|
|
321
|
+
// awaited: an advisory must never delay the real command.
|
|
322
|
+
if (globals.output !== 'json' && globals.dryRun !== true && commandPath !== 'completion') {
|
|
254
323
|
void maybeNotifyUpdate();
|
|
255
324
|
}
|
|
256
325
|
});
|
|
@@ -323,45 +392,46 @@ catch (err) {
|
|
|
323
392
|
const output = new Output(mode);
|
|
324
393
|
if (err instanceof ApiError) {
|
|
325
394
|
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;
|
|
395
|
+
const { message, nextAction, details } = err;
|
|
330
396
|
if (mode === 'json') {
|
|
331
397
|
const envelope = {
|
|
332
398
|
error: {
|
|
333
399
|
code: err.code,
|
|
334
400
|
message,
|
|
335
|
-
nextAction
|
|
401
|
+
nextAction,
|
|
336
402
|
requestId: err.requestId,
|
|
337
403
|
// `err.details` is already redacted at ApiError construction (see
|
|
338
404
|
// `errors.ts`); redacting again here is defence in depth for this
|
|
339
405
|
// hand-built envelope specifically, independent of that.
|
|
340
|
-
details: redactDeep(
|
|
406
|
+
details: redactDeep(details),
|
|
341
407
|
...(billingRefusal ? { links: billingRefusal.links } : {}),
|
|
342
408
|
},
|
|
343
409
|
};
|
|
344
|
-
process.stderr.write(`${
|
|
410
|
+
process.stderr.write(`${jsonForTerminal(envelope, 2)}\n`);
|
|
345
411
|
}
|
|
346
412
|
else {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
413
|
+
// Server text on a terminal: escape sequences and other control
|
|
414
|
+
// characters are removed, and the message and request id stay on their
|
|
415
|
+
// own line, so the server cannot write a line of its own beneath them.
|
|
416
|
+
// The JSON envelope above keeps what the server sent.
|
|
417
|
+
process.stderr.write(`Error: ${terminalSafeLine(message)}\n`);
|
|
418
|
+
if (nextAction)
|
|
419
|
+
process.stderr.write(`${terminalSafe(nextAction)}\n`);
|
|
350
420
|
if (billingRefusal) {
|
|
351
421
|
for (const line of billingRefusal.lines)
|
|
352
422
|
process.stderr.write(`${line}\n`);
|
|
353
423
|
}
|
|
354
424
|
if (err.requestId && err.requestId !== 'local')
|
|
355
|
-
process.stderr.write(`requestId: ${err.requestId}\n`);
|
|
425
|
+
process.stderr.write(`requestId: ${terminalSafeLine(err.requestId)}\n`);
|
|
356
426
|
// C1: surface requiredScopes / grantedScopes on AUTH_FORBIDDEN
|
|
357
427
|
if (err.code === 'AUTH_FORBIDDEN') {
|
|
358
428
|
const required = err.getDetail('requiredScopes');
|
|
359
429
|
const granted = err.getDetail('grantedScopes');
|
|
360
430
|
if (Array.isArray(required) && required.length > 0) {
|
|
361
|
-
process.stderr.write(` required: ${required.join(', ')}\n`);
|
|
431
|
+
process.stderr.write(` required: ${terminalSafeLine(required.join(', '))}\n`);
|
|
362
432
|
}
|
|
363
433
|
if (Array.isArray(granted)) {
|
|
364
|
-
process.stderr.write(` granted: ${granted.join(', ')}\n`);
|
|
434
|
+
process.stderr.write(` granted: ${terminalSafeLine(granted.join(', '))}\n`);
|
|
365
435
|
}
|
|
366
436
|
}
|
|
367
437
|
// Surface the version gap on CLIENT_TOO_OLD so the user sees exactly what
|
|
@@ -371,7 +441,7 @@ catch (err) {
|
|
|
371
441
|
const your = err.getDetail('yourVersion');
|
|
372
442
|
const min = err.getDetail('minVersion');
|
|
373
443
|
if (typeof your === 'string' && typeof min === 'string') {
|
|
374
|
-
process.stderr.write(` your version: ${your}, minimum supported: ${min}\n`);
|
|
444
|
+
process.stderr.write(` your version: ${terminalSafeLine(your)}, minimum supported: ${terminalSafeLine(min)}\n`);
|
|
375
445
|
}
|
|
376
446
|
}
|
|
377
447
|
// AMBIGUOUS_ORG: the same testId resolved inside more than one of the
|
|
@@ -395,10 +465,10 @@ catch (err) {
|
|
|
395
465
|
// A disarmed request has no run ID, so its JSON hint describes checking
|
|
396
466
|
// current state before retrying. Both use the conventional 128+signum code.
|
|
397
467
|
if (mode === 'json') {
|
|
398
|
-
process.stderr.write(`${
|
|
468
|
+
process.stderr.write(`${jsonForTerminal(buildInterruptEnvelope(err), 2)}\n`);
|
|
399
469
|
}
|
|
400
470
|
else {
|
|
401
|
-
process.stderr.write(`Error: ${err.message}\n`);
|
|
471
|
+
process.stderr.write(`Error: ${terminalSafeLine(err.message)}\n`);
|
|
402
472
|
}
|
|
403
473
|
await flushThenSetExitCode(err.exitCode);
|
|
404
474
|
armInterruptExitBackstop(err.exitCode);
|
|
@@ -411,16 +481,17 @@ catch (err) {
|
|
|
411
481
|
error: {
|
|
412
482
|
code: 'REQUEST_TIMEOUT',
|
|
413
483
|
message: err.message,
|
|
414
|
-
nextAction:
|
|
415
|
-
'
|
|
484
|
+
nextAction: err.nextAction ??
|
|
485
|
+
'Increase --request-timeout <seconds> or set TESTSPRITE_REQUEST_TIMEOUT_MS. ' +
|
|
486
|
+
'Check that the backend is reachable and not overloaded.',
|
|
416
487
|
requestId: err.requestId,
|
|
417
488
|
details: { timeoutMs: err.timeoutMs },
|
|
418
489
|
},
|
|
419
490
|
};
|
|
420
|
-
process.stderr.write(`${
|
|
491
|
+
process.stderr.write(`${jsonForTerminal(envelope, 2)}\n`);
|
|
421
492
|
}
|
|
422
493
|
else {
|
|
423
|
-
process.stderr.write(`Error: ${err.message}\n`);
|
|
494
|
+
process.stderr.write(`Error: ${terminalSafeLine(err.message)}\n`);
|
|
424
495
|
}
|
|
425
496
|
await flushThenSetExitCode(err.exitCode);
|
|
426
497
|
}
|
|
@@ -461,7 +532,17 @@ catch (err) {
|
|
|
461
532
|
}
|
|
462
533
|
return mode;
|
|
463
534
|
})();
|
|
464
|
-
|
|
535
|
+
// A removed command also says where it went, by the
|
|
536
|
+
// same walk that found the unknown name (Commander's own error and the
|
|
537
|
+
// one raised before a group's help both arrive here). A removed option
|
|
538
|
+
// does too, from the command the arguments name and the message it wrote.
|
|
539
|
+
const unknown = err.code === 'commander.unknownCommand' ? unknownCommandIn(program.args) : undefined;
|
|
540
|
+
const removedPointer = unknown !== undefined
|
|
541
|
+
? removedCommandPointer(commandPathOf(unknown.group), unknown.name)
|
|
542
|
+
: err.code === 'commander.unknownOption'
|
|
543
|
+
? removedOptionPointer(commandPathOf(commandNamedBy(program.args)), err.message)
|
|
544
|
+
: undefined;
|
|
545
|
+
process.stderr.write(renderCommanderError(pendingCommanderErrorMsg, err.message, commanderMode, removedPointer));
|
|
465
546
|
await flushThenSetExitCode(5);
|
|
466
547
|
}
|
|
467
548
|
}
|
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
|
*
|