spike(npm): prototype npx stash proxy distribution - #398
Open
coderdan wants to merge 7 commits into
Open
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
freshtonic
force-pushed
the
dan/cli-connection-flags
branch
from
August 18, 2026 06:46
c928bdf to
fde3ad2
Compare
Proof-of-concept for shipping the proxy via npm as `npx stash proxy`, using the esbuild/Biome/SWC pattern (per-platform packages + os/cpu-filtered optionalDependencies + a thin JS launcher) -- NOT native N-API bindings, since proxy is a standalone server we only need to distribute and launch. Verified end-to-end locally on darwin-arm64: npx -> stash shim -> exec native cipherstash-proxy binary, with --version/--help passthrough, correct exit-code forwarding (0 / clap's 2), signal forwarding, and os/cpu platform resolution. Binaries are git-ignored build artifacts (build-binaries.sh / demo.sh regenerate them). Packages are private + 0.0.0-prototype to prevent publish. See npm/README.md for how this maps to a production CI matrix and the code-signing rationale (skips notarization/Developer-ID; keeps free ad-hoc signing on Apple Silicon). Signed-off-by: James Sadler <james@cipherstash.com>
Signed-off-by: James Sadler <james@cipherstash.com>
`stash proxy --psql ...` starts the proxy, waits for it to report its listen address (parsing the OS-assigned port when the default is in use), then launches psql connected to the proxy with the target db/user/password. psql is the foreground session; the proxy is torn down when it exits. Falls back with a clear message if psql is not on PATH. Connection details are taken from --database-url, then --db-* flags, then CS_DATABASE__* env. Validated against a local dev DB. Signed-off-by: James Sadler <james@cipherstash.com>
When `--psql` is used and psql isn't on PATH (or STASH_USE_BUILTIN_SQL=1 is set), open a small built-in SQL shell (lib/repl.js) instead of failing. It uses the pure-JS `pg` driver (no native binaries) and runs SQL through the proxy with tabular output and a few meta-commands (\l, \dt, \d, \?, \q). Not a psql replacement -- a convenience fallback. Real psql is still preferred when installed. Validated end-to-end against a local dev DB via the proxy. Background: bundling real psql isn't viable off-the-shelf -- the @embedded-postgres/* packages ship initdb/pg_ctl/postgres but strip psql -- so a pure-JS shell is the pragmatic no-native-deps fallback. Signed-off-by: James Sadler <james@cipherstash.com>
Visually distinguishes a via-proxy session from a direct psql connection: the prompt becomes e.g. `stash:mydb=>` with "stash" in cyan (on a TTY). Applied to both real psql (via PROMPT1/PROMPT2 --set) and the built-in shell. Override with STASH_PSQL_PROMPT (set empty to use psql's default / ~/.psqlrc); colour honours NO_COLOR and is disabled off a TTY. Signed-off-by: James Sadler <james@cipherstash.com>
A literal ESC byte in PROMPT1 was stripped by psql's variable parser, so the prompt showed in the default colour. psql's own %033 octal escape produces the ESC reliably (verified: \001 ESC[36m \002 stash \001 ESC[0m \002 -- 'stash' wrapped in cyan). Signed-off-by: James Sadler <james@cipherstash.com>
Signed-off-by: James Sadler <james@cipherstash.com>
freshtonic
force-pushed
the
dan/npx-stash-proxy-prototype
branch
from
August 18, 2026 07:06
59bed52 to
6f82ea5
Compare
npx stash proxynpx stash proxy distribution
freshtonic
marked this pull request as ready for review
August 18, 2026 12:19
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.
Prototypes distributing CipherStash Proxy through npm so it can be launched with:
Distribution design
stashmeta package resolves and launches the correct prebuilt Proxy binary while forwarding argv, stdio, exit status, and common termination signals.os/cpu-filtered optional platform packages cover macOS and Linux on arm64 and x64.npm/build-binaries.shbuilds and stages the current host binary.npm/release-workflow.example.ymlsketches a four-target build/publish matrix, including a working Linux arm64crosssetup.--psqlworkflowpsql, or a pure-JavaScript SQL shell whenpsqlis unavailable.stash:<db>=>prompt on interactive terminals.--flag=valueforms, positional database name, and environment fallbacks using the same CLI-over-URL-over-environment precedence as Proxy.Review fixes
set -eno longer terminates it prematurely.SIGQUITforwarding.Validation
node --checkfor all launcher modules.npm test: 3/3 connection-propagation tests pass.bash -n npm/build-binaries.sh npm/demo.sh.npm pack --dry-runfor the meta package and all four platform packages.npxversion/help passthrough, and exit-code validation.Status / decision
This remains a non-publishable prototype: packages are private and versioned
0.0.0-prototype; no release workflow is active and no platform package has been published.