arkgate 3.9.2 → 4.0.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 (75) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/README.md +16 -4
  3. package/bin/ark-check-runtime.mjs +75 -3
  4. package/bin/ark-mcp-runtime.mjs +94 -0
  5. package/bin/lib/adapter-contract.mjs +14 -1
  6. package/bin/lib/analysis-engine.mjs +8 -8
  7. package/bin/lib/architecture-scan.mjs +35 -2
  8. package/bin/lib/arkrule-file-hints.mjs +71 -0
  9. package/bin/lib/arkrules-contract.mjs +382 -0
  10. package/bin/lib/arkrules-sensors.mjs +411 -0
  11. package/bin/lib/config-contract.mjs +85 -6
  12. package/bin/lib/doctor-advisories.mjs +14 -1
  13. package/bin/lib/doctor-plan.mjs +21 -0
  14. package/bin/lib/effective-contract-load.mjs +116 -0
  15. package/bin/lib/field-install.mjs +104 -0
  16. package/bin/lib/graph-blind.mjs +20 -1
  17. package/bin/lib/html-report-advisories.mjs +12 -5
  18. package/bin/lib/install-migrate.mjs +20 -2
  19. package/bin/lib/invariant-coverage-io.mjs +157 -0
  20. package/bin/lib/invariant-coverage.mjs +127 -0
  21. package/bin/lib/managed-upgrade.mjs +1 -1
  22. package/bin/lib/policy-delta-io.mjs +33 -0
  23. package/bin/lib/presets.mjs +241 -1
  24. package/bin/lib/remediation.mjs +28 -0
  25. package/bin/lib/resolved-candidate-facts.mjs +14 -1
  26. package/bin/lib/rules-inventory.mjs +144 -0
  27. package/bin/lib/rules-under-contract.mjs +320 -0
  28. package/bin/lib/start-preview.mjs +24 -7
  29. package/bin/lib/upgrade-command.mjs +373 -16
  30. package/dist/{configTypes-DAPvBqK6.d.ts → configTypes-CC0FEXoF.d.ts} +16 -3
  31. package/dist/eslint/index.cjs +2 -2
  32. package/dist/eslint/index.d.ts +1 -1
  33. package/dist/eslint/index.js +2 -2
  34. package/dist/index.cjs +14 -7
  35. package/dist/index.d.ts +615 -20
  36. package/dist/index.js +13 -6
  37. package/docs/README.md +5 -3
  38. package/docs/agent-guide.md +7 -3
  39. package/docs/ai-gates.md +6 -1
  40. package/docs/brownfield-adoption.md +22 -0
  41. package/docs/configuration.md +53 -4
  42. package/docs/develop.md +8 -2
  43. package/docs/enthusiast/README.md +11 -0
  44. package/docs/package-surface.md +13 -10
  45. package/docs/product-voice.md +11 -2
  46. package/docs/use.md +11 -0
  47. package/package.json +4 -17
  48. package/schemas/ark.analysis-result.schema.json +9 -1
  49. package/schemas/ark.arkrules.schema.json +141 -0
  50. package/schemas/ark.config.schema.json +10 -2
  51. package/schemas/ark.resolved-candidate-facts.schema.json +1 -1
  52. package/server.json +2 -2
  53. package/templates/arkrules/ApplicationOrchestration.json +14 -0
  54. package/templates/arkrules/DomainModel.json +32 -0
  55. package/templates/arkrules/PersistenceAdapters.json +14 -0
  56. package/templates/arkrules/PresentationAdapters.json +14 -0
  57. package/templates/skills/ark-adopt.md +28 -1
  58. package/templates/skills/ark-architect.md +23 -0
  59. package/templates/skills/ark-autopilot.md +27 -1
  60. package/templates/skills/ark-contract.md +27 -1
  61. package/templates/skills/ark-coverage.md +23 -0
  62. package/templates/skills/ark-explain.md +39 -3
  63. package/templates/skills/ark-explore.md +26 -1
  64. package/templates/skills/ark-fix.md +23 -0
  65. package/templates/skills/ark-loop.md +23 -0
  66. package/templates/skills/ark-place.md +26 -0
  67. package/templates/skills/ark-runtime.md +4 -0
  68. package/templates/skills/ark-think.md +24 -1
  69. package/templates/skills/ark-upgrade.md +80 -11
  70. package/compat/nestjs.cjs +0 -2
  71. package/compat/nestjs.d.ts +0 -2
  72. package/compat/nestjs.js +0 -1
  73. package/compat/runtime.cjs +0 -2
  74. package/compat/runtime.d.ts +0 -2
  75. package/compat/runtime.js +0 -1
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ark-think
3
- description: Host-side architectural reasoning — 2–3 enforceable options from real code + contract for ONE decision. Not full recon (use /ark-explore). No gate bypass. No package LLM call.
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
4
  ---
