arkgate 2.2.0 → 2.4.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 +59 -0
- package/README.md +26 -16
- package/SECURITY.md +9 -8
- package/bin/ark-check.mjs +605 -53
- package/bin/ark-shared.mjs +70 -3
- package/bin/ark.mjs +20 -5
- package/dist/index.cjs +1 -1
- 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 +1 -1
- 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/docs/agent-guide.md +11 -5
- package/docs/ai-gates.md +11 -7
- package/docs/brownfield-adoption.md +14 -13
- package/docs/demos/03-copilot-autopilot.md +5 -3
- package/docs/enthusiast/README.md +4 -3
- package/docs/enthusiast/how-to-agent-gates.md +14 -6
- package/docs/enthusiast/reference-commands.md +23 -8
- package/docs/migrate-from-ark-runtime-kernel.md +18 -0
- package/docs/typescript-support.md +142 -0
- package/package.json +12 -3
- package/server.json +2 -2
- package/templates/skills/ark-autopilot.md +6 -4
- package/templates/skills/ark-explain.md +7 -2
- package/templates/skills/ark-fix.md +16 -12
- package/templates/skills/ark-loop.md +14 -4
- package/templates/skills/ark-upgrade.md +26 -1
- package/templates/tests/ark-adoption-gaps.test.ts +68 -0
- package/tests/fixtures/ts-consumer/ark.config.json +11 -0
- package/tests/fixtures/ts-consumer/src/app/types.ts +1 -0
- package/tests/fixtures/ts-consumer/src/domain/bad.ts +1 -0
- package/tests/fixtures/ts-consumer/src/domain/ok.ts +1 -0
- package/tests/fixtures/ts-consumer/src/domain/user.ts +1 -0
- package/tests/fixtures/ts-consumer/tsconfig.json +16 -0
package/docs/agent-guide.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ArkGate — Agent Integration Guide
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
and codegen tools
|
|
3
|
+
**ArkGate** (`arkgate`) — architecture co-pilot for AI TypeScript. This guide describes how AI
|
|
4
|
+
agents and codegen tools safely interact with the write gate, MCP tools, and `/ark-*` skills.
|
|
5
|
+
|
|
6
|
+
CLI names: prefer **`arkgate` / `arkgate-check` / `arkgate-mcp`**; aliases `ark` / `ark-check` /
|
|
7
|
+
`ark-mcp` still work for one major. TypeScript **5.x / 6.x / 7.x** as the project compiler:
|
|
8
|
+
see [typescript-support.md](typescript-support.md).
|
|
5
9
|
|
|
6
10
|
## Architecture playbook and `ark-check --recommend`
|
|
7
11
|
|
|
@@ -120,7 +124,8 @@ directories (`utils/`, `lib/`) must be classified explicitly via `/ark-contract`
|
|
|
120
124
|
Wire write-gate + MCP + `/ark-*` skills with:
|
|
121
125
|
|
|
122
126
|
```bash
|
|
123
|
-
npx
|
|
127
|
+
npx arkgate-check --install-agent-gates --tools claude,cursor,codex,grok
|
|
128
|
+
# alias: npx ark-check --install-agent-gates --tools claude,cursor,codex,grok
|
|
124
129
|
```
|
|
125
130
|
|
|
126
131
|
| Host | Write gate | MCP | Skills path |
|
|
@@ -424,7 +429,8 @@ not replace your web framework, HTTP clients, or job scheduler.
|
|
|
424
429
|
## Write-Path Gate (MCP)
|
|
425
430
|
|
|
426
431
|
The strongest place to constrain an AI agent is the moment it writes a file, not after.
|
|
427
|
-
`ark-mcp` exposes
|
|
432
|
+
`arkgate-mcp` / `ark-mcp` exposes ArkGate over MCP (JSON-RPC over stdio; gate host needs a
|
|
433
|
+
JS-API TypeScript — nested or project) so a host can gate
|
|
428
434
|
the write path:
|
|
429
435
|
|
|
430
436
|
```bash
|
package/docs/ai-gates.md
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
# Gating AI Agents with
|
|
1
|
+
# Gating AI Agents with ArkGate
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**ArkGate** (`arkgate`) is the architecture co-pilot for AI TypeScript (write gate · CI · plan/loop).
|
|
4
4
|
The write-path gate is what makes it different from every other architecture linter:
|
|
5
5
|
generated code is validated against your architecture **before it lands on disk**, not
|
|
6
6
|
after the PR is red.
|
|
7
7
|
|
|
8
|
-
Everything below uses the same `ark.config.json` as `ark-check` (CI) — one
|
|
8
|
+
Everything below uses the same `ark.config.json` as `arkgate-check` / `ark-check` (CI) — one
|
|
9
|
+
contract, enforced everywhere. Generate it once:
|
|
9
10
|
|
|
10
11
|
```bash
|
|
11
|
-
npx
|
|
12
|
+
npx arkgate-check --init
|
|
13
|
+
# aliases: ark-check, ark init, arkgate start
|
|
12
14
|
```
|
|
13
15
|
|
|
14
16
|
For guided setup with prompts, use:
|
|
15
17
|
|
|
16
18
|
```bash
|
|
17
|
-
npx
|
|
19
|
+
npx arkgate start
|
|
20
|
+
# or: npx ark init
|
|
18
21
|
```
|
|
19
22
|
|
|
20
23
|
For non-interactive defaults, use:
|
|
21
24
|
|
|
22
25
|
```bash
|
|
23
|
-
npx
|
|
26
|
+
npx arkgate start --yes
|
|
27
|
+
# or: npx ark init --yes
|
|
24
28
|
```
|
|
25
29
|
|
|
26
30
|
You can also generate only the starter gate files for common agent runtimes and CI:
|
|
27
31
|
|
|
28
32
|
```bash
|
|
29
|
-
npx
|
|
33
|
+
npx arkgate-check --install-agent-gates
|
|
30
34
|
```
|
|
31
35
|
|
|
32
36
|
The command writes templates for `.mcp.json`, Claude hooks, Cursor MCP/rules,
|
|
@@ -61,19 +61,20 @@ violations — the ratchet only moves toward zero.
|
|
|
61
61
|
|
|
62
62
|
## 5. Burn down, in order
|
|
63
63
|
|
|
64
|
-
`summary.edges` is the burn-down order.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
- **Type-only inversion** (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
type
|
|
71
|
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
`summary.edges` is the burn-down order. Prefer `ark-check --plan`: it tags each step
|
|
65
|
+
`mechanical-safe` / `judgment` / `deferred` and sets `remediationKind` for auto-safe cases.
|
|
66
|
+
|
|
67
|
+
- **Type-only inversion** (`typeOnly` — plan: `type-only-import-move`): move the type to the
|
|
68
|
+
owning layer + re-export for back-compat. Safe to sweep when mechanical-safe.
|
|
69
|
+
- **Pure-type file** (`sourcePureTypeModule` — plan: `pure-type-file-relocate`): whole file is
|
|
70
|
+
type-surface only — relocate the file (or extract types) to the owning layer.
|
|
71
|
+
- **Value import of pure type module** (`targetTypeOnlyExports` — plan:
|
|
72
|
+
`import-type-from-pure-type-module`): convert static import to `import type`. Not safe for
|
|
73
|
+
`require()` / dynamic `import()`.
|
|
74
|
+
- **Raw infrastructure access** (value coupling — always **judgment**): relocate data-access
|
|
75
|
+
**verbatim** into a repository/adapter. Same query bytes = same behavior; do NOT rewrite the
|
|
76
|
+
query. If CODEOWNERS reserves the data layer, migrate one route as a pattern and hand bulk
|
|
77
|
+
work over; interleaved transactions aren't a pure relocation — flag them.
|
|
77
78
|
|
|
78
79
|
`/ark-fix` resolves each cluster at the root cause; fixing a frozen violation shrinks the
|
|
79
80
|
baseline permanently. Re-freeze lower with `--update-baseline` as you go.
|
|
@@ -39,9 +39,11 @@ npx ark-check --plan # human view (includes Governed: N%)
|
|
|
39
39
|
npx ark-check --plan --json # { ok, plan: { goal, counts, steps } }
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
Each step is tagged `mechanical-safe` / `judgment` / `deferred` with a `confidence
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
Each step is tagged `mechanical-safe` / `judgment` / `deferred` with a `confidence`,
|
|
43
|
+
`rationale`, and often `remediationKind`. Only three kinds are auto-safe: type-only type move,
|
|
44
|
+
pure-type **file** relocate, and `import type` of pure-type modules. `goal.met` is true only when
|
|
45
|
+
there are no active violations **and** governed coverage is meaningful — so a clean plan that
|
|
46
|
+
checks almost nothing is not "done."
|
|
45
47
|
|
|
46
48
|
### 3. Carry the plan out — the autopilot
|
|
47
49
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ArkGate — Architecture Co-pilot (enthusiast track)
|
|
2
2
|
|
|
3
3
|
Plain-language onboarding for builders who use AI agents but are not professional
|
|
4
4
|
developers. This track follows [Diátaxis](https://diataxis.fr/): tutorial, how-to,
|
|
5
|
-
reference, and explanation.
|
|
5
|
+
reference, and explanation. Package: **`arkgate`** (CLI: `arkgate` / `arkgate-check`;
|
|
6
|
+
aliases `ark` / `ark-check` still work).
|
|
6
7
|
|
|
7
|
-
## How
|
|
8
|
+
## How ArkGate talks to you
|
|
8
9
|
|
|
9
10
|
**Entry style** — who is driving: *newbie* (`ark start` / `/ark-autopilot`) vs *expert* (individual commands).
|
|
10
11
|
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
# How to install agent gates
|
|
2
2
|
|
|
3
3
|
```bash
|
|
4
|
-
npx
|
|
5
|
-
npx
|
|
4
|
+
npx arkgate-check --install-agent-gates
|
|
5
|
+
npx arkgate-check --install-agent-gates --tools claude,cursor,codex,grok
|
|
6
|
+
# aliases: ark-check …
|
|
6
7
|
```
|
|
7
8
|
|
|
8
9
|
Installs:
|
|
9
10
|
|
|
10
11
|
- Write-gate hook configuration (Claude / Grok PreToolUse; Cursor advisory + MCP)
|
|
11
12
|
- MCP server entry (`.mcp.json`, Cursor/Codex/Grok equivalents)
|
|
12
|
-
- `/ark-*` skills including **`/ark-architect
|
|
13
|
+
- `/ark-*` skills including **`/ark-architect`**, **`/ark-autopilot`**, **`/ark-loop`**
|
|
14
|
+
(with current `mechanical-safe` remediation kinds)
|
|
13
15
|
|
|
14
16
|
| Host | Extra paths |
|
|
15
17
|
|------|-------------|
|
|
@@ -20,7 +22,7 @@ Installs:
|
|
|
20
22
|
|
|
21
23
|
## Session hint
|
|
22
24
|
|
|
23
|
-
`
|
|
25
|
+
`arkgate-mcp --session-context` appends when governed coverage is low:
|
|
24
26
|
|
|
25
27
|
```
|
|
26
28
|
New to Ark? Run /ark-architect or: ark-check --recommend
|
|
@@ -29,8 +31,14 @@ New to Ark? Run /ark-architect or: ark-check --recommend
|
|
|
29
31
|
## Verify gates
|
|
30
32
|
|
|
31
33
|
```bash
|
|
32
|
-
npx
|
|
33
|
-
npx
|
|
34
|
+
npx arkgate-check --doctor
|
|
35
|
+
npx arkgate-check --require-gates
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
After upgrading the package, refresh skills so agents see the latest plan kinds:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx arkgate-check --install-agent-gates --skills-only --force
|
|
34
42
|
```
|
|
35
43
|
|
|
36
44
|
Full copy-paste setups: [docs/ai-gates.md](../ai-gates.md).
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# Reference: commands and artifacts
|
|
2
2
|
|
|
3
|
+
Product: **ArkGate** (`arkgate`). Prefer `arkgate` / `arkgate-check` / `arkgate-mcp`; aliases
|
|
4
|
+
`ark` / `ark-check` / `ark-mcp` work for one major. TypeScript 5–7: [typescript-support.md](../typescript-support.md).
|
|
5
|
+
|
|
3
6
|
## Recommendation
|
|
4
7
|
|
|
5
8
|
```bash
|
|
6
|
-
|
|
9
|
+
arkgate-check --recommend [--json] [--write-plan]
|
|
10
|
+
# alias: ark-check …
|
|
7
11
|
```
|
|
8
12
|
|
|
9
13
|
MCP: `ark_recommend` — same JSON body.
|
|
@@ -33,18 +37,29 @@ Pack metadata: `templates/policy-packs/enthusiast-*.json`.
|
|
|
33
37
|
## Init and verify
|
|
34
38
|
|
|
35
39
|
```bash
|
|
36
|
-
|
|
37
|
-
ark
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
arkgate start --yes # guided setup + plan
|
|
41
|
+
ark init --archetype <id> --yes # alias path
|
|
42
|
+
arkgate-check --doctor [--json]
|
|
43
|
+
arkgate-check --coverage [--json]
|
|
44
|
+
arkgate-check --plan [--json] # mechanical-safe vs judgment vs deferred
|
|
45
|
+
arkgate-check --strict-config
|
|
46
|
+
arkgate-check --report out.html --beginner
|
|
47
|
+
arkgate-check --watch
|
|
42
48
|
```
|
|
43
49
|
|
|
50
|
+
## Plan classes (`--plan --json`)
|
|
51
|
+
|
|
52
|
+
| `class` | Agent may auto-apply? | Examples (`remediationKind`) |
|
|
53
|
+
|---------|----------------------|------------------------------|
|
|
54
|
+
| `mechanical-safe` | Yes (validate + rollback) | `type-only-import-move`, `pure-type-file-relocate`, `import-type-from-pure-type-module` |
|
|
55
|
+
| `judgment` | No — propose | value imports, ports, infra relocate, cycles |
|
|
56
|
+
| `deferred` | No | unclear shape |
|
|
57
|
+
|
|
44
58
|
## Violation JSON (enthusiast fields)
|
|
45
59
|
|
|
46
60
|
When present on violations:
|
|
47
61
|
|
|
48
62
|
- `fixClass` — e.g. `port-inversion`, `file-move`
|
|
49
63
|
- `effort` — `small` | `medium`
|
|
50
|
-
- `enthusiastHint` — plain English fix guidance
|
|
64
|
+
- `enthusiastHint` — plain English fix guidance
|
|
65
|
+
- plan enrichment: `class`, `remediationKind`, `typeOnly`, `sourcePureTypeModule`, `targetTypeOnlyExports`
|
|
@@ -42,6 +42,24 @@ npx arkgate upgrade
|
|
|
42
42
|
|
|
43
43
|
(`ark upgrade` works too — both install `arkgate@latest` and refresh gates.)
|
|
44
44
|
|
|
45
|
+
### TypeScript 7
|
|
46
|
+
|
|
47
|
+
If the project uses **TypeScript 7** as `tsc`, the gate still works: ArkGate embeds a JS-API
|
|
48
|
+
TypeScript host and falls back when `require('typescript')` is version-only. See
|
|
49
|
+
[typescript-support.md](typescript-support.md). Optional dual-install (TS 6 for tools + TS 7
|
|
50
|
+
CLI) is documented there.
|
|
51
|
+
|
|
52
|
+
### MCP args (avoid double binary)
|
|
53
|
+
|
|
54
|
+
`.mcp.json` / `.cursor/mcp.json` must look like:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
"args": ["arkgate-mcp", "--root", ".", "--config", "ark.config.json"]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Not** `["ark-mcp", "arkgate-mcp", …]` — that breaks MCP stdio. Fixed by
|
|
61
|
+
`npx arkgate-check --install-agent-gates --migrate-commands` (ArkGate ≥ 2.4.0).
|
|
62
|
+
|
|
45
63
|
---
|
|
46
64
|
|
|
47
65
|
## What to change in your repo
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# TypeScript support (5.x · 6.x · 7.x)
|
|
2
|
+
|
|
3
|
+
ArkGate’s architecture gate (`arkgate-check` / `ark-mcp`) needs a **JavaScript API**
|
|
4
|
+
TypeScript package that exposes:
|
|
5
|
+
|
|
6
|
+
- `ts.sys` (at least `fileExists`)
|
|
7
|
+
- `createSourceFile` (AST)
|
|
8
|
+
- `resolveModuleName` (module graph)
|
|
9
|
+
|
|
10
|
+
It does **not** require the Go-native `tsc` binary for the gate. Type-checking
|
|
11
|
+
semantics of your app still come from **your** project `typescript` + `tsconfig`.
|
|
12
|
+
|
|
13
|
+
## Supported versions
|
|
14
|
+
|
|
15
|
+
| Range | Status |
|
|
16
|
+
|-------|--------|
|
|
17
|
+
| **TypeScript 5.x** | Fully supported (primary CI) |
|
|
18
|
+
| **TypeScript 6.x** | Supported (bridge release before 7) |
|
|
19
|
+
| **TypeScript 7.x** | Supported as **project** compiler; gate loads project TS when API-compatible, otherwise **falls back** to a JS-API TypeScript |
|
|
20
|
+
|
|
21
|
+
Optional peer (documentational):
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"typescript": ">=5.0.0 <8"
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
ArkGate does not hard-require `typescript` as a runtime dependency of the package
|
|
30
|
+
itself; the CLI resolves it from the **project** first, then from the environment.
|
|
31
|
+
|
|
32
|
+
## How loading works
|
|
33
|
+
|
|
34
|
+
1. Prefer `require('typescript')` from the **project** root (when it has `sys` + AST + resolve).
|
|
35
|
+
2. If missing or **not API-compatible** (TS 7.0 version-only export, or incomplete host), fall back to **ArkGate’s own** `typescript` dependency (JS-API 5.x nested under the package), then bare `import('typescript')`.
|
|
36
|
+
3. If nothing usable is found:
|
|
37
|
+
- `--plan` still prints **coverage honesty** (no import graph)
|
|
38
|
+
- full check exits non-zero with an install hint
|
|
39
|
+
|
|
40
|
+
Debug which TypeScript was used:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
ARK_DEBUG_TS=1 npx arkgate-check --plan
|
|
44
|
+
# → [ark-check] TypeScript 5.9.x via arkgate (fallback)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## TypeScript 7 notes
|
|
48
|
+
|
|
49
|
+
TypeScript 7 is the **native (Go) compiler** generation. Important for tools like ArkGate:
|
|
50
|
+
|
|
51
|
+
- **`require('typescript')` on 7.0.x** exports only `{ version, versionMajorMinor }` — not `sys`, `createSourceFile`, or `resolveModuleName`.
|
|
52
|
+
- Unstable programmatic surfaces live under `typescript/unstable/*` (sync/async API, AST). They are **not** the classic TS 5/6 host ArkGate uses today.
|
|
53
|
+
- Stable **programmatic JS API** maturity continues over the 7.x line (Microsoft: full story into **7.1+**).
|
|
54
|
+
- When the project’s TypeScript is not API-compatible, ArkGate loads its **bundled JS-API dependency** (`typescript@^5.9`, nested under the package) so the write/CI gate keeps working while you try TS 7 as the project compiler.
|
|
55
|
+
- Your **tsconfig** must follow TS 6/7 defaults (see below) or `tsc` / resolve can fail independently of ArkGate.
|
|
56
|
+
|
|
57
|
+
### tsconfig defaults that surprise teams (TS 6 → 7)
|
|
58
|
+
|
|
59
|
+
Adopt these before or when moving to TS 7:
|
|
60
|
+
|
|
61
|
+
| Option | TS7 direction |
|
|
62
|
+
|--------|----------------|
|
|
63
|
+
| `strict` | default `true` |
|
|
64
|
+
| `module` | often `esnext` |
|
|
65
|
+
| `moduleResolution` | `nodenext` or `bundler` (not `node` / `node10`) |
|
|
66
|
+
| `baseUrl` | removed — put paths relative to project root |
|
|
67
|
+
| `types` | default `[]` — list globals explicitly, e.g. `["node"]` |
|
|
68
|
+
| `rootDir` | default `./` — set `"./src"` when sources live under `src` |
|
|
69
|
+
| `target: es5` | unsupported |
|
|
70
|
+
| `esModuleInterop: false` | unsupported |
|
|
71
|
+
|
|
72
|
+
Example consumer-friendly skeleton (also used in `tests/fixtures/ts-consumer`):
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"compilerOptions": {
|
|
77
|
+
"target": "ES2022",
|
|
78
|
+
"module": "ESNext",
|
|
79
|
+
"moduleResolution": "bundler",
|
|
80
|
+
"strict": true,
|
|
81
|
+
"rootDir": "./src",
|
|
82
|
+
"types": ["node"],
|
|
83
|
+
"skipLibCheck": true,
|
|
84
|
+
"noEmit": true
|
|
85
|
+
},
|
|
86
|
+
"include": ["src/**/*.ts"]
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Side-by-side TypeScript 6 + 7 (tooling)
|
|
91
|
+
|
|
92
|
+
If you need **tsc 7** for builds and a **JS API 6** for tools that still expect classic exports:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"devDependencies": {
|
|
97
|
+
"typescript": "npm:@typescript/typescript6@^6.0.0",
|
|
98
|
+
"typescript-7": "npm:typescript@^7.0.0"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- `npx tsc6` — TypeScript 6 CLI (from the alias package)
|
|
104
|
+
- `npx typescript-7` / install path — TypeScript 7 CLI as needed
|
|
105
|
+
|
|
106
|
+
ArkGate will prefer the project’s `typescript` package; keep that entry **API-compatible** (5/6, or 7 once `sys` is present). See Microsoft’s TS 7 RC blog for dual-install details.
|
|
107
|
+
|
|
108
|
+
## CI matrix (this repo)
|
|
109
|
+
|
|
110
|
+
GitHub Actions job `ts-compat` installs TypeScript **5.9.x**, **6.0.x**, and **7.0.x** into a temp copy of `tests/fixtures/ts-consumer` and runs:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
node bin/ark-check.mjs --root <fixture> --plan --json --no-cache
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Locally:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
node scripts/ts-compat-matrix.mjs 5.9.3
|
|
120
|
+
node scripts/ts-compat-matrix.mjs 6.0.3
|
|
121
|
+
node scripts/ts-compat-matrix.mjs 7.0.2
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## What “compatible” means for ArkGate
|
|
125
|
+
|
|
126
|
+
| Goal | Status |
|
|
127
|
+
|------|--------|
|
|
128
|
+
| Gate does not crash on project TS 7 | Yes (fallback if API incomplete) |
|
|
129
|
+
| Plan/check work with project TS 5/6 | Yes |
|
|
130
|
+
| Plan/check work when project has TS 7 + usable `sys` | Yes (uses project) |
|
|
131
|
+
| Gate uses native Go typechecker API exclusively | Not required; future if 7.1+ exposes a stable Node API we adopt |
|
|
132
|
+
| User tsconfigs with removed options still “just work” | User must migrate tsconfig (TS6/7); Ark reports resolve/parse failures clearly |
|
|
133
|
+
|
|
134
|
+
## Future (7.1+ programmatic API)
|
|
135
|
+
|
|
136
|
+
When Microsoft ships a stable Node API for native TypeScript 7.1+:
|
|
137
|
+
|
|
138
|
+
1. Extend `usableTypescript` for the new export shape.
|
|
139
|
+
2. Keep the multi-version matrix green.
|
|
140
|
+
3. Optionally prefer project TS 7 for resolution without fallback.
|
|
141
|
+
|
|
142
|
+
Until then, **fallback + matrix** is the compatibility story so teams can try TS 7 today without breaking the architecture gate.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkgate",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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",
|
|
@@ -41,10 +41,12 @@
|
|
|
41
41
|
"docs/demos",
|
|
42
42
|
"docs/ai-gates.md",
|
|
43
43
|
"docs/migrate-from-ark-runtime-kernel.md",
|
|
44
|
+
"docs/typescript-support.md",
|
|
44
45
|
"docs/ark-check-example.json",
|
|
45
46
|
"docs/assets",
|
|
46
47
|
"docs/brownfield-adoption.md",
|
|
47
48
|
"docs/production-hardening.md",
|
|
49
|
+
"tests/fixtures/ts-consumer",
|
|
48
50
|
"templates",
|
|
49
51
|
"server.json",
|
|
50
52
|
"README.md",
|
|
@@ -60,18 +62,26 @@
|
|
|
60
62
|
"typecheck": "tsc --noEmit",
|
|
61
63
|
"security:audit": "npm audit --omit=dev --audit-level=high",
|
|
62
64
|
"check:architecture": "node bin/ark-check.mjs --root . --config ark.config.json --strict-config",
|
|
65
|
+
"test:ts-compat": "node scripts/ts-compat-matrix.mjs 5.9.3 && node scripts/ts-compat-matrix.mjs 6.0.3 && node scripts/ts-compat-matrix.mjs 7.0.2",
|
|
63
66
|
"eval:agent": "node eval/run.mjs",
|
|
64
67
|
"eval:comparative": "node eval/comparative-run.mjs",
|
|
65
68
|
"clean": "rm -rf dist",
|
|
66
69
|
"release:npm": "node scripts/release-npm.mjs",
|
|
67
70
|
"prepack": "npm run build"
|
|
68
71
|
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"typescript": "^5.9.3"
|
|
74
|
+
},
|
|
69
75
|
"peerDependencies": {
|
|
70
|
-
"@nestjs/common": ">=9"
|
|
76
|
+
"@nestjs/common": ">=9",
|
|
77
|
+
"typescript": ">=5.0.0 <8"
|
|
71
78
|
},
|
|
72
79
|
"peerDependenciesMeta": {
|
|
73
80
|
"@nestjs/common": {
|
|
74
81
|
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"typescript": {
|
|
84
|
+
"optional": true
|
|
75
85
|
}
|
|
76
86
|
},
|
|
77
87
|
"overrides": {
|
|
@@ -89,7 +99,6 @@
|
|
|
89
99
|
"reflect-metadata": "^0.2.2",
|
|
90
100
|
"rxjs": "^7.8.2",
|
|
91
101
|
"tsup": "^8.1.0",
|
|
92
|
-
"typescript": "^5.5.3",
|
|
93
102
|
"vitest": "^3.2.6"
|
|
94
103
|
},
|
|
95
104
|
"engines": {
|
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.4.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "arkgate",
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.4.0",
|
|
15
15
|
"runtimeHint": "npx",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
@@ -55,12 +55,14 @@ Never tell a user "your architecture is guarded" while `--plan` reports `goal.me
|
|
|
55
55
|
|
|
56
56
|
3. **Show the plan.** Run `ark-check --plan` and explain it in outcome terms: how many fixes are
|
|
57
57
|
_safe to auto-apply_ vs _need your decision_ vs _deferred_, and what the goal is (a clean,
|
|
58
|
-
enforced architecture).
|
|
58
|
+
enforced architecture). Safe auto steps are only the three `mechanical-safe` kinds:
|
|
59
|
+
type-only type move, pure-type **file** relocate, and converting static imports of pure-type
|
|
60
|
+
modules to `import type` (see `/ark-loop`). Confirm before changing anything.
|
|
59
61
|
|
|
60
62
|
4. **Drive the loop.** Hand off to **`/ark-loop`**: in a discardable git worktree, auto-apply
|
|
61
|
-
the `mechanical-safe` steps one at a time (
|
|
62
|
-
and PROPOSE each `judgment` step in plain language for
|
|
63
|
-
`goal.met` is true or a round makes no progress.
|
|
63
|
+
the `mechanical-safe` steps one at a time (match each `remediationKind`; validate with
|
|
64
|
+
`ark-check`, roll back regressions), and PROPOSE each `judgment` step in plain language for
|
|
65
|
+
a yes/no. Loop until the plan's `goal.met` is true or a round makes no progress.
|
|
64
66
|
|
|
65
67
|
5. **Confirm it stays clean.** Verify the gates are installed and active so the architecture is
|
|
66
68
|
enforced from now on (in CI, and at write time if the MCP hook is wired) — the
|
|
@@ -36,16 +36,21 @@ Your job is to **teach with this repo's real data** and leave a shareable visual
|
|
|
36
36
|
```bash
|
|
37
37
|
npx ark-check --coverage
|
|
38
38
|
npx ark-check --doctor
|
|
39
|
+
npx ark-check --plan
|
|
39
40
|
```
|
|
40
41
|
|
|
41
|
-
so your spoken explanation matches the report's governed
|
|
42
|
-
(SUGGEST / ADAPT / ENFORCE).
|
|
42
|
+
so your spoken explanation matches the report's governed%, operating mode
|
|
43
|
+
(SUGGEST / ADAPT / ENFORCE), and the plan's safe-to-auto vs decision counts.
|
|
43
44
|
|
|
44
45
|
The HTML report is the visual twin of this skill: architecture map, files per layer,
|
|
45
46
|
dependency direction, matrix, violations, enforcement points, Ark fitness score, and a
|
|
46
47
|
**Senior diagnostics** block (coupling fan-in/out, deny density, purity surface, pattern
|
|
47
48
|
forensics, baseline taxonomy) for tech leads.
|
|
48
49
|
|
|
50
|
+
When explaining the **plan**, name the three `mechanical-safe` remediation kinds only
|
|
51
|
+
(type-only move, pure-type file relocate, `import type` of pure-type modules) — everything
|
|
52
|
+
else is judgment/deferred and must not be auto-applied.
|
|
53
|
+
|
|
49
54
|
## Spoken / written explanation
|
|
50
55
|
|
|
51
56
|
1. **Load the real contract**: `ark.config.json`, `ark://manifest` if available, `AGENTS.md`.
|
|
@@ -47,18 +47,22 @@ paste output you can generate yourself.
|
|
|
47
47
|
with the impure implementation outside the domain, and pass it in.
|
|
48
48
|
- **Intent prefix mismatch**: rename the intent to the layer's declared prefix,
|
|
49
49
|
or move the handler to the layer that owns that prefix.
|
|
50
|
-
- **Type-only inversion** (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
`tsc --noEmit
|
|
56
|
-
|
|
57
|
-
(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
- **Type-only inversion** (`typeOnly: true` on a `LAYER_IMPORT_VIOLATION` — plan class
|
|
51
|
+
`mechanical-safe`, `remediationKind: type-only-import-move`): a lower layer `import type`s
|
|
52
|
+
something from an upper layer (e.g. domain importing a type that lives in a UI hook). Move the
|
|
53
|
+
TYPE down to the layer that owns it and re-export for back-compat
|
|
54
|
+
(`export type { X } from "@/lib/<domain>/types"`). Highest-volume safe fix — verify with the
|
|
55
|
+
gate (and `tsc --noEmit` if present). Not mechanical if: (a) the type extends a persistence/ORM
|
|
56
|
+
row — needs a domain-owned type/port; (b) the source mixes types with runtime logic — split
|
|
57
|
+
first, then move (or use pure-type file relocate when the *whole file* is type-only).
|
|
58
|
+
- **Pure-type file relocate** (`sourcePureTypeModule` + type-only edge —
|
|
59
|
+
`remediationKind: pure-type-file-relocate`): the entire source file is type-surface only (no
|
|
60
|
+
runtime statements). Relocate the **file** to the owning layer (or extract the type module
|
|
61
|
+
there). Behavior-preserving; do not invent runtime ports.
|
|
62
|
+
- **Value-syntax import of a pure type-only module** (`targetTypeOnlyExports` —
|
|
63
|
+
`remediationKind: import-type-from-pure-type-module`): convert static `import { T } from …`
|
|
64
|
+
to `import type { T } from …`. Never auto-apply for `require()` / dynamic `import()` (those stay
|
|
65
|
+
judgment — they still execute the module).
|
|
62
66
|
- **Raw infrastructure access in an orchestration/UI layer** (a route/handler or component
|
|
63
67
|
that runs SQL or imports the DB client directly — e.g. `sqlClient\`SELECT …\`` or
|
|
64
68
|
`import { db } from "@/lib/db"` inside `src/app/**`): this is the value-import counterpart
|
|
@@ -21,15 +21,25 @@ If Ark isn't set up yet, run `ark start` (or `ark-check --recommend` then `ark i
|
|
|
21
21
|
1. **Read the plan.** Run `ark-check --plan --json` (add `--baseline .ark-baseline.json` if the
|
|
22
22
|
repo uses a baseline). It returns `goal` (with `met`, `activeViolations`, `autoApplicable`,
|
|
23
23
|
`needsDecision`, `deferred`) and `steps[]`, each tagged `class` (`mechanical-safe` /
|
|
24
|
-
`judgment` / `deferred`) with a `confidence
|
|
25
|
-
`goal.met` is already true, report "nothing to do" and stop.
|
|
24
|
+
`judgment` / `deferred`) with a `confidence`, plain-language `rationale`, and often
|
|
25
|
+
`remediationKind`. If `goal.met` is already true, report "nothing to do" and stop.
|
|
26
|
+
|
|
27
|
+
**`mechanical-safe` kinds you may auto-apply** (zero false-safe — never invent others):
|
|
28
|
+
|
|
29
|
+
| `remediationKind` | What to do |
|
|
30
|
+
|-------------------|------------|
|
|
31
|
+
| `type-only-import-move` | Edge is already `import type` / type-only: move the **type** to the owning layer + re-export for back-compat |
|
|
32
|
+
| `pure-type-file-relocate` | Whole **source file** is pure type-surface (`sourcePureTypeModule`) + type-only edge: relocate the file (or extract types) to the owning layer |
|
|
33
|
+
| `import-type-from-pure-type-module` | Static value-syntax import of a pure type-only **target** module (`targetTypeOnlyExports`): convert to `import type` (and place type if needed) |
|
|
34
|
+
|
|
35
|
+
Still **judgment** (never auto): value imports, `require()` / dynamic `import()`, mixed modules with side effects, forbidden globals, cycles, verbatim infra relocation.
|
|
26
36
|
|
|
27
37
|
2. **Work in a discardable git worktree.** Create one (`git worktree add`) so the entire run is
|
|
28
38
|
reversible and never disturbs the user's working tree. Do all edits there. Nothing is
|
|
29
39
|
permanent until the user reviews the final diff.
|
|
30
40
|
|
|
31
|
-
3. **Apply the `mechanical-safe` steps, one at a time, validated.**
|
|
32
|
-
(
|
|
41
|
+
3. **Apply the `mechanical-safe` steps, one at a time, validated.** Match the step's
|
|
42
|
+
`remediationKind` (table above) — do not expand the edit into a broader refactor:
|
|
33
43
|
- Record the current active-violation count from the plan.
|
|
34
44
|
- Make the edit at the SOURCE (fix the placement; don't add an `ark-*-disable` or edit the
|
|
35
45
|
baseline/config to hide it).
|
|
@@ -18,6 +18,26 @@ npx arkgate-check --install-agent-gates --force
|
|
|
18
18
|
|
|
19
19
|
Guide: `docs/migrate-from-ark-runtime-kernel.md` in the package (or on GitHub).
|
|
20
20
|
|
|
21
|
+
**TypeScript 7 projects:** ArkGate falls back to a nested JS-API TypeScript when the
|
|
22
|
+
project's `typescript` main export is version-only (TS 7.0). After upgrade, point users at
|
|
23
|
+
`docs/typescript-support.md` if the gate or `ARK_DEBUG_TS=1` mentions fallback. Dual install
|
|
24
|
+
(TS6 JS API + TS7 CLI) is optional for tooling that still needs classic `tsc` APIs.
|
|
25
|
+
|
|
26
|
+
**MCP double-bin check (identity cutover):** after upgrade, open `.mcp.json` and
|
|
27
|
+
`.cursor/mcp.json`. `args` must contain **exactly one** of `arkgate-mcp` / `ark-mcp`
|
|
28
|
+
(prefer `arkgate-mcp`), never both. If both appear, run:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
npx arkgate-check --install-agent-gates --migrate-commands
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`ark upgrade` already runs migrate-commands; re-run it if an older 2.x left dual names.
|
|
35
|
+
|
|
36
|
+
**Adoption completeness:** run `npx arkgate-check --doctor` (or `--doctor --json`) and
|
|
37
|
+
read the **Adoption** section — host gaps, Codex home temp paths, optional-but-populated
|
|
38
|
+
core layers, missing origin snapshot, baseline policy. Fix commands are printed per gap.
|
|
39
|
+
HTML reports include the same Adoption card (separate from the 0–100 fitness score).
|
|
40
|
+
|
|
21
41
|
## Fast path
|
|
22
42
|
|
|
23
43
|
One command does the whole flow — update the package, refresh gates + `/ark-*` skills
|
|
@@ -30,7 +50,12 @@ arkgate upgrade
|
|
|
30
50
|
|
|
31
51
|
Use it when the user just wants the update done. Run the detailed steps below instead when
|
|
32
52
|
you need to inspect the changelog first, handle a pnpm cooling-off window, or the one-liner
|
|
33
|
-
reports a problem to triage.
|
|
53
|
+
reports a problem to triage. Always refresh skills so agents pick up new `mechanical-safe`
|
|
54
|
+
kinds and TS guidance:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
npx arkgate-check --install-agent-gates --skills-only --force
|
|
58
|
+
```
|
|
34
59
|
|
|
35
60
|
## Steps
|
|
36
61
|
|