arkgate 4.2.0 → 4.3.0

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 (46) hide show
  1. package/CHANGELOG.md +86 -4
  2. package/README.md +20 -6
  3. package/bin/ark-mcp-runtime.mjs +64 -0
  4. package/bin/ark-shared.mjs +16 -4
  5. package/bin/ark.mjs +55 -1
  6. package/bin/lib/adapter-contract.mjs +88 -5
  7. package/bin/lib/agent-projection-command.mjs +396 -0
  8. package/bin/lib/agent-projection.mjs +319 -0
  9. package/bin/lib/agent-skills-package.mjs +266 -0
  10. package/bin/lib/baseline-key.mjs +32 -0
  11. package/bin/lib/ci-and-commands.mjs +44 -0
  12. package/bin/lib/diagnostic-catalog.mjs +155 -0
  13. package/bin/lib/physical-cohesion.mjs +2 -1
  14. package/bin/lib/status-command.mjs +369 -0
  15. package/bin/lib/status-manifest.mjs +394 -0
  16. package/dist/eslint/index.cjs +3 -3
  17. package/dist/eslint/index.js +3 -3
  18. package/dist/index.cjs +46 -11
  19. package/dist/index.d.ts +729 -6
  20. package/dist/index.js +46 -11
  21. package/docs/README.md +6 -6
  22. package/docs/agent-guide.md +112 -14
  23. package/docs/configuration.md +7 -0
  24. package/docs/develop.md +8 -0
  25. package/docs/diagnostics.md +606 -0
  26. package/docs/package-surface.md +19 -8
  27. package/docs/product-voice.md +45 -0
  28. package/docs/use.md +23 -0
  29. package/package.json +11 -1
  30. package/schemas/ark.analysis-result.schema.json +14 -1
  31. package/schemas/ark.status-manifest.schema.json +244 -0
  32. package/server.json +2 -2
  33. package/templates/agent-skills/README.md +59 -0
  34. package/templates/agent-skills/ark-adopt/SKILL.md +171 -0
  35. package/templates/agent-skills/ark-architect/SKILL.md +175 -0
  36. package/templates/agent-skills/ark-autopilot/SKILL.md +242 -0
  37. package/templates/agent-skills/ark-contract/SKILL.md +136 -0
  38. package/templates/agent-skills/ark-coverage/SKILL.md +167 -0
  39. package/templates/agent-skills/ark-explain/SKILL.md +210 -0
  40. package/templates/agent-skills/ark-explore/SKILL.md +377 -0
  41. package/templates/agent-skills/ark-fix/SKILL.md +185 -0
  42. package/templates/agent-skills/ark-loop/SKILL.md +180 -0
  43. package/templates/agent-skills/ark-place/SKILL.md +162 -0
  44. package/templates/agent-skills/ark-runtime/SKILL.md +120 -0
  45. package/templates/agent-skills/ark-think/SKILL.md +133 -0
  46. package/templates/agent-skills/ark-upgrade/SKILL.md +218 -0
