arkgate 4.2.1 → 4.4.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 (63) hide show
  1. package/CHANGELOG.md +85 -3
  2. package/README.md +24 -8
  3. package/bin/ark-check-runtime.mjs +16 -1
  4. package/bin/ark-mcp-runtime.mjs +64 -0
  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 +55 -5
  12. package/bin/lib/diagnostic-catalog.mjs +155 -0
  13. package/bin/lib/doctor-plan.mjs +25 -0
  14. package/bin/lib/html-report-advisories.mjs +33 -0
  15. package/bin/lib/html-report-depth.mjs +24 -0
  16. package/bin/lib/improvement-compass-doctor.mjs +106 -0
  17. package/bin/lib/improvement-compass.mjs +630 -0
  18. package/bin/lib/status-command.mjs +369 -0
  19. package/bin/lib/status-manifest.mjs +431 -0
  20. package/dist/eslint/index.cjs +3 -3
  21. package/dist/eslint/index.js +3 -3
  22. package/dist/index.cjs +46 -11
  23. package/dist/index.d.ts +886 -6
  24. package/dist/index.js +46 -11
  25. package/docs/README.md +9 -8
  26. package/docs/agent-guide.md +128 -14
  27. package/docs/configuration.md +7 -0
  28. package/docs/develop.md +12 -1
  29. package/docs/diagnostics.md +606 -0
  30. package/docs/package-surface.md +44 -31
  31. package/docs/product-voice.md +71 -0
  32. package/docs/use.md +60 -1
  33. package/package.json +7 -1
  34. package/schemas/ark.analysis-result.schema.json +14 -1
  35. package/schemas/ark.status-manifest.schema.json +270 -0
  36. package/server.json +2 -2
  37. package/templates/agent-skills/README.md +59 -0
  38. package/templates/agent-skills/ark-adopt/SKILL.md +191 -0
  39. package/templates/agent-skills/ark-architect/SKILL.md +195 -0
  40. package/templates/agent-skills/ark-autopilot/SKILL.md +262 -0
  41. package/templates/agent-skills/ark-contract/SKILL.md +156 -0
  42. package/templates/agent-skills/ark-coverage/SKILL.md +187 -0
  43. package/templates/agent-skills/ark-explain/SKILL.md +230 -0
  44. package/templates/agent-skills/ark-explore/SKILL.md +397 -0
  45. package/templates/agent-skills/ark-fix/SKILL.md +205 -0
  46. package/templates/agent-skills/ark-loop/SKILL.md +200 -0
  47. package/templates/agent-skills/ark-place/SKILL.md +182 -0
  48. package/templates/agent-skills/ark-runtime/SKILL.md +127 -0
  49. package/templates/agent-skills/ark-think/SKILL.md +153 -0
  50. package/templates/agent-skills/ark-upgrade/SKILL.md +238 -0
  51. package/templates/skills/ark-adopt.md +20 -0
  52. package/templates/skills/ark-architect.md +21 -1
  53. package/templates/skills/ark-autopilot.md +25 -5
  54. package/templates/skills/ark-contract.md +20 -0
  55. package/templates/skills/ark-coverage.md +20 -0
  56. package/templates/skills/ark-explain.md +20 -0
  57. package/templates/skills/ark-explore.md +23 -3
  58. package/templates/skills/ark-fix.md +22 -2
  59. package/templates/skills/ark-loop.md +22 -2
  60. package/templates/skills/ark-place.md +20 -0
  61. package/templates/skills/ark-runtime.md +7 -0
  62. package/templates/skills/ark-think.md +20 -0
  63. package/templates/skills/ark-upgrade.md +20 -0
