Skip to content

Commit af73b97

Browse files
authored
docs: align init agent JSON docs with settlement envelopes (#1776)
init --agent/--json on v1 emits settlement envelopes (ok, dotted CLI.* codes, nextActions), matching check --json. reference/init.mdx and skills/arkenv/SKILL.md still taught status/retryWith. This PR updates both to the ErroredEnvelope shape (CLI.GIT_TREE_DIRTY + nextActions run-command) and the ok:true success path. Leaves dev/main machine-readable-output.mdx alone (v1 focus). Docs/skill only, no changeset.
1 parent 9d9f35b commit af73b97

4 files changed

Lines changed: 61 additions & 20 deletions

File tree

apps/www/content/docs/guides/ai.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public prefixes, and skip a `runtimeEnv` map.
8282
**Greenfield setup**
8383

8484
```text
85-
Add ArkEnv to this repo. Run `npx arkenv init --agent`, parse the JSON on stdout, and only retry with flags from `retryWith` if a refusal is safe to bypass. Do not hand-write next.config or env.ts unless init fails.
85+
Add ArkEnv to this repo. Run `npx arkenv init --agent`, parse the JSON on stdout, and only retry with `--force` if the refusal's `nextActions` include a `run-command` with `--force`. Do not hand-write next.config or env.ts unless init fails.
8686
```
8787

8888
**Existing keys**

apps/www/content/docs/reference/agent-plugin.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ a follow-up to `plugins add`.
4141
## Commands
4242

4343
Two slash commands wrap the CLI and the auditor. Parse JSON on stdout.
44-
Do not pass `--force` unless a refusal lists it in `retryWith`.
44+
Do not pass `--force` unless a refusal's `nextActions` include a `--force` run-command.
4545

4646
### `/arkenv:init`
4747

apps/www/content/docs/reference/init.mdx

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,42 @@ See [Hosting presets](/docs/core-concepts/hosting-presets).
5252
Same macro as the [global `--agent` flag](/docs/reference#agent):
5353
`--yes --quiet --json`. It does not imply `--force`.
5454

55-
When a safety check fails (dirty git tree), stdout is a JSON refusal and
56-
the process exits non-zero:
55+
When a safety check fails (dirty git tree), stdout is an errored
56+
settlement envelope (`ok: false`) and the process exits non-zero:
5757

5858
```json
5959
{
60-
"status": "error",
61-
"code": "GIT_TREE_DIRTY",
62-
"message": "Git working tree is not clean.",
63-
"retryWith": ["--force"]
60+
"ok": false,
61+
"commandId": "init",
62+
"error": {
63+
"code": "CLI.GIT_TREE_DIRTY",
64+
"severity": "error",
65+
"summary": "Git working tree is not clean.",
66+
"why": "Commit or stash your changes before running arkenv init.",
67+
"nextActions": [
68+
{
69+
"kind": "run-command",
70+
"label": "Re-run with --force to bypass git working tree check",
71+
"command": "arkenv init --force"
72+
}
73+
]
74+
},
75+
"diagnostics": [],
76+
"nextActions": [
77+
{
78+
"kind": "run-command",
79+
"label": "Re-run with --force to bypass git working tree check",
80+
"command": "arkenv init --force"
81+
}
82+
]
6483
}
6584
```
6685

67-
Only rerun with flags in `retryWith` after you confirm the bypass is
68-
safe.
86+
Branch on `error.code` (dotted `CLI.*` / `ENV.*` codes). Use
87+
`nextActions` for remediation — a `run-command` action with `--force`
88+
means the refusal is bypassable. Only re-run with that flag after you
89+
confirm the bypass is safe. The same envelope shape is documented for
90+
[`check --json`](/docs/reference/check#json--j).
6991

7092
### `--example <name>`
7193

skills/arkenv/SKILL.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,44 @@ AI agents SHOULD always use the CLI for project initialization to ensure consist
4949
- **`--yes`**: Bypasses all interactive prompts and uses recommended defaults.
5050
- **`--quiet`**: Suppresses spinners and ANSI formatting for cleaner terminal logs.
5151
- **`--json`**: Emits a structured JSON summary to `stdout` upon completion (all other output is sent to `stderr`).
52-
- **Success Verification**: Parse the JSON output to verify `status: "success"` and retrieve details like the scaffolded file path.
52+
- **Success Verification**: Parse the JSON settlement envelope on `stdout`. Success is `ok: true` with `commandId: "init"`; details (e.g. scaffolded paths) live under `result`.
5353

54-
#### Handling refusals (`status: "error"`)
54+
#### Handling refusals (`ok: false`)
5555

56-
`--agent` **never** implies `--force`. When a safety check trips, the CLI refuses and emits a machine-actionable JSON payload to `stdout`:
56+
`--agent` **never** implies `--force`. When a safety check trips, the CLI refuses and emits an errored settlement envelope to `stdout`:
5757

5858
```json
5959
{
60-
"status": "error",
61-
"code": "GIT_TREE_DIRTY",
62-
"message": "Git working tree is not clean.",
63-
"retryWith": ["--force"]
60+
"ok": false,
61+
"commandId": "init",
62+
"error": {
63+
"code": "CLI.GIT_TREE_DIRTY",
64+
"severity": "error",
65+
"summary": "Git working tree is not clean.",
66+
"why": "Commit or stash your changes before running arkenv init.",
67+
"nextActions": [
68+
{
69+
"kind": "run-command",
70+
"label": "Re-run with --force to bypass git working tree check",
71+
"command": "arkenv init --force"
72+
}
73+
]
74+
},
75+
"diagnostics": [],
76+
"nextActions": [
77+
{
78+
"kind": "run-command",
79+
"label": "Re-run with --force to bypass git working tree check",
80+
"command": "arkenv init --force"
81+
}
82+
]
6483
}
6584
```
6685

67-
- **`code`**: a stable identifier you can branch on. Refusal codes: `REQUIREMENTS_NOT_MET`, `GIT_TREE_DIRTY`, `NON_EMPTY_DIR`. A `code` of `INTERNAL` means the CLI *broke* rather than *refused* - retrying with flags will not help.
68-
- **`retryWith`**: the flag(s) that would bypass the check (e.g. `["--force"]`). Empty (`[]`) means the refusal is not bypassable.
86+
- **`error.code`**: a stable dotted identifier you can branch on (`CLI.REQUIREMENTS_NOT_MET`, `CLI.GIT_TREE_DIRTY`, `CLI.NON_EMPTY_DIR`, …). `CLI.INTERNAL_ERROR` means the CLI *broke* rather than *refused* retrying with flags will not help.
87+
- **`nextActions`**: remediation steps. A `run-command` action that includes `--force` means the refusal is bypassable; empty `nextActions` means it is not. Prefer `nextActions` over any legacy `retryWith` field.
6988

70-
**Escalation pattern**: always run `init --agent` **without** `--force` first. If you get `status: "error"`, inspect `code` and `retryWith`. Only re-run with the flag(s) from `retryWith` (e.g. append `--force`) once you have deliberately decided the refusal is safe to bypass - do not add `--force` pre-emptively.
89+
**Escalation pattern**: always run `init --agent` **without** `--force` first. If you get `ok: false`, inspect `error.code` and `nextActions`. Only re-run with `--force` (or the command from a `run-command` action) once you have deliberately decided the refusal is safe to bypass do not add `--force` pre-emptively.
7190

7291
---
7392

0 commit comments

Comments
 (0)