arkgate 3.8.2 → 3.9.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 +91 -0
- package/README.md +94 -345
- package/bin/ark-mcp-runtime.mjs +137 -11
- package/bin/ark-shared.mjs +89 -2
- package/bin/ark.mjs +41 -19
- package/bin/lib/agent-gates.mjs +4 -0
- package/bin/lib/ci-and-commands.mjs +28 -21
- package/bin/lib/doctor-plan.mjs +37 -28
- package/bin/lib/hook-templates.mjs +13 -9
- package/bin/lib/host-support-matrix.mjs +64 -4
- package/bin/lib/install-migrate.mjs +96 -1
- package/bin/lib/managed-upgrade.mjs +30 -1
- package/bin/lib/mcp-adoption.mjs +60 -2
- package/bin/lib/post-green-path.mjs +2 -2
- package/bin/lib/skill-install.mjs +46 -2
- package/bin/lib/start-preview.mjs +23 -7
- package/bin/lib/upgrade-command.mjs +57 -15
- package/bin/lib/write-path-capabilities.mjs +67 -18
- package/bin/lib/write-path-detect.mjs +11 -7
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/docs/README.md +70 -0
- package/docs/agent-guide.md +59 -17
- package/docs/ai-gates.md +97 -11
- package/docs/develop.md +127 -0
- package/docs/enthusiast/README.md +2 -0
- package/docs/package-surface.md +3 -3
- package/docs/product-voice.md +194 -0
- package/docs/use.md +88 -0
- package/package.json +5 -1
- package/server.json +2 -2
- package/templates/hooks/opencode-ark-write-gate.mjs +85 -0
- package/templates/skills/ark-autopilot.md +20 -7
- package/templates/skills/ark-explore.md +17 -4
package/docs/use.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Use ArkGate
|
|
2
|
+
|
|
3
|
+
For **anyone** shipping TypeScript with an AI coding agent. You do not need to study clean architecture first.
|
|
4
|
+
|
|
5
|
+
**One contract. One gate. One co-pilot.**
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## In one minute
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -D arkgate typescript
|
|
13
|
+
npx arkgate start # preview what will change
|
|
14
|
+
npx arkgate start --apply # install compact contract + host router + CI plan
|
|
15
|
+
npx arkgate-check --doctor # where am I? one status light, one next action
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then keep working with your agent. The doctor is the **control plane**: when stuck, run doctor and do action **#1**.
|
|
19
|
+
|
|
20
|
+
| Stuck on… | Do this |
|
|
21
|
+
|-----------|---------|
|
|
22
|
+
| Unsure | `npx arkgate-check --doctor` |
|
|
23
|
+
| Agent broke architecture | Fix the edge doctor names (or re-run check) |
|
|
24
|
+
| Code is green but still a mess | Shape residual — see below |
|
|
25
|
+
| New ArkGate version | Follow doctor / upgrade guidance |
|
|
26
|
+
|
|
27
|
+
Full skill pack is **optional** (expert depth). Day-to-day: compact router + doctor is enough.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## What you get
|
|
32
|
+
|
|
33
|
+
| When | What happens |
|
|
34
|
+
|------|----------------|
|
|
35
|
+
| While the AI writes | Host write gate or advisory MCP (depends on host) |
|
|
36
|
+
| Before merge | `arkgate-check` — make it a **required** CI status |
|
|
37
|
+
| Anytime | Doctor: Suggest / Adapt / Enforce (+ design-weak if residual) |
|
|
38
|
+
|
|
39
|
+
ArkGate is **not** a web framework, ORM, or app runtime. It is architecture enforcement + co-pilot for AI TypeScript.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Status lights (not settings)
|
|
44
|
+
|
|
45
|
+
| Light | Means | Your move |
|
|
46
|
+
|-------|--------|-----------|
|
|
47
|
+
| **Suggest** | New or thin project | Finish `start`, re-run doctor |
|
|
48
|
+
| **Adapt** | Not fully protected yet | Doctor action #1 until clean |
|
|
49
|
+
| **Enforce** | Edges honest under the contract | Keep write path + CI |
|
|
50
|
+
| **Enforce · design-weak** | Edges clean; design still messy | Shape door — not “done” |
|
|
51
|
+
|
|
52
|
+
**Green edges ≠ elegant design.** Empty remediation plan is not “architecture finished” if design residual remains.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## When the gate is green but the code is still messy
|
|
57
|
+
|
|
58
|
+
That is **Shape** work (plan B) — suggested, never auto-applied as silent magic.
|
|
59
|
+
|
|
60
|
+
1. Doctor confirms design-weak
|
|
61
|
+
2. Guided map / dual plan (skill pack: `/ark-explore` then `/ark-autopilot` with your OK)
|
|
62
|
+
3. One pilot at a time · re-run doctor
|
|
63
|
+
|
|
64
|
+
Install skills only when you want that guided path:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npx arkgate-check --install-agent-gates --skills-only --force
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Tutorials and demos
|
|
73
|
+
|
|
74
|
+
- Plain-language track: [enthusiast/](enthusiast/README.md)
|
|
75
|
+
- First project tutorial: [enthusiast/tutorial-first-project.md](enthusiast/tutorial-first-project.md)
|
|
76
|
+
- Demos: [demos/](demos/)
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Next depth
|
|
81
|
+
|
|
82
|
+
| Need | Doc |
|
|
83
|
+
|------|-----|
|
|
84
|
+
| Hosts, CI, MCP, brownfield, power CLI | [develop.md](develop.md) |
|
|
85
|
+
| Wire a specific agent host | [ai-gates.md](ai-gates.md) |
|
|
86
|
+
| Improve the library | [CONTRIBUTING.md](../CONTRIBUTING.md) |
|
|
87
|
+
|
|
88
|
+
← [All docs](README.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkgate",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.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",
|
|
@@ -65,7 +65,11 @@
|
|
|
65
65
|
"!dist/**/*.d.cts",
|
|
66
66
|
"schemas",
|
|
67
67
|
"!schemas/*.source.json",
|
|
68
|
+
"docs/README.md",
|
|
69
|
+
"docs/use.md",
|
|
70
|
+
"docs/develop.md",
|
|
68
71
|
"docs/agent-guide.md",
|
|
72
|
+
"docs/product-voice.md",
|
|
69
73
|
"docs/enthusiast",
|
|
70
74
|
"docs/demos/01-write-gate-self-correction.md",
|
|
71
75
|
"docs/demos/02-brownfield-baseline-adoption.md",
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/pedroknigge/arkgate",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "3.
|
|
9
|
+
"version": "3.9.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "arkgate",
|
|
14
|
-
"version": "3.
|
|
14
|
+
"version": "3.9.0",
|
|
15
15
|
"runtimeHint": "npx",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Experimental OpenCode plugin: best-effort write gate via tool.execute.before.
|
|
3
|
+
*
|
|
4
|
+
* Install:
|
|
5
|
+
* 1. Copy to `.opencode/plugins/ark-write-gate.mjs` (or reference from opencode.json plugin list)
|
|
6
|
+
* 2. Ensure `arkgate-mcp` / `npx arkgate-mcp` is on PATH
|
|
7
|
+
* 3. Keep CI on `arkgate-check --strict-merge` + required status
|
|
8
|
+
*
|
|
9
|
+
* Honesty: OpenCode plugin hooks are **not** a complete hard write boundary
|
|
10
|
+
* (subagent and alternate tool paths may bypass). Never treat this plugin as
|
|
11
|
+
* Claude/Grok/Antigravity PreToolUse hard-write. Prefer MCP `ark_prepare_write`
|
|
12
|
+
* + required merge status.
|
|
13
|
+
*
|
|
14
|
+
* This file is a gallery template shipped with arkgate — not auto-installed.
|
|
15
|
+
*/
|
|
16
|
+
import { spawnSync } from 'node:child_process';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
|
|
19
|
+
const WRITE_TOOLS = new Set(['write', 'edit', 'apply_patch', 'patch']);
|
|
20
|
+
|
|
21
|
+
function resolveMcpBin() {
|
|
22
|
+
return process.env.ARK_MCP_BIN?.trim() || 'npx';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function resolveMcpArgs(root) {
|
|
26
|
+
const bin = process.env.ARK_MCP_SCRIPT?.trim();
|
|
27
|
+
if (bin) {
|
|
28
|
+
return [bin, '--hook', '--root', root, '--config', 'ark.config.json'];
|
|
29
|
+
}
|
|
30
|
+
return ['arkgate-mcp', '--hook', '--root', root, '--config', 'ark.config.json'];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function toClaudePayload(tool, args) {
|
|
34
|
+
if (tool === 'write') {
|
|
35
|
+
return {
|
|
36
|
+
tool_name: 'Write',
|
|
37
|
+
tool_input: {
|
|
38
|
+
file_path: args?.filePath ?? args?.path ?? args?.file_path,
|
|
39
|
+
content: args?.content ?? '',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (tool === 'edit') {
|
|
44
|
+
return {
|
|
45
|
+
tool_name: 'Edit',
|
|
46
|
+
tool_input: {
|
|
47
|
+
file_path: args?.filePath ?? args?.path ?? args?.file_path,
|
|
48
|
+
old_string: args?.oldString ?? args?.old_string ?? '',
|
|
49
|
+
new_string: args?.newString ?? args?.new_string ?? '',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (tool === 'apply_patch' || tool === 'patch') {
|
|
54
|
+
return {
|
|
55
|
+
tool_name: 'apply_patch',
|
|
56
|
+
tool_input: {
|
|
57
|
+
patch: args?.patchText ?? args?.patch ?? args?.content ?? '',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default async function ArkWriteGatePlugin(ctx) {
|
|
65
|
+
const root = ctx?.directory ?? ctx?.worktree ?? process.cwd();
|
|
66
|
+
return {
|
|
67
|
+
'tool.execute.before': async (input, output) => {
|
|
68
|
+
const tool = String(input?.tool ?? '').toLowerCase();
|
|
69
|
+
if (!WRITE_TOOLS.has(tool)) return;
|
|
70
|
+
const payload = toClaudePayload(tool, output?.args ?? input?.args ?? {});
|
|
71
|
+
if (!payload) return;
|
|
72
|
+
const result = spawnSync(resolveMcpBin(), resolveMcpArgs(root), {
|
|
73
|
+
input: JSON.stringify(payload),
|
|
74
|
+
encoding: 'utf8',
|
|
75
|
+
cwd: root,
|
|
76
|
+
env: process.env,
|
|
77
|
+
});
|
|
78
|
+
if (result.status === 2) {
|
|
79
|
+
const reason = (result.stderr || result.stdout || 'Ark write gate denied').trim();
|
|
80
|
+
throw new Error(reason);
|
|
81
|
+
}
|
|
82
|
+
// Plumbing failures fail open (same as ark-mcp --hook contract).
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ark-autopilot
|
|
3
|
-
description:
|
|
3
|
+
description: Guided end-to-end path — doctor next action when unsure. Explore first; dual plan A (edges) + B (shape); mechanical-safe only by default; B with user OK, one pilot at a time. Empty plan A is not healthy if design-weak. CLI is a sensor; you read and remediate files.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# /ark-autopilot —
|
|
6
|
+
# /ark-autopilot — Guided end-to-end architecture path
|
|
7
|
+
|
|
8
|
+
**This is the full guided co-pilot** after the compact router. Prefer it when the user wants
|
|
9
|
+
architecture cleaned end-to-end, not when they only need a map (`/ark-explore`) or a single
|
|
10
|
+
edge fix (`/ark-fix`). Doctor remains the control plane: re-check status after each major step.
|
|
7
11
|
|
|
8
12
|
Composes **explore → sensors → dual plan → loop**. Safe default: auto-apply only
|
|
9
|
-
`mechanical-safe`; when the user says full apply /
|
|
10
|
-
|
|
11
|
-
never weaken the gate).
|
|
13
|
+
`mechanical-safe`; when the user says full apply / apply everything, also execute **judgment**
|
|
14
|
+
fixes you design from reading source (still validate with ark-check, never weaken the gate).
|
|
12
15
|
|
|
13
16
|
**Not a plan grinder.** Empty `--plan` does **not** mean “architecture is healthy” without
|
|
14
17
|
the explore pass and dual-plan section B (pattern / Shape bets).
|
|
@@ -32,7 +35,7 @@ to apply B with OK. Prefer that order when `postGreenPath` / design-weak is the
|
|
|
32
35
|
- **Brownfield:** `/ark-adopt` — match contract to reality; do not force a starter preset.
|
|
33
36
|
- **Deep map only:** `/ark-explore` — full recon / dual-plan seed without applying.
|
|
34
37
|
- **Adoption fitness only:** `/ark-coverage` — governed% + capability gaps (not pattern dual-plan).
|
|
35
|
-
- **Default path:** `ark start` →
|
|
38
|
+
- **Default path:** `ark start` → `ark-check --doctor` → **`/ark-autopilot`** (this skill) for guided work.
|
|
36
39
|
|
|
37
40
|
## Dual engine (mandatory)
|
|
38
41
|
|
|
@@ -127,9 +130,19 @@ repo so the next agent session continues the same pilot — still never auto-app
|
|
|
127
130
|
|
|
128
131
|
## Operating modes (detected, not picked)
|
|
129
132
|
|
|
130
|
-
|
|
133
|
+
Status lights from doctor — not settings you choose. Rank residual honestly:
|
|
134
|
+
|
|
135
|
+
| Light | Means | Your move (this skill) |
|
|
136
|
+
|-------|--------|------------------------|
|
|
137
|
+
| **Suggest** | Thin/new tree; contract not control plane | Finish `ark start` → re-doctor; do not skill-shop |
|
|
138
|
+
| **Adapt** | Contract/tree disagree or debt open | Explore + adopt/loop/contract; do not claim guarded |
|
|
139
|
+
| **Enforce** | Honest coverage + clean checked **edges** | Confirm gates + CI; emit dual-plan B only if residual found |
|
|
140
|
+
| **Enforce · design-weak** | Edges clean; design smells remain | **Primary Shape door:** explore shape-focus → dual-plan **B** → apply **one** pilot with user OK. Empty plan A ≠ done. Never mechanical-safe B. False-done forbidden. |
|
|
141
|
+
|
|
142
|
+
- **Setup (Suggest):** no config → `ark start` (start freezes origin after config, before gates).
|
|
131
143
|
- **Align (Adapt):** open debt, low honesty, or false-green → explore + adopt/loop; do not claim “guarded”.
|
|
132
144
|
- **Guard (Enforce):** `goal.met`, solid governed%, no false-green → confirm gates; still emit dual plan B if explore found residual.
|
|
145
|
+
- **Guard · design-weak:** same as Enforce on edges, **plus** mandatory dual-plan B / pilot card; Incomplete? must not claim healthy finished while residual remains.
|
|
133
146
|
|
|
134
147
|
## Flow
|
|
135
148
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ark-explore
|
|
3
|
-
description:
|
|
3
|
+
description: Specialized map skill — decision-grade recon + dual-plan seed (no apply). Primary post-green door when design-weak. Not the default day-to-day path (use doctor + place/gate; guided apply is /ark-autopilot). CLI is a sensor; you read the tree. No gate bypass.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# /ark-explore — Recon the real project
|
|
6
|
+
# /ark-explore — Recon the real project (map only)
|
|
7
|
+
|
|
8
|
+
**Specialized escape**, not the default curriculum. Use when you need a decision-grade map
|
|
9
|
+
or the post-green Shape door; hand off to `/ark-autopilot` to apply. Day-to-day place + gate
|
|
10
|
+
work does not require this skill.
|
|
7
11
|
|
|
8
12
|
You are a **staff engineer doing architecture reconnaissance** on *this* repository.
|
|
9
13
|
Ark’s CLI is a **sensor** (coverage, doctor, plan). **You** open source, entry points,
|
|
@@ -25,6 +29,15 @@ ranked residual that changes the next command — **not** a celebration of ENFOR
|
|
|
25
29
|
(shape-focus / dual-plan seed) is the map half of the one door** — then `/ark-autopilot` only
|
|
26
30
|
to apply B with user OK. Do not send the user to coverage or think as equal first choices.
|
|
27
31
|
|
|
32
|
+
### Status lights (rank residual; not settings)
|
|
33
|
+
|
|
34
|
+
| Light | Explore role |
|
|
35
|
+
|-------|----------------|
|
|
36
|
+
| **Suggest** | Point at `ark start` → doctor; map only if user insists on recon before setup |
|
|
37
|
+
| **Adapt** | Map false-green / ungoverned / concentrated edge; hand off adopt/contract before Shape vanity |
|
|
38
|
+
| **Enforce** | Confirm edges; if residual smells/patterns appear, auto-upgrade to dual-plan seed / shape-focus |
|
|
39
|
+
| **Enforce · design-weak** | **Primary post-green map door** — shape-focus + dual-plan B + extraction cards. False-done forbidden. Never claim healthy because plan A is empty. |
|
|
40
|
+
|
|
28
41
|
`/ark-autopilot`, `/ark-adopt`, and `/ark-coverage` embed a **lighter** version of this pass.
|
|
29
42
|
**You** are the full recon + pattern-planning skill.
|
|
30
43
|
|
|
@@ -33,7 +46,7 @@ to apply B with user OK. Do not send the user to coverage or think as equal firs
|
|
|
33
46
|
- **Greenfield / thin tree:** `/ark-architect` or `ark-check --recommend` / `ark start`.
|
|
34
47
|
- **Brownfield action (write contract/baseline):** `/ark-adopt` after the map.
|
|
35
48
|
- **Execute dual plan:** `/ark-autopilot` (explore seeds; autopilot applies A, proposes B).
|
|
36
|
-
- **Default path:** `ark start` →
|
|
49
|
+
- **Default path:** `ark start` → `ark-check --doctor` → `/ark-autopilot` for guided apply; use this skill for map-only or post-green Shape residual.
|
|
37
50
|
|
|
38
51
|
## Dual engine (mandatory)
|
|
39
52
|
|
|
@@ -222,7 +235,7 @@ ENFORCE without Shape progress is **`ENFORCE · design-weak`** — say that out
|
|
|
222
235
|
| Smell id (label) | How you detect it in source |
|
|
223
236
|
|------------------|-----------------------------|
|
|
224
237
|
| `io-under-application` | I/O clients under Application; empty Domain/Persistence (also doctor when present) |
|
|
225
|
-
| `handler-in-persistence` | Static framework HTTP imports, `defineRoute` calls, or route bodies under Persistence-role repo/db globs (first 800 sorted candidates;
|
|
238
|
+
| `handler-in-persistence` | Static framework HTTP imports, `defineRoute` calls, or route bodies under Persistence-role repo/db globs (**envelope:** first 800 sorted candidates; absence of smell ≠ full-tree proof above that cap; incomplete/partial analysis is never “no smells”) |
|
|
226
239
|
| `god-module` | High fan-in + wide export surface + mixed concerns |
|
|
227
240
|
| `domain-logic-in-ui` | `can*` / `calculate*` / policy constants in hooks/pages |
|
|
228
241
|
| `mixed-pattern-cluster` | Same feature area uses ≥2 incompatible layouts |
|