arkgate 4.5.7 → 4.6.1

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 (83) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/README.md +18 -12
  3. package/bin/ark-check-runtime.mjs +107 -8
  4. package/bin/ark-mcp-runtime.mjs +17 -1
  5. package/bin/ark.mjs +5 -3
  6. package/bin/lib/agent-homes.mjs +296 -0
  7. package/bin/lib/agent-projection.mjs +2 -2
  8. package/bin/lib/analysis-engine.mjs +3 -3
  9. package/bin/lib/ci-and-commands.mjs +16 -16
  10. package/bin/lib/config-contract.mjs +2 -0
  11. package/bin/lib/contract-smells.mjs +5 -5
  12. package/bin/lib/design-smells.mjs +4 -8
  13. package/bin/lib/doctor-advisories.mjs +9 -0
  14. package/bin/lib/doctor-plan.mjs +39 -15
  15. package/bin/lib/field-install.mjs +1 -1
  16. package/bin/lib/golden-pattern.mjs +1 -1
  17. package/bin/lib/host-support-matrix.mjs +4 -4
  18. package/bin/lib/html-report-advisories.mjs +20 -0
  19. package/bin/lib/html-report-depth.mjs +7 -8
  20. package/bin/lib/html-report.mjs +2 -1
  21. package/bin/lib/improvement-compass-map.mjs +20 -20
  22. package/bin/lib/install-migrate.mjs +12 -0
  23. package/bin/lib/pilot-loop.mjs +1 -1
  24. package/bin/lib/post-green-path.mjs +5 -4
  25. package/bin/lib/prepare-change.mjs +9 -0
  26. package/bin/lib/product-copy.mjs +32 -0
  27. package/bin/lib/skill-write.mjs +1 -1
  28. package/bin/lib/status-command.mjs +14 -0
  29. package/bin/lib/status-manifest.mjs +17 -0
  30. package/bin/lib/team-parliament-io.mjs +338 -0
  31. package/bin/lib/team-parliament.mjs +383 -0
  32. package/bin/lib/upgrade-whats-new.mjs +32 -0
  33. package/bin/lib/violations.mjs +8 -4
  34. package/dist/{configTypes-CC0FEXoF.d.ts → configTypes-B8uIcLaG.d.ts} +5 -0
  35. package/dist/eslint/index.cjs +2 -2
  36. package/dist/eslint/index.d.ts +1 -1
  37. package/dist/eslint/index.js +2 -2
  38. package/dist/index.cjs +8 -8
  39. package/dist/index.d.ts +61 -2
  40. package/dist/index.js +8 -8
  41. package/docs/README.md +5 -4
  42. package/docs/agent-guide.md +31 -24
  43. package/docs/ai-gates.md +19 -0
  44. package/docs/configuration.md +36 -2
  45. package/docs/develop.md +16 -4
  46. package/docs/enthusiast/README.md +1 -1
  47. package/docs/enthusiast/how-to-agent-gates.md +3 -3
  48. package/docs/enthusiast/how-to-pick-shape.md +2 -2
  49. package/docs/enthusiast/tutorial-first-project.md +4 -3
  50. package/docs/package-surface.md +5 -3
  51. package/docs/product-voice.md +126 -82
  52. package/docs/use.md +13 -6
  53. package/package.json +1 -1
  54. package/schemas/ark.config.schema.json +9 -0
  55. package/schemas/ark.status-manifest.schema.json +51 -0
  56. package/server.json +2 -2
  57. package/templates/agent-skills/README.md +1 -1
  58. package/templates/agent-skills/ark-adopt/SKILL.md +46 -19
  59. package/templates/agent-skills/ark-architect/SKILL.md +24 -145
  60. package/templates/agent-skills/ark-autopilot/SKILL.md +40 -30
  61. package/templates/agent-skills/ark-contract/SKILL.md +21 -105
  62. package/templates/agent-skills/ark-coverage/SKILL.md +3 -0
  63. package/templates/agent-skills/ark-explain/SKILL.md +7 -4
  64. package/templates/agent-skills/ark-explore/SKILL.md +29 -21
  65. package/templates/agent-skills/ark-fix/SKILL.md +34 -157
  66. package/templates/agent-skills/ark-loop/SKILL.md +31 -153
  67. package/templates/agent-skills/ark-place/SKILL.md +25 -13
  68. package/templates/agent-skills/ark-runtime/SKILL.md +3 -3
  69. package/templates/agent-skills/ark-think/SKILL.md +5 -2
  70. package/templates/agent-skills/ark-upgrade/SKILL.md +13 -8
  71. package/templates/skills/ark-adopt.md +46 -19
  72. package/templates/skills/ark-architect.md +24 -145
  73. package/templates/skills/ark-autopilot.md +40 -30
  74. package/templates/skills/ark-contract.md +21 -105
  75. package/templates/skills/ark-coverage.md +3 -0
  76. package/templates/skills/ark-explain.md +7 -4
  77. package/templates/skills/ark-explore.md +29 -21
  78. package/templates/skills/ark-fix.md +34 -157
  79. package/templates/skills/ark-loop.md +31 -153
  80. package/templates/skills/ark-place.md +25 -13
  81. package/templates/skills/ark-runtime.md +3 -3
  82. package/templates/skills/ark-think.md +5 -2
  83. package/templates/skills/ark-upgrade.md +13 -8
