arkgate 2.12.0 → 2.13.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 (70) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +55 -31
  3. package/bin/ark-check.mjs +95 -36
  4. package/bin/ark-mcp.mjs +11 -5
  5. package/bin/ark-shared.mjs +88 -56
  6. package/bin/ark.mjs +45 -10
  7. package/bin/lib/agent-gates.mjs +12 -0
  8. package/bin/lib/architecture-scan.mjs +8 -0
  9. package/bin/lib/ci-and-commands.mjs +9 -3
  10. package/bin/lib/codex-home.mjs +7 -0
  11. package/bin/lib/config-contract.mjs +331 -0
  12. package/bin/lib/doctor-plan.mjs +43 -16
  13. package/bin/lib/enforcement-profiles.mjs +97 -0
  14. package/bin/lib/host-support-matrix.mjs +77 -0
  15. package/bin/lib/install-migrate.mjs +45 -14
  16. package/bin/lib/mcp-adoption.mjs +35 -3
  17. package/bin/lib/open-html.mjs +75 -0
  18. package/bin/lib/presets.mjs +3 -2
  19. package/bin/lib/safety-diagnostics.mjs +31 -11
  20. package/bin/lib/skill-install.mjs +64 -0
  21. package/bin/lib/ts-resolve.mjs +2 -1
  22. package/bin/lib/weakest-link.mjs +417 -0
  23. package/bin/lib/write-path-capabilities.mjs +182 -0
  24. package/bin/lib/write-path-detect.mjs +62 -99
  25. package/dist/configContract-iBLxx5Tz.d.cts +53 -0
  26. package/dist/configContract-iBLxx5Tz.d.ts +53 -0
  27. package/dist/eslint/index.cjs +375 -13
  28. package/dist/eslint/index.cjs.map +1 -1
  29. package/dist/eslint/index.d.cts +30 -20
  30. package/dist/eslint/index.d.ts +30 -20
  31. package/dist/eslint/index.js +375 -13
  32. package/dist/eslint/index.js.map +1 -1
  33. package/dist/index.cjs +723 -61
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +95 -5
  36. package/dist/index.d.ts +95 -5
  37. package/dist/index.js +716 -61
  38. package/dist/index.js.map +1 -1
  39. package/dist/nestjs/index.cjs +150 -42
  40. package/dist/nestjs/index.cjs.map +1 -1
  41. package/dist/nestjs/index.d.cts +2 -1
  42. package/dist/nestjs/index.d.ts +2 -1
  43. package/dist/nestjs/index.js +150 -42
  44. package/dist/nestjs/index.js.map +1 -1
  45. package/dist/runtime/index.cjs +723 -61
  46. package/dist/runtime/index.cjs.map +1 -1
  47. package/dist/runtime/index.d.cts +3 -2
  48. package/dist/runtime/index.d.ts +3 -2
  49. package/dist/runtime/index.js +716 -61
  50. package/dist/runtime/index.js.map +1 -1
  51. package/dist/{types-BZ17b9i5.d.cts → types-BxBwnBpC.d.cts} +9 -36
  52. package/dist/{types-BZ17b9i5.d.ts → types-Wcs_l1_J.d.ts} +9 -36
  53. package/docs/agent-guide.md +32 -20
  54. package/docs/ai-gates.md +53 -18
  55. package/docs/configuration.md +97 -0
  56. package/docs/enthusiast/README.md +3 -3
  57. package/docs/enthusiast/how-to-agent-gates.md +7 -3
  58. package/docs/migrate-from-ark-runtime-kernel.md +3 -0
  59. package/docs/package-surface.md +14 -9
  60. package/docs/production-hardening.md +15 -2
  61. package/docs/threat-model.md +65 -0
  62. package/docs/typescript-support.md +3 -3
  63. package/package.json +15 -2
  64. package/schemas/ark.config.schema.json +750 -0
  65. package/server.json +2 -2
  66. package/templates/hooks/pre-commit-ark +37 -0
  67. package/templates/skills/ark-coverage.md +2 -2
  68. package/templates/skills/ark-runtime.md +8 -5
  69. package/templates/skills/ark-upgrade.md +36 -16
  70. package/tests/fixtures/ts-consumer/ark.config.json +2 -0
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.12.0",
9
+ "version": "2.13.0",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "arkgate",
14
- "version": "2.12.0",
14
+ "version": "2.13.0",
15
15
  "runtimeHint": "npx",
