From 3e2937c8f98a164ac3808238825cd03c6779cc85 Mon Sep 17 00:00:00 2001 From: Dan Draper Date: Tue, 24 Nov 2026 12:56:32 +1100 Subject: [PATCH 1/6] docs(skills): an agent starts the device login itself when credentials are missing --- .../skills-agent-starts-device-login.md | 9 ++++++++ skills/stash-auth/SKILL.md | 8 ++++++- skills/stash-cli/SKILL.md | 21 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 .changeset/skills-agent-starts-device-login.md diff --git a/.changeset/skills-agent-starts-device-login.md b/.changeset/skills-agent-starts-device-login.md new file mode 100644 index 0000000000..ef8e583d59 --- /dev/null +++ b/.changeset/skills-agent-starts-device-login.md @@ -0,0 +1,9 @@ +--- +"stash": patch +--- + +The `stash-cli` and `stash-auth` skills now tell an agent to start +`stash auth login --json` itself when local work stops on missing +credentials, and to show the user the approval URL, rather than stop, ask for +`CS_*` values, or run `stash env`. They also say how to choose `--region` +instead of guessing it. diff --git a/skills/stash-auth/SKILL.md b/skills/stash-auth/SKILL.md index a2ea408b55..43cfa834ba 100644 --- a/skills/stash-auth/SKILL.md +++ b/skills/stash-auth/SKILL.md @@ -479,7 +479,13 @@ client-side strategy model applies to apps behind the Proxy. ## Quick diagnosis 1. **`NOT_AUTHENTICATED` locally** → `npx stash auth login` (dev profile), - or export the four `CS_*` variables. With `@cipherstash/auth`'s + or export the four `CS_*` variables. An agent starts the login itself: + `npx stash auth login --json --region ` in the background, then + show the user the `verificationUriComplete` URL it prints and wait for + `device_bound` (the loop, and how to pick the region, are in `stash-cli` + under Authentication). The same goes for an SDK in any language that + reports no credentials or no client key. Never run `stash env` to get + local credentials: it mints a new access key. With `@cipherstash/auth`'s `AutoStrategy` and `CS_WORKSPACE_CRN` set, log in to that workspace, or unset it; the default client follows the CLI's current workspace. 2. **Works locally, 401 in CI/production** → the deployed environment lacks diff --git a/skills/stash-cli/SKILL.md b/skills/stash-cli/SKILL.md index 4ea65c39ca..f1adcb2b4c 100644 --- a/skills/stash-cli/SKILL.md +++ b/skills/stash-cli/SKILL.md @@ -100,6 +100,27 @@ The working loop is: 4. To confirm, trust the event stream or run any authenticated command — never inspect `~/.cipherstash` (see "Never read these"). +**When to start it.** Start this loop yourself whenever local work stops on +missing credentials. That includes a `stash` command, a test, or an SDK in any +language (TypeScript, Rust, Go) reporting `NOT_AUTHENTICATED`, "no +credentials", "no client key", or "run `stash auth login`". It also includes a +profile that exists but has no key for the current workspace: a login fixes +that too. Do not stop the task to hand the problem back. Do not ask the user +to paste `CS_*` values. And do not run `stash env` to get local credentials, +because it mints a new access key each time it runs. The user only has to +open one link. + +**Choose the region; do not guess it.** Without a terminal, `auth login` +needs `--region` (or `STASH_REGION`), and exits with "Cannot resolve a region +without a prompt" if it has neither. A workspace lives in one region: + +- If a `CS_WORKSPACE_CRN` is in view, use the region it names + (`crn:.:`). +- Otherwise ask the user, offering the slugs from + `npx stash auth regions --json`. + +A login in another region does not reach a workspace in this one. + **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 ` (env `STASH_REGION`), `--json`, `--no-open`, `--supabase` / `--drizzle` / `--prisma` (referrer tracking only). From 563399e8573a715d8834b96f41058c8c98f6fa96 Mon Sep 17 00:00:00 2001 From: Dan Draper Date: Tue, 24 Nov 2026 23:14:54 +1100 Subject: [PATCH 2/6] docs(skills): name every case that needs --region, the workspace to approve, and Node Review of #1782: - auth login refuses to prompt for a region under --json and with CI set, as well as without a terminal. - A login gives a key for the workspace the user approves in the browser, and the command cannot choose it. The agent now tells the user which workspace to approve (the one the error names, or the one in CS_WORKSPACE_CRN) and runs the failing command again afterwards. - stash is a Node CLI (Node 22 or later). Where there is none, the agent says so and asks the user to install it or log in there themselves. --- skills/stash-auth/SKILL.md | 6 ++++-- skills/stash-cli/SKILL.md | 27 ++++++++++++++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/skills/stash-auth/SKILL.md b/skills/stash-auth/SKILL.md index 43cfa834ba..0194d52f7f 100644 --- a/skills/stash-auth/SKILL.md +++ b/skills/stash-auth/SKILL.md @@ -484,8 +484,10 @@ client-side strategy model applies to apps behind the Proxy. show the user the `verificationUriComplete` URL it prints and wait for `device_bound` (the loop, and how to pick the region, are in `stash-cli` under Authentication). The same goes for an SDK in any language that - reports no credentials or no client key. Never run `stash env` to get - local credentials: it mints a new access key. With `@cipherstash/auth`'s + reports no credentials or no client key. The CLI needs Node 22 or later; + where there is none, ask the user to install it or to log in there + themselves. Never run `stash env` to get local credentials: it mints a + new access key. With `@cipherstash/auth`'s `AutoStrategy` and `CS_WORKSPACE_CRN` set, log in to that workspace, or unset it; the default client follows the CLI's current workspace. 2. **Works locally, 401 in CI/production** → the deployed environment lacks diff --git a/skills/stash-cli/SKILL.md b/skills/stash-cli/SKILL.md index f1adcb2b4c..7cdd3a43d4 100644 --- a/skills/stash-cli/SKILL.md +++ b/skills/stash-cli/SKILL.md @@ -104,15 +104,24 @@ The working loop is: missing credentials. That includes a `stash` command, a test, or an SDK in any language (TypeScript, Rust, Go) reporting `NOT_AUTHENTICATED`, "no credentials", "no client key", or "run `stash auth login`". It also includes a -profile that exists but has no key for the current workspace: a login fixes -that too. Do not stop the task to hand the problem back. Do not ask the user -to paste `CS_*` values. And do not run `stash env` to get local credentials, -because it mints a new access key each time it runs. The user only has to -open one link. - -**Choose the region; do not guess it.** Without a terminal, `auth login` -needs `--region` (or `STASH_REGION`), and exits with "Cannot resolve a region -without a prompt" if it has neither. A workspace lives in one region: +profile that exists but has no key for the workspace the code uses. A login +gives a key for the workspace the user approves in the browser, and the +command has no flag to choose it. So tell the user which workspace to +approve: the one the error names, or the one in `CS_WORKSPACE_CRN`. After +`device_bound`, run the failing command again to confirm it works. Do not +stop the task to hand the problem back. Do not ask the user to paste `CS_*` +values. And do not run `stash env` to get local credentials, because it mints +a new access key each time it runs. The user only has to open one link. + +`stash` is a Node CLI, and needs Node 22 or later. If `npx` is not available +where the code runs (a sandbox for a Go or Rust service, say), say so, and ask +the user to install Node there or to run `stash auth login` in that +environment themselves. + +**Choose the region; do not guess it.** With `--json`, without a terminal, or +with `CI` set, `auth login` needs `--region` (or `STASH_REGION`), and exits +with "Cannot resolve a region without a prompt" if it has neither. A workspace +lives in one region: - If a `CS_WORKSPACE_CRN` is in view, use the region it names (`crn:.:`). From 9b1d650f2a7a381ee6e117596b91b9d405f5bb8f Mon Sep 17 00:00:00 2001 From: Dan Draper Date: Tue, 24 Nov 2026 23:20:53 +1100 Subject: [PATCH 3/6] docs(skills): a wasm-inline client is not fixed by a login Review of #1782: @cipherstash/stack/wasm-inline never reads the profile and takes clientId and clientKey in its config, so starting a device login for its missing client key does nothing. Both skills now except it from the start-a-login advice and point at stash-edge. --- skills/stash-auth/SKILL.md | 5 ++++- skills/stash-cli/SKILL.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/skills/stash-auth/SKILL.md b/skills/stash-auth/SKILL.md index 0194d52f7f..a3dcb995ee 100644 --- a/skills/stash-auth/SKILL.md +++ b/skills/stash-auth/SKILL.md @@ -484,7 +484,10 @@ client-side strategy model applies to apps behind the Proxy. show the user the `verificationUriComplete` URL it prints and wait for `device_bound` (the loop, and how to pick the region, are in `stash-cli` under Authentication). The same goes for an SDK in any language that - reports no credentials or no client key. The CLI needs Node 22 or later; + reports no credentials or no client key, except + `@cipherstash/stack/wasm-inline`: it never reads the profile, so a login + does not help it, and it needs `clientId` and `clientKey` in its config + (see `stash-edge`). The CLI needs Node 22 or later; where there is none, ask the user to install it or to log in there themselves. Never run `stash env` to get local credentials: it mints a new access key. With `@cipherstash/auth`'s diff --git a/skills/stash-cli/SKILL.md b/skills/stash-cli/SKILL.md index 7cdd3a43d4..e0d9385429 100644 --- a/skills/stash-cli/SKILL.md +++ b/skills/stash-cli/SKILL.md @@ -103,7 +103,10 @@ The working loop is: **When to start it.** Start this loop yourself whenever local work stops on missing credentials. That includes a `stash` command, a test, or an SDK in any language (TypeScript, Rust, Go) reporting `NOT_AUTHENTICATED`, "no -credentials", "no client key", or "run `stash auth login`". It also includes a +credentials", "no client key", or "run `stash auth login`", except a client +built from `@cipherstash/stack/wasm-inline`. That one never reads the profile, +so a login does not help it: it needs `clientId` and `clientKey` in its config +(see `stash-edge`). It also includes a profile that exists but has no key for the workspace the code uses. A login gives a key for the workspace the user approves in the browser, and the command has no flag to choose it. So tell the user which workspace to From 470420a2e07b5e22ac690c37d6e8d89e75ffecb1 Mon Sep 17 00:00:00 2001 From: Dan Draper Date: Sun, 29 Nov 2026 02:39:17 +1100 Subject: [PATCH 4/6] docs(skills): give stash-auth the region and workspace steps of the login The quick diagnosis in stash-auth sent the agent to stash-cli for how to choose the region. A skill can be inlined on its own, so stash-auth now says it in full: take the region from CS_WORKSPACE_CRN or ask the user, tell the user which workspace to approve, and run the failing command again after device_bound. The steps are a list, so the item is easier to follow. stash-cli now says which values of CI make auth login need --region: CI=true or CI=1, the values the CLI checks. --- skills/stash-auth/SKILL.md | 39 +++++++++++++++++++++++++------------- skills/stash-cli/SKILL.md | 6 +++--- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/skills/stash-auth/SKILL.md b/skills/stash-auth/SKILL.md index a3dcb995ee..fddcc3ec09 100644 --- a/skills/stash-auth/SKILL.md +++ b/skills/stash-auth/SKILL.md @@ -480,19 +480,32 @@ client-side strategy model applies to apps behind the Proxy. 1. **`NOT_AUTHENTICATED` locally** → `npx stash auth login` (dev profile), or export the four `CS_*` variables. An agent starts the login itself: - `npx stash auth login --json --region ` in the background, then - show the user the `verificationUriComplete` URL it prints and wait for - `device_bound` (the loop, and how to pick the region, are in `stash-cli` - under Authentication). The same goes for an SDK in any language that - reports no credentials or no client key, except - `@cipherstash/stack/wasm-inline`: it never reads the profile, so a login - does not help it, and it needs `clientId` and `clientKey` in its config - (see `stash-edge`). The CLI needs Node 22 or later; - where there is none, ask the user to install it or to log in there - themselves. Never run `stash env` to get local credentials: it mints a - new access key. With `@cipherstash/auth`'s - `AutoStrategy` and `CS_WORKSPACE_CRN` set, log in to that workspace, or - unset it; the default client follows the CLI's current workspace. + + - Run `npx stash auth login --json --region ` in the background. + Show the user the `verificationUriComplete` URL it prints, and wait for + `device_bound`. + - Do not guess the region. Take it from `CS_WORKSPACE_CRN` + (`crn:.:`) when one is set. Otherwise + ask the user, offering the slugs from `npx stash auth regions --json`. + - The login gives a key for the workspace the user approves in the + browser. Tell them which one to approve: the one the error names, or + the one in `CS_WORKSPACE_CRN`. + - After `device_bound`, run the failing command again to confirm it + works. + + The full loop is in `stash-cli` under Authentication. Do the same for an + SDK in any language that reports no credentials or no client key, except + `@cipherstash/stack/wasm-inline`. That client never reads the profile, so + a login does not help it: it needs `clientId` and `clientKey` in its + config (see `stash-edge`). + + The CLI needs Node 22 or later. Where there is none, ask the user to + install it or to log in there themselves. Never run `stash env` to get + local credentials: it mints a new access key. + + With `@cipherstash/auth`'s `AutoStrategy` and `CS_WORKSPACE_CRN` set, log + in to that workspace, or unset it. The default client follows the CLI's + current workspace. 2. **Works locally, 401 in CI/production** → the deployed environment lacks the `CS_*` variables, or they're from the wrong workspace — mint with `stash env`, compare `CS_WORKSPACE_CRN`. diff --git a/skills/stash-cli/SKILL.md b/skills/stash-cli/SKILL.md index e0d9385429..ec7d78cab5 100644 --- a/skills/stash-cli/SKILL.md +++ b/skills/stash-cli/SKILL.md @@ -122,9 +122,9 @@ the user to install Node there or to run `stash auth login` in that environment themselves. **Choose the region; do not guess it.** With `--json`, without a terminal, or -with `CI` set, `auth login` needs `--region` (or `STASH_REGION`), and exits -with "Cannot resolve a region without a prompt" if it has neither. A workspace -lives in one region: +with `CI=true` (or `CI=1`), `auth login` needs `--region` (or +`STASH_REGION`). Without either, it exits with "Cannot resolve a region +without a prompt". A workspace lives in one region: - If a `CS_WORKSPACE_CRN` is in view, use the region it names (`crn:.:`). From dc698d135bc3e420eeddd7963fed2831b108e0d7 Mon Sep 17 00:00:00 2001 From: Dan Draper Date: Sun, 29 Nov 2026 05:02:51 +1100 Subject: [PATCH 5/6] docs(skills): show the login code, and ask for the workspace when nothing names it The stash-auth quick diagnosis is inlined without stash-cli for some editors, so it has to be complete on its own. It now tells the agent to show the user the code with the approval link. The code lets the user check that the approval page is the one the agent started. When neither the error nor CS_WORKSPACE_CRN names a workspace, the agent now asks the user which one the project uses before they approve. --- skills/stash-auth/SKILL.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/skills/stash-auth/SKILL.md b/skills/stash-auth/SKILL.md index fddcc3ec09..4b0d5917d3 100644 --- a/skills/stash-auth/SKILL.md +++ b/skills/stash-auth/SKILL.md @@ -482,14 +482,16 @@ client-side strategy model applies to apps behind the Proxy. or export the four `CS_*` variables. An agent starts the login itself: - Run `npx stash auth login --json --region ` in the background. - Show the user the `verificationUriComplete` URL it prints, and wait for - `device_bound`. + Show the user the `verificationUriComplete` URL and the `userCode` it + prints, and wait for `device_bound`. The code lets the user check that + the approval page is the one you started. - Do not guess the region. Take it from `CS_WORKSPACE_CRN` (`crn:.:`) when one is set. Otherwise ask the user, offering the slugs from `npx stash auth regions --json`. - The login gives a key for the workspace the user approves in the browser. Tell them which one to approve: the one the error names, or - the one in `CS_WORKSPACE_CRN`. + the one in `CS_WORKSPACE_CRN`. If neither names a workspace, ask the + user which workspace the project uses before they approve. - After `device_bound`, run the failing command again to confirm it works. From e1ade7eae0c902853cf4049025b4bd5b235d6861 Mon Sep 17 00:00:00 2001 From: Dan Draper Date: Sun, 29 Nov 2026 05:08:27 +1100 Subject: [PATCH 6/6] docs(skills): say what to do when the agent's login fails or expires The stash-auth quick diagnosis told the agent only to wait for device_bound. A login can also end with an error event, or exit when its code expires after about 15 minutes. The agent now shows the user the message and hint, then starts the login again with a new code. --- skills/stash-auth/SKILL.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skills/stash-auth/SKILL.md b/skills/stash-auth/SKILL.md index 4b0d5917d3..5b46d8b82c 100644 --- a/skills/stash-auth/SKILL.md +++ b/skills/stash-auth/SKILL.md @@ -485,6 +485,10 @@ client-side strategy model applies to apps behind the Proxy. Show the user the `verificationUriComplete` URL and the `userCode` it prints, and wait for `device_bound`. The code lets the user check that the approval page is the one you started. + - The code expires after about 15 minutes. If the process prints + `{ "status": "error", ... }` or exits without `device_bound`, show the + user its `message` and `hint`. Then start the login again, with a new + code. - Do not guess the region. Take it from `CS_WORKSPACE_CRN` (`crn:.:`) when one is set. Otherwise ask the user, offering the slugs from `npx stash auth regions --json`.