@testsprite/testsprite-cli 0.8.0 → 0.10.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 -47
- package/dist/commands/agent.d.ts +3 -0
- package/dist/commands/agent.js +32 -7
- package/dist/commands/ci.js +4 -1
- package/dist/commands/init.d.ts +45 -2
- package/dist/commands/init.js +190 -29
- package/dist/commands/project.d.ts +21 -0
- package/dist/commands/project.js +118 -12
- package/dist/commands/test.d.ts +32 -3
- package/dist/commands/test.js +157 -29
- package/dist/lib/agent-detect.d.ts +53 -0
- package/dist/lib/agent-detect.js +198 -0
- package/dist/lib/dry-run/samples.js +16 -9
- package/dist/lib/http.d.ts +10 -0
- package/dist/lib/http.js +6 -2
- package/dist/lib/response-schemas.js +14 -0
- package/dist/lib/runs.types.d.ts +26 -0
- package/dist/lib/skill-nudge.d.ts +13 -5
- package/dist/lib/skill-nudge.js +40 -14
- package/dist/lib/target-url.d.ts +10 -1
- package/dist/lib/target-url.js +28 -11
- package/dist/lib/tunnel-session.d.ts +12 -3
- package/dist/lib/tunnel-session.js +23 -6
- package/dist/vendor/tunnel-client/client.d.ts +2 -3
- package/dist/vendor/tunnel-client/client.js +60 -7
- package/dist/vendor/tunnel-client/config.d.ts +8 -0
- package/dist/vendor/tunnel-client/config.js +8 -0
- package/dist/vendor/tunnel-client/types.d.ts +5 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/testsprite-onboard.skill.md +6 -0
- package/skills/testsprite-verify.skill.md +5 -1
package/dist/commands/init.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* `testsprite init` — one-shot onboarding orchestrator.
|
|
3
3
|
*
|
|
4
4
|
* Chains, in order:
|
|
5
|
+
* 0. Agent-target resolution + confirmation prompt — the chosen install
|
|
6
|
+
* targets are settled here, before anything is written
|
|
5
7
|
* 1. runConfigure — writes the API-key profile (validates via GET /me first)
|
|
6
8
|
* 2. runWhoami — fetches identity for the post-configure banner
|
|
7
9
|
* 3. runInstall — installs the TestSprite verification-loop skill (unless --no-agent)
|
|
@@ -13,11 +15,13 @@ import { Command } from 'commander';
|
|
|
13
15
|
import { parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
14
16
|
import { normalizeEnvVar } from '../lib/config.js';
|
|
15
17
|
import { emitDeprecationNotice } from '../lib/deprecate.js';
|
|
16
|
-
import { CLIError } from '../lib/errors.js';
|
|
18
|
+
import { CLIError, localValidationError } from '../lib/errors.js';
|
|
17
19
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
18
20
|
import { runConfigure, runWhoami } from './auth.js';
|
|
19
21
|
import { runInstall } from './agent.js';
|
|
20
22
|
import { TARGETS, DEFAULT_SKILLS } from '../lib/agent-targets.js';
|
|
23
|
+
import { FALLBACK_TARGET, resolveAgentTargets, } from '../lib/agent-detect.js';
|
|
24
|
+
import { promptText } from '../lib/prompt.js';
|
|
21
25
|
import { readProfile } from '../lib/credentials.js';
|
|
22
26
|
/** Mirrors auth.ts's DEFAULT_API_URL (kept in sync; auth.ts owns the canonical value). */
|
|
23
27
|
const DEFAULT_API_URL = 'https://api.testsprite.com';
|
|
@@ -41,6 +45,22 @@ function resolveReportedEndpoint(opts, deps) {
|
|
|
41
45
|
}
|
|
42
46
|
return opts.endpointUrl ?? envApiUrl ?? existing ?? DEFAULT_API_URL;
|
|
43
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Provenance for the summary. `env` and `trace` both collapse to `detected`
|
|
50
|
+
* because resolution is a union of the two signals — one word cannot honestly
|
|
51
|
+
* label a set whose members came from different ones. The split is carried
|
|
52
|
+
* per target in `detections`.
|
|
53
|
+
*/
|
|
54
|
+
function agentProvenance(r) {
|
|
55
|
+
return {
|
|
56
|
+
detectedBy: r.source === 'flag' || r.source === 'fallback' ? r.source : 'detected',
|
|
57
|
+
detections: r.detections.map(d => ({
|
|
58
|
+
target: d.target,
|
|
59
|
+
source: d.source,
|
|
60
|
+
signal: d.signal,
|
|
61
|
+
})),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
44
64
|
/**
|
|
45
65
|
* Collapse the per-skill install actions into one representative action for the
|
|
46
66
|
* init summary. Precedence: a real change (updated) outranks a fresh install,
|
|
@@ -103,17 +123,119 @@ function toAgentDeps(deps, captureStdout) {
|
|
|
103
123
|
function _suppressedStdout(_line) {
|
|
104
124
|
// intentionally empty
|
|
105
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Say which agents the install covers and why. Silent when `--agent` named one
|
|
128
|
+
* (the caller already knows), and always says the fallback out loud — an
|
|
129
|
+
* unannounced fallback is how skills land where the calling agent cannot read
|
|
130
|
+
* them while the command still reports success.
|
|
131
|
+
*/
|
|
132
|
+
function emitAgentResolutionNotice(resolution, stderrFn, willPrompt = false) {
|
|
133
|
+
if (resolution.source === 'flag')
|
|
134
|
+
return;
|
|
135
|
+
if (resolution.source === 'fallback') {
|
|
136
|
+
stderrFn(`[info] no coding agent detected in this project; installing for ${FALLBACK_TARGET}. ` +
|
|
137
|
+
`Pass --agent <target> to choose (${Object.keys(TARGETS).join(', ')}).`);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const evidence = resolution.detections.map(d => `${d.target} (${d.signal})`).join(', ');
|
|
141
|
+
// When a prompt follows, the install set is not decided yet — saying
|
|
142
|
+
// "installing for X" here would read as a decision already taken.
|
|
143
|
+
if (willPrompt) {
|
|
144
|
+
stderrFn(`[info] detected ${evidence}`);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
stderrFn(`[info] detected ${evidence}; installing skills for ${resolution.targets.join(', ')}`);
|
|
148
|
+
}
|
|
149
|
+
/** Whether `confirmDetectedTargets` will actually ask. */
|
|
150
|
+
function shouldConfirmTargets(resolution, opts, isTTY) {
|
|
151
|
+
const fromDetection = resolution.source === 'env' || resolution.source === 'trace';
|
|
152
|
+
return fromDetection && isTTY && !opts.yes && !opts.dryRun && opts.output !== 'json';
|
|
153
|
+
}
|
|
154
|
+
const CONFIRM_TARGETS_MAX_ATTEMPTS = 3;
|
|
155
|
+
/**
|
|
156
|
+
* Let an operator see and edit the detected set before anything is written.
|
|
157
|
+
*
|
|
158
|
+
* Detection is a UNION of env and repo signals, so an ordinary repo carrying
|
|
159
|
+
* `AGENTS.md` plus a couple of agent config roots resolves to five targets and
|
|
160
|
+
* nine files — two of them shared, always-on rule files. `agent install`
|
|
161
|
+
* already asks when it has to choose; setup asking too keeps the two commands
|
|
162
|
+
* telling the same story.
|
|
163
|
+
*
|
|
164
|
+
* Returns the set to install, or `null` when the answer was `none` — the
|
|
165
|
+
* prompt's equivalent of `--no-agent`. Asks nothing when `--agent` named it
|
|
166
|
+
* (already explicit), on the fallback (one target, and the notice says so),
|
|
167
|
+
* under `--yes`, under `--dry-run` (nothing is written), off a TTY, or in JSON
|
|
168
|
+
* mode — a prompt there would corrupt the single-object stdout contract, the
|
|
169
|
+
* same reason the API-key prompt is refused in that mode.
|
|
170
|
+
*
|
|
171
|
+
* An unrecognised name is refused here and asked again, a bounded number of
|
|
172
|
+
* times. This runs before credentials are written, so a typo costs a retry
|
|
173
|
+
* rather than a half-finished setup that exits 5 after the key was saved.
|
|
174
|
+
*/
|
|
175
|
+
async function confirmDetectedTargets(resolution, opts, isTTY, stderrFn, promptFn) {
|
|
176
|
+
if (!shouldConfirmTargets(resolution, opts, isTTY)) {
|
|
177
|
+
return [...resolution.targets];
|
|
178
|
+
}
|
|
179
|
+
const suggestion = resolution.targets.join(',');
|
|
180
|
+
const validTargets = Object.keys(TARGETS);
|
|
181
|
+
const ask = promptFn ?? ((q) => promptText(q));
|
|
182
|
+
for (let attempt = 1; attempt <= CONFIRM_TARGETS_MAX_ATTEMPTS; attempt++) {
|
|
183
|
+
const answer = (await ask(`Install skills for (comma-separated, or "none" to skip) [${suggestion}]: `)).trim();
|
|
184
|
+
if (answer.toLowerCase() === 'none')
|
|
185
|
+
return null;
|
|
186
|
+
// Lower-cased for the same reason `none` is: every target name is lower
|
|
187
|
+
// case, so `Claude` is a typo only in the sense that the shift key was
|
|
188
|
+
// down. Refusing it while accepting `NONE` would be an inconsistency the
|
|
189
|
+
// user has no way to predict.
|
|
190
|
+
const chosen = (answer || suggestion)
|
|
191
|
+
.split(',')
|
|
192
|
+
.map((s) => s.trim().toLowerCase())
|
|
193
|
+
.filter(Boolean);
|
|
194
|
+
// An answer of only separators ("," / ", ,") parses to nothing. Treat it as
|
|
195
|
+
// the empty answer it effectively is rather than installing for no target.
|
|
196
|
+
if (chosen.length === 0)
|
|
197
|
+
return [...resolution.targets];
|
|
198
|
+
const unknown = chosen.filter(t => !validTargets.includes(t));
|
|
199
|
+
if (unknown.length === 0)
|
|
200
|
+
return [...new Set(chosen)];
|
|
201
|
+
stderrFn(`[warn] unknown target ${unknown.map(t => `"${t}"`).join(', ')}; ` +
|
|
202
|
+
`supported: ${validTargets.join(', ')} (or "none" to skip)`);
|
|
203
|
+
}
|
|
204
|
+
throw new CLIError(`No recognised agent target after ${CONFIRM_TARGETS_MAX_ATTEMPTS} attempts. ` +
|
|
205
|
+
`Re-run with --agent <target> (${validTargets.join(', ')}) or --no-agent.`, 5);
|
|
206
|
+
}
|
|
106
207
|
// ---------------------------------------------------------------------------
|
|
107
208
|
// runInit
|
|
108
209
|
// ---------------------------------------------------------------------------
|
|
109
210
|
export async function runInit(opts, deps = {}) {
|
|
110
211
|
const stderrFn = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
111
212
|
const out = new Output(opts.output, { stdout: deps.stdout, stderr: deps.stderr });
|
|
213
|
+
// An unknown --agent is refused here, before credentials are written. Left
|
|
214
|
+
// to runInstall it surfaced as a `--target` error — a flag this command does
|
|
215
|
+
// not have — after the key was already saved, with a hint echoing the bad
|
|
216
|
+
// value back.
|
|
217
|
+
const validTargets = Object.keys(TARGETS);
|
|
218
|
+
if (opts.agent !== undefined && !opts.noAgent && !validTargets.includes(opts.agent)) {
|
|
219
|
+
throw localValidationError('agent', `unknown target "${opts.agent}"; supported: ${validTargets.join(', ')}`);
|
|
220
|
+
}
|
|
221
|
+
// -------------------------------------------------------------------------
|
|
222
|
+
// Which agents to install for: an explicit --agent, else whatever this repo
|
|
223
|
+
// shows, else the fallback. Resolved before any output so every branch below
|
|
224
|
+
// (conflict warning, dry-run preview, real install) reports the same set.
|
|
225
|
+
// -------------------------------------------------------------------------
|
|
226
|
+
let resolution = opts.noAgent
|
|
227
|
+
? null
|
|
228
|
+
: resolveAgentTargets(opts.agent, opts.dir ?? deps.cwd ?? process.cwd(), {
|
|
229
|
+
env: deps.env,
|
|
230
|
+
...deps.detect,
|
|
231
|
+
});
|
|
112
232
|
// -------------------------------------------------------------------------
|
|
113
233
|
// Fix 5: emit conflict warning when both --agent and --no-agent were given
|
|
114
234
|
// -------------------------------------------------------------------------
|
|
115
235
|
if (opts.rawArgConflict) {
|
|
116
|
-
const effectiveLabel = opts.noAgent
|
|
236
|
+
const effectiveLabel = opts.noAgent
|
|
237
|
+
? '--no-agent'
|
|
238
|
+
: `--agent ${opts.agent ?? resolution?.targets.join(',')}`;
|
|
117
239
|
stderrFn(`[warn] both --no-agent and --agent supplied; using ${effectiveLabel} (last flag wins)`);
|
|
118
240
|
}
|
|
119
241
|
// -------------------------------------------------------------------------
|
|
@@ -141,6 +263,28 @@ export async function runInit(opts, deps = {}) {
|
|
|
141
263
|
throw new CLIError('Interactive API-key prompt is unavailable in --output json mode (it would corrupt JSON stdout). ' +
|
|
142
264
|
'Pass --api-key <key> or --from-env.', 5);
|
|
143
265
|
}
|
|
266
|
+
// Announced only once the guards above have passed — otherwise a `--yes` with
|
|
267
|
+
// no key source printed "detected …" and then exited 5, describing an install
|
|
268
|
+
// that was never going to happen.
|
|
269
|
+
let agentSkippedBy = opts.noAgent ? 'flag' : undefined;
|
|
270
|
+
if (resolution) {
|
|
271
|
+
const willPrompt = shouldConfirmTargets(resolution, opts, isTTY);
|
|
272
|
+
emitAgentResolutionNotice(resolution, stderrFn, willPrompt);
|
|
273
|
+
// A detected set is confirmable before it lands; every other case passes
|
|
274
|
+
// through untouched. Narrowed here so every downstream reader — the install
|
|
275
|
+
// call, the summary, the failure hint — sees the set actually chosen.
|
|
276
|
+
const confirmed = await confirmDetectedTargets(resolution, opts, isTTY, stderrFn, deps.agentPrompt);
|
|
277
|
+
if (confirmed === null) {
|
|
278
|
+
stderrFn('[info] skipping the agent skill install (answered "none")');
|
|
279
|
+
resolution = null;
|
|
280
|
+
agentSkippedBy = 'prompt';
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
resolution = { ...resolution, targets: confirmed };
|
|
284
|
+
if (willPrompt)
|
|
285
|
+
stderrFn(`[info] installing skills for ${confirmed.join(', ')}`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
144
288
|
// -------------------------------------------------------------------------
|
|
145
289
|
// Dry-run: zero network + zero FS writes; print preview only
|
|
146
290
|
// -------------------------------------------------------------------------
|
|
@@ -153,13 +297,12 @@ export async function runInit(opts, deps = {}) {
|
|
|
153
297
|
: opts.skipIfConfigured
|
|
154
298
|
? 'skip-if-configured'
|
|
155
299
|
: 'prompt'})`);
|
|
156
|
-
|
|
157
|
-
if (!opts.noAgent) {
|
|
300
|
+
if (resolution) {
|
|
158
301
|
// Delegate to runInstall's own dry-run for the file-listing preview.
|
|
159
302
|
// runInstall prints the would-write lines itself under dryRun.
|
|
160
303
|
await runInstall({
|
|
161
304
|
...opts,
|
|
162
|
-
target:
|
|
305
|
+
target: resolution.targets,
|
|
163
306
|
force: opts.force,
|
|
164
307
|
dir: opts.dir,
|
|
165
308
|
}, toAgentDeps(deps));
|
|
@@ -169,8 +312,14 @@ export async function runInit(opts, deps = {}) {
|
|
|
169
312
|
apiUrl: resolveReportedEndpoint(opts, deps),
|
|
170
313
|
env: 'development',
|
|
171
314
|
scopes: [],
|
|
172
|
-
agent:
|
|
173
|
-
? {
|
|
315
|
+
agent: resolution
|
|
316
|
+
? {
|
|
317
|
+
target: resolution.targets[0],
|
|
318
|
+
targets: [...resolution.targets],
|
|
319
|
+
...agentProvenance(resolution),
|
|
320
|
+
action: 'dry-run',
|
|
321
|
+
skills: [...DEFAULT_SKILLS],
|
|
322
|
+
}
|
|
174
323
|
: null,
|
|
175
324
|
status: 'initialized',
|
|
176
325
|
};
|
|
@@ -225,10 +374,10 @@ export async function runInit(opts, deps = {}) {
|
|
|
225
374
|
// -------------------------------------------------------------------------
|
|
226
375
|
// Step 3: Agent skill install (unless --no-agent)
|
|
227
376
|
// -------------------------------------------------------------------------
|
|
228
|
-
let
|
|
377
|
+
let installedTargets = null;
|
|
229
378
|
let installedAction = null;
|
|
230
379
|
let installedSkills = [];
|
|
231
|
-
if (
|
|
380
|
+
if (resolution) {
|
|
232
381
|
// Run install in JSON mode internally so we can reliably parse the result
|
|
233
382
|
// regardless of the outer --output flag. The stdout is captured here and
|
|
234
383
|
// NOT forwarded — runInit owns the output surface. setup installs the full
|
|
@@ -250,12 +399,12 @@ export async function runInit(opts, deps = {}) {
|
|
|
250
399
|
await runInstall({
|
|
251
400
|
...opts,
|
|
252
401
|
output: 'json', // parse the result; final summary is ours to print
|
|
253
|
-
target:
|
|
402
|
+
target: resolution.targets,
|
|
254
403
|
// skills omitted → runInstall installs DEFAULT_SKILLS (verify + onboard)
|
|
255
404
|
force: opts.force,
|
|
256
405
|
dir: opts.dir,
|
|
257
406
|
}, toAgentDeps(deps, captureStdout));
|
|
258
|
-
|
|
407
|
+
installedTargets = [...resolution.targets];
|
|
259
408
|
installedAction =
|
|
260
409
|
capturedInstallResults.length > 0
|
|
261
410
|
? aggregateInstallAction(capturedInstallResults.map(r => r.action))
|
|
@@ -268,17 +417,19 @@ export async function runInit(opts, deps = {}) {
|
|
|
268
417
|
// Emit a clear summary line BEFORE re-throwing so the user knows their
|
|
269
418
|
// API key was persisted — only the agent skill step failed (Fix 6).
|
|
270
419
|
stderrFn(`[info] credentials saved for profile "${opts.profile}"; only the agent skill install failed — ` +
|
|
271
|
-
`re-run 'testsprite agent install --target ${
|
|
420
|
+
`re-run 'testsprite agent install --target ${resolution.targets.join(',')}' after fixing the path`);
|
|
272
421
|
throw installErr;
|
|
273
422
|
}
|
|
274
423
|
}
|
|
275
424
|
// -------------------------------------------------------------------------
|
|
276
425
|
// Step 4: Summary
|
|
277
426
|
// -------------------------------------------------------------------------
|
|
278
|
-
const agentSummary =
|
|
427
|
+
const agentSummary = resolution === null || installedTargets === null
|
|
279
428
|
? null
|
|
280
429
|
: {
|
|
281
|
-
target:
|
|
430
|
+
target: installedTargets[0],
|
|
431
|
+
targets: installedTargets,
|
|
432
|
+
...agentProvenance(resolution),
|
|
282
433
|
action: installedAction ?? 'installed',
|
|
283
434
|
skills: installedSkills.length > 0 ? installedSkills : [...DEFAULT_SKILLS],
|
|
284
435
|
};
|
|
@@ -291,6 +442,7 @@ export async function runInit(opts, deps = {}) {
|
|
|
291
442
|
email: me.email,
|
|
292
443
|
scopes: me.scopes,
|
|
293
444
|
agent: agentSummary,
|
|
445
|
+
...(agentSummary === null && agentSkippedBy ? { agentSkippedBy } : {}),
|
|
294
446
|
status: 'initialized',
|
|
295
447
|
};
|
|
296
448
|
out.print(summary, renderInitText);
|
|
@@ -312,13 +464,16 @@ function renderInitText(data) {
|
|
|
312
464
|
lines.push(` scopes: ${s.scopes.join(', ')}`);
|
|
313
465
|
lines.push('');
|
|
314
466
|
if (s.agent) {
|
|
315
|
-
|
|
467
|
+
const targets = s.agent.targets.length > 0 ? s.agent.targets : [s.agent.target];
|
|
468
|
+
lines.push(` agent: ${targets.join(', ')} (${s.agent.action})`);
|
|
316
469
|
if (s.agent.skills && s.agent.skills.length > 0) {
|
|
317
470
|
lines.push(` skills: ${s.agent.skills.join(', ')}`);
|
|
318
471
|
}
|
|
319
472
|
}
|
|
320
473
|
else {
|
|
321
|
-
lines.push(
|
|
474
|
+
lines.push(s.agentSkippedBy === 'prompt'
|
|
475
|
+
? ' agent: skipped (answered "none" at the prompt)'
|
|
476
|
+
: ' agent: skipped (--no-agent)');
|
|
322
477
|
}
|
|
323
478
|
lines.push('');
|
|
324
479
|
// DEV-279: an agent session already open when the skills landed won't re-read
|
|
@@ -369,12 +524,18 @@ function resolveCommonOptions(command) {
|
|
|
369
524
|
};
|
|
370
525
|
}
|
|
371
526
|
const SETUP_DESCRIPTION = 'Set up TestSprite: configure your API key and install the TestSprite agent skills for your coding agent';
|
|
372
|
-
/**
|
|
527
|
+
/**
|
|
528
|
+
* Attach the onboarding flags shared by `setup` and the `init`/`auth configure`
|
|
529
|
+
* aliases. `--agent` deliberately carries NO default: its absence is the signal
|
|
530
|
+
* that setup should detect the agent, and a default value here is
|
|
531
|
+
* indistinguishable from the caller naming that same target.
|
|
532
|
+
*/
|
|
373
533
|
export function addSetupOptions(cmd, validTargets, defaultAgent) {
|
|
374
534
|
return cmd
|
|
375
535
|
.option('--api-key <key>', 'API key to configure (skips the interactive prompt)')
|
|
376
536
|
.option('--from-env', 'Read TESTSPRITE_API_KEY from the environment instead of prompting', false)
|
|
377
|
-
.option('--agent <target>', `Coding-agent target to install: ${validTargets.join(', ')}
|
|
537
|
+
.option('--agent <target>', `Coding-agent target to install: ${validTargets.join(', ')} ` +
|
|
538
|
+
`(default: every agent detected in this project, or ${defaultAgent} if none)`)
|
|
378
539
|
.option('--no-agent', 'Skip the agent skill install (configure credentials only)')
|
|
379
540
|
.option('--force', 'Overwrite an existing skill file (a .bak backup is kept)')
|
|
380
541
|
.option('--dir <path>', 'Project root for the skill install (default: current directory)')
|
|
@@ -382,13 +543,10 @@ export function addSetupOptions(cmd, validTargets, defaultAgent) {
|
|
|
382
543
|
.option('--skip-if-configured', 'Skip the API key prompt when credentials already exist for this profile (CI-safe idempotent re-run)');
|
|
383
544
|
}
|
|
384
545
|
/** Build {@link InitOptions} from raw Commander opts + globals. */
|
|
385
|
-
function buildSetupOptions(cmdOpts, command
|
|
546
|
+
function buildSetupOptions(cmdOpts, command) {
|
|
386
547
|
const common = resolveCommonOptions(command);
|
|
387
548
|
// Commander sets `agent: false` (boolean) when `--no-agent` is passed,
|
|
388
|
-
// because `--no-agent` is the negation of `--agent <target>`.
|
|
389
|
-
// this: if agent is falsy (false or empty string) default to the CLI default
|
|
390
|
-
// so runInstall never receives a non-string target.
|
|
391
|
-
const resolvedAgent = cmdOpts.agent && typeof cmdOpts.agent === 'string' ? cmdOpts.agent : defaultAgent;
|
|
549
|
+
// because `--no-agent` is the negation of `--agent <target>`.
|
|
392
550
|
const isNoAgent = cmdOpts.noAgent === true || cmdOpts.agent === false;
|
|
393
551
|
// Detect conflict when both --no-agent and --agent <target> appear in the raw
|
|
394
552
|
// args. Commander only populates `rawArgs` on the ROOT command passed to
|
|
@@ -402,11 +560,14 @@ function buildSetupOptions(cmdOpts, command, defaultAgent) {
|
|
|
402
560
|
const rawArgs = root.rawArgs ?? process.argv;
|
|
403
561
|
const rawArgConflict = rawArgs.some((a) => a === '--no-agent') &&
|
|
404
562
|
rawArgs.some((a) => a === '--agent' || a.startsWith('--agent='));
|
|
563
|
+
// Only a real `--agent <target>` reaches runInit. Left undefined otherwise, so
|
|
564
|
+
// setup detects instead of installing for a target nobody asked for.
|
|
565
|
+
const chosenAgent = typeof cmdOpts.agent === 'string' && cmdOpts.agent ? cmdOpts.agent : undefined;
|
|
405
566
|
return {
|
|
406
567
|
...common,
|
|
407
568
|
apiKey: cmdOpts.apiKey,
|
|
408
569
|
fromEnv: Boolean(cmdOpts.fromEnv),
|
|
409
|
-
agent:
|
|
570
|
+
agent: chosenAgent,
|
|
410
571
|
noAgent: isNoAgent,
|
|
411
572
|
force: Boolean(cmdOpts.force),
|
|
412
573
|
dir: cmdOpts.dir,
|
|
@@ -416,8 +577,8 @@ function buildSetupOptions(cmdOpts, command, defaultAgent) {
|
|
|
416
577
|
};
|
|
417
578
|
}
|
|
418
579
|
/** Shared action for `setup` and the deprecated `init` alias. */
|
|
419
|
-
async function runSetupAction(cmdOpts, command, deps
|
|
420
|
-
const opts = buildSetupOptions(cmdOpts, command
|
|
580
|
+
async function runSetupAction(cmdOpts, command, deps) {
|
|
581
|
+
const opts = buildSetupOptions(cmdOpts, command);
|
|
421
582
|
// When --yes is supplied without a key source, force isTTY=false so runInit
|
|
422
583
|
// emits exit 5 with a clear message rather than hanging on a prompt in a
|
|
423
584
|
// headless CI environment where a TTY fd happens to be open.
|
|
@@ -434,7 +595,7 @@ export function createSetupCommand(deps = {}) {
|
|
|
434
595
|
.description(SETUP_DESCRIPTION)
|
|
435
596
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
436
597
|
.action(async (cmdOpts, command) => {
|
|
437
|
-
await runSetupAction(cmdOpts, command, deps
|
|
598
|
+
await runSetupAction(cmdOpts, command, deps);
|
|
438
599
|
});
|
|
439
600
|
}
|
|
440
601
|
/**
|
|
@@ -450,7 +611,7 @@ export function createDeprecatedInitCommand(deps = {}) {
|
|
|
450
611
|
.description('(deprecated) alias for `setup`')
|
|
451
612
|
.action(async (cmdOpts, command) => {
|
|
452
613
|
emitDeprecationNotice('init', 'setup', deps.stderr);
|
|
453
|
-
await runSetupAction(cmdOpts, command, deps
|
|
614
|
+
await runSetupAction(cmdOpts, command, deps);
|
|
454
615
|
});
|
|
455
616
|
}
|
|
456
617
|
/**
|
|
@@ -466,6 +627,6 @@ export function createDeprecatedInitCommand(deps = {}) {
|
|
|
466
627
|
* `addSetupOptions` before wiring this action.
|
|
467
628
|
*/
|
|
468
629
|
export async function runConfigureViaSetup(command, deps, cmdOpts) {
|
|
469
|
-
await runSetupAction(cmdOpts, command, deps
|
|
630
|
+
await runSetupAction(cmdOpts, command, deps);
|
|
470
631
|
}
|
|
471
632
|
//# sourceMappingURL=init.js.map
|
|
@@ -42,7 +42,22 @@ export interface CliProject {
|
|
|
42
42
|
* (see the `project create --type backend` note in CLAUDE.md).
|
|
43
43
|
*/
|
|
44
44
|
targetUrl?: string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Project-level test-id attribute priority list (e.g. `['data-element',
|
|
47
|
+
* 'data-testid']`). The execution engine tries these DOM attributes, in
|
|
48
|
+
* order, before any other locator strategy when it exports test code, so
|
|
49
|
+
* customers who tag their UI with their own attribute get
|
|
50
|
+
* `page.locator('[data-element="…"]')` locators. Absent on older backends;
|
|
51
|
+
* `null`/empty means "not configured" (engine default: `data-testid`).
|
|
52
|
+
*/
|
|
53
|
+
testIdAttributes?: string[] | null;
|
|
45
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse `--test-id-attributes <list>`: a comma-separated, ordered list of DOM
|
|
57
|
+
* attribute names. Trims, drops empties and duplicates (first occurrence
|
|
58
|
+
* wins — order is the priority), rejects invalid names. Exported for tests.
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseTestIdAttributesFlag(raw: string, flagName: string): string[];
|
|
46
61
|
export interface ProjectDeps {
|
|
47
62
|
env?: NodeJS.ProcessEnv;
|
|
48
63
|
credentialsPath?: string;
|
|
@@ -72,6 +87,8 @@ export interface CliCreateProjectRequest {
|
|
|
72
87
|
username?: string;
|
|
73
88
|
password?: string;
|
|
74
89
|
instruction?: string;
|
|
90
|
+
/** Ordered test-id attribute list — see `CliProject.testIdAttributes`. */
|
|
91
|
+
testIdAttributes?: string[];
|
|
75
92
|
}
|
|
76
93
|
/**
|
|
77
94
|
* Response shape for `POST /projects`.
|
|
@@ -106,6 +123,7 @@ interface CreateOptions extends CommonOptions {
|
|
|
106
123
|
name: string;
|
|
107
124
|
targetUrl?: string;
|
|
108
125
|
description?: string;
|
|
126
|
+
testIdAttributes?: string[];
|
|
109
127
|
username?: string;
|
|
110
128
|
password?: string;
|
|
111
129
|
passwordFile?: string;
|
|
@@ -140,6 +158,9 @@ interface UpdateOptions extends CommonOptions {
|
|
|
140
158
|
password?: string;
|
|
141
159
|
passwordFile?: string;
|
|
142
160
|
instruction?: string;
|
|
161
|
+
/** Ordered test-id attribute list; `clearTestIdAttributes` sends `null` to unset. */
|
|
162
|
+
testIdAttributes?: string[];
|
|
163
|
+
clearTestIdAttributes?: boolean;
|
|
143
164
|
idempotencyKey?: string;
|
|
144
165
|
}
|
|
145
166
|
export declare function runUpdate(opts: UpdateOptions, deps?: ProjectDeps): Promise<CliUpdateProjectResponse>;
|