@@ -0,0 +1,153 @@
1
+ ---
2
+ name: ark-think
3
+ description: Host-side architectural reasoning — 2–3 enforceable options on layer and/or ArkRules planes for ONE decision. Not full recon (use /ark-explore). No gate bypass. No package LLM call.
4
+ ---
5
+
6
+ # /ark-think — Architectural reasoning (host LLM only)
7
+
8
+ You are the user's architecture thinking partner **inside** the project's Ark contract.
9
+ This skill does **not** call any LLM API from the arkgate package. **You** (the host agent)
10
+ reason; the write-gate and CI remain deterministic.
11
+
12
+ ## Improvement compass (process preflight)
13
+
14
+ When doctor is available, read `doctor.improvementCompass` (or the human **Improvement compass** section).
15
+ Name 1–3 **residual** lenses in plain language before skill-shopping. Always `notAScore` — never invent
16
+ 0–10 scores or Excellent/Good ranks.
17
+
18
+ **What the user should feel next:** fewer blocked AI writes, clearer folders, safer domain — then jargon.
19
+
20
+ **Anti false-done:** empty plan A + residual lenses / design-weak → **Incomplete? yes**. Green edges alone
21
+ are not “architecture finished.”
22
+
23
+ **AI-easy architecture:** ports over concrete I/O in domain; one concern per module; golden pattern for
24
+ new files; place before write (`/ark-place` / prepare-write).
25
+
26
+ **Out of scope (honest):** scalability/performance, full app-security tooling (SAST), and full resilience
27
+ patterns are **out-of-scope** lenses — say so; do not invent Ark enforcement for them.
28
+
29
+ **2–3 options labeled by lens impact** (what residual improves / what stays out-of-scope).
30
+
31
+ ## When / not when
32
+
33
+ | Use `/ark-think` when… | Do **not** use it when… |
34
+ |------------------------|-------------------------|
35
+ | One decision: new layer vs slice, port vs shared, peerIsolation choice | Full map / ranked residual / dual-plan seed → `/ark-explore` |
36
+ | 2–3 options already bounded by a known surface | Apply remediation → `/ark-fix` / `/ark-loop` / `/ark-autopilot` |
37
+ | Trade-offs before writing a **new** feature | Brownfield contract wrong / false-green → `/ark-adopt` then `/ark-contract` |
38
+ | Explain *why* a rule exists in *this* tree | HTML tour → `/ark-explain`; fitness numbers → `/ark-coverage` |
39
+
40
+ If you lack a product map and the tree is messy: run a **compressed** explore pass first
41
+ (≥8 files) **or** **STOP** and invoke `/ark-explore` — do not invent options from diagrams alone.
42
+
43
+ ## Dual engine (mandatory)
44
+
45
+ | Engine | Role |
46
+ |--------|------|
47
+ | **Deterministic** | What the contract and doctor *prove* today (layers, rules, governed%, gaps) |
48
+ | **Exploratory** | What *this* decision surface wants — options grounded in files you open |
49
+
50
+ Never reason only from abstract hexagons. Open real modules before recommending a shape.
51
+
52
+
53
+ ## MCP workspace binding (mandatory)
54
+
55
+ Before any `ark_*` MCP tool, call `ark_identity` with `project.expectedRoot` set to the exact
56
+ workspace root. Continue only when `binding.status === "matched"` and `authoritative === true`;
57
+ retain `projectIdentity.projectId`, then pass both `expectedRoot` and `expectedProjectId` under
58
+ `project` on every later MCP call. If identity is missing, mismatched, unverified, or the root is
59
+ uncertain, do not consume MCP analysis: use the workspace-local CLI and report that MCP
60
+ restart/retargeting is required. `ark://manifest` never satisfies this preflight.
61
+
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`.
77
+
78
+
79
+ ### Think + ArkRules
80
+ - For ONE decision, consider options on **both** planes when relevant: e.g. new layer wall **vs** structure sensor **vs** invariant catalog entry.
81
+ - Every option must state enforceability: which plane holds it after the change.
82
+
83
+ ## Subagent fan-out (optional, host-dependent)
84
+
85
+ When the user asks to go faster **or** the work naturally splits (multiple packages,
86
+ feature dirs, plan clusters), you **may** dispatch **subagents**:
87
+
88
+ | Host capability | Behavior |
89
+ |-----------------|----------|
90
+ | **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. |
91
+ | **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. |
92
+
93
+ **Rules:**
94
+ 1. Give each subagent a **tight brief**: paths in scope, sensor commands allowed, deliverable shape (paths opened + findings JSON or bullets).
95
+ 2. **No shared mutable files** across parallel writers.
96
+ 3. STOP handoffs and dual-engine rules still apply in every agent.
97
+ 4. Parent owns the **### Completion** block (union of **Opened**, single **Handoff**).
98
+ 5. Do **not** use subagents to weaken the gate or invent `mechanical-safe` kinds.
99
+
100
+ ## Steps
101
+
102
+ 1. **Load the contract** — `ark.config.json`; when MCP is available, call `ark_identity` with
103
+ the exact project root followed by `ark_manifest` with the same root plus returned project
104
+ id. The `ark://manifest` resource is compatibility-only and always
105
+ unverified/non-authoritative. Use `ark-check --coverage --json` / `--doctor` for honesty
106
+ about governed% and false-green.
107
+ 2. **Touch the decision surface** — README skim + **≥5 source files** on the feature/package/boundary
108
+ under discussion. Name paths in the answer.
109
+ 3. **Name the active shape** — which preset/archetype fits (hexagonal, vertical-slice,
110
+ ddd-bounded-contexts, feature-sliced, monorepo, …). If none, run `--recommend --json`
111
+ **and** say whether detection matches the tree you opened.
112
+ 4. **Name concurrent patterns** on the decision surface (if ≥2): which is **golden** vs legacy.
113
+ 5. **Reason within bounds** — propose **2–3 options** that **stay enforceable** by the gate.
114
+ Prefer concrete paths and import rules over abstract diagrams.
115
+ 6. **Explore alternatives** — for each option: coupling, testability, **AI-agent safety**,
116
+ migration cost, **pilot + kill-switch** if the option adds a layer or wall.
117
+ 7. **Surface hard lines** — never suggest: weakening `ark.config.json` to pass, silent
118
+ judgment auto-apply, codemod engines, or skipping write-gate/CI.
119
+ 8. **Hand off** — placement `/ark-place`; config `/ark-contract`; bulk debt `/ark-loop` /
120
+ `/ark-autopilot`; map-only `/ark-explore`; violations `/ark-fix`.
121
+ When the user needs action not advice: **STOP — do not continue this skill as complete** — invoke the handoff skill.
122
+
123
+ ## Output format
124
+
125
+ - **Context:** product + contract + what you opened (paths) + phase if known (Align/Stabilize/Shape)
126
+ - **Options:** 2–3 alternatives with trade-offs (coupling, testability, agent safety, enforceability)
127
+ - **Recommendation:** one option + why it is enforceable **today**
128
+ - **Pilot / kill-switch:** if the choice changes shape or adds a layer
129
+ - **Risks if we pick wrong:** one sentence user-visible impact
130
+ - **Next command:** exact `ark-check` / skill to run next
131
+
132
+ ## Related
133
+
134
+ - Greenfield shape: `/ark-architect`
135
+ - Brownfield: `/ark-adopt`
136
+ - Full recon / dual-plan seed: `/ark-explore`
137
+ - Explain existing: `/ark-explain`
138
+
139
+ ## Completion contract (skill incomplete if missing)
140
+
141
+ End with **exactly** these headings (markdown `###`):
142
+
143
+ ### Completion
144
+ - **Sensor:** commands/tools run
145
+ - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
146
+ - **Result:** one-line outcome
147
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
148
+ - **Compass:** top residual lenses | `n/a`
149
+ - **Handoff:** `/ark-…` / CLI / `none`
150
+ - **Incomplete?** `no` | `yes — <what is missing>`
151
+
152
+ If a **STOP** handoff applies and you continued as if done, set **Incomplete?** to `yes`.
153
+ **Skill incomplete if missing** any of the bullets above.
@@ -0,0 +1,238 @@
1
+ ---
2
+ name: ark-upgrade
3
+ description: Upgrade ArkGate through a content-identity preview, preserve customized files, and verify the active host and architecture contract.
4
+ ---
5
+
6
+ # /ark-upgrade — managed ArkGate upgrade
7
+
8
+ Upgrade the published `arkgate` package and its managed gates without treating a
9
+ filename, package version, or similar-looking file as proof of ownership. The
10
+ preview is the source of truth: inspect it before applying anything.
11
+
12
+ For greenfield onboarding, start with `/ark-architect` (or
13
+ `ark-check --recommend`); for a brownfield repository, use `/ark-adopt` before
14
+ this upgrade flow.
15
+
16
+ ## Improvement compass (process preflight)
17
+
18
+ When doctor is available, read `doctor.improvementCompass` (or the human **Improvement compass** section).
19
+ Name 1–3 **residual** lenses in plain language before skill-shopping. Always `notAScore` — never invent
20
+ 0–10 scores or Excellent/Good ranks.
21
+
22
+ **What the user should feel next:** fewer blocked AI writes, clearer folders, safer domain — then jargon.
23
+
24
+ **Anti false-done:** empty plan A + residual lenses / design-weak → **Incomplete? yes**. Green edges alone
25
+ are not “architecture finished.”
26
+
27
+ **AI-easy architecture:** ports over concrete I/O in domain; one concern per module; golden pattern for
28
+ new files; place before write (`/ark-place` / prepare-write).
29
+
30
+ **Out of scope (honest):** scalability/performance, full app-security tooling (SAST), and full resilience
31
+ patterns are **out-of-scope** lenses — say so; do not invent Ark enforcement for them.
32
+
33
+ **After upgrade:** refresh projection; re-doctor; compass residual still drives process, not scores.
34
+
35
+ ## Dual engine (mandatory)
36
+
37
+ Use the semantic sensor (`ark-check --doctor --json` plus the strict contract
38
+ check) and direct inspection of every managed file the preview will change.
39
+ Neither signal replaces the other.
40
+
41
+
42
+ ## MCP workspace binding (mandatory)
43
+
44
+ Before any `ark_*` MCP tool, call `ark_identity` with `project.expectedRoot` set to the exact
45
+ workspace root. Continue only when `binding.status === "matched"` and `authoritative === true`;
46
+ retain `projectIdentity.projectId`, then pass both `expectedRoot` and `expectedProjectId` under
47
+ `project` on every later MCP call. If identity is missing, mismatched, unverified, or the root is
48
+ uncertain, do not consume MCP analysis: use the workspace-local CLI and report that MCP
49
+ restart/retargeting is required. `ark://manifest` never satisfies this preflight.
50
+
51
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
52
+
53
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
54
+
55
+ | Plane | What it protects | Where it lives | Sensors / tools |
56
+ |-------|------------------|----------------|-----------------|
57
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
58
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
59
+
60
+ **Rules for every report / answer:**
61
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
62
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
63
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
64
+ 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).
65
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
66
+
67
+
68
+ ### Upgrade + ArkRules
69
+ - Refresh skills + note if templates gained ArkRules deepen; do not force consumers to adopt `arkRules`.
70
+ - After upgrade: doctor `rulesUnderContract` if map exists; dual-truth note if `--no-install` left package pin old.
71
+
72
+ ## Safety contract
73
+
74
+ - Always invoke the **project-local** CLI (`npx arkgate` /
75
+ `node node_modules/arkgate/bin/ark.mjs`). Bare PATH `ark` / `arkgate` is unsafe
76
+ when a global 2.x install shadows the project (mutative legacy upgrade).
77
+ - `ark upgrade` (managed era) is read-only. It reports the selected profile and hosts, every
78
+ managed asset, its content state, and the exact next command.
79
+ - The first `ark upgrade --apply` updates the dependency and lockfile, then runs
80
+ the newly installed CLI to produce another read-only preview. It does **not**
81
+ apply that preview's gate or skill changes.
82
+ - The post-update/no-install preview's `nextCommand` includes
83
+ `--plan-digest <sha256:…>` and applies only that exact candidate. A changed file
84
+ or selection invalidates the digest instead of being overwritten.
85
+ - Missing or conflicted assets previously recorded as managed require explicit
86
+ `--accept-conflicts`. Stop and obtain user consent before using it.
87
+ - Customized files are preserved. Unrelated source files and similar filenames
88
+ are never adopted. The command never writes a Codex home or another global
89
+ directory implicitly.
90
+ - Do not combine this flow with legacy `--force`, `--migrate-commands`, or
91
+ `--codex-home` repair commands. Diagnose any older adoption debt separately.
92
+
93
+ ## Read the states
94
+
95
+ | State | Meaning | Action |
96
+ |---|---|---|
97
+ | `current` | Content identity matches the candidate. | Record/adopt safely; metadata-only stamps may refresh. |
98
+ | `stale` | Recorded managed content still matches its old identity. | Safe candidate replacement. |
99
+ | `missing` | Candidate is absent. | Create if new; require consent if a recorded asset was deleted. |
100
+ | `customized` | User content diverged without a competing managed base. | Preserve it. |
101
+ | `conflicted` | Both managed base and user content diverged. | Preserve and require explicit consent. |
102
+ | `retired` | A recorded asset is no longer selected by the candidate. | Preserve its file and manifest identity; take no action. |
103
+
104
+ ## Procedure
105
+
106
+ 1. **Resolve the project CLI (mandatory before any upgrade command).** Prefer the
107
+ **project-local** binary — never bare `ark` / `arkgate` from PATH unless you
108
+ prove it is this project's install.
109
+
110
+ Resolution order:
111
+
112
+ 1. `node node_modules/arkgate/bin/ark.mjs` from the repository root (both `arkgate`
113
+ and `ark` package bins map to this file).
114
+ 2. Package-manager exec from the project: `npx arkgate`, `pnpm exec arkgate`,
115
+ `yarn arkgate`, etc.
116
+
117
+ **Do not** use bare `ark` / `arkgate` from PATH unless `which ark` (or the
118
+ resolved realpath) is under this project's `node_modules/arkgate`, or the
119
+ binary reports the **same** version as `node_modules/arkgate/package.json` and
120
+ supports managed upgrade.
121
+
122
+ **Capability probe (abort if missing):** run
123
+ `node node_modules/arkgate/bin/ark.mjs upgrade --help` (or the resolved local
124
+ equivalent) and require a **managed upgrade** surface — help text must mention
125
+ `--plan-digest` (and read-only `upgrade --json` preview). If the only available
126
+ CLI is old (global Homebrew / npm global 2.x, or any binary whose help lacks
127
+ `--plan-digest`), **stop**: skill incomplete; do **not** preview or apply.
128
+ Global 2.x `ark upgrade` is mutative and can rewrite managed skills, forcing a
129
+ later `--accept-conflicts` recovery.
130
+
131
+ **Recovery (preferred → optional):**
132
+
133
+ - Preferred: package-manager runner from project / `--root`
134
+ (`npx arkgate upgrade …` / `pnpm exec arkgate upgrade …` / `yarn arkgate upgrade …`).
135
+ This works when arkgate is **hoisted** and a nested package has no shallow
136
+ `node_modules/arkgate`.
137
+ - Secondary: `node node_modules/arkgate/bin/ark.mjs upgrade …` from the
138
+ **workspace install root** (not a nested package lacking a local install).
139
+ - Optional: refresh a global install with `npm i -g arkgate@latest` only if the
140
+ user wants a global binary; still prefer project-local for this procedure.
141
+
142
+ Record the resolved CLI path/version, read
143
+ `node_modules/arkgate/package.json`, query `npm view arkgate version`, identify
144
+ the repository package manager, and open the intervening entries in the
145
+ shipped `CHANGELOG.md` (fall back to registry or release notes and name that
146
+ source). Do not infer “latest” from `node_modules` alone.
147
+
148
+ 2. **Preview managed content.** Using the **project-local** CLI from step 1
149
+ (never a bare PATH `ark` that failed the probe), run:
150
+
151
+ ```bash
152
+ npx arkgate upgrade --json
153
+ # or: node node_modules/arkgate/bin/ark.mjs upgrade --json
154
+ ```
155
+
156
+ Pass `--root <path>` and `--tools <active-host>` when selection would otherwise
157
+ be ambiguous. Open the reported files that matter to this repository. Confirm
158
+ that customized files remain non-applying and that any deletion/conflict is
159
+ blocked.
160
+
161
+ 3. **Update and re-preview.** If the registry is newer, run (project-local CLI):
162
+
163
+ ```bash
164
+ npx arkgate upgrade --apply
165
+ ```
166
+
167
+ This updates through the detected package manager and hands control to the new
168
+ package for a fresh preview. Review that new preview; do not assume the old
169
+ candidate and new candidate are identical. If already on the latest package,
170
+ retain the current read-only preview.
171
+
172
+ For pnpm repositories with `minimumReleaseAge`, use the repository's existing
173
+ trusted first-party exception mechanism when the new release is still cooling
174
+ off, and prove `pnpm install --frozen-lockfile` succeeds.
175
+
176
+ 4. **Apply only the reviewed candidate.** When there are no blocked assets, run
177
+ the preview's **exact** `nextCommand` as emitted (JSON field / human “Apply the
178
+ exact preview with: …”). That command is already **project-local**
179
+ (`npx arkgate` / `pnpm exec arkgate` / `yarn arkgate` — never bare PATH `ark`).
180
+ Do **not** rewrite it to bare `ark upgrade`; pasting through a global 2.x PATH
181
+ reintroduces the mutative footgun. Shape:
182
+
183
+ ```bash
184
+ npx arkgate upgrade --apply --no-install --plan-digest <preview-digest>
185
+ ```
186
+
187
+ If recorded deletion/conflict recovery is desired, ask first and then add
188
+ `--accept-conflicts`. Never add it merely to make the run green. Run a second
189
+ preview and require `summary.changed: 0`.
190
+
191
+ 5. **Verify enforcement and architecture.** Run
192
+ `npx arkgate-check --doctor --json` (or the project-local `ark-check`) and
193
+ the same fail-closed architecture command used by managed apply (normally
194
+ `npx arkgate-check --root . --config ark.config.json --strict-merge --json`).
195
+ Require `completeness: "complete"` and `ok: true`. Treat provider-unavailable CI
196
+ required-check evidence as `unverified`, never as proof that merges are
197
+ blocked. If new violations appear, hand off to `/ark-fix` for a small set or
198
+ `/ark-loop` / `/ark-autopilot` for residual debt; do not regenerate a baseline
199
+ without explicit approval.
200
+
201
+ ## Active host vs deferred hosts
202
+
203
+ **Active host:** its repo-local gate, skills, MCP/advisory surface, doctor evidence,
204
+ and strict check must be coherent before completion.
205
+
206
+ **Deferred hosts:** inactive hosts may remain untouched and must be named with a
207
+ future repair command when relevant. Deferred hosts never make Incomplete? `yes`
208
+ once the active host and shared repository surfaces are verified. A temporary
209
+ upgrade path or an actively selected host is not deferred.
210
+
211
+ The managed manifest retains the selected host set, so a later preview does not
212
+ silently switch to a different host. Home-level Codex setup is separate and is
213
+ never an implicit side effect of this skill.
214
+
215
+ ## Subagent fan-out (optional, host-dependent)
216
+
217
+ Parallelize independent preview, changelog, and enforcement checks when the
218
+ host supports isolated subagents; otherwise fall back to sequential execution.
219
+
220
+ ## Completion contract (skill incomplete if missing)
221
+
222
+ Skill incomplete if missing any required verification or any field below.
223
+
224
+ End with exactly this structure:
225
+
226
+ ### Completion
227
+ - **Sensor:** commands/tools run
228
+ - **Opened:** real project and changelog paths read
229
+ - **Active host:** host and verified status
230
+ - **Deferred hosts:** `none` or host plus future action
231
+ - **Result:** old → new version and managed-upgrade outcome
232
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
233
+ - **Compass:** top residual lenses | `n/a`
234
+ - **Handoff:** `/ark-…`, CLI action, or `none`
235
+ - **Incomplete?** `no` or `yes — <missing work>`
236
+
237
+ If a required verification did not run or a conflict remains blocked, report the
238
+ task incomplete. Deferred hosts (including Codex when inactive) never make Incomplete? yes.
@@ -12,6 +12,25 @@ with a burn-down. A green check over a wrong contract is a **false green**.
12
12
  spaghetti “ENFORCE · design-weak”. Always end with dual-plan **B** seeds (or handoff explore)
