autonomous-flow-daemon 1.6.0 → 1.9.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 (61) hide show
  1. package/CHANGELOG.md +85 -85
  2. package/LICENSE +21 -21
  3. package/README-ko.md +282 -0
  4. package/README.md +282 -266
  5. package/mcp-config.json +10 -10
  6. package/package.json +4 -2
  7. package/src/adapters/index.ts +370 -370
  8. package/src/cli.ts +162 -127
  9. package/src/commands/benchmark.ts +187 -187
  10. package/src/commands/correlate.ts +180 -0
  11. package/src/commands/dashboard.ts +404 -0
  12. package/src/commands/evolution.ts +84 -1
  13. package/src/commands/fix.ts +158 -158
  14. package/src/commands/lang.ts +41 -41
  15. package/src/commands/plugin.ts +110 -0
  16. package/src/commands/restart.ts +14 -14
  17. package/src/commands/score.ts +276 -276
  18. package/src/commands/start.ts +155 -155
  19. package/src/commands/status.ts +157 -157
  20. package/src/commands/stop.ts +68 -68
  21. package/src/commands/suggest.ts +211 -0
  22. package/src/commands/sync.ts +329 -16
  23. package/src/constants.ts +32 -32
  24. package/src/core/boast.ts +280 -280
  25. package/src/core/config.ts +49 -49
  26. package/src/core/correlation-engine.ts +265 -0
  27. package/src/core/db.ts +145 -117
  28. package/src/core/discovery.ts +65 -65
  29. package/src/core/federation.ts +129 -0
  30. package/src/core/hologram/engine.ts +71 -71
  31. package/src/core/hologram/fallback.ts +11 -11
  32. package/src/core/hologram/go-extractor.ts +203 -0
  33. package/src/core/hologram/incremental.ts +227 -227
  34. package/src/core/hologram/py-extractor.ts +132 -132
  35. package/src/core/hologram/rust-extractor.ts +244 -0
  36. package/src/core/hologram/ts-extractor.ts +406 -320
  37. package/src/core/hologram/types.ts +27 -25
  38. package/src/core/hologram.ts +73 -71
  39. package/src/core/i18n/messages.ts +309 -309
  40. package/src/core/locale.ts +88 -88
  41. package/src/core/log-rotate.ts +33 -33
  42. package/src/core/log-utils.ts +38 -38
  43. package/src/core/lru-map.ts +61 -61
  44. package/src/core/notify.ts +74 -74
  45. package/src/core/plugin-manager.ts +225 -0
  46. package/src/core/rule-suggestion.ts +127 -0
  47. package/src/core/validator-generator.ts +224 -0
  48. package/src/core/workspace.ts +28 -28
  49. package/src/daemon/client.ts +78 -65
  50. package/src/daemon/event-batcher.ts +108 -108
  51. package/src/daemon/guards.ts +13 -13
  52. package/src/daemon/http-routes.ts +376 -293
  53. package/src/daemon/mcp-handler.ts +575 -270
  54. package/src/daemon/mcp-subscriptions.ts +81 -0
  55. package/src/daemon/mesh.ts +51 -0
  56. package/src/daemon/server.ts +655 -590
  57. package/src/daemon/types.ts +121 -100
  58. package/src/daemon/workspace-map.ts +104 -92
  59. package/src/platform.ts +60 -60
  60. package/src/version.ts +15 -15
  61. package/README.ko.md +0 -266