5
5
 
6
6
  # /ark-think — Architectural reasoning (host LLM only)
@@ -30,6 +30,28 @@ If you lack a product map and the tree is messy: run a **compressed** explore pa
30
30
 
31
31
  Never reason only from abstract hexagons. Open real modules before recommending a shape.
32
32
 
33
+
34
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
35
+
36
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
37
+
38
+ | Plane | What it protects | Where it lives | Sensors / tools |
39
+ |-------|------------------|----------------|-----------------|
40
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
41
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
42
+
43
+ **Rules for every report / answer:**
44
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
45
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
46
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
47
+ 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).
48
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
49
+
50
+
51
+ ### Think + ArkRules
52
+ - For ONE decision, consider options on **both** planes when relevant: e.g. new layer wall **vs** structure sensor **vs** invariant catalog entry.
53
+ - Every option must state enforceability: which plane holds it after the change.
54
+
33
55
  ## Subagent fan-out (optional, host-dependent)
34
56
 
35
57
  When the user asks to go faster **or** the work naturally splits (multiple packages,
@@ -91,6 +113,7 @@ End with **exactly** these headings (markdown `###`):
91
113
  - **Sensor:** commands/tools run
92
114
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
93
115
  - **Result:** one-line outcome
116
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
94
117
  - **Handoff:** `/ark-…` / CLI / `none`
95
118
  - **Incomplete?** `no` | `yes — <what is missing>`
96
119
 
@@ -19,9 +19,34 @@ Use the semantic sensor (`ark-check --doctor --json` plus the strict contract
19
19
  check) and direct inspection of every managed file the preview will change.
20
20
  Neither signal replaces the other.
21
21
 
22
+
23
+ ## Dual plane — layers + ArkRules (mandatory, except /ark-runtime)
24
+
25
+ ArkGate has **two opt-in planes**. The user chooses which to use; you **always label** findings so they never blur.
26
+
27
+ | Plane | What it protects | Where it lives | Sensors / tools |
28
+ |-------|------------------|----------------|-----------------|
29
+ | **Layers** (inter-layer) | Who may import whom, capabilities, pure/forbiddenGlobals, peerIsolation | `ark.config.json` → `layers[]`, `rules[]` | graph check, baseline edges, doctor coverage % |
30
+ | **ArkRules** (intra-layer) | Structure inside a layer + domain invariants as data | `arkRules` map + `arkrules/<ExactLayerName>.json` | structure sensors, invariant coverage, `--rules-inventory`, doctor `rulesUnderContract` |
31
+
32
+ **Rules for every report / answer:**
33
+ 1. Prefix each finding or next step with **`[Layer]`** or **`[ArkRules]`** (or a two-column table with those headers).
34
+ 2. Never call an import-edge violation an “invariant” or an aggregate sensor a “layer deny.”
35
+ 3. Absence of `arkRules` is **valid** — do not force ArkRules unless the user wants them or residual inventory clearly wants a pilot.
36
+ 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).
37
+ 5. CLI helpers: `ark-check --rules-inventory --json`, doctor JSON `rulesUnderContract`, sensors emit `ARKRULE_*` / `INVARIANT_UNCOVERED` with `evidence.arkruleId`.
38
+
39
+
40
+ ### Upgrade + ArkRules
41
+ - Refresh skills + note if templates gained ArkRules deepen; do not force consumers to adopt `arkRules`.
42
+ - After upgrade: doctor `rulesUnderContract` if map exists; dual-truth note if `--no-install` left package pin old.
43
+
22
44
  ## Safety contract
23
45
 
24
- - `ark upgrade` is read-only. It reports the selected profile and hosts, every
46
+ - Always invoke the **project-local** CLI (`npx arkgate` /
47
+ `node node_modules/arkgate/bin/ark.mjs`). Bare PATH `ark` / `arkgate` is unsafe
48
+ when a global 2.x install shadows the project (mutative legacy upgrade).
49
+ - `ark upgrade` (managed era) is read-only. It reports the selected profile and hosts, every
25
50
  managed asset, its content state, and the exact next command.
26
51
  - The first `ark upgrade --apply` updates the dependency and lockfile, then runs
27
52
  the newly installed CLI to produce another read-only preview. It does **not**
@@ -50,16 +75,54 @@ Neither signal replaces the other.
50
75
 
51
76
  ## Procedure
52
77
 
53
- 1. **Establish versions and context.** Read the installed
78
+ 1. **Resolve the project CLI (mandatory before any upgrade command).** Prefer the
79
+ **project-local** binary — never bare `ark` / `arkgate` from PATH unless you
80
+ prove it is this project's install.
81
+
82
+ Resolution order:
83
+
84
+ 1. `node node_modules/arkgate/bin/ark.mjs` from the repository root (both `arkgate`
85
+ and `ark` package bins map to this file).
86
+ 2. Package-manager exec from the project: `npx arkgate`, `pnpm exec arkgate`,
87
+ `yarn arkgate`, etc.
88
+
89
+ **Do not** use bare `ark` / `arkgate` from PATH unless `which ark` (or the
90
+ resolved realpath) is under this project's `node_modules/arkgate`, or the
91
+ binary reports the **same** version as `node_modules/arkgate/package.json` and
92
+ supports managed upgrade.
93
+
94
+ **Capability probe (abort if missing):** run
95
+ `node node_modules/arkgate/bin/ark.mjs upgrade --help` (or the resolved local
96
+ equivalent) and require a **managed upgrade** surface — help text must mention
97
+ `--plan-digest` (and read-only `upgrade --json` preview). If the only available
98
+ CLI is old (global Homebrew / npm global 2.x, or any binary whose help lacks
99
+ `--plan-digest`), **stop**: skill incomplete; do **not** preview or apply.
100
+ Global 2.x `ark upgrade` is mutative and can rewrite managed skills, forcing a
101
+ later `--accept-conflicts` recovery.
102
+
103
+ **Recovery (preferred → optional):**
104
+
105
+ - Preferred: package-manager runner from project / `--root`
106
+ (`npx arkgate upgrade …` / `pnpm exec arkgate upgrade …` / `yarn arkgate upgrade …`).
107
+ This works when arkgate is **hoisted** and a nested package has no shallow
108
+ `node_modules/arkgate`.
109
+ - Secondary: `node node_modules/arkgate/bin/ark.mjs upgrade …` from the
110
+ **workspace install root** (not a nested package lacking a local install).
111
+ - Optional: refresh a global install with `npm i -g arkgate@latest` only if the
112
+ user wants a global binary; still prefer project-local for this procedure.
113
+
114
+ Record the resolved CLI path/version, read
54
115
  `node_modules/arkgate/package.json`, query `npm view arkgate version`, identify
55
116
  the repository package manager, and open the intervening entries in the
56
117
  shipped `CHANGELOG.md` (fall back to registry or release notes and name that
57
118
  source). Do not infer “latest” from `node_modules` alone.
58
119
 
59
- 2. **Preview managed content.** Run:
120
+ 2. **Preview managed content.** Using the **project-local** CLI from step 1
121
+ (never a bare PATH `ark` that failed the probe), run:
60
122
 
61
123
  ```bash
62
- ark upgrade --json
124
+ npx arkgate upgrade --json
125
+ # or: node node_modules/arkgate/bin/ark.mjs upgrade --json
63
126
  ```
64
127
 
65
128
  Pass `--root <path>` and `--tools <active-host>` when selection would otherwise