@@ -0,0 +1,136 @@
1
+ ---
2
+ name: ark-contract
3
+ description: Safely edit ark.config.json layers/rules and arkrules/* (structure + invariants); land business rules under the dual plane. Validated with strict ark-check. Deep source evidence required.
4
+ ---
5
+
6
+ # /ark-contract — Change the architecture contract (safely)
7
+
8
+ ## When / not when
9
+
10
+ | Use `/ark-contract` when… | Do **not** use it when… |
11
+ |---------------------------|-------------------------|
12
+ | Edit layers/rules/includes/intents with source evidence | Move product code without config change → `/ark-fix` / `/ark-loop` |
13
+ | Concentrated-edge / false-green STOP from other skills | Full map without config edit → `/ark-explore` |
14
+
15
+ The **one sanctioned way** to change layers/rules/`intentPrefixes`/includes.
16
+ Also used to **land mined business rules** into the executable manifest (`ark.config.json` +
17
+ intent naming that the project-bound `ark_manifest` tool exposes authoritatively).
18
+
19
+
20
+ ## Dual engine (mandatory)
21
+
22
+ | Engine | Role |
23
+ |--------|------|
24
+ | **Deterministic** | CLI / MCP / contract sensors — exit codes, plan kinds, coverage numbers, install status |
25
+ | **Exploratory** | You open **this** repo's real files and product surface before concluding |
26
+
27
+ The CLI is a **sensor**, never the whole job. Claiming done without the exploratory bar for this skill is **incomplete**.
28
+
29
+
30
+
31
+ ## MCP workspace binding (mandatory)
32
+
33
+ Before any `ark_*` MCP tool, call `ark_identity` with `project.expectedRoot` set to the exact
34
+ workspace root. Continue only when `binding.status === "matched"` and `authoritative === true`;
35
+ retain `projectIdentity.projectId`, then pass both `expectedRoot` and `expectedProjectId` under
36
+ `project` on every later MCP call. If identity is missing, mismatched, unverified, or the root is
37
+ uncertain, do not consume MCP analysis: use the workspace-local CLI and report that MCP
38
+ restart/retargeting is required. `ark://manifest` never satisfies this preflight.
39
+
40
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
41
+
42
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
43
+
44
+ | Plane | What it protects | Where it lives | Sensors / tools |
45
+ |-------|------------------|----------------|-----------------|
46
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
47
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
48
+
49
+ **Rules for every report / answer:**
50
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
51
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
52
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
53
+ 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).
54
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
55
+
56
+
57
+ ### Contract + ArkRules
58
+ - You own **both** `layers/rules` and `arkRules`/`arkrules/*.json`.
59
+ - Report diffs in two blocks: **[Layer] config** and **[ArkRules] files**.
60
+ - Promotion ladder: advisory→enforced only with coverage; demote = hash-ack weakening.
61
+
62
+ ## Subagent fan-out (optional, host-dependent)
63
+
64
+ If the host supports **parallel subagents** and the task splits cleanly (e.g. multiple
65
+ dirs to sample), fan out read-only scouts; otherwise **fall back to sequential**.
66
+ Parent merges and still emits the **### Completion** contract. Never parallel-write
67
+ the same files or weaken the gate.
68
+
69
+ ## Related onboarding
70
+
71
+ - **Greenfield:** `/ark-architect` or `ark-check --recommend` / `ark start`.
72
+ - **Brownfield:** `/ark-adopt` — match contract to reality; do not force a starter preset.
73
+ - **Default path:** `ark start` → `/ark-autopilot` → `ark-check --doctor`.
74
+
75
+ ## Anti-wrapper rule (mandatory)
76
+
77
+ **Forbidden:** editing globs from vibes without reading the directories those globs claim to cover.
78
+
79
+ **Required:**
80
+ 1. Snapshot before using CLI as **sensor**: coverage + check JSON.
81
+ 2. **Read source** in dirs you reclassify (sample files).
82
+ 3. **“Así te lo re-soluciono”** — exact JSON fields + which files become governed/ungoverned.
83
+ 4. After write: `ark-check --strict-config` must be the validation gate (dead pattern noise is advisory; unclassified + real violations still matter).
84
+
85
+ ## What you may edit
86
+
87
+ - `include` / `exclude`
88
+ - `layers[]` (`name`, `patterns`, `optional`, `forbiddenGlobals`, `intentPrefixes`, layer `exclude`)
89
+ - `rules[]` (from/to/allowed)
90
+ - **`arkRules` map + `arkrules/<Layer>.json`** (ADR 0012/0014) — structure sensors + invariant catalog;
91
+ promote advisory→enforced only with coverage evidence; demote/delete requires hash-bound policy ack
92
+ - Never: disable the check, delete CI gates, or add blanket `allowed: true` for a bad edge without a facade design
93
+
94
+ ## Steps
95
+
96
+ 1. **Snapshot** — coverage governed%, unclassified samples, current violations.
97
+ 2. **Smallest edit** for the user intent:
98
+ - New layer + neighbor rules
99
+ - Expand patterns for ungoverned dirs (`suggestions` from coverage)
100
+ - Facade: public surface patterns more specific than internals
101
+ - **Business rules → manifiesto:**
102
+ - Add/adjust `intentPrefixes` (`Domain.`, `Application.`, …)
103
+ - Point Domain patterns at real pure folders (`**/domain/**`, not bare `**/types.ts`)
104
+ - Document proposed intent names for the app to register (kernel) or for agents to use
105
+ 3. **Impact** — re-run coverage/check; report before/after governed% and violation delta.
106
+ 4. **Rollback** if strict fails for reasons other than pre-existing debt the user accepted.
107
+
108
+ ## Operating modes
109
+
110
+ Contract edits are most common in **Align (Adapt)**. In **Guard (Enforce)**, treat edits as high-risk product decisions.
111
+
112
+ ## Critical handoffs
113
+
114
+ - After contract is honest but residual violations remain: **STOP — do not continue this skill as complete.** **STOP — bulk residual debt: invoke /ark-loop or /ark-autopilot** instead of ad-hoc multi-file grinding without a plan.
115
+ - New artifact home after reclassify: **STOP — do not continue this skill as complete.** **STOP — new file placement: invoke /ark-place** when the user needs a new artifact home.
116
+
117
+ ## Done
118
+
119
+ - Diff of `ark.config.json` explained in plain language.
120
+ - **Así te lo re-soluciono en el manifiesto** when intents/Domain were part of the request.
121
+ - Strict check result captured.
122
+
123
+ ## Completion contract (skill incomplete if missing)
124
+
125
+ End with **exactly** these headings (markdown `###`):
126
+
127
+ ### Completion
128
+ - **Sensor:** commands/tools run
129
+ - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
130
+ - **Result:** one-line outcome
131
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
132
+ - **Handoff:** `/ark-…` / CLI / `none`
133
+ - **Incomplete?** `no` | `yes — <what is missing>`
134
+
135
+ If a **STOP** handoff applies and you continued as if done, set **Incomplete?** to `yes`.
136
+ **Skill incomplete if missing** any of the bullets above.
@@ -0,0 +1,167 @@
1
+ ---
2
+ name: ark-coverage
3
+ description: Ark adoption fitness audit — governed%, gates, baseline honesty, capability gaps. CLI is a sensor; read enough source to prove gaps. Full product recon and pattern dual-plan belong to /ark-explore.
4
+ ---
5
+
6
+ # /ark-coverage — Ark adoption fitness (not full recon)
7
+
8
+ You audit **how this repo uses ArkGate** (coverage, gates, baseline, host write path) and
9
+ what adoption gaps remain. Work autonomously. End with a ranked fitness report.
10
+
11
+ **This is not `/ark-explore`.** You do **not** produce a multi-pattern dual-plan or spaghetti
12
+ Shape ladder by default. If the tree is design-weak under ENFORCE, **handoff** to explore.
13
+
14
+ ## When / not when
15
+
16
+ | Use `/ark-coverage` when… | Do **not** use it when… |
17
+ |---------------------------|-------------------------|
18
+ | “How adopted is Ark?” governed%, gates, baseline, skills stale | Full product map / what-next architecture → `/ark-explore` |
19
+ | Capability gaps (CI, write path, ESLint, optional layers) | Apply fixes end-to-end → `/ark-autopilot` |
20
+ | Ranked *adoption* opportunities (install, ratchet, contract classify) | Spaghetti pattern plan / golden pattern → `/ark-explore` dual-plan seed |
21
+ | Quick honesty before a release checklist | One design trade-off → `/ark-think` |
22
+
23
+ ## Dual engine (mandatory)
24
+
25
+ | Engine | Deliverable |
26
+ |--------|-------------|
27
+ | **Deterministic** | governed%, layers, gates, baseline, doctor gaps, summary edges |
28
+ | **Exploratory** | Enough source to prove ungoverned clusters / false-green are real (not JSON-only) |
29
+
30
+ **Forbidden:** only `ark-check --coverage/--doctor/--json` paraphrase with no source evidence.
31
+
32
+ **Required before you finish:**
33
+ 1. CLI sensor: `--coverage --json`, `--doctor`, normal `--json` for `summary`.
34
+ 2. **Product surface** — name the app/package(s) in one line (not a full recon).
35
+ 3. **Read real source** in the top ungoverned / high-risk clusters (minimum **10 files**
36
+ across at least **4 directories**). Prefer domain, features, adapters, routes — not only config.
37
+ 4. **“Así te lo re-soluciono”** for adoption gaps (globs, install, baseline, intents).
38
+ 5. If plan A is empty but you see design-weak / concurrent patterns / god modules:
39
+ list them briefly and **STOP — do not continue this skill as complete** for pattern work —
40
+ **handoff `/ark-explore` (dual-plan seed or shape-focus)**. Do not invent a second explore report here.
41
+
42
+ If you did not open source files, the skill is **not complete**.
43
+ Full recon + pattern planning: `/ark-explore`.
44
+
45
+
46
+ ## MCP workspace binding (mandatory)
47
+
48
+ Before any `ark_*` MCP tool, call `ark_identity` with `project.expectedRoot` set to the exact
49
+ workspace root. Continue only when `binding.status === "matched"` and `authoritative === true`;
50
+ retain `projectIdentity.projectId`, then pass both `expectedRoot` and `expectedProjectId` under
51
+ `project` on every later MCP call. If identity is missing, mismatched, unverified, or the root is
52
+ uncertain, do not consume MCP analysis: use the workspace-local CLI and report that MCP
53
+ restart/retargeting is required. `ark://manifest` never satisfies this preflight.
54
+
55
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
56
+
57
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
58
+
59
+ | Plane | What it protects | Where it lives | Sensors / tools |
60
+ |-------|------------------|----------------|-----------------|
61
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
62
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
63
+
64
+ **Rules for every report / answer:**
65
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
66
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
67
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
68
+ 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).
69
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
70
+
71
+
72
+ ### Coverage + ArkRules
73
+ - Fitness report: governed% / gates / baseline = **[Layer]**; `rulesUnderContract` inventoried/under-contract/frozen = **[ArkRules]** (counts, never a score).
74
+ - Capability gap: “no arkRules map” is optional adoption opportunity, not a failed gate.
75
+
76
+ ## Subagent fan-out (optional, host-dependent)
77
+
78
+ When the user asks to go faster **or** the work naturally splits (multiple packages,
79
+ feature dirs, plan clusters), you **may** dispatch **subagents**:
80
+
81
+ | Host capability | Behavior |
82
+ |-----------------|----------|
83
+ | **Parallel subagents supported** (e.g. multi-agent / `spawn_subagent` / concurrent Agent tools) | Launch **2–N** agents in **one wave** with **disjoint path scopes**. Prefer **read-only** explore agents for mapping; at most **one writer** unless the host gives isolated worktrees. Parent merges findings, then runs `ark-check` once. |
84
+ | **Not supported** (single agent only) | **Fall back to sequential** — same checklist, one cluster/step at a time. Never claim parallel work you did not run. |
85
+
86
+ **Rules:**
87
+ 1. Give each subagent a **tight brief**: paths in scope, sensor commands allowed, deliverable shape (paths opened + findings JSON or bullets).
88
+ 2. **No shared mutable files** across parallel writers.
89
+ 3. STOP handoffs and dual-engine rules still apply in every agent.
90
+ 4. Parent owns the **### Completion** block (union of **Opened**, single **Handoff**).
91
+ 5. Do **not** use subagents to weaken the gate or invent `mechanical-safe` kinds.
92
+
93
+ ## Operating modes (detected — not user-picked)
94
+
95
+ | Mode | User meaning | What you tell them |
96
+ |------|----------------|--------------------|
97
+ | **Suggest / Setup** | Thin or new tree | “Ark will propose a starting shape — you don’t switch a mode.” |
98
+ | **Adapt / Align** | Contract ≠ folders or open debt | “Gates don’t fully protect you yet — classify + fix plan.” |
99
+ | **Enforce / Guard** | Coverage + clean edges + honest cores | “You arrived here for *contract* fitness — design may still be weak; use explore for Shape.” |
100
+
101
+ Never say “your architecture is guarded” while `goal.met` is false, governed% is low,
102
+ or false-green doctor gaps are open. Never say “architecture is healthy finished” solely
103
+ because governed% is 100% and plan is empty.
104
+
105
+ **Honesty hard lines (doctor JSON):**
106
+ - `coverageHonesty.worseThanNoGate` / weak coverage (~&lt;50%): green is **worse than no gate**.
107
+ - `baseline.honesty.dirtyBaselineRisk`: green-via-freeze may hide false-positive debt.
108
+ - `writePath.honesty.softWriteHost` (Cursor / Codex / OpenCode): write path is **advisory /
109
+ best-effort**, not hard PreToolUse — required CI status is the hard merge boundary.
110
+ - Do not invent hard write guarantees for soft hosts.
111
+
112
+ ## Related onboarding
113
+
114
+ - **Greenfield:** low governed% → `/ark-architect` or `ark-check --recommend`.
115
+ - **Brownfield:** `/ark-adopt` for action; this skill for fitness metrics.
116
+ - **Pattern / spaghetti residual:** `/ark-explore` dual-plan seed / shape-focus.
117
+ - **Business rules loose:** note in table; mining action → `/ark-adopt` or `/ark-contract`.
118
+
119
+ ## Checklist (sensor + light code)
120
+
121
+ 1. Config + `ark-check --strict-config`.
122
+ 2. Baseline policy (orphan empty file? wire or delete).
123
+ 3. Host-appropriate write path + `/ark-*` skills per detected agent.
124
+ 4. CI workflow + monorepo install reality.
125
+ 5. ESLint `arkgate/eslint` if ESLint exists.
126
+ 6. Domain `forbiddenGlobals`.
127
+ 7. **Governed%** + unclassified + `suggestions` from `--coverage --json`.
128
+ 8. Concentrated edges in check `summary` → contract smell, not N freezes.
129
+ 9. `layersWithoutRules` + empty cores with I/O under Application (false-green).
130
+ On false-green: **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`.
131
+ On one-edge wall: **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).
132
+ 10. Runtime kernel / Nest only if deps prove it — never force-fit.
133
+
134
+ ## Output format
135
+
136
+ 1. **Headline honesty** — product one-liner, governed%, mode, violations, false-green risk, **design-weak handoff?** (yes/no).
137
+ 2. **Adoption map** — clusters you read for *fitness* (paths) — keep short.
138
+ 3. **Ranked table** (adoption residual + install/capability opportunities)
139
+
140
+ | # | Kind | Gap / opportunity | Evidence (path or CLI) | Así te lo re-soluciono (concrete) | Next |
141
+
142
+ Kinds: `debt` | `false-green` | `shape` | `manifiesto` | `gates` | `opportunity` | `design-weak`
143
+
144
+ 4. If any `design-weak` rows: **Handoff required** → `/ark-explore` (do not expand into full dual-plan here).
145
+ 5. Offer: “Apply top adoption N?” / “Run /ark-adopt?” / “Run /ark-explore for Shape?” — apply only if user agrees.
146
+
147
+ ## Done criteria
148
+
149
+ - ≥10 source files read and cited; product surface named.
150
+ - At least one **Así te lo re-soluciono** block with real paths or install commands.
151
+ - CLI numbers used as evidence, not as the whole report.
152
+ - Design residual either absent with evidence or explicitly handed to `/ark-explore`.
153
+
154
+ ## Completion contract (skill incomplete if missing)
155
+
156
+ End with **exactly** these headings (markdown `###`):
157
+
158
+ ### Completion
159
+ - **Sensor:** commands/tools run
160
+ - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
161
+ - **Result:** one-line outcome
162
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
163
+ - **Handoff:** `/ark-…` / CLI / `none`
164
+ - **Incomplete?** `no` | `yes — <what is missing>`
165
+
166
+ If a **STOP** handoff applies and you continued as if done, set **Incomplete?** to `yes`.
167
+ **Skill incomplete if missing** any of the bullets above.
@@ -0,0 +1,210 @@
1
+ ---
2
+ name: ark-explain
3
+ description: Explain this project's architecture in plain language and generate the showcase HTML report — layers, rules, coverage, gates, and why the contract exists.
4
+ ---
5
+
6
+ # /ark-explain — Understand this project's architecture
7
+
8
+ The user wants to understand the architecture, a specific rule, or why the gate blocked them.
9
+
10
+ ## When / not when
11
+
12
+ | Use `/ark-explain` when… | Do **not** use it when… |
13
+ |--------------------------|-------------------------|
14
+ | Plain-language tour of layers/rules/report | Decision-grade recon / dual-plan → `/ark-explore` |
15
+ | “Why did the gate block me?” pedagogy | Apply fixes → `/ark-fix` / `/ark-autopilot` |
16
+ | Generate / walk HTML showcase report | Fitness numbers only → `/ark-coverage`; brownfield action → `/ark-adopt` |
17
+ Your job is to **teach with this repo's real data** and leave a shareable visual artifact.
18
+
19
+ ## Dual engine (mandatory)
20
+
21
+ | Engine | Role |
22
+ |--------|------|
23
+ | **Deterministic** | CLI / MCP / contract sensors — exit codes, plan kinds, coverage numbers, install status |
24
+ | **Exploratory** | You open **this** repo's real files and product surface before concluding |
25
+
26
+ The CLI is a **sensor**, never the whole job. Claiming done without the exploratory bar for this skill is **incomplete**.
27
+
28
+
29
+
30
+ ## MCP workspace binding (mandatory)
31
+
32
+ Before any `ark_*` MCP tool, call `ark_identity` with `project.expectedRoot` set to the exact
33
+ workspace root. Continue only when `binding.status === "matched"` and `authoritative === true`;
34
+ retain `projectIdentity.projectId`, then pass both `expectedRoot` and `expectedProjectId` under
35
+ `project` on every later MCP call. If identity is missing, mismatched, unverified, or the root is
36
+ uncertain, do not consume MCP analysis: use the workspace-local CLI and report that MCP
37
+ restart/retargeting is required. `ark://manifest` never satisfies this preflight.
38
+
39
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
40
+
41
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
42
+
43
+ | Plane | What it protects | Where it lives | Sensors / tools |
44
+ |-------|------------------|----------------|-----------------|
45
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
46
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
47
+
48
+ **Rules for every report / answer:**
49
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
50
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
51
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
52
+ 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).
53
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
54
+
55
+
56
+ ### Explain + ArkRules
57
+ - HTML/plain tour: section **Layers** and section **Rules under contract (ArkRules)** —
58
+ when `arkRules` is active the showcase lists **per-layer counts**, **structure sensors**
59
+ (id / sensor / mode), **uncovered** invariants (call them out), and a **covered sample**.
60
+ Inactive map stays a short opt-in note. Counts are never a score.
61
+ - Spoken tour: name 2–4 real invariant IDs and one structure sensor from this repo’s
62
+ `arkrules/*` (open the files — do not invent). Residual candidates → `--rules-inventory`.
63
+ - **Teach the product model (required when arkRules is active):**
64
+ - **[Layer]** = dependency direction / purity / capabilities.
65
+ - **[ArkRules] structure** = module-shape **heuristics** (orchestration-only, thin-adapter, …);
66
+ enforced is not proof of Domain extraction.
67
+ - **[ArkRules] invariants** = named business policies as **data + coverage evidence**
68
+ (symbol/test); not a runtime engine and not a substitute for behavior tests.
69
+ - Green edges + covered catalog ≠ elegant Shape (design-weak residual stays honest).
70
+ - Never merge Layers and ArkRules into one “architecture score.”
71
+
72
+ ## Subagent fan-out (optional, host-dependent)
73
+
74
+ If the host supports **parallel subagents** and the task splits cleanly (e.g. multiple
75
+ dirs to sample), fan out read-only scouts; otherwise **fall back to sequential**.
76
+ Parent merges and still emits the **### Completion** contract. Never parallel-write
77
+ the same files or weaken the gate.
78
+
79
+ ## Always do this first (showcase report)
80
+
81
+ 1. Run the full HTML report (uses the real contract + coverage + gates):
82
+
83
+ ```bash
84
+ npx ark-check --root . --config ark.config.json --report ark-report.html
85
+ ```
86
+
87
+ Prefer the project's package-manager runner if gates already emit one
88
+ (`pnpm … exec ark-check` / `yarn` / `npx`).
89
+
90
+ This also maintains snapshots under **`.ark/reports/`**:
91
+ - `origin.json` / `origin.html` — frozen **day-zero** report (`ark start`/`ark init`
92
+ freezes this **right after** `ark.config.json`, before agent docs/CI templates)
93
+ - `latest.json` / `latest.html` — every run
94
+ - `history/*.json` — last ~20 machine-readable points for later tooling
95
+
96
+ If origin already exists, the HTML includes **Evolution vs origin** (score, governed%,
97
+ violations, files per layer). Do not delete origin unless the user explicitly wants a
98
+ new baseline (`--reset-origin`).
99
+
100
+ 2. Tell the user the path to `ark-report.html` and `.ark/reports/origin.html`.
101
+ Mention `.ark/` should stay gitignored (Ark appends that on first report when possible).
102
+
103
+ 3. **Open the report in the default browser** (mandatory when `ark-report.html` exists and
104
+ this is a local interactive session — skip only in CI/headless or if the user said not to):
105
+
106
+ Detect OS and run **one** simple open (best-effort; do not fail the skill if open fails):
107
+
108
+ | OS | Command |
109
+ |----|---------|
110
+ | **macOS** | `open ark-report.html` |
111
+ | **Linux** | `xdg-open ark-report.html` |
112
+ | **Windows** | `start ark-report.html` (cmd) or `Invoke-Item ark-report.html` (PowerShell) |
113
+
114
+ One-liner that picks the host OS (from the project root, after the report was written):
115
+
116
+ ```bash
117
+ # macOS / Linux / Windows (Git Bash or similar)
118
+ case "$(uname -s 2>/dev/null || echo unknown)" in
119
+ Darwin*) open ark-report.html ;;
120
+ Linux*) xdg-open ark-report.html ;;
121
+ MINGW*|MSYS*|CYGWIN*|Windows_NT) start ark-report.html 2>/dev/null || cmd.exe /c start ark-report.html ;;
122
+ *) open ark-report.html 2>/dev/null || xdg-open ark-report.html 2>/dev/null || true ;;
123
+ esac
124
+ ```
125
+
126
+ Prefer the absolute path if the cwd is not the project root. This only opens the file in
127
+ the **default browser** — no special flags, no browser selection.
128
+
129
+ 4. Optionally also run:
130
+
131
+ ```bash
132
+ npx ark-check --coverage
133
+ npx ark-check --doctor
134
+ npx ark-check --plan
135
+ ```
136
+
137
+ so your spoken explanation matches the report's governed%, operating mode
138
+ (SUGGEST / ADAPT / ENFORCE), and the plan's safe-to-auto vs decision counts.
139
+
140
+ The HTML report is the visual twin of this skill: architecture map, files per layer,
141
+ dependency direction, matrix, violations, **ArkRules under contract** (when mapped),
142
+ enforcement points, Ark fitness score, and a **Senior diagnostics** block (coupling
143
+ fan-in/out, deny density, purity surface, pattern forensics, baseline taxonomy) for
144
+ tech leads.
145
+
146
+ When explaining the **plan**, name the four `mechanical-safe` remediation kinds only
147
+ (type-only move, pure-type file relocate, `import type` of pure-type modules,
148
+ `import-type-of-type-exports` for named type exports from mixed modules; W6 port-proof inject is judgment when proof holds) — everything
149
+ else is judgment/deferred and must not be auto-applied.
150
+
151
+ **Type-edge honesty:** type-only denied edges are **placement debt** (`typeOnly` +
152
+ `failsStrict: false`) — prefer SharedTypes / owning layer; they do not fail merge like value
153
+ edges. Doctor `productHonesty` and `violations.typeEdgePolicy` must not be sold as “all done”
154
+ when residual signals remain.
155
+
156
+ ## Spoken / written explanation
157
+
158
+ 1. **Load the real contract**: `ark.config.json`, `AGENTS.md`, and—when MCP is available—
159
+ `ark_identity` with the exact project root followed by `ark_manifest` with the same root plus
160
+ returned project id. `ark://manifest` is compatibility-only and always
161
+ unverified/non-authoritative.
162
+ 2. **If asked generally** ("explain the architecture"), produce a guided tour:
163
+ - Operating mode + governed% (honest: low coverage means green checks almost nothing).
164
+ - Each major layer: name, purpose, one real file from this repo, file count if known.
165
+ - Dependency direction in one short diagram (ASCII is fine).
166
+ - Enforcement points that are actually on: write gate, CI, ESLint, baseline.
167
+ - If a DI/kernel framework border exists, explain public surface vs internals.
168
+ 3. **If asked about a specific rule or block**, answer with: the rule, the consequence it
169
+ prevents, and the sanctioned fix (usually a port). If they want it fixed now:
170
+ **STOP — do not continue this skill as complete.** **STOP — fix requested: invoke /ark-fix.**
171
+ This skill stays read-only.
172
+ 4. **If asked "what's a port/adapter/saga…"**, two sentences + this-repo example or conventional path.
173
+
174
+ ## Operating rules
175
+
176
+ - Prefer generating the HTML report even when the question is narrow — then zoom the prose.
177
+ - Read-only for source code: this skill does not refactor product files (writing the report
178
+ HTML is fine).
179
+ - Calibrate depth: one-rule questions get a paragraph; full tours get structure + report.
180
+ - Every jargon term gets a one-line plain definition on first use.
181
+ - End with:
182
+ - the strict check from `package.json` (or `ark-check --root . --config ark.config.json --strict-config`)
183
+ - `/ark-place` for "where does new code go?"
184
+ - the path to `ark-report.html`
185
+ - **open that HTML in the default browser** (step 3 above: `open` / `xdg-open` / `start`)
186
+ if you have not already — so the user sees the showcase without hunting for the file
187
+
188
+ ## Related
189
+
190
+ - Onboarding: `/ark-architect`, `ark-check --recommend`, `docs/enthusiast/README.md`
191
+ - Brownfield: `/ark-adopt`, `docs/brownfield-adoption.md`
192
+ - Autopilot: `/ark-autopilot` after the user understands the contract
193
+
194
+ ## Completion contract (skill incomplete if missing)
195
+
196
+ End with **exactly** these headings (markdown `###`):
197
+
198
+ ### Completion
199
+ - **Sensor:** commands/tools run (include report + browser-open command when used)
200
+ - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
201
+ - **Result:** one-line outcome (include `ark-report.html` path; note if browser open was attempted)
202
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
203
+ - **Handoff:** `/ark-…` / CLI / `none`
204
+ - **Incomplete?** `no` | `yes — <what is missing>`
205
+
206
+ Prefer **Incomplete?** `yes` if the showcase report was generated but the browser-open step was
207
+ skipped without CI/headless/user-opt-out reason.
208
+
209
+ If a **STOP** handoff applies and you continued as if done, set **Incomplete?** to `yes`.
210
+ **Skill incomplete if missing** any of the bullets above.