16
16
  "transport": {
17
17
  "type": "stdio"
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env bash
2
+ # Maintained by ArkGate (Q3) — human-edit architecture gate.
3
+ # Install (git hooks):
4
+ # cp templates/hooks/pre-commit-ark .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
5
+ # Or with husky:
6
+ # cp templates/hooks/pre-commit-ark .husky/pre-commit && chmod +x .husky/pre-commit
7
+ #
8
+ # Blocks commit when ark-check fails. Does not replace CI branch protection.
9
+ set -euo pipefail
10
+
11
+ ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
12
+ cd "$ROOT"
13
+
14
+ run_check() {
15
+ if [ -f package.json ] && node -e "const p=require('./package.json');process.exit(p.scripts&&p.scripts['check:architecture']?0:1)" 2>/dev/null; then
16
+ npm run -s check:architecture
17
+ return $?
18
+ fi
19
+ if [ -f bin/ark-check.mjs ]; then
20
+ node bin/ark-check.mjs --root . --config ark.config.json --strict-config
21
+ return $?
22
+ fi
23
+ if command -v arkgate-check >/dev/null 2>&1; then
24
+ arkgate-check --root . --config ark.config.json --strict-config
25
+ return $?
26
+ fi
27
+ if command -v npx >/dev/null 2>&1; then
28
+ # --yes: pre-commit is non-interactive; never hang on npx install prompts
29
+ npx --yes --no-install arkgate-check --root . --config ark.config.json --strict-config 2>/dev/null \
30
+ || npx --yes arkgate-check --root . --config ark.config.json --strict-config
31
+ return $?
32
+ fi
33
+ echo "ark-check not found — install arkgate or add check:architecture script" >&2
34
+ return 1
35
+ }
36
+
37
+ run_check
@@ -56,7 +56,7 @@ feature dirs, plan clusters), you **may** dispatch **subagents**:
56
56
  |------|----------------|--------------------|
57
57
  | **Suggest / Setup** | Thin or new tree | “Ark will propose a starting shape — you don’t switch a mode.” |
58
58
  | **Adapt / Align** | Contract ≠ folders or open debt | “Gates don’t fully protect you yet — classify + fix plan.” |
59
- | **Enforce / Guard** | Coverage + clean edges + honest cores | “You arrived here — keep CI/write gates on.” |
59
+ | **Enforce / Guard** | Coverage + clean edges + honest cores | “You arrived here — keep the host-appropriate write path and CI check on.” |
60
60
 
61
61
  Never say “your architecture is guarded” while `goal.met` is false, governed% is low,
62
62
  or false-green doctor gaps are open.
@@ -73,7 +73,7 @@ or false-green doctor gaps are open.
73
73
 
74
74
  1. Config + `ark-check --strict-config` (dead preset globs advisory; unclassified files still fail strict).
75
75
  2. Baseline policy (orphan empty file? wire or delete).
76
- 3. Write gates + `/ark-*` skills per detected agent.
76
+ 3. Host-appropriate write path + `/ark-*` skills per detected agent.
77
77
  4. CI workflow + monorepo install reality (`frontend/package.json`?).
78
78
  5. ESLint `arkgate/eslint` if ESLint exists.
79
79
  6. Domain `forbiddenGlobals`.
@@ -1,11 +1,14 @@
1
1
  ---
2
2
  name: ark-runtime
3
- description: Replace hand-rolled infra with the Ark runtime kernel event bus, outbox, audit, sagas, projections, policies, NestJS. Finds candidates, wires one, verifies.
3
+ description: Evaluate the experimental Ark runtime kernel against hand-rolled event bus, outbox, audit, saga, projection, policy, or NestJS code. Finds one candidate, wires one, verifies.
4
4
  ---
5
5
 
6
- # /ark-runtime — Adopt the runtime kernel (opt-in features)
6
+ # /ark-runtime — Evaluate the runtime kernel (experimental opt-in)
7
7
 
8
- `arkgate` is not just static checking: it ships a runtime kernel
8
+ The runtime kernel is currently **experimental** and is not required for ArkGate enforcement or
9
+ presented as production-ready. Use this skill only when the user explicitly wants to evaluate it.
10
+
11
+ `arkgate` ships the experimental runtime kernel
9
12
  (`createArkKernel`) with an event bus, event contracts, outbox, audit trail,
