Repository navigation
feat: first-class third-party completion package activation (#15) #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
be7e01a
feat: first-class third-party completion package activation (#15)
tonythethompson 7908efd
fix: address review findings on completion activation (#165)
tonythethompson 0332e69
chore: bump libz-sys 1.1.29 to 1.1.31 (RUSTSEC-2026-0418)
tonythethompson 17a1846
Fixed 3 review threads; tests and lint pass.
opencode-agent[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # Completion package activation (issue #15) | ||
|
|
||
| ## Contract | ||
|
|
||
| - A completion package declares its targets in its registry activation spec: | ||
| `activation: {kind: "nu-completion", targets: [{command, path, kind}, ...]}`. | ||
| `command` is the external command surface the package augments (a single | ||
| command name, e.g. `git`); `path` is a package-relative `.nu` source file | ||
| contributing that command's completions; `kind` is the declared completion | ||
| kind, `"static"` or `"command-backed"`. At least one target is required. | ||
|
tonythethompson marked this conversation as resolved.
Resolved
|
||
| - Command names use the same small grammar as script command names (ASCII | ||
| letter or `_`, then letters, digits, `_`, `-`) because the target name is | ||
| emitted into the generated managed file's ownership comments, and a | ||
| declared target is an ownership claim, not free text. Duplicate commands | ||
| or duplicate paths within a package are rejected, as are Nushell reserved | ||
| keywords. | ||
| - `kind` is declared, never inferred. `"command-backed"` means the source | ||
| defines completer functions that Nushell will execute when it requests a | ||
| completion; `"static"` means completions are literal values in the source. | ||
| Activation and install never invoke a completer either way. `numan info` | ||
| displays every declared target and, for `"command-backed"` targets, states | ||
| plainly that the provider can execute code during completion. | ||
| - Target ownership is exclusive across active completion packages: if a | ||
| command target is already owned by another active completion package, | ||
| activation of the second package is rejected. Numan never silently | ||
| replaces or shadows another active package's completion. | ||
| - Install persists the declaration in the lockfile (`completion_targets`); | ||
| install never executes package code. Activation validates every target | ||
| with the same containment/regular-file/`.nu` rules as script entry points. | ||
| - Activation composes each target into the Numan-managed autoload file | ||
| (`numan.nu`), alongside module `use` statements and script wrappers: | ||
|
|
||
| ```nu | ||
| # numan:completion <owner/name> <command> | ||
| use "<absolute path to target file>" * | ||
| ``` | ||
|
|
||
| The `use ... *` form matches how Nushell custom-completion files are | ||
| consumed (they export `extern` definitions plus completer functions). | ||
| Rendering is sorted by scoped package ID, then command, so the generated | ||
| file is deterministic. | ||
| - The managed file goes through the existing candidate-validation, journal, | ||
| drift, and recovery machinery; the lockfile ground truth is a per-package | ||
| `completion_activation` record with the same Nu-identity fields as | ||
| `script_activation` (Nu executable hash, Nu version, vendor autoload dir, | ||
| managed file path, resolved targets). | ||
| - Deactivation removes exactly the package's `use` lines and clears its | ||
| record, leaving other packages' contributions and all user-authored | ||
| configuration untouched. Update/remove follow the existing autoload | ||
| reconciliation used for script packages. | ||
| - `numan init --refresh` re-resolves active completion targets and | ||
| regenerates the managed file when the Nu identity changes, matching | ||
| script behaviour. | ||
|
|
||
| ## Acceptance | ||
|
|
||
| - Fixture coverage for static and command-backed targets, multi-command | ||
| packages, cross-package target conflicts, malformed declarations, | ||
| traversal attempts, deactivation, interrupted activation (recovery), and | ||
| updates, mirroring `tests/script_activation_test.rs`. | ||
|
tonythethompson marked this conversation as resolved.
Resolved
|
||
| - Real-Nu acceptance (ignored by default, run explicitly) proves a clean | ||
| interactive session receives a contributed completion after activation | ||
| and no longer receives it after deactivation, without modifying user | ||
| config files. | ||
| - Documentation distinguishes Numan's own shell-completion generator | ||
| (`numan completions <shell>`) from installable Nushell completion | ||
| packages, and the README package-support table lists completion packages | ||
| as activatable via `numan activate`. | ||
|
|
||
| ## Non-goals | ||
|
|
||
| - Managing Bash/Fish/Zsh/PowerShell completion packages for arbitrary tools. | ||
| - Executing completion providers at install, inspect, lock, update, or | ||
| activation time. Providers run only when Nushell requests a completion. | ||
| - Merging arbitrary user-authored completion files, or detecting conflicts | ||
| with completions a user defined outside Numan. Declared targets are | ||
| registry-curated; the ownership check covers Numan-activated completion | ||
| packages. | ||
| - Inferring a target's kind by parsing its source. The declaration is the | ||
| contract; a package that mis-declares is a curation failure, surfaced by | ||
| `numan info` showing the declared kind before activation. | ||
|
|
||
| ## Registry dependency | ||
|
|
||
| This contract is implemented on the client side only. The numan-registry | ||
| index schema (`schemas/index-v1.json` in numan-cli/numan-registry) does not | ||
| yet permit the `targets` field on an activation spec, so registry packages | ||
| cannot declare completion targets until that schema and its validation | ||
| path are updated to accept `nu-completion` targets. That schema change is | ||
| a tracked numan-registry follow-up; it is not part of the client PR that | ||
| implements this spec. | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.