@sanity/runtime-cli 17.4.0-blueprinit.g0ac8878 → 17.4.0-blueprinit.g596ac51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +50 -47
  2. package/SKILL.md +50 -12
  3. package/dist/actions/blueprinit/manifest.js +21 -15
  4. package/dist/actions/blueprints/pre-deploy.d.ts +15 -6
  5. package/dist/actions/blueprints/pre-deploy.js +29 -70
  6. package/dist/actions/blueprints/process-assets.d.ts +29 -0
  7. package/dist/actions/blueprints/process-assets.js +80 -0
  8. package/dist/commands/blueprints/deploy.js +3 -1
  9. package/dist/commands/blueprints/destroy.js +1 -1
  10. package/dist/commands/blueprints/info.d.ts +1 -0
  11. package/dist/commands/blueprints/info.js +5 -0
  12. package/dist/commands/blueprints/init.js +1 -2
  13. package/dist/commands/blueprints/logs.js +1 -0
  14. package/dist/commands/functions/add.js +3 -3
  15. package/dist/commands/functions/dev.js +2 -2
  16. package/dist/commands/functions/logs.d.ts +1 -1
  17. package/dist/commands/functions/logs.js +3 -0
  18. package/dist/cores/blueprints/deploy.js +69 -19
  19. package/dist/cores/functions/add.js +1 -1
  20. package/dist/utils/display/blueprints-formatting.js +3 -3
  21. package/dist/utils/style-text.js +1 -0
  22. package/oclif.manifest.json +21 -15
  23. package/package.json +27 -17
  24. package/skills/_functions-build.md +23 -0
  25. package/skills/_functions-list.md +28 -0
  26. package/skills/blueprints-add.md +8 -0
  27. package/skills/blueprints-config.md +33 -0
  28. package/skills/blueprints-deploy.md +36 -0
  29. package/skills/blueprints-destroy.md +30 -0
  30. package/skills/blueprints-doctor.md +31 -0
  31. package/skills/blueprints-info.md +23 -0
  32. package/skills/blueprints-init.md +48 -0
  33. package/skills/blueprints-logs.md +33 -0
  34. package/skills/blueprints-mint-deploy-token.md +25 -0
  35. package/skills/blueprints-plan.md +28 -0
  36. package/skills/blueprints-promote.md +31 -0
  37. package/skills/blueprints-stacks.md +28 -0
  38. package/skills/functions-add.md +35 -0
  39. package/skills/functions-dev.md +21 -0
  40. package/skills/functions-env-add.md +29 -0
  41. package/skills/functions-env-list.md +21 -0
  42. package/skills/functions-env-remove.md +22 -0
  43. package/skills/functions-logs.md +39 -0
  44. package/skills/functions-test.md +31 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sanity/runtime-cli",
3
3
  "description": "Sanity's Runtime CLI for Blueprints and Functions",
4
- "version": "17.4.0-blueprinit.g0ac8878",
4
+ "version": "17.4.0-blueprinit.g596ac51",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -26,9 +26,9 @@
26
26
  "files": [
27
27
  "./bin",
28
28
  "./dist",
29
- "./oclif.manifest.json",
30
29
  "./SKILL.md",
31
- "./skills"
30
+ "./skills",
31
+ "./oclif.manifest.json"
32
32
  ],
