arkgate 4.2.1 → 4.3.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 (44) hide show
  1. package/CHANGELOG.md +59 -3
  2. package/README.md +19 -6
  3. package/bin/ark-mcp-runtime.mjs +64 -0
  4. package/bin/ark.mjs +55 -1
  5. package/bin/lib/adapter-contract.mjs +88 -5
  6. package/bin/lib/agent-projection-command.mjs +396 -0
  7. package/bin/lib/agent-projection.mjs +319 -0
  8. package/bin/lib/agent-skills-package.mjs +266 -0
  9. package/bin/lib/baseline-key.mjs +32 -0
  10. package/bin/lib/ci-and-commands.mjs +44 -0
  11. package/bin/lib/diagnostic-catalog.mjs +155 -0
  12. package/bin/lib/status-command.mjs +369 -0
  13. package/bin/lib/status-manifest.mjs +394 -0
  14. package/dist/eslint/index.cjs +3 -3
  15. package/dist/eslint/index.js +3 -3
  16. package/dist/index.cjs +46 -11
  17. package/dist/index.d.ts +729 -6
  18. package/dist/index.js +46 -11
  19. package/docs/README.md +6 -6
  20. package/docs/agent-guide.md +112 -14
  21. package/docs/configuration.md +7 -0
  22. package/docs/develop.md +8 -0
  23. package/docs/diagnostics.md +606 -0
  24. package/docs/package-surface.md +18 -8
  25. package/docs/product-voice.md +45 -0
  26. package/docs/use.md +23 -0
  27. package/package.json +7 -1
  28. package/schemas/ark.analysis-result.schema.json +14 -1
  29. package/schemas/ark.status-manifest.schema.json +244 -0
  30. package/server.json +2 -2
  31. package/templates/agent-skills/README.md +59 -0
  32. package/templates/agent-skills/ark-adopt/SKILL.md +171 -0
  33. package/templates/agent-skills/ark-architect/SKILL.md +175 -0
  34. package/templates/agent-skills/ark-autopilot/SKILL.md +242 -0
  35. package/templates/agent-skills/ark-contract/SKILL.md +136 -0
  36. package/templates/agent-skills/ark-coverage/SKILL.md +167 -0
  37. package/templates/agent-skills/ark-explain/SKILL.md +210 -0
  38. package/templates/agent-skills/ark-explore/SKILL.md +377 -0
  39. package/templates/agent-skills/ark-fix/SKILL.md +185 -0
  40. package/templates/agent-skills/ark-loop/SKILL.md +180 -0
  41. package/templates/agent-skills/ark-place/SKILL.md +162 -0
  42. package/templates/agent-skills/ark-runtime/SKILL.md +120 -0
  43. package/templates/agent-skills/ark-think/SKILL.md +133 -0
  44. package/templates/agent-skills/ark-upgrade/SKILL.md +218 -0
