feat(plugin): external command discovery (Phase 1 MVP)#189
Open
gwpl wants to merge 3 commits intosteipete:mainfrom
Open
feat(plugin): external command discovery (Phase 1 MVP)#189gwpl wants to merge 3 commits intosteipete:mainfrom
gwpl wants to merge 3 commits intosteipete:mainfrom
Conversation
Document Phase 1 MVP design for cargo/git-style external commands. Key design decisions with rationale: * Post-parse fallback (Option B): Built-in commands always take precedence over external plugins, preventing shadowing * Longest-first matching: More specific plugins win over generic ones * gog-* prefix: Matches CLI binary name (git/cargo convention) Part of steipete#188 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement cargo/git-style external command discovery:
* Search PATH for gog-{subcommands} binaries
* Longest-first (greedy) matching: gog-docs-headings wins over gog-docs
* Pass remaining args to plugin
* Use syscall.Exec for true process replacement
Design rationale documented in code comments:
- Longest-first: More specific plugins take precedence
- gog-* prefix: Matches CLI binary name (following git/cargo)
Unit tests document and verify the matching behavior.
Part of steipete#188
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Hook external command discovery into Kong parse error handling: * Try external command AFTER Kong parsing fails (post-parse fallback) * If found: exec replaces current process * If not found: return original Kong error Design choice: Post-parse fallback (Option B) Why: Built-in commands always take precedence over external plugins. This prevents accidental or malicious shadowing of core functionality and follows the git/cargo convention. Part of steipete#188 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This was referenced Feb 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Phase 1 MVP of cargo/git-style external command discovery (Issue #188).
When
gog foo baris invoked and Kong parsing fails (unknown command), the CLI now searches PATH forgog-foo-barbinary and executes it.Design Decisions
1. Post-parse fallback (Option B) vs Pre-parse interception
Chosen: Post-parse fallback
Why Option B: Built-in commands always take precedence over external plugins. This prevents accidental or malicious shadowing of core functionality and follows the git/cargo convention.
2. Longest-first (greedy) matching
For
gog docs headings list, search order:gog-docs-headings-list(most specific)gog-docs-headingsgog-docsWhy: More specific plugins should take precedence over generic ones.
3. Binary prefix:
gog-*Why: Matches the CLI binary name (following git → git-, cargo → cargo-).
Changes
internal/cmd/external.go- Discovery and execution logicinternal/cmd/external_test.go- Unit tests documenting behaviorinternal/cmd/root.go- Integration into Execute()docs/plans/2026-02-06-external-plugin-discovery-design.md- Design documentTest plan
Example usage
Future phases (separate PRs)
--help-onelinerprotocol, help integrationCloses #188 (Phase 1)
Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com