feat(cmd): add shell completion for bash, zsh, and fish - #36
Merged
Merged
Conversation
Adds github.com/jotaen/kong-completion v0.0.14 with transitive deps posener/complete and riywo/loginshell (pure Go, no CGO). Includes a compat smoke test proving v0.0.14 registers cleanly against kong v1.16.0 without panicking or intercepting normal invocations.
Wires jotaen/kong-completion into the CLI: adds a completion subcommand that prints per-shell activation instructions (bash/zsh/fish), and registers predictors before arg parsing so COMP_LINE-triggered shell invocations are intercepted. --format and --log-level are completed automatically by the library from their kong enum values (verified in vendored source), so no explicit predictors are needed for them. --llm-model gets a static predictor with documented model values. Refactors ParseAndRun to accept args (ParseAndRun signature unchanged) so completion behavior is testable.
Lists all indexed note slugs (sorted, one per line) from chunk_index=0 metadata. Hidden from help and shell completion. Fast: paginated scan only, no embeddings or LLM calls. Exits 0 with empty output on an empty store, so the completion predictor can treat no DB as no candidates.
Adds a note-slug completion predictor that shells out to the hidden suggest-notes command. The child process strips COMP_LINE/COMP_POINT from its environment so posener/complete cannot hijack it (it triggers on COMP_LINE alone), and failures (e.g. no DB yet) yield no candidates instead of errors. Wired to the positional <note> args of get, backlinks, connections, hidden, and tags, plus boosted's --seed.
Adds wiki/Shell_Completion.md covering per-shell activation, completion scope (subcommands, flags, enums, llm-model values, dynamic note slugs), the live-index requirement, and known limitations. Linked from the README documentation table.
Slug candidates follow the config or default chroma path; a --chroma-path typed on the command line is not reflected in completions (found during live verification).
Applies ASD-STE100 rules across the README and all wiki guides: - One verb for the check/verify concept: make sure that - Removed banned modals (should/would/may/might/could) and present perfect - Removed slop words (robust, comprehensive, via, easily, graceful) - Semicolons split into separate sentences; conditions moved before commands - Consistency pass: run/show/see, configuration file - README: shell completion feature bullet added - PDF_Ingestion: corrected the wizard command (notebrain init, not config init) Code blocks, identifiers, and command names are untouched.
Pre-commit formatting gates normalized three vendored files: - jotaen/kong-completion/completion.go: import grouping (gci) - posener/complete/doc.go and riywo/loginshell/loginshell.go: gofmt doc-comment heading normalization (Go 1.19+ style) No functional changes; output matches go mod vendor regeneration.
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 tab completion for the
notebrainCLI in bash, zsh, and fish using jotaen/kong-completion v0.0.14.What's Included
completionsubcommand — prints per-shell activation instructions (notebrain completion bash|zsh|fish)--format,--log-level) derived from kong annotations--llm-modelpredictor — documented model values for PDF ingestion<note>args ofget,backlinks,connections,hidden,tags, and--seedofboostedcomplete from the live ChromaDB indexsuggest-notescommand — paginated slug scan, excluded from help and completion outputwiki/Shell_Completion.md+ README feature bullet; README and wiki rewritten in Simplified Technical EnglishKey Implementation Details
kongcompletion.Registerruns before arg parsing to interceptCOMP_LINE-triggered shell invocationssuggest-noteswithCOMP_LINE/COMP_POINTstripped from the child env, so posener/complete cannot hijack the child processformatpredictor needed)Commits
build(deps): add jotaen/kong-completion (+ compat test)feat(cmd): add shell completion supportfeat(cmd): add hidden suggest-notes commandfeat(cmd): complete note slugs from the live indexdocs×3: shell completion guide, README link, chroma-path limitation, STE rewritechore(vendor): gofmt/gci formatting of vendored files