Skip to content

feat(cli): rename stash init --prisma-next to --prisma - #853

Merged
coderdan merged 3 commits into
mainfrom
james/cip-3691-add-prisma-option-to-npx-stash-init
Jul 30, 2026
Merged

feat(cli): rename stash init --prisma-next to --prisma#853
coderdan merged 3 commits into
mainfrom
james/cip-3691-add-prisma-option-to-npx-stash-init

Conversation

@freshtonic

@freshtonic freshtonic commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What & why

Closes CIP-3691. Adds stash init --prisma as the logical equivalent of --supabase — the canonical flag that selects the Prisma (Next) integration, making the integration flags consistent: --supabase, --drizzle, --prisma.

Per product direction, this replaces the old --prisma-next flag and tracks the referrer as "prisma".

Behaviour

  • stash init --prisma selects the same Prisma Next setup flow as before: EQL bundle installed via prisma-next migrate, schema derived from contract.json, no encryption-client scaffold.
  • provider.name (used for referrer tracking) is now 'prisma'. The internal Integration value stays 'prisma-next', so skill set (stash-prisma), adapter dependency (@cipherstash/stack-prisma), schema handling, and EQL-install skip are all unchanged.
  • Breaking: stash init --prisma-next is no longer recognized. Init now errors with guidance to re-run with --prisma (mirroring the retired---proxy pattern) rather than silently falling through to auto-detection.

Changes

  • providers/prisma.ts (renamed from prisma-next.ts): createPrismaProvider, name: 'prisma'
  • init/index.ts: PROVIDER_MAP key prisma; retirement error for --prisma-next
  • steps/build-schema.ts, steps/install-eql.ts: provider.name === 'prisma' checks
  • cli/registry.ts: init --prisma flag + example
  • skills/stash-cli/SKILL.md, skills/stash-prisma/SKILL.md: flag docs
  • Tests: renamed provider test + new coverage for flag selection, retirement error, and the prisma→prisma-next integration forcing

Verification

  • pnpm --filter stash build
  • stash manifest --json: init flags --supabase, --drizzle, --prisma, --region; no --prisma-next
  • Full stash test suite: 965 passed / 10 skipped ✅
  • Biome clean on changed files ✅
  • Changeset: stash: minor

Summary by CodeRabbit

  • New Features
    • Added --prisma support to stash init for Prisma Next setup, and expanded Prisma handling in stash auth login.
  • Breaking Changes
    • stash init --prisma-next is no longer recognized; it now errors with guidance to use --prisma.
  • Documentation
    • Updated stash-cli/stash-prisma docs and CLI examples to use --prisma, including Prisma Next “no placeholder encryption client” and “skip EQL install” guidance.
  • Tests
    • Added integration/unit test coverage for --prisma, referrer ordering, and deprecated-flag failure behavior.

Make the Prisma integration flag consistent with `--supabase` and
`--drizzle`. `stash init --prisma` selects the same Prisma Next setup
flow (EQL bundle installed via `prisma-next migrate`, schema derived
from contract.json, no encryption-client scaffold) and records `prisma`
as the referrer.

The internal `Integration` value stays `prisma-next`, so skill, adapter
dependency, schema, and EQL-install wiring are unchanged — only the
user-facing flag and `provider.name` change.

The removed `--prisma-next` flag now errors with guidance to re-run with
`--prisma` rather than silently falling through to auto-detection.

Updates the bundled stash-cli and stash-prisma skills and the command
registry to match.

CIP-3691
@freshtonic
freshtonic requested a review from a team as a code owner July 30, 2026 07:06
@freshtonic
freshtonic requested review from coderdan and tobyhede July 30, 2026 07:06
@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fae3df0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
stash Minor
@cipherstash/basic-example Patch
@cipherstash/e2e Patch
@cipherstash/stack Minor
@cipherstash/stack-drizzle Minor
@cipherstash/stack-supabase Minor
@cipherstash/stack-prisma Minor
@cipherstash/wizard Minor
@cipherstash/bench Patch
@cipherstash/migrate Patch
@cipherstash/test-kit Patch
@cipherstash/prisma-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a6460f0-f968-4d61-841a-78f6d5f1a9c4

📥 Commits

Reviewing files that changed from the base of the PR and between f90389c and fae3df0.

📒 Files selected for processing (3)
  • .changeset/auth-login-prisma-referrer.md
  • packages/cli/src/commands/auth/index.ts
  • skills/stash-cli/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli/src/commands/auth/index.ts

