@codewithjuber/forgekit 0.8.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 (140) hide show
  1. package/.claude-plugin/marketplace.json +12 -0
  2. package/.claude-plugin/plugin.json +20 -0
  3. package/.codex-plugin/plugin.json +29 -0
  4. package/.mcp.json +8 -0
  5. package/ARCHITECTURE.md +314 -0
  6. package/CHANGELOG.md +467 -0
  7. package/LICENSE +21 -0
  8. package/ONBOARDING.md +180 -0
  9. package/README.md +286 -0
  10. package/bin/claude-init.sh +90 -0
  11. package/bin/claude-taste.sh +33 -0
  12. package/bin/learn-consolidate.sh +51 -0
  13. package/brand.json +15 -0
  14. package/global/CLAUDE.md +31 -0
  15. package/global/crew/frontend-verifier.md +36 -0
  16. package/global/crew/independent-reviewer.md +29 -0
  17. package/global/crew/scout.md +24 -0
  18. package/global/crew/verifier.md +28 -0
  19. package/global/guards/_guardlib.sh +36 -0
  20. package/global/guards/cortex.sh +14 -0
  21. package/global/guards/cost-budget.sh +41 -0
  22. package/global/guards/doom-loop.sh +25 -0
  23. package/global/guards/format-on-edit.sh +32 -0
  24. package/global/guards/lean-guard.sh +20 -0
  25. package/global/guards/protect-paths.sh +45 -0
  26. package/global/guards/recall-load.sh +22 -0
  27. package/global/guards/secret-redact.sh +18 -0
  28. package/global/guards/session-learner.sh +72 -0
  29. package/global/recall/MEMORY.md +7 -0
  30. package/global/rules/self-correction.md +17 -0
  31. package/global/rules/stack-notes.md +24 -0
  32. package/global/rules/tech-currency.md +19 -0
  33. package/global/settings.template.json +183 -0
  34. package/global/statusline.sh +51 -0
  35. package/global/taste/brutalist.json +9 -0
  36. package/global/taste/brutalist.md +19 -0
  37. package/global/taste/corporate.json +9 -0
  38. package/global/taste/corporate.md +19 -0
  39. package/global/taste/editorial.json +9 -0
  40. package/global/taste/editorial.md +19 -0
  41. package/global/taste/minimalist.json +9 -0
  42. package/global/taste/minimalist.md +20 -0
  43. package/global/taste/playful.json +9 -0
  44. package/global/taste/playful.md +19 -0
  45. package/global/tools/atlas/SKILL.md +27 -0
  46. package/global/tools/code-modernization/SKILL.md +275 -0
  47. package/global/tools/code-modernization/references/cost-impact-preflight.md +54 -0
  48. package/global/tools/code-modernization/references/design-patterns-cheatsheet.md +24 -0
  49. package/global/tools/code-modernization/references/research-protocol.md +42 -0
  50. package/global/tools/code-modernization/scripts/preflight_scan.py +190 -0
  51. package/global/tools/cognitive-substrate/SKILL.md +56 -0
  52. package/global/tools/cognitive-substrate/references/capability-map.md +17 -0
  53. package/global/tools/cost-guard/SKILL.md +50 -0
  54. package/global/tools/design-md/SKILL.md +54 -0
  55. package/global/tools/dev-radar/SKILL.md +56 -0
  56. package/global/tools/explore-plan-code/SKILL.md +24 -0
  57. package/global/tools/lean/SKILL.md +41 -0
  58. package/global/tools/recall/SKILL.md +31 -0
  59. package/global/tools/reuse-first/SKILL.md +64 -0
  60. package/global/tools/self-improve/SKILL.md +44 -0
  61. package/global/tools/taste/SKILL.md +26 -0
  62. package/global/tools/tech-selector/SKILL.md +35 -0
  63. package/global/tools/ui-workflow/SKILL.md +44 -0
  64. package/hooks/hooks.json +107 -0
  65. package/install.sh +88 -0
  66. package/package.json +93 -0
  67. package/public/index.html +45 -0
  68. package/scripts/build-pages.mjs +180 -0
  69. package/scripts/bump.mjs +322 -0
  70. package/skills/cognitive-substrate/SKILL.md +56 -0
  71. package/skills/cognitive-substrate/references/capability-map.md +17 -0
  72. package/source/mcp.json +10 -0
  73. package/source/rules.json +106 -0
  74. package/source/substrate.json +41 -0
  75. package/src/adjudicate.js +84 -0
  76. package/src/anchor.js +210 -0
  77. package/src/atlas.js +487 -0
  78. package/src/brain.js +84 -0
  79. package/src/brand.js +25 -0
  80. package/src/cli.js +1509 -0
  81. package/src/context.js +273 -0
  82. package/src/cortex.js +251 -0
  83. package/src/cortex_distill.js +55 -0
  84. package/src/cortex_features.js +81 -0
  85. package/src/cortex_hook.js +197 -0
  86. package/src/cortex_hook_main.js +139 -0
  87. package/src/cortex_mcp.js +352 -0
  88. package/src/cost_report.js +271 -0
  89. package/src/dash.html +396 -0
  90. package/src/dash.js +220 -0
  91. package/src/diagnose.js +0 -0
  92. package/src/doctor.js +315 -0
  93. package/src/embed.js +244 -0
  94. package/src/emit/_shared.js +39 -0
  95. package/src/emit/aider.js +22 -0
  96. package/src/emit/claude.js +44 -0
  97. package/src/emit/codex.js +17 -0
  98. package/src/emit/continue.js +28 -0
  99. package/src/emit/copilot.js +12 -0
  100. package/src/emit/cursor.js +23 -0
  101. package/src/emit/gemini.js +40 -0
  102. package/src/emit/mcp.js +94 -0
  103. package/src/emit/windsurf.js +22 -0
  104. package/src/emit/zed.js +34 -0
  105. package/src/eval.js +47 -0
  106. package/src/extract.js +82 -0
  107. package/src/harden.js +44 -0
  108. package/src/imagine.js +301 -0
  109. package/src/init.js +178 -0
  110. package/src/lean.js +149 -0
  111. package/src/ledger.js +475 -0
  112. package/src/ledger_bridge.js +279 -0
  113. package/src/ledger_read.js +152 -0
  114. package/src/ledger_store.js +360 -0
  115. package/src/lessons.js +185 -0
  116. package/src/lessons_store.js +137 -0
  117. package/src/metrics.js +54 -0
  118. package/src/model_tiers.js +17 -0
  119. package/src/model_tiers.json +39 -0
  120. package/src/predictor.js +143 -0
  121. package/src/preflight.js +410 -0
  122. package/src/providers.js +320 -0
  123. package/src/recall.js +103 -0
  124. package/src/reuse.js +0 -0
  125. package/src/route.js +323 -0
  126. package/src/scope.js +122 -0
  127. package/src/skillgate.js +89 -0
  128. package/src/speclock.js +64 -0
  129. package/src/substrate.js +492 -0
  130. package/src/sync.js +132 -0
  131. package/src/taste.js +55 -0
  132. package/src/uicheck.js +96 -0
  133. package/src/uifingerprint.js +861 -0
  134. package/src/uivisual.js +334 -0
  135. package/src/util.js +71 -0
  136. package/src/verify.js +117 -0
  137. package/templates/project-layer/.claude/settings.json +22 -0
  138. package/templates/project-layer/.claude/skills/hostlelo-deploy/SKILL.md +38 -0
  139. package/templates/project-layer/AGENTS.md +28 -0
  140. package/templates/project-layer/CLAUDE.md +40 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,467 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format is based on
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres
5
+ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.8.0] - 2026-07-08
10
+
11
+
12
+
13
+ ## [0.7.0] - 2026-07-08
14
+
15
+ ### Added
16
+
17
+ - **Optional embeddings tier** (`src/embed.js`, ADR-0005; ROADMAP "Next"): set
18
+ `FORGE_EMBED=cmd:<command>` (stdin/stdout JSON protocol — any local model or script)
19
+ or `FORGE_EMBED=http:<url>` (OpenAI-compatible, `$FORGE_EMBED_MODEL` /
20
+ `$FORGE_EMBED_KEY`, key never logged) and `forge reuse query` + `forge ledger query`
21
+ replace the MinHash `rel` term with embedding cosine (near/adapt ≥ 0.85/0.7 — a
22
+ higher bar than Jaccard's 0.8/0.6 to match dense cosine's noise floor), fixing the
23
+ documented weak spot on very short specs. Vectors are disk-cached
24
+ (`.forge/embed-cache.jsonl`, content-hash keyed, corrupt-tolerant, truncate-oldest);
25
+ both commands print the backend that served (`sim: minhash` / `sim: embed(cmd)`);
26
+ any provider failure degrades silently to MinHash. `dependencies` stays empty —
27
+ the tier is configuration, not a package; the pure ledger core never imports it.
28
+ - **`forge uicheck visual <file-or-url>`** — the Playwright visual loop
29
+ (07-ui-quality-gate §5): renders the page headless at two viewports, fingerprints
30
+ the **computed** styles of every visible element (what the cascade and runtime
31
+ theming actually painted, with used `auto`-margins and never-painted UA noise
32
+ filtered out), and runs the identical `design` gate over that rendered vector —
33
+ screenshots land in `.forge/ui/`. Playwright stays an optional tier (ADR-0005):
34
+ `package.json` gains no dependency, absence degrades to a "skipped (no browser
35
+ runtime)" note with exit 0 (`npm i -D playwright-core` or `FORGE_PLAYWRIGHT=…` to
36
+ enable), and non-loopback http(s) targets are refused by default (`--remote` to
37
+ override) — a gate that fetches arbitrary URLs is an exfiltration hazard.
38
+
39
+ ### Changed
40
+
41
+ - **Ledger read-path flip (P2).** Reads are now a merged view (legacy ∪ ledger) via the
42
+ new `src/ledger_read.js`, so teammate knowledge that arrives with `forge ledger merge`
43
+ actually reaches injection and retrieval: cortex lesson surfaces
44
+ (`lessonsForContext`, `startupBlock`, `summary`, the substrate advisory and routing
45
+ past-mistake density) map ledger `lesson` claims onto the legacy lesson shape with an
46
+ evidence-derived status (tombstoned → retired, val ≥ 0.6 → active, val < 0.45 with a
47
+ contradiction → quarantined, else candidate), and fact surfaces (`recall list`/
48
+ `MEMORY.md`, brain's `AGENTS.md` index) include live ledger `fact` claims — always
49
+ deduped by legacy id/slug with the local file winning, and best-effort (a missing or
50
+ corrupt ledger degrades to legacy-only). Write paths (`recordMistake`'s
51
+ confirm-vs-create lookup, `recordContradiction`, `applyDistillation`) deliberately
52
+ keep reading the legacy store they edit; convergence comes from content-addressed
53
+ claim ids. `reconcileFacts` now only tombstones locally-authored claims, so a merged
54
+ teammate fact survives `forge recall consolidate`. Legacy formats are still written —
55
+ full retirement is the next step.
56
+ - **Professional redesign of the public site, gated by forge's own UI system.** The
57
+ landing page (`landing/index.html`) and the generated status page
58
+ (`scripts/build-pages.mjs` → `public/index.html`) are rebuilt on one design system —
59
+ the `forge dash` eight-color warm-ink/ember palette, a strict 4px spacing base, three
60
+ radius levels, one shadow — and both now pass `forge uicheck design` **and** the
61
+ rendered `forge uicheck visual` gate (the old pages failed with 15–19 accumulated
62
+ colors and 5–9 radius levels; a project fingerprint claim is minted so conformance is
63
+ checked too). Scroll-reveal is JS-gated progressive enhancement (no-JS UAs, crawlers,
64
+ and reduced-motion users see the full page), and the Pages workflow (`static.yml`) now
65
+ builds and deploys an assembled `_site/` — landing at the site root, status page at
66
+ `/status/` — instead of uploading the entire repository as the artifact.
67
+
68
+ ## [0.6.0] - 2026-07-07
69
+
70
+ ### Changed
71
+
72
+ - Docs consolidation pass: deduplicated cross-doc prose into single canonical homes
73
+ (the substrate README now points at the GUIDE's command reference, output table, and
74
+ honest-limits list instead of repeating them), added orientation diagrams
75
+ (ARCHITECTURE four-layer compiler + ledger, substrate-v2 phase graph with all phases
76
+ marked shipped, the GUIDE daily loop), brought the ROADMAP current, and refreshed the
77
+ model-facing skills/crew guidance for the v0.5.0 surface (`forge context`,
78
+ `forge imagine --run`, `forge diagnose`, `forge ledger blame`, `forge cost --stages`,
79
+ `forge uicheck design --taste`) without growing the skills' context payload.
80
+
81
+ ## [0.5.0] - 2026-07-07
82
+
83
+ ### Added
84
+
85
+ - Security & OSS hardening: CodeQL, gitleaks secret-scan (blocking; verified clean on the
86
+ full history), and OSSF Scorecard workflows; refreshed repo topics; SECURITY.md now
87
+ states the supported line (0.5.x) and documents the ledger's forgery-resistance
88
+ properties (content-hash verification; oracle weights never trusted from records).
89
+ - **UI fingerprints resolve CSS `var()` indirection**, so design systems declared as
90
+ custom properties fingerprint fully (the dashboard now reads as a 6-value 4px scale
91
+ with two radius levels instead of one lonely spacing value), and the five taste
92
+ profiles gain machine-readable constraint JSONs (`global/taste/<name>.json`) wired
93
+ into `forge uicheck design --taste <name>` — with auto-pickup from a
94
+ `forge taste`-managed DESIGN.md. Prose steers generation; the JSON is what the gate
95
+ checks.
96
+ - **One-click release automation.** `scripts/bump.mjs` (node stdlib only, unit-tested)
97
+ bumps every version field in one shot — `package.json`, `package-lock.json`, both
98
+ plugin manifests, `CITATION.cff`, the landing page — rotates the CHANGELOG
99
+ `[Unreleased]` section under a dated heading, and prints the new version;
100
+ `npm run bump -- <patch|minor|major|auto>` (auto = conventional commits since the last
101
+ tag: BREAKING → major, feat → minor, else patch). The new `bump.yml` workflow makes a
102
+ release one click from the Actions tab (commit + tag + dispatch of `release.yml`);
103
+ `release.yml` now soft-skips npm publish when `NPM_TOKEN` is missing instead of
104
+ failing, and CI gained a version-drift guard (`node scripts/bump.mjs check`).
105
+ - **Benchmark harness (`npm run bench`) + measured results doc.** `bench/bench.mjs`
106
+ (node stdlib only) measures the substrate primitives as medians of N runs after
107
+ warmup — atlas build/incremental/impact latency on this repo, ledger
108
+ mint+put/loadClaims/mergeDirs/val() on seeded synthetic fixtures, reuse fingerprint +
109
+ exact/near-LSH lookup at 100 and 1000 artifacts, `assemble()` and full
110
+ `substrateCheck` wall time — and writes the tables plus an environment block into
111
+ `reports/benchmarks.md`. The same run scores `impact()` precision/recall/F1 against a
112
+ committed, hand-labeled case set from this repo's real import graph
113
+ (`bench/impact_cases.mjs`, every reference cited; one known-miss alias case kept in on
114
+ purpose), reported next to — never blended with — the paper prototype's
115
+ mutation-derived numbers, plus a structural-only contrast with adjacent tools (note
116
+ stores, LLM gateways, plain RAG), every row checkable from the named source.
117
+ - **Loop closure (P5 of the substrate-v2 plan): doom-loop diagnosis, imagination, CUSUM
118
+ drift, checkpoint cadence.** `forge diagnose "<error>"` hashes each failure into a
119
+ signature (line numbers, addresses, timestamps, and absolute paths normalized out) and
120
+ counts recurrences in a 50-entry ring; the 3rd identical hit is thrash — it mints a
121
+ content-addressed `diagnosis` claim into the team ledger and tells the agent to STOP
122
+ retrying and escalate ONE model tier with the diagnosis as the prompt's head (the same
123
+ loop becomes a one-per-team event, not one-per-session). `forge imagine "<task>"` is the
124
+ static half of the consequence simulator (paper Eq. 4): entities → blast radius →
125
+ predicted breaks with confidence, plus the minimal dry-run test suite via weighted greedy
126
+ set cover (weight = file size as a duration proxy; classic ln-n approximation) and
127
+ `riskScore = Σ confidence`. **`forge imagine --run` executes that minimal suite in a
128
+ sandboxed ephemeral git worktree** (HEAD-only — refused on a dirty tree unless
129
+ `--allow-dirty`), parses the TAP summary into per-file verdicts, always removes the
130
+ worktree (verified in a finally), and meters the run (`stage: "imagine"`); on this repo
131
+ the 8-test selected suite measured 1.3 s where the full suite takes ~60 s.
132
+ `anchor.cusum()` adds the M4 one-sided CUSUM control chart (k = 0.35,
133
+ h = 1.0): sustained small drift alarms, a single exploratory spike drains back to zero.
134
+ `verify.checkpointCadence()` prices M6's "when to check?" as the optimal-stopping
135
+ threshold rule `n* = ⌈checkCost / (pErr·tokensPerStep·costPerToken)⌉`, clamped to
136
+ [1, 50] — every input measured or priced, no magic constants.
137
+
138
+ - **Context assembly + completeness gate (P4 of the substrate-v2 plan).** `forge context
139
+ "<task>"` makes what goes into the window a budgeted optimization and makes
140
+ *sufficiency* a computed set. The required-knowledge set `R(edit)` — the target's
141
+ definitions, its hop-1 dependents from the atlas, sibling tests, and team lessons
142
+ trusted past val ≥ 0.8 — is derived, then covered by pinned items with a **compression
143
+ ladder** (full → head → pointer): a tight budget downgrades granularity instead of
144
+ silently dropping coverage. Optional items (trusted facts) fill remaining budget
145
+ greedily with per-source diminishing returns. `missing = R \ covered` becomes derived
146
+ clarifying questions ("the task names `X` but the repo doesn't define it — which file
147
+ implements it?"), shown in `forge substrate` and — under `FORGE_ENFORCE=1` — blocking:
148
+ acting on missing context is acting on a guess. Incomplete context stops being a
149
+ feeling and starts being a set difference.
150
+ - **Generated-UI quality gate (P6 of the substrate-v2 plan).** Taste becomes measurable:
151
+ `src/uifingerprint.js` extracts a deterministic design fingerprint from CSS/JSX/Tailwind
152
+ classes — pure static parsing, no LLM, no screenshots — covering palette (HSL + 12-bin hue
153
+ histogram), spacing (base unit by residual-minimization approximate GCD, on-scale
154
+ fraction), font families, radius and shadow levels. Two distances gate generated UI:
155
+ `slopDistance` to a shipped, rationale-documented generic-template signature set
156
+ (default-Tailwind blue/indigo, stock Bootstrap, the AI-landing gradient) must stay HIGH,
157
+ and `conformance` to the project's own fingerprint — stored as a shared `fingerprint`
158
+ ledger claim via `mintProjectFingerprint` — must stay LOW; `uiGate` failures are
159
+ actionable per-feature edits, never a bare score. Scale-conformance checks
160
+ (spacing-on-base, radius/shadow level caps, palette bound) join `ASSERTABLE_CHECKS`.
161
+ `forge uicheck` gains `fingerprint <file...> [--mint]` and `design <file...>` (exit 1 on
162
+ fail) alongside the unchanged contrast math.
163
+ - **Local dashboard (P7 of the substrate-v2 plan).** `forge dash [--port N]` serves a
164
+ read-only lens on the substrate's state: a `node:http` stdlib server (localhost-only,
165
+ zero runtime deps) with ONE self-contained HTML page — inline CSS/JS, no CDN, no
166
+ framework, no build step. Panels: Ledger (claims with val bars, kind filter, contested
167
+ claims — val ∈ [0.4, 0.6] with ≥1 contradiction — and per-author trust), Cost/Cache
168
+ (stage counters + measured saved-token estimates from `.forge/metrics.jsonl`), and
169
+ Impact (atlas blast-radius explorer via `/api/impact?target=X`). Every claim row shows
170
+ its `forge ledger blame <id>` command — no unexplained scores anywhere in the UI. Data
171
+ is separated from serving (`dashData()` vs `serve()` in `src/dash.js`) so the payload
172
+ is tested without sockets, and corrupt/missing stores degrade to empty sections instead
173
+ of taking down the lens. The ratify/retract POSTs are a follow-up; this phase never
174
+ writes.
175
+ - **Measured cost report (P8 of the substrate-v2 plan).** `forge cost --stages [--json]`
176
+ computes per-stage cost factors as pure arithmetic over `.forge/metrics.jsonl`
177
+ (`src/cost_report.js`): gate halt rate, tier-weighted cache hit rate (exact 1.0 / near
178
+ 0.85 / adapt 0.5), route saving priced against the always-premium baseline, and context
179
+ assembly — then composes `C = C₀ · Π(1 − fᵢ)` over ONLY the measured stages. A stage with
180
+ no events reports "no data", never a default; the composed figure is a lower bound whose
181
+ caveats name every unmeasured stage; the paper's 62 % routing figure is cited as context,
182
+ and ~90 % appears only as a labeled target. `substrateCheck` now meters the assumption
183
+ gate on the explicit path (one `gate` halt/pass line per decision; ambient hooks stay
184
+ write-free), `recordGate`/`recordRoute` give future stage wiring one obvious call each,
185
+ and `reports/cost-eval.md` scaffolds the paired-run harness report with a truthful
186
+ empty state.
187
+
188
+ - **Proof-carrying reuse cache (P3 of the substrate-v2 plan).** `forge reuse` turns
189
+ "reuse already-generated code" from prose into a deterministic system: verified code
190
+ becomes an `artifact` claim keyed by a normalized task fingerprint (volatile literals →
191
+ typed placeholders; MinHash sketch + 16×8 LSH banding for near-match), looked up through
192
+ the exact → near → adapt → miss ladder. An artifact serves ONLY while its proof holds —
193
+ confidence above the 0.6 floor (an unverified mint sits at the 0.5 prior and does not
194
+ serve) and every declared dependency still resolving in the atlas; a failed revalidation
195
+ appends a `graph.reval` contradiction, so stale code demotes itself for the whole team.
196
+ `forge reuse query|mint|stats`, a reuse stage in `forge substrate` (read-only on the
197
+ ambient hook path), and `src/metrics.js` — the stage-tagged `.forge/metrics.jsonl` the
198
+ cost model's measured savings are computed from. The `reuse-first` skill now calls the
199
+ cache before advising a repo search.
200
+
201
+ - **Team memory (P2 of the substrate-v2 plan).** The PCM ledger becomes shared:
202
+ `forge ledger merge <path>` performs the conflict-free semilattice merge of any other
203
+ ledger tree (a teammate's checkout, a worktree, a backup) — identical knowledge minted
204
+ independently converges to one claim with every author preserved in its provenance log.
205
+ `forge ledger blame <id>` is the accountability view (every mint, every oracle outcome,
206
+ every retraction, per-author trust). `forge ledger query "<text>"` ranks live claims by
207
+ the paper's Eq. 3. Every claim, evidence record, and tombstone now carries the git
208
+ identity (`FORGE_AUTHOR` override; cached; best-effort). **Per-author trust**
209
+ `u(author) ∈ [0.5, 1]` is computed from the oracle track record of the claims an author
210
+ minted — smoothed to 1.0 for new teammates, floored at 0.5, self-confirmation excluded —
211
+ and optionally weights `val()`. `forge doctor` now checks the union-merge driver is
212
+ present (a populated ledger without it WILL conflict) and the ledger's normal form.
213
+
214
+ ### Fixed
215
+
216
+ - **PCM ledger hardened after an 8-angle adversarial review of the P1 merge.** The
217
+ conflict-free-merge guarantee is now structural: claim file bytes are a pure function of
218
+ (kind, body, scope) — byte-identical on every replica — while provenance and tombstones
219
+ move into per-claim append-only logs (hash-deduped, union-merged like evidence), so
220
+ concurrent mints and concurrent retractions can never produce a git conflict or a
221
+ merge-order-dependent state. Forged evidence is now powerless AND detectable: `val()`
222
+ takes oracle weights from the ORACLES table (never the stored record) and skips unknown
223
+ oracles, while `forge ledger verify` recomputes every record's content hash and flags
224
+ mismatches, ghost oracles, and inflated weights. `forge ledger import` is truly
225
+ idempotent (claims already tracked live are never re-synthesized — no double counting).
226
+ Cortex shadow-writes: distillation now supersedes (evidence carried over, template claim
227
+ tombstoned); evidence refs carry the confirmation counter so same-day sessions with
228
+ colliding episode ids stay distinct; regex-detected reverts contradict at the
229
+ conservative bridge weight instead of the full-weight human oracle. Fact claims: one
230
+ CRLF-tolerant parser (`recall.readFact`), trimmed bodies (shadow path and import path
231
+ mint one id), same-name updates supersede the stale claim, and `forge recall
232
+ consolidate` reconciles deletions into tombstones. `putClaim` repairs corrupt/truncated
233
+ claim files instead of trusting `existsSync`. `forge ledger --personal` reaches the
234
+ personal ledger (previously write-only); `forge ledger show` resolves by shard instead
235
+ of scanning; `forge init` emits the union-merge `.gitattributes` rule into consumer
236
+ repos. `SCOPE_WEIGHT` has one home (ledger core; lessons re-exports).
237
+
238
+ ### Documentation
239
+
240
+ - **Substrate v2 plan: the whitepaper, completed (`docs/plans/substrate-v2/`).** Nine specs
241
+ + two ADRs mapping every remaining paper faculty/mechanism to a concrete algorithm, unified
242
+ by the **Proof-Carrying Memory (PCM) protocol**: every stored unit (lesson, fact, cached
243
+ artifact, graph edge, design fingerprint, diagnosis) becomes a content-addressed claim whose
244
+ confidence is a decayed Beta posterior over independent-oracle outcomes — retrieval implements
245
+ the paper's Eq. 3, team memory is a conflict-free CRDT ledger merged over git, code reuse is a
246
+ proof-carrying artifact cache, context assembly is a token-budget knapsack with a set-cover
247
+ completeness gate, and generated-UI quality is a measurable slop-distance/conformance gate.
248
+ ADR-0005 relaxes the zero-dependency rule to selective optional deps with stdlib fallbacks;
249
+ ADR-0006 converges all persistence on the PCM ledger. `ROADMAP.md` now carries the P1–P8
250
+ phase plan. Docs only — no runtime behavior changes.
251
+ - **Visual flow diagrams in the entry-point docs.** A "one source → every tool + pre-action gate"
252
+ mermaid in `README.md` and a "your day with Forge" loop in `ONBOARDING.md` (alongside the
253
+ propose→verify diagram in the substrate README) — making the model easier to grasp at a glance,
254
+ while preserving the docs' existing dry-precise voice.
255
+
256
+ ### Added
257
+
258
+ - **Proof-Carrying Memory ledger (P1 of the substrate-v2 plan).** `src/ledger.js` — the
259
+ pure PCM core (ADR-0006): content-addressed claims over canonical JSON, an oracle
260
+ taxonomy in which only independent signals (tests, CI, human accept/revert) may move
261
+ confidence, a time-decayed Beta-posterior `val` that decays toward *uncertainty* (never
262
+ toward false), the paper's Eq. 3 retrieval score, dependency-free MinHash similarity +
263
+ union-find consolidation clustering, and a join-semilattice merge (property-tested:
264
+ commutative, associative, idempotent — teammate ledgers converge in any order).
265
+ `src/ledger_store.js` — the git-native on-disk ledger (`.forge/ledger/`): one immutable
266
+ file per claim sharded by id, append-only hash-deduped evidence logs (union-merge safe,
267
+ see `.gitattributes`), tombstones, attic, `LEDGER.md` index, and a CI-friendly
268
+ normal-form `verify`. `forge ledger stats|verify|show|import` CLI. The legacy stores
269
+ stay the read path in P1: cortex shadow-writes every lesson event (create/confirm/
270
+ human-revert contradiction) into the ledger, `forge remember` / `forge recall add`
271
+ shadow facts, and `forge ledger import` back-fills history idempotently
272
+ (`src/ledger_bridge.js`). Secret-refusal now lives in the ledger core so no claim kind
273
+ can store a credential (re-exported from `recall.js` for compatibility).
274
+ - **Uniform `--json`.** `doctor`, `route`, `preflight`, `verify`, and `scope` now accept `--json`
275
+ (previously only `impact`/`substrate`/`anchor` did) — so CI and scripts can gate on the health
276
+ check, the routed tier, the assumption gap, and the verification result.
277
+ - **`forge doctor` sees more silent misconfiguration.** New checks: guard scripts present **and
278
+ executable**, `jq`/`git` availability (several guards degrade without `jq`), atlas
279
+ **presence + freshness** (a stale graph misleads impact/verify), and **model-pricing staleness**
280
+ (warns when the verified date is >90 days old).
281
+ - **Evaluation harness (`src/eval.js`).** The deterministic core of the prototype's mutation-testing
282
+ idea: score the impact oracle's precision/recall/F1 over labeled cases and against the
283
+ edited-file-only baseline the paper measured against — so the graph-quality claim is checkable in CI.
284
+
285
+ ### Changed
286
+
287
+ - **Model tiers carry a currency + a verified date.** `model_tiers.js` exports `PRICING_CURRENCY`
288
+ ("USD") and `PRICING_VERIFIED`, which `forge doctor` uses for the staleness warning.
289
+ - **One shared call-site extractor (`src/extract.js`).** `atlas.js` and `verify.js` each kept their
290
+ own copy of the call regex + builtins ignore-list; they now share one module so the two can't
291
+ drift apart.
292
+
293
+ - **Opt-in enforcing gate (`FORGE_ENFORCE=1`).** The substrate's assumption gate can now be a real
294
+ *halt* (the paper's Eq 5 / M2 "block on insufficient input"), not just advice. On the Claude Code
295
+ ambient path it blocks a prompt with **no concrete anchor at all** ("fix it", "make it better") —
296
+ or an action into a very large predicted blast radius — and returns the clarifying questions.
297
+ Deliberately low-false-positive: a specified task is never blocked, and it's **off by default**
298
+ (`enforceDecision()` in `src/substrate.js`).
299
+ - **M5 anti-over-engineering is now measured, not guessed (`forge lean`).** The paper's
300
+ `φ(y) − φ*(x)` check replaces the old three-keyword stub: `src/lean.js` reads the working diff
301
+ and flags the footprint beyond what the task asked for — new abstractions the task never named,
302
+ a large diff for a short ask, files touched beyond the stated scope. Folded into
303
+ `forge substrate` (a `minimality.footprint` field) and available standalone as `forge lean "<task>"`.
304
+ - **Doom-loop breaker (self-correction).** Complements the shell guard (which catches the *same
305
+ action* repeated) by catching the subtler loop the paper names — *different edits that keep
306
+ producing the same test failure*. `cortex_hook` now captures a normalized signature of failing
307
+ test output; `detectDoomLoop` fires when one signature recurs past a threshold, and the
308
+ pre-edit hook surfaces a "stop and find the root cause" advisory with the diagnosis.
309
+ - **Consequence simulation — failing-tests class (Eq 4).** `forge substrate` now predicts the
310
+ tests likely to break *before* an edit (`impact.predictedTests`): the impacted files that are
311
+ tests, plus each impacted source file's sibling test — surfaced so you run the narrowest
312
+ affected tests first, not after the fact.
313
+
314
+ ### Changed
315
+
316
+ - **`forge sync` now adopts an existing project `CLAUDE.md` instead of skipping it.** Previously a
317
+ repo with its own `CLAUDE.md` was left untouched — which meant Forge's shared rules never
318
+ reached Claude Code there. Sync now prepends the one-line `@AGENTS.md` import (idempotent,
319
+ every original line preserved) and reports `adopted`. `AGENTS.md` keeps its back-up-then-write
320
+ behaviour; your skills and other tool files are untouched.
321
+
322
+ ### Fixed
323
+
324
+ - **The Cortex capture/learn loop now works in the dotfile install too.** `global/settings.template.json`
325
+ wired only `cortex.sh preflight` (1 of 6 modes), so dotfile users got the substrate advisory but
326
+ **never captured events or distilled lessons** — the learning loop was dead for them while plugin
327
+ users had it. The template now wires all six modes (`session-start`, `prompt`, `preflight`,
328
+ `pre-edit`, `capture`, `stop`), matching `hooks/hooks.json`.
329
+ - **`forge verify` can't hang.** `runTests` now bounds the test run with a timeout
330
+ (`FORGE_VERIFY_TIMEOUT_MS`, default 10 min); a timeout is reported honestly as "did not complete",
331
+ never as a pass.
332
+ - **Secret-refusal no longer guts auth-related work.** `SECRET_RE` matched the bare words
333
+ `secret`/`password`/`api key`, so any task or lesson merely mentioning them was silently
334
+ refused — disabling the LLM proposer (`adjudicate`) and blocking memory persistence
335
+ (`recall`/`lessons`) for exactly the high-risk code you most want help on. The word arm now
336
+ requires a value-shaped assignment (`password = "…"`, `SECRET_KEY: …`); credential *formats*
337
+ (`sk-…`, `ghp_…`, JWTs, …) are still refused.
338
+ - **One malformed file no longer takes down memory.** `lessons_store.load`/`readEpisodes` and
339
+ `cortex_hook.readSession` now skip a corrupt lesson file / JSONL line instead of throwing
340
+ (which previously broke retrieval, routing, and the pre-edit advisory everywhere `load` is used).
341
+ - **`recordMistake` reports `refused` (not `created`) when a save is rejected**, so the Stop hook
342
+ never tries to distill a phantom lesson; `applyDistillation`/`recordContradiction` surface the
343
+ real write result too.
344
+ - **Atlas emits `inherits` edges** (`class X extends Y`; Python `class X(Base)`) — the weight was
345
+ defined but never produced, so base-class changes were invisible to blast-radius.
346
+ - **Atlas is incremental + staleness-aware.** `build()` reuses per-file extraction by content
347
+ hash (a sidecar cache) instead of re-parsing the whole repo; `isStale()` lets `verify` rebuild
348
+ when the cached graph is out of date (post-edit hallucination detection was running on a stale
349
+ atlas). A capped graph now degrades to "uncertain" rather than raising false "unknown symbol".
350
+ - **Performance:** `resolveEdges` is O(E) (was O(E·N) — a full node scan per edge); `impact()`
351
+ reuses one memoized reverse-adjacency map across the up-to-8 calls per `substrate` run.
352
+ - **`substrate` no longer recomputes preflight twice** (or fires a redundant assumption model
353
+ call): the gap is computed once and threaded into routing.
354
+
355
+ ### Added
356
+
357
+ - **Opt-in LLM adjudication for the substrate (`FORGE_LLM=1`)** — one shared, fail-safe `claude -p` proposer (`src/adjudicate.js`) wired thinly into the assumption gate (M2), model routing (M1), impact/blast-radius, and goal-drift (M4). The model only *proposes*; every proposal is verified against the deterministic rubric, the code graph, or a grep before it can move a verdict. Off by default — behaviour is unchanged unless enabled — never blocks, and the ambient Claude Code hook stays deterministic unless `FORGE_LLM_AMBIENT=1`. `forge substrate --json` carries an `llm.provenance` map per faculty for auditability.
358
+ - **Bidirectional verified reconcile (default on when `FORGE_LLM=1`; `llm.bidirectional` in `source/substrate.json` to disable).** A verified reading may now *reduce* caution as well as add it — clear a false "ASK FIRST" (`llm-cleared`) and route a task *down* a tier (`llm-lowered`) — but only within `band` and never past the hard floors: the gate can't clear a task with no concrete anchor or one naming symbols/files the repo lacks, and routing can't drop below a strong-signal (algorithmic/architectural) floor. Set `llm.bidirectional: false` for the conservative tighten-/raise-only mode. Impact edges stay graph-+-grep-verified; goal-drift stays off→on with a goal-referencing reason.
359
+ - **Explicit memory `val` term** — lesson retrieval now decomposes into the white paper's `relevance × freshness × validity × scope`, with `validity()` (a ground-truth Beta posterior over confirmed vs. contradicted outcomes) exported and ranked so outcome-confirmed lessons outrank merely-recent ones.
360
+
361
+ ### Changed
362
+
363
+ - **Unified the model-call path** — the Cortex distiller now shares the `adjudicate` runner instead of its own `claude` shell-out.
364
+
365
+ ## [0.4.0] - 2026-07-06
366
+
367
+ ### Added
368
+
369
+ - **Forge Cognitive Substrate** — one pre-action command (`forge substrate`) plus an MCP surface (`substrate_check`, `predict_impact`, `assumption_gate`, `route_task`, `scope_files`): assumption gate, transparent model routing, impact/blast-radius, scope decomposition, Cortex lessons, minimality, and a verification checklist.
370
+ - **M4 goal-anchoring (`forge anchor`)** — a deterministic goal-drift check that flags changed files off the stated goal. All 11 white-paper capabilities now ship a real mechanism.
371
+ - **Atlas v2 graph** — dependency nodes/edges + reverse-dependency impact traversal (the symbol-query API is preserved).
372
+ - **`docs/GUIDE.md`** (the complete command guide) and **`docs/RELEASING.md`** (release runbook).
373
+ - **Repo automation** — `repo-settings.yml` (About/topics/Discussions as code) and `labels.yml` (label sync) workflows; a Codex plugin manifest and `cognitive-substrate` skill; the paper bundle under `docs/cognitive-substrate/`.
374
+
375
+ ### Changed
376
+
377
+ - **Publish to public npm.** `@codewithjuber/forgekit` now publishes to npmjs with provenance, so `npm install -g @codewithjuber/forgekit` needs no token (replacing the GitHub Packages route, which required auth even for public installs). The release workflow was fixed to trigger on a tag, publish, and cut a GitHub Release with generated notes.
378
+ - **Substrate auto-runs in Claude Code** via a `UserPromptSubmit` hook — it surfaces only when something needs attention and never blocks — and `forge init` emits a "run substrate before risky work" rule into every other tool's config.
379
+ - **Docs overhaul** — README rewritten (problem → solution → how, npm-first, SEO-friendly); the install, honest-limits, frozen-model, and substrate blocks are single-sourced instead of copied across files; the supported-tool list is reconciled everywhere.
380
+
381
+ ### Fixed
382
+
383
+ - **Security (research prototype):** removed the pickle-based cache in `impact_oracle/world_model.py` — an insecure-deserialization (RCE) vector on a caller-supplied `cache_dir`. Now JSON node-link only, with `cache_dir` contained inside `root`.
384
+ - **Smaller npm package** — stopped publishing the ~2 MB paper bundle and the redundant `*_src.zip` (source lives unzipped under `research/`).
385
+ - **Perf** — `substrateCheck` no longer recomputes the assumption assessment.
386
+
387
+ ## [0.3.1] - 2026-07-05
388
+
389
+ ### Changed
390
+
391
+ - **Publish to GitHub Packages** instead of npmjs. Package renamed to the scoped
392
+ `@codewithjuber/forgekit`; `publishConfig.registry` → `https://npm.pkg.github.com`. The
393
+ release workflow now authenticates with the built-in `GITHUB_TOKEN` (`packages: write`) — no
394
+ external `NPM_TOKEN` secret. A committed `.npmrc` maps the scope to the registry and sets
395
+ `min-release-age=7` (supply-chain cooldown). Note: GitHub Packages requires consumers to
396
+ authenticate even for public installs, so the `bash install.sh` clone path stays the
397
+ friction-free primary channel.
398
+
399
+ ## [0.3.0] - 2026-07-05
400
+
401
+ ### Added
402
+
403
+ - **Forge Preflight** — a deterministic, math-first layer that runs BEFORE tokens are spent,
404
+ on the premise that an LLM is a fixed-capacity stochastic predictor: size the task to the
405
+ model, fill the context, detect assumptions. All advisory, never blocks.
406
+ - **Assumption detector** (`forge preflight`, UserPromptSubmit hook): scans a task for code
407
+ identifiers/files the repo doesn't define — what the model would otherwise ASSUME — and
408
+ surfaces the known-unknowns so it asks instead of confabulating. The research whitespace.
409
+ - **Complexity routing** (`forge route`): recommends the cheapest CAPABLE model
410
+ (Haiku → Sonnet → Opus → Fable) from code-task signals (files, fan-out, churn, past-mistake
411
+ density, ambiguity). `forge route gateway` emits a LiteLLM config for real auto-routing.
412
+ - **Decomposition** (`forge scope`): a zero-dep import graph → connected components →
413
+ independent clusters (run as separate sessions) + the coupled files you didn't name.
414
+ - **Design-quality**: emitted AI-UX rules (anti-slop, WCAG, functional empty states, specific
415
+ errors, confidence/transparency, pattern selection) + `forge uicheck` (exact WCAG contrast
416
+ math) + a calibrated frontend-verifier that ASSERTS only the deterministic and keeps
417
+ hierarchy/taste ADVISORY (the fix for hallucinated UI audits).
418
+ - Cross-tool via `preflight_check` / `route_task` / `scope_files` MCP tools.
419
+
420
+ ## [0.2.0] - 2026-07-05
421
+
422
+ ### Added
423
+
424
+ - **Forge Cortex** — self-correcting project memory. Detects a genuine recurring mistake
425
+ on this repo (test-fail→fix, revert, symbol thrash, explicit human undo), distills a
426
+ structured lesson, and re-confirms it against independent outcomes — with an
427
+ anti-self-reinforcement lifecycle (`Beta` confidence + decay; injection never confirms;
428
+ a green build always wins) so a wrong lesson decays out instead of ossifying.
429
+ `forge cortex`, `forge cortex why <symbol>`.
430
+ - Ambient hooks (fail-safe, never block): capture signals during a session, distill at
431
+ `Stop`, inject learned lessons at `SessionStart`, and a `PreToolUse` advisory before a
432
+ risky edit.
433
+ - Local error predictor (heuristic + a tiny logistic model) gated by an AUC-PR kill-switch
434
+ — it only ships if it measurably beats the heuristic; otherwise it falls back or disables.
435
+ - Cross-tool: lessons inlined into `AGENTS.md` + a zero-dependency MCP server
436
+ (`forge cortex-mcp`, registered in `source/mcp.json`).
437
+ - Optional LLM lesson distiller (`ENABLE_CORTEX_DISTILL=1`) — replaces the deterministic
438
+ template with a real distilled lesson via `claude -p`.
439
+ - `forge doctor` reports Cortex lesson state; `forge catalog` lists Cortex.
440
+
441
+ ## [0.1.0] - 2026-07-05
442
+
443
+ ### Added
444
+
445
+ - Cross-tool config emitter (`forge sync`) — one source → each tool's native format; three
446
+ install channels (Claude plugin + marketplace, installer, npm); `forge doctor`; code-graph
447
+ (`atlas`); `lean` discipline; guard/skill/crew layers.
448
+ - Verification layer: `forge verify` (tests + hallucinated-symbol catch + provenance),
449
+ doom-loop breaker guard, bias-safe `independent-reviewer` agent.
450
+ - Security gate: `forge scan` (skill-gate), `secret-redact` guard, structured
451
+ `permissionDecision` in `protect-paths`, `forge harden` (gitleaks + sandbox).
452
+ - Cross-tool MCP emit; portable memory (`forge brain` / `forge remember`); design-taste
453
+ menu (`forge taste`); `forge spec` spec-lock + OpenSpec wiring; MCP ~6-server hygiene
454
+ check; coverage + type-checking (`tsc --checkJs`); 2026 production-standard rules;
455
+ OWASP-LLM / NIST SSDF / SLSA control mapping.
456
+
457
+ [Unreleased]: https://github.com/CodeWithJuber/forgekit/compare/v0.8.0...HEAD
458
+ [0.8.0]: https://github.com/CodeWithJuber/forgekit/compare/v0.7.0...v0.8.0
459
+ [0.7.0]: https://github.com/CodeWithJuber/forgekit/compare/v0.6.0...v0.7.0
460
+ [0.6.0]: https://github.com/CodeWithJuber/forgekit/compare/v0.5.0...v0.6.0
461
+ [0.5.0]: https://github.com/CodeWithJuber/forgekit/compare/v0.4.0...v0.5.0
462
+ [Unreleased]: https://github.com/CodeWithJuber/forgekit/compare/v0.4.0...HEAD
463
+ [0.4.0]: https://github.com/CodeWithJuber/forgekit/compare/v0.3.1...v0.4.0
464
+ [0.3.1]: https://github.com/CodeWithJuber/forgekit/compare/v0.3.0...v0.3.1
465
+ [0.3.0]: https://github.com/CodeWithJuber/forgekit/compare/v0.2.0...v0.3.0
466
+ [0.2.0]: https://github.com/CodeWithJuber/forgekit/compare/v0.1.0...v0.2.0
467
+ [0.1.0]: https://github.com/CodeWithJuber/forgekit/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CodeWithJuber
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.