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 commander
dist/commands/import.js (lines 453-454):
.requiredOption('--from <format>', '...gemini)')
.requiredOption('--from <format>', '...codex)') // duplicate — crashes commander
2. 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 exits
Fix
For both export.js and import.js:
- Merge the two
.requiredOption() calls into one, listing all formats including both gemini and codex.
- Move
case 'codex' out of default as an independent case with its own break.
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.
Description
After installing gitagent v0.1.0 via
npm i -g @open-gitagent/gitagent, every CLI command fails (not justexportorimport— evengitagent initandgitagent infocrash) because the duplicate option registration error is thrown during module loading.Environment
Error
After patching
export.js, a second identical error appears inimport.js:Root Cause
Two bugs in the compiled output, both following the same pattern:
1. Duplicate
.requiredOption()callsdist/commands/export.js(lines 9-10):dist/commands/import.js(lines 453-454):2.
case 'codex'falls through fromdefaultIn both files,
case 'codex'is placed inside thedefaultbranch (aftererror()and beforeprocess.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.jsandimport.js:.requiredOption()calls into one, listing all formats including bothgeminiandcodex.case 'codex'out ofdefaultas an independent case with its ownbreak.export.js diff:
Same pattern applies to
import.js.Workaround
Manually patch the two files in
node_modules/@open-gitagent/gitagent/dist/commands/as described above.