@testsprite/testsprite-cli 0.12.0 → 0.14.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 +59 -49
- package/dist/commands/agent.js +16 -13
- package/dist/commands/auth.d.ts +19 -0
- package/dist/commands/auth.js +60 -24
- package/dist/commands/ci.d.ts +86 -1
- package/dist/commands/ci.js +436 -5
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +34 -20
- package/dist/commands/init.js +14 -11
- package/dist/commands/project-env.d.ts +11 -1
- package/dist/commands/project-env.js +408 -70
- package/dist/commands/project-sign-in.d.ts +60 -0
- package/dist/commands/project-sign-in.js +289 -0
- package/dist/commands/project.d.ts +14 -5
- package/dist/commands/project.js +110 -70
- package/dist/commands/schedule.d.ts +14 -0
- package/dist/commands/schedule.js +193 -15
- package/dist/commands/test.d.ts +123 -44
- package/dist/commands/test.js +2993 -636
- package/dist/commands/testlist.d.ts +10 -5
- package/dist/commands/testlist.js +217 -47
- package/dist/commands/tunnel.d.ts +26 -3
- package/dist/commands/tunnel.js +221 -18
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.js +12 -5
- package/dist/index.js +39 -50
- package/dist/lib/agent-targets.d.ts +3 -3
- package/dist/lib/agent-targets.js +2 -2
- package/dist/lib/billing-refusal.d.ts +43 -0
- package/dist/lib/billing-refusal.js +171 -0
- package/dist/lib/bundle.d.ts +5 -0
- package/dist/lib/bundle.js +43 -13
- package/dist/lib/ci-linkage.d.ts +90 -0
- package/dist/lib/ci-linkage.js +181 -0
- package/dist/lib/client-factory.d.ts +16 -2
- package/dist/lib/client-factory.js +37 -6
- package/dist/lib/config.d.ts +17 -0
- package/dist/lib/config.js +20 -1
- package/dist/lib/conflict-reason.d.ts +27 -3
- package/dist/lib/conflict-reason.js +53 -4
- package/dist/lib/credentials.js +56 -14
- package/dist/lib/dry-run/samples.d.ts +13 -1
- package/dist/lib/dry-run/samples.js +104 -7
- package/dist/lib/environment-tunnel.d.ts +109 -0
- package/dist/lib/environment-tunnel.js +465 -0
- package/dist/lib/errors.d.ts +18 -11
- package/dist/lib/errors.js +123 -14
- package/dist/lib/failing-fe-resolver.d.ts +1 -1
- package/dist/lib/failing-fe-resolver.js +3 -3
- package/dist/lib/gh-output.d.ts +1 -0
- package/dist/lib/gh-output.js +16 -4
- package/dist/lib/history-retention.d.ts +8 -0
- package/dist/lib/history-retention.js +24 -0
- package/dist/lib/http.d.ts +39 -19
- package/dist/lib/http.js +46 -24
- package/dist/lib/interrupt.d.ts +21 -13
- package/dist/lib/interrupt.js +32 -21
- package/dist/lib/junit-report.d.ts +18 -4
- package/dist/lib/junit-report.js +23 -5
- package/dist/lib/local-target.d.ts +14 -4
- package/dist/lib/local-target.js +48 -13
- package/dist/lib/output.js +15 -1
- package/dist/lib/plan-poll.d.ts +11 -11
- package/dist/lib/plan-poll.js +15 -16
- package/dist/lib/plans.types.d.ts +9 -9
- package/dist/lib/plans.types.js +3 -3
- package/dist/lib/poll.d.ts +2 -2
- package/dist/lib/poll.js +9 -3
- package/dist/lib/redact.d.ts +38 -0
- package/dist/lib/redact.js +140 -0
- package/dist/lib/render-error.d.ts +21 -5
- package/dist/lib/render-error.js +44 -0
- package/dist/lib/response-schemas.d.ts +54 -12
- package/dist/lib/response-schemas.js +88 -7
- package/dist/lib/runs.types.d.ts +68 -11
- package/dist/lib/secret-file.js +72 -14
- package/dist/lib/skill-nudge.d.ts +6 -1
- package/dist/lib/skill-nudge.js +32 -5
- package/dist/lib/target-url-preflight.d.ts +6 -4
- package/dist/lib/target-url-preflight.js +64 -51
- package/dist/lib/target-url.js +11 -11
- package/dist/lib/telemetry.d.ts +10 -8
- package/dist/lib/telemetry.js +24 -17
- package/dist/lib/testlist.types.d.ts +1 -0
- package/dist/lib/ticker.d.ts +9 -0
- package/dist/lib/ticker.js +111 -4
- package/dist/lib/tunnel-session.d.ts +16 -4
- package/dist/lib/tunnel-session.js +7 -5
- package/dist/lib/tunnel.types.d.ts +12 -2
- package/dist/lib/tunnel.types.js +2 -2
- package/dist/lib/v3-advisory.js +0 -1
- package/dist/lib/wait-exit.d.ts +8 -0
- package/dist/lib/wait-exit.js +76 -4
- package/dist/lib/workspace-status.d.ts +23 -0
- package/dist/lib/workspace-status.js +15 -0
- package/dist/vendor/tunnel-client/client.d.ts +15 -8
- package/dist/vendor/tunnel-client/client.js +477 -407
- package/dist/vendor/tunnel-client/config.d.ts +5 -5
- package/dist/vendor/tunnel-client/config.js +5 -5
- package/dist/vendor/tunnel-client/index.d.ts +4 -4
- package/dist/vendor/tunnel-client/index.js +4 -4
- package/dist/vendor/tunnel-client/types.d.ts +19 -34
- package/dist/vendor/tunnel-client/types.js +1 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +13 -3
- package/dist/vendor/tunnel-client/ws-compat.js +70 -12
- package/dist/version-guard.d.ts +7 -1
- package/dist/version-guard.js +19 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/skills/testsprite-onboard.skill.md +8 -8
- package/skills/testsprite-verify.codex.md +59 -57
- package/skills/testsprite-verify.skill.md +53 -38
package/dist/commands/tunnel.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `testsprite tunnel start | status | stop
|
|
2
|
+
* `testsprite tunnel start | list | status | stop`.
|
|
3
3
|
*
|
|
4
4
|
* The out-of-band primitive under `test run --local`, which is sugar over it.
|
|
5
5
|
* Two things it buys that the sugar cannot:
|
|
@@ -20,10 +20,12 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import { Command } from 'commander';
|
|
22
22
|
import * as v from 'valibot';
|
|
23
|
+
import { resolveProfileName } from '../lib/config.js';
|
|
23
24
|
import { createHttpClientFactory, emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, resolveRequestTimeoutMs, } from '../lib/client-factory.js';
|
|
24
|
-
import { ApiError, RequestTimeoutError } from '../lib/errors.js';
|
|
25
|
+
import { ApiError, CLIError, InterruptError, RequestTimeoutError } from '../lib/errors.js';
|
|
25
26
|
import { globalShutdown } from '../lib/interrupt.js';
|
|
26
27
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
28
|
+
import { renderTextTable } from '../lib/text-table.js';
|
|
27
29
|
import { formatDataPlaneUnreachableMessage, formatDataPlaneUnreachableNextAction, openTunnelSession, } from '../lib/tunnel-session.js';
|
|
28
30
|
import { TunnelClient } from '../vendor/tunnel-client/index.js';
|
|
29
31
|
const TUNNEL_CLIENT_ID_SCHEMA = v.pipe(v.string(), v.uuid());
|
|
@@ -50,7 +52,7 @@ function makeClient(opts, deps, shutdownSignal = (deps.shutdown ?? globalShutdow
|
|
|
50
52
|
return makeHttpClient(opts, {
|
|
51
53
|
env: deps.env,
|
|
52
54
|
credentialsPath: deps.credentialsPath,
|
|
53
|
-
fetchImpl: deps.fetchImpl,
|
|
55
|
+
fetchImpl: opts.dryRun ? undefined : deps.fetchImpl,
|
|
54
56
|
stderr: deps.stderr,
|
|
55
57
|
shutdownSignal,
|
|
56
58
|
});
|
|
@@ -228,6 +230,7 @@ export async function runTunnelStart(opts, deps = {}) {
|
|
|
228
230
|
log: stderr,
|
|
229
231
|
logLevel: opts.debug ? 'debug' : opts.verbose ? 'info' : 'error',
|
|
230
232
|
...(opts.ttlSeconds !== undefined ? { ttlSeconds: opts.ttlSeconds } : {}),
|
|
233
|
+
onMinted: minted => stderr(`Minted tunnel client ${minted.clientId} (expires ${minted.expiresAt}); connecting…`),
|
|
231
234
|
onFatal: (reason, message) => {
|
|
232
235
|
fatal = true;
|
|
233
236
|
fatalReason = reason;
|
|
@@ -261,7 +264,7 @@ export async function runTunnelStart(opts, deps = {}) {
|
|
|
261
264
|
`expiresAt ${d.expiresAt}`,
|
|
262
265
|
`status online`,
|
|
263
266
|
`transport ${d.transport}`,
|
|
264
|
-
`hint Attach a run: testsprite test run <test-id> --
|
|
267
|
+
`hint Attach a run: testsprite test run <test-id> --env <name> --tunnel-client ${d.clientId}`,
|
|
265
268
|
`hint Stop it: press Ctrl-C here, or run 'testsprite tunnel stop ${d.clientId}' from another terminal`,
|
|
266
269
|
].join('\n');
|
|
267
270
|
});
|
|
@@ -363,6 +366,66 @@ function renderStatus(status) {
|
|
|
363
366
|
}
|
|
364
367
|
return lines.join('\n');
|
|
365
368
|
}
|
|
369
|
+
async function listTunnelsForAccount(opts, deps) {
|
|
370
|
+
try {
|
|
371
|
+
return await makeClient(opts, deps).listTunnels();
|
|
372
|
+
}
|
|
373
|
+
catch (err) {
|
|
374
|
+
if (err instanceof ApiError && err.httpStatus === 404) {
|
|
375
|
+
throw ApiError.fromEnvelope({
|
|
376
|
+
error: {
|
|
377
|
+
code: 'NOT_FOUND',
|
|
378
|
+
message: 'This TestSprite server cannot list tunnels yet.',
|
|
379
|
+
nextAction: 'Stop a tunnel you know the id of with `testsprite tunnel stop <client-id>`, or wait for it to expire.',
|
|
380
|
+
requestId: err.requestId,
|
|
381
|
+
details: err.details,
|
|
382
|
+
},
|
|
383
|
+
}, 404);
|
|
384
|
+
}
|
|
385
|
+
throw err;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
export async function runTunnelList(opts, deps = {}) {
|
|
389
|
+
const response = await listTunnelsForAccount(opts, deps);
|
|
390
|
+
makeOutput(opts.output, deps).print(response, data => renderTunnelList(data));
|
|
391
|
+
return response;
|
|
392
|
+
}
|
|
393
|
+
function renderTunnelList(response) {
|
|
394
|
+
if (response.tunnels.length === 0)
|
|
395
|
+
return 'No live tunnels.';
|
|
396
|
+
const columns = [
|
|
397
|
+
{
|
|
398
|
+
header: 'CLIENT ID',
|
|
399
|
+
width: (rows) => Math.max(9, ...rows.map(item => item.clientId.length)),
|
|
400
|
+
render: (item) => item.clientId,
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
header: 'STATUS',
|
|
404
|
+
width: (rows) => Math.max(6, ...rows.map(item => item.status.length)),
|
|
405
|
+
render: (item) => item.status,
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
header: 'CREATED',
|
|
409
|
+
width: (rows) => Math.max(7, ...rows.map(item => (item.createdAt ?? '-').length)),
|
|
410
|
+
render: (item) => item.createdAt ?? '-',
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
header: 'EXPIRES',
|
|
414
|
+
width: (rows) => Math.max(7, ...rows.map(item => item.expiresAt.length)),
|
|
415
|
+
render: (item) => item.expiresAt,
|
|
416
|
+
},
|
|
417
|
+
];
|
|
418
|
+
return [
|
|
419
|
+
renderTextTable(response.tunnels, columns),
|
|
420
|
+
'hint Stop one: testsprite tunnel stop <client-id>',
|
|
421
|
+
'hint Stop all of them: testsprite tunnel stop --all --confirm',
|
|
422
|
+
...(response.tunnels.some(item => item.status === 'unknown')
|
|
423
|
+
? [
|
|
424
|
+
'note "unknown" means TestSprite could not check that connection just now; the tunnel may still be up.',
|
|
425
|
+
]
|
|
426
|
+
: []),
|
|
427
|
+
].join('\n');
|
|
428
|
+
}
|
|
366
429
|
/**
|
|
367
430
|
* Destroy a binding. Idempotent by contract — deleting an unknown or
|
|
368
431
|
* already-deleted binding is a success, because the requested end state holds.
|
|
@@ -372,6 +435,109 @@ function renderStatus(status) {
|
|
|
372
435
|
* observes the revocation on its next status check and exits.
|
|
373
436
|
*/
|
|
374
437
|
export async function runTunnelStop(opts, deps = {}) {
|
|
438
|
+
if (opts.clientId !== undefined && opts.all) {
|
|
439
|
+
throw ApiError.fromEnvelope({
|
|
440
|
+
error: {
|
|
441
|
+
code: 'VALIDATION_ERROR',
|
|
442
|
+
message: 'Pass either a <client-id> or --all, not both.',
|
|
443
|
+
nextAction: 'Choose one tunnel to stop, or use --all --confirm.',
|
|
444
|
+
requestId: 'local',
|
|
445
|
+
details: { field: 'all', reason: 'mutually exclusive with clientId' },
|
|
446
|
+
},
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
if (opts.confirm && !opts.all) {
|
|
450
|
+
throw ApiError.fromEnvelope({
|
|
451
|
+
error: {
|
|
452
|
+
code: 'VALIDATION_ERROR',
|
|
453
|
+
message: '--confirm only applies with --all.',
|
|
454
|
+
nextAction: 'Remove --confirm, or use --all --confirm.',
|
|
455
|
+
requestId: 'local',
|
|
456
|
+
details: { field: 'confirm', reason: 'requires --all' },
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
if (opts.clientId === undefined && !opts.all) {
|
|
461
|
+
throw ApiError.fromEnvelope({
|
|
462
|
+
error: {
|
|
463
|
+
code: 'VALIDATION_ERROR',
|
|
464
|
+
message: 'provide a <client-id>, or use --all --confirm to stop every tunnel on this account',
|
|
465
|
+
nextAction: 'Run testsprite tunnel list to see your tunnel client ids.',
|
|
466
|
+
requestId: 'local',
|
|
467
|
+
details: { field: 'clientId', reason: 'required unless --all is set' },
|
|
468
|
+
},
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
if (opts.all) {
|
|
472
|
+
if (!opts.confirm && !opts.dryRun) {
|
|
473
|
+
throw ApiError.fromEnvelope({
|
|
474
|
+
error: {
|
|
475
|
+
code: 'VALIDATION_ERROR',
|
|
476
|
+
message: 'Refusing to stop every tunnel without --confirm.',
|
|
477
|
+
nextAction: 'This revokes every live tunnel on this account, including ones another terminal or a CI job is using — their runs lose their route to your machine. Re-run with --confirm. To see what would be stopped: testsprite tunnel list.',
|
|
478
|
+
requestId: 'local',
|
|
479
|
+
details: { field: 'confirm', reason: 'required for destructive operation' },
|
|
480
|
+
},
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
if (opts.dryRun) {
|
|
484
|
+
stderrOf(deps)("[dry-run] WARNING: the preview below uses sample data and does NOT reflect the real tunnels on this account. Run 'testsprite tunnel list' to see them.");
|
|
485
|
+
}
|
|
486
|
+
const response = await listTunnelsForAccount(opts, deps);
|
|
487
|
+
const out = makeOutput(opts.output, deps);
|
|
488
|
+
if (opts.dryRun) {
|
|
489
|
+
const requests = response.tunnels.map(item => ({
|
|
490
|
+
method: 'DELETE',
|
|
491
|
+
path: `/api/cli/v1/tunnel/${item.clientId}`,
|
|
492
|
+
}));
|
|
493
|
+
out.print({ requests }, () => requests.map(item => `${item.method} ${item.path}`).join('\n'));
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if (response.tunnels.length === 0) {
|
|
497
|
+
out.print({ results: [], summary: { total: 0, stopped: 0, failed: 0 } }, () => 'No live tunnels — nothing to stop.');
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
const client = makeClient(opts, deps);
|
|
501
|
+
const results = [];
|
|
502
|
+
for (const item of response.tunnels) {
|
|
503
|
+
try {
|
|
504
|
+
// Sequential and one id at a time, with the HTTP layer's normal retries:
|
|
505
|
+
// the delete is idempotent, so a transient failure is worth retrying.
|
|
506
|
+
await client.deleteTunnel(item.clientId);
|
|
507
|
+
results.push({ clientId: item.clientId, stopped: true });
|
|
508
|
+
}
|
|
509
|
+
catch (err) {
|
|
510
|
+
if (err instanceof InterruptError)
|
|
511
|
+
throw err;
|
|
512
|
+
const failure = err instanceof CLIError ? err : new CLIError(String(err), 1);
|
|
513
|
+
results.push({
|
|
514
|
+
clientId: item.clientId,
|
|
515
|
+
stopped: false,
|
|
516
|
+
error: {
|
|
517
|
+
code: failure.code,
|
|
518
|
+
message: failure.message,
|
|
519
|
+
exitCode: failure.exitCode,
|
|
520
|
+
},
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const stopped = results.filter(result => result.stopped).length;
|
|
525
|
+
const bulk = {
|
|
526
|
+
results,
|
|
527
|
+
summary: { total: results.length, stopped, failed: results.length - stopped },
|
|
528
|
+
};
|
|
529
|
+
out.print(bulk, () => [
|
|
530
|
+
...results.map(result => result.stopped
|
|
531
|
+
? `stopped ${result.clientId}`
|
|
532
|
+
: `failed ${result.clientId} ${result.error?.message}`),
|
|
533
|
+
`Stopped ${stopped} of ${results.length} tunnels.`,
|
|
534
|
+
'hint A running `tunnel start` notices a revoked credential within ~15 s and exits.',
|
|
535
|
+
].join('\n'));
|
|
536
|
+
if (bulk.summary.failed > 0) {
|
|
537
|
+
throw new CLIError(`${bulk.summary.failed} tunnel stop${bulk.summary.failed === 1 ? '' : 's'} failed. See results for details.`, 1);
|
|
538
|
+
}
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
375
541
|
assertTunnelClientId(opts.clientId);
|
|
376
542
|
const out = makeOutput(opts.output, deps);
|
|
377
543
|
if (opts.dryRun) {
|
|
@@ -385,17 +551,19 @@ export async function runTunnelStop(opts, deps = {}) {
|
|
|
385
551
|
export function createTunnelCommand(deps = {}) {
|
|
386
552
|
const tunnel = new Command('tunnel')
|
|
387
553
|
.description('Open a tunnel so TestSprite can reach an app on this machine')
|
|
388
|
-
.addHelpText('after', '\
|
|
389
|
-
'
|
|
554
|
+
.addHelpText('after', '\nFrontend runs automatically open and close a tunnel when the selected environment URL\n' +
|
|
555
|
+
'is on this machine. Use these commands when you want one tunnel to serve several runs, or to check on\n' +
|
|
390
556
|
'one that a run reported as down.\n' +
|
|
391
557
|
'\nA tunnel lives only as long as `tunnel start` is running — there is no background\n' +
|
|
392
558
|
'daemon, because the credential that authorises an inbound network path into this machine\n' +
|
|
393
559
|
'is never written to disk.\n' +
|
|
394
560
|
'\nExamples:\n' +
|
|
395
561
|
' testsprite tunnel start # hold a tunnel open (Ctrl-C to stop)\n' +
|
|
396
|
-
' testsprite test run <id> --
|
|
562
|
+
' testsprite test run <id> --env <name> --tunnel-client <id>\n' +
|
|
563
|
+
' testsprite tunnel list\n' +
|
|
397
564
|
' testsprite tunnel status <id>\n' +
|
|
398
|
-
' testsprite tunnel stop <id>\n'
|
|
565
|
+
' testsprite tunnel stop <id>\n' +
|
|
566
|
+
' testsprite tunnel stop --all --confirm\n');
|
|
399
567
|
tunnel
|
|
400
568
|
.command('start')
|
|
401
569
|
// One-line description: Commander prints it in the parent's command list,
|
|
@@ -405,7 +573,11 @@ export function createTunnelCommand(deps = {}) {
|
|
|
405
573
|
.option('--ttl <seconds>', 'requested lifetime of the tunnel credential (60–28800). The server clamps this, and the ' +
|
|
406
574
|
'credential is deleted when the command exits regardless — the lifetime only matters if ' +
|
|
407
575
|
'this process is killed without cleaning up.')
|
|
408
|
-
.addHelpText('after', '\nPrints the client id to
|
|
576
|
+
.addHelpText('after', '\nPrints the client id to stderr as soon as it is minted, before connecting; pass it\n' +
|
|
577
|
+
'to `test run <id> --env <name> --tunnel-client <id>` for an environment on this machine.\n' +
|
|
578
|
+
'Frontend runs normally open their own tunnel automatically for a loopback environment URL.\n' +
|
|
579
|
+
'\nDev servers can take a minute per page through the tunnel. For a heavy dev server,\n' +
|
|
580
|
+
"test a built server: `npm run build`, then your framework's preview/start command.\n" +
|
|
409
581
|
'\nExit codes:\n' +
|
|
410
582
|
' 0 you stopped it (Ctrl-C is the normal way to end this command)\n' +
|
|
411
583
|
' 3 auth error — the key needs the `run:tunnel` scope; mint a new key\n' +
|
|
@@ -415,38 +587,69 @@ export function createTunnelCommand(deps = {}) {
|
|
|
415
587
|
.action(async (cmdOpts, command) => {
|
|
416
588
|
const ttlSeconds = parseTtl(cmdOpts.ttl);
|
|
417
589
|
await runTunnelStart({
|
|
418
|
-
...resolveCommonOptions(command),
|
|
590
|
+
...resolveCommonOptions(command, deps.env),
|
|
419
591
|
...(ttlSeconds !== undefined ? { ttlSeconds } : {}),
|
|
420
592
|
}, deps);
|
|
421
593
|
});
|
|
594
|
+
tunnel
|
|
595
|
+
.command('list')
|
|
596
|
+
.description('List live tunnel bindings for this account')
|
|
597
|
+
.addHelpText('after', '\nShows each tunnel client id, connection status, creation time and expiry.\n' +
|
|
598
|
+
'Includes tunnels automatically opened for environments on this machine.\n' +
|
|
599
|
+
'\nExit codes:\n' +
|
|
600
|
+
' 0 listed (possibly empty)\n' +
|
|
601
|
+
' 3 auth error — the key needs the `run:tunnel` scope\n' +
|
|
602
|
+
' 4 server too old to list tunnels\n' +
|
|
603
|
+
' 10 could not reach TestSprite\n')
|
|
604
|
+
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
605
|
+
.action(async (_cmdOpts, command) => {
|
|
606
|
+
await runTunnelList(resolveCommonOptions(command, deps.env), deps);
|
|
607
|
+
});
|
|
422
608
|
tunnel
|
|
423
609
|
.command('status <client-id>')
|
|
424
610
|
.description('Report whether a tunnel client of yours is connected')
|
|
425
611
|
.addHelpText('after', '\n`offline` means the API answered and said nothing is connected with that id. A failure\n' +
|
|
426
612
|
'to reach TestSprite is reported as its own error, never as `offline`.\n' +
|
|
613
|
+
'Use the client id printed by a run that automatically opened a tunnel.\n' +
|
|
427
614
|
'\nExit codes:\n' +
|
|
428
615
|
' 0 answered (the answer may be `offline`)\n' +
|
|
429
616
|
' 4 no such tunnel for this account\n' +
|
|
430
617
|
' 10 could not reach TestSprite to ask\n')
|
|
431
618
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
432
619
|
.action(async (clientId, _cmdOpts, command) => {
|
|
433
|
-
await runTunnelStatus({ ...resolveCommonOptions(command), clientId }, deps);
|
|
620
|
+
await runTunnelStatus({ ...resolveCommonOptions(command, deps.env), clientId }, deps);
|
|
434
621
|
});
|
|
435
622
|
tunnel
|
|
436
|
-
.command('stop
|
|
437
|
-
.description('Destroy
|
|
623
|
+
.command('stop [client-id]')
|
|
624
|
+
.description('Destroy one tunnel credential or stop every live tunnel')
|
|
625
|
+
.option('--all', 'stop every live tunnel on this account', false)
|
|
626
|
+
.option('--confirm', 'required with --all for this destructive operation', false)
|
|
438
627
|
.addHelpText('after', '\nStopping one that is already gone succeeds. Revoking the credential\n' +
|
|
439
|
-
'also makes a running `tunnel start` exit within ~15 s.\n'
|
|
628
|
+
'also makes a running `tunnel start` exit within ~15 s.\n' +
|
|
629
|
+
'A run that automatically opened this tunnel loses access to its environment when you stop it.\n' +
|
|
630
|
+
'Stopping all requires --confirm; --dry-run previews sample ids without it.\n' +
|
|
631
|
+
'\nExit codes:\n' +
|
|
632
|
+
' 0 stopped (or already absent), including an empty --all result\n' +
|
|
633
|
+
' 1 at least one tunnel could not be stopped\n' +
|
|
634
|
+
' 3 auth error — the key needs the `run:tunnel` scope\n' +
|
|
635
|
+
' 4 server too old to list tunnels (with --all)\n' +
|
|
636
|
+
' 5 invalid arguments or --all without --confirm\n' +
|
|
637
|
+
' 10 could not reach TestSprite\n')
|
|
440
638
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
441
|
-
.action(async (clientId,
|
|
442
|
-
await runTunnelStop({
|
|
639
|
+
.action(async (clientId, cmdOpts, command) => {
|
|
640
|
+
await runTunnelStop({
|
|
641
|
+
...resolveCommonOptions(command, deps.env),
|
|
642
|
+
clientId,
|
|
643
|
+
all: cmdOpts.all,
|
|
644
|
+
confirm: cmdOpts.confirm,
|
|
645
|
+
}, deps);
|
|
443
646
|
});
|
|
444
647
|
return tunnel;
|
|
445
648
|
}
|
|
446
|
-
function resolveCommonOptions(command) {
|
|
649
|
+
function resolveCommonOptions(command, env) {
|
|
447
650
|
const globals = command.optsWithGlobals();
|
|
448
651
|
return {
|
|
449
|
-
profile: globals.profile
|
|
652
|
+
profile: resolveProfileName(globals.profile, env),
|
|
450
653
|
output: resolveOutputMode(globals.output),
|
|
451
654
|
endpointUrl: globals.endpointUrl,
|
|
452
655
|
debug: globals.debug ?? false,
|
package/dist/commands/usage.d.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* has no server-side source at all today).
|
|
12
12
|
*/
|
|
13
13
|
import { Command } from 'commander';
|
|
14
|
+
import { type WorkspaceStatus } from '../lib/workspace-status.js';
|
|
14
15
|
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
15
16
|
import type { FetchImpl } from '../lib/http.js';
|
|
16
17
|
import type { CliOrgBinding, CliOrgSummary } from '../lib/org-render.js';
|
|
@@ -80,6 +81,8 @@ export interface ActiveOrg {
|
|
|
80
81
|
/** Monthly per-seat credit allowance for the org's plan. */
|
|
81
82
|
includedCredits: number;
|
|
82
83
|
seats: number;
|
|
84
|
+
/** Billing standing (paused / pending / ok). Absent on an older backend. */
|
|
85
|
+
workspace?: WorkspaceStatus;
|
|
83
86
|
}
|
|
84
87
|
export interface UsageDeps {
|
|
85
88
|
env?: NodeJS.ProcessEnv;
|
package/dist/commands/usage.js
CHANGED
|
@@ -11,11 +11,13 @@
|
|
|
11
11
|
* has no server-side source at all today).
|
|
12
12
|
*/
|
|
13
13
|
import { Command } from 'commander';
|
|
14
|
+
import { formatWorkspaceStatus } from '../lib/workspace-status.js';
|
|
14
15
|
import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
15
|
-
import { loadConfig } from '../lib/config.js';
|
|
16
|
+
import { loadConfig, resolveProfileName } from '../lib/config.js';
|
|
16
17
|
import { resolvePortalBase } from '../lib/facade.js';
|
|
17
18
|
import { formatOrgBinding, formatOrgsSummary } from '../lib/org-render.js';
|
|
18
19
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
20
|
+
import { USAGE_RESPONSE_SCHEMA } from '../lib/response-schemas.js';
|
|
19
21
|
/** Dry-run canned response — matches what the real /me + User lookup would return. */
|
|
20
22
|
export const DRY_RUN_USAGE_SAMPLE = {
|
|
21
23
|
userId: '11111111-1111-4111-8111-111111111111',
|
|
@@ -72,7 +74,7 @@ export async function runUsage(opts, deps = {}) {
|
|
|
72
74
|
// /me is the only available source of credits/plan today. If the backend
|
|
73
75
|
// adds a dedicated /usage endpoint later, this single get call is where
|
|
74
76
|
// it would be swapped in — no other code change needed in the CLI.
|
|
75
|
-
const me = await client.get('/me');
|
|
77
|
+
const me = await client.get('/me', { schema: USAGE_RESPONSE_SCHEMA });
|
|
76
78
|
out.print(me, data => renderUsage(data, portalBase));
|
|
77
79
|
// In text mode, emit a note when NO balance was shown at all — neither the
|
|
78
80
|
// legacy per-user `credits` nor an org wallet. A V3-routed org account can
|
|
@@ -146,6 +148,11 @@ function renderUsage(u, portalBase) {
|
|
|
146
148
|
lines.push('--- organization ---');
|
|
147
149
|
lines.push(`org: ${org.name} (${org.role})`);
|
|
148
150
|
lines.push(`plan: ${org.plan}`);
|
|
151
|
+
// A paused workspace cannot spend this balance at all; a payment-pending
|
|
152
|
+
// one keeps spending but gets no refill. Both are worth a line here.
|
|
153
|
+
const standing = formatWorkspaceStatus(org.workspace);
|
|
154
|
+
if (standing)
|
|
155
|
+
lines.push(`state: ${standing}`);
|
|
149
156
|
// Labeled `balance:` (not `credits:`) — `--output json` exposes the
|
|
150
157
|
// legacy per-user number under `.credits`, and giving the org wallet the
|
|
151
158
|
// same label in text mode would make one word mean two different values.
|
|
@@ -250,14 +257,14 @@ export function createUsageCommand(deps = {}) {
|
|
|
250
257
|
' organization billing settings (ask an org admin) if this key is\n' +
|
|
251
258
|
' organization-bound.')
|
|
252
259
|
.action(async (_cmdOpts, command) => {
|
|
253
|
-
await runUsage(resolveCommonOptions(command), deps);
|
|
260
|
+
await runUsage(resolveCommonOptions(command, deps.env), deps);
|
|
254
261
|
});
|
|
255
262
|
return cmd;
|
|
256
263
|
}
|
|
257
|
-
function resolveCommonOptions(command) {
|
|
264
|
+
function resolveCommonOptions(command, env) {
|
|
258
265
|
const globals = command.optsWithGlobals();
|
|
259
266
|
return {
|
|
260
|
-
profile: globals.profile
|
|
267
|
+
profile: resolveProfileName(globals.profile, env),
|
|
261
268
|
output: resolveOutputMode(globals.output),
|
|
262
269
|
endpointUrl: globals.endpointUrl,
|
|
263
270
|
debug: globals.debug ?? false,
|
package/dist/index.js
CHANGED
|
@@ -12,23 +12,23 @@ import { createTunnelCommand } from './commands/tunnel.js';
|
|
|
12
12
|
import { createTestCommand } from './commands/test.js';
|
|
13
13
|
import { createTestListCommand } from './commands/testlist.js';
|
|
14
14
|
import { createUsageCommand } from './commands/usage.js';
|
|
15
|
+
import { resolveProfileName } from './lib/config.js';
|
|
16
|
+
import { classifyBillingRefusal } from './lib/billing-refusal.js';
|
|
15
17
|
import { TARGETS } from './lib/agent-targets.js';
|
|
16
18
|
import { ApiError, CLIError, InterruptError, RequestTimeoutError, extractNodeErrorCode, } from './lib/errors.js';
|
|
17
|
-
import { installBrokenPipeGuard, installSignalHandlers } from './lib/interrupt.js';
|
|
19
|
+
import { armInterruptExitBackstop, installBrokenPipeGuard, installSignalHandlers, } from './lib/interrupt.js';
|
|
18
20
|
import { Output, isOutputMode } from './lib/output.js';
|
|
19
21
|
import { maybeInstallProxyAgent } from './lib/proxy.js';
|
|
20
|
-
import {
|
|
22
|
+
import { redactDeep } from './lib/redact.js';
|
|
23
|
+
import { buildInterruptEnvelope, renderAmbiguousOrgCandidates, renderTunnelBindingLimitIds, renderCommanderError, rephraseUnknownOption, } from './lib/render-error.js';
|
|
21
24
|
import { isPlanTemplateInvocation, maybeEmitSkillNudge } from './lib/skill-nudge.js';
|
|
22
|
-
import { classifyCliError, isTelemetryOptedOut, recordOutcome, resolveTelemetryAuth, } from './lib/telemetry.js';
|
|
25
|
+
import { classifyCliError, isTelemetryOptedOut, recordOutcome, recordTelemetryExtras, resolveTelemetryAuth, } from './lib/telemetry.js';
|
|
23
26
|
import { maybeNotifyUpdate } from './lib/update-check.js';
|
|
24
27
|
import { VERSION } from './version.js';
|
|
25
|
-
import {
|
|
28
|
+
import { rejectUnsupportedNodeVersion } from './version-guard.js';
|
|
26
29
|
// Guard: exit early with a clear message on unsupported Node.js versions,
|
|
27
30
|
// rather than failing later with a cryptic ESM/runtime error.
|
|
28
|
-
|
|
29
|
-
process.stderr.write(`Error: testsprite requires Node.js ${SUPPORTED_NODE_RANGE} (found ${process.versions.node}).\nInstall a supported Node.js release from https://nodejs.org\n`);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
31
|
+
rejectUnsupportedNodeVersion(process.versions.node);
|
|
32
32
|
const program = new Command();
|
|
33
33
|
// exitOverride() causes Commander to throw CommanderError instead of calling
|
|
34
34
|
// process.exit() directly, giving our catch block a chance to remap error
|
|
@@ -120,12 +120,6 @@ let telemetryEmit = false;
|
|
|
120
120
|
// Auth resolved in the preAction hook, before the command's action runs, so
|
|
121
121
|
// `auth remove` (which deletes the profile) is still reported on the key it used.
|
|
122
122
|
let telemetryAuth;
|
|
123
|
-
// True when the leaf command that is about to run carries a `--local` option
|
|
124
|
-
// value — `test run --local <port>` or `project create --local <port>`.
|
|
125
|
-
// Set before validation so test-run refusals still report attempts that a
|
|
126
|
-
// backend-side mint/attach event never observes. Local project admission
|
|
127
|
-
// failures have a separate zero-HTTP exception below.
|
|
128
|
-
let telemetryLocal = false;
|
|
129
123
|
// Local project admission failures must exit without any TestSprite HTTP,
|
|
130
124
|
// including telemetry. Track companion flags even when --local is missing.
|
|
131
125
|
let telemetryLocalProject = false;
|
|
@@ -206,9 +200,10 @@ program.hook('preAction', (_thisCommand, actionCommand) => {
|
|
|
206
200
|
const commandPath = commandPathOf(actionCommand);
|
|
207
201
|
// Record which leaf command ran, for the telemetry emit around parseAsync.
|
|
208
202
|
ranCommandPath = commandPath;
|
|
209
|
-
//
|
|
210
|
-
//
|
|
211
|
-
|
|
203
|
+
// Preserve explicit --local attempts, including refusals and borrowed tunnels;
|
|
204
|
+
// only flag presence is recorded. Automatic tunnel paths record the same fact.
|
|
205
|
+
if (globals.local !== undefined)
|
|
206
|
+
recordTelemetryExtras({ local: true });
|
|
212
207
|
telemetryLocalProject =
|
|
213
208
|
commandPath === 'project create' &&
|
|
214
209
|
(globals.local !== undefined || globals.localHost !== undefined);
|
|
@@ -231,9 +226,10 @@ program.hook('preAction', (_thisCommand, actionCommand) => {
|
|
|
231
226
|
commandPath,
|
|
232
227
|
output: isOutputMode(globals.output) ? globals.output : 'text',
|
|
233
228
|
dryRun: globals.dryRun ?? false,
|
|
234
|
-
profile: globals.profile
|
|
229
|
+
profile: resolveProfileName(globals.profile),
|
|
235
230
|
cwd: process.cwd(),
|
|
236
231
|
env: process.env,
|
|
232
|
+
debug: globals.debug ?? false,
|
|
237
233
|
});
|
|
238
234
|
}
|
|
239
235
|
// Best-effort update notice (see lib/update-check.ts): self-gates on the
|
|
@@ -251,12 +247,12 @@ program.hook('preAction', (_thisCommand, actionCommand) => {
|
|
|
251
247
|
void maybeNotifyUpdate();
|
|
252
248
|
}
|
|
253
249
|
});
|
|
254
|
-
// Clean process lifecycle (
|
|
250
|
+
// Clean process lifecycle (errors.md §8.1): during a `--wait`
|
|
255
251
|
// poll the scope is armed — the first SIGINT/SIGTERM/SIGHUP aborts gracefully
|
|
256
252
|
// and the wait path prints an honest partial (the run KEEPS executing and
|
|
257
253
|
// billing server-side) + re-attach hint before exiting 128+signum; a second
|
|
258
|
-
// signal hard-exits. Outside an armed scope: a clear one-line message
|
|
259
|
-
//
|
|
254
|
+
// signal hard-exits. Outside an armed scope: a clear one-line message, then
|
|
255
|
+
// drain an in-flight request or exit immediately when idle. Plus an EPIPE guard
|
|
260
256
|
// so piping to a reader that closes early (`| head`) exits cleanly instead of
|
|
261
257
|
// dumping a raw `write EPIPE` stack.
|
|
262
258
|
installSignalHandlers();
|
|
@@ -277,7 +273,6 @@ try {
|
|
|
277
273
|
exitCode: 0,
|
|
278
274
|
durationMs: Date.now() - telemetryStartedAt,
|
|
279
275
|
...telemetryGlobals(),
|
|
280
|
-
local: telemetryLocal,
|
|
281
276
|
}, { resolvedAuth: telemetryAuth });
|
|
282
277
|
}
|
|
283
278
|
}
|
|
@@ -292,7 +287,7 @@ catch (err) {
|
|
|
292
287
|
// user's error. The classification mirrors the exit-code mapping the
|
|
293
288
|
// branches apply.
|
|
294
289
|
//
|
|
295
|
-
//
|
|
290
|
+
// SET `process.exitCode` and let the event loop drain instead of
|
|
296
291
|
// forcing `process.exit()`. A forced exit tears the process down while the
|
|
297
292
|
// just-completed HTTPS request's TLS socket is still mid-close; on Windows
|
|
298
293
|
// libuv asserts on the half-closed handle (src/win/async.c) and the process
|
|
@@ -312,7 +307,6 @@ catch (err) {
|
|
|
312
307
|
...waitTimeoutTelemetry,
|
|
313
308
|
durationMs: Date.now() - telemetryStartedAt,
|
|
314
309
|
...telemetryGlobals(),
|
|
315
|
-
local: telemetryLocal,
|
|
316
310
|
}, { resolvedAuth: telemetryAuth });
|
|
317
311
|
}
|
|
318
312
|
process.exitCode = code;
|
|
@@ -321,6 +315,7 @@ catch (err) {
|
|
|
321
315
|
const mode = isOutputMode(rawMode) ? rawMode : 'text';
|
|
322
316
|
const output = new Output(mode);
|
|
323
317
|
if (err instanceof ApiError) {
|
|
318
|
+
const billingRefusal = classifyBillingRefusal(err);
|
|
324
319
|
const message = err.code === 'UNSUPPORTED' &&
|
|
325
320
|
err.getDetail('reason') === 'tunnel-unsupported-for-backend-test'
|
|
326
321
|
? '--local only supports frontend tests today. Re-run without --local, or point the test at a reachable base URL.'
|
|
@@ -332,7 +327,11 @@ catch (err) {
|
|
|
332
327
|
message,
|
|
333
328
|
nextAction: err.nextAction,
|
|
334
329
|
requestId: err.requestId,
|
|
335
|
-
|
|
330
|
+
// `err.details` is already redacted at ApiError construction (see
|
|
331
|
+
// `errors.ts`); redacting again here is defence in depth for this
|
|
332
|
+
// hand-built envelope specifically, independent of that.
|
|
333
|
+
details: redactDeep(err.details),
|
|
334
|
+
...(billingRefusal ? { links: billingRefusal.links } : {}),
|
|
336
335
|
},
|
|
337
336
|
};
|
|
338
337
|
process.stderr.write(`${JSON.stringify(envelope, null, 2)}\n`);
|
|
@@ -341,6 +340,10 @@ catch (err) {
|
|
|
341
340
|
process.stderr.write(`Error: ${message}\n`);
|
|
342
341
|
if (err.nextAction)
|
|
343
342
|
process.stderr.write(`${err.nextAction}\n`);
|
|
343
|
+
if (billingRefusal) {
|
|
344
|
+
for (const line of billingRefusal.lines)
|
|
345
|
+
process.stderr.write(`${line}\n`);
|
|
346
|
+
}
|
|
344
347
|
if (err.requestId && err.requestId !== 'local')
|
|
345
348
|
process.stderr.write(`requestId: ${err.requestId}\n`);
|
|
346
349
|
// C1: surface requiredScopes / grantedScopes on AUTH_FORBIDDEN
|
|
@@ -372,40 +375,26 @@ catch (err) {
|
|
|
372
375
|
process.stderr.write(`${line}\n`);
|
|
373
376
|
}
|
|
374
377
|
}
|
|
378
|
+
if (err.code === 'RATE_LIMITED' && err.getDetail('reason') === 'tunnel_binding_limit') {
|
|
379
|
+
for (const line of renderTunnelBindingLimitIds(err.getDetail('clientIds'))) {
|
|
380
|
+
process.stderr.write(`${line}\n`);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
375
383
|
}
|
|
376
384
|
await flushThenSetExitCode(err.exitCode);
|
|
377
385
|
}
|
|
378
386
|
else if (err instanceof InterruptError) {
|
|
379
|
-
//
|
|
380
|
-
//
|
|
381
|
-
// the conventional 128+signum code
|
|
382
|
-
// the error catalog. Note: Ctrl-C does NOT cancel the server-side run.
|
|
387
|
+
// A run wait may already have printed a partial result and re-attach hint.
|
|
388
|
+
// A disarmed request has no run ID, so its JSON hint describes checking
|
|
389
|
+
// current state before retrying. Both use the conventional 128+signum code.
|
|
383
390
|
if (mode === 'json') {
|
|
384
|
-
|
|
385
|
-
.tunnelDetach;
|
|
386
|
-
const envelope = {
|
|
387
|
-
error: {
|
|
388
|
-
code: 'INTERRUPTED',
|
|
389
|
-
message: err.message,
|
|
390
|
-
nextAction: tunnelDetach?.nextAction ??
|
|
391
|
-
'The server-side run (if any) keeps executing and billing. ' +
|
|
392
|
-
'Re-attach with: testsprite test wait <runId>, or stop it with: testsprite test cancel <runId> ' +
|
|
393
|
-
'(runId is in the partial JSON on stdout).',
|
|
394
|
-
requestId: 'local',
|
|
395
|
-
details: {
|
|
396
|
-
signal: err.signal,
|
|
397
|
-
...(tunnelDetach
|
|
398
|
-
? { runId: tunnelDetach.runId, cancelOutcome: tunnelDetach.cancel }
|
|
399
|
-
: {}),
|
|
400
|
-
},
|
|
401
|
-
},
|
|
402
|
-
};
|
|
403
|
-
process.stderr.write(`${JSON.stringify(envelope, null, 2)}\n`);
|
|
391
|
+
process.stderr.write(`${JSON.stringify(buildInterruptEnvelope(err), null, 2)}\n`);
|
|
404
392
|
}
|
|
405
393
|
else {
|
|
406
394
|
process.stderr.write(`Error: ${err.message}\n`);
|
|
407
395
|
}
|
|
408
396
|
await flushThenSetExitCode(err.exitCode);
|
|
397
|
+
armInterruptExitBackstop(err.exitCode);
|
|
409
398
|
}
|
|
410
399
|
else if (err instanceof RequestTimeoutError) {
|
|
411
400
|
// Structured rendering for per-request timeouts: JSON mode emits a
|
|
@@ -441,7 +430,7 @@ catch (err) {
|
|
|
441
430
|
// help`, `help test`, etc.)
|
|
442
431
|
// Both are user-initiated "show me help" requests and must exit 0 per the
|
|
443
432
|
// AWS-CLI convention. Failing to map 'commander.help' caused these paths
|
|
444
|
-
// to fall through to the generic `process.exit(5)` branch
|
|
433
|
+
// to fall through to the generic `process.exit(5)` branch.
|
|
445
434
|
if (err.code === 'commander.helpDisplayed' ||
|
|
446
435
|
err.code === 'commander.help' ||
|
|
447
436
|
err.code === 'commander.version') {
|
|
@@ -21,7 +21,7 @@ export interface TargetSpec {
|
|
|
21
21
|
* truncated beyond) and `copilot` (no cap, but `applyTo: '**'` injects it into
|
|
22
22
|
* every request, so context cost is the constraint).
|
|
23
23
|
*
|
|
24
|
-
* Read it via {@link ownFileBodyFor}, never by testing target names
|
|
24
|
+
* Read it via {@link ownFileBodyFor}, never by testing target names.
|
|
25
25
|
*/
|
|
26
26
|
compactBody?: boolean;
|
|
27
27
|
/**
|
|
@@ -153,8 +153,8 @@ export declare function compactBodyFor(skill: string, read?: ReadFn): string;
|
|
|
153
153
|
/**
|
|
154
154
|
* The canonical own-file body for a (target, skill) pair, and therefore the body
|
|
155
155
|
* the install marker's hash covers. Every producer AND consumer of an own-file
|
|
156
|
-
* body must resolve through here —
|
|
157
|
-
*
|
|
156
|
+
* body must resolve through here — keeping separate copies of this rule is
|
|
157
|
+
* what lets install and status disagree on the same file.
|
|
158
158
|
*/
|
|
159
159
|
export declare function ownFileBodyFor(target: AgentTarget, skill: string, read?: ReadFn): string;
|
|
160
160
|
/**
|
|
@@ -287,8 +287,8 @@ export function compactBodyFor(skill, read = defaultRead) {
|
|
|
287
287
|
/**
|
|
288
288
|
* The canonical own-file body for a (target, skill) pair, and therefore the body
|
|
289
289
|
* the install marker's hash covers. Every producer AND consumer of an own-file
|
|
290
|
-
* body must resolve through here —
|
|
291
|
-
*
|
|
290
|
+
* body must resolve through here — keeping separate copies of this rule is
|
|
291
|
+
* what lets install and status disagree on the same file.
|
|
292
292
|
*/
|
|
293
293
|
export function ownFileBodyFor(target, skill, read = defaultRead) {
|
|
294
294
|
return TARGETS[target].compactBody ? compactBodyFor(skill, read) : loadSkillBodyFor(skill, read);
|