-
Notifications
You must be signed in to change notification settings - Fork 6
feat(cli): rename stash init --prisma-next to --prisma
#853
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| 'stash': patch | ||
| --- | ||
|
|
||
| `stash auth login` now accepts `--prisma`, bringing the integration referrer | ||
| flags to parity with `stash init`: `--supabase`, `--drizzle`, `--prisma`. A | ||
| multi-flag referrer is now ordered alphabetically, so it no longer depends on | ||
| argv order. | ||
|
|
||
| This closes a documentation/implementation gap: the bundled `stash-cli` skill | ||
| listed `--prisma` among `auth login`'s referrer flags, but the command did not | ||
| register it — and because the CLI's argument parser does not reject unknown | ||
| flags, `stash auth login --prisma` was silently dropped rather than erroring. | ||
|
|
||
| The `stash-cli` skill also now records that `init` writes no encryption-client | ||
| placeholder for Prisma Next, which derives its schemas from `contract.json` — | ||
| previously the scaffold step and the generated-file table both claimed the file | ||
| was always written. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| 'stash': minor | ||
| --- | ||
|
|
||
| `stash init` now takes `--prisma`, the Prisma Next setup flag, replacing | ||
| `--prisma-next`. This makes the integration flags consistent — `--supabase`, | ||
| `--drizzle`, `--prisma` — and matches how `--supabase` is used for referrer | ||
| tracking. `--prisma` selects the same Prisma Next flow (EQL bundle installed via | ||
| `prisma-next migrate`, no encryption-client scaffold) and records `prisma` as the | ||
| referrer. | ||
|
|
||
| **Breaking:** `stash init --prisma-next` is no longer recognized. Init errors with | ||
| guidance to re-run with `--prisma`. The bundled `stash-cli` skill is updated to | ||
| document the new flag. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,27 @@ describe('initCommand — region threading', () => { | |
| }) | ||
| }) | ||
|
|
||
| describe('initCommand — integration flags', () => { | ||
| it('selects the Prisma provider (name `prisma`) for `--prisma`', async () => { | ||
| await initCommand({ prisma: true }, {}) | ||
|
|
||
| expect(authRun).toHaveBeenCalledTimes(1) | ||
| // Steps receive the resolved provider as their second argument; `--prisma` | ||
| // must resolve to the Prisma Next provider whose referrer name is `prisma`. | ||
| const providerArg = authRun.mock.calls[0][1] as { name?: string } | ||
| expect(providerArg.name).toBe('prisma') | ||
| }) | ||
|
|
||
| it('errors on the renamed `--prisma-next` flag before running any step', async () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: this calls It is reachable, for what it's worth: |
||
| // `--prisma-next` was renamed to `--prisma`; init must fail loudly with | ||
| // guidance rather than silently ignore a previously-documented flag. | ||
| await expect( | ||
| initCommand({ 'prisma-next': true }, {}), | ||
| ).rejects.toBeInstanceOf(CliExit) | ||
| expect(authRun).not.toHaveBeenCalled() | ||
| }) | ||
| }) | ||
|
|
||
| describe('initCommand — honest summary', () => { | ||
| it('exits non-zero and reports "Setup incomplete" when EQL was not installed', async () => { | ||
| eqlRun.mockImplementationOnce(async (s: InitState) => ({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -32,8 +32,9 @@ Do **not** trigger when: | |||||
| The entry point, for humans and agents alike: | ||||||
|
|
||||||
| ```bash | ||||||
| npx stash init # PostgreSQL / Drizzle / Prisma | ||||||
| npx stash init # PostgreSQL / Drizzle / Prisma (auto-detected) | ||||||
| npx stash init --supabase # Supabase | ||||||
| npx stash init --prisma # Prisma Next | ||||||
| ``` | ||||||
|
|
||||||
| `stash init` installs the CLI as a project dev dependency, so subsequent commands can drop the `npx`. The CLI is package-manager aware — before init, use whichever one-shot runner your project uses (`npx`, `pnpm dlx`, `bunx`, `yarn dlx`). Installs are **pinned to the exact `@cipherstash/*` versions this CLI release shipped with** (never bare dist-tags, which can lag behind a release), and init flags any already-installed `@cipherstash/*` package whose resolved version differs from the release's. The fix depends on direction, and init says which applies: an **older** install should be aligned to the release (init offers the exact command); a **newer** install must NOT be downgraded — update the `stash` CLI to the matching release instead (init prints that command too). **Non-interactively, an older ("behind") skew is fatal** — init refuses with a non-zero exit and the align command rather than scaffolding against mismatched packages and reporting a false success. Interactively it offers to align. Likewise, if the EQL extension isn't installed at the end, init reports **"Setup incomplete"** and exits non-zero — it never claims a setup is complete when encryption would fail at query time. Integrations that install EQL through a migration are the exception and exit 0: **Prisma Next** installs it via the top-level `prisma-next migrate`, and the **Drizzle** flow *generates* an EQL migration, which init reports honestly as "EQL migration generated — apply it with `drizzle-kit migrate`" rather than claiming the extension is already installed. | ||||||
|
|
@@ -100,7 +101,7 @@ The working loop is: | |||||
|
|
||||||
| **Authenticate before `stash init`.** Init's authenticate step uses the interactive path, so an agent running `init` unauthenticated makes the CLI try to open a browser on the agent's machine — and in a non-TTY it exits with `region_required` unless `--region` or `STASH_REGION` is set. Once a valid token exists, init logs `Using workspace X (region)` and moves on silently. | ||||||
|
|
||||||
| Flags: `--region <slug>` (env `STASH_REGION`), `--json`, `--no-open`, `--supabase` / `--drizzle` (referrer tracking only). | ||||||
| Flags: `--region <slug>` (env `STASH_REGION`), `--json`, `--no-open`, `--supabase` / `--drizzle` / `--prisma` (referrer tracking only). | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove "(referrer tracking only)" from this text.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This documents This line sits under the Against the shipped manifest:
It fails silently, which is the worst part: Two ways to fix, depending on intent:
This is what the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed on this branch in f90389c — pushed here rather than as a follow-up PR, at Dan's request. Took the second option: Manifest now agrees: Also made the referrer parts alphabetical, so a multi-flag referrer no longer depends on argv order. Two tests added in One caveat worth knowing: referrer tracking on |
||||||
|
|
||||||
| ## Never read these | ||||||
|
|
||||||
|
|
@@ -219,16 +220,16 @@ Six mechanical steps, no agent handoff. It prompts only when it can't pick a sen | |||||
|
|
||||||
| 1. **Authenticate** — silent when a valid token exists. | ||||||
| 2. **Resolve database** — per the resolution order above; verifies the connection. | ||||||
| 3. **Build schema** — auto-detects Drizzle, Supabase, and Prisma Next and writes the placeholder encryption client. | ||||||
| 3. **Build schema** — auto-detects Drizzle, Supabase, and Prisma Next and writes the placeholder encryption client. **Prisma Next is the exception:** it derives schemas from `contract.json`, so no encryption-client file is written and none is needed. | ||||||
| 4. **Install dependencies** — one combined prompt for `@cipherstash/stack` and `stash`. | ||||||
| 5. **Install EQL** — always EQL v3. Drizzle generates `eql migration --drizzle`; Prisma Next installs through `prisma-next migrate`; other integrations install directly. | ||||||
| 6. **Gather context** — detects available coding agents and writes `.cipherstash/context.json`. | ||||||
|
|
||||||
| Flags: `--supabase`, `--drizzle`, `--prisma-next`, `--region <slug>`. | ||||||
| Flags: `--supabase`, `--drizzle`, `--prisma`, `--region <slug>`. | ||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||
|
|
||||||
| | Generated file | Purpose | | ||||||
| |---|---| | ||||||
| | `./src/encryption/index.ts` | Placeholder encryption client — declare encrypted columns here, or let `plan`/`impl` do it | | ||||||
| | `./src/encryption/index.ts` | Placeholder encryption client — declare encrypted columns here, or let `plan`/`impl` do it. **Not written for Prisma Next** (`--prisma`), which derives schemas from `contract.json` | | ||||||
| | `.cipherstash/context.json` | Detected facts: integration, package manager, schemas, env key names, and agents. CLI-owned; never hand-edit | | ||||||
| | `stash.config.ts` | Scaffolded if missing | | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.