@@ -1,12 +1,39 @@
1
1
  ---
2
2
  name: ark-adopt
3
- description: Brownfield onboardingmatch contract to real product code, classify ungoverned dirs, mine business rules, freeze only real debt, seed Shape dual-plan B for spaghetti residual. Deep source analysis required.
3
+ description: Session 0mark the Ark path. Greenfield scaffold or brownfield honesty. Write ark.config, optional advisory ArkRules, baseline, and gates in this turn. CLI validates.
4
4
  ---
5
5
 
6
- # /ark-adopt — Bring Ark into an existing codebase
6
+ # /ark-adopt — Mark the path (session 0)
7
7
 
8
- Goal: contract reflects **product reality**, most code governed, only genuine debt frozen
9
- with a burn-down. A green check over a wrong contract is a **false green**.
8
+ Invoking this skill **is** the approval. Write the architecture config in this turn.
9
+ Greenfield: scaffold like `--recommend` / today’s architect. Brownfield: match **product
10
+ reality**, freeze only genuine debt. A green check over a wrong config is a **false green**.
11
+
12
+ ## Autonomy contract
13
+
14
+ The CLI is a **sensor and gate**, never the deliverable. **CLI budget:** one
15
+ `ark-check --recommend` or `--coverage` / `--doctor`; then write; then `ark-check`.
16
+ Forbidden as the result: preview-only adopt, “approve?”, or `STOP — invoke /ark-architect`
17
+ / `/ark-contract`. Do that work **here**.
18
+
19
+ **Still never:** weaken `ark.config.json`; invent `mechanical-safe` kinds; claim finished
20
+ while leftover design work remains.
21
+
22
+ **Team lock:** this door **is** a contract session (law-only). Do not mix product source
23
+ into the same diff. After writes, validate with
24
+ `ark-check --contract-diff --contract-session --base <merge-ref> --author <steward>`.
25
+ If `stewards` is set, loosen and baseline-grow require a listed author. Feature work
26
+ uses `/ark-place` / `/ark-autopilot` and must not touch the constitution.
27
+
28
+ **Several hands → ask for stewards.** Read `doctor.stewardNudge` (or the human
29
+ **Stewards (advisory)** line). Act when `needsStewards` **or** `drift` is true.
30
+ **Ask once** before writing `stewards[]`. Identity is a **GitHub handle or email**
31
+ (`pedroknigge` or the GitHub noreply mail), not git `user.name`. Empty list: use
32
+ `proposed` (CODEOWNERS first, else git handles/emails; bots and display names stripped).
33
+ Drift: CODEOWNERS handles in `missingFromList`, or “team grew” (author count > steward
34
+ count) — ask who else owns the law. If the user says yes or names handles or emails,
35
+ write them in this turn. If they say the list is still right, leave it. Never invent
36
+ or auto-remove stewards.
10
37
 
11
38
  **Adopt is Align + Stabilize, then seed Shape.** Freezing debt without a pattern plan leaves
12
39
  spaghetti “ENFORCE · design-weak”. Always end with dual-plan **B** seeds (or handoff explore)
@@ -47,10 +74,10 @@ When present, prefer the consumer **domain glossary** for layer names, slice fol
47
74
 
48
75
  | Use `/ark-adopt` when… | Do **not** use it when… |
49
76
  |------------------------|-------------------------|
50
- | Existing messy repo; contract folders | Empty greenfield shape → `/ark-architect` |
51
- | False-green / concentrated edge needs contract truth | Map-only without writing config/baseline → `/ark-explore` |
52
- | Mine loose business rules into Domain / intents | Single violation fix → `/ark-fix` |
53
- | Freeze **real** debt after contract is honest | Grind plan A only → `/ark-loop`; full apply loop → `/ark-autopilot` |
77
+ | Session 0: empty tree or existing repo needs an honest path | Map-only without writing config → `/ark-explore` |
78
+ | False-green / concentrated edge needs config truth | Feature file only → `/ark-place` |
79
+ | Mine loose business rules into Domain / advisory ArkRules | Apply leftover design after the path is honest → `/ark-autopilot` |
80
+ | Freeze **real** debt after the config is honest | User said map only |
54
81
 
55
82
  ## Dual engine (mandatory)
56
83
 
@@ -83,13 +110,13 @@ ArkGate has **two opt-in planes**. The user chooses which to use; you **always l
83
110
  1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
84
111
  2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
85
112
  3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
86
- 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
113
+ 4. Editing `arkrules/*` or promoting modes is **this skill** (session 0) or **`/ark-autopilot`** later; never invent `mechanical-safe`.
87
114
  5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
88
115
 
89
116
 
90
117
  ### Adopt + ArkRules
91
118
  - After classify: emit or refresh `arkRules` for matched layers (exact names; generic mold for unknowns).
92
- - Mine rules → inventory + propose invariants/structure; land via `/ark-contract`.
119
+ - Mine rules → inventory + write advisory invariants/structure into `arkrules/<Layer>.json` **in this turn**.
93
120
  - Freeze baseline is **[Layer]** debt; inventory residual is **[ArkRules]** — report both.
94
121
 
95
122
  ## Subagent fan-out (optional, host-dependent)