33
33
  "bin": {
34
34
  "sanity-run": "bin/run.js"
@@ -50,7 +50,7 @@
50
50
  "lint:fix": "npm run lint:write",
51
51
  "prepare": "npm run build",
52
52
  "postpack": "shx rm -f oclif.manifest.json",
53
- "test": "vitest run && npm run test:depmgmt && npm run lint",
53
+ "test": "npm run typecheck && vitest run && npm run test:depmgmt && npm run lint",
54
54
  "test:depmgmt": "vitest run --config ./test-depmgmt/vitest.config.ts",
55
55
  "test:coverage": "vitest run --coverage --coverage.include \"runtime-cli/src/**/*\"",
56
56
  "test:scenarios": "vitest run test/scenarios",
@@ -65,20 +65,20 @@
65
65
  "@architect/hydrate": "~6.0.2",
66
66
  "@architect/inventory": "~6.1.0",
67
67
  "@inquirer/prompts": "^8.5.2",
68
- "@oclif/core": "^4.13.2",
69
- "@oclif/plugin-help": "^6.2.55",
68
+ "@oclif/core": "^4.13.3",
69
+ "@oclif/plugin-help": "^6.2.56",
70
70
  "@sanity-labs/design-tokens": "^0.0.2-alpha.2",
71
- "@sanity-labs/oclif-plugin-skills-flag": "^0.1.3",
72
- "@sanity/blueprints": "^0.23.1",
71
+ "@sanity-labs/oclif-plugin-skills-flag": "^0.2.1",
72
+ "@sanity/blueprints": "^0.23.2",
73
73
  "@sanity/blueprints-parser": "^0.4.0",
74
74
  "@sanity/cli-build": "^5.1.0",
75
- "@sanity/cli-core": "^2.7.1",
76
- "@sanity/client": "^7.26.0",
75
+ "@sanity/cli-core": "^2.8.1",
76
+ "@sanity/client": "^7.26.2",
77
77
  "adm-zip": "^0.6.0",
78
78
  "array-treeify": "^0.1.5",
79
79
  "cardinal": "^2.1.1",
80
80
  "empathic": "^2.0.1",
81
- "eventsource": "^4.1.0",
81
+ "eventsource": "^4.1.1",
82
82
  "groq-js": "^2.0.0",
83
83
  "jiti": "^2.7.0",
84
84
  "mime-types": "^3.0.2",
@@ -87,12 +87,12 @@
87
87
  "strip-ansi": "^7.2.0",
88
88
  "tar-fs": "^3.1.3",
89
89
  "tar-stream": "^3.2.0",
90
- "vite": "^8.1.5",
91
- "ws": "^8.21.1",
90
+ "vite": "^8.2.1",
91
+ "ws": "^8.21.3",
92
92
  "xdg-basedir": "^5.1.0"
93
93
  },
94
94
  "devDependencies": {
95
- "@biomejs/biome": "2.5.6",
95
+ "@biomejs/biome": "2.5.7",
96
96
  "@codemirror/lang-json": "^6.0.2",
97
97
  "@codemirror/state": "^6.7.1",
98
98
  "@enhance/store": "^1.0.2",
@@ -100,7 +100,7 @@
100
100
  "@oclif/test": "^4.1.21",
101
101
  "@playwright/test": "^1.62.1",
102
102
  "@rollup/plugin-node-resolve": "^16.0.3",
103
- "@sanity/functions": "^1.5.0",
103
+ "@sanity/functions": "^1.6.0",
104
104
  "@types/adm-zip": "^0.5.8",
105
105
  "@types/cardinal": "^2.1.1",
106
106
  "@types/mime-types": "^3.0.1",
@@ -111,10 +111,10 @@
111
111
  "@vitest/coverage-v8": "4.1.10",
112
112
  "codemirror": "^6.0.2",
113
113
  "mentoss": "^0.13.0",
114
- "oclif": "^4.23.29",
114
+ "oclif": "^4.23.30",
115
115
  "pretty-bytes": "^7.1.1",
116
116
  "pretty-ms": "^9.3.0",
117
- "rollup": "^4.62.3",
117
+ "rollup": "^4.62.4",
118
118
  "shx": "^0.4.0",
119
119
  "typescript": "^7.0.2",
120
120
  "vitest": "4.1.10"
@@ -137,6 +137,16 @@
137
137
  }
138
138
  }
139
139
  },
