hebbian 0.3.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +155 -70
- package/dist/bin/hebbian.js +707 -79
- package/dist/bin/hebbian.js.map +1 -1
- package/dist/candidates.d.ts +32 -0
- package/dist/candidates.d.ts.map +1 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/doctor.d.ts +7 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/emit.d.ts.map +1 -1
- package/dist/episode.d.ts +6 -1
- package/dist/episode.d.ts.map +1 -1
- package/dist/evolve.d.ts +1 -1
- package/dist/evolve.d.ts.map +1 -1
- package/dist/fire.d.ts +10 -0
- package/dist/fire.d.ts.map +1 -1
- package/dist/hooks.d.ts +3 -3
- package/dist/hooks.d.ts.map +1 -1
- package/dist/inbox.d.ts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +459 -69
- package/dist/index.js.map +1 -1
- package/dist/outcome.d.ts +42 -0
- package/dist/outcome.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img src="https://img.shields.io/badge/TypeScript-6.0-3178C6?style=flat-square&logo=typescript" />
|
|
3
3
|
<img src="https://img.shields.io/badge/Node.js-22+-339933?style=flat-square&logo=node.js" />
|
|
4
4
|
<img src="https://img.shields.io/badge/Runtime_Deps-0-brightgreen?style=flat-square" />
|
|
5
|
-
<img src="https://img.shields.io/badge/Tests-
|
|
5
|
+
<img src="https://img.shields.io/badge/Tests-277-blue?style=flat-square" />
|
|
6
6
|
<img src="https://img.shields.io/badge/MIT-green?style=flat-square" />
|
|
7
7
|
</p>
|
|
8
8
|
|
|
@@ -10,12 +10,47 @@
|
|
|
10
10
|
|
|
11
11
|
# hebbian
|
|
12
12
|
|
|
13
|
-
### *Folder-as-neuron brain for any AI agent.*
|
|
13
|
+
### *Folder-as-neuron brain for any AI agent. Self-evolving.*
|
|
14
14
|
|
|
15
15
|
> "Neurons that fire together, wire together." — Donald Hebb (1949)
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
+
## The 2-minute demo
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# 1. Install and init a brain
|
|
23
|
+
npm install -g hebbian
|
|
24
|
+
hebbian init ./brain
|
|
25
|
+
hebbian claude install # attach to Claude Code (hooks)
|
|
26
|
+
|
|
27
|
+
# 2. Start a Claude Code session
|
|
28
|
+
claude
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
During the session, correct Claude once:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
you: don't use console.log, always use the logger utility
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# 3. End the session (hooks auto-run hebbian digest)
|
|
39
|
+
# Check what hebbian learned:
|
|
40
|
+
hebbian candidates
|
|
41
|
+
# ░░█ 1/3 cortex/NO_console_log (0d idle)
|
|
42
|
+
|
|
43
|
+
# 4. After 2 more corrections, it graduates:
|
|
44
|
+
# 🎓 promoted: cortex/_candidates/NO_console_log → cortex/NO_console_log
|
|
45
|
+
|
|
46
|
+
# 5. Next session — Claude sees the rule in CLAUDE.md:
|
|
47
|
+
# ❌ NO console.log → use logger utility
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**That's it.** One correction, hebbian learns. Three confirmations, it becomes permanent.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
19
54
|
## TL;DR
|
|
20
55
|
|
|
21
56
|
**`mkdir` replaces system prompts.** Folders are neurons. Paths are sentences. Counter files are synaptic weights.
|
|
@@ -23,9 +58,8 @@
|
|
|
23
58
|
```bash
|
|
24
59
|
npx hebbian init ./brain
|
|
25
60
|
npx hebbian grow brainstem/禁fallback --brain ./brain
|
|
26
|
-
npx hebbian fire brainstem/禁fallback --brain ./brain
|
|
27
61
|
npx hebbian emit claude --brain ./brain # → CLAUDE.md
|
|
28
|
-
npx hebbian
|
|
62
|
+
npx hebbian evolve --dry-run # → LLM proposes brain mutations
|
|
29
63
|
```
|
|
30
64
|
|
|
31
65
|
| Before | hebbian |
|
|
@@ -34,25 +68,43 @@ npx hebbian emit all --brain ./brain # → All AI formats at once
|
|
|
34
68
|
| Vector DB $70/mo | **$0** (folders = DB) |
|
|
35
69
|
| Switch AI → full migration | `cp -r brain/` — 1 second |
|
|
36
70
|
| Rule violation → wishful thinking | `bomb.neuron` → **cascade halt** |
|
|
37
|
-
| Rules
|
|
71
|
+
| Rules accumulate forever | Candidates decay if not confirmed |
|
|
38
72
|
|
|
39
73
|
---
|
|
40
74
|
|
|
41
|
-
##
|
|
75
|
+
## How It Works
|
|
42
76
|
|
|
43
|
-
|
|
77
|
+
### Architecture
|
|
44
78
|
|
|
45
|
-
|
|
79
|
+
```
|
|
80
|
+
Claude Code session
|
|
81
|
+
│
|
|
82
|
+
SessionStart hook Stop hook
|
|
83
|
+
│ │
|
|
84
|
+
hebbian emit hebbian digest
|
|
85
|
+
│ │
|
|
86
|
+
CLAUDE.md ←── brain ──→ _candidates/
|
|
87
|
+
│ │
|
|
88
|
+
hebbian evolve 3 confirmations
|
|
89
|
+
│ │
|
|
90
|
+
LLM proposes permanent neuron
|
|
91
|
+
grow/fire/prune
|
|
92
|
+
```
|
|
46
93
|
|
|
47
|
-
|
|
94
|
+
### Candidate Staging (immune system)
|
|
48
95
|
|
|
49
|
-
|
|
96
|
+
New neurons don't go straight into the brain. They land in `_candidates/` first:
|
|
50
97
|
|
|
51
98
|
```
|
|
52
|
-
brain/cortex/
|
|
99
|
+
brain/cortex/_candidates/NO_console_log/1.neuron ← 1st correction
|
|
100
|
+
brain/cortex/_candidates/NO_console_log/2.neuron ← 2nd correction
|
|
101
|
+
brain/cortex/_candidates/NO_console_log/3.neuron ← promoted!
|
|
102
|
+
brain/cortex/NO_console_log/3.neuron ← permanent
|
|
53
103
|
```
|
|
54
104
|
|
|
55
|
-
|
|
105
|
+
- Counter >= 3 → graduates to permanent region
|
|
106
|
+
- 14 days without a fire → decays (removed)
|
|
107
|
+
- This prevents hallucinations and one-off corrections from permanently changing behavior
|
|
56
108
|
|
|
57
109
|
### 7-Region Subsumption Architecture
|
|
58
110
|
|
|
@@ -79,23 +131,75 @@ bomb.neuron in any region → cascade halt.
|
|
|
79
131
|
| `bomb.neuron` | Circuit breaker | Pain response |
|
|
80
132
|
| `memoryN.neuron` | Episode recording | Long-term memory |
|
|
81
133
|
| `*.dormant` | Inactive marker | Sleep pruning |
|
|
82
|
-
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Claude Code Integration
|
|
138
|
+
|
|
139
|
+
One command to set up:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
hebbian claude install
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
This adds two hooks to `.claude/settings.local.json`:
|
|
146
|
+
|
|
147
|
+
| Hook | Command | When |
|
|
148
|
+
|------|---------|------|
|
|
149
|
+
| `SessionStart` | `hebbian emit claude` | Injects brain into CLAUDE.md |
|
|
150
|
+
| `Stop` | `hebbian digest` | Extracts corrections from conversation |
|
|
151
|
+
|
|
152
|
+
Check status anytime:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
hebbian claude status
|
|
156
|
+
hebbian doctor # full diagnostic
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## LLM Evolution
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
GEMINI_API_KEY=... hebbian evolve --dry-run --brain ./brain
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
The evolve engine reads the last 100 episodes + current brain state, sends it to Gemini, and proposes up to 10 mutations per cycle. Protected regions (brainstem/limbic/sensors) are blocked.
|
|
168
|
+
|
|
169
|
+
Actions it can take: `grow` (new neuron), `fire` (strengthen), `signal` (dopamine/bomb), `prune` (weaken), `decay` (mark dormant).
|
|
83
170
|
|
|
84
171
|
---
|
|
85
172
|
|
|
86
173
|
## CLI Reference
|
|
87
174
|
|
|
88
175
|
```bash
|
|
176
|
+
# Brain management
|
|
89
177
|
hebbian init <path> # Create brain with 7 regions
|
|
90
|
-
hebbian
|
|
178
|
+
hebbian doctor # Self-diagnostic (hooks, versions, brain)
|
|
179
|
+
hebbian diag # Brain diagnostics
|
|
180
|
+
hebbian stats # Brain statistics
|
|
181
|
+
|
|
182
|
+
# Neuron operations
|
|
183
|
+
hebbian grow <neuron-path> # Create neuron (merge detection via Jaccard)
|
|
91
184
|
hebbian fire <neuron-path> # Increment counter (+1)
|
|
92
|
-
hebbian grow <neuron-path> # Create neuron (with merge detection)
|
|
93
185
|
hebbian rollback <neuron-path> # Decrement counter (min=1)
|
|
94
186
|
hebbian signal <type> <neuron-path> # Add signal (dopamine/bomb/memory)
|
|
95
187
|
hebbian decay [--days N] # Mark inactive neurons dormant
|
|
96
|
-
hebbian
|
|
97
|
-
|
|
98
|
-
|
|
188
|
+
hebbian dedup # Batch merge similar neurons
|
|
189
|
+
|
|
190
|
+
# Candidates
|
|
191
|
+
hebbian candidates # List pending candidates
|
|
192
|
+
hebbian candidates promote # Promote graduated, decay stale
|
|
193
|
+
|
|
194
|
+
# Emit / compile
|
|
195
|
+
hebbian emit <target> [--brain <path>] # claude/cursor/gemini/copilot/generic/all
|
|
196
|
+
|
|
197
|
+
# Claude Code
|
|
198
|
+
hebbian claude install|uninstall|status
|
|
199
|
+
hebbian digest [--transcript <path>]
|
|
200
|
+
|
|
201
|
+
# Evolution
|
|
202
|
+
GEMINI_API_KEY=... hebbian evolve [--dry-run]
|
|
99
203
|
```
|
|
100
204
|
|
|
101
205
|
### Emit Targets
|
|
@@ -109,54 +213,40 @@ hebbian stats # Brain statistics
|
|
|
109
213
|
| `generic` | `.neuronrc` |
|
|
110
214
|
| `all` | All of the above |
|
|
111
215
|
|
|
112
|
-
### Environment Variables
|
|
113
|
-
|
|
114
|
-
| Variable | Purpose | Default |
|
|
115
|
-
|----------|---------|---------|
|
|
116
|
-
| `HEBBIAN_BRAIN` | Brain directory path | `./brain` |
|
|
117
|
-
|
|
118
216
|
---
|
|
119
217
|
|
|
120
|
-
##
|
|
121
|
-
|
|
122
|
-
hebbian compiles your brain into 3 tiers:
|
|
123
|
-
|
|
124
|
-
| Tier | File | Tokens | When |
|
|
125
|
-
|------|------|--------|------|
|
|
126
|
-
| 1 | Target file (CLAUDE.md, etc.) | ~500 | Auto-loaded by AI |
|
|
127
|
-
| 2 | `brain/_index.md` | ~1000 | AI reads at session start |
|
|
128
|
-
| 3 | `brain/{region}/_rules.md` | Variable | AI reads on demand |
|
|
218
|
+
## Compared to
|
|
129
219
|
|
|
130
|
-
|
|
220
|
+
| Feature | .cursorrules / CLAUDE.md | Mem0 / MemOS | hebbian |
|
|
221
|
+
|---------|--------------------------|-------------|------|
|
|
222
|
+
| Self-learning | ❌ manual | ✅ vector DB | ✅ filesystem |
|
|
223
|
+
| Infrastructure | $0 | $$$ | **$0** |
|
|
224
|
+
| Switch AI | Manual migration | Full re-setup | **`cp -r brain/`** |
|
|
225
|
+
| Immutable guardrails | None | None | **brainstem + bomb** |
|
|
226
|
+
| False-positive protection | None | None | **candidate staging** |
|
|
227
|
+
| Audit trail | Text file | DB logs | **`ls -R` = full history** |
|
|
228
|
+
| Runtime deps | N/A | Many | **0** |
|
|
229
|
+
| Offline | ✅ | ❌ | **✅** |
|
|
131
230
|
|
|
132
231
|
---
|
|
133
232
|
|
|
134
|
-
##
|
|
135
|
-
|
|
136
|
-
When you `hebbian grow`, the system checks for similar existing neurons using Jaccard similarity:
|
|
233
|
+
## Starter Brain Templates
|
|
137
234
|
|
|
138
235
|
```bash
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
236
|
+
# TypeScript strict mode brain
|
|
237
|
+
hebbian init ./brain
|
|
238
|
+
hebbian grow brainstem/NO_any_type
|
|
239
|
+
hebbian grow brainstem/NO_implicit_returns
|
|
240
|
+
hebbian grow cortex/DO_strict_mode
|
|
241
|
+
hebbian grow cortex/DO_explicit_types
|
|
242
|
+
|
|
243
|
+
# Python best practices
|
|
244
|
+
hebbian grow brainstem/NO_bare_except
|
|
245
|
+
hebbian grow brainstem/NO_mutable_defaults
|
|
246
|
+
hebbian grow cortex/DO_type_hints
|
|
247
|
+
hebbian grow cortex/DO_dataclasses
|
|
142
248
|
```
|
|
143
249
|
|
|
144
|
-
**Consolidation over duplication.** Hebbian principle in action.
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
## Compared to
|
|
149
|
-
|
|
150
|
-
| Feature | .cursorrules | Mem0/Letta | hebbian |
|
|
151
|
-
|---------|-------------|------------|------|
|
|
152
|
-
| 1000+ rules | Token overflow | Vector DB | Folder tree |
|
|
153
|
-
| Infrastructure | $0 | $$$$ | **$0** |
|
|
154
|
-
| Switch AI | Manual migration | Full re-setup | **`cp -r brain/`** |
|
|
155
|
-
| Self-growth | Manual | Bot-based | **Counter-based** |
|
|
156
|
-
| Immutable guardrails | None | None | **brainstem + bomb** |
|
|
157
|
-
| Audit trail | Hidden | DB logs | **`ls -R` = full history** |
|
|
158
|
-
| Runtime deps | N/A | Many | **0** |
|
|
159
|
-
|
|
160
250
|
---
|
|
161
251
|
|
|
162
252
|
## Zero Runtime Dependencies
|
|
@@ -166,35 +256,30 @@ Written in **TypeScript 6.0**, built with tsup, tested with vitest.
|
|
|
166
256
|
- `node:fs` — filesystem operations
|
|
167
257
|
- `node:path` — path handling
|
|
168
258
|
- `node:util` — CLI argument parsing
|
|
169
|
-
- `node:http` — REST API
|
|
259
|
+
- `node:http` — REST API
|
|
260
|
+
- `node:https` / `fetch()` — LLM API calls (Node 22 built-in)
|
|
170
261
|
|
|
171
|
-
**Runtime dependencies: 0.**
|
|
262
|
+
**Runtime dependencies: 0.**
|
|
172
263
|
|
|
173
264
|
---
|
|
174
265
|
|
|
175
266
|
## Governance
|
|
176
267
|
|
|
177
|
-
|
|
268
|
+
277 tests pass in ~10s:
|
|
178
269
|
|
|
179
|
-
- **SCC** (Subsumption Cascade Correctness):
|
|
180
|
-
- **MLA** (Memory Lifecycle Accuracy):
|
|
181
|
-
- Scanner
|
|
182
|
-
- Lifecycle: 18 tests
|
|
183
|
-
- Emit: 16 tests
|
|
184
|
-
- Similarity: 12 tests
|
|
185
|
-
- CLI E2E: 21 tests
|
|
186
|
-
- Dedup: 3 tests
|
|
270
|
+
- **SCC** (Subsumption Cascade Correctness): 100%
|
|
271
|
+
- **MLA** (Memory Lifecycle Accuracy): 100%
|
|
272
|
+
- Candidates, Evolve, Digest, Hooks, Scanner, Similarity...
|
|
187
273
|
|
|
188
274
|
```bash
|
|
189
|
-
npm test
|
|
190
|
-
npx vitest run test/governance.test.ts # Governance only
|
|
275
|
+
npm test
|
|
191
276
|
```
|
|
192
277
|
|
|
193
278
|
---
|
|
194
279
|
|
|
195
280
|
## Inspired By
|
|
196
281
|
|
|
197
|
-
[NeuronFS](https://github.com/rhino-acoustic/NeuronFS) — the original Go implementation that proved folders can be neurons. hebbian is a
|
|
282
|
+
[NeuronFS](https://github.com/rhino-acoustic/NeuronFS) — the original Go implementation that proved folders can be neurons. hebbian is a TypeScript reimagination, designed for the npm ecosystem and zero-dependency operation.
|
|
198
283
|
|
|
199
284
|
---
|
|
200
285
|
|