Skip to content

Commit aeaaf22

Browse files
Version Packages
1 parent d732f27 commit aeaaf22

17 files changed

Lines changed: 141 additions & 108 deletions

.changeset/cli-init-agent-handoff.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

.changeset/cli-runner-aware-help-banners.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

.changeset/cli-stash-wizard-subcommand.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

.changeset/encryption-migrations.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

.changeset/package-manager-aware-output.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/cli/CHANGELOG.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,96 @@
11
# @cipherstash/cli
22

3+
## 0.12.0
4+
5+
### Minor Changes
6+
7+
- f315334: `stash init` can now hand off the rest of setup to whichever coding agent the user is set up with — and it leaves them with a project-specific action plan and the right reference material, not just generic rules.
8+
9+
The new pipeline:
10+
11+
1. **Authenticate** (unchanged).
12+
2. **Resolve `DATABASE_URL`** — uses the same resolver as `stash db install` (flag → env → `supabase status` → interactive prompt). Hard-fails with an actionable message if nothing resolves.
13+
3. **Build the encryption client.** When the database has tables, `init` introspects them and generates a real client from the user's selection. When the database is empty, it falls back to a placeholder so fresh projects still work — and the action prompt notes the placeholder so the agent reshapes it later.
14+
4. **Install dependencies**`@cipherstash/stack` (runtime) + `stash` (CLI dev dep).
15+
5. **Install EQL into the database** — y/N confirm, then runs `stash db install` programmatically against the URL we already resolved. No second prompt for credentials.
16+
6. **Pick a handoff** from the four-option menu. Each handoff installs the right artifacts for the chosen tool:
17+
- **Hand off to Claude Code** — copies the per-integration set of authored skills (`stash-encryption` + `stash-<integration>` + `stash-cli`) into `.claude/skills/`, writes `.cipherstash/context.json` and `.cipherstash/setup-prompt.md`, spawns `claude`. Default when `claude` is on PATH.
18+
- **Hand off to Codex** — writes a sentinel-managed `AGENTS.md` (durable doctrine) + copies the same skills into `.codex/skills/` (procedural workflows), writes `context.json` + `setup-prompt.md`, spawns `codex`. Default when `codex` is on PATH and `claude` is not. Follows OpenAI's Codex guidance: AGENTS.md for repo doctrine, skills for repeatable workflows.
19+
- **Use the CipherStash Agent** — writes `context.json` and runs `stash wizard`. Fallback for users without a local CLI agent. The wizard installs its own skills.
20+
- **Write AGENTS.md** — for editor agents (Cursor, Windsurf, Cline) that don't auto-load skill directories. Writes a single `AGENTS.md` with the doctrine _plus_ the relevant skill content inlined under a sentinel block, so the agent has the API details without needing to follow file references. Plus `context.json` + `setup-prompt.md`. No spawn.
21+
22+
Detection is non-blocking: if the chosen CLI agent (`claude` or `codex`) isn't installed, init still writes the artifacts and prints install + manual-launch instructions. Progress is never wasted.
23+
24+
`.cipherstash/setup-prompt.md` is the headline artifact. It's the project-specific action plan — _"init has done X and Y; you need to do Z next, with these exact commands and paths"_ — generated from the current init state. The launch prompt for Claude / Codex points the agent at this file first; the installed skills provide the reusable rulebook the prompt references. For IDE users, it's ready to paste into the first chat.
25+
26+
Per-integration skill subset:
27+
28+
```text
29+
drizzle → stash-encryption + stash-drizzle + stash-cli
30+
supabase → stash-encryption + stash-supabase + stash-cli
31+
postgresql → stash-encryption + stash-cli
32+
```
33+
34+
The skills themselves are the authored ones at the repo root (`/skills/`); they ship inside the CLI tarball via `tsup` so init can copy them locally without a network round-trip. The AGENTS.md doctrine fragment ships the same way.
35+
36+
Re-running `init` is safe — `AGENTS.md` uses sentinel-marker upsert (`<!-- cipherstash:rulebook start/end -->`), so the managed region is replaced in place and any user edits outside it are preserved. Skill directories are overwritten so the user always gets the latest content. `setup-prompt.md` is regenerated wholesale each run since it's meant to reflect the current state.
37+
38+
`.cipherstash/context.json` is the universal "what shape is this project" payload — integration, encryption client path, schema, env key names (never values), package manager, install command, CLI version, names of installed skills, generation timestamp.
39+
40+
- ce70b4d: Add `stash wizard` as a thin wrapper subcommand around `@cipherstash/wizard`.
41+
42+
The wizard ships as a separate npm package so the heavy agent SDK stays out of the `stash` CLI bundle. Until now, users had to remember a second tool name (`npx @cipherstash/wizard`); the wrapper exposes the same capability under the existing `stash` surface so the user only has to think about one CLI.
43+
44+
`stash wizard` detects the project's package manager and spawns the wizard via the matching one-shot runner — `npx`, `pnpm dlx`, `yarn dlx`, or `bunx` — with `stdio: 'inherit'` so the wizard owns the terminal cleanly. Any flags after `wizard` are forwarded verbatim, so `stash wizard --debug` works.
45+
46+
On a cold cache (the wizard package isn't installed in the project) the runner downloads it before launching — a few seconds. The wrapper prints an explicit "first run downloads ~5s" line in that case so the CLI doesn't appear hung. On a warm cache, just a "Launching the CipherStash wizard…" line, then the wizard takes over.
47+
48+
Existing copy that pointed at `npx @cipherstash/wizard` (init's next-steps for base / Drizzle / Supabase, `db install`'s post-install note) now uses `stash wizard`.
49+
50+
- add4357: Add `stash encrypt` command group and `@cipherstash/migrate` library for plaintext → encrypted column migrations.
51+
52+
New CLI commands:
53+
54+
- `stash encrypt status` — per-column migration status (phase, backfill progress, drift between intent and state, EQL registration).
55+
- `stash encrypt plan` — diff `.cipherstash/migrations.json` (intent) vs observed state.
56+
- `stash encrypt backfill --table <t> --column <c>` — resumable, idempotent, chunked encryption of plaintext into `<col>_encrypted`. Uses the user's encryption client (Protect/Stack). SIGINT-safe; re-run to resume. The first run on a column prompts to confirm dual-writes are deployed (or accept `--confirm-dual-writes-deployed` for non-interactive contexts), records the `dual_writing` transition in `cs_migrations`, then runs the chunked encryption loop. `--force` re-encrypts every plaintext row regardless of current state — recovery path for drift caused by an earlier backfill running before dual-writes were actually live.
57+
- `stash encrypt cutover --table <t> --column <c>` — runs `eql_v2.rename_encrypted_columns()` inside a transaction; optionally forces Proxy config refresh via `CIPHERSTASH_PROXY_URL`. After cutover, apps reading `<col>` transparently receive the encrypted column.
58+
- `stash encrypt drop --table <t> --column <c>` — generates a migration file that drops the old plaintext column.
59+
60+
`stash db install` now also installs a `cipherstash.cs_migrations` table used to track per-column migration runtime state (current phase, backfill cursor, rows processed). The table is append-only (event-log shape) and kept separate from `eql_v2_configuration` which remains the authoritative EQL intent store used by Proxy.
61+
62+
The new `@cipherstash/migrate` package exposes the same primitives as a library for users who want to embed backfill in their own workers or cron jobs — all commands are thin wrappers around its exports (`runBackfill`, `appendEvent`, `latestByColumn`, `progress`, `renameEncryptedColumns`, `reloadConfig`, `readManifest`, `writeManifest`).
63+
64+
### Patch Changes
65+
66+
- 39af183: Make `--help` banners and the post-install "Next steps" panel show commands using the package manager the user actually invoked the CLI with, instead of always emitting `npx`.
67+
68+
A user who runs `bunx @cipherstash/cli --help` now sees:
69+
70+
```
71+
Usage: bunx @cipherstash/cli <command> [options]
72+
73+
Examples:
74+
bunx @cipherstash/cli init
75+
bunx @cipherstash/cli auth login
76+
bunx @cipherstash/cli db install
77+
```
78+
79+
instead of `npx @cipherstash/cli …` regardless of how they invoked it. Same for `pnpm dlx`, `yarn dlx`, and the default `npx` path.
80+
81+
Concretely:
82+
83+
- `--help` (top-level) — usage line and all six examples in `bin/stash.ts`.
84+
- `--help` (auth) — usage line and the two `auth login` examples in `commands/auth/index.ts`.
85+
- `db install`'s "Next steps" note — the `wizard` invocation now matches the user's runner.
86+
- The `@cipherstash/stack is required for this command` hint shown by `requireStack` (when `db push`/`validate`/`schema build` are run before the runtime SDK is installed) now suggests the package manager's install command and the user's runner for the follow-up `init` invocation.
87+
88+
No public-API change. Detection sources unchanged from #379: `npm_config_user_agent` first, then lockfile, then `npx` fallback.
89+
90+
- a8dbb65: Render every user-facing CLI string and execute every shell-out under the detected package manager (`npx` / `bunx` / `pnpm dlx` / `yarn dlx`), completing the work started in #379. Affected surfaces: `@cipherstash/cli` top-level + `auth` + `env` help, `db install` Drizzle migration steps, `db migrate` not-implemented warning, the Supabase migration SQL header, the Supabase status fallback exec, the `@cipherstash/protect` `stash` Stricli help (set/get/list/delete), the `@cipherstash/wizard` usage line and agent command allowlist, and the `@cipherstash/drizzle` `generate-eql-migration` help + drizzle-kit invocation. A new `pnpm run lint:runners` lint runs in CI and fails on any reintroduction of a hardcoded runner literal.
91+
- Updated dependencies [add4357]
92+
- @cipherstash/migrate@0.2.0
93+
394
## 0.11.0
495

596
### Minor Changes

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stash",
3-
"version": "0.11.0",
3+
"version": "0.12.0",
44
"description": "CipherStash CLI — the one stash command for auth, init, encryption schema, database setup, and secrets.",
55
"license": "MIT",
66
"author": "CipherStash <hello@cipherstash.com>",

packages/drizzle/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @cipherstash/drizzle
22

3+
## 3.0.2
4+
5+
### Patch Changes
6+
7+
- a8dbb65: Render every user-facing CLI string and execute every shell-out under the detected package manager (`npx` / `bunx` / `pnpm dlx` / `yarn dlx`), completing the work started in #379. Affected surfaces: `@cipherstash/cli` top-level + `auth` + `env` help, `db install` Drizzle migration steps, `db migrate` not-implemented warning, the Supabase migration SQL header, the Supabase status fallback exec, the `@cipherstash/protect` `stash` Stricli help (set/get/list/delete), the `@cipherstash/wizard` usage line and agent command allowlist, and the `@cipherstash/drizzle` `generate-eql-migration` help + drizzle-kit invocation. A new `pnpm run lint:runners` lint runs in CI and fails on any reintroduction of a hardcoded runner literal.
8+
39
## 3.0.1
410

511
### Patch Changes

0 commit comments

Comments
 (0)