feat(mcp): add shell completion command for bash, zsh, and fish - #400
Merged
Conversation
Add `gittensory-mcp completion <bash|zsh|fish>` to print a tab-completion
script for the user's shell. It completes the top-level commands and the
subcommands of `profile`, `cache`, and `agent`, driven by a single command
spec so it stays in sync with the CLI. `--json` returns
`{ shell, script }` for tooling; a missing or unsupported shell errors with
the supported list.
Tests cover all three shells, the JSON form, and the missing/unsupported
shell errors.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
JSONbored
approved these changes
Jun 5, 2026
JSONbored
left a comment
Owner
There was a problem hiding this comment.
@glorydavid03023 thanks, this is in good shape.
A few notes:
- The completion command is scoped to the MCP CLI surface and the README coverage matches the user-facing behavior.
- The tests cover the command path closely enough for this slice.
- No code changes requested from me.
Validation expected:
- Current green CI is enough for this change.
Closed
12 tasks
This was referenced Jul 2, 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
Adds
gittensory-mcp completion <bash|zsh|fish>— a standard CLI feature that prints a tab-completion script for the user's shell:It completes the top-level commands and the subcommands of
profile,cache, andagent.--jsonreturns{ "shell": "...", "script": "..." }for tooling. A missing or unsupported shell errors with the supported list.Design
The scripts are generated from a single
CLI_COMMAND_SPEC(top-level command → subcommands) so completion stays in sync with the CLI surface rather than drifting from a hand-maintained list.Why no linked issue
Additive, self-contained CLI ergonomics. No public-behavior, auth/session, schema, deploy, or frontend-architecture change, so per CONTRIBUTING this does not require an issue first. Happy to file one if preferred.
Changes
packages/gittensory-mcp/bin/gittensory-mcp.js—completiondispatch;completionCommand()+buildCompletionScript()and per-shell generators;CLI_COMMAND_SPEC/COMPLETION_SHELLSconstants; help-text usage line.test/unit/mcp-cli.test.ts— cover all three shells, the JSON form, and the missing/unsupported-shell errors.packages/gittensory-mcp/README.md— document the command with install snippets.Contract notes
No MCP tool or HTTP/OpenAPI contract changes. Local CLI command only; the
--jsonpayload is additive.Validation
Run locally from the repo root (environment note: portable Node v20.18.1; CI runs Node 22):
npm run build:mcp→ pass (exit 0)npm run typecheck(tsc --noEmit) → pass (exit 0)test/unit/mcp-cli.test.ts→ my new cases pass:prints shell completion scripts for bash, zsh, and fish✓emits completion as machine-readable json✓rejects missing or unsupported completion shells✓complete -F, zsh#compdef, fishcomplete -c) and the--jsonoutput.Honest caveat (unrelated to this change): in a full
mcp-cli.test.tsrun, one pre-existing test (rejects unsafe server-provided packet markdown before non-json output, which doesgit init+ subprocess work) times out at its 10s limit under the slow portable Node on Windows. It passes on CI (Linux/Node 22); my three cases and the other 36 tests pass locally. CI on this PR gives the authoritative full-gate result.During development I caught and fixed a temporal-dead-zone bug (the command-spec constants are referenced by
runCli, which is invoked at module load, so they must be declared before that call) before pushing.Security / privacy
No auth, cookie, CORS, GitHub App output, identity, or contributor-evidence changes. The generated scripts contain only static command/subcommand names already shown in
--help.