Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/commands/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,28 @@ describe('createAgentCommand wiring', () => {
expect(out).toContain('claude');
expect(out).toContain('antigravity');
});

it('agent list rejects unsupported global --output modes', async () => {
const { deps } = makeCapture();

const command = createAgentCommand({ cwd: CWD, ...deps });
const parent = new (await import('commander')).Command('testsprite');
parent.option('--output <mode>', 'output', 'text');
parent.option('--profile <name>', 'profile', 'default');
parent.option('--endpoint-url <url>');
parent.option('--debug', 'debug', false);
parent.option('--verbose', 'verbose', false);
parent.option('--dry-run', 'dry-run', false);
parent.addCommand(command);

await expect(
parent.parseAsync(['node', 'ts', 'agent', 'list', '--output', 'yaml']),
).rejects.toMatchObject({
code: 'VALIDATION_ERROR',
exitCode: 5,
details: { field: 'output' },
});
});
});

// ---------------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion src/commands/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,13 @@ export function createAgentCommand(deps: AgentDeps = {}): Command {

function resolveCommonOptions(command: Command): CommonOptions {
const globals = command.optsWithGlobals() as Partial<CommonOptions>;
const rawOutput = globals.output;
if (rawOutput !== undefined && rawOutput !== 'json' && rawOutput !== 'text') {
throw localValidationError('output', 'must be one of: json, text', ['json', 'text']);
}
return {
profile: globals.profile ?? 'default',
output: globals.output ?? 'text',
output: (globals.output as OutputMode | undefined) ?? 'text',
endpointUrl: globals.endpointUrl,
debug: globals.debug ?? false,
verbose: globals.verbose ?? false,
Expand Down