package/docs/README.md CHANGED
@@ -29,7 +29,8 @@ Product site: [arkgate.online](https://www.arkgate.online/) · npm: [`arkgate`](
29
29
  |-----|------------|
30
30
  | [develop.md](develop.md) | Gates, hosts, config, brownfield, power tools |
31
31
  | [ai-gates.md](ai-gates.md) | Install hooks / MCP / CI per host |
32
- | [agent-guide.md](agent-guide.md) | Agent, CLI, and MCP reference |
32
+ | [agent-guide.md](agent-guide.md) | Agent, CLI, and MCP reference (incl. `ark status --json` / MCP `ark_status`) |
33
+ | [diagnostics.md](diagnostics.md) | Public diagnostic `ruleId` catalog (why / fix anchors) |
33
34
  | [configuration.md](configuration.md) | `ark.config.json` contract |
34
35
  | [brownfield-adoption.md](brownfield-adoption.md) | Existing messy repos |
35
36
  | [package-surface.md](package-surface.md) | Stable vs experimental package surface |
@@ -52,15 +53,14 @@ These are **not** the day-to-day product path. They stay in the repo for evidenc
52
53
  | Area | Path |
53
54
  |------|------|
54
55
  | Release notes (by version) | [releases/](releases/) · [CHANGELOG.md](../CHANGELOG.md) |
55
- | Epic plans (seeded + shipped) | [plans/](plans/) · latest shipped: [workspace identity and activation truth](plans/workspace-identity-activation-truth/README.md) (Phase WI; **4.2.0 published**) |
56
+ | Epic plans (seeded + shipped) | [plans/](plans/) · [agent contract surface 4.3](plans/agent-contract-surface-4.3/README.md) (Phase ACS → **4.3.0 prepared**; product voice: [guardrail catalog + scan/process](product-voice.md#scan-vs-process-dual-depth)); prior: [workspace identity](plans/workspace-identity-activation-truth/README.md) (WI / **4.2.0**; npm **4.2.1**) |
56
57
  | Claims audit | [audit/claims-matrix.md](audit/claims-matrix.md) |
57
58
  | Field adoption kit (scaffolding, not closed) | [field/](field/) |
58
59
  | Runtime hardening (experimental) | [production-hardening.md](production-hardening.md) |
59
60
 
60
- Prepared candidate: [releases/4.2.1.md](releases/4.2.1.md) (`arkgate@4.2.1`, not published).
61
-
62
- Current published: [releases/4.2.0.md](releases/4.2.0.md) (`arkgate@4.2.0` on npm `latest`).
63
- Previous: [releases/4.1.1.md](releases/4.1.1.md) (`arkgate@4.1.1`) · [releases/4.1.0.md](releases/4.1.0.md) (`arkgate@4.1.0`).
61
+ Prepared candidate: [releases/4.3.0.md](releases/4.3.0.md) (`arkgate@4.3.0`, not published yet).
62
+ Current published: [releases/4.2.1.md](releases/4.2.1.md) (`arkgate@4.2.1` on npm `latest`).
63
+ Previous: [releases/4.2.0.md](releases/4.2.0.md) (`arkgate@4.2.0`) · [releases/4.1.1.md](releases/4.1.1.md) (`arkgate@4.1.1`).
64
64
  Previous major: [releases/4.0.0.md](releases/4.0.0.md) (`arkgate@4.0.0`).
65
65
  Config: [configuration.md](configuration.md) · Agent skills dual-plane: [agent-guide.md](agent-guide.md).
66
66
 
@@ -38,13 +38,19 @@ feature work. Full `/ark-*` skills are **expert depth** and label residual **`[L
38
38
  npx ark-check --install-agent-gates --skills-only --force
39
39
  ```
40
40
 
41
- **Write-path honesty:** Claude/Grok/Antigravity can hard-block listed PreToolUse ops when
42
- installed and trusted. Cursor/Codex/OpenCode remain **advisory at write**. For every host, the
43
- repository-wide hard boundary is a **required GitHub status context** that runs
44
- `arkgate-check --strict-merge` (alias `ark-check --strict-merge`) the CLI name is not the
45
- status context name. Never claim Cursor/Codex/OpenCode hard write. Soft-write alone does not mean
46
- the project is unfinished; doctor keeps it as an environment residual. See [ai-gates.md](ai-gates.md)
47
- and the README host matrix.
41
+ ### Write-path honesty
42
+
43
+ Claude/Grok/Antigravity can hard-block listed PreToolUse ops when installed and trusted.
44
+ Cursor/Codex/OpenCode remain **advisory at write**. For every host, the repository-wide hard
45
+ boundary is a **required GitHub status context** that runs `arkgate-check --strict-merge` (alias
46
+ `ark-check --strict-merge`) the CLI name is not the status context name. Never claim
47
+ Cursor/Codex/OpenCode hard write. Soft-write alone does not mean the project is unfinished; doctor
48
+ keeps it as an environment residual. See [ai-gates.md](ai-gates.md) and the README host matrix.
49
+
50
+ Surface the same plane from the CLI: pair **`ark status --json`** (activation facts) with
51
+ **`ark-check --doctor`** (`doctor.writePath`) — advisory local write on soft hosts → **required**
52
+ merge status as the hard boundary. Product path: [use.md — What you get](use.md#what-you-get) ·
53
+ [README host matrix](../README.md#host-enforcement-support).
48
54
 
49
55
  **MCP project identity (4.2.0):** before trusting project-specific MCP evidence, call
50
56
  `ark_identity` with `project.expectedRoot` set to the exact project's absolute root. Reuse that
@@ -53,6 +59,56 @@ path is authoritative only when that matching project id is also supplied. Only
53
59
  `binding.status: "matched"` with `authoritative: true` is authoritative; calls that omit the
54
60
  expectation remain compatible but are explicitly `unverified`.
55
61
 
62
+ ### Unified status snapshot (4.3 / ACS03)
63
+
64
+ For one machine-readable session/project manifest (identity binding, honest write-path activation,
65
+ last-check summary, rules residual counts, primary next action) use:
66
+
67
+ ```bash
68
+ npx ark status --json
69
+ # optional identity check (matched vs stale):
70
+ npx ark status --json --expected-root /abs/project/root
71
+ ```
72
+
73
+ MCP parity tool: **`ark_status`** (same envelope; pass `project.expectedRoot` after `ark_identity`).
74
+ Schema: `arkgate/schema/status-manifest`. Never prompts; under `CI=1` JSON is forced. **Not a
75
+ score** — counts and verdicts only. Write-path interpretation of activation vs merge teeth is under
76
+ [Write-path honesty](#write-path-honesty).
77
+
78
+ **Stable finding refs (4.3 / ACS06):** every factory-emitted diagnostic on CLI JSON, MCP analysis
79
+ envelopes, and opt-in hook repair payloads (`ARK_REPAIR_JSON`) carries:
80
+
81
+ | Field | Meaning |
82
+ |-------|---------|
83
+ | `findingRef` | Compact multi-turn id (`fnv1a-` + 8 hex). Re-address the same finding without fuzzy text match. |
84
+ | `targetKey` | Baseline-compatible freeze identity (`ruleId\|file\|from\|to\|target`, with `#N` for duplicates). **Same plane as `--baseline`** — refs never orphan freezes. |
85
+ | `docsCodePath` | Package-relative catalog anchor (`docs/diagnostics.md#RULE_ID`). |
86
+
87
+ Line/message drift across agent turns does not change `findingRef` / `targetKey`. Schema:
88
+ `arkgate/schema/analysis-result` **`1.5`**. Multi-turn fixture:
89
+ `tests/fixtures/finding-refs/multi-turn-stability.json`.
90
+
91
+ **Version-matched agent projection (4.3 / ACS04):** install/upgrade embeds a managed AGENTS.md
92
+ block stamped with the installed `arkgate` version plus a compact contract summary (layers +
93
+ diagnostic short list). Regenerate after package upgrade without clobbering customized regions
94
+ outside the markers:
95
+
96
+ ```bash
97
+ npx ark agents-md # preview
98
+ npx ark agents-md --write # merge managed block only
99
+ npx ark agents-md --check # exit 1 on version/stamp drift
100
+ npx ark agents-md --stdout # print block only
101
+ ```
102
+
103
+ The projection is **non-authoritative**. Enforcement is `ark-check` / host write hooks / required
104
+ CI (`--strict-merge`) — never AGENTS.md, skills, or this projection. Root API:
105
+ `buildAgentProjectionBlock` / `mergeAgentProjectionDocument`.
106
+
107
+ **Agent Skills packaging (4.3 / ACS05):** the same frozen **13** skill names are also shipped as
108
+ an Agent Skills–compatible package under `templates/agent-skills/<name>/SKILL.md` for hosts that
109
+ install via `npx skills` (in addition to Ark `--install-agent-gates`). See
110
+ [Install skills — Ark and ecosystem](#install-skills-ark-and-ecosystem). No new skill names.
111
+
56
112
  ## Architecture playbook and `ark-check --recommend`
57
113
 
58
114
  Before generating project structure, agents should read the **tool-agnostic application
@@ -486,6 +542,40 @@ monotonic across ArkGate 4.2.0+ installers. Pre-4.2 binaries ignore its metadata
486
542
  upgrade legacy repos before they write the optional home catalog. See
487
543
  [AI gates — Codex skill catalog](ai-gates.md#codex-skill-catalog-skillmd-not-flat-prompts).
488
544
 
545
+ ### Install skills — Ark and ecosystem {#install-skills-ark-and-ecosystem}
546
+
547
+ The same **13** skill names ship two ways. **No new skill names** (4.3 freeze): packaging and
548
+ routing only.
549
+
550
+ | Channel | What it installs | When to use |
551
+ |---------|------------------|-------------|
552
+ | **Ark install** | Host skill catalogs + optional hooks/MCP/CI wiring via `--install-agent-gates` | Default for projects that want write-path gates and version-stamped managed catalogs |
553
+ | **Agent Skills ecosystem** (`npx skills`) | The Agent Skills layout only (`<name>/SKILL.md`) into host skill dirs | Hosts already on the open skills channel; discovery without running Ark install |
554
+
555
+ **Canonical authoring source:** flat `templates/skills/<name>.md` (Ark install reads these).
556
+
557
+ **Agent Skills package root** (generated, 1:1 content): `templates/agent-skills/<name>/SKILL.md`
558
+ — ships in the npm tarball under `templates/`. Drift guard: `npm run check:agent-skills`.
559
+
560
+ ```bash
561
+ # Ark — expert skill pack (preferred when you also want gates)
562
+ npx ark-check --install-agent-gates --skills-only --force
563
+
564
+ # Ecosystem — from installed package or a git checkout
565
+ npx skills add ./node_modules/arkgate/templates/agent-skills
566
+ npx skills add ./templates/agent-skills
567
+ # GitHub tree:
568
+ npx skills add https://github.com/pedroknigge/arkgate/tree/main/templates/agent-skills
569
+ # List without installing:
570
+ npx skills add ./node_modules/arkgate/templates/agent-skills --list
571
+ ```
572
+
573
+ Frozen names: `ark-adopt`, `ark-architect`, `ark-autopilot`, `ark-contract`, `ark-coverage`,
574
+ `ark-explain`, `ark-explore`, `ark-fix`, `ark-loop`, `ark-place`, `ark-runtime`, `ark-think`,
575
+ `ark-upgrade`. Root API: `ARK_SKILL_NAMES` / `validateAgentSkillsPackage` (Domain
576
+ `agentSkillsPackage`). Skills are **process** depth — they never decide pass/fail; enforcement
577
+ remains `ark-check` / hooks / CI.
578
+
489
579
  For an optional executable adoption check, copy the shipped template into a Vitest/Jest suite
490
580
  after installing ArkGate:
491
581
 
@@ -646,6 +736,11 @@ Relevant violation codes include `LAYER_IMPORT_VIOLATION`, `FORBIDDEN_GLOBAL`,
646
736
  `FORBIDDEN_SUBSTRING`, `FORBIDDEN_IMPORT`, `POLICY_VIOLATION`, `UNKNOWN_INTENT`,
647
737
  `LAYER_REFERENCE_VIOLATION`, `EXTENSION_ERROR`, and `AST_ANALYZER_ERROR`.
648
738
 
739
+ **Full catalog (ACS02):** every public `ruleId` with why/fix anchors lives in
740
+ [diagnostics.md](diagnostics.md) (stable fragment `#RULE_ID`) and the root API
741
+ `DIAGNOSTIC_CATALOG` / `getDiagnosticCatalogEntry` / `diagnosticDocsPath`. Agents must not
742
+ invent free-form rule ids outside that closed vocabulary.
743
+
649
744
  Use `ark-check` in CI for repository-level checks that need real file paths:
650
745
 
651
746
  ```bash
@@ -893,7 +988,7 @@ npx ark-mcp --root . --config ark.config.json [--manifest ark.manifest.json]
893
988
  this resource `unverified` and non-authoritative. It never substitutes for `ark_manifest` in
894
989
  a project verdict.
895
990
 
896
- The server exposes these twelve tools. Every tool accepts the additive
991
+ The server exposes these thirteen tools. Every tool accepts the additive
897
992
  `project: { expectedRoot, expectedProjectId? }` input:
898
993
 
899
994
  | Tool | Primary input and purpose |
@@ -910,6 +1005,7 @@ The server exposes these twelve tools. Every tool accepts the additive
910
1005
  | `ark_recommend` | No args: return the deterministic application-shape plan used by `ark-check --recommend --json`. |
911
1006
  | `ark_suggest_include` | No args: propose TypeScript/JavaScript include roots from workspaces and nested packages. |
912
1007
  | `ark_rules_inventory` | No args: inventory possible intra-layer rules using configured layer evidence when available; test/fixture/seed/migration surfaces and narrow technical constants are excluded from extraction pilots. Counts are not a score. |
1008
+ | `ark_status` | No non-project args: return the unified status-manifest envelope (identity binding, honest write-path activation, last-check summary, rules residual counts, primary next action). Same shape as `ark status --json`. Prefer after `ark_identity`. Never a score. |
913
1009
 
914
1010
  Every project-bound tool success, tool error, and JSON-RPC error data carries:
915
1011
 
@@ -957,13 +1053,15 @@ when the binding is matched, analysis is complete, the graph is valid, coverage
957
1053
  are active. The underlying CLI fields remain present for diagnosis, but are not an authoritative
958
1054
  whole-project green on their own.
959
1055
 
960
- Current diagnostic envelopes use schema `1.4` and require `mode`,
1056
+ Current diagnostic envelopes use schema `1.5` and require `mode`,
961
1057
  `completeness: "complete" | "partial" | "unavailable"`, and structured
962
- `completenessReasons`. Resolved results expose `policyHash`, `resolverIdentity`, `factsHash`, and
963
- `candidateTreeHash`; MCP `ark_check` mirrors CLI `ok`. Single-file `validate_code`,
964
- `ark_prepare_write`, and `createAICodeGate().validate()` are named lexical compatibility surfaces:
965
- they may expose `lexicalValid`, but remain partial and `valid:false` until complete-candidate
966
- preflight. Consumer-owned 1.0/1.1/1.2 `AdapterResult` values remain accepted by the public union.
1058
+ `completenessReasons`. Factory-emitted diagnostics carry stable `findingRef`, baseline-compatible
1059
+ `targetKey`, and `docsCodePath` (ACS06). Resolved results expose `policyHash`, `resolverIdentity`,
1060
+ `factsHash`, and `candidateTreeHash`; MCP `ark_check` mirrors CLI `ok`. Single-file
1061
+ `validate_code`, `ark_prepare_write`, and `createAICodeGate().validate()` are named lexical
1062
+ compatibility surfaces: they may expose `lexicalValid`, but remain partial and `valid:false` until
1063
+ complete-candidate preflight. Consumer-owned 1.0–1.4 `AdapterResult` values remain accepted by the
1064
+ public union (refs optional on those older envelopes).
967
1065
 
968
1066
  For hook-based enforcement, `ark-mcp --hook` runs one-shot: it reads a PreToolUse payload
969
1067
  from stdin, validates the post-edit file content, and exits `2` with violations on stderr
@@ -94,6 +94,13 @@ Layer fields:
94
94
  (`network`, `filesystem`, `clock`, `randomness`, `environment`, `process`, `persistence`);
95
95
  `pure: true` is the shorthand that denies all seven. Absence changes no verdict.
96
96
 
97
+ **Day-to-day maintenance:** new modules that land under an existing layer `patterns` glob need **no**
98
+ config edit. Edit `ark.config.json` when you add a layer, change who may import whom, cover an
99
+ ungoverned path under `include`, or adjust capabilities / forbidden globals. Optional ArkRules
100
+ `invariants[].appliesTo` globs only narrow *which files* a named invariant considers inside that
101
+ layer — they do not replace Layers placement. Empty `appliesTo: []` fails closed; zero-match globs
102
+ warn or fail by mode (`ARKRULE_SCOPE_EMPTY`). Product path: [use.md — New modules vs config edits](use.md#new-modules-vs-config-edits).
103
+
97
104
  `forbiddenGlobals: ["process"]` covers the ambient binding plus exact runtime imports from
98
105
  `process` and `node:process`. It does not imply the broader `process` capability wall: subpaths
99
106
  and `child_process` remain outside this narrow dual, and statement-level `import type` /
package/docs/develop.md CHANGED
@@ -68,6 +68,11 @@ can show `runtimeObserved: true` even when branch-protection policy is plan-unav
68
68
  | ArkRules (structure + invariants) | [configuration.md](configuration.md#arkrules-intra-layer-opt-in) · `arkRules` / `arkrules/*` · skill `/ark-contract` |
69
69
  | Rules inventory (brownfield) | `arkgate-check --rules-inventory` · MCP `ark_rules_inventory` |
70
70
  | Stable package API | [package-surface.md](package-surface.md) |
71
+ | Diagnostic codes (`ruleId` why/fix) | [diagnostics.md](diagnostics.md) · root `DIAGNOSTIC_CATALOG` |
72
+ | Session / project status snapshot | `ark status --json` · MCP `ark_status` · [agent-guide](agent-guide.md) · schema `arkgate/schema/status-manifest` |
73
+ | Version-matched AGENTS projection | `ark agents-md` · [agent-guide](agent-guide.md) · **non-authoritative** (never enforces) |
74
+ | Stable finding refs (`findingRef` / `targetKey`) | analysis-result schema **1.5** · [agent-guide](agent-guide.md) · [package-surface](package-surface.md) |
75
+ | Agent Skills layout (same 13 names) | `templates/agent-skills/` · [agent-guide](agent-guide.md#install-skills-ark-and-ecosystem) · `npx skills add …` |
71
76
  | Where new code goes | MCP `ark_place` · skill `/ark-place` (respects layer **and** structure sensors) |
72
77
  | Preflight multi-file change | MCP `ark_prepare_change` · `ark preflight --changes …` |
73
78
  | Write snippet preflight | MCP `ark_prepare_write` |
@@ -117,6 +122,9 @@ npx arkgate-check --doctor --json
117
122
  npx arkgate-check --plan --json
118
123
  npx arkgate-check --coverage
119
124
  npx arkgate-check --baseline
125
+ npx arkgate status --json # ACS03 session/project snapshot (not a score)
126
+ npx arkgate agents-md # ACS04 preview managed AGENTS block
127
+ npx arkgate agents-md --write # embed/refresh projection markers
120
128
  npx arkgate preflight --changes changes.json --json
121
129
  npx arkgate upgrade --json # managed content preview
122
130
  npx arkgate upgrade --apply