10
13
  policy engine, workflow/saga coordination, projections, observability hooks,
11
14
  and NestJS adapters. This skill migrates hand-rolled versions of those to the
@@ -43,12 +46,12 @@ the same files or weaken the gate.
43
46
  2. **Pick ONE target** — the smallest, most self-contained candidate (fewest
44
47
  call sites). Migrating everything at once is how adoptions die. List the
45
48
  rest as follow-ups in the report.
46
- 3. **Migrate** — import from `arkgate` (root export) or
49
+ 3. **Migrate** — import from `arkgate/runtime` (preferred experimental subpath) or
47
50
  `arkgate/nestjs`, and read the package's `docs/agent-guide.md`
48
51
  (in `node_modules/arkgate/docs/`) for the runtime API before
49
52
  writing code. Wire the kernel at the composition root; keep the domain
50
53
  ignorant of it (handlers/ports, not kernel imports inside domain code —
51
- the write gate will enforce this anyway). Note: the kernel bounds in-memory
54
+ the architecture check enforces this; Claude/Grok hooks can block it earlier). Note: the kernel bounds in-memory
52
55
  history by default (`maxHistorySize` 1000); mention this if the hand-rolled
53
56
  version retained everything.
54
57
  4. **Delete the hand-rolled version** once call sites are moved — the point is
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ark-upgrade
3
- description: Update arkgate to the latest published version, then refresh gates and /ark-* skills for every agent CLI and re-verify the architecture check. Autonomous.
3
+ description: Update arkgate to the latest published version, then refresh gates and /ark-* skills for the active agent host (defer inactive hosts like Codex when not in use) and re-verify the architecture check. Autonomous.
4
4
  ---
5
5
 
6
6
  # /ark-upgrade — Update ArkGate and refresh its gates
@@ -38,6 +38,13 @@ read the **Adoption** section — host gaps, Codex home temp paths, optional-but
38
38
  core layers, missing origin snapshot, baseline policy. Fix commands are printed per gap.
39
39
  HTML reports include the same Adoption card (separate from the 0–100 fitness score).
40
40
 
41
+ **Active host vs deferred hosts:** green the **session host** (Grok, Claude, Cursor, …)
42
+ and repo gates first. Codex home (`$CODEX_HOME` prompts + `config.toml` MCP multi-project)
43
+ is **deferred** unless this session is Codex or the user asked to fix Codex. Doctor marks
44
+ those gaps `deferred` / info and does not put them in Top actions. A temp/upgrade MCP
45
+ `--root` stays urgent (fail-closed rewrite). Never set **Incomplete?** because of deferred
46
+ Codex debt.
47
+
41
48
  ## Dual engine (mandatory)
42
49
 
43
50
  | Engine | Role |
@@ -58,7 +65,8 @@ the same files or weaken the gate.
58
65
  ## Fast path
59
66
 
60
67
  One command does the whole flow — update the package, refresh gates + `/ark-*` skills
61
- (and Codex home prompts), migrate command runners, and run the strict check:
68
+ (and best-effort Codex home prompts when `~/.codex` exists), migrate command runners,
69
+ and run the strict check:
62
70
 
