arkgate 2.3.0 → 2.5.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 +64 -0
- package/README.md +28 -17
- package/SECURITY.md +9 -8
- package/bin/ark-check.mjs +599 -53
- package/bin/ark-shared.mjs +53 -0
- package/bin/ark.mjs +20 -5
- package/dist/eslint/index.cjs +258 -23
- package/dist/eslint/index.cjs.map +1 -1
- package/dist/eslint/index.d.cts +38 -1
- package/dist/eslint/index.d.ts +38 -1
- package/dist/eslint/index.js +240 -22
- package/dist/eslint/index.js.map +1 -1
- 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 +15 -8
- package/docs/ai-gates.md +26 -36
- 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 |
|
|
@@ -333,7 +338,7 @@ layers, unclassified included files, unmatched layer patterns, duplicate layers,
|
|
|
333
338
|
that reference unknown layers. These are advisory by default. Use `--strict-config` once a
|
|
334
339
|
project is ready to fail CI on coverage gaps.
|
|
335
340
|
|
|
336
|
-
Use the optional ESLint plugin for fast local feedback:
|
|
341
|
+
Use the optional ESLint plugin for fast local feedback aligned with CI:
|
|
337
342
|
|
|
338
343
|
```js
|
|
339
344
|
import ark from 'arkgate/eslint';
|
|
@@ -343,8 +348,9 @@ export default [
|
|
|
343
348
|
];
|
|
344
349
|
```
|
|
345
350
|
|
|
346
|
-
Rules: `ark/no-domain-infra-imports
|
|
347
|
-
`ark/
|
|
351
|
+
Rules: `ark/no-domain-infra-imports` (layer edges from `ark.config.json`, same semantics as
|
|
352
|
+
`arkgate-check`), `ark/no-forbidden-globals` (per-layer `forbiddenGlobals`),
|
|
353
|
+
`ark/no-raw-event-publish`, and `ark/require-publish-source`. See [ai-gates.md](ai-gates.md).
|
|
348
354
|
|
|
349
355
|
## Runtime Observability
|
|
350
356
|
|
|
@@ -424,7 +430,8 @@ not replace your web framework, HTTP clients, or job scheduler.
|
|
|
424
430
|
## Write-Path Gate (MCP)
|
|
425
431
|
|
|
426
432
|
The strongest place to constrain an AI agent is the moment it writes a file, not after.
|
|
427
|
-
`ark-mcp` exposes
|
|
433
|
+
`arkgate-mcp` / `ark-mcp` exposes ArkGate over MCP (JSON-RPC over stdio; gate host needs a
|
|
434
|
+
JS-API TypeScript — nested or project) so a host can gate
|
|
428
435
|
the write path:
|
|
429
436
|
|
|
430
437
|
```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,
|
|
@@ -279,47 +283,33 @@ If your runtime can run a shell command before file writes and pass the tool pay
|
|
|
279
283
|
- Grok payloads also get `{ "decision": "deny", "reason": "…" }` on stdout when blocked
|
|
280
284
|
- plumbing problems (no stdin, non-source files, files outside `--root`) never block
|
|
281
285
|
|
|
282
|
-
## ESLint (editor feedback)
|
|
286
|
+
## ESLint (editor feedback) — same contract as CI
|
|
283
287
|
|
|
284
|
-
For in-editor red squiggles
|
|
285
|
-
|
|
288
|
+
For in-editor red squiggles that match **`arkgate-check`**, add the ESLint plugin.
|
|
289
|
+
Layer imports and purity globals are driven by **`ark.config.json`** (walk-up from the
|
|
290
|
+
linted file): same layer globs, specificity, `exclude`, and `rules[]` edges as the CI gate.
|
|
286
291
|
|
|
287
292
|
```js
|
|
288
293
|
// eslint.config.js (flat config)
|
|
289
294
|
import ark from 'arkgate/eslint';
|
|
290
295
|
|
|
291
296
|
export default [
|
|
292
|
-
ark.configs.recommended,
|
|
297
|
+
ark.configs.recommended,
|
|
298
|
+
// no-domain-infra-imports → config-driven layer edges (type-only + value)
|
|
299
|
+
// no-forbidden-globals → layer.forbiddenGlobals from ark.config.json
|
|
300
|
+
// no-raw-event-publish + require-publish-source → runtime event hygiene
|
|
293
301
|
];
|
|
294
302
|
```
|
|
295
303
|
|
|
296
|
-
|
|
297
|
-
`fetch`, `Date.now`, `Math.random`, …). That rule is only correct when scoped to your
|
|
298
|
-
domain directories — a global block would flag legitimate infrastructure code. Add it
|
|
299
|
-
as its own block with a `files` glob matching your `DomainModel` layer:
|
|
300
|
-
|
|
301
|
-
```js
|
|
302
|
-
import ark from 'arkgate/eslint';
|
|
304
|
+
**Parity notes (2.5+):**
|
|
303
305
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
plugins: { ark },
|
|
309
|
-
rules: {
|
|
310
|
-
'ark/no-forbidden-globals': [
|
|
311
|
-
'error',
|
|
312
|
-
{ globals: ['fetch', 'process', 'Date.now', 'Math.random'] }, // match ark.config.json
|
|
313
|
-
],
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
];
|
|
317
|
-
```
|
|
306
|
+
- Relative imports are resolved to on-disk TS/JS targets; package bare imports are left to CI/TS.
|
|
307
|
+
- Type-only and value forbidden edges both error (same pass/fail as `arkgate-check`).
|
|
308
|
+
- `no-forbidden-globals` only applies when the file’s layer declares `forbiddenGlobals` (or you pass a `globals` option). Layers without a purity list are not inventively restricted.
|
|
309
|
+
- Without `ark.config.json`, `no-domain-infra-imports` falls back to a domain→infra path heuristic.
|
|
318
310
|
|
|
319
|
-
Rule ids are `ark/<kebab-name>`.
|
|
320
|
-
|
|
321
|
-
`ark-check` agree. All four rules are exported individually too (`ark.rules`) if you
|
|
322
|
-
prefer to wire them by hand.
|
|
311
|
+
Rule ids are `ark/<kebab-name>`. Individual rules are also on `ark.rules` if you wire them by hand.
|
|
312
|
+
Prefer keeping editor + CI on the same `ark.config.json` — do not maintain a parallel globals list unless you intentionally override.
|
|
323
313
|
|
|
324
314
|
## CI backstop
|
|
325
315
|
|
|
@@ -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.5.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.5.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "arkgate",
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.5.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`.
|