Skip to content

feat(cli): add explicit shell-scoped sp shorthand - #75

Merged
abruption merged 12 commits into
mainfrom
feat/74-sp
Oct 3, 2026
Merged

abruption merged 12 commits into
mainfrom
feat/74-sp

Conversation

@abruption

@abruption abruption commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Users can opt in to sp as another invocation name for the installed session-peer CLI. Ship Bash/zsh and PowerShell activation files that are explicitly sourced into the caller's shell/scope and refuse any existing sp executable, alias or function. PowerShell's default sp = Set-ItemProperty must be explicitly resolved by the user first.

The alias resolves canonical session-peer without a second parser, wrapper, argument reconstruction or eval. npm continues to register only the canonical bin and performs no profile/PATH edits or activation hooks. Scripts, SSH, help/version and reply instructions retain the canonical name. This assumes one installed implementation; Python/TS co-installation and a dispatcher are out of scope. Windows cmd.exe uses the canonical command.

Document activation, scope/detection limits, deactivation and manager-owned update/uninstall in a detailed guide linked from all four README/guide languages. The public npm 0.2.1 archive is explicitly excluded; the source addition targets 0.3.0.

Closes #74. Python counterpart: abruption/session-peer#242. Correlation: SP-CLI-SHORTHAND-20260929.

Validation

  • Local clean dependency install, build, test type checking, repository link/anchor checks and diff check pass.
  • Package smoke checks the exact new assets, reproducible tarball, isolated install/native load and no npm-installed sp bin.
  • Bash/zsh checks pass for version/help/list/dry-run/usage failures (exit code, stdout and stderr identical through both names), Unicode/whitespace/literal metacharacters/stdin/-- (canonical and alias capture both exit 7), unchanged collisions and deactivation. Each fixture shell first proves its runner reports a script's own exit code (exit 3 -> 3).
  • The lifecycle runs in every fixture shell (Bash, zsh where present, Windows PowerShell 5.1) in an isolated --prefix: install the packed version, activate sp, replace it in place with a second, lower fixture-only version (a version replacement in the same prefix, not a registry upgrade or a PATH move) (<version>-fixture.1, packed from a private copy with package.json and the compiled VERSION changed), assert sp --version and session-peer --version both report the new version, uninstall, assert both names fail as command not found (Bash/zsh exit 127 with "not found", PowerShell CommandNotFoundException), and confirm deactivation removes sp. Fixture PATH excludes unrelated installed CLIs; no global install or profile change.
  • Rebased onto main 64b98b9 (fix(windows): give the creation-time probe a cold-start deadline #79, feat(ssh): support ordered multi-host commands and constrained connection options #84, feat(updates): add npm-aware update check and opt-in cached notices #85, feat(replies): add verified sender context and optional return-route diagnostics #86). Package file lists in scripts/release.mjs and test/package-smoke.ts are the union of the shorthand assets plus docs/shorthand.md and main's dist/ssh.*, dist/replies.*, dist/updates.*; PARITY keeps main's sections and adds the shorthand section after them. test:package does not load test/fixtures/isolate-env.mjs, so the shorthand fixture sets the same isolation explicitly (SESSION_PEER_TAILSCALE=off, cleared sender socket, reply-host and update-notice variables); its PATH contains only the installed bin and a node link, so no real ssh/tailscale is reachable.
  • Local after rebase (Node 24, macOS): npm test 121 tests, 116 pass, 5 skipped (Windows-only), 0 fail; test:package bash/zsh contract and lifecycle pass; test:types, check-repository, release.mjs pack + artifact, npm audit (0) and diff check pass.
  • CI run 37091759757 (head 796b525) and CodeQL run 37091757017 pass every job. shorthandLifecycle with 0.2.1 -> 0.2.1-fixture.1 appears for bash (Linux and macOS, Node 22/24), zsh (macOS, Node 22/24) and powershell (Windows PowerShell 5.1, Node 22/24), alongside shorthandContract for the same shells. Alias forwarding retains PowerShell's ordinary native-argument/text-pipeline semantics.
  • Stderr comparison normalizes only the per-process ID in Node 22's (node:<pid>) ExperimentalWarning prefix; all other stderr bytes must match.
  • docs/shorthand.md documents the PowerShell detector limit (Get-Command -ListImported does not consider commands from modules not yet imported; activation does not import modules), how to check an installation for the activation files (--version cannot distinguish a local build from public 0.2.1), and the exact lifecycle coverage.
  • Windows fixture fixes found in CI: the builtin sp alias is ReadOnly, AllScope, so the fixture removes it with -Force in global scope (the activator never removes it); Windows PowerShell 5.1 ConvertFrom-Json arrays are assigned directly to keep argument arrays flat; and -Command reports only 0/1 unless the command string ends with exit $LASTEXITCODE (about_PowerShell_exe), which had turned expected usage refusals (exit 2) into 1. The fixture now reports every mismatching case in one assertion.

Release impact

No runtime parser, transport or submission code changes. Package contents add two opt-in activation assets and one guide. No publication, fleet installation or user shell/profile changes are performed by this PR.

Windows PowerShell -Command reports only 0 or 1 unless the command string ends with exit $LASTEXITCODE (about_PowerShell_exe), which turned expected usage refusals (exit 2) into 1. Keep -Command for global-scope alias removal, propagate the script exit code, and report every shorthand case mismatch with its output in one assertion.
Run the install/activate/update/uninstall lifecycle in every fixture shell with a second fixture-only version, assert command-not-found after removal, require exit 7 for the canonical capture, compare stderr between names, and verify each runner reports a script's own exit code.
Explain the PowerShell -ListImported limit for modules not yet imported, how to check an installation for the activation files, and the lifecycle coverage.
Node 22 prefixes the SQLite ExperimentalWarning with a per-process ID, so stderr from two invocations differs only in that number.
The lifecycle fixture replaces the package with a lower fixture version in the same prefix; it is not a registry upgrade and does not cover moving the canonical command on PATH.
…settings

test:package does not load the isolate-env preload, so the shorthand fixture sets the same variables explicitly.
@abruption
abruption merged commit ab30762 into main Oct 3, 2026
12 checks passed
@abruption
abruption deleted the feat/74-sp branch October 3, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): add opt-in sp shorthand for the canonical CLI

1 participant