63
71
  ```
64
72
  arkgate upgrade
@@ -112,13 +120,18 @@ npx arkgate-check --install-agent-gates --skills-only --force
112
120
  losing customizations. If the changelog says a GATE file changed, report the
113
121
  diff and let the user decide; never rewrite settings/CI/AGENTS.md without
114
122
  explicit approval.
115
- If you use Codex, its prompts live in `$CODEX_HOME/prompts` (`~/.codex/prompts`),
116
- not the repo, so a repo refresh never updates them. Refresh them there too:
117
- `ark-check --install-agent-gates --skills-only --codex-home --force`. Keep
118
- `--skills-only` without it, `--force` also rewrites customized gate files
119
- (AGENTS.md, CI, settings). This writes to the user's home dir — say so. (A normal
120
- `ark-check` now flags stale Codex-home skills when copies exist, so you don't have
121
- to remember.)
123
+ **Active host first.** Refresh skills for the host running this skill (e.g.
124
+ `.grok/skills/`, `.claude/skills/`, `.cursor/commands/`). Repo-local copies for
125
+ other detected hosts are fine to refresh in the same pass when cheap.
126
+ **Codex is deferred when you are not on Codex.** Prompts live in
127
+ `$CODEX_HOME/prompts` (`~/.codex/prompts`), not the repo. `ark upgrade` may
128
+ best-effort refresh that home when it exists; still list Codex under
129
+ **Deferred hosts** and do **not** chase MCP multi-project / stale home skills
130
+ until the user is on Codex (or asks). Fix command when needed:
131
+ `ark-check --install-agent-gates --skills-only --codex-home --force`
132
+ (and `--tools codex` / `--force` for primary MCP rebind). Exception: temp or
133
+ `ark-upgrade` MCP `--root` paths — leave fail-closed rewrite to the CLI; do not
134
+ block completion on multi-project noise.
122
135
  **Migrate stale command runners.** The package-manager-aware command templates
123
136
  (`pnpm exec` / `yarn` / `npx`) only apply to NEWLY written files, so a repo that adopted
124
137
  Ark before they shipped keeps a stale `npx` in its EXISTING gate files
@@ -138,10 +151,14 @@ npx arkgate-check --install-agent-gates --skills-only --force
138
151
 
139
152
  ## Operating rules
140
153
 
141
- - Cover EVERY detected agent CLI (`.claude/`, `.cursor/`, `.codex/`,
142
- `.windsurf/`, `.clinerules/`, `.kiro/`), not just the one running this skill —
143
- gates and skills must stay in sync across tools or the weakest tool becomes
144
- the hole in the fence.
154
+ - **Must green:** the **active session host** (skills + gates that host uses) and
155
+ shared repo surfaces (`.mcp.json` dual-bin, command runners, architecture check).
156
+ - **May defer:** other hosts not used in this session. Always list them under
157
+ **Deferred hosts** with the fix command — do not treat them as Incomplete.
158
+ Codex home (global `$CODEX_HOME`) is the common case on Grok/Claude.
159
+ - **Optional sync:** if other repo-local tool dirs already exist (`.cursor/`,
160
+ `.claude/`, …), refreshing their `/ark-*` skills is good hygiene when cheap;
161
+ it is not a reason to fail the skill when the active host is already current.
145
162
  - Never run `--force` blindly; customized files are the user's.
146
163
  - Stop only if the changelog documents a breaking config change with two valid
147
164
  migration paths — then present both with a recommendation.
@@ -158,8 +175,8 @@ npx arkgate-check --install-agent-gates --skills-only --force
158
175
 
159
176
  End with a passing check. Report: latest published version, old → new version
160
177
  (or "already latest"), changelog entries that mattered here (plain language),
161
- files written/refreshed per tool, skipped customized files needing a manual
162
- look, and the final check status.
178
+ files written/refreshed for the **active host**, deferred hosts (if any),
179
+ skipped customized files needing a manual look, and the final check status.
163
180
 
164
181
  ## Completion contract (skill incomplete if missing)
165
182
 
@@ -168,9 +185,12 @@ End with **exactly** these headings (markdown `###`):
168
185
  ### Completion
169
186
  - **Sensor:** commands/tools run
170
187
  - **Opened:** real paths read (or `n/a` only if pure install/upgrade with no source analysis)
188
+ - **Active host:** e.g. `grok` / `claude` / `cursor` / `codex` (skills/gates OK or note)
189
+ - **Deferred hosts:** `none` | e.g. `codex — home MCP/prompts; fix when using Codex`
171
190
  - **Result:** one-line outcome
172
191
  - **Handoff:** `/ark-…` / CLI / `none`
173
192
  - **Incomplete?** `no` | `yes — <what is missing>`
174
193
 
175
194
  If a **STOP** handoff applies and you continued as if done, set **Incomplete?** to `yes`.
176
- **Skill incomplete if missing** any of the bullets above.
195
+ **Deferred hosts (including Codex when not on Codex) never make Incomplete? yes.**
196
+ **Skill incomplete if missing** any of the bullets above (use `none` for Deferred hosts when empty).
@@ -1,4 +1,6 @@
1
1
  {
2
+ "$schema": "https://unpkg.com/arkgate@2/schemas/ark.config.schema.json",
3
+ "schemaVersion": "1.0",
2
4
  "include": ["src"],
3
5
  "layers": [
4
6
  { "name": "DomainModel", "patterns": ["src/domain/**"], "forbiddenGlobals": ["fetch"] },