feat(cli)!: default the scan target and add a JSON error contract

List local scans, resolve the active or most recent workspace automatically, and make logs, status, and stop use one canonical scan identity.

Add stable machine-readable failures, richer status output, explicit help errors, and seven-day Temporal retention. Treat absent Temporal pending-activity failures as absent whether the decoder represents them as `null` or missing.

BREAKING CHANGE: `status --json` now returns a fixed `failureMessage`. Read `partialReasons`, `agenticSast`, and `workflow.log` for diagnostic detail.
This commit is contained in:
ajmallesh
2026-08-26 20:00:11 -07:00
parent 3bdcfac85d
commit 242f85f158
13 changed files with 651 additions and 146 deletions
+24 -5
View File
@@ -20,6 +20,7 @@ import {
import { fail, failUsage, warn } from '../errors.js';
import { commandPrefix } from '../mode.js';
import { resolveWorkflowId } from '../session.js';
import { resolveDefaultWorkspace } from '../workspaces.js';
export interface StopOptions {
all: boolean;
@@ -108,6 +109,24 @@ async function stopAllScans(yes: boolean): Promise<void> {
}
}
/**
* Infer which scan `stop` acts on when neither a workspace nor --all was given: the single
* running scan, announced on stderr so it is never a silent guess. Zero or several running
* scans exit with guidance — there is no most-recent fallback, since stopping a finished
* scan is a no-op.
*/
function resolveStopTarget(): string {
const target = resolveDefaultWorkspace({ allowFinished: false });
if (target.kind === 'ok') {
console.error(`No workspace given; stopping running scan "${target.workspace}".`);
return target.workspace;
}
if (target.kind === 'ambiguous') {
failUsage('Multiple scans are running — specify which one, or use --all:', ` ${target.running.join(', ')}`);
}
fail('No running scans to stop.', 'Pass a workspace name to stop a specific scan.');
}
export async function stop(opts: StopOptions): Promise<void> {
ensureDocker();
@@ -115,12 +134,12 @@ export async function stop(opts: StopOptions): Promise<void> {
if (opts.all && opts.workspace) {
failUsage('Pass a workspace name or --all, not both.');
}
if (!opts.all && !opts.workspace) {
failUsage('Specify which scan to stop: `stop <workspace>`, or `stop --all` to stop every scan.');
}
if (opts.workspace) {
await stopSingleScan(opts.workspace, opts.yes);
// With no explicit target and no --all, default to the single running scan.
const workspace = opts.all ? undefined : (opts.workspace ?? resolveStopTarget());
if (workspace) {
await stopSingleScan(workspace, opts.yes);
} else {
await stopAllScans(opts.yes);
}