13
13
  when design smells remain after the contract is honest.
14
14
 
15
+ ## Improvement compass (process preflight)
16
+
17
+ When doctor is available, read `doctor.improvementCompass` (or the human **Improvement compass** section).
18
+ Name 1–3 **residual** lenses in plain language before skill-shopping. Always `notAScore` — never invent
19
+ 0–10 scores or Excellent/Good ranks.
20
+
21
+ **What the user should feel next:** fewer blocked AI writes, clearer folders, safer domain — then jargon.
22
+
23
+ **Anti false-done:** empty plan A + residual lenses / design-weak → **Incomplete? yes**. Green edges alone
24
+ are not “architecture finished.”
25
+
26
+ **AI-easy architecture:** ports over concrete I/O in domain; one concern per module; golden pattern for
27
+ new files; place before write (`/ark-place` / prepare-write).
28
+
29
+ **Out of scope (honest):** scalability/performance, full app-security tooling (SAST), and full resilience
30
+ patterns are **out-of-scope** lenses — say so; do not invent Ark enforcement for them.
31
+
32
+ **Spaghetti → honest contract.** SoC/DIP false-green STOP paths in plain language; residual lenses stay Incomplete until mapped.
33
+
15
34
  ## When / not when
16
35
 
17
36
  | Use `/ark-adopt` when… | Do **not** use it when… |
