mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 06:42:03 +00:00
refactor: streamline argument handling in CodexProvider
- Reorganized argument construction in CodexProvider to separate pre-execution arguments from global flags, improving clarity and maintainability. - Updated unit tests to reflect changes in argument order, ensuring correct validation of approval and search indices. These changes enhance the structure of the CodexProvider's command execution process and improve test reliability.
This commit is contained in:
@@ -744,21 +744,25 @@ export class CodexProvider extends BaseProvider {
|
||||
}
|
||||
|
||||
const configOverrides = buildConfigOverrides(overrides);
|
||||
const globalArgs = [CODEX_SKIP_GIT_REPO_CHECK_FLAG, CODEX_APPROVAL_FLAG, approvalPolicy];
|
||||
const preExecArgs: string[] = [];
|
||||
|
||||
if (searchEnabled) {
|
||||
globalArgs.push(CODEX_SEARCH_FLAG);
|
||||
preExecArgs.push(CODEX_SEARCH_FLAG);
|
||||
}
|
||||
|
||||
// Add additional directories with write access
|
||||
if (codexSettings.additionalDirs && codexSettings.additionalDirs.length > 0) {
|
||||
for (const dir of codexSettings.additionalDirs) {
|
||||
globalArgs.push(CODEX_ADD_DIR_FLAG, dir);
|
||||
preExecArgs.push(CODEX_ADD_DIR_FLAG, dir);
|
||||
}
|
||||
}
|
||||
|
||||
const args = [
|
||||
...globalArgs,
|
||||
CODEX_EXEC_SUBCOMMAND,
|
||||
CODEX_SKIP_GIT_REPO_CHECK_FLAG,
|
||||
CODEX_APPROVAL_FLAG,
|
||||
approvalPolicy,
|
||||
...preExecArgs,
|
||||
CODEX_MODEL_FLAG,
|
||||
options.model,
|
||||
CODEX_JSON_FLAG,
|
||||
|
||||
@@ -193,9 +193,9 @@ describe('codex-provider.ts', () => {
|
||||
expect(call.args[approvalIndex + 1]).toBe('never');
|
||||
expect(approvalIndex).toBeGreaterThan(-1);
|
||||
expect(execIndex).toBeGreaterThan(-1);
|
||||
expect(approvalIndex).toBeLessThan(execIndex);
|
||||
expect(approvalIndex).toBeGreaterThan(execIndex);
|
||||
expect(searchIndex).toBeGreaterThan(-1);
|
||||
expect(searchIndex).toBeLessThan(execIndex);
|
||||
expect(searchIndex).toBeGreaterThan(execIndex);
|
||||
});
|
||||
|
||||
it('injects user and project instructions when auto-load is enabled', async () => {
|
||||
|
||||
Reference in New Issue
Block a user