Files
hapi/cli/src/codex/codexLocal.test.ts
T
weishu f132a7dc79 feat(codex): implement CLI argument passthrough for codex
Collect unknown CLI arguments from index.ts and pass them through the execution chain (runCodex → loop → CodexSession → codexLocalLauncher → codexLocal), similar to how claude already works. This enables users to pass CLI arguments like --model and --sandbox to the underlying codex process.

Filter out the 'resume' subcommand which is managed internally by hapi, while allowing other CLI arguments to pass through. Add warning log in remote mode when CLI args are ignored since remote mode uses message-based configuration instead. Include unit tests for the resume filtering logic.
2025-12-23 09:06:08 +08:00

37 lines
1.6 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { filterResumeSubcommand } from './codexLocal';
describe('filterResumeSubcommand', () => {
it('returns empty array unchanged', () => {
expect(filterResumeSubcommand([])).toEqual([]);
});
it('passes through args when first arg is not resume', () => {
expect(filterResumeSubcommand(['--model', 'gpt-4'])).toEqual(['--model', 'gpt-4']);
expect(filterResumeSubcommand(['--sandbox', 'read-only'])).toEqual(['--sandbox', 'read-only']);
});
it('filters resume subcommand with session ID', () => {
expect(filterResumeSubcommand(['resume', 'abc-123'])).toEqual([]);
expect(filterResumeSubcommand(['resume', 'abc-123', '--model', 'gpt-4']))
.toEqual(['--model', 'gpt-4']);
});
it('filters resume subcommand without session ID', () => {
expect(filterResumeSubcommand(['resume'])).toEqual([]);
expect(filterResumeSubcommand(['resume', '--model', 'gpt-4']))
.toEqual(['--model', 'gpt-4']);
});
it('does not filter resume when it appears as flag value', () => {
// --name resume should pass through (resume is value, not subcommand)
expect(filterResumeSubcommand(['--name', 'resume'])).toEqual(['--name', 'resume']);
});
it('does not filter resume in middle of args', () => {
// If resume appears after flags, it's not the subcommand position
expect(filterResumeSubcommand(['--model', 'gpt-4', 'resume', '123']))
.toEqual(['--model', 'gpt-4', 'resume', '123']);
});
});