Skip to content

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

Closed
tianhaocui wants to merge 1 commit into
open-gitagent:mainfrom
tianhaocui:fix/duplicate-option-registration
Closed

fix: resolve duplicate option registration in export and import commands#54
tianhaocui wants to merge 1 commit into
open-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>
@shreyas-lyzr
Copy link
Copy Markdown
Contributor

Apologies for the delay reviewing this — and thank you for the clean catch.

The duplicate requiredOption and the case-after-default bug were both real, and your fix here is correct. However, the same fix has already been applied in main as part of the v0.3.0 rebrand — src/commands/export.ts:30 and src/commands/import.ts:524 both now have a single, consolidated requiredOption with all formats (including the new kiro, gitclaw, and gemini cases properly placed before default:).

I'm closing this as superseded, but the credit for first-spotting is yours. Thanks for the patience and for keeping the spec hygienic.

@shreyas-lyzr
Copy link
Copy Markdown
Contributor

Superseded by main (see comment above).

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

2 participants