@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/ONBOARDING.md ADDED
@@ -0,0 +1,180 @@
1
+ # Onboarding — five minutes to productive
2
+
3
+ **One brain for every AI coding agent.** A language model is *stateless* — one
4
+ context window, wiped every call — so it has no memory of what your team learned, no
5
+ foresight about what an edit breaks, and no enforced guardrails. forgekit is the
6
+ **cognitive substrate** that supplies exactly those three things, and it delivers them
7
+ as native config to Claude Code, Codex, Cursor, Gemini, Aider, Copilot, Windsurf, Zed,
8
+ and Continue at once. Author the brain once; every tool reads it.
9
+
10
+ This page is the fast path: install, configure a repo, do a task, and watch the ledger
11
+ start paying off on day two.
12
+
13
+ ```mermaid
14
+ %%{init: {'theme':'base','themeVariables':{'primaryColor':'#201a15','primaryTextColor':'#f2ede7','primaryBorderColor':'#372c22','lineColor':'#f26430','secondaryColor':'#272019','tertiaryColor':'#171310','fontFamily':'ui-sans-serif, system-ui, sans-serif'}}}%%
15
+ flowchart TD
16
+ I["forge init"] --> Cfg["every tool configured<br/>from one source"]
17
+ Cfg --> Work["you work as usual"]
18
+ Work --> Gate["substrate checks each task:<br/>ask first? · which model? · what breaks?"]
19
+ Gate --> Edit["agent edits, with guardrails"]
20
+ Edit --> Learn["cortex learns from corrections"]
21
+ Learn -.->|next task is smarter| Work
22
+ classDef accent fill:#f26430,stroke:#f26430,color:#171310;
23
+ class Gate accent;
24
+ ```
25
+
26
+ ## 1. Install (once)
27
+
28
+ The recommended paths need no token and no clone:
29
+
30
+ ```bash
31
+ # Claude Code / Codex — the plugin (guards auto-wire, nothing to merge)
32
+ /plugin marketplace add CodeWithJuber/forgekit
33
+ /plugin install forgekit
34
+
35
+ # Any tool — the CLI, from public npm
36
+ npm install -g @codewithjuber/forgekit
37
+
38
+ forge doctor # everything green?
39
+ ```
40
+
41
+ Full matrix (no-registry `github:` install, symlink dev setup) →
42
+ [README → Install](README.md#install).
43
+
44
+ ## 2. Configure a repo (once per repo)
45
+
46
+ One config for every tool. Author your rules once; `forge init` emits each tool's
47
+ native file.
48
+
49
+ ```bash
50
+ cd ~/your-project
51
+ forge init # emits AGENTS.md, CLAUDE.md, .gemini/settings.json, .aider.conf.yml …
52
+ ```
53
+
54
+ Now Claude Code, Codex, Cursor, Gemini, Aider, Copilot, Windsurf, Zed, and Continue all
55
+ read the **same** rules — each from its own native file (plus MCP server config for Roo
56
+ Code and VS Code).
57
+
58
+ Change a rule later by editing `source/rules.json` (or dropping a per-repo
59
+ `.forge/rules.json`), then:
60
+
61
+ ```bash
62
+ forge sync # recompiles into every tool; idempotent (only rewrites what changed)
63
+ ```
64
+
65
+ ## 3. Use the cognitive substrate
66
+
67
+ The substrate is the layer that runs *before* the model edits code. One command runs
68
+ the whole pre-action gate:
69
+
70
+ ```bash
71
+ forge substrate "<task>" # ask/route/impact/scope/reuse/context/memory/verify in one pass
72
+ forge substrate "<task>" --json
73
+ forge impact <symbol-or-file> # the blast radius on its own
74
+ ```
75
+
76
+ If `forge substrate` says `ASK FIRST`, ask the returned questions before editing. Read
77
+ the predicted impacted files — the **blast radius**, the set of files an edit is
78
+ predicted to touch — before any mutating change.
79
+
80
+ Paper and evidence package: [docs/cognitive-substrate/](docs/cognitive-substrate/).
81
+
82
+ ## 4. Use the extras
83
+
84
+ ```bash
85
+ forge atlas build # index this repo's symbols → .forge/atlas.json
86
+ forge atlas query useAuth # where is it defined? (cheaper than grep-and-read)
87
+ forge atlas has useAuth # does it exist? "not found" = likely hallucinated
88
+ forge recall add "db port" "Postgres is on 5433 here, not 5432"
89
+ forge recall list # facts the recall-load guard injects next session
90
+ forge catalog # the Start-Here index of everything
91
+ ```
92
+
93
+ ## 5. Day two: the ledger is learning
94
+
95
+ Everything the substrate learned on day one — cortex lessons, remembered facts,
96
+ verified code — landed as claims in `.forge/ledger/`. This is **proof-carrying memory
97
+ (PCM)**: every stored fact carries its own evidence and is only trusted once independent
98
+ oracles (tests, CI, a human accept/revert) raise its confidence above a floor. A wrong
99
+ lesson decays out instead of ossifying. Now it starts paying off:
100
+
101
+ ```bash
102
+ forge ledger stats # what the repo knows, by kind and trust level
103
+ forge ledger blame <id-prefix> # who minted a claim, every oracle outcome, per-author trust
104
+ forge reuse query "<what you're about to build>" # verified code you already have — with its proof
105
+ ```
106
+
107
+ A `forge reuse query` hit points at working, test-confirmed code and the
108
+ `forge ledger blame` command that proves it — reuse it instead of regenerating. And
109
+ after `git pull`, `forge ledger merge <path>` folds a teammate's ledger in
110
+ conflict-free (union-merge), so their lessons arrive with their provenance intact. The
111
+ ledger is shared team memory.
112
+
113
+ ---
114
+
115
+ ## Forge principles
116
+
117
+ Forge is opinionated. These are the ideas every part of it is built on — the "why"
118
+ behind the mechanisms.
119
+
120
+ ### 1. Guard over prose
121
+
122
+ Rules the model can drift from live in prose; rules it must **never** break live in
123
+ **guards** (deterministic shell hooks). A guard can't be forgotten after context
124
+ compaction. Move every enforceable invariant out of `CLAUDE.md` and into a guard; keep
125
+ the prose thin.
126
+
127
+ ### 2. One source, many emitters
128
+
129
+ Author rules **once** (`source/rules.json`); a deterministic compiler (`forge sync`)
130
+ emits each tool's native format with a content-hash header, so drift is detectable and
131
+ re-running is a no-op. No rule is ever written twice.
132
+
133
+ ### 3. Precompute, then serve
134
+
135
+ Answer "where is X / does X exist" from a **prebuilt artifact** (`.forge/atlas.json`),
136
+ not a live scan. Resolve the expensive part once; serve a few-hundred-token slice
137
+ instead of reading five files. The artifact is portable — any tool reads it, no MCP
138
+ required.
139
+
140
+ ### 4. The Lean Path
141
+
142
+ The smallest change that works, chosen _after_ understanding the problem: need it at
143
+ all? → already here? → stdlib/native/existing dep? → one small change → root not
144
+ symptom. Deletion over addition. Boring over clever. (See the `lean` tool.)
145
+
146
+ ### 5. Reuse over rebuild — thin layers over proven primitives
147
+
148
+ "Our own" never means "reimplement a mature tool." The smallest surface that delivers
149
+ the capability: `lean` is one rule file, not a plugin engine.
150
+
151
+ ### 6. Verify, don't assert
152
+
153
+ Nothing is "done" without a check you can run — a test, a build exit code, a screenshot.
154
+ Show the command and its output. Fix root causes; never suppress an error to make a
155
+ check pass.
156
+
157
+ ### 7. Re-entrancy safety
158
+
159
+ No guard may loop. Every guard is idempotent, holds an atomic lock while it runs, and
160
+ the one guard that calls a model (`session-learner`) is opt-in, gated, and single-shot.
161
+ The class of bug that once burned 1.67B tokens in five hours cannot originate here.
162
+
163
+ ### 8. Name the ceiling
164
+
165
+ Every deliberate simplification states its limit and upgrade path, in code and in docs.
166
+ Forge would rather ship an honest subset with a clear boundary than a vague claim — see
167
+ [the honest limits](docs/GUIDE.md#honest-limits).
168
+
169
+ ---
170
+
171
+ ## Extend it
172
+
173
+ - **Add a rule** → a bullet in `source/rules.json`, then `forge sync`.
174
+ - **Add a tool (skill)** → `global/tools/<name>/SKILL.md` with `name` + `description` frontmatter.
175
+ - **Add a guard** → `global/guards/<name>.sh` (source `_guardlib.sh` for fields + the lock), then wire it in `global/settings.template.json` and `hooks/hooks.json`.
176
+ - **Rebrand** → edit `brand.json` (+ `package.json` bin, `.claude-plugin/plugin.json` name).
177
+
178
+ Every command with worked examples and the full extension guide live in
179
+ [docs/GUIDE.md](docs/GUIDE.md); the architecture, pain-point evidence, and cross-tool
180
+ matrix live in [ARCHITECTURE.md](ARCHITECTURE.md).
package/README.md ADDED
@@ -0,0 +1,286 @@
1
+ # Forge — one brain for every AI coding agent
2
+
3
+ [![CI](https://github.com/CodeWithJuber/forgekit/actions/workflows/ci.yml/badge.svg)](https://github.com/CodeWithJuber/forgekit/actions/workflows/ci.yml)
4
+ [![CodeQL](https://github.com/CodeWithJuber/forgekit/actions/workflows/codeql.yml/badge.svg)](https://github.com/CodeWithJuber/forgekit/actions/workflows/codeql.yml)
5
+ [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/CodeWithJuber/forgekit/badge)](https://scorecard.dev/viewer/?uri=github.com/CodeWithJuber/forgekit)
6
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
7
+ [![node: >=20](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](./package.json)
8
+ [![runtime deps: 0](https://img.shields.io/badge/runtime%20dependencies-0-brightgreen.svg)](./package.json)
9
+
10
+ <p align="center">
11
+ <picture>
12
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/hero-dark.svg">
13
+ <img alt="forgekit — one brain for every AI coding agent: the cognitive substrate (memory, foresight, guardrails) wraps a stateless model and ships as one config to nine AI coding tools" src="docs/assets/hero-light.svg" width="100%">
14
+ </picture>
15
+ </p>
16
+
17
+ Forge is one shared brain for your AI coding agents. It gives a stateless model the
18
+ three things it structurally lacks — memory, foresight, and enforced guardrails — and
19
+ delivers them into every tool you use.
20
+
21
+ > The cognitive substrate every frozen model is missing — proof-carrying memory, impact
22
+ > foresight, and enforced guardrails — authored once and delivered as native config to
23
+ > Claude Code, Codex, Cursor, Gemini, Aider, Copilot, Windsurf, Zed, and Continue (plus
24
+ > MCP config for Roo and VS Code).
25
+
26
+ > **Status: beta.** The core (`init`, `sync`, `substrate`, `impact`, `ledger`, guards) is
27
+ > tested and in daily use; some flags may change before `1.0`.
28
+
29
+ ## Contents
30
+
31
+ - [The problem](#the-problem)
32
+ - [How it works — the loop](#how-it-works--the-loop)
33
+ - [What you get](#what-you-get)
34
+ - [60-second quickstart](#60-second-quickstart)
35
+ - [Commands](#commands)
36
+ - [Team memory in three commands](#team-memory-in-three-commands)
37
+ - [How it compares](#how-it-compares)
38
+ - [Honest limits](#honest-limits)
39
+ - [Why a cognitive substrate? The white paper](#why-a-cognitive-substrate-the-white-paper)
40
+ - [Public site](#public-site) · [Documentation](#documentation) · [Community & support](#community--support)
41
+
42
+ ## The problem
43
+
44
+ A large language model is stateless — one context window, wiped every call.
45
+
46
+ - It has **no memory** of what your team already learned.
47
+ - It has **no foresight** about what an edit will break.
48
+ - It has **no enforced guardrails** — prose rules get forgotten after a compaction.
49
+
50
+ And every tool wants its own config file (`CLAUDE.md`, `AGENTS.md`, `.cursor/rules`,
51
+ `GEMINI.md`, MCP…). Forge is the **cognitive substrate** — the layer that runs *before*
52
+ the model edits code, supplying memory, foresight, and guardrails — and the compiler that
53
+ delivers it into every tool from one source.
54
+
55
+ ## How it works — the loop
56
+
57
+ Every task passes a fast, deterministic gate; every outcome flows back into a shared,
58
+ proof-carrying memory.
59
+
60
+ ```mermaid
61
+ %%{init: {'theme':'base','themeVariables':{'primaryColor':'#201a15','primaryTextColor':'#f2ede7','primaryBorderColor':'#372c22','lineColor':'#f26430','secondaryColor':'#272019','tertiaryColor':'#171310','fontFamily':'ui-sans-serif, system-ui, sans-serif'}}}%%
62
+ flowchart LR
63
+ T["task"] --> G["substrate gate<br/>assume · route · reuse<br/>context · impact"]
64
+ G -->|unclear| Q["ask clarifying<br/>questions first"]
65
+ Q --> T
66
+ G -->|clear| A["agent acts"]
67
+ A --> O["oracles<br/>tests · CI · human"]
68
+ O --> L["ledger write-back<br/>claims + evidence"]
69
+ L --> M["team merge<br/>plain git, conflict-free"]
70
+ M -.->|lessons and verified reuse| G
71
+ classDef accent fill:#f26430,stroke:#f26430,color:#171310;
72
+ class G accent;
73
+ ```
74
+
75
+ Only independent oracles (tests, CI, a human accept/revert) move a memory's confidence —
76
+ so a wrong lesson decays out instead of ossifying. Full design:
77
+ [`ARCHITECTURE.md`](ARCHITECTURE.md).
78
+
79
+ ## What you get
80
+
81
+ The day-to-day value first — the substrate gives a frozen model what it can't hold itself:
82
+
83
+ - **Memory that persists across sessions and teammates.** Every lesson, fact, and verified
84
+ reuse is *proof-carrying memory (PCM)* — a claim that carries its own evidence and is only
85
+ trusted once independent oracles raise its confidence above a floor. Wrong lessons decay
86
+ out instead of ossifying.
87
+ - **Foresight before you break things.** Ask "what does changing `verifyToken` break?" and
88
+ get the *blast radius* — the set of files an edit is predicted to impact, read from the
89
+ code graph, including coupled files you never named.
90
+ - **Guardrails that can't be forgotten.** Deterministic hooks enforce the rules a model must
91
+ never break (protected paths, cost budget, doom loops) — they survive a context compaction
92
+ the way `CLAUDE.md` prose does not.
93
+ - **One config for 9 tools.** Author your rules once; Forge emits each tool's native config,
94
+ plus MCP for Roo and VS Code. Zero runtime dependencies — one Node CLI, plain files in git,
95
+ no server.
96
+
97
+ ### The measured evidence
98
+
99
+ Every number is a median from `npm run bench` on this repo, recorded with its environment
100
+ block in [`reports/benchmarks.md`](reports/benchmarks.md) — the project rule is *a number is
101
+ an assumption until measured*.
102
+
103
+ - **Blast radius in 0.43 ms** (warm code-graph). On 6 hand-labeled cases from this repo's
104
+ real import graph: recall **0.97** vs **0.33** for looking at the edited file alone.
105
+ - **A full pre-action gate in 118 ms** — assumption check, routing, reuse lookup, context
106
+ assembly, blast radius, scope, and goal anchor in one deterministic pass, no LLM call. On
107
+ Claude Code it runs on **every prompt, automatically**.
108
+ - **62.1% cost saved vs always-premium** — from the white paper's live routing prototype on
109
+ real models (paper §9; that's the paper's measurement, not this repo's — `forge cost
110
+ --stages` reports only *your* measured stages).
111
+ - **Conflict-free team memory** — merging two 500-claim ledger replicas takes **158 ms**; the
112
+ merge is a property-tested join-semilattice, so teammate ledgers converge in any order over
113
+ plain git.
114
+
115
+ ## 60-second quickstart
116
+
117
+ Install — pick one row (the recommended paths need no token and no clone):
118
+
119
+ | You use… | Run this |
120
+ | --- | --- |
121
+ | **Claude Code / Codex** *(recommended — full plugin, ambient guards)* | `/plugin marketplace add CodeWithJuber/forgekit` then `/plugin install forgekit` |
122
+ | **Any tool, from the CLI** | `npm install -g @codewithjuber/forgekit` |
123
+ | **No registry** | `npm install -g github:CodeWithJuber/forgekit` |
124
+ | **Contributors / local dev** | `git clone https://github.com/CodeWithJuber/forgekit.git && cd forgekit && npm link` — or `bash install.sh` for the symlink setup |
125
+
126
+ Then, in your project:
127
+
128
+ ```bash
129
+ forge init # emit every AI tool's native config from one shared source
130
+ forge doctor # pass/fail health check: tools, guards, MCP, config drift
131
+
132
+ # pre-action check before you (or your agent) edit anything:
133
+ forge substrate "Change verifyToken in src/auth.js to require length > 20; update tests"
134
+ # → assumption verdict · cheapest capable model · predicted blast radius
135
+ # (including files you didn't name) · scope clusters · verification checklist
136
+
137
+ # team memory: fold in a teammate's ledger — conflict-free, any order
138
+ git pull && forge ledger merge <path-to-their-ledger>
139
+ ```
140
+
141
+ On Claude Code the substrate then runs on **every prompt automatically** via a
142
+ `UserPromptSubmit` hook — advisory only, silent on clean tasks. Every other tool gets a
143
+ native config rule plus MCP tools (`substrate_check`, `predict_impact`, `assumption_gate`,
144
+ `route_task`, `scope_files`) it can call itself.
145
+
146
+ ## Commands
147
+
148
+ Advisory by default. Set `FORGE_ENFORCE=1` to turn the substrate into a hard block on the
149
+ strongest signals (vacuous prompt, un-assemblable required context, blast radius over the
150
+ default 25-file threshold).
151
+
152
+ | Group | Command | Does |
153
+ | --- | --- | --- |
154
+ | **Config layer** | `forge init` | emit every tool's native config from one source |
155
+ | | `forge sync` | recompile canonical source → each tool's native files (idempotent) |
156
+ | | `forge doctor` | pass/fail health check: tools, guards, MCP, drift |
157
+ | | `forge harden` | wire gitleaks pre-commit + sandbox settings |
158
+ | | `forge catalog` | Start-Here index of every tool / crew / guard |
159
+ | | `forge brand` | print the brand token map |
160
+ | **Memory & team** | `forge ledger` | proof-carrying memory — stats / verify / show / blame / query / ratify / retract / merge / import |
161
+ | | `forge recall` | cross-session personal memory — list / add / consolidate |
162
+ | | `forge remember` | durable, repo-committable fact |
163
+ | | `forge brain` | portable project-memory index |
164
+ | | `forge cortex` | self-correcting lessons — `status` / `why` |
165
+ | | `forge reuse` | proof-carrying code cache — query / mint / stats |
166
+ | **Substrate (pre-action)** | `forge substrate` | the full pre-action gate in one pass |
167
+ | | `forge preflight` | assumption / info-gap check |
168
+ | | `forge route` | cheapest capable model tier (`route gateway` emits LiteLLM config) |
169
+ | | `forge impact` | predict blast radius for a symbol or file |
170
+ | | `forge scope` | cluster + surface coupled files |
171
+ | | `forge imagine` | consequence sim + minimal dry-run suite (`--run` executes it sandboxed) |
172
+ | | `forge context` | budgeted context assembly + completeness gate |
173
+ | | `forge atlas` | build / query / has (hallucinated-symbol check) the code graph |
174
+ | | `forge anchor` | goal-drift check (advisory) |
175
+ | | `forge diagnose` | doom-loop: same failure 3× → diagnosis + escalation |
176
+ | | `forge lean` | scope-minimality footprint (advisory) |
177
+ | | `forge cost` | real per-day spend · measured stage factors (`--stages`) |
178
+ | **Verification & safety** | `forge verify` | independent gate — tests + hallucinated-symbol flag + provenance |
179
+ | | `forge scan` | skill-gate: vet a SKILL.md / .mcp.json for injection / RCE / exfil |
180
+ | | `forge spec` | spec-as-contract drift — init / lock / check |
181
+ | **UI / design** | `forge taste` | pick one visual direction → DESIGN.md |
182
+ | | `forge uicheck` | contrast · fingerprint · design · visual (WCAG · slop+conformance · Playwright) |
183
+ | **Observability** | `forge dash` | localhost-only read-only dashboard over ledger, metrics, blast radius (default port 4242) |
184
+
185
+ **→ Every command with a worked example and real output:
186
+ [`docs/GUIDE.md`](docs/GUIDE.md).**
187
+
188
+ ## Team memory in three commands
189
+
190
+ Everything the substrate learns — Cortex lessons, `forge remember` facts, verified reuse
191
+ artifacts — lands as content-addressed claims in a git-native ledger (`.forge/ledger/`)
192
+ built to merge without conflicts:
193
+
194
+ ```bash
195
+ forge init # once — also emits the .gitattributes union-merge rule the ledger needs
196
+ # …work normally: cortex and `forge remember` shadow claims into the ledger as you go…
197
+ git pull && forge ledger merge <path-to-their-ledger> # fold in a teammate's ledger — any order
198
+ ```
199
+
200
+ Identical knowledge minted independently converges to **one** claim with every author
201
+ preserved in its provenance; `forge ledger blame <id>` shows who minted it, every oracle
202
+ outcome, and per-author trust. No server, no sync service — it's just files in git.
203
+
204
+ ## How it compares
205
+
206
+ Structural differences only — each row is checkable against the named source, and the full
207
+ tables (including what each adjacent tool does *better*) are in
208
+ [`reports/benchmarks.md` → Uniqueness](reports/benchmarks.md#uniqueness--structural-contrasts-with-adjacent-tools):
209
+
210
+ | Property | Forge | Note stores / gateways / RAG |
211
+ | --- | --- | --- |
212
+ | Memory confidence moved **only by independent oracles** (tests, CI, human) | yes — closed `ORACLES` table; unverifiable evidence rejected (`src/ledger.js`) | note stores keep notes as written |
213
+ | Unreviewed knowledge decays toward *uncertainty*, not deletion | yes — time-decayed Beta posterior; dormant claims kept for audit | notes persist unchanged until deleted |
214
+ | Conflict-free team merge over plain git | yes — join-semilattice, property-tested | per-machine SQLite or a hosted store |
215
+ | Routing decision visible and diffable **before** dispatch | yes — deterministic rubric over `src/model_tiers.json` | gateways decide inside the proxy at request time |
216
+ | Cached code served **only with verification evidence**, revalidated against the current code graph | yes — `SERVE_FLOOR`, `revalidate()` in `src/reuse.js` | plain RAG serves on similarity alone |
217
+ | **What they do better** | — | hosted sync, web UIs, embedding search that catches paraphrase; gateways actually *move traffic* (failover, quotas). Forge is a transparency layer, not a replacement |
218
+
219
+ ## Honest limits
220
+
221
+ Forge states its own ceiling everywhere. In short: **guards reduce, don't eliminate** the
222
+ "ignored my rules" problem; `recall`/`cortex` are file memory, **not** weight-level
223
+ learning; the `atlas`/`impact` graph is regex-approximate (conservative, not a sound call
224
+ graph — the impact numbers above are n = 6 hand-labeled cases on one JavaScript repo); the
225
+ substrate's rubrics are heuristic; the MinHash near-match is weak on very short specs (an
226
+ optional embeddings backend — `FORGE_EMBED` — lifts this; MinHash stays the zero-dependency
227
+ default); and `forge cost --stages` reports **measured stages only** — a stage with no
228
+ events says "no data", never a default. What's *asserted* is safe to gate on (repo
229
+ grounding, graph traversal, routing arithmetic, test commands); everything else is
230
+ *advisory*. **Tests and human corrections always win.** Full list:
231
+ [docs/GUIDE.md → Honest limits](docs/GUIDE.md#honest-limits).
232
+
233
+ ## Why a cognitive substrate? The white paper
234
+
235
+ A language model at inference is a fixed function `y = f(x)` — frozen weights, a bounded
236
+ window, no state between calls. Memory, foresight, and self-checking can't be prompted into
237
+ that shape; they have to be supplied from outside. The full argument, with every
238
+ load-bearing statistic re-graded against primary sources, is the
239
+ [cognitive-substrate white paper](docs/cognitive-substrate/).
240
+
241
+ ## Public site
242
+
243
+ Forgekit ships two static pages. [`landing/index.html`](landing/index.html) is a
244
+ hand-authored landing page — the project's front door. [`public/index.html`](public/index.html)
245
+ is a generated status page, intentionally static and auto-updated from real repository data
246
+ (`package.json`, `README.md`, `CHANGELOG.md`, and `reports/benchmarks.md`) by the generator
247
+ in [`scripts/build-pages.mjs`](scripts/build-pages.mjs).
248
+
249
+ ```bash
250
+ npm run pages:build # offline, deterministic repo-data build
251
+ BUILD_PAGES_LIVE=1 npm run pages:build # also refresh public GitHub counters
252
+ ```
253
+
254
+ The optional live mode uses the no-auth GitHub repository API with timeouts, retries,
255
+ jitter, and ETag/Last-Modified caching.
256
+
257
+ Both pages share one design system (the same tokens as `forge dash`) and are gated by
258
+ `forge uicheck design` and the rendered `forge uicheck visual` check.
259
+
260
+ GitHub Pages is the primary deployment, via [`.github/workflows/static.yml`](.github/workflows/static.yml):
261
+ the landing page is published at the site root and the status page at `/status/`. GitLab
262
+ Pages ([`.gitlab-ci.yml`](.gitlab-ci.yml)) is unchanged and only deploys the status page at
263
+ its root — it does not get the landing page.
264
+
265
+ ## Documentation
266
+
267
+ | Doc | What's in it |
268
+ | --- | --- |
269
+ | [`ONBOARDING.md`](ONBOARDING.md) | Five minutes to productive + the design principles. |
270
+ | [`docs/GUIDE.md`](docs/GUIDE.md) | Every command, worked examples, all cases, how to extend. |
271
+ | [`reports/benchmarks.md`](reports/benchmarks.md) | Every measured number, methodology, and `npm run bench` to reproduce. |
272
+ | [`docs/cognitive-substrate/`](docs/cognitive-substrate/) | The white paper, evidence map, ecosystem map, and prototype sources. |
273
+ | [`ARCHITECTURE.md`](ARCHITECTURE.md) | The four-layer compiler and the cross-tool emit matrix. |
274
+ | [`docs/RELEASING.md`](docs/RELEASING.md) | How releases are cut (tag → npm + GitHub Release). |
275
+ | [`CHANGELOG.md`](CHANGELOG.md) | What changed, per release. |
276
+
277
+ ## Community & support
278
+
279
+ - **Get help** → [SUPPORT.md](./SUPPORT.md) · [Discussions](https://github.com/CodeWithJuber/forgekit/discussions)
280
+ - **Contribute** → [CONTRIBUTING.md](./CONTRIBUTING.md) · [Code of Conduct](./CODE_OF_CONDUCT.md)
281
+ - **Direction** → [ROADMAP.md](./ROADMAP.md) · [GOVERNANCE.md](./GOVERNANCE.md)
282
+ - **Security** → [SECURITY.md](./SECURITY.md) (report privately) · **Accessibility** → [ACCESSIBILITY.md](./ACCESSIBILITY.md)
283
+
284
+ ---
285
+
286
+ MIT licensed. Built by [CodeWithJuber](https://github.com/CodeWithJuber).
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env bash
2
+ # claude-init — scaffold per-repo AI config in the CURRENT directory.
3
+ # Auto-detects stack + commands and writes a shared AGENTS.md (read by
4
+ # Claude/Cursor/Codex/Gemini) + a thin CLAUDE.md that references it.
5
+ # Idempotent: won't overwrite existing files unless --force.
6
+ set -uo pipefail
7
+
8
+ FORCE=0; [ "${1:-}" = "--force" ] && FORCE=1
9
+ root="$PWD"
10
+ name="$(basename "$root")"
11
+
12
+ # --- detect package manager + scripts (Node) ---
13
+ pm=""; dev=""; build=""; test=""; lint=""; typecheck=""; fw=""; ts=""
14
+ if [ -f package.json ]; then
15
+ [ -f pnpm-lock.yaml ] && pm=pnpm; [ -f yarn.lock ] && pm=yarn
16
+ [ -f package-lock.json ] && pm=npm; [ -f bun.lockb ] && pm=bun
17
+ [ -z "$pm" ] && pm=npm
18
+ read -r dev build test lint typecheck fw ts < <(node -e '
19
+ const p=require("./package.json"); const s=p.scripts||{}; const d={...p.dependencies,...p.devDependencies};
20
+ const has=k=>s[k]?k:"-";
21
+ const fw = d.next?"Next.js":d.astro?"Astro":d.nuxt?"Nuxt":d["@remix-run/react"]?"Remix":d.svelte?"Svelte":d.vue?"Vue":d.react?"React":d.express?"Express/Node":"Node";
22
+ const ts = (d.typescript||require("fs").existsSync("tsconfig.json"))?"TypeScript":"JavaScript";
23
+ console.log([has("dev"),has("build"),has("test"),has("lint"),has("typecheck")||has("type-check"),fw,ts].join(" "));
24
+ ' 2>/dev/null || echo "- - - - - Node JavaScript")
25
+ fi
26
+
27
+ # --- detect python / db / infra ---
28
+ py=""; [ -f pyproject.toml ] && py="uv (pyproject.toml)"; [ -z "$py" ] && [ -f requirements.txt ] && py="pip (requirements.txt)"
29
+ db=""
30
+ [ -f prisma/schema.prisma ] && db="Prisma"
31
+ [ -f drizzle.config.ts ] || [ -f drizzle.config.js ] && db="${db:+$db, }Drizzle"
32
+ grep -riqE 'pgvector|postgres' docker-compose*.yml 2>/dev/null && db="${db:+$db, }Postgres"
33
+ infra=""; ls ./*.tf >/dev/null 2>&1 && infra="Terraform"
34
+ [ -f Dockerfile ] || ls docker-compose*.yml >/dev/null 2>&1 && infra="${infra:+$infra, }Docker"
35
+
36
+ pmr(){ [ -n "$pm" ] && [ "$1" != "-" ] && echo "\`$pm run $1\`" || echo "<add>"; }
37
+ stack="$( [ -n "$fw" ] && echo -n "$fw · $ts"; [ -n "$py" ] && echo -n " · Python ($py)"; [ -n "$db" ] && echo -n " · $db"; [ -n "$infra" ] && echo -n " · $infra")"
38
+ [ -z "$stack" ] && stack="<fill in: language, framework, DB, infra>"
39
+
40
+ write_agents(){
41
+ cat > AGENTS.md <<EOF
42
+ # AGENTS.md — $name
43
+
44
+ Cross-tool rules (Claude Code, Cursor, Codex, Gemini, Aider…). Keep thin.
45
+
46
+ ## Stack
47
+ $stack
48
+
49
+ ## Commands
50
+ - Install: \`${pm:-npm} ${pm:+install}${pm:-} \`
51
+ - Dev: $(pmr "${dev:--}")
52
+ - Test: $(pmr "${test:--}")
53
+ - Lint: $(pmr "${lint:--}") · Typecheck: $(pmr "${typecheck:--}")
54
+ - Build: $(pmr "${build:--}")
55
+ $( [ -n "$py" ] && echo "- Python: \`uv run <cmd>\` · lint \`ruff check\` · test \`pytest\`" )
56
+ $( [ -n "$db" ] && echo "- DB migrate: <add migrate command>" )
57
+
58
+ ## Rules
59
+ - Reuse existing components/utils before writing new; smallest change that works.
60
+ - Verify current best library from live sources before adding a dependency; prefer what's here.
61
+ - Wrap fallible async in try/catch; guard array/object access; explicit errors.
62
+ - UI: check mobile AND desktop; clear loading/empty/error states; follow DESIGN.md if present.
63
+ - Verify before "done": run tests/build/lint and show output; screenshot UI changes.
64
+ - Never commit secrets or .env*; never run destructive DB/FS commands without confirmation.
65
+
66
+ ## References
67
+ - Visual rules: @DESIGN.md (if present)
68
+ EOF
69
+ }
70
+
71
+ write_claude(){
72
+ cat > CLAUDE.md <<EOF
73
+ # $name — Claude notes
74
+
75
+ Shared rules live in @AGENTS.md (stack, commands, engineering rules). Keep this
76
+ file thin — only Claude-specific or repo-specific bits Claude keeps getting wrong.
77
+
78
+ ## Notes
79
+ - <add non-obvious gotchas, e.g. "run X before Y", env quirks>
80
+ EOF
81
+ }
82
+
83
+ made=""
84
+ if [ -f AGENTS.md ] && [ $FORCE -eq 0 ]; then echo "skip AGENTS.md (exists — use --force)"; else write_agents; made="$made AGENTS.md"; fi
85
+ if [ -f CLAUDE.md ] && [ $FORCE -eq 0 ]; then echo "skip CLAUDE.md (exists — use --force)"; else write_claude; made="$made CLAUDE.md"; fi
86
+
87
+ echo "✓ $name: detected [$stack]"
88
+ [ -n "$made" ] && echo " wrote:$made" || echo " nothing written (both existed)"
89
+ echo " next: skim AGENTS.md, fill any <add>/<fill> spots, then: git add AGENTS.md CLAUDE.md"
90
+ echo " optional: 'graphify install --project' + '/graphify .' to add a code graph"
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env bash
2
+ # claude-taste — enable ONE UI taste skill for the CURRENT repo (project-scoped).
3
+ # Best practice: one taste direction per project. Global taste skills compete and
4
+ # produce inconsistent UI. This copies a taste into ./.claude/skills/ so it applies
5
+ # only here. List with no args; enable with a name.
6
+ set -uo pipefail
7
+
8
+ ARCH="$HOME/.claude/skills-archive"
9
+ KEPT="$HOME/.claude/skills"
10
+
11
+ list() {
12
+ echo "Taste skills you can enable per-repo (usage: claude-taste <name>):"
13
+ { for d in "$ARCH"/*/ "$KEPT"/design-taste-frontend/; do
14
+ [ -f "${d}SKILL.md" ] && basename "$d"; done; } 2>/dev/null | sort -u | sed 's/^/ - /'
15
+ echo
16
+ echo "Then set the actual look in DESIGN.md (run: claude-init or ask for /design-md)."
17
+ }
18
+
19
+ [ $# -eq 0 ] && { list; exit 0; }
20
+
21
+ name="$1"
22
+ src=""
23
+ for cand in "$ARCH/$name" "$KEPT/$name"; do
24
+ [ -f "$cand/SKILL.md" ] && src="$cand" && break
25
+ done
26
+ [ -z "$src" ] && { echo "No taste skill named '$name'."; echo; list; exit 1; }
27
+
28
+ dest="./.claude/skills/$name"
29
+ if [ -d "$dest" ]; then echo "'$name' already enabled in $(basename "$PWD")."; exit 0; fi
30
+ mkdir -p "./.claude/skills"
31
+ cp -R "$src" "$dest"
32
+ echo "✓ enabled taste '$name' for $(basename "$PWD") -> $dest"
33
+ echo " next: define the look in DESIGN.md, then: git add .claude/skills/$name DESIGN.md"
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env bash
2
+ # Consolidate accumulated learned lessons: merge duplicates, prune trivia,
3
+ # keep only durable rules. Run weekly (manually or via cron). Uses Haiku.
4
+ # Fixes the append-only bloat of the session-learning hook.
5
+ set -uo pipefail
6
+
7
+ DIR="$HOME/.claude/skills/learned"
8
+ command -v claude >/dev/null 2>&1 || { echo "claude CLI not found on PATH"; exit 1; }
9
+
10
+ # Gather current consolidated file (if any) + all monthly lesson files.
11
+ inputs=$(ls "$DIR"/CONSOLIDATED.md "$DIR"/lessons-*.md 2>/dev/null)
12
+ [ -z "$inputs" ] && { echo "nothing to consolidate in $DIR"; exit 0; }
13
+ all="$(cat "$DIR"/CONSOLIDATED.md "$DIR"/lessons-*.md 2>/dev/null)"
14
+ [ -n "${all//[[:space:]]/}" ] || { echo "no lesson content"; exit 0; }
15
+
16
+ # Archive originals before rewriting.
17
+ mkdir -p "$DIR/archive"
18
+ ts="$(date +%Y%m%d-%H%M%S)"
19
+ for f in $inputs; do cp "$f" "$DIR/archive/$(basename "$f").$ts.bak"; done
20
+
21
+ prompt="You are consolidating a developer's accumulated learned lessons from AI
22
+ coding sessions. MERGE duplicates and near-duplicates into one rule. DROP anything
23
+ trivial, one-off, session-specific, or contradicted. KEEP only durable, reusable
24
+ rules (project gotchas, error->fix patterns, workflow rules). Group under
25
+ '## <project>' headers (use '## General' for cross-project). Each rule = one
26
+ markdown bullet. Do NOT invent anything — only compress what is given. NEVER
27
+ include secrets/tokens/PII. Output only the markdown, no preamble.
28
+
29
+ LESSONS:
30
+ $all"
31
+
32
+ # Uses your logged-in session (slower startup, but authed). Weekly/cron task.
33
+ out="$(printf '%s' "$prompt" | timeout 180 claude -p --model haiku 2>/dev/null)"
34
+ out="$(printf '%s' "$out" | sed '/^[[:space:]]*$/d')"
35
+
36
+ # Guard: never overwrite/delete on an error or empty/too-short response.
37
+ if printf '%s' "$out" | grep -qiE 'not logged in|/login|error|usage:'; then
38
+ echo "! claude returned an error (not logged in / empty) — originals kept, nothing changed"; exit 1
39
+ fi
40
+ if [ "$(printf '%s' "$out" | wc -c)" -lt 20 ]; then
41
+ echo "! response too short to be valid — originals kept"; exit 1
42
+ fi
43
+
44
+ if [ -n "$out" ]; then
45
+ { echo "# Learned — consolidated $(date +%Y-%m-%d)"; echo; printf '%s\n' "$out"; } > "$DIR/CONSOLIDATED.md"
46
+ rm -f "$DIR"/lessons-*.md
47
+ echo "✓ consolidated -> $DIR/CONSOLIDATED.md (originals archived in $DIR/archive/)"
48
+ echo " lines: $(wc -l < "$DIR/CONSOLIDATED.md")"
49
+ else
50
+ echo "! Haiku produced no output — originals kept, nothing changed"
51
+ fi
package/brand.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "brand": "Forge",
3
+ "cli": "forge",
4
+ "pkg": "forgekit",
5
+ "tagline": "One brain for every AI coding agent.",
6
+ "home": "~/.forge",
7
+ "layers": {
8
+ "tools": "skills (model-invoked capabilities)",
9
+ "crew": "agents (isolated-context sub-agents)",
10
+ "guards": "hooks (deterministic, enforced)",
11
+ "atlas": "code-graph (symbol/call index)",
12
+ "lean": "minimalism discipline",
13
+ "recall": "cross-session memory"
14
+ }
15
+ }