Skip to content

Shell completions for bash and zsh - #43

Open
dchaudhari7177 wants to merge 1 commit into
notsointresting:mainfrom
dchaudhari7177:feat/shell-completions
Open

Shell completions for bash and zsh#43
dchaudhari7177 wants to merge 1 commit into
notsointresting:mainfrom
dchaudhari7177:feat/shell-completions

Conversation

@dchaudhari7177

Copy link
Copy Markdown
Contributor

Adds a completions subcommand: skillscope completions bash / skillscope completions zsh prints the script to stdout.

It completes subcommands, flags, and the values of --sort and --theme.

Generated, not hand-maintained

The issue offers a static scripts/completions.bash as one option. I went with generation instead, because a static script drifts silently the moment a flag or theme is added. So:

  • the parseArgs spec is lifted to a named OPTIONS const, and the flag list is derived from what the parser actually accepts;
  • subcommands come from the existing COMMANDS;
  • --theme values come from the live themes registry, so a new theme appears in --theme <TAB> with no extra work;
  • --sort values come from SORTS.

That's the only structural change to cli.ts — the options object moved out of the parseArgs call and is passed by name.

Dependency-free

The output is plain shell text with no node subprocess at completion time, matching the project's zero-runtime-deps stance. Word lists are single-quote escaped so a value containing ' can't break out.

Verified in a real shell

Beyond the unit tests, I sourced the generated script in bash and drove the function directly:

[skillscope ]            -> report skills agents cost wrapped doctor completions
[skillscope re]          -> report
[skillscope --js]        -> --json
[skillscope --sort ]     -> fires cost last-used name sessions
[skillscope --theme d]   -> dark dracula
[skillscope report --]   -> --json --md --csv --since ... --version

bash -n parses the emitted script cleanly.

Tests

test/completions.test.ts: both shells list every command/flag/value, each registers with the correct hook (and #compdef is asserted to be the first line, or zsh won't autoload it), the output contains no node/require, and quote escaping holds.
test/cli.test.ts: the subcommand prints for both shells, carries the real theme names, and rejects a missing or unsupported shell with exit 2.

README gains a Shell completions section with the source <(...) form and permanent install paths for both shells, including the fpath/compinit note for zsh.

Typecheck and the full suite (89 passing) are green.

Closes #34

@notsointresting

Copy link
Copy Markdown
Owner

Conflict against main now — a few other PRs touching src/cli.ts/themes/index.ts landed first. Could you rebase onto main and resolve? Should just be re-applying your change alongside the others already merged.

New `skillscope completions <shell>` subcommand printing a bash or zsh script.
Completes subcommands, flags, and the values of --sort and --theme.

The script is GENERATED from the CLI's own lists rather than a hand-maintained
copy: the parseArgs spec is lifted to a named OPTIONS const so the flag list is
derived from what the parser actually accepts, commands come from COMMANDS, and
--theme values come from the live themes registry. Adding a flag or a theme
cannot leave completions silently stale.

Dependency-free plain shell text, matching the project's zero-runtime-deps
stance — no node subprocess at completion time. Word lists are single-quote
escaped. README documents both the source <(...) form and permanent install.

Closes notsointresting#34
@dchaudhari7177
dchaudhari7177 force-pushed the feat/shell-completions branch from e55a1f6 to 3989bd5 Compare July 23, 2026 15:34
@dchaudhari7177

Copy link
Copy Markdown
Contributor Author

I saw the new Pace section in CONTRIBUTING — that's fair, and it's clearly about me. I opened eight PRs here in about an hour, which is exactly the "one person claiming everything within minutes" pattern you're describing, and I'm sorry for crowding the queue.

I've rebased all seven of the open ones onto current main so nothing is sitting there conflicting and creating work for you (#36 merging made all of them dirty). They're each green: typecheck plus the full suite.

Rather than unilaterally closing things, I'd rather you pick — happy to do any of these, just say which:

  • Close most of them and keep only 1–2 open (my suggestion would be New command: skillscope mcp #37 mcp, since it's the direct companion to the hooks command you just merged and is a ~30-line diff). I'd close the rest and reopen them one at a time as they merge — the branches stay on my fork, so nothing is lost.
  • Keep a specific couple you actually want now, and I close the others.
  • Leave them if you'd rather triage them yourself.

Either way I won't open anything new here until these are down to 1–2, and I'll stick to that going forward.

For what it's worth, the ones most worth your time are probably #42 (doctor --json/--md, since every other command already honours the format flags) and #43 (completions, generated from the CLI's own command/flag lists so it can't drift). The four theme PRs are the most disposable — close those first if you want the queue back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants