arkgate 2.9.2 → 2.10.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.
- package/CHANGELOG.md +44 -0
- package/README.md +6 -0
- package/bin/ark-mcp.mjs +282 -102
- package/bin/lib/agent-gates.mjs +152 -3
- package/bin/lib/architecture-scan.mjs +19 -0
- package/bin/lib/auto-patch.mjs +264 -0
- package/bin/lib/doctor-plan.mjs +54 -0
- package/bin/lib/port-proof.mjs +309 -0
- package/bin/lib/prepare-write.mjs +130 -0
- package/bin/lib/remediation.mjs +21 -0
- package/dist/index.cjs +13 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/nestjs/index.cjs +1 -1
- package/dist/nestjs/index.cjs.map +1 -1
- package/dist/nestjs/index.js +1 -1
- package/dist/nestjs/index.js.map +1 -1
- package/dist/runtime/index.cjs +13 -4
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.js +13 -4
- package/dist/runtime/index.js.map +1 -1
- package/docs/agent-guide.md +14 -0
- package/docs/ai-gates.md +43 -3
- package/docs/enthusiast/how-to-agent-gates.md +8 -0
- package/docs/enthusiast/reference-commands.md +1 -1
- package/package.json +2 -1
- package/server.json +2 -2
- package/templates/skills/ark-explain.md +1 -1
- package/templates/skills/ark-loop.md +2 -1
package/docs/agent-guide.md
CHANGED
|
@@ -178,6 +178,20 @@ reference, and explanation for the full path (recommend → init → gallery →
|
|
|
178
178
|
5. Use `/ark-place` or `ark_place` for individual files after the contract exists.
|
|
179
179
|
6. Verify with `ark-check --root . --config ark.config.json --strict-config`.
|
|
180
180
|
|
|
181
|
+
### Write protocol (2.10+ / Track W)
|
|
182
|
+
|
|
183
|
+
Prefer preparing the write before the host commits it to disk:
|
|
184
|
+
|
|
185
|
+
| Surface | Role |
|
|
186
|
+
|---------|------|
|
|
187
|
+
| MCP **`ark_prepare_write`** | Place + constrain + validate + optional `autoPatch` + `judgmentBrief` + contentHash in one call |
|
|
188
|
+
| Write-gate **`autoPatch`** | Mechanical-safe **import type** rewrites only; post-patch revalidation green or discarded |
|
|
189
|
+
| PreToolUse **`--hook-repair`** | On deny: `ARK_REPAIR_JSON` / `ARK_AUTOPATCH_JSON` on stderr (still exit 2 — never silent write) |
|
|
190
|
+
| Doctor **`writePath`** | Reports `repair` \| `reject-only` \| `mcp-only` \| `none` for installed gates |
|
|
191
|
+
|
|
192
|
+
Port-proof inject binding is **judgment** for auto-apply (signature/arity change), not write-path autoPatch.
|
|
193
|
+
Full reference: [ai-gates.md](ai-gates.md). Loop-cost harness: `npm run eval:loop-cost`.
|
|
194
|
+
|
|
181
195
|
Do not invent layers outside the 11-layer profile or named presets. Unrecognized
|
|
182
196
|
directories (`utils/`, `lib/`) must be classified explicitly via `/ark-contract`.
|
|
183
197
|
|
package/docs/ai-gates.md
CHANGED
|
@@ -38,6 +38,11 @@ GitHub Actions, `AGENTS.md`, a Codex TOML snippet under `docs/`, and (when
|
|
|
38
38
|
selected) Grok Build project files under `.grok/`. It skips existing files unless
|
|
39
39
|
you pass `--force`, so review and commit only the templates that match your project.
|
|
40
40
|
|
|
41
|
+
**Doctor (W5):** `ark-check --doctor --json` includes `doctor.writePath`
|
|
42
|
+
(`mode`: `repair` | `reject-only` | `mcp-only` | `none`, plus `prepareWrite` /
|
|
43
|
+
`autoPatch` flags) so leads can see whether the write path is repair-capable or
|
|
44
|
+
still reject-only.
|
|
45
|
+
|
|
41
46
|
If your project uses Codex or Grok, treat MCP registration as part of the default
|
|
42
47
|
setup, not an optional extra. Ark works best when the agent can read `ark://manifest`
|
|
43
48
|
before it writes code; that is the fast path to avoiding architecture drift during
|
|
@@ -52,6 +57,40 @@ violations relative to the file's current on-disk state, so files with pre-exist
|
|
|
52
57
|
(baselined) violations stay editable — they just can't get worse. New files block on
|
|
53
58
|
every violation.
|
|
54
59
|
|
|
60
|
+
### Opt-in repair payload (W4)
|
|
61
|
+
|
|
62
|
+
Default is **hard block with prose** on stderr. Hosts that can re-inject a fixed write
|
|
63
|
+
can enable a **machine-readable repair payload** (still exit `2` — **never** silent write):
|
|
64
|
+
|
|
65
|
+
| Enable | Effect on deny |
|
|
66
|
+
|--------|----------------|
|
|
67
|
+
| `--hook-repair` | Emit `ARK_REPAIR_JSON:…` and, when available, `ARK_AUTOPATCH_JSON:…` on stderr |
|
|
68
|
+
| `ARK_HOOK_REPAIR=1` | Same as `--hook-repair` (env, no template rewrite) |
|
|
69
|
+
|
|
70
|
+
`ARK_REPAIR_JSON` shape (stable additive):
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"mode": "repair",
|
|
75
|
+
"decision": "deny",
|
|
76
|
+
"filePath": "src/domain/use.ts",
|
|
77
|
+
"layer": "DomainModel",
|
|
78
|
+
"autoPatch": {
|
|
79
|
+
"source": "import type { Row } from '../infra/types-only';\n…",
|
|
80
|
+
"remediationKind": "import-type-from-pure-type-module",
|
|
81
|
+
"confidence": 0.85,
|
|
82
|
+
"valid": true
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
When no mechanical-safe patch applies, `autoPatch` is `null` (host still re-reasons or uses
|
|
88
|
+
`ark_prepare_write` / judgment). Grok deny JSON also includes `autoPatch` + `"repair": true`
|
|
89
|
+
when repair mode is on.
|
|
90
|
+
|
|
91
|
+
`--install-agent-gates` writes Claude/Grok PreToolUse commands with `--hook-repair` enabled.
|
|
92
|
+
Reject-only installs: drop `--hook-repair` (or unset `ARK_HOOK_REPAIR`).
|
|
93
|
+
|
|
55
94
|
Add to your project's `.claude/settings.json`:
|
|
56
95
|
|
|
57
96
|
```json
|
|
@@ -63,7 +102,7 @@ Add to your project's `.claude/settings.json`:
|
|
|
63
102
|
"hooks": [
|
|
64
103
|
{
|
|
65
104
|
"type": "command",
|
|
66
|
-
"command": "npx ark-mcp --hook --root \"$CLAUDE_PROJECT_DIR\" --config ark.config.json"
|
|
105
|
+
"command": "npx ark-mcp --hook --hook-repair --root \"$CLAUDE_PROJECT_DIR\" --config ark.config.json"
|
|
67
106
|
}
|
|
68
107
|
]
|
|
69
108
|
}
|
|
@@ -124,10 +163,11 @@ prints nothing and exits 0, so non-Ark projects are untouched.
|
|
|
124
163
|
|
|
125
164
|
## Claude Code — MCP server (contract discovery + on-demand validation)
|
|
126
165
|
|
|
127
|
-
The MCP server exposes a resource and
|
|
166
|
+
The MCP server exposes a resource and tools agents can use proactively (not an exhaustive list — `tools/list` is authoritative):
|
|
128
167
|
|
|
129
168
|
- **`ark://manifest`** (resource) — the machine-readable architecture contract (layers + rules), so the agent can read the architecture before generating code.
|
|
130
|
-
- **`validate_code`** (tool) — validates a snippet against the architecture on demand (the write-path gate).
|
|
169
|
+
- **`validate_code`** (tool) — validates a snippet against the architecture on demand (the write-path gate). May return additive **`autoPatch`** (W1) for mechanical-safe import-type rewrites.
|
|
170
|
+
- **`ark_prepare_write`** (tool) — **W2:** place + constrain + validate + optional autoPatch + judgmentBrief + contentHash in one call (composes `ark_place` + write gate).
|
|
131
171
|
- **`ark_place`** (tool) — given a target file path, returns its layer, forbidden globals, and which layers it may / must not import. Call it *before* writing a new file so generated code lands in a governed location.
|
|
132
172
|
- **`ark_check`** (tool) — runs the full architecture check and returns structured violations (applies the baseline automatically when one exists).
|
|
133
173
|
- **`ark_coverage`** (tool) — per-layer file counts, the full unclassified-file list, and layers whose patterns match nothing.
|
|
@@ -9,6 +9,10 @@ npx arkgate-check --install-agent-gates --tools claude,cursor,codex,grok
|
|
|
9
9
|
Installs:
|
|
10
10
|
|
|
11
11
|
- Write-gate hook configuration (Claude / Grok PreToolUse; Cursor advisory + MCP)
|
|
12
|
+
— PreToolUse uses **`--hook-repair`** (W4): on deny, stderr may include
|
|
13
|
+
`ARK_REPAIR_JSON` / `ARK_AUTOPATCH_JSON` for hosts that re-inject a patch.
|
|
14
|
+
Still exit 2 / hard block; never silent write. Drop `--hook-repair` for
|
|
15
|
+
reject-only prose, or set `ARK_HOOK_REPAIR=0` and omit the flag.
|
|
12
16
|
- MCP server entry (`.mcp.json`, Cursor/Codex/Grok equivalents)
|
|
13
17
|
- `/ark-*` skills including **`/ark-architect`**, **`/ark-autopilot`**, **`/ark-loop`**
|
|
14
18
|
(with current `mechanical-safe` remediation kinds)
|
|
@@ -35,6 +39,10 @@ npx arkgate-check --doctor
|
|
|
35
39
|
npx arkgate-check --require-gates
|
|
36
40
|
```
|
|
37
41
|
|
|
42
|
+
Doctor JSON (`--doctor --json`) includes **`writePath`**: whether PreToolUse is
|
|
43
|
+
`repair` (machine-readable autoPatch on deny), `reject-only`, `mcp-only`, or
|
|
44
|
+
`none` — plus `prepareWrite` / `autoPatch` booleans for leads.
|
|
45
|
+
|
|
38
46
|
After upgrading the package, refresh skills so agents see the latest plan kinds:
|
|
39
47
|
|
|
40
48
|
```bash
|
|
@@ -52,7 +52,7 @@ arkgate-check --watch
|
|
|
52
52
|
| `class` | Agent may auto-apply? | Examples (`remediationKind`) |
|
|
53
53
|
|---------|----------------------|------------------------------|
|
|
54
54
|
| `mechanical-safe` | Yes (validate + rollback) | `type-only-import-move`, `pure-type-file-relocate`, `import-type-from-pure-type-module`, `import-type-of-type-exports` |
|
|
55
|
-
| `judgment` | No — propose | value
|
|
55
|
+
| `judgment` | No — propose | free value-import uses, multi-file ports, **W6 port-proof inject** (arity change), infra relocate, cycles |
|
|
56
56
|
| `deferred` | No | unclear shape |
|
|
57
57
|
|
|
58
58
|
## Violation JSON (enthusiast fields)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkgate",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "ArkGate — architecture co-pilot for AI TypeScript (write gate, CI gate, plan/loop)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"eval:agent": "node eval/run.mjs",
|
|
80
80
|
"eval:corpus": "node eval/validate-corpus.mjs",
|
|
81
81
|
"eval:comparative": "node eval/comparative-run.mjs",
|
|
82
|
+
"eval:loop-cost": "node eval/loop-cost-run.mjs",
|
|
82
83
|
"clean": "rm -rf dist",
|
|
83
84
|
"release:npm": "node scripts/release-npm.mjs",
|
|
84
85
|
"prepack": "npm run build"
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/pedroknigge/arkgate",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "2.
|
|
9
|
+
"version": "2.10.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "arkgate",
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.10.0",
|
|
15
15
|
"runtimeHint": "npx",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
@@ -66,7 +66,7 @@ forensics, baseline taxonomy) for tech leads.
|
|
|
66
66
|
|
|
67
67
|
When explaining the **plan**, name the four `mechanical-safe` remediation kinds only
|
|
68
68
|
(type-only move, pure-type file relocate, `import type` of pure-type modules,
|
|
69
|
-
`import-type-of-type-exports` for named type exports from mixed modules) — everything
|
|
69
|
+
`import-type-of-type-exports` for named type exports from mixed modules; W6 port-proof inject is judgment when proof holds) — everything
|
|
70
70
|
else is judgment/deferred and must not be auto-applied.
|
|
71
71
|
|
|
72
72
|
## Spoken / written explanation
|
|
@@ -65,8 +65,9 @@ feature dirs, plan clusters), you **may** dispatch **subagents**:
|
|
|
65
65
|
| `pure-type-file-relocate` | Relocate pure-type file to owning layer (or rename out of false Domain globs) |
|
|
66
66
|
| `import-type-from-pure-type-module` | Convert value import of pure-type module to `import type` |
|
|
67
67
|
| `import-type-of-type-exports` | Convert value-syntax named import/export of type-only exports from a mixed module to `import type` / `export type` |
|
|
68
|
+
| *(none for port-proof)* | **W6** `port-proof-inject-binding` is **judgment** (arity change) — propose inject; do not auto-apply |
|
|
68
69
|
|
|
69
|
-
Never auto: value
|
|
70
|
+
Never auto: free value uses of imports, multi-import files, dynamic import/require, forbidden globals, cycles, port-proof inject, multi-file adapter scaffolding without proof.
|
|
70
71
|
|
|
71
72
|
## Steps
|
|
72
73
|
|