Skip to content

feat(cmd): add shell completion for bash, zsh, and fish - #36

Merged
nmdra merged 8 commits into
masterfrom
feat/shell-completion
Aug 1, 2026
Merged

nmdra merged 8 commits into
masterfrom
feat/shell-completion

Conversation

@nmdra

@nmdra nmdra commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

Adds tab completion for the notebrain CLI in bash, zsh, and fish using jotaen/kong-completion v0.0.14.

What's Included

  • completion subcommand — prints per-shell activation instructions (notebrain completion bash|zsh|fish)
  • Static completion — subcommands, global flags, and enum values (--format, --log-level) derived from kong annotations
  • --llm-model predictor — documented model values for PDF ingestion
  • Dynamic note-slug completion — positional <note> args of get, backlinks, connections, hidden, tags, and --seed of boosted complete from the live ChromaDB index
  • Hidden suggest-notes command — paginated slug scan, excluded from help and completion output
  • Docs — wiki/Shell_Completion.md + README feature bullet; README and wiki rewritten in Simplified Technical English

Key Implementation Details

  • kongcompletion.Register runs before arg parsing to intercept COMP_LINE-triggered shell invocations
  • The note-slug predictor shells out to suggest-notes with COMP_LINE/COMP_POINT stripped from the child env, so posener/complete cannot hijack the child process
  • Enums complete automatically from kong annotations (no explicit format predictor needed)
  • Compat verified with a smoke test against kong v1.16.0 (library targets v1.13)
  • Live-verified against a real 771-note database: 841 slugs, prefix filtering, empty DB → no candidates, ~0.7s cold latency

Commits

  • build(deps): add jotaen/kong-completion (+ compat test)
  • feat(cmd): add shell completion support
  • feat(cmd): add hidden suggest-notes command
  • feat(cmd): complete note slugs from the live index
  • docs ×3: shell completion guide, README link, chroma-path limitation, STE rewrite
  • chore(vendor): gofmt/gci formatting of vendored files

nmdra added 8 commits August 1, 2026 12:23
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.
@nmdra nmdra added the enhancement New feature or request label Aug 1, 2026
@nmdra
nmdra merged commit 3b8f7c6 into master Aug 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant