arkgate 2.1.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 (64) hide show
  1. package/CHANGELOG.md +1249 -0
  2. package/LICENSE +21 -0
  3. package/README.md +218 -0
  4. package/SECURITY.md +39 -0
  5. package/bin/ark-check.mjs +5204 -0
  6. package/bin/ark-mcp.mjs +898 -0
  7. package/bin/ark-shared.mjs +1520 -0
  8. package/bin/ark.mjs +491 -0
  9. package/dist/eslint/index.cjs +222 -0
  10. package/dist/eslint/index.cjs.map +1 -0
  11. package/dist/eslint/index.d.cts +42 -0
  12. package/dist/eslint/index.d.ts +40 -0
  13. package/dist/eslint/index.js +193 -0
  14. package/dist/eslint/index.js.map +1 -0
  15. package/dist/index.cjs +3080 -0
  16. package/dist/index.cjs.map +1 -0
  17. package/dist/index.d.cts +577 -0
  18. package/dist/index.d.ts +577 -0
  19. package/dist/index.js +2998 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/nestjs/index.cjs +2332 -0
  22. package/dist/nestjs/index.cjs.map +1 -0
  23. package/dist/nestjs/index.d.cts +22 -0
  24. package/dist/nestjs/index.d.ts +22 -0
  25. package/dist/nestjs/index.js +2308 -0
  26. package/dist/nestjs/index.js.map +1 -0
  27. package/dist/types-DpdVN7Lm.d.cts +1023 -0
  28. package/dist/types-DpdVN7Lm.d.ts +1023 -0
  29. package/docs/agent-guide.md +490 -0
  30. package/docs/ai-gates.md +337 -0
  31. package/docs/ark-check-example.json +87 -0
  32. package/docs/assets/ark-write-gate.svg +28 -0
  33. package/docs/brownfield-adoption.md +87 -0
  34. package/docs/demos/01-write-gate-self-correction.md +74 -0
  35. package/docs/demos/02-brownfield-baseline-adoption.md +71 -0
  36. package/docs/demos/03-copilot-autopilot.md +83 -0
  37. package/docs/enthusiast/README.md +62 -0
  38. package/docs/enthusiast/explanation-application-shape.md +29 -0
  39. package/docs/enthusiast/how-to-agent-gates.md +36 -0
  40. package/docs/enthusiast/how-to-gallery-starter.md +27 -0
  41. package/docs/enthusiast/how-to-pick-shape.md +45 -0
  42. package/docs/enthusiast/how-to-policy-pack.md +37 -0
  43. package/docs/enthusiast/reference-archetypes.md +36 -0
  44. package/docs/enthusiast/reference-commands.md +50 -0
  45. package/docs/enthusiast/tutorial-first-project.md +86 -0
  46. package/docs/production-hardening.md +59 -0
  47. package/package.json +125 -0
  48. package/server.json +39 -0
  49. package/templates/architecture-playbook.json +339 -0
  50. package/templates/policy-packs/enthusiast-feature-sliced.json +20 -0
  51. package/templates/policy-packs/enthusiast-hexagonal.json +18 -0
  52. package/templates/policy-packs/enthusiast-layered.json +18 -0
  53. package/templates/policy-packs/enthusiast-monorepo.json +18 -0
  54. package/templates/skills/ark-adopt.md +103 -0
  55. package/templates/skills/ark-architect.md +90 -0
  56. package/templates/skills/ark-autopilot.md +95 -0
  57. package/templates/skills/ark-contract.md +98 -0
  58. package/templates/skills/ark-coverage.md +96 -0
  59. package/templates/skills/ark-explain.md +78 -0
  60. package/templates/skills/ark-fix.md +96 -0
  61. package/templates/skills/ark-loop.md +69 -0
  62. package/templates/skills/ark-place.md +68 -0
  63. package/templates/skills/ark-runtime.md +62 -0
  64. package/templates/skills/ark-upgrade.md +109 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pedro Knigge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,218 @@
1
+ <div align="center">
2
+
3
+ # ArkGate — Architecture Co-pilot for AI TypeScript
4
+
5
+ **Write gate · CI gate · co-pilot** for TypeScript projects that use AI agents.
6
+
7
+ Your AI writes most of the code. **ArkGate** keeps that code inside an architecture you can
8
+ trust — and makes sure a “green” check means something real.
9
+
10
+ [![CI](https://github.com/pedroknigge/ark-runtime-kernel/actions/workflows/ci.yml/badge.svg)](https://github.com/pedroknigge/ark-runtime-kernel/actions/workflows/ci.yml)
11
+ [![npm](https://img.shields.io/npm/v/arkgate?color=cb3837&label=npm)](https://www.npmjs.com/package/arkgate)
12
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
13
+ ![Node](https://img.shields.io/badge/node-%3E%3D18-339933?logo=node.js)
14
+ ![Zero deps](https://img.shields.io/badge/dependencies-0-success)
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## What it is
21
+
22
+ **ArkGate** is a **machine-readable architecture contract** for TypeScript, enforced in three places:
23
+
24
+ | When | Tool | What happens |
25
+ |------|------|----------------|
26
+ | **While the AI writes** | `arkgate-mcp` (write gate) | Blocks bad edits; agent self-corrects |
27
+ | **Before merge** | `arkgate-check` (CI) | Full TypeScript import graph + rules |
28
+ | **At runtime** *(optional)* | `createArkKernel()` | Event/intent governance if you opt in |
29
+
30
+ One file drives all of it: **`ark.config.json`**.
31
+
32
+ It is **not** a web framework, ORM, or job runner — and the optional runtime kernel is not
33
+ the product. The product is the **agent-native architecture gate** (write path + CI + plan/loop)
34
+ plus tools agents can read *before* generating code (`ark_place`, `ark://manifest`, …).
35
+
36
+ ![Write gate: agent blocked, then self-corrects](docs/assets/ark-write-gate.svg)
37
+
38
+ ---
39
+
40
+ ## Who it’s for
41
+
42
+ | You are… | You want… | Start with |
43
+ |----------|-----------|------------|
44
+ | **Builder with AI** (not necessarily an architect) | Order without learning “hexagonal” first | `npx arkgate start` → `/ark-autopilot` |
45
+ | **Engineer / tech lead** | A strict contract, CI, baselines, precise control | `ark init` + `ark-check` + write gate |
46
+ | **Team on a messy repo** | Truth about coverage + a cleanup path, not a false green | `ark-check --coverage` → `/ark-adopt` |
47
+
48
+ **Not for:** projects with no TypeScript, people who only want a one-off lint rule and no agent workflow, or anyone looking for an app framework.
49
+
50
+ ---
51
+
52
+ ## What you get (in plain language)
53
+
54
+ 1. **A shape** — Ark looks at your repo (Nest, Next, API, library, …) and suggests how to organize it.
55
+ 2. **Guardrails** — config + agent gates + CI so new code can’t quietly break layers.
56
+ 3. **A plan** — what’s safe for an agent to fix vs what needs your decision.
57
+ 4. **Honesty** — if Ark only governs 10% of the tree, it says so. “Clean” with almost no coverage is not success.
58
+
59
+ Three **operating modes** (not “user types”) on the same contract:
60
+
61
+ | Mode | Meaning |
62
+ |------|---------|
63
+ | **Suggest** | Install a starting shape |
64
+ | **Adapt** | Match the contract to real folders / raise coverage |
65
+ | **Enforce** | Gates actually protect you |
66
+
67
+ ---
68
+
69
+ ## Start in one minute
70
+
71
+ ```bash
72
+ npm install -D arkgate typescript
73
+ npx arkgate start # look at the project → setup → plan (plain language)
74
+ # (aliases: ark start / ark-check / ark-mcp still work)
75
+ ```
76
+
77
+ Then, in your agent (Claude / Cursor / Codex / **Grok** / …):
78
+
79
+ ```text
80
+ /ark-autopilot
81
+ ```
82
+
83
+ That is the **co-pilot**: set up → plan → apply safe fixes (validated, reversible) → propose the rest → leave gates on.
84
+
85
+ **Prefer manual control?**
86
+
87
+ ```bash
88
+ npx arkgate init # config + gates
89
+ npx arkgate-check # CI gate
90
+ npx arkgate-check --plan # classified fix list
91
+ npx arkgate-check --coverage
92
+ ```
93
+
94
+ Works with **npm, pnpm, and yarn**. No install lifecycle scripts (safe for hardened CI).
95
+
96
+ ---
97
+
98
+ ## Agent skills (`/ark-*`)
99
+
100
+ Install with agent gates:
101
+
102
+ ```bash
103
+ npx arkgate-check --install-agent-gates
104
+ # or pick hosts: --tools claude,cursor,codex,grok
105
+ ```
106
+
107
+ | Skill | What it does |
108
+ |-------|----------------|
109
+ | **`/ark-autopilot`** | End-to-end co-pilot: setup → plan → safe auto-fixes → propose the rest → leave gates on |
110
+ | **`/ark-loop`** | Drive the remediation plan in a discardable worktree; only `mechanical-safe` steps auto-apply |
111
+ | **`/ark-architect`** | Greenfield: pick application shape, phase-1 layers, scaffold, verify honestly |
112
+ | **`/ark-adopt`** | Brownfield: match contract to reality, raise coverage, freeze only real debt |
113
+ | **`/ark-contract`** | Safely edit `ark.config.json` (smallest change, strict re-check) |
114
+ | **`/ark-place`** | Where does this new artifact go? Layer, path, naming — then scaffold |
115
+ | **`/ark-fix`** | Fix violations at the source (no disable comments, no gate weakening) |
116
+ | **`/ark-explain`** | Explain the current contract, coverage, and report in plain language |
117
+ | **`/ark-coverage`** | Audit which Ark capabilities you are not using yet |
118
+ | **`/ark-runtime`** | Opt-in: migrate hand-rolled bus/outbox/sagas onto the runtime kernel |
119
+ | **`/ark-upgrade`** | Bump the package and refresh gates + skills for every agent host |
120
+
121
+ Supported agent hosts for full MCP/hook gates: **Claude Code**, **Cursor**, **OpenAI Codex**, **Grok Build**. Instruction-tier hosts (Windsurf, Cline, Copilot, …) get rule files. See [docs/ai-gates.md](docs/ai-gates.md).
122
+
123
+ ---
124
+
125
+ ## How it works (short)
126
+
127
+ ```
128
+ ark.config.json
129
+
130
+ ├─► Write gate (ark-mcp) — agent PreToolUse / MCP tools
131
+ ├─► CI gate (ark-check) — PR / main
132
+ └─► Runtime kernel (opt-in) — only if you call it
133
+ ```
134
+
135
+ - **Presets:** hexagonal, layered, feature-sliced, monorepo (all layers optional).
136
+ - **Frameworks:** Nest / Next / express / library layouts get sensible globs on init so day-one coverage is real.
137
+ - **Brownfield:** baseline ratchet, refuse to freeze a wrong contract, `/ark-adopt` for mature trees.
138
+ - **Agents:** skills above install into Claude / Cursor / Codex / Grok command locations.
139
+
140
+ ### Why not only ESLint / dependency-cruiser / Nx?
141
+
142
+ | | Ark | Typical boundary linter |
143
+ |--|:---:|:---:|
144
+ | CI import rules | ✅ | ✅ |
145
+ | Block **AI writes** before they land | ✅ | ❌ |
146
+ | Contract agents can read (`ark://manifest`) | ✅ | ❌ |
147
+ | Placement tools (`ark_place`, …) | ✅ | ❌ |
148
+ | Honest governed % + adoption path | ✅ | ❌ |
149
+ | Zero runtime dependencies | ✅ | varies |
150
+
151
+ ---
152
+
153
+ ## Common commands
154
+
155
+ ```bash
156
+ npx arkgate start # guided setup + plan
157
+ npx arkgate-check --doctor # health + operating mode
158
+ npx arkgate-check --plan # safe-to-auto-fix vs your call
159
+ npx arkgate-check --coverage # Governed: N%
160
+ npx arkgate-check --report ark-report.html # showcase HTML + origin/latest snapshots
161
+ npx arkgate-check --baseline # only NEW violations fail
162
+ npx arkgate upgrade # update package + refresh gates/skills
163
+ ```
164
+
165
+ CI (example):
166
+
167
+ ```yaml
168
+ - run: npx arkgate-check --root . --config ark.config.json --strict-config
169
+ # or: uses: pedroknigge/ark-runtime-kernel@main # Action still on this repo until rename
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Optional: runtime kernel
175
+
176
+ Gates need **no app code changes**. If you also want runtime intent/event contracts:
177
+
178
+ ```ts
179
+ import { createStrictArkKernelFromConfig } from 'arkgate';
180
+ // see docs/production-hardening.md and package exports
181
+ ```
182
+
183
+ NestJS: `arkgate/nestjs` (optional peer `@nestjs/common`).
184
+
185
+ ---
186
+
187
+ ## Documentation
188
+
189
+ | Audience | Link |
190
+ |----------|------|
191
+ | New builders (plain language) | [docs/enthusiast/](docs/enthusiast/README.md) |
192
+ | Wire Claude / Cursor / Codex / Grok | [docs/ai-gates.md](docs/ai-gates.md) |
193
+ | Messy existing repo | [docs/brownfield-adoption.md](docs/brownfield-adoption.md) |
194
+ | Agent / MCP tools | [docs/agent-guide.md](docs/agent-guide.md) |
195
+ | Demos | [docs/demos/](docs/demos/) |
196
+ | Examples | [examples/](examples/README.md) |
197
+ | Roadmap | [ROADMAP.md](ROADMAP.md) · [Changelog](CHANGELOG.md) |
198
+
199
+ ---
200
+
201
+ ## Develop this repo
202
+
203
+ ```bash
204
+ npm ci && npm run build
205
+ npx vitest run
206
+ npm run typecheck
207
+ npm run check:architecture # Ark gates itself
208
+ ```
209
+
210
+ **npm:** [`arkgate`](https://www.npmjs.com/package/arkgate) · formerly `ark-runtime-kernel`
211
+ **Product:** **ArkGate** — architecture co-pilot / gate for AI TypeScript (not a runtime kernel).
212
+ CLI: `arkgate` · `arkgate-check` · `arkgate-mcp` (aliases `ark` / `ark-check` / `ark-mcp` still work).
213
+
214
+ Node ≥ 18 · **MIT**.
215
+
216
+ ---
217
+
218
+ **Ark doesn’t invent your product. It keeps AI-generated TypeScript inside an architecture you can trust — and tells you when it isn’t really enforcing anything yet.**
package/SECURITY.md ADDED
@@ -0,0 +1,39 @@
1
+ # Security Policy
2
+
3
+ Ark runs in developer machines, CI, and agent tooling paths, so security reports are
4
+ treated as high priority.
5
+
6
+ ## Supported Versions
7
+
8
+ Security fixes target the latest published minor version. If a fix needs a new release,
9
+ the changelog will call out the affected versions and the patched version.
10
+
11
+ ## Reporting A Vulnerability
12
+
13
+ Please do not open a public issue for a suspected vulnerability.
14
+
15
+ Preferred path: use GitHub's private vulnerability reporting for this repository. Include:
16
+
17
+ - affected version or commit
18
+ - reproduction steps
19
+ - expected impact
20
+ - whether the issue affects `ark-check`, `ark-mcp`, generated agent gates, the GitHub
21
+ Action, or the optional runtime kernel
22
+
23
+ If private vulnerability reporting is unavailable, open a minimal public issue asking for
24
+ a private security contact without including exploit details.
25
+
26
+ ## Release Verification
27
+
28
+ Ark releases are GitHub-first:
29
+
30
+ 1. Changes land on GitHub and must pass CI plus the dedicated security workflow.
31
+ 2. A GitHub Release is created from an annotated `vX.Y.Z` tag. Signed tags are
32
+ supported and can be made mandatory by setting `ARK_REQUIRE_SIGNED_RELEASE_TAG=true`
33
+ in the publish workflow once release signing is configured.
34
+ 3. The manual `Publish npm` workflow verifies the tag, requires the GitHub Release to
35
+ exist, reruns release checks, publishes npm with provenance, and uploads a SHA-256
36
+ checksum for the npm tarball to the GitHub Release.
37
+
38
+ Consumers in sensitive environments should still pin exact npm versions and GitHub
39
+ Action SHAs/tags, then verify npm provenance and the release checksum before upgrading.