📝 Walkthrough

Walkthrough

stash init now uses --prisma for the Prisma Next setup flow, while the retired flag is rejected. Provider mapping, schema/EQL handling, auth referrer forwarding, tests, changesets, and skill documentation are updated.

Changes

Prisma CLI migration

Layer / File(s) Summary
CLI flag and provider contract
packages/cli/src/cli/registry.ts, packages/cli/src/commands/init/...
The CLI exposes --prisma, creates a provider named prisma, rejects --prisma-next, and updates provider tests.
Prisma Next initialization path
packages/cli/src/commands/init/steps/...
The prisma provider maps to prisma-next, skips schema scaffolding, and skips standard EQL installation; tests cover these behaviors.
Auth Prisma referrer forwarding
packages/cli/src/commands/auth/..., packages/cli/src/cli/registry.ts
auth login accepts --prisma and composes multiple referrers alphabetically, with forwarding tests.
Documentation and release metadata
.changeset/..., skills/stash-cli/SKILL.md, skills/stash-prisma/SKILL.md
Changesets and skill documentation replace --prisma-next references with --prisma and describe the updated flow.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant initCommand
  participant buildSchemaStep
  participant installEqlStep
  participant PrismaNextMigration
  User->>initCommand: stash init --prisma
  initCommand->>buildSchemaStep: run with provider prisma
  buildSchemaStep-->>initCommand: select prisma-next and skip schema scaffolding
  initCommand->>installEqlStep: run Prisma Next path
  installEqlStep-->>initCommand: skip standard EQL installation
  PrismaNextMigration->>PrismaNextMigration: install EQL via prisma-next migrate
Loading

Possibly related PRs