@@ -111,10 +138,10 @@ feature dirs, plan clusters), you **may** dispatch **subagents**:
111
138
 
112
139
  ## Related onboarding
113
140
 
114
- - **Greenfield:** `/ark-architect` or `ark-check --recommend` / `ark start`.
115
- - **Brownfield:** `/ark-adopt` — match contract to reality; do not force a starter preset.
141
+ - **Greenfield:** this skill + `ark-check --recommend` / `ark start` — write the scaffold here.
142
+ - **Brownfield:** this skill — match config to reality; do not force a starter preset.
116
143
  - **Deep map only:** `/ark-explore`.
117
- - **Default path:** `ark start` → `/ark-autopilot` `ark-check --doctor`.
144
+ - **Default path:** `ark start` → **`/ark-adopt`** → `/ark-place` / `/ark-autopilot`.
118
145
 
119
146
  ## Anti-wrapper rule (mandatory)
120
147
 
@@ -143,18 +170,18 @@ Ark protects the **boundary around** a framework, not its internals. Nest/DI pub
143
170
  **ApplicationOrchestration**, not Presentation — do not reclassify API shells as UI.
144
171
  2. **Check + diagnose** — `summary.concentrated` / dominant edge → fix contract first, don’t freeze.
145
172
  Cross-slice / cross-context `peerIsolation` hits are judgment: extract shared or events.
146
- If one edge dominates residual debt: **STOP — do not continue this skill as complete.** **STOP — concentrated edge: invoke /ark-contract with source evidence** (do not freeze a wrong contract or grind N freezes).
173
+ If one edge dominates residual debt: **STOP — do not continue this skill as complete.** **STOP — concentrated edge:** rewrite `ark.config.json` **in this turn** with source evidence (do not freeze a wrong config or grind N freezes).
147
174
  Empty Domain/Persistence + I/O under Application → false-green.
148
- **STOP — do not continue this skill as complete.** **STOP — false-green: invoke /ark-adopt or /ark-contract before claiming ENFORCE.** Do not claim goal.met / ENFORCE from type-only cleanup while doctor reports `contract-false-green-io-under-application`.
175
+ **STOP — do not continue this skill as complete.** **STOP — false-green:** fix the config **in this turn** before claiming ENFORCE. Do not claim goal.met / ENFORCE from type-only cleanup while doctor reports `contract-false-green-io-under-application`.
149
176
  3. **Classify ungoverned** — use coverage `suggestions` **plus** dirs you discovered by reading;
150
- add layers/patterns via `/ark-contract`.
177
+ add layers/patterns **here** (write `ark.config.json`).
151
178
  4. **Mine business rules → manifiesto** (model job — this is why the skill exists):
152
179
  - Scan for loose domain: validators, pricing/policy functions, `can*`/`calculate*`, magic business constants, publish/intent strings, logic in UI/hooks that belongs in Domain.
153
180
  - **ArkRules inventory (AR13):** run `ark-check --rules-inventory --json` for deterministic candidates
154
181
  (validation-in-controller, magic constants, anemic entities). Counts are **not a score**.
155
182
  - Propose: Domain files, `intentPrefixes`, intent names (`Domain.*` / `Application.*`), kernel `defineIntent` stubs if runtime is used;
156
- land structure/invariant entries under `arkrules/<Layer>.json` via `/ark-contract` (ADR 0015 routing).
157
- - Apply config through `/ark-contract` discipline; move pure rules into Domain when safe; validate with ark-check.
183
+ land structure/invariant entries under `arkrules/<Layer>.json` **in this turn** (ADR 0015 routing).
184
+ - Write the config; move pure rules into Domain when safe; validate with ark-check.
158
185
  - Deliver section **“Así te lo re-soluciono en el manifiesto”** with before/after contract snippets.
159
186
  5. **Freeze only real debt** — `--update-baseline` (zero debt → **no empty baseline file** left behind).
160
187
  6. **Gates + skills** — `--install-agent-gates` (CI monorepo-aware when `frontend/package.json` exists).
@@ -164,7 +191,7 @@ Ark protects the **boundary around** a framework, not its internals. Nest/DI pub
164
191
  domain logic in UI, or semantic false-green: emit **dual-plan B** (3–5 bets) with pilot,
165
192
  success signal, kill-switch, and extraction cards for I/O moves — same bar as `/ark-explore` §G.
166
193
  - Do **not** claim “adopt complete / healthy” solely because the check is green.
167
- - Prefer handoff `/ark-autopilot` for B execution with user ok, or `/ark-explore` shape-focus
194
+ - Prefer handoff `/ark-autopilot` to apply one Shape refactor, or `/ark-explore` shape-focus
168
195
  if the user only wanted a plan.
169
196
 
170
197
  ## Operating modes
@@ -1,43 +1,24 @@
1
1
  ---
2
2
  name: ark-architect
3
- description: Choose the application shape, adopt phase-1 layers, scaffold directories, and verify honestly for enthusiasts before codegen. Autonomous.
3
+ description: Shortcut to /ark-adopt for greenfield shape. Deprecated as a first-class door. Do adopt’s job.
4
4
  ---
5
5
 
6
- # /ark-architect — Choose your application shape and adopt Ark
6
+ # /ark-architect — Shortcut to /ark-adopt
7
7
 
