Add pty completions <shell> generator (fish/bash/zsh, SSOT, dynamic sessions) - #106
Merged
schickling merged 1 commit intoJul 20, 2026
Merged
Conversation
… sessions)
- src/completions.ts owns one declarative command-tree spec that emits
fish, bash, and zsh completion scripts, so the three can't drift.
- Keeps pty's dynamic session-name completion (reads <root>/*.json at
completion time) for every verb that takes a <ref>, plus path completion
for up/down and enum completion for list/ls --status.
- src/cli.ts dispatches `case "completions"` to the generator.
- Regenerated completions/pty.{fish,bash,zsh} from the generator; the
static files now carry a 'generated by pty completions' header.
- tests/completions.test.ts guards COMMAND_HELP<->spec parity and shell
syntax (fish -n / bash -n via the built CLI).
schickling
marked this pull request as ready for review
July 20, 2026 09:58
schickling
marked this pull request as draft
July 20, 2026 10:10
schickling
marked this pull request as ready for review
July 20, 2026 14:00
This was referenced Jul 20, 2026
This was referenced Jul 21, 2026
myobie
added a commit
that referenced
this pull request
Jul 21, 2026
…k parity + wire vitest CI (#114) Un-breaks the post-exit parity contract that #111 (exit-reap) broke on main, per Nathan's call: make reap-vs-preserve-on-exit CONFIGURABLE rather than a fixed default. - PTY_REAP_ON_EXIT env knob (network/global; the daemon inherits it via spawn.ts) sets the default: false/0/no/off -> preserve, unset/else -> reap (shipped default). Per-session keep=true (force preserve) / --ephemeral (force reap) override it. shouldReapAtExit gains an OPTIONAL defaultReap param (defaults to reapOnExitDefault()) so the re-exported 2-arg API (relay/layout/supervisors) stays backward-compatible. - parity #1 now asserts BOTH modes (preserve keeps the final screen; reap reaps). exit-reap.test.ts keeps the reap-default suite + adds a preserve-mode block. isolate-env.ts scrubs PTY_REAP_ON_EXIT for a deterministic default. - help.test.ts: completions -> NON_COMMAND_CASES (fixes pre-existing #106 help drift; completions ships its own lightweight usage, not the strict per-subcommand format). - CI: add .github/workflows/test.yml gating the vitest suite (Node 22, matches flake.nix) on PR + push-to-main. Installs the test-only binaries ubuntu-latest lacks (zsh/fish for shells.test.ts; a no-op claude stub for restart-guardrail). The push CI was Nix-build-only, which is how both breaks reached main invisibly. Supersedes #113. - Docs: README "Session lifecycle and cleanup" + CHANGELOG rewritten for the configurable setting. Full suite green: 1408 passed, 21 pre-existing env-gated skips.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
ptyships staticcompletions/pty.{fish,bash,zsh}files that are hand-maintained and drift from the actual command surface insrc/cli.ts. There is nopty completionssubcommand, so downstreams (Home Manager, distro packages) can't regenerate them from the binary.What
Adds
pty completions <shell>(fish/bash/zsh) that prints a completion script to stdout, generated from a single declarative command-tree spec insrc/completions.ts. The existingcompletions/pty.{fish,bash,zsh}are now produced by this generator and carry a "generated bypty completions" header.How
src/completions.tsowns oneCommandSpec[]describing commands → flags, enum-valued flags, and positionals. It emits all three shell scripts, so they cannot drift.src/cli.tsdispatchescase "completions"to the generator (exit code 2 + usage on unknown/missing shell, 0 on--help).<ref>are markeddynamic: "sessions"and the generator emits the per-shell idiom that reads<root>/*.jsonat completion time (same behavior as the legacy static files).up/downget path completion;list/ls --statusget therunning|exited|vanishedenum.tests/completions.test.tsasserts every command documented inCOMMAND_HELPhas a matching spec entry, and that the generated scripts are syntactically valid (fish -n/bash -nvia the built CLI).Rationale
Mirrors
st'sst completionsdesign (whichptywas modeled on), extended with the two things pty specifically needs: live session-name completion and path completion. Keeping the static files as generated artifacts means there is now exactly one source of truth.Verification
npm run buildandnpm run typecheckpass.tests/completions.test.tspasses (including a realfish -n/bash -nsyntax check and a dynamic-session completion smoke test).package-lock.jsonis unchanged, so the existingflake.nixnpmDepsHashstays valid andnix build .#ptyis unaffected.