mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-13 20:09:55 +00:00
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.
37 lines
1.6 KiB
TypeScript
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']);
|
|
});
|
|
});
|