8
- ## Improvement compass (process preflight)
8
+ **Deprecated as a first-class door.** Session 0 is **`/ark-adopt`**. Do that job now
9
+ (greenfield scaffold via `ark-check --recommend` / MCP `ark_recommend` after `ark_identity`).
9
10
 
10
- When doctor is available, read `doctor.improvementCompass` (or the human **Improvement compass** section).
11
- Name 1–3 **residual** lenses in plain language before skill-shopping. Always `notAScore` — never invent
12
- 0–10 scores or Excellent/Good ranks.
11
+ ## Autonomy contract
13
12
 
14
- **What the user should feel next:** fewer blocked AI writes, clearer folders, safer domain — then jargon.
15
-
16
- **Anti false-done:** empty plan A + residual lenses / design-weak → **Incomplete? yes**. Green edges alone
17
- are not “architecture finished.”
18
-
19
- **AI-easy architecture:** ports over concrete I/O in domain; one concern per module; golden pattern for
20
- new files; place before write (`/ark-place` / prepare-write).
21
-
22
- **Out of scope (honest):** scalability/performance, full app-security tooling (SAST), and full resilience
23
- patterns are **out-of-scope** lenses — say so; do not invent Ark enforcement for them.
24
-
25
- **Greenfield that is AI-easy day one:** golden norm + thin layers so the next agent turn stays ordered.
13
+ Invoking this skill **is** the approval to mark the path. Write `ark.config.json` and
14
+ phase-1 dirs in this turn. Then `ark-check`.
26
15
 
27
16
  ## When / not when
28
17
 
29
- | Use `/ark-architect` when… | Do **not** use it when… |
30
- |----------------------------|-------------------------|
31
- | Greenfield / thin tree; pick shape + phase-1 layers | Existing spaghetti brownfield → `/ark-adopt` (+ `/ark-explore` first if map missing) |
32
- | Enthusiast before heavy codegen | Enforcement residual on mature tree `/ark-autopilot` |
33
-
34
- The user is building something new or early in Ark adoption. They may not know
35
- layered architecture jargon. Your job: translate **what they want to build**
36
- (application shape, not framework name) into an Ark preset, a phase-1 layer plan,
37
- conventional directories, and a passing honest check — without weakening the gate.
38
-
39
- Commands below are written as `ark-check` / `ark`; run each through the project's
40
- package manager (`pnpm exec`, `yarn`, `npx`) — match the lockfile.
18
+ | Use this leftover name when… | Prefer instead |
19
+ |------------------------------|----------------|
20
+ | Muscle memory / old docs say architect | **`/ark-adopt`** (greenfield + brownfield) |
21
+ | Empty tree needs a shape | Same adopt writes the recommend result |
41
22
 
42
23
  ## Dual engine (mandatory)
43
24
 
@@ -48,8 +29,6 @@ package manager (`pnpm exec`, `yarn`, `npx`) — match the lockfile.
48
29
 
49
30
  The CLI is a **sensor**, never the whole job. Claiming done without the exploratory bar for this skill is **incomplete**.
50
31
 
51
-
52
-
53
32
  ## MCP workspace binding (mandatory)
54
33
 
55
34
  Before any `ark_*` MCP tool, call `ark_identity` with `project.expectedRoot` set to the exact
@@ -59,128 +38,31 @@ retain `projectIdentity.projectId`, then pass both `expectedRoot` and `expectedP
59
38
  uncertain, do not consume MCP analysis: use the workspace-local CLI and report that MCP
60
39
  restart/retargeting is required. `ark://manifest` never satisfies this preflight.
61
40
 
62
- ## Dual plane layers + ArkRules (mandatory, except /ark-runtime)
63
-
64
- ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
65
-
66
- | Plane | What it protects | Where it lives | Sensors / tools |
67
- |-------|------------------|----------------|-----------------|
68
- | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
69
- | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
70
-
71
- **Rules for every report / answer:**
72
- 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
73
- 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
74
- 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
75
- 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
76
- 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
41
+ Then call **`ark_recommend`** with the same bound `project` envelope (or `ark-check --recommend`).
77
42
 
43
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
78
44
 
79
- ### Architect + ArkRules
80
- - Preset/init should emit lean `arkRules` + templates for phase-1 layers (exact names).
81
- - Explain to the user: layers = boundaries; arkrules = habits inside Domain/App/adapters (opt-in, start advisory).
45
+ Label findings **`[Layer]`** vs **`[ArkRules]`**. Absence of `arkRules` is valid.
82
46
 
83
47
  ## Subagent fan-out (optional, host-dependent)
84
48
 
85
- If the host supports **parallel subagents** and the task splits cleanly (e.g. multiple
86
- dirs to sample), fan out read-only scouts; otherwise **fall back to sequential**.
87
- Parent merges and still emits the **### Completion** contract. Never parallel-write
88
- the same files or weaken the gate.
49
+ If the host supports **parallel subagents**, fan out read-only scouts; otherwise
50
+ **fall back to sequential**. Never weaken the gate.
89
51
 
90
- ## Relationship to other skills
52
+ ## Related onboarding
91
53
 