package/README.md CHANGED
@@ -1,266 +1,282 @@
1
- <p align="center">
2
- <img src="https://capsule-render.vercel.app/api?type=soft&color=auto&height=200&section=header&text=afd&fontSize=90" alt="afd" />
3
- </p>
4
-
5
- <h3 align="center">The Autonomous Flow Daemon</h3>
6
- <p align="center"><strong>Self-healing AI development environments in < 270ms.</strong></p>
7
-
8
- <p align="center">
9
- <a href="https://github.com/dotoricode/autonomous-flow-daemon">
10
- <img src="demo.gif" width="850" alt="afd demo" style="border-radius: 12px; box-shadow: 0 20px 40px rgba(0,0,0,0.4);">
11
- </a>
12
- </p>
13
-
14
- ---
15
-
16
- <p align="center">
17
- <img src="https://img.shields.io/badge/version-1.6.0-blue?style=flat-square" alt="version" />
18
- <a href="https://www.npmjs.com/package/autonomous-flow-daemon"><img src="https://img.shields.io/npm/v/autonomous-flow-daemon?style=flat-square&logo=npm&color=cb0000" alt="npm" /></a>
19
- <img src="https://img.shields.io/badge/runtime-Bun-f472b6?style=flat-square&logo=bun" alt="Bun" />
20
- <img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="MIT" />
21
- <img src="https://img.shields.io/badge/built%20for-Claude%20Code-7c3aed?style=flat-square" alt="Claude Code" />
22
- </p>
23
-
24
- <p align="center">
25
- <a href="README.ko.md">한국어</a>
26
- </p>
27
-
28
- ---
29
-
30
- ## Why afd?
31
-
32
- > [afd] AI agent deleted '.claudeignore' | Self-healed in 184ms | Context preserved.
33
-
34
- Your AI agent deletes a config, corrupts a hook file, wipes `.cursorrules`. Without `afd`, you stop everything, diagnose the breakage, manually fix it: **30 minutes gone**.
35
-
36
- With `afd`, the daemon noticed in 10ms, restored the file in 184ms, and logged it silently. **You never even saw it happen.** Running as a native Bun daemon, it consumes < 0.1% CPU and ~40MB RAM — zero interference with your workflow.
37
-
38
- | Situation | Without afd | With afd |
39
- |:----------|:------------|:---------|
40
- | AI deletes `.claudeignore` | 30 min manual fix | **0.2s auto-heal** |
41
- | Hook file corrupted | Re-inject hooks, restart session | **Silent background repair** |
42
- | `git checkout` triggers 50 file events | AI goes haywire | **Mass-event suppressor kicks in** |
43
- | AI reads 8 large files (114KB) | ~28,600 tokens consumed | **~1,700 tokens via hologram (94% saved)** |
44
-
45
- ---
46
-
47
- ## Key Features
48
-
49
- | Feature | What it does |
50
- |:--------|:-------------|
51
- | **S.E.A.M Auto-Heal** | Detects file deletion/corruption and restores it in < 270ms |
52
- | **Hologram Extraction** | Serves 80-93% lighter file skeletons to AI agents via MCP, slashing token costs |
53
- | **Smart File Reader** | `afd_read` — small files served raw, large files auto-compressed; supports line-range reads |
54
- | **Workspace Map** | `afd://workspace-map` — full file tree + export signatures in one call |
55
- | **Hologram L1** | Import-aware compression — only imported symbols get full signatures (85%+ savings) |
56
- | **Quarantine Zone** | Backs up corrupted files to `.afd/quarantine/` before restoring |
57
- | **Self-Evolution** | Analyzes quarantined failures and writes prevention rules to `afd-lessons.md` |
58
- | **Mistake History** | PreToolUse hook injects past mistakes as warnings before file edits |
59
- | **Double-Tap Heuristic** | Delete once = auto-heal; delete again within 30s = respected as intent |
60
- | **Vaccine Network** | Export learned antibodies via `afd sync` for cross-project immunity |
61
- | **MCP Integration** | `afd mcp install` auto-registers the daemon as an MCP server |
62
- | **HUD Defense Counter** | Status bar shows defense count + reason summary at a glance |
63
-
64
- ---
65
-
66
- ## Token Savings — Real Measured Data
67
-
68
- The hologram system is afd's biggest value driver for AI-assisted development. Here's what we measured in a real session:
69
-
70
- ### Session Snapshot (measured during a real coding session)
71
-
72
- | Metric | Value |
73
- |:-------|:------|
74
- | Hologram requests | 8 calls |
75
- | Target files total size | ~114.5 KB (8 files, avg 14.3 KB each) |
76
- | Original token cost | ~28,600 tokens |
77
- | After hologram compression | ~1,700 tokens |
78
- | **Tokens saved** | **~26,900 tokens (94% reduction)** |
79
-
80
- ### How It Scales
81
-
82
- ```
83
- Session tokens (at ctx ~15%): ~150,000 ████████████████
84
- Tokens saved by hologram: ~26,900 ██░░░░░░░░░░░░░░ (18% of session)
85
- ```
86
-
87
- At ctx 50%+, file reads dominate the token budget. Without hologram, reading 8 large files costs ~28.6K tokens each time. With hologram, **each file costs 1/16th** of its original footprint and the gap widens with every repeated read.
88
-
89
- ### Three Layers of Token Optimization
90
-
91
- | Layer | Tool | Savings | How |
92
- |:------|:-----|:--------|:----|
93
- | **L0 Hologram** | `afd_hologram` | 80%+ | Strip function bodies, keep type signatures |
94
- | **L1 Hologram** | `afd_hologram` + `contextFile` | 85%+ | Filter to only imported symbols |
95
- | **Smart Reader** | `afd_read` | Auto | Files < 10KB raw, >= 10KB auto-hologram |
96
- | **Workspace Map** | `afd://workspace-map` | N/A | Entire project structure in one call |
97
-
98
- ---
99
-
100
- ## The One-Command Experience
101
-
102
- ```bash
103
- npx @dotoricode/afd start
104
- ```
105
-
106
- Or install locally:
107
-
108
- ```bash
109
- bun link && afd start
110
- ```
111
-
112
- That's it. `afd` takes over from here:
113
-
114
- - **Auto-Injection** — Installs `PreToolUse` hooks into Claude Code silently.
115
- - **Sense (Watcher)** — 10ms real-time monitoring of critical configs.
116
- - **Auto-Heal** Silent background repair using the S.E.A.M cycle.
117
-
118
- ```
119
- $ afd start
120
- Daemon started (pid 4812, port 52413)
121
- Smart Discovery: Watching 7 AI-context targets
122
- Hook injected into .claude/hooks.json
123
- ```
124
-
125
- ---
126
-
127
- ## The S.E.A.M Cycle
128
-
129
- Every file event flows through four stages:
130
-
131
- ```mermaid
132
- graph LR
133
- S["Sense<br/><i>File Change Detected</i>"] --> E["Extract<br/><i>Detect Symptom</i>"]
134
- E --> A["Adapt<br/><i>Select Antibody</i>"]
135
- A --> M["Mutate<br/><i>Apply JSON-Patch</i>"]
136
- M -->|"Learn"| S
137
- style S fill:#3b82f6,color:#fff,stroke:none
138
- style E fill:#f59e0b,color:#fff,stroke:none
139
- style A fill:#10b981,color:#fff,stroke:none
140
- style M fill:#ef4444,color:#fff,stroke:none
141
- ```
142
-
143
- | Stage | What Happens | Speed |
144
- |:------|:-------------|:------|
145
- | **Sense** | Chokidar watcher detects `add`, `change`, `unlink` events | < 10ms |
146
- | **Extract** | Generates hologram (type skeleton) & runs health checks | < 5ms |
147
- | **Adapt** | Matches symptom to antibody, quarantines corrupted state | < 1ms |
148
- | **Mutate** | Applies RFC 6902 JSON-Patch to restore the file | < 25ms |
149
-
150
- > Full cycle: **< 270ms** from file deletion to full recovery.
151
-
152
- ---
153
-
154
- ## Commands
155
-
156
- | Command | What it does |
157
- |:--------|:-------------|
158
- | `afd start` | Daemon spawn + Smart Discovery + Hook injection + MCP registration |
159
- | `afd stop` | Shift summary report & graceful shutdown (`--clean` to remove hooks & MCP) |
160
- | `afd score` | Health dashboard with evolution & hologram metrics |
161
- | `afd fix` | Symptom detection with hologram context & antibody learning |
162
- | `afd sync` | Vaccine payload export/import (`--push`, `--pull`, `--remote <url>`) |
163
- | `afd restart` | Stop + start in one command |
164
- | `afd status` | Quick health check — daemon, hooks, MCP, defenses |
165
- | `afd doctor` | Comprehensive health analysis with auto-fix recommendations |
166
- | `afd evolution` | Analyze quarantined failures & generate prevention rules |
167
- | `afd mcp install` | Register afd as MCP server in project + global config |
168
- | `afd vaccine` | List, search, install, publish community antibodies |
169
- | `afd lang` | Switch display language (`afd lang ko` / `afd lang en`) |
170
-
171
- ---
172
-
173
- ## Advanced Intelligence
174
-
175
- ### Double-Tap Heuristic
176
-
177
- `afd` distinguishes **accidents** from **intent**:
178
-
179
- ```
180
- $ rm .claudeignore # First tap -> afd heals it silently
181
- $ rm .claudeignore # Second tap within 30s -> "You meant it."
182
- [afd] Antibody IMM-001 retired. Double-tap detected. Standing down.
183
- ```
184
-
185
- | Scenario | Response |
186
- |:---------|:---------|
187
- | Single delete (accident) | Auto-heal + record first tap |
188
- | Re-delete within 30s (intent) | Antibody goes dormant, deletion respected |
189
- | 3+ deletes in 1s (git checkout) | Mass-event detected, all suppression paused |
190
-
191
- ### Vaccine Network
192
-
193
- ```bash
194
- afd sync # Export to .afd/global-vaccine-payload.json
195
- afd sync --push # Push vaccines to remote
196
- afd sync --pull # Pull vaccines from remote
197
- ```
198
-
199
- The payload is sanitized (no absolute paths, no secrets) and portable.
200
-
201
- ### Self-Evolution
202
-
203
- ```bash
204
- afd evolution
205
- ```
206
-
207
- Analyzes quarantined failures and writes prevention rules to `afd-lessons.md`. AI agents read this before editing immune-critical files — turning past failures into future prevention.
208
-
209
- ---
210
-
211
- ## MCP Setup
212
-
213
- `afd` provides four MCP tools and one resource:
214
-
215
- | MCP Tool | Purpose |
216
- |:---------|:--------|
217
- | `afd_read` | Smart file reader raw for small files, auto-hologram for large, optional line ranges |
218
- | `afd_hologram` | Token-efficient type skeleton of any TS/JS file (80%+ savings) |
219
- | `afd_diagnose` | Health diagnosis with symptoms and hologram context |
220
- | `afd_score` | Runtime stats: uptime, heals, hologram savings |
221
-
222
- | MCP Resource | Purpose |
223
- |:-------------|:--------|
224
- | `afd://workspace-map` | Full file tree with export signatures in one call |
225
-
226
- ```bash
227
- afd mcp install # Registers in .mcp.json + ~/.claude.json
228
- ```
229
-
230
- ---
231
-
232
- ## Tech Stack
233
-
234
- | Layer | Technology | Why |
235
- |:------|:-----------|:----|
236
- | Runtime | **Bun** | Native TypeScript, fast SQLite, single binary |
237
- | Database | **Bun SQLite (WAL)** | 0.29ms reads, 24ms writes, crash-safe |
238
- | Watching | **Chokidar** | Cross-platform, battle-tested file watcher |
239
- | Patching | **RFC 6902 JSON-Patch** | Deterministic, composable file mutations |
240
- | CLI | **Commander.js** | Standard, zero-surprise command parsing |
241
-
242
- ---
243
-
244
- ## Installation
245
-
246
- ```bash
247
- # With Bun (recommended)
248
- bun install
249
- bun link
250
- afd start
251
-
252
- # With npx (no install)
253
- npx @dotoricode/afd start
254
- ```
255
-
256
- ### Requirements
257
-
258
- - **Bun** >= 1.0
259
- - **OS**: Windows, macOS, Linux
260
- - **Target**: Claude Code, Cursor, Windsurf, Codex (ecosystem auto-detected)
261
-
262
- ---
263
-
264
- ## License
265
-
266
- MIT
1
+ <p align="center">
2
+ <img src="https://capsule-render.vercel.app/api?type=soft&color=auto&height=200&section=header&text=afd&fontSize=90" alt="afd" />
3
+ </p>
4
+
5
+ <h3 align="center">The Invisible Guardian for AI Agents</h3>
6
+ <p align="center"><strong>Self-healing environments + 84% token savings. Your AI breaks things — afd fixes them in 184ms.</strong></p>
7
+
8
+ <p align="center">
9
+ <a href="https://github.com/dotoricode/autonomous-flow-daemon">
10
+ <img src="demo.gif" width="850" alt="afd demo" style="border-radius: 12px; box-shadow: 0 20px 40px rgba(0,0,0,0.4);">
11
+ </a>
12
+ </p>
13
+
14
+ <p align="center">
15
+ <img src="https://img.shields.io/badge/version-1.6.0-blue?style=flat-square" alt="version" />
16
+ <a href="https://www.npmjs.com/package/autonomous-flow-daemon"><img src="https://img.shields.io/npm/v/autonomous-flow-daemon?style=flat-square&logo=npm&color=cb0000" alt="npm" /></a>
17
+ <img src="https://img.shields.io/badge/runtime-Bun-f472b6?style=flat-square&logo=bun" alt="Bun" />
18
+ <img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="MIT" />
19
+ <img src="https://img.shields.io/badge/built%20for-Claude%20Code-7c3aed?style=flat-square" alt="Claude Code" />
20
+ </p>
21
+
22
+ <p align="center">
23
+ <a href="README-ko.md">한국어</a>
24
+ </p>
25
+
26
+ ---
27
+
28
+ ## The Numbers Don't Lie
29
+
30
+ | Situation | Without afd | With afd |
31
+ |:----------|:------------|:---------|
32
+ | AI deletes `.claudeignore` | **30 min** manual fix | **0.2s** auto-heal |
33
+ | Hook file corrupted | Re-inject hooks, restart session | **Silent background repair** |
34
+ | `git checkout` triggers 50 events | AI goes haywire | **Mass-event suppressor** |
35
+ | AI reads 8 large files (114KB) | **~28,600 tokens** consumed | **~4,600 tokens** (84% saved) |
36
+ | Session token budget | Burns through context window | **~60,900 tokens saved per codebase scan** |
37
+
38
+ > `< 0.1% CPU` | `~40MB RAM` | `< 270ms` full heal cycle | You never even see it happen.
39
+
40
+ ---
41
+
42
+ ## One Command to Rule Them All
43
+
44
+ ```bash
45
+ npx @dotoricode/afd start
46
+ ```
47
+
48
+ That's it. Daemon spawns, hooks inject, MCP registers. You're protected.
49
+
50
+ ```
51
+ $ afd start
52
+ Daemon started (pid 4812, port 52413)
53
+ Smart Discovery: Watching 7 AI-context targets
54
+ Hook injected into .claude/hooks.json
55
+ ```
56
+
57
+ ---
58
+
59
+ ## The Problem
60
+
61
+ Your AI agent is powerful but clumsy. It deletes `.claudeignore`, corrupts `hooks.json`, wipes `.cursorrules` and you don't notice until everything is broken. You stop coding, diagnose the mess, manually restore files. **30 minutes gone. Flow destroyed.**
62
+
63
+ And every time it reads your codebase? Full source files pumped straight into the context window. **Thousands of tokens burned on function bodies it never needed.**
64
+
65
+ ## The Solution
66
+
67
+ `afd` runs as an invisible background daemon. It watches your critical files, heals corruption in 184ms, and serves AI agents compressed type skeletons instead of raw source code. Your AI gets the structure it needs at 1/16th the token cost. Accidents get fixed before you notice. Intentional deletions are respected. Zero config, zero interference.
68
+
69
+ ---
70
+
71
+ ## What's New in v1.6.0
72
+
73
+ | Feature | What Changed |
74
+ |:--------|:-------------|
75
+ | **Tree-sitter AST Engine** | Replaced TypeScript compiler with tree-sitter — multilingual hologram support (TS/JS full, Python/Go/Rust fallback) |
76
+ | **Real-time HUD ROI** | Status bar now shows live session token savings as you work |
77
+ | **Event Batching** | 300ms debounce + dedup — no more event storms from rapid file changes |
78
+ | **Hook Manager** | Multi-owner orchestration afd coexists cleanly with other hook providers |
79
+
80
+ ---
81
+
82
+ ## Key Features
83
+
84
+ | Feature | What it does |
85
+ |:--------|:-------------|
86
+ | **S.E.A.M Auto-Heal** | File deletion/corruption detected and restored in < 270ms |
87
+ | **Hologram Extraction** | 70-96% lighter file skeletons served to AI agents via MCP |
88
+ | **Smart Reader** | `afd_read` — small files raw, large files auto-compressed, line-range support |
89
+ | **Workspace Map** | `afd://workspace-map` — full file tree + export signatures in one call |
90
+ | **Import-Aware L1** | Only imported symbols get full signatures (85%+ savings) |
91
+ | **Double-Tap** | Delete once = heal; delete again within 30s = respected as intent |
92
+ | **Vaccine Network** | `afd sync` exports learned antibodies across projects |
93
+ | **Self-Evolution** | Quarantined failures become prevention rules automatically |
94
+ | **Mistake History** | PreToolUse hook injects past mistakes as warnings before edits |
95
+ | **HUD Counter** | Status bar shows defense count + token savings at a glance |
96
+
97
+ ---
98
+
99
+ ## Token Savings — Real Measured Data
100
+
101
+ The hologram system is afd's biggest value driver. Here's what we measured in a real session:
102
+
103
+ ### Session Snapshot
104
+
105
+ | Metric | Value |
106
+ |:-------|:------|
107
+ | Hologram requests | 55 files analyzed |
108
+ | Target files total size | ~290 KB (55 files, avg 5.3 KB each) |
109
+ | Original token cost | ~72,500 tokens |
110
+ | After hologram compression | ~11,600 tokens |
111
+ | **Tokens saved** | **~60,900 tokens (84% reduction)** |
112
+
113
+ ### How It Scales
114
+
115
+ ```
116
+ Session tokens (at ctx ~15%): ~150,000 ████████████████
117
+ Tokens saved by hologram: ~60,900 ████████░░░░░░░░ (41% of session)
118
+ ```
119
+
120
+ At ctx 50%+, file reads dominate the token budget. Without hologram, scanning 55 source files costs ~72.5K tokens. With hologram, **each file averages just 16% of its original footprint** — and the gap widens with every repeated read.
121
+
122
+ ### Three Layers of Token Optimization
123
+
124
+ | Layer | Tool | Savings | How |
125
+ |:------|:-----|:--------|:----|
126
+ | **L0 Hologram** | `afd_hologram` | 80%+ | Strip function bodies, keep type signatures |
127
+ | **L1 Hologram** | `afd_hologram` + `contextFile` | 85%+ | Filter to only imported symbols |
128
+ | **Smart Reader** | `afd_read` | Auto | Files < 10KB raw, >= 10KB auto-hologram |
129
+ | **Workspace Map** | `afd://workspace-map` | N/A | Entire project structure in one call |
130
+
131
+ ---
132
+
133
+ <details>
134
+ <summary><b>How S.E.A.M Works (internals)</b></summary>
135
+
136
+ Every file event flows through four stages:
137
+
138
+ ```mermaid
139
+ graph LR
140
+ S["Sense<br/><i>File Change Detected</i>"] --> E["Extract<br/><i>Detect Symptom</i>"]
141
+ E --> A["Adapt<br/><i>Select Antibody</i>"]
142
+ A --> M["Mutate<br/><i>Apply JSON-Patch</i>"]
143
+ M -->|"Learn"| S
144
+ style S fill:#3b82f6,color:#fff,stroke:none
145
+ style E fill:#f59e0b,color:#fff,stroke:none
146
+ style A fill:#10b981,color:#fff,stroke:none
147
+ style M fill:#ef4444,color:#fff,stroke:none
148
+ ```
149
+
150
+ | Stage | What Happens | Speed |
151
+ |:------|:-------------|:------|
152
+ | **Sense** | Chokidar watcher detects `add`, `change`, `unlink` events | < 10ms |
153
+ | **Extract** | Generates hologram (type skeleton) & runs health checks | < 5ms |
154
+ | **Adapt** | Matches symptom to antibody, quarantines corrupted state | < 1ms |
155
+ | **Mutate** | Applies RFC 6902 JSON-Patch to restore the file | < 25ms |
156
+
157
+ > Full cycle: **< 270ms** from file deletion to full recovery.
158
+
159
+ </details>
160
+
161
+ ---
162
+
163
+ ## Commands
164
+
165
+ | Command | What it does |
166
+ |:--------|:-------------|
167
+ | `afd start` | Daemon spawn + Smart Discovery + Hook injection + MCP registration |
168
+ | `afd stop` | Shift summary report & graceful shutdown (`--clean` to remove hooks & MCP) |
169
+ | `afd score` | Health dashboard with evolution & hologram metrics |
170
+ | `afd fix` | Symptom detection with hologram context & antibody learning |
171
+ | `afd sync` | Vaccine payload export/import (`--push`, `--pull`, `--remote <url>`) |
172
+ | `afd restart` | Stop + start in one command |
173
+ | `afd status` | Quick health check — daemon, hooks, MCP, defenses |
174
+ | `afd doctor` | Comprehensive health analysis with auto-fix recommendations |
175
+ | `afd evolution` | Analyze quarantined failures & generate prevention rules |
176
+ | `afd mcp install` | Register afd as MCP server in project + global config |
177
+ | `afd vaccine` | List, search, install, publish community antibodies |
178
+ | `afd lang` | Switch display language (`afd lang ko` / `afd lang en`) |
179
+
180
+ ---
181
+
182
+ <details>
183
+ <summary><b>Advanced Intelligence</b></summary>
184
+
185
+ ### Double-Tap Heuristic
186
+
187
+ `afd` distinguishes **accidents** from **intent**:
188
+
189
+ ```
190
+ $ rm .claudeignore # First tap -> afd heals it silently
191
+ $ rm .claudeignore # Second tap within 30s -> "You meant it."
192
+ [afd] Antibody IMM-001 retired. Double-tap detected. Standing down.
193
+ ```
194
+
195
+ | Scenario | Response |
196
+ |:---------|:---------|
197
+ | Single delete (accident) | Auto-heal + record first tap |
198
+ | Re-delete within 30s (intent) | Antibody goes dormant, deletion respected |
199
+ | 3+ deletes in 1s (git checkout) | Mass-event detected, all suppression paused |
200
+
201
+ ### Vaccine Network
202
+
203
+ ```bash
204
+ afd sync # Export to .afd/global-vaccine-payload.json
205
+ afd sync --push # Push vaccines to remote
206
+ afd sync --pull # Pull vaccines from remote
207
+ ```
208
+
209
+ The payload is sanitized (no absolute paths, no secrets) and portable.
210
+
211
+ ### Self-Evolution
212
+
213
+ ```bash
214
+ afd evolution
215
+ ```
216
+
217
+ Analyzes quarantined failures and writes prevention rules to `afd-lessons.md`. AI agents read this before editing immune-critical files turning past failures into future prevention.
218
+
219
+ </details>
220
+
221
+ ---
222
+
223
+ ## MCP Setup
224
+
225
+ `afd` provides four MCP tools and one resource:
226
+
227
+ | MCP Tool | Purpose |
228
+ |:---------|:--------|
229
+ | `afd_read` | Smart file reader — raw for small files, auto-hologram for large, optional line ranges |
230
+ | `afd_hologram` | Token-efficient type skeleton of any TS/JS file (80%+ savings) |
231
+ | `afd_diagnose` | Health diagnosis with symptoms and hologram context |
232
+ | `afd_score` | Runtime stats: uptime, heals, hologram savings |
233
+
234
+ | MCP Resource | Purpose |
235
+ |:-------------|:--------|
236
+ | `afd://workspace-map` | Full file tree with export signatures in one call |
237
+
238
+ ```bash
239
+ afd mcp install # Registers in .mcp.json + ~/.claude.json
240
+ ```
241
+
242
+ ---
243
+
244
+ <details>
245
+ <summary><b>Tech Stack</b></summary>
246
+
247
+ | Layer | Technology | Why |
248
+ |:------|:-----------|:----|
249
+ | Runtime | **Bun** | Native TypeScript, fast SQLite, single binary |
250
+ | Database | **Bun SQLite (WAL)** | 0.29ms reads, 24ms writes, crash-safe |
251
+ | Parsing | **Tree-sitter** | Multilingual AST — TS, JS, Python, Go, Rust |
252
+ | Watching | **Chokidar** | Cross-platform, battle-tested file watcher |
253
+ | Patching | **RFC 6902 JSON-Patch** | Deterministic, composable file mutations |
254
+ | CLI | **Commander.js** | Standard, zero-surprise command parsing |
255
+
256
+ </details>
257
+
258
+ ---
259
+
260
+ ## Installation
261
+
262
+ ```bash
263
+ # Fastest (no install)
264
+ npx @dotoricode/afd start
265
+
266
+ # With Bun (recommended for development)
267
+ bun install
268
+ bun link
269
+ afd start
270
+ ```
271
+
272
+ ### Requirements
273
+
274
+ - **Bun** >= 1.0
275
+ - **OS**: Windows, macOS, Linux
276
+ - **Target**: Claude Code, Cursor, Windsurf, Codex (ecosystem auto-detected)
277
+
278
+ ---
279
+
280
+ ## License
281
+
282
+ MIT
package/mcp-config.json CHANGED
@@ -1,10 +1,10 @@
1
- {
2
- "mcpServers": {
3
- "afd": {
4
- "command": "bun",
5
- "args": ["run", "src/cli.ts", "start"],
6
- "description": "Autonomous Flow Daemon — self-healing AI development environment guardian. Monitors critical config files and auto-restores them within 270ms.",
7
- "env": {}
8
- }
9
- }
10
- }
1
+ {
2
+ "mcpServers": {
3
+ "afd": {
4
+ "command": "bun",
5
+ "args": ["run", "src/cli.ts", "start"],
6
+ "description": "Autonomous Flow Daemon — self-healing AI development environment guardian. Monitors critical config files and auto-restores them within 270ms.",
7
+ "env": {}
8
+ }
9
+ }
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autonomous-flow-daemon",
3
- "version": "1.6.0",
3
+ "version": "1.9.0",
4
4
  "description": "Zero-config immunity for AI coding workflows. Self-heals broken configs in < 270ms.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,7 +11,7 @@
11
11
  "src/**/*.ts",
12
12
  "mcp-config.json",
13
13
  "README.md",
14
- "README.ko.md",
14
+ "README-ko.md",
15
15
  "CHANGELOG.md",
16
16
  "LICENSE"
17
17
  ],
@@ -34,6 +34,8 @@
34
34
  "dependencies": {
35
35
  "chokidar": "^4.0.3",
36
36
  "commander": "^13.1.0",
37
+ "tree-sitter-go": "^0.25.0",
38
+ "tree-sitter-rust": "^0.24.0",
37
39
  "typescript": "^6.0.2",
38
40
  "web-tree-sitter": "^0.26.8"
39
41
  },