feat: your own commands complete with Tab and can be shared in the registry

Merged
KI
21d ago
+798-58

Problem

  • Your own : commands ([commands], :command) couldn't say what they do.
  • They didn't complete with Tab, which offered only built-ins.
  • They couldn't be shared through the registry: a keymap entry may not define commands, and no kind could.

Change

  • Descriptions:
    • A command can be a table: [commands.Review] with run (a string or a list) and description. The string and list forms keep working.
    • Mistakes are warnings in the usual config.toml style: an unknown option, a non-string description, a missing run.
    • :command shows Name = steps · description, and :help has a YOUR COMMANDS section.
    • A project command with shell steps that waits for :trust now says so when run, instead of E492, and runs after :trust.
  • Tab completion:
    • :re<Tab> offers your commands after the matching built-ins, case-insensitively, each with its description as the hint (using #187's hint support).
    • Commands from a trusted .vigent.toml complete normally. Shell commands from an untrusted one complete with (waits for :trust).
  • A command kind in the registry:
    • registry/command/<name>/entry.toml holds [commands.<Name>] tables, each needing run and description.
    • An entry may include [keys.*] mappings, but only ones that call its own commands. A step may not define commands or mappings, so every shell step is visible.
    • scripts/registry.mjs checks entries with vigent's loader and lists every ! step in runs; ex-only commands are data only.
    • vigent add merges the entry into config.toml. It refuses a command or key you already have unless --force, shows the file and every shell step, and asks first. --list command and vigent search work too.
    • Starter entries:
      • land: :Land runs the tests, then :pr, with <leader>L.
      • review-flow: :Review and :Fix from the shipped templates.
      • switch: :Fast and :Deep set the effort.
    • The website, docs/registry.md, registry/README.md, docs/config.md, the README and the config templates are updated.
  • The TypeScript app and the Rust binary behave the same.

Verification

Run on this branch, which already contains current main (6ec92a6):

SuitePassFailSkipped
npm test465013
cargo test (crates/vigent)1920–
full pty suite through the packaged Rust binary47107
  • npm run registry:check: 14 entries ok. cargo build --release has no warnings, and website/ type-checks.
  • New tests:
    • command tables and their warnings;
    • :command and :help output;
    • completion, including the trust hint;
    • a pty test of Tab completion with hints, on both builds;
    • validator cases: a bad name, a lowercase command, a missing description, mappings to other commands, steps that define commands, and shell steps listed in runs;
    • vigent add of a command entry, on both builds.
  • Binary size: +13 KB (3,016,344 → 3,029,736 bytes); the archive is still 1.3 MB.

Follow-ups

  • Keymap entries: a mapping that runs :!cmd<CR> is shown as data only today. It should be listed in runs. This was already the case before this PR; it gets its own PR.
  • A command's hint shows only in the wildmenu, which needs two or more matches, as with #187.