92
- | Skill | When |
93
- |-------|------|
94
- | **/ark-architect** | **Before** — greenfield or fresh config; pick shape + phase 1 |
95
- | /ark-adopt | **After** — messy existing repo |
96
- | /ark-contract | **During** — evolve config safely |
97
- | /ark-place | **During** — one new file |
98
- | /ark-explain | **After** — understand what exists |
54
+ - **Greenfield:** this shortcut → **`/ark-adopt`** + `ark-check --recommend` / `ark start`.
55
+ - **Brownfield:** `/ark-adopt` — do not force a starter preset.
99
56
 
100
57
  ## Steps
101
58
 
102
- 1. **Bind and detect the shape** complete the mandatory `ark_identity` preflight first, then
103
- call MCP tool **`ark_recommend`** with the bound `project` envelope (or run the workspace-local
104
- `ark-check --recommend --json`). Never use an unverified recommendation. Read `archetype`, `preset`, `confidence`,
105
- `adoptInOrder.phase1`, `analogy`, `why`, `evidence`, and `requiresConfirmation`.
106
- Ask at most **two** questions only if `requiresConfirmation` is true (or for compatibility
107
- with older ArkGate output, `confidence < 0.5`):
108
- - "Will this app save data between sessions?"
109
- - "Is this one app or several in one repository?"
110
-
111
- 2. **Present in plain English** — name the application shape (e.g. "product with
112
- UI and stored data"), not the framework. One analogy. List **phase-1 layers only**.
113
-
114
- 3. **Map to Ark** — if `ark.config.json` is missing, run
115
- `ark init --archetype <archetype> --yes` (maps playbook id → preset + gates),
116
- or `ark-check --apply-policy-pack enthusiast-<preset>` for the enthusiast variant.
117
- Optional team record: `ark-check --recommend --write-plan` → `ark-adoption-plan.json`.
118
- If a config already exists, use `/ark-contract` to align it — do not regenerate
119
- unasked. On a messy brownfield tree: **STOP — do not continue this skill as complete.** Invoke **/ark-adopt** instead of forcing greenfield shape.
120
-
121
- 4. **Scaffold phase 1** — create conventional directories from the preset/playbook
122
- (`src/domain`, `src/application`, …). Add a one-line README per folder explaining
123
- what belongs there. Match the nearest sibling file style if code already exists.
124
- Flat layouts (`src/` + `lib/` + `api/` at the repo root) are common in Vite and
125
- serverless projects — use `/ark-contract` to map them to layers instead of forcing
126
- everything under `src/**/domain/**` only.
127
-
128
- 5. **Install gates** when the user uses AI coding tools and gates are missing:
129
- `ark-check --install-agent-gates`.
130
-
131
- 6. **Verify honestly** — run `ark-check --doctor` and `ark-check --coverage --json`.
132
- Report `governed.percent`. Say explicitly what is **not** governed yet
133
- (ungoverned directories, empty layers).
134
-
135
- 7. **Deliver to the user**
136
- - ASCII diagram (≤3 boxes for phase 1, inner → outer)
137
- - Table: "when you build X, put it in Y"
138
- - Three rules the agent must not break (no domain→database imports, no raw
139
- `publish()`, no weakening `ark.config.json` to pass)
140
- - Optional book refs from `books` in the recommendation JSON under "go deeper"
141
- - **Gallery starter** — point the user at the matching clonable example:
142
-
143
- | Archetype | Example directory |
144
- |-----------|-------------------|
145
- | `crud-product` | `examples/crud-product-starter/` |
146
- | `api-backend` | `examples/api-backend-starter/` |
147
- | `worker-pipeline` | `examples/worker-pipeline-starter/` |
148
- | `multi-app-workspace` | `examples/multi-app-workspace-starter/` |
149
- | `vertical-slice-product` | `examples/vertical-slice-starter/` |
150
- | `ddd-bounded-contexts` | `examples/ddd-context-starter/` |
151
-
152
- Say they can copy that folder as a baseline (`npm install && npm run check`).
153
- For a runnable API with break exercises, mention `examples/hexagonal-order-api/`.
154
- Full enthusiast track: `docs/enthusiast/README.md`.
155
-
156
- ## Operating rules
157
-
158
- - Never weaken `ark.config.json`, the baseline, CI, or agent settings to pass.
159
- - Never invent layers outside the 11-layer profile or named presets
160
- (`hexagonal`, `layered`, `feature-sliced`, `monorepo`, `ui-surface`,
161
- `vertical-slice`, `ddd-bounded-contexts`).
162
- - Flag unrecognized dirs (`utils/`, `lib/`) — user must classify via `/ark-contract`.
163
- - Default to smallest viable phase 1; unlock phase 2 only when the user describes need.
164
- - All user-facing copy is **English**.
165
-
166
- ## Merge cards (physical cohesion reshape — judgment only)
167
-
168
- When `doctor.physicalCohesion` reports a mirrored concept and the user asks whether files
169
- should be **merged**, treat it as domain modeling, never deduplication (field fact: zero
170
- structural clones among 123 same-concept files). Produce a **merge card** per candidate group:
171
- which files, the domain concept they express, 2–3 shapes the merged module could take, and what
172
- each shape costs — **no default action, no auto-merge, never a codemod**. Physical **moves**
173
- belong to `/ark-loop`'s pilot loop; your job here is the judgment about what the concept IS.
174
-
175
- ## Verify and report
176
-
177
- End with `ark-check --root . --config ark.config.json --strict-config` when the
178
- tree is ready. Report: archetype + preset, directories created, governed %, and
179
- the next command if anything remains ungoverned.
59
+ 1. Bind MCP (`ark_identity` then `ark_recommend`) or run `ark-check --recommend`.
60
+ 2. Execute **`/ark-adopt`** autonomy: write the config, dirs, optional advisory ArkRules, gates.
61
+ 3. `ark-check --strict-config`. Handoff `/ark-place` for new files.
180
62
 
181
63
  ## Completion contract (skill incomplete if missing)
182
64
 
183
- End with **exactly** these headings (markdown `###`):
65
+ Skill incomplete if missing any field below.
184
66
 
185
67
  ### Completion
186
68
  - **Sensor:** commands/tools run
@@ -188,8 +70,5 @@ End with **exactly** these headings (markdown `###`):
188
70
  - **Result:** one-line outcome
189
71
  - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
190
72
  - **Compass:** top residual lenses | `n/a`
191
- - **Handoff:** `/ark-…` / CLI / `none`
73
+ - **Handoff:** `/ark-adopt` / `/ark-place` / `none`
192
74
  - **Incomplete?** `no` | `yes — <what is missing>`
193
-
194
- If a **STOP** handoff applies and you continued as if done, set **Incomplete?** to `yes`.
195
- **Skill incomplete if missing** any of the bullets above.
@@ -1,17 +1,27 @@
1
1
  ---
2
2
  name: ark-autopilot
3
- description: Guided end-to-end path for layers and opt-in ArkRules doctor next action when unsure. Explore first; dual plan A (edges) + B (shape); mechanical-safe only by default; B with user OK, one pilot at a time. Empty plan A is not healthy if design-weak. CLI is a sensor; you read and remediate files.
3
+ description: Apply Ark end-to-end — explore first; dual plan A (edges) + B (shape); write mechanical-safe and judgment in this turn; one Shape refactor. Empty plan A is not healthy if leftover design remains. CLI is a sensor; you edit files.
4
4
  ---
5
5
 
6
- # /ark-autopilot — Guided end-to-end architecture path
6
+ # /ark-autopilot — Apply the path
7
7
 
8
- **This is the full guided co-pilot** after the compact router. Prefer it when the user wants
9
- architecture cleaned end-to-end, not when they only need a map (`/ark-explore`) or a single
10
- edge fix (`/ark-fix`). Doctor remains the control plane: re-check status after each major step.
8
+ **This is the apply door.** Invoking it **is** the approval. Prefer it when the user wants
9
+ architecture cleaned end-to-end, not when they only need a map (`/ark-explore`). Doctor
10
+ remains the control plane: re-check status after each major step.
11
11
 
12
- Composes **explore → sensors → dual plan → loop**. Safe default: auto-apply only
13
- `mechanical-safe`; when the user says full apply / apply everything, also execute **judgment**
14
- fixes you design from reading source (still validate with ark-check, never weaken the gate).
12
+ ## Autonomy contract
13
+
14
+ The CLI is a **sensor and gate**. **CLI budget:** one doctor / `--plan`; open files; **write**;
15
+ re-check. Forbidden as the result: “4 safe / 4 judgment — approve?”, dumping `--plan` JSON,
16
+ or `STOP — invoke /ark-fix` / `/ark-loop` / `/ark-contract`. Do that work **here**.
17
+
18
+ Apply plan A (`mechanical-safe` **and** judgment). If leftover design work remains, apply
19
+ **one** small refactor this turn, then re-doctor. Never batch every Shape bet.
20
+
21
+ Composes **explore → sensors → dual plan → write**. Validate with ark-check; never weaken the gate.
22
+ **Team lock:** do not edit `ark.config.json`, `arkrules/*`, or `.ark-baseline.json` in this
23
+ turn unless the user invoked a steward contract session. Feature diffs use
24
+ `ark-check --changed --base <merge-ref>`. Growing the baseline is steward-only.
15
25
 
16
26
  **Not a plan grinder.** Empty `--plan` does **not** mean “architecture is healthy” without
17
27
  the explore pass and dual-plan section B (pattern / Shape bets).
@@ -33,25 +43,25 @@ new files; place before write (`/ark-place` / prepare-write).
33
43
  **Out of scope (honest):** scalability/performance, full app-security tooling (SAST), and full resilience
34
44
  patterns are **out-of-scope** lenses — say so; do not invent Ark enforcement for them.
35
45
 
36
- **Guided vibe path:** phase 0 = doctor + compass residual. Shape only with user OK. Never script “done” while residual lenses remain.
46
+ **Guided vibe path:** phase 0 = doctor + compass residual. Shape: one refactor this turn (invoke = OK). Never script “done” while residual lenses remain.
37
47
 
38
48
  ## When / not when
39
49
 
40
50
  | Use `/ark-autopilot` when… | Do **not** use it when… |
41
51
  |----------------------------|-------------------------|
42
52
  | “Make architecture sound” end-to-end | Map only, no apply → `/ark-explore` |
43
- | Brownfield or greenfield with apply | Only fitness numbers → `/ark-coverage` |
44
- | User wants A + B planned and A executed | Single edge fix → `/ark-fix`; plan A only → `/ark-loop` |
45
- | **Apply half of post-green Shape path** (after explore map / when user wants full apply) | Skipping explore when doctor primary is Shape map-first |
46
- | Spaghetti under ENFORCE: Shape work with user ok on B | Contract false-green first → `/ark-adopt` / `/ark-contract` STOP paths |
53
+ | Brownfield or greenfield with apply | Session 0 / config lying → `/ark-adopt` first, then return |
54
+ | User wants A + B planned and **applied** | New file only → `/ark-place` |
55
+ | **Apply** leftover design (one Shape refactor) | User said map only |
56
+ | Spaghetti under ENFORCE: Shape work (invoke = apply one pilot) | |
47
57
 
48
- **Post-green door:** doctor’s single door is `/ark-explore` shape-focus → dual-plan B, **then** this skill only
49
- to apply B with OK. Prefer that order when `postGreenPath` / design-weak is the primary residual.
58
+ **Post-green door:** `/ark-explore` shape-focus → dual-plan B, **then this skill applies one
59
+ pilot**. Prefer that order when `postGreenPath` / leftover design work is the primary residual.
50
60
 
51
61
  ## Related onboarding
52
62
 
53
- - **Greenfield:** `/ark-architect` or `ark-check --recommend` / `ark start`.
54
- - **Brownfield:** `/ark-adopt` — match contract to reality; do not force a starter preset.
63
+ - **Greenfield:** `/ark-adopt` or `ark-check --recommend` / `ark start`.
64
+ - **Brownfield:** `/ark-adopt` — match config to reality; do not force a starter preset.
55
65
  - **Deep map only:** `/ark-explore` — full recon / dual-plan seed without applying.
56
66
  - **Adoption fitness only:** `/ark-coverage` — governed% + capability gaps (not pattern dual-plan).
57
67
  - **Default path:** `ark start` → `ark-check --doctor` → **`/ark-autopilot`** (this skill) for guided work.
@@ -73,8 +83,8 @@ decision-grade explore pass **and** without opening violating files.
73
83
  4. **Open every file** in plan A `steps[]` (and `target` if present) before classifying a fix.
74
84
  5. **“Así te lo re-soluciono”** for each A cluster and each B pattern bet.
75
85
  6. Apply A → re-run ark-check → rollback on regression. **Never auto-apply B** as mechanical-safe.
76
- 7. **One-pilot loop for B:** when design-weak, take **`pilotLoop.nextPilot`** (one extraction card)
77
- → apply **only** that pilot with user OK → **re-doctor**. Never multi-pilot batch B; residual
86
+ 7. **One-pilot loop for B:** when leftover design / design-weak, take **`pilotLoop.nextPilot`** (one extraction card)
87
+ → apply **only** that pilot **in this turn** → **re-doctor**. Never multi-pilot batch B; residual
78
88
  outside the pilot may remain and must not be called “healthy finished.”
79
89
  8. **Reshape decision memory:** read `doctor.physicalCohesion.reshapeDecisions` before acting on
80
90
  mirror facts. Outcome first: a current rejected/deferred verdict means “intentional/deferred
@@ -106,7 +116,7 @@ ArkGate has **two opt-in planes**. The user chooses which to use; you **always l
106
116
  1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
107
117
  2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
108
118
  3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
109
- 4. Editing `arkrules/*` or promoting modes is **`/ark-contract`**; fixing code under a structure sensor is **`/ark-fix`** / **`/ark-loop`** (judgment, never invent mechanical-safe).
119
+ 4. Editing `arkrules/*` or promoting modes and fixing structure sensors is **this skill** (judgment, never invent `mechanical-safe`).
110
120
  5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
111
121
 
112
122
 
@@ -150,7 +160,7 @@ Include explore **§G** when spaghetti / design-weak signals fire.
150
160
  5. **Agent/gate reality** — installed hooks vs install templates (e.g. `--hook` vs `--hook-repair`); MCP; CI gate present.
151
161
  6. **Coupling** — fan-in / exports / importers for hotspots (LOC alone is a hint).
152
162
  7. **False-green soft block** — doctor/coverage: empty Domain/Persistence while Application owns I/O (`airtable`, `supabase`, `prisma`, `drizzle`, `repositories`, …). Doctor gap id: `contract-false-green-io-under-application`. If so:
153
- **STOP — do not continue this skill as complete.** **STOP — false-green: invoke /ark-adopt or /ark-contract before claiming ENFORCE.** Do not claim goal.met / ENFORCE from type-only cleanup while doctor reports `contract-false-green-io-under-application`.
163
+ **STOP — do not continue this skill as complete.** **STOP — false-green:** fix the architecture config **in this turn** (same job as `/ark-adopt`) before claiming ENFORCE. Do not claim goal.met / ENFORCE from type-only cleanup while doctor reports `contract-false-green-io-under-application`.
154
164
  8. **Seed dual plan B** — 2–5 pattern / Shape bets ranked (impact × effort × enforceability). Each B row needs pilot + success signal; I/O bets need an **extraction card** (explore §G).
155
165
 
156
166
  Min bar: **≥12 source files** across **≥4 meaningful directories** (not only files in `steps[]`).
@@ -160,16 +170,16 @@ Standalone long report: `/ark-explore`. Adoption fitness only: `/ark-coverage`.
160
170
 
161
171
  | Section | Source | Question | Auto-apply? |
162
172
  |---------|--------|----------|-------------|
163
- | **A. Remediation** | `--plan --json` + opened step files | What must change so the **gate** is honest? | Only `mechanical-safe` by default |
173
+ | **A. Remediation** | `--plan --json` + opened step files | What must change so the **gate** is honest? | Write `mechanical-safe` **and** judgment |
164
174
  | **B. Pattern / Shape** | Explore §B/§G (not coverage alone) | What **design** must improve even if A is empty? | **Never** as mechanical-safe |
165
175
 
166
176
  **Section A** — group by edge; treat `peerIsolation` / cross-slice as **judgment**.
167
177
  **Section B** examples: choose golden pattern + pilot migrate-on-touch, peerIsolation, move rules out of UI, write-path repair, split god modules, Domain placement / intents, facade SQL → port/adapter (extraction card). Cap **3–5** B rows. Each row: evidence path + **así te lo re-soluciono** + next skill/command + **success signal** + **pilot** (+ kill-switch if new layer).
168
178
 
169
- B does **not** count as “architecture healthy finished.” Report B as `proposed | deferred | applied-with-user-ok`.
179
+ B does **not** count as “architecture healthy finished.” Report B as `proposed | deferred | applied`.
170
180
  When A is empty and B is non-empty: status is **`goal.met on edges · Shape residual open`** — never “done” without listing B.
171
- Prefer CLI `patternBets[]` / `designSmells[]` when present; apply B only with explicit user ok using
172
- **extraction cards** (`docs/brownfield-adoption.md` §6) — never mechanical-safe, never silent.
181
+ Prefer CLI `patternBets[]` / `designSmells[]` when present; apply **one** B pilot this turn using
182
+ **extraction cards** (`docs/brownfield-adoption.md` §6) — never mechanical-safe, never silent, never multi-pilot.
173
183
  If B will take multiple PRs, offer (do not require) persisting a short Shape plan under the
174
184
  repo so the next agent session continues the same pilot — still never auto-apply B.
175
185
 
@@ -190,7 +200,7 @@ Status lights from doctor — not settings you choose. Rank residual honestly:
190
200
  | **Suggest** | Thin/new tree; contract not control plane | Finish `ark start` → re-doctor; do not skill-shop |
191
201
  | **Adapt** | Contract/tree disagree or debt open | Explore + adopt/loop/contract; do not claim guarded |
192
202
  | **Enforce** | Honest coverage + clean checked **edges** | Confirm gates + CI; emit dual-plan B only if residual found |
193
- | **Enforce · design-weak** | Edges clean; design smells remain | **Primary Shape door:** explore shape-focus → dual-plan **B** → apply **one** pilot with user OK. Empty plan A ≠ done. Never mechanical-safe B. False-done forbidden. |
203
+ | **Enforce · leftover design work** | Imports clean; design still messy | **Primary Shape door:** explore shape-focus → dual-plan **B** → apply **one** small refactor. Empty plan A ≠ done. Never mechanical-safe B. False-done forbidden. |
194
204
 
195
205
  - **Setup (Suggest):** no config → `ark start` (start freezes origin after config, before gates).
196
206
  - **Align (Adapt):** open debt, low honesty, or false-green → explore + adopt/loop; do not claim “guarded”.
@@ -206,12 +216,12 @@ Status lights from doctor — not settings you choose. Rank residual honestly:
206
216
  3. **Sensors** — `--plan --json`, doctor/coverage as needed.
207
217
  4. **Emit dual plan** — A from plan steps (files opened); B from explore (3–5 bets).
208
218
  5. **Concentrated edge?** — if one edge dominates A:
209
- **STOP — do not continue this skill as complete.** **STOP — concentrated edge: invoke /ark-contract with source evidence** (do not freeze a wrong contract or grind N freezes).
219
+ **STOP — do not continue this skill as complete.** **STOP — concentrated edge:** rewrite `ark.config.json` **in this turn** with source evidence (do not freeze a wrong config or grind N freezes).
210
220
  6. **Worktree preferred** — discardable git worktree when possible.
211
221
  7. **Mechanical-safe (A only)** — kinds from `/ark-loop` table; one step, validate, rollback.
212
- 8. **Judgment (A)** — default: propose with full “así te lo re-soluciono”. If user authorized full apply: implement, validate, rollback on fail.
213
- 9. **Pattern bets (B)** — propose; apply only with explicit user go + correct skill (`/ark-contract`, refactor, install gates, etc.). Never weaken the gate to clear B.
214
- 10. **Manifiesto** — loose business rules → Domain placement + `intentPrefixes` / intents via `/ark-contract` discipline.
222
+ 8. **Judgment (A)** — implement with full “así te lo re-soluciono”; validate; rollback on fail.
223
+ 9. **Pattern bets (B)** — apply **one** extraction-card pilot this turn; leave the rest queued. Never weaken the gate to clear B.
224
+ 10. **Manifiesto** — loose business rules → Domain placement + `intentPrefixes` / intents; write config here if the path is still dishonest.
215
225
  11. **Final report** — re-`--report`; evolution vs origin; A applied vs open; B proposed/deferred; gates on.
216
226
  12. **Strict check** — `ark-check --strict-config` (dead preset globs are advisory; real violations still fail).
217
227
  13. **Core ratchet (when green)** — if plan `goal.met` and doctor still **ADAPT** only because