@@ -67,10 +130,10 @@ Neither signal replaces the other.
67
130
  that customized files remain non-applying and that any deletion/conflict is
68
131
  blocked.
69
132
 
70
- 3. **Update and re-preview.** If the registry is newer, run:
133
+ 3. **Update and re-preview.** If the registry is newer, run (project-local CLI):
71
134
 
72
135
  ```bash
73
- ark upgrade --apply
136
+ npx arkgate upgrade --apply
74
137
  ```
75
138
 
76
139
  This updates through the detected package manager and hands control to the new
@@ -83,20 +146,25 @@ Neither signal replaces the other.
83
146
  off, and prove `pnpm install --frozen-lockfile` succeeds.
84
147
 
85
148
  4. **Apply only the reviewed candidate.** When there are no blocked assets, run
86
- the preview's exact `nextCommand`, whose shape is:
149
+ the preview's **exact** `nextCommand` as emitted (JSON field / human “Apply the
150
+ exact preview with: …”). That command is already **project-local**
151
+ (`npx arkgate` / `pnpm exec arkgate` / `yarn arkgate` — never bare PATH `ark`).
152
+ Do **not** rewrite it to bare `ark upgrade`; pasting through a global 2.x PATH
153
+ reintroduces the mutative footgun. Shape:
87
154
 
88
155
  ```bash
89
- ark upgrade --apply --no-install --plan-digest <preview-digest>
156
+ npx arkgate upgrade --apply --no-install --plan-digest <preview-digest>
90
157
  ```
91
158
 
92
159
  If recorded deletion/conflict recovery is desired, ask first and then add
93
160
  `--accept-conflicts`. Never add it merely to make the run green. Run a second
94
161
  preview and require `summary.changed: 0`.
95
162
 
96
- 5. **Verify enforcement and architecture.** Run `ark-check --doctor --json` and
163
+ 5. **Verify enforcement and architecture.** Run
164
+ `npx arkgate-check --doctor --json` (or the project-local `ark-check`) and
97
165
  the same fail-closed architecture command used by managed apply (normally
98
- `ark-check --root . --config ark.config.json --strict-merge --json`). Require
99
- `completeness: "complete"` and `ok: true`. Treat provider-unavailable CI
166
+ `npx arkgate-check --root . --config ark.config.json --strict-merge --json`).
167
+ Require `completeness: "complete"` and `ok: true`. Treat provider-unavailable CI
100
168
  required-check evidence as `unverified`, never as proof that merges are
101
169
  blocked. If new violations appear, hand off to `/ark-fix` for a small set or
102
170
  `/ark-loop` / `/ark-autopilot` for residual debt; do not regenerate a baseline
@@ -133,6 +201,7 @@ End with exactly this structure:
133
201
  - **Active host:** host and verified status
134
202
  - **Deferred hosts:** `none` or host plus future action
135
203
  - **Result:** old → new version and managed-upgrade outcome
204
+ - **Planes:** one-line split of residual **[Layer]** vs **[ArkRules]** (or `n/a` if unused)
136
205
  - **Handoff:** `/ark-…`, CLI action, or `none`
137
206
  - **Incomplete?** `no` or `yes — <missing work>`
138
207
 
package/compat/nestjs.cjs DELETED
@@ -1,2 +0,0 @@
1
- 'use strict';
2
- module.exports = require('@arkgate/runtime/nestjs');
@@ -1,2 +0,0 @@
1
- /** @deprecated Install `@arkgate/runtime` and import from `@arkgate/runtime/nestjs`. */
2
- export * from '@arkgate/runtime/nestjs';
package/compat/nestjs.js DELETED
@@ -1 +0,0 @@
1
- export * from '@arkgate/runtime/nestjs';
@@ -1,2 +0,0 @@
1
- 'use strict';
2
- module.exports = require('@arkgate/runtime');
@@ -1,2 +0,0 @@
1
- /** @deprecated Install and import from `@arkgate/runtime`. This shim is removed in ArkGate 4. */
2
- export * from '@arkgate/runtime';
package/compat/runtime.js DELETED
@@ -1 +0,0 @@
1
- export * from '@arkgate/runtime';