Skip to content

fix: resolve duplicate option registration in export and import commands#54

Open
tianhaocui wants to merge 1 commit intoopen-gitagent:mainfrom
tianhaocui:fix/duplicate-option-registration
Open

fix: resolve duplicate option registration in export and import commands#54
tianhaocui wants to merge 1 commit intoopen-gitagent:mainfrom
tianhaocui:fix/duplicate-option-registration

Conversation

@tianhaocui
Copy link
Copy Markdown

@tianhaocui tianhaocui commented Mar 30, 2026

What

Fix duplicate .requiredOption() registration in export and import commands that crashes the entire CLI on startup.

Why

After installing v0.1.0 via npm i -g @open-gitagent/gitagent, every CLI command fails — not just export/import, but even gitagent init and gitagent info — because commander throws during module loading.

Two bugs in both export.ts and import.ts:

  1. .requiredOption() called twice with the same flag (once for gemini, once for codex)
  2. case 'codex' placed inside default branch, unreachable

Closes #53

How Tested

  • npm run build passes
  • gitagent validate passes on example agents
  • Manual testing (describe below)

After patching:

  • gitagent --version0.1.0 (no crash)
  • gitagent info → displays agent summary
  • gitagent validate → validation passed
  • gitagent export --format claude-code → correct output

Checklist

  • My code follows the existing style of this project
  • I have added/updated tests (if applicable)
  • I have updated documentation (if applicable)
  • I have read the CONTRIBUTING.md

The `export` and `import` commands each registered the same required
option twice (once for gemini, once for codex), causing commander to
throw on startup and making the entire CLI unusable.

Additionally, `case 'codex'` was placed inside the `default` branch
in both switch statements, so it could never be matched correctly.

Changes:
- Merge duplicate `.requiredOption()` calls into a single call listing
  all supported formats
- Move `case 'codex'` out of `default` as an independent case with
  its own `break`

Fixes open-gitagent#53

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] CLI crashes on startup: duplicate option registration in export.js and import.js

1 participant