Suggested reviewers: calvinbrewer, auxesis, coderdan

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: renaming the stash init Prisma flag from --prisma-next to --prisma.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch james/cip-3691-add-prisma-option-to-npx-stash-init

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread skills/stash-cli/SKILL.md
**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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "(referrer tracking only)" from this text.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/commands/init/providers/prisma.ts`:
- Around line 4-14: Separate Prisma provider identity from its referrer name: in
packages/cli/src/commands/init/providers/prisma.ts:4-14 add a dedicated
provider/integration discriminator while retaining name: 'prisma'. In
packages/cli/src/commands/init/steps/build-schema.ts:64-66, use that
discriminator to force the 'prisma-next' integration, and in
packages/cli/src/commands/init/steps/install-eql.ts:49-53, use the resolved
Prisma Next discriminator when skipping standalone EQL installation.

In `@packages/cli/src/commands/init/steps/__tests__/build-schema.test.ts`:
- Line 87: Replace the type-erasing provider cast in build-schema.test.ts at
lines 87-87 with the real provider factory or a properly typed test double.
Apply the same typed construction in install-eql.test.ts at lines 119-119,
preserving the existing test behavior without adding undocumented type
assertions.

In `@skills/stash-cli/SKILL.md`:
- Line 228: Update the init — scaffold documentation to explicitly distinguish
the --prisma workflow: state that Prisma Next skips the encryption-client
placeholder and derives its schema from contract.json, and make the
./src/encryption/index.ts generated-file entry conditional or exclude it for
Prisma. Keep the standard scaffold behavior documented for non-Prisma options.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0dd9f5b7-63f8-42bd-9491-ae870829eab7

📥 Commits

Reviewing files that changed from the base of the PR and between c54f19c and f89dae2.

📒 Files selected for processing (12)
  • .changeset/cli-init-prisma-flag.md
  • packages/cli/src/cli/registry.ts
  • packages/cli/src/commands/init/__tests__/init-command.test.ts
  • packages/cli/src/commands/init/index.ts
  • packages/cli/src/commands/init/providers/__tests__/prisma.test.ts
  • packages/cli/src/commands/init/providers/prisma.ts
  • packages/cli/src/commands/init/steps/__tests__/build-schema.test.ts
  • packages/cli/src/commands/init/steps/__tests__/install-eql.test.ts
  • packages/cli/src/commands/init/steps/build-schema.ts
  • packages/cli/src/commands/init/steps/install-eql.ts
  • skills/stash-cli/SKILL.md
  • skills/stash-prisma/SKILL.md

Comment thread packages/cli/src/commands/init/providers/prisma.ts
Comment thread packages/cli/src/commands/init/steps/__tests__/build-schema.test.ts
Comment thread skills/stash-cli/SKILL.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes stash init’s Prisma integration flag by renaming --prisma-next to --prisma, aligning it with the existing --supabase / --drizzle naming and updating referrer tracking to "prisma" while keeping the internal integration identifier as prisma-next.

Changes:

  • Add stash init --prisma and wire it to the existing Prisma Next init flow (internally still prisma-next).
  • Make --prisma-next a hard error with guidance to re-run using --prisma.
  • Update shipped skills/docs plus unit tests and the CLI registry/manifest surface.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
skills/stash-prisma/SKILL.md Updates Prisma Next setup guidance to use npx stash init --prisma.
skills/stash-cli/SKILL.md Updates init examples and documented flags to include --prisma (and removes --prisma-next).
packages/cli/src/commands/init/steps/install-eql.ts Switches Prisma Next “skip EQL install” branching to the new provider.name === 'prisma' while preserving integration === 'prisma-next'.
packages/cli/src/commands/init/steps/build-schema.ts Forces internal integration to prisma-next when --prisma provider is selected, ensuring the same Prisma Next behavior as before.
packages/cli/src/commands/init/steps/tests/install-eql.test.ts Adds coverage ensuring --prisma correctly skips stash eql install.
packages/cli/src/commands/init/steps/tests/build-schema.test.ts Adds coverage ensuring --prisma forces prisma-next integration and skips scaffold generation.
packages/cli/src/commands/init/providers/prisma.ts Renames provider factory to createPrismaProvider() and changes provider.name to 'prisma' (referrer).
packages/cli/src/commands/init/providers/tests/prisma.test.ts Updates provider tests for the new factory/name and preserves next-steps expectations.
packages/cli/src/commands/init/index.ts Updates provider map key to prisma and introduces explicit retirement error for --prisma-next.
packages/cli/src/commands/init/tests/init-command.test.ts Adds coverage for selecting --prisma and rejecting --prisma-next before steps run.
packages/cli/src/cli/registry.ts Updates init examples and flags list to expose --prisma in stash manifest --json / help output.
.changeset/cli-init-prisma-flag.md Adds release notes for the new flag and breaking removal of --prisma-next.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread skills/stash-cli/SKILL.md
**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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Flags: `--region <slug>` (env `STASH_REGION`), `--json`, `--no-open`, `--supabase` / `--drizzle` / `--prisma` (referrer tracking only).
Flags: `--region <slug>` (env `STASH_REGION`), `--json`, `--no-open`, `--supabase` / `--drizzle` / `--prisma`.

@coderdan coderdan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude found a problem, posted as a comment. The auth command doesn't accept the --prisma option.

@coderdan coderdan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Light review. The core rename is clean and correctly threaded — one real defect in the skill, plus one test-coverage nit.

What I verified as correct

  • The retirement guard at init/index.ts:84-91 faithfully mirrors the --proxy retirement immediately above it, same flags[k] === true || Object.hasOwn(values, k) shape — so --prisma-next=false errors too, consistent with existing behaviour.
  • The guard runs before resolveProvider, so no step executes first.
  • All provider.name consumers are swept: build-schema.ts:64 and install-eql.ts:49 are the only two comparing against the Prisma name. authenticate.ts:60, install-deps.ts:167 and resolve-database.ts:26 are name-agnostic or Supabase-only.
  • resolveProvider's multi-flag path (index.ts:64, matchedKeys.sort().join('-')) already defeated the old === 'prisma-next' check before this PR, so --prisma --supabase behaves exactly as it did. No regression introduced.
  • No stale --prisma-next references outside the CHANGELOGs (correctly left as history) and the test name.
  • --prisma is already the spelling eql migration uses (main.ts:260), so the rename increases CLI-wide consistency rather than just init-local consistency.
  • Changeset present, stash: minor, breaking change called out.

Happy to push the skill fix if you'd rather not context-switch.

Comment thread skills/stash-cli/SKILL.md
**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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documents --prisma on auth login, which doesn't accept it.

This line sits under the auth login section, not init — the flags listed beside it (--region, --json, --no-open) are all auth login flags.

Against the shipped manifest:

init:       --supabase, --drizzle, --prisma, --region
auth login: --region, --json, --no-open, --supabase, --drizzle     <- no --prisma

registry.ts:284-286 confirms auth login has only --supabase and --drizzle referrer flags.

It fails silently, which is the worst part: parseArgs (main.ts:162-189) does no unknown-flag validation, so stash auth login --prisma won't error — the flag is just dropped and the referrer is never tracked. Since skills/ ships in the stash tarball and gets copied into customer repos, this lands as wrong guidance in someone else's project.

Two ways to fix, depending on intent:

  • revert this line to --supabase / --drizzle, or
  • add --prisma to auth login's registry flags if referrer parity across the three integrations is actually wanted (that'd match the spirit of the PR).

This is what the stash manifest --json check in AGENTS.md is for — worth running before merge.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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: --prisma is now registered on auth login and threaded through referrerFromFlags, at exact parity with --supabase / --drizzle. This line needed no edit — registering the flag is what made it true, so your wording stands.

Manifest now agrees:

init       : --supabase, --drizzle, --prisma, --region
auth login : --region, --json, --no-open, --supabase, --drizzle, --prisma

Also made the referrer parts alphabetical, so a multi-flag referrer no longer depends on argv order. Two tests added in auth/__tests__/index.test.ts; suite is 967 passed / 10 skipped, code:check exit 0. Changeset: stash patch.

One caveat worth knowing: referrer tracking on auth login is inert today. auth/login.ts:30 names the parameter _referrer and never reads it — the comment at line 41 explains why (client_id must be cli, anything else gives INVALID_CLIENT). So --supabase and --drizzle were already accepted, threaded, and discarded; --prisma now matches them exactly. That makes the flag surface honest, but the "(referrer tracking only)" parenthetical overpromises for all three. Reviving it needs the CTS side to take a referrer separate from client_id, so I left it out of scope.

expect(providerArg.name).toBe('prisma')
})

it('errors on the renamed `--prisma-next` flag before running any step', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this calls initCommand({ 'prisma-next': true }, {}) directly, so it bypasses parseArgs and doesn't prove the retirement message is reachable through the real CLI — which is the interesting risk now that --prisma-next is gone from the registry.

It is reachable, for what it's worth: parseArgs is permissive and main.ts:531 passes flags/values through wholesale, so stash init --prisma-next does hit the friendly error rather than a generic failure. That chain just isn't pinned anywhere. packages/cli/tests/e2e/ would be the natural home if you think it's worth a guard.

The bundled stash-cli skill lists `--prisma` among `auth login`'s referrer
flags, but the command never registered it. The CLI's argument parser does
not reject unknown flags, so `stash auth login --prisma` was silently
dropped rather than erroring — wrong guidance that failed quietly, in a
file that ships in the tarball and is copied into customer repos.

Registers the flag and threads it through `referrerFromFlags`, giving it
exact parity with `--supabase` / `--drizzle`. The referrer parts are now
ordered alphabetically so a multi-flag referrer no longer depends on argv
order.

Note: `login()` still names the parameter `_referrer` and discards it (the
OAuth client_id must be `cli`), so all three flags are inert downstream.
This change is parity and honesty about the flag surface, not a revival of
referrer tracking.

CIP-3691

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/commands/auth/index.ts`:
- Around line 37-40: Update the auth command’s HELP text to document the
--prisma option alongside --supabase and --drizzle, and add a corresponding
--prisma usage example. Keep the existing referrerFromFlags behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 35a011af-b0d1-4ab3-a9be-cc0f50aa64bf

📥 Commits

Reviewing files that changed from the base of the PR and between f89dae2 and f90389c.

📒 Files selected for processing (4)
  • .changeset/auth-login-prisma-referrer.md
  • packages/cli/src/cli/registry.ts
  • packages/cli/src/commands/auth/__tests__/index.test.ts
  • packages/cli/src/commands/auth/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli/src/cli/registry.ts

Comment thread packages/cli/src/commands/auth/index.ts
…ext scaffold exception

Two review findings from #853.

`auth --help` listed only `--supabase` and `--drizzle` under Options, so the
`--prisma` flag registered in the previous commit was undiscoverable from the
command itself.

The stash-cli skill's `init — scaffold` section claimed step 3 always writes
the placeholder encryption client, and listed `./src/encryption/index.ts`
unconditionally in the generated-file table. Prisma Next derives schemas from
`contract.json`, so `buildSchemaStep` writes nothing for it — the skill now
says so in both places.

CIP-3691

@coderdan coderdan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred any tracking work until after launch.

@coderdan
coderdan merged commit 7fdc30f into main Jul 30, 2026
10 checks passed
@coderdan
coderdan deleted the james/cip-3691-add-prisma-option-to-npx-stash-init branch July 30, 2026 09:46
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.

4 participants