-
Notifications
You must be signed in to change notification settings - Fork 254
Description
Description
After installing gitagent v0.1.0 via npm i -g @open-gitagent/gitagent, every CLI command fails (not just export or import — even gitagent init and gitagent info crash) because the duplicate option registration error is thrown during module loading.
Environment
- gitagent: 0.1.0
- Node.js: v23.7.0
- OS: macOS (Darwin 24.0.0)
Error
Error: Cannot add option '-f, --format <format>' to command 'export' due to conflicting flag '--format'
- already used by option '-f, --format <format>'
at Command._registerOption (commander/lib/command.js:602:13)
After patching export.js, a second identical error appears in import.js:
Error: Cannot add option '--from <format>' to command 'import' due to conflicting flag '--from'
- already used by option '--from <format>'
Root Cause
Two bugs in the compiled output, both following the same pattern:
1. Duplicate .requiredOption() calls
dist/commands/export.js (lines 9-10):
.requiredOption('-f, --format <format>', '...gemini)')
.requiredOption('-f, --format <format>', '...codex)') // duplicate — crashes commanderdist/commands/import.js (lines 453-454):
.requiredOption('--from <format>', '...gemini)')
.requiredOption('--from <format>', '...codex)') // duplicate — crashes commander2. case 'codex' falls through from default
In both files, case 'codex' is placed inside the default branch (after error() and before process.exit(1)), so it can never be matched correctly:
default:
error(`Unknown format: ${options.format}`);
info('Supported formats: ...');
case 'codex': // falls through from default
result = exportToCodexString(dir);
process.exit(1); // always exitsFix
For both export.js and import.js:
- Merge the two
.requiredOption()calls into one, listing all formats including bothgeminiandcodex. - Move
case 'codex'out ofdefaultas an independent case with its ownbreak.
export.js diff:
- .requiredOption('-f, --format <format>', 'Export format (...gemini)')
- .requiredOption('-f, --format <format>', 'Export format (...codex)')
+ .requiredOption('-f, --format <format>', 'Export format (...gemini, codex)')- default:
- error(`Unknown format: ${options.format}`);
- info('Supported formats: ...gemini');
- case 'codex':
- result = exportToCodexString(dir);
- info('Supported formats: ...codex');
- process.exit(1);
+ case 'codex':
+ result = exportToCodexString(dir);
+ break;
+ default:
+ error(`Unknown format: ${options.format}`);
+ info('Supported formats: ...gemini, codex');
+ process.exit(1);Same pattern applies to import.js.
Workaround
Manually patch the two files in node_modules/@open-gitagent/gitagent/dist/commands/ as described above.