@@ -164,6 +183,7 @@ End with **exactly** these headings (markdown `###`):
164
183
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
165
184
  - **Result:** one-line outcome
166
185
  - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
186
+ - **Compass:** top residual lenses | `n/a`
167
187
  - **Handoff:** `/ark-…` / CLI / `none`
168
188
  - **Incomplete?** `no` | `yes — <what is missing>`
169
189
 
@@ -5,6 +5,25 @@ description: Choose the application shape, adopt phase-1 layers, scaffold direct
5
5
 
6
6
  # /ark-architect — Choose your application shape and adopt Ark
7
7
 
8
+ ## Improvement compass (process preflight)
9
+
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.
13
+
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.
26
+
8
27
  ## When / not when
9
28
 
10
29
  | Use `/ark-architect` when… | Do **not** use it when… |
@@ -144,7 +163,7 @@ the same files or weaken the gate.
144
163
  - Default to smallest viable phase 1; unlock phase 2 only when the user describes need.
145
164
  - All user-facing copy is **English**.
146
165
 
147
- ## Merge cards (X04 reshape — judgment only)
166
+ ## Merge cards (physical cohesion reshape — judgment only)
148
167
 
149
168
  When `doctor.physicalCohesion` reports a mirrored concept and the user asks whether files
150
169
  should be **merged**, treat it as domain modeling, never deduplication (field fact: zero
@@ -168,6 +187,7 @@ End with **exactly** these headings (markdown `###`):
168
187
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
169
188
  - **Result:** one-line outcome
170
189
  - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
190
+ - **Compass:** top residual lenses | `n/a`
171
191
  - **Handoff:** `/ark-…` / CLI / `none`
172
192
  - **Incomplete?** `no` | `yes — <what is missing>`
173
193
 
@@ -16,6 +16,25 @@ fixes you design from reading source (still validate with ark-check, never weake
16
16
  **Not a plan grinder.** Empty `--plan` does **not** mean “architecture is healthy” without
17
17
  the explore pass and dual-plan section B (pattern / Shape bets).
18
18
 
19
+ ## Improvement compass (process preflight)
20
+
21
+ When doctor is available, read `doctor.improvementCompass` (or the human **Improvement compass** section).
22
+ Name 1–3 **residual** lenses in plain language before skill-shopping. Always `notAScore` — never invent
23
+ 0–10 scores or Excellent/Good ranks.
24
+
25
+ **What the user should feel next:** fewer blocked AI writes, clearer folders, safer domain — then jargon.
26
+
27
+ **Anti false-done:** empty plan A + residual lenses / design-weak → **Incomplete? yes**. Green edges alone
28
+ are not “architecture finished.”
29
+
30
+ **AI-easy architecture:** ports over concrete I/O in domain; one concern per module; golden pattern for
31
+ new files; place before write (`/ark-place` / prepare-write).
32
+
33
+ **Out of scope (honest):** scalability/performance, full app-security tooling (SAST), and full resilience
34
+ patterns are **out-of-scope** lenses — say so; do not invent Ark enforcement for them.
35
+
36
+ **Guided vibe path:** phase 0 = doctor + compass residual. Shape only with user OK. Never script “done” while residual lenses remain.
37
+
19
38
  ## When / not when
20
39
 
21
40
  | Use `/ark-autopilot` when… | Do **not** use it when… |
@@ -23,10 +42,10 @@ the explore pass and dual-plan section B (pattern / Shape bets).
23
42
  | “Make architecture sound” end-to-end | Map only, no apply → `/ark-explore` |
24
43
  | Brownfield or greenfield with apply | Only fitness numbers → `/ark-coverage` |
25
44
  | User wants A + B planned and A executed | Single edge fix → `/ark-fix`; plan A only → `/ark-loop` |
26
- | **Apply half of Q01 post-green path** (after explore map / when user wants full apply) | Skipping explore when doctor primary is Shape map-first |
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 |
27
46
  | Spaghetti under ENFORCE: Shape work with user ok on B | Contract false-green first → `/ark-adopt` / `/ark-contract` STOP paths |
28
47
 
29
- **Q01:** doctor’s single door is `/ark-explore` shape-focus → dual-plan B, **then** this skill only
48
+ **Post-green door:** doctor’s single door is `/ark-explore` shape-focus → dual-plan B, **then** this skill only
30
49
  to apply B with OK. Prefer that order when `postGreenPath` / design-weak is the primary residual.
31
50
 
32
51
  ## Related onboarding
@@ -54,10 +73,10 @@ decision-grade explore pass **and** without opening violating files.
54
73
  4. **Open every file** in plan A `steps[]` (and `target` if present) before classifying a fix.
55
74
  5. **“Así te lo re-soluciono”** for each A cluster and each B pattern bet.
56
75
  6. Apply A → re-run ark-check → rollback on regression. **Never auto-apply B** as mechanical-safe.
57
- 7. **Q04 pilot loop for B:** when design-weak, take **`pilotLoop.nextPilot`** (one extraction card)
76
+ 7. **One-pilot loop for B:** when design-weak, take **`pilotLoop.nextPilot`** (one extraction card)
58
77
  → apply **only** that pilot with user OK → **re-doctor**. Never multi-pilot batch B; residual
59
78
  outside the pilot may remain and must not be called “healthy finished.”
60
- 8. **Y01 reshape verdicts:** read `doctor.physicalCohesion.reshapeDecisions` before acting on
79
+ 8. **Reshape decision memory:** read `doctor.physicalCohesion.reshapeDecisions` before acting on
61
80
  mirror facts. Outcome first: a current rejected/deferred verdict means “intentional/deferred
62
81
  layout — no pilot”; never reconstruct that dead card from `findings`. When the user accepts,
63
82
  defers, or rejects a live card, persist its exact `decisionTarget` with a non-empty reason and
@@ -199,7 +218,7 @@ Status lights from doctor — not settings you choose. Rank residual honestly:
199
218
  populated cores are `optional: true`, run `ark-check --ratchet-cores` then `--doctor`.
200
219
  Never ratchet while active violations remain or false-green gap is open.
201
220
 
202
- ## Mechanical-edit hygiene (Y04 — outcome gate)
221
+ ## Mechanical-edit hygiene (outcome gate)
203
222
 
204
223
  - Header injection must **merge into the existing doc comment**; the kept result has one `/**`, not stacked headers.
205
224
  - Route completion or movement must **preserve the original typed `defineRoute<…>(opts, handler)` call**; reconstruct that call instead of extracting untyped opts/handler constants that drop generics or contextual typing.
@@ -235,6 +254,7 @@ End with **exactly** these headings (markdown `###`):
235
254
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
236
255
  - **Result:** one-line outcome
237
256
  - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
257
+ - **Compass:** top residual lenses | `n/a`
238
258
  - **Handoff:** `/ark-…` / CLI / `none`
239
259
  - **Incomplete?** `no` | `yes — <what is missing>`
240
260
 
@@ -5,6 +5,25 @@ description: Safely edit ark.config.json layers/rules and arkrules/* (structure
5
5
 
6
6
  # /ark-contract — Change the architecture contract (safely)
7
7
 
8
+ ## Improvement compass (process preflight)
9
+
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.
13
+
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
+ **Contract edits are last resort.** Policy-delta honesty; do not weaken rules to clear compass residual.
26
+
8
27
  ## When / not when
9
28
 
10
29
  | Use `/ark-contract` when… | Do **not** use it when… |
@@ -129,6 +148,7 @@ End with **exactly** these headings (markdown `###`):
129
148
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
130
149
  - **Result:** one-line outcome
131
150
  - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
151
+ - **Compass:** top residual lenses | `n/a`
132
152
  - **Handoff:** `/ark-…` / CLI / `none`
133
153
  - **Incomplete?** `no` | `yes — <what is missing>`
134
154
 
@@ -11,6 +11,25 @@ what adoption gaps remain. Work autonomously. End with a ranked fitness report.
11
11
  **This is not `/ark-explore`.** You do **not** produce a multi-pattern dual-plan or spaghetti
12
12
  Shape ladder by default. If the tree is design-weak under ENFORCE, **handoff** to explore.
13
13
 
14
+ ## Improvement compass (process preflight)
15
+
16
+ When doctor is available, read `doctor.improvementCompass` (or the human **Improvement compass** section).
17
+ Name 1–3 **residual** lenses in plain language before skill-shopping. Always `notAScore` — never invent
18
+ 0–10 scores or Excellent/Good ranks.
19
+
20
+ **What the user should feel next:** fewer blocked AI writes, clearer folders, safer domain — then jargon.
21
+
22
+ **Anti false-done:** empty plan A + residual lenses / design-weak → **Incomplete? yes**. Green edges alone
23
+ are not “architecture finished.”
24
+
25
+ **AI-easy architecture:** ports over concrete I/O in domain; one concern per module; golden pattern for
26
+ new files; place before write (`/ark-place` / prepare-write).
27
+
28
+ **Out of scope (honest):** scalability/performance, full app-security tooling (SAST), and full resilience
29
+ patterns are **out-of-scope** lenses — say so; do not invent Ark enforcement for them.
30
+
31
+ **Fitness numbers + handoff** when residual lenses are non-empty — never call coverage “done architecture.”
32
+
14
33
  ## When / not when
15
34
 
16
35
  | Use `/ark-coverage` when… | Do **not** use it when… |
@@ -160,6 +179,7 @@ End with **exactly** these headings (markdown `###`):
160
179
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
161
180
  - **Result:** one-line outcome
162
181
  - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
182
+ - **Compass:** top residual lenses | `n/a`
163
183
  - **Handoff:** `/ark-…` / CLI / `none`
164
184
  - **Incomplete?** `no` | `yes — <what is missing>`
165
185
 
@@ -7,6 +7,25 @@ description: Explain this project's architecture in plain language and generate
7
7
 
8
8
  The user wants to understand the architecture, a specific rule, or why the gate blocked them.
9
9
 
10
+ ## Improvement compass (process preflight)
11
+
12
+ When doctor is available, read `doctor.improvementCompass` (or the human **Improvement compass** section).
13
+ Name 1–3 **residual** lenses in plain language before skill-shopping. Always `notAScore` — never invent
14
+ 0–10 scores or Excellent/Good ranks.
15
+
16
+ **What the user should feel next:** fewer blocked AI writes, clearer folders, safer domain — then jargon.
17
+
18
+ **Anti false-done:** empty plan A + residual lenses / design-weak → **Incomplete? yes**. Green edges alone
19
+ are not “architecture finished.”
20
+
21
+ **AI-easy architecture:** ports over concrete I/O in domain; one concern per module; golden pattern for
22
+ new files; place before write (`/ark-place` / prepare-write).
23
+
24
+ **Out of scope (honest):** scalability/performance, full app-security tooling (SAST), and full resilience
25
+ patterns are **out-of-scope** lenses — say so; do not invent Ark enforcement for them.
26
+
27
+ **Tour by lenses** (teach, not score). Prefer showcase HTML + doctor compass section when explaining residual.
28
+
10
29
  ## When / not when
11
30
 
12
31
  | Use `/ark-explain` when… | Do **not** use it when… |
@@ -200,6 +219,7 @@ End with **exactly** these headings (markdown `###`):
200
219
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
201
220
  - **Result:** one-line outcome (include `ark-report.html` path; note if browser open was attempted)
202
221
  - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
222
+ - **Compass:** top residual lenses | `n/a`
203
223
  - **Handoff:** `/ark-…` / CLI / `none`
204
224
  - **Incomplete?** `no` | `yes — <what is missing>`
205
225