cli: shell completion scripts (CLI slice 3) #125
Labels
No labels
loop
queue/failed
queue/queued
ready
status/parked
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
torbscript/language#125
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Shell completion for any program declared with
std/cli, generated from the same declaration as the help text (CLI.md section 2, point 2: "later, generated from the same declaration"). This issue is the std/cli half of slice 3: a pure function that turns aCommandtree into the completion script of a shell. Exposing it astorb completions <shell>is the compiler half and a follow-up (see Seed).Decisions (by the loop, from CLI.md and docs/standard-library/cli.md)
std/cli, because the declaration (Commandwith publiccommands,flags,options,positional) is there;Command.completion(shell: Shell): Stringis pure likeparseandhelp, so a test needs no process and no shell.torb completions bash > ...); the generator never writes a file itself, so the package stays pure except forrun.--flagand--optionnames of the command the line is in, plus-hand--help. Values of options are not completed (OptionSpechas a type name but no value list); the shell falls back to file names. Completing values is a later slice and needs anArgumenthook.arguments) is rendered for each shell and compared with a checked-in expected text; one test per shell. No test starts a real shell.Requirements
Shelltype with the cases Bash, Zsh, Fish and PowerShell, andCommand.completion(shell: Shell): Stringthat answers the completion script of the command tree.name,commands,flags,options,positional), so a new flag or subcommand appears without a second list to edit.--nameof every flag and option of that command plus-hand--help, at every depth: aftertorb testthe offered names are those oftest.complete -F, zsh#compdefwith a completion function, fishcomplete -c, PowerShellRegister-ArgumentCompleter -Native.Command.completionshall be pure and write nothing.Shellandcompletion(the docs check keeps them in sync).Done when
std/cli/tests/cli.test.trb(or a new file beside it) has one golden test per shell (bash, zsh, fish, PowerShell) that compares the generated text with the expected text for a fixed declaration with a nested subcommand, a flag, an option, a repeatable and a passthrough arguments spec.testsubcommand's script part liststestflags and options and not those of its parent.docs/standard-library/cli.mdanddocs/design/CLI.mddescribeShellandCommand.completionand mark slice 3 done for std/cli; thetorb:declarationblocks match the source (docs check green).sh tools/gates.sh agreen in forge CI;tools/check-commits.shclean; one or two Conventional Commits (feat(std/cli): ...,docs(cli): ...).cli: torb completions <shell>is filed (just in time, depends on this issue and a seed refresh). Filed as #807.Seed
This issue does not touch the seed: it adds new API to
std/clionly, with no syntax change, no new native, no driver flag and no std name the compiler looks up by string. The compiler importsstd/clithrough the seed, sotorb completions <shell>(callingcompletionfromcompiler/src/cli/declaration.trb) can only land after a seed refresh that contains this change; that refresh stays Torben's. That is why the subcommand is a separate follow-up and not a second commit here.Source
Command,OptionSpec,ArgumentsSpec)Dependencies
Depends on #123 (closed). Slice 2 (#124) is not needed: the generator works on any
Command.Moved from the planning lists of the docs; the design record stays the specification.
[loop:torbscript] intake: in scope (author orion, label loop), source CLI.md slice 3, not a duplicate. Depends on #123. next: waiting (dependency #123) until 2026-10-10T04:00:00Z
std/cli(CLI slice 1) #123torbparses its command line withstd/cli(CLI slice 2) #124torbparses its command line withstd/cli(CLI slice 2) #124[loop:torbscript] re-sweep: state check, body unchanged. The dependency #123 closed on 2026-10-23, so the last note (waiting until 2026-10-10) is stale. The acceptance criteria are a single line, and CLI.md says only "later, generated from the same declaration" about this slice, so the scope (which shells, where the completion script is written, how it is tested) is not settled. This is a definition-of-ready gap: refine has to write goal, criteria and the seed statement before
ready.[loop:torbscript] claim refine by session:loop-torbscript-20261114-0814 until 2026-11-14T09:14:00Z
[loop:torbscript] decided by the loop: scope of slice 3. Shells bash, zsh, fish and PowerShell; one pure
Command.completion(shell)in std/cli generated from the declaration; golden-output tests per shell; option values not completed (no value list inOptionSpec); thetorb completions <shell>subcommand is a just-in-time follow-up after a seed refresh. No owner decision needed: technical design inside CLI.md. Body rewritten with goal, R1-R7, done criteria and seed statement; labelreadyset. Size: one PR, one or two commits, so no split. next: implement[loop:torbscript] release refine by session:loop-torbscript-20261114-0814
[loop:torbscript] claim implement by session:loop-torbscript-20261114-1056 until 2026-11-14T12:56:00Z
[loop:torbscript] implement: opened #785 (2 commits: feat(std/cli), docs(cli); R1-R7 and the tests of the done list). Written without a local compiler (CI only by rule), so the golden texts and the hand-edited skills copy are unverified until forge CI runs; a fix round may be needed. next: waiting (review of PR #785)
[loop:torbscript] release implement by session:agent:orion:subagent:875c3410-95a9-4cf5-8391-985a9de04aab
[loop:torbscript] claim implement by session:loop-torbscript-20261114-1616 until 2026-11-14T19:16:00Z
[loop:torbscript] implement: PR #785 had a failing commit-message check because of a
stylecommit. Folded it into the feat commit; PR #785 is now feat + docs, new headc3c38fea9f, tree unchanged, commit lint passes locally. CI re-runs.next: waiting (CI on PR #785, then review)
[loop:torbscript] release implement by session:loop-torbscript-20261114-1616
[loop:torbscript] claim implement by session:loop-torbscript-20261114-1746 until 2026-11-14T19:46:00Z
[loop:torbscript] implement: rebased PR #785 onto main (
64f7ca6a), conflicts in docs/design/CLI.md; CI re-runs.next: waiting (CI on PR #785, then argus review)
[loop:torbscript] release implement by session:loop-torbscript-20261114-1746
Status by orion (PR follow-up after merge): PR #785 (
feat(std/cli): shell completion scripts) merged by argus at 2026-11-14T23:02Z asf823aa3f40. Post-merge CI on main (ci / gates,ci / commit messages,pdisc) was still pending at this run.Remaining, in order:
f823aa3(ci / gates,pdisc). If red, fix in a new PR.edgeafter main CI. Cut the next release via a version-bump PR (project.trb, compiler/project.trb, editors/vscode/package.json, compiler/src/package/version.trb; version per docs/design/RELEASE.md), reviewer requested.torb completions <shell>(compiler half, seed refresh) is a separate follow-up issue, not yet filed. This task stays open until it is filed or done.[loop:torbscript] claim refine by session:loop-torbscript-125-followup until 2026-11-15T04:50Z
torb completions <shell>#807Closing: the std/cli half of CLI slice 3 landed in PR #785 (#785, merged as
f823aa3f; feature commit16d67f30, docs commit3c23fdec).Shell,Command.completion,std/cli/tests/completion.test.trb, and the docs/standard-library/cli.md and docs/design/CLI.md sections are onmain;ci / gateswas green onf823aa3f, andpdiscis green on the later main commit35209c5d(the redpdisconf823aa3fwas not caused by a content change of this issue: it passed again two commits later).The follow-up
cli: torb completions <shell>is filed as #807 (#807). It needs a seed refresh that contains PR #785, which stays Torben's, so it is notreadyyet.A release (version tag) is cut outside the loop; this issue does not depend on it.
[loop:torbscript] release refine: verified the merged work on main, filed the follow-up #807 (#807, without
ready: needs a seed refresh with PR #785, Torben's), ticked the criteria and closed #125; a release is cut outside the loop. Released the claim of session:loop-torbscript-125-followup. Worker usage: about 60k tokens (sonnet). next: #125 done; #807 waiting (seed refresh)