140
+ "oclif-plugin-skills-flag": {
141
+ "flag": "skill",
142
+ "aliases": [
143
+ "agent",
144
+ "llm",
145
+ "llms",
146
+ "skills"
147
+ ],
148
+ "directory": "skills"
149
+ },
140
150
  "publishConfig": {
141
151
  "access": "public",
142
152
  "provenance": false
@@ -0,0 +1,23 @@
1
+ # `npx @sanity/cli functions build`
2
+
3
+ Build local Functions into zip archives. This command is hidden from generated help; use it when archive artifacts are explicitly needed, not as a required step before `blueprints deploy`.
4
+
5
+ ## Build
6
+
7
+ Build every local Function in the Blueprint:
8
+
9
+ ```sh
10
+ npx @sanity/cli functions build --json
11
+ ```
12
+
13
+ Build one Function into a chosen directory:
14
+
15
+ ```sh
16
+ npx @sanity/cli functions build process-order --out-dir artifacts/functions --json
17
+ ```
18
+
19
+ Without `--out-dir`, archives are written to `.build/` beside the Blueprint manifest. An existing archive with the same Function name is replaced.
20
+
21
+ The JSON result contains `built`, `errors`, and `outDir`. A run can succeed when some Functions build and others fail, so inspect `errors` even when the exit code is zero. If every build fails, the command exits with an error.
22
+
23
+ The `.gitignore` written by `blueprints init` covers `functions/**/.build/`, not the top-level `.build/` these archives land in, so exclude the output directory before committing.
@@ -0,0 +1,28 @@
1
+ # `npx @sanity/cli functions list`
2
+
3
+ List Functions deployed in a project or organization scope. This command is hidden from generated help. Results cover the whole scope rather than one Stack; use `blueprints info` for the resources of a single Stack.
4
+
5
+ ## Run
6
+
7
+ Use the locally configured scope:
8
+
9
+ ```sh
10
+ npx @sanity/cli functions list --json
11
+ ```
12
+
13
+ Select a scope explicitly when working outside a local Blueprint:
14
+
15
+ ```sh
16
+ npx @sanity/cli functions list --project-id PROJECT_ID --json
17
+ npx @sanity/cli functions list --organization-id ORGANIZATION_ID --json
18
+ ```
19
+
20
+ The two flags are mutually exclusive. No Blueprint manifest is required: the scope resolves from those flags, from `SANITY_PROJECT_ID` or `SANITY_ORGANIZATION_ID`, or from `.sanity/blueprint.config.json`, and the command fails with `Missing scope` when none of them do. The scope is sent with the request, so a project and its organization return different sets: scheduled Functions are organization-scoped, every other type is project-scoped.
21
+
22
+ ## Read the result
23
+
24
+ The JSON result contains `functions`, `scopeType`, and `scopeId`. Each entry carries `id`, `name`, `displayName`, `type`, `runtime`, `status`, `memory`, `storage`, `timeout`, `resourceType`, `resourceId`, `url`, `createdAt`, and `updatedAt`. An empty scope still emits `{"functions": []}` and exits `0`, so check the array length rather than the exit code.
25
+
26
+ Default output is one line per Function with its name, ID, type, and last update time. `--verbose` (`-v`) instead prints the type, update time, memory, timeout, and event rule of each.
27
+
28
+ Treat this as an inspection command. `functions logs`, `functions env add`, and `functions env remove` address a Function by its Blueprint resource name resolved through the deployed Stack, not by the `id` shown here.
@@ -0,0 +1,8 @@
1
+ # `npx @sanity/cli blueprints add`
2
+
3
+ Treat this command as legacy compatibility only. It is deprecated and supports only the `function` resource type. Prefer `npx @sanity/cli functions add` for new work.
4
+
5
+ ## Agent guidance
6
+
7
+ - Warn that the command is deprecated before adding new usage to scripts or documentation.
8
+ - Migrate existing legacy invocations to `npx @sanity/cli functions add`.
@@ -0,0 +1,33 @@
1
+ # `npx @sanity/cli blueprints config`
2
+
3
+ Read or update `.sanity/blueprint.config.json`, written next to the Blueprint manifest, which connects the local Blueprint to a Sanity scope and Stack.
4
+
5
+ ## Inspect first
6
+
7
+ Run from the Blueprint directory and request structured output:
8
+
9
+ ```sh
10
+ npx @sanity/cli blueprints config --json
11
+ ```
12
+
13
+ Without `--edit`, the command only displays the current configuration; with no config file on disk, `--json` emits nothing and exits `0`. Treat the project or organization ID and Stack ID as a single target; changing one can redirect later plan, deploy, info, logs, promote, or destroy commands.
14
+
15
+ ## Update
16
+
17
+ For agent-driven changes, pass the intended values instead of using the interactive editor:
18
+
19
+ ```sh
20
+ npx @sanity/cli blueprints config --edit --project-id PROJECT_ID --stack NAME_OR_ID --json
21
+ ```
22
+
23
+ Use `--organization-id ORGANIZATION_ID` instead of `--project-id` for an organization scope. The two scope flags are mutually exclusive. `--stack` accepts a Stack name or ID.
24
+
25
+ Scope or Stack flags without `--edit` write nothing: the command prints `To update the Blueprint config, use the --edit flag.` (suppressed under `--json`) and exits `0`, so a successful exit does not mean the change was applied.
26
+
27
+ ## Switching scope
28
+
29
+ An update only sets the keys it was given. Adding `--organization-id` to a config that already holds `projectId` leaves both in the file, and project scope takes precedence over organization scope, so the switch has no effect on later commands.
30
+
31
+ To move a Blueprint from project to organization scope, either edit `.sanity/blueprint.config.json` to remove `projectId`, or use `blueprints promote`, which clears it as part of the scope change.
32
+
33
+ After an update, run `blueprints config --json` again and verify every ID before executing a mutating command.
@@ -0,0 +1,36 @@
1
+ # `npx @sanity/cli blueprints deploy`
2
+
3
+ Apply the local Blueprint to a remote Stack. This command can create, update, and remove remote resources.
4
+
5
+ ## Preflight
6
+
7
+ 1. Locate and inspect the Blueprint manifest.
8
+ 2. Resolve the target from local configuration, or pass an explicit scope and `--stack`.
9
+ 3. Run `npx @sanity/cli blueprints plan --json`.
10
+ 4. Review all planned changes, especially replacements and removals.
11
+
12
+ Do not deploy when the target or plan is ambiguous.
13
+
14
+ ## Deploy
15
+
16
+ Include a message that records the reason for the change:
17
+
18
+ ```sh
19
+ npx @sanity/cli blueprints deploy --message "Deploy order processing changes" --json
20
+ ```
21
+
22
+ To target another Stack, pass `--stack NAME_OR_ID`, adding `--project-id PROJECT_ID` or `--organization-id ORGANIZATION_ID` when the scope also differs.
23
+
24
+ Use `--no-wait` only when the caller does not need a confirmed result. Follow an asynchronous deployment with:
25
+
26
+ ```sh
27
+ npx @sanity/cli blueprints info --json
28
+ ```
29
+
30
+ Exit code `0` means the deployment completed, or was accepted when `--no-wait` is set. Exit code `2` means it failed. Exit code `75` means the request was accepted but completion could not be confirmed; inspect `blueprints info` and `blueprints logs` before retrying.
31
+
32
+ The command refuses to start while the Stack has a `QUEUED` or `IN_PROGRESS` operation, so a retry during one fails with that message rather than deploying twice. Once the earlier operation settles, a retry does deploy again.
33
+
34
+ Use `--new-stack-name NAME` only when the deployment should also rename the Stack.
35
+
36
+ Set `SANITY_ASSET_TIMEOUT` in seconds to raise the 180-second per-asset limit on processing resource assets when large Functions time out during preparation. Set `SANITY_ASSET_CONCURRENCY` to change how many assets are processed at once (default 4).
@@ -0,0 +1,30 @@
1
+ # `npx @sanity/cli blueprints destroy`
2
+
3
+ Permanently destroy a remote Stack and its provisioned resources. The local Blueprint manifest and resource files remain, and a matching local Stack ID is cleared from `.sanity/blueprint.config.json`.
4
+
5
+ ## Required safety checks
6
+
7
+ 1. Obtain explicit authorization to destroy the Stack.
8
+ 2. Resolve the exact project or organization scope and Stack ID.
9
+ 3. Run `npx @sanity/cli blueprints info --json` for that target.
10
+ 4. Present the resolved target and affected resources before continuing.
11
+
12
+ Do not infer authorization from a request to clean up files, redeploy, or fix configuration.
13
+
14
+ ## Run
15
+
16
+ Interactive use prompts for confirmation:
17
+
18
+ ```sh
19
+ npx @sanity/cli blueprints destroy
20
+ ```
21
+
22
+ For an authorized non-interactive destruction, provide the complete target:
23
+
24
+ ```sh
25
+ npx @sanity/cli blueprints destroy --project-id PROJECT_ID --stack NAME_OR_ID --force --json
26
+ ```
27
+
28
+ Use `--organization-id` instead of `--project-id` for an organization-scoped Stack. The explicit scope flags require both `--stack` and `--force`.
29
+
30
+ Use `--no-wait` only when asynchronous destruction is intended: it exits `0` as soon as the request is accepted. While waiting, exit code `75` means the request was accepted but completion could not be confirmed. Check `blueprints info` before retrying.
@@ -0,0 +1,31 @@
1
+ # `npx @sanity/cli blueprints doctor`
2
+
3
+ Runs five checks: Host online, Authenticated, Manifest valid, Stack ready, User has access. Run this before changing files when another Blueprint command fails for an unclear reason.
4
+
5
+ ## Diagnose
6
+
7
+ Run from the project directory:
8
+
9
+ ```sh
10
+ npx @sanity/cli blueprints doctor
11
+ ```
12
+
13
+ Use `--path PATH` when the Blueprint manifest is outside the current directory or cannot be discovered automatically. `SANITY_BLUEPRINT_PATH` provides the same path through the environment.
14
+
15
+ Read the reported diagnostics and warnings before proposing changes. Do not assume every warning requires a fix.
16
+
17
+ ## Read the exit code, not just the JSON
18
+
19
+ The command exits non-zero unless every check passes; a check that cannot be determined also fails the run. `--json` suppresses the report: a clean run prints `{"diagnostics": {"online": true, "tokenValid": true, ...}}` with `true`, `false`, or `null` per check, and a failing run prints an error object with no diagnostics. Rerun without `--json` to see which checks failed and why.
20
+
21
+ ## Fix
22
+
23
+ `--fix` prompts for scope and Stack, then writes `.sanity/blueprint.config.json`:
24
+
25
+ ```sh
26
+ npx @sanity/cli blueprints doctor --fix
27
+ ```
28
+
29
+ `--fix` cannot be combined with `--path`, including a path supplied through `SANITY_BLUEPRINT_PATH`. It also requires authentication and a readable Blueprint manifest; without either it reports what is missing and changes nothing.
30
+
31
+ Use `--fix` only when interactive input is available and the user has authorized configuration changes. Otherwise, apply a specific, reviewed fix and rerun the read-only diagnostic command.
@@ -0,0 +1,23 @@
1
+ # `npx @sanity/cli blueprints info`
2
+
3
+ Read the current state and deployed resources of one remote Stack, including the status of its most recent deploy or destroy operation. Use it to verify a target before mutation.
4
+
5
+ ## Run
6
+
7
+ Use the locally configured Stack:
8
+
9
+ ```sh
10
+ npx @sanity/cli blueprints info --json
11
+ ```
12
+
13
+ Query a specific target when local configuration is absent or should not be trusted:
14
+
15
+ ```sh
16
+ npx @sanity/cli blueprints info --project-id PROJECT_ID --stack NAME_OR_ID --json
17
+ ```
18
+
19
+ Use `--organization-id` instead of `--project-id` for an organization scope. `--stack` accepts a Stack name or ID. `--verbose` (`-v`) adds each resource's ID and external ID to human-readable output.
20
+
21
+ The JSON result contains a `stack` object with `id`, `name`, `scopeType`, `scopeId`, `resources`, and `recentOperation`. Check `recentOperation.status` rather than relying on a successful exit alone.
22
+
23
+ Run this command after `deploy --no-wait`, `destroy --no-wait`, or exit code `75`. Use `blueprints stacks --json` first when the Stack ID is unknown.
@@ -0,0 +1,48 @@
1
+ # `npx @sanity/cli blueprints init`
2
+
3
+ Initialize a local Blueprint and connect it to a new or existing remote Stack. Use this at the start of a Blueprint project or to configure an existing manifest.
4
+
5
+ ## Before running
6
+
7
+ - Authenticate with Sanity.
8
+ - Choose the target directory and whether the Stack belongs to a project or an organization.
9
+ - Check the target directory and its parents for an existing manifest (`sanity.blueprint` or `blueprint`, with `.json`, `.js`, `.mjs`, or `.ts`). When one is found, the command configures it instead of creating another manifest.
10
+ - Confirm whether to create a Stack or attach an existing one.
11
+
12
+ ## Run
13
+
14
+ Pass `.` to initialize the current directory without the directory confirmation prompt:
15
+
16
+ ```sh
17
+ npx @sanity/cli blueprints init . --project-id PROJECT_ID --stack-name development
18
+ ```
19
+
20
+ To connect to an existing Stack, provide its ID and scope:
21
+
22
+ ```sh
23
+ npx @sanity/cli blueprints init . --project-id PROJECT_ID --stack-id STACK_ID
24
+ ```
25
+
26
+ Use `--organization-id` instead of `--project-id` for an organization-scoped Stack. `--stack-id` and `--stack-name` are mutually exclusive, and either one requires an explicit project or organization scope.
27
+
28
+ For a new local Blueprint, choose the manifest format with `--blueprint-type json|js|ts`. JavaScript and TypeScript setups add `@sanity/blueprints` to `devDependencies`, writing a `package.json` with `"type": "module"` if the directory has none. A `js` manifest is written as `sanity.blueprint.mjs` when a `package.json` already exists there without `"type": "module"`. The command also writes `.sanity/blueprint.config.json` and a `.gitignore` covering `node_modules`, `.env`, and function build output; the `.sanity` config itself is not ignored. `--example NAME` takes a different path: it scaffolds a published example into the named directory (or `./NAME` when none is given), creates a project-scoped Stack called `example-NAME`, and cannot be combined with `--blueprint-type`, `--stack-id`, or `--stack-name`.
29
+
30
+ ## Avoid the prompts
31
+
32
+ A fresh initialization is interactive unless every decision is supplied up front. Pass all four:
33
+
34
+ ```sh
35
+ npx @sanity/cli blueprints init . --project-id PROJECT_ID --stack-name development --blueprint-type ts
36
+ ```
37
+
38
+ Omitting `--blueprint-type` prompts for the manifest format. Omitting both `--stack-id` and `--stack-name` prompts for Stack selection. Omitting the scope starts a full organization and project wizard. Omitting the directory prompts to confirm the current one.
39
+
40
+ ## Verify
41
+
42
+ Inspect the created files, then preview the first deployment:
43
+
44
+ ```sh
45
+ npx @sanity/cli blueprints plan --json
46
+ ```
47
+
48
+ Do not deploy until the plan targets the expected Stack and contains the expected resource changes.
@@ -0,0 +1,33 @@
1
+ # `npx @sanity/cli blueprints logs`
2
+
3
+ Retrieve deployment logs for one remote Stack. Prefer bounded, one-shot queries for agent work.
4
+
5
+ ## Query logs
6
+
7
+ Request structured output with an explicit limit:
8
+
9
+ ```sh
10
+ npx @sanity/cli blueprints logs --limit 100 --json
11
+ ```
12
+
13
+ Narrow a query with ISO 8601 timestamps:
14
+
15
+ ```sh
16
+ npx @sanity/cli blueprints logs --since 2026-07-29T00:00:00Z --limit 100 --json
17
+ ```
18
+
19
+ Use `--before` to page toward older entries. `--limit` must be between 1 and 500; without it the API's default page size applies. When entries are found, the JSON result contains `logs` and `hasMore`; an empty range returns no JSON payload.
20
+
21
+ Pass `--stack NAME_OR_ID` with `--project-id PROJECT_ID` or `--organization-id ORGANIZATION_ID` when overriding the locally configured target.
22
+
23
+ ## Watch mode
24
+
25
+ `--watch` (`-w`, alias `--follow`) prints the 10 most recent entries, then polls for new ones until interrupted. It cannot be combined with `--json`, `--limit`, `--since`, or `--before`.
26
+
27
+ Use watch mode only when continuous monitoring is requested:
28
+
29
+ ```sh
30
+ npx @sanity/cli blueprints logs --watch
31
+ ```
32
+
33
+ If no expected logs appear, run `blueprints info --json` and verify the Stack ID and deployment status.
@@ -0,0 +1,25 @@
1
+ # `npx @sanity/cli blueprints mint-deploy-token`
2
+
3
+ Create a robot token for deploying Blueprints from CI, scoped to one project or organization. The role granted is `blueprints-deployer` for a project, `blueprints-deployer-robot` for an organization.
4
+
5
+ ## Protect the credential
6
+
7
+ - Obtain authorization before creating a new robot credential.
8
+ - Confirm the exact scope and use a label that identifies the CI system or deployment purpose.
9
+ - Send the token only to the user-approved secret destination.
10
+ - Never write the token to source files, commit it, paste it into an issue, or include it in a response or log.
11
+ - Revoke unused tokens in Sanity Manage.
12
+
13
+ ## Run
14
+
15
+ The default command prints the robot label, ID, and expiry, then prompts for clipboard, terminal, or discard handling. For automation, `--print` emits only the raw token:
16
+
17
+ ```sh
18
+ npx @sanity/cli blueprints mint-deploy-token --project-id PROJECT_ID --label "production-ci" --print
19
+ ```
20
+
21
+ Use `--organization-id ORGANIZATION_ID` instead of `--project-id` for organization scope. The two scope flags are mutually exclusive.
22
+
23
+ `--json` returns the full robot response, including sensitive token material. Do not use it when output is collected in ordinary build logs.
24
+
25
+ A `ROLE_UNAVAILABLE` error means the role does not exist in that project or organization. Other access or permission errors mean the account needs project or organization administrator access. Do not mint repeated replacement tokens without checking whether the earlier request succeeded.
@@ -0,0 +1,28 @@
1
+ # `npx @sanity/cli blueprints plan`
2
+
3
+ Preview the resource changes produced by the local Blueprint without creating, modifying, or deleting deployed resources.
4
+
5
+ ## Run
6
+
7
+ Run after editing the Blueprint and before every deployment:
8
+
9
+ ```sh
10
+ npx @sanity/cli blueprints plan --json
11
+ ```
12
+
13
+ The JSON result contains the resolved local `resources` and the remote deployment `plan`. Review the operations instead of treating a zero exit code as approval to deploy.
14
+
15
+ To plan against a Stack other than the locally configured one, pass its name or ID, and the scope when that differs too:
16
+
17
+ ```sh
18
+ npx @sanity/cli blueprints plan --project-id PROJECT_ID --stack NAME_OR_ID --json
19
+ ```
20
+
21
+ Use `--organization-id` instead of `--project-id` for organization scope. The scope flags are mutually exclusive.
22
+
23
+ ## Review
24
+
25
+ - Confirm the Stack ID and scope.
26
+ - Match planned resources to the requested change.
27
+ - Flag unexpected deletions, replacements, or unrelated changes.
28
+ - Stop when the target or impact cannot be determined.
@@ -0,0 +1,31 @@
1
+ # `npx @sanity/cli blueprints promote`
2
+
3
+ Promote a deployed Stack from project scope to organization scope. Promotion cannot be reversed, and the local Blueprint configuration is updated to the organization scope after success.
4
+
5
+ ## Required safety checks
6
+
7
+ 1. Obtain explicit authorization for the scope change.
8
+ 2. Run `npx @sanity/cli blueprints info --json`.
9
+ 3. Confirm the exact Stack ID, current project scope, and deployed resources.
10
+ 4. Confirm the caller has organization admin access.
11
+
12
+ The command requires a local Blueprint manifest and an existing `.sanity/blueprint.config.json` to update.
13
+
14
+ ## Run
15
+
16
+ Interactive use prompts for confirmation:
17
+
18
+ ```sh
19
+ npx @sanity/cli blueprints promote --project-id PROJECT_ID --stack NAME_OR_ID
20
+ ```
21
+
22
+ `--force` skips that prompt. Use `--new-stack-name NAME` to rename during promotion, which is required when the destination organization already holds a Stack with the current name; it is rejected on a Stack that is already organization-scoped.
23
+
24
+ After success, run:
25
+
26
+ ```sh
27
+ npx @sanity/cli blueprints config --json
28
+ npx @sanity/cli blueprints info --json
29
+ ```
30
+
31
+ If the remote promotion succeeds but the local config update fails, repair the configuration with `blueprints config --edit`; do not promote the Stack again.
@@ -0,0 +1,28 @@
1
+ # `npx @sanity/cli blueprints stacks`
2
+
3
+ List remote Stacks for a project or organization. Use this read-only command to discover a Stack ID before running a targeted info, logs, config, deploy, promote, or destroy command.
4
+
5
+ ## Run
6
+
7
+ List Stacks for the locally configured scope:
8
+
9
+ ```sh
10
+ npx @sanity/cli blueprints stacks --json
11
+ ```
12
+
13
+ Select a scope explicitly when working outside the local Blueprint:
14
+
15
+ ```sh
16
+ npx @sanity/cli blueprints stacks --project-id PROJECT_ID --json
17
+ npx @sanity/cli blueprints stacks --organization-id ORGANIZATION_ID --json
18
+ ```
19
+
20
+ The JSON result contains `stacks`, `scopeType`, and `scopeId`; each entry carries `resourceCount` rather than a full `resources` array. Zero results prints `No stacks found` and emits no JSON. Match both the Stack and its scope; names alone may be ambiguous.
21
+
22
+ To also include Stacks scoped to the organization's projects:
23
+
24
+ ```sh
25
+ npx @sanity/cli blueprints stacks --organization-id ORGANIZATION_ID --include-projects --json
26
+ ```
27
+
28
+ `--include-projects` requires `--organization-id`, cannot be combined with `--project-id`, and only queries the organization's first 50 projects. This command does not change the local Blueprint target; use `blueprints config --edit` for that.
@@ -0,0 +1,35 @@
1
+ # `npx @sanity/cli functions add`
2
+
3
+ Scaffold a local Function and its resource definition for the current Blueprint.
4
+
5
+ ## Before running
6
+
7
+ - Run from a project containing a Blueprint manifest.
8
+ - Choose a Function name not already used by a Blueprint resource, and one event family: document, media-library asset, scheduled, or sync-tag invalidation.
9
+ - Names must be at least three characters, start with a letter or digit, and otherwise contain only letters, digits, hyphens, and underscores.
10
+ - Decide whether to install `@sanity/functions`, which provides typed helpers for authoring handler code, and which package manager to use.
11
+
12
+ ## Add a Function
13
+
14
+ Provide flags to avoid interactive prompts:
15
+
16
+ ```sh
17
+ npx @sanity/cli functions add --name process-order --type document-create --type document-update --language ts --helpers --installer npm
18
+ ```
19
+
20
+ No flag is required and any omitted value is prompted for, but `--type` without `--name` is rejected. The accepted `--type` values are `document-create`, `document-update`, `document-delete`, `document-publish`, `media-library-asset-create`, `media-library-asset-update`, `media-library-asset-delete`, `scheduled-function`, and `sync-tag-invalidate`. Repeat the flag for multiple events from the same family; the command rejects a mix of families.
21
+
22
+ TypeScript is the default language. Use `--language js` or `--javascript` for JavaScript, but do not combine those flags. Use `--no-helpers` when helper installation is not wanted. `--installer` accepts `npm`, `pnpm`, `yarn`, or `skip`.
23
+
24
+ `--example EXAMPLE_NAME` downloads a Function example from the `sanity-labs/function-recipes` repository into `functions/EXAMPLE_NAME/` instead of running the normal scaffold flow. Browse recipes at https://www.sanity.io/exchange/type=recipes/solution=functions. Each recipe's Quick Start contains the correct `--example` value. Pass it alone: every other scaffold flag is rejected, and the manifest is not updated. Use it only for an example the user requested, then follow the configuration instructions printed by the command.
25
+
26
+ ## Verify
27
+
28
+ The scaffold writes one file, `functions/NAME/index.ts` (or `index.js`). Only `.json` manifests are edited in place; for `.ts`, `.js`, and `.mjs` manifests the command prints a resource definition that still needs to be added by hand.
29
+
30
+ Run the Function locally with a payload that matches the handler before deployment:
31
+
32
+ ```sh
33
+ npx @sanity/cli functions test process-order --file payload.json --json
34
+ npx @sanity/cli blueprints plan --json
35
+ ```
@@ -0,0 +1,21 @@
1
+ # `npx @sanity/cli functions dev`
2
+
3
+ Start the local web emulator for interactive Function development. The command keeps running until interrupted.
4
+
5
+ ## Start the emulator
6
+
7
+ Use the default host and port:
8
+
9
+ ```sh
10
+ npx @sanity/cli functions dev
11
+ ```
12
+
13
+ The emulator is available at `http://localhost:8080`. Choose another loopback port when needed:
14
+
15
+ ```sh
16
+ npx @sanity/cli functions dev --host 127.0.0.1 --port 3333 --timeout 60
17
+ ```
18
+
19
+ Port 8974 is not available: the emulator's WebSocket server binds it. `--timeout` sets the execution limit in seconds for every Function, taking precedence over each Function's configured `timeout` (default 10 seconds). Bind to a non-loopback interface only when network access is requested and exposing the development server is acceptable.
20
+
21
+ Run this command in a persistent terminal, report the URL, and stop the process when development is complete. For one bounded invocation without a web server, use `functions test`.
@@ -0,0 +1,29 @@
1
+ # `npx @sanity/cli functions env add`
2
+
3
+ Set or replace one environment variable on a deployed Function. The command writes to the Functions API and does not redeploy the Stack.
4
+
5
+ Run from the Blueprint directory or a subdirectory; the manifest is required even though the command only touches remote state.
6
+
7
+ ## Confirm the target
8
+
9
+ Resolve the deployed Function name and Stack before changing remote state. Use `functions env list` to inspect existing keys when replacing a value was not explicitly requested.
10
+
11
+ Set a non-secret value:
12
+
13
+ ```sh
14
+ npx @sanity/cli functions env add process-order API_URL https://api.example.com/
15
+ ```
16
+
17
+ Override the locally configured Stack with `--stack NAME_OR_ID`.
18
+
19
+ ## Protect secret values
20
+
21
+ The value is a positional command argument and may be visible in shell history, process inspection, or agent tool transcripts. Do not run the command with a secret until the user has approved both the target and the handling method.
22
+
23
+ Do not use `--json` or `--trace` for secrets: the JSON result contains the value, and trace output prints the request body. Never paste a secret value into source files, logs, issue comments, or an assistant response.
24
+
25
+ After setting the variable, verify only its key:
26
+
27
+ ```sh
28
+ npx @sanity/cli functions env list process-order --json
29
+ ```
@@ -0,0 +1,21 @@
1
+ # `npx @sanity/cli functions env list`
2
+
3
+ List the environment-variable keys configured on one deployed Function. Values are not returned.
4
+
5
+ Run from the Blueprint directory or a subdirectory; the manifest is required even though the command only touches remote state.
6
+
7
+ ## Run
8
+
9
+ Use the locally configured Stack:
10
+
11
+ ```sh
12
+ npx @sanity/cli functions env list process-order --json
13
+ ```
14
+
15
+ Query another Stack:
16
+
17
+ ```sh
18
+ npx @sanity/cli functions env list process-order --stack NAME_OR_ID --json
19
+ ```
20
+
21
+ The JSON result contains the Function `name` and an `envvars` array of keys. Match the Function name and Stack before using the result to add, replace, or remove a variable.