@sparkleideas/claude-flow-patch 3.1.0-alpha.44.patch.10 → 3.1.0-alpha.44.patch.11

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 (79) hide show
  1. package/CLAUDE.md +87 -8
  2. package/README.md +156 -4
  3. package/check-patches.sh +90 -16
  4. package/lib/categories.json +3 -1
  5. package/lib/common.py +15 -0
  6. package/package.json +6 -3
  7. package/patch/010-CF-001-doctor-yaml/sentinel +1 -1
  8. package/patch/020-CF-002-config-export-yaml/README.md +1 -1
  9. package/patch/020-CF-002-config-export-yaml/fix.py +3 -43
  10. package/patch/060-DM-004-worker-stubs/README.md +35 -0
  11. package/patch/060-DM-004-worker-stubs/fix.py +83 -0
  12. package/patch/{070-DM-005-consolidation-worker-stub → 060-DM-004-worker-stubs}/sentinel +1 -0
  13. package/patch/320-SG-004-wizard-parity/fix.py +1 -1
  14. package/patch/340-SG-006-wizard-capture/README.md +29 -0
  15. package/patch/340-SG-006-wizard-capture/fix.py +23 -0
  16. package/patch/340-SG-006-wizard-capture/sentinel +2 -0
  17. package/patch/350-WM-001-memory-wiring/README.md +50 -0
  18. package/patch/350-WM-001-memory-wiring/fix.py +385 -0
  19. package/patch/350-WM-001-memory-wiring/sentinel +3 -0
  20. package/patch/360-WM-002-config-respect/README.md +31 -0
  21. package/patch/360-WM-002-config-respect/fix.py +37 -0
  22. package/patch/360-WM-002-config-respect/sentinel +3 -0
  23. package/patch/370-WM-003-auto-memory-bridge/README.md +37 -0
  24. package/patch/370-WM-003-auto-memory-bridge/fix.py +261 -0
  25. package/patch/370-WM-003-auto-memory-bridge/sentinel +6 -0
  26. package/patch/380-CF-003-doctor-native-deps/README.md +46 -0
  27. package/patch/380-CF-003-doctor-native-deps/fix.py +157 -0
  28. package/patch/380-CF-003-doctor-native-deps/sentinel +4 -0
  29. package/patch/385-SG-007-init-shallow-copy/README.md +25 -0
  30. package/patch/385-SG-007-init-shallow-copy/fix.py +44 -0
  31. package/patch/385-SG-007-init-shallow-copy/sentinel +3 -0
  32. package/patch/390-WM-004-source-hook-fail-loud/README.md +33 -0
  33. package/patch/390-WM-004-source-hook-fail-loud/fix.py +164 -0
  34. package/patch/390-WM-004-source-hook-fail-loud/sentinel +2 -0
  35. package/patch/420-CF-004-config-export-json/README.md +24 -0
  36. package/patch/420-CF-004-config-export-json/fix.py +24 -0
  37. package/patch/420-CF-004-config-export-json/sentinel +2 -0
  38. package/patch/440-SG-008-init-config-json/README.md +21 -0
  39. package/patch/440-SG-008-init-config-json/fix.py +116 -0
  40. package/patch/440-SG-008-init-config-json/sentinel +2 -0
  41. package/patch/450-CF-006-config-yaml-to-json/README.md +42 -0
  42. package/patch/450-CF-006-config-yaml-to-json/fix.py +138 -0
  43. package/patch/450-CF-006-config-yaml-to-json/sentinel +7 -0
  44. package/patch/480-DOC-001-readme-docs/README.md +52 -0
  45. package/patch/480-DOC-001-readme-docs/fix.py +273 -0
  46. package/patch/480-DOC-001-readme-docs/sentinel +11 -0
  47. package/patch/490-SG-009-remove-v3-mode/README.md +47 -0
  48. package/patch/490-SG-009-remove-v3-mode/fix.py +204 -0
  49. package/patch/490-SG-009-remove-v3-mode/sentinel +8 -0
  50. package/patch/500-CF-009-minimal-v3-defaults/README.md +25 -0
  51. package/patch/500-CF-009-minimal-v3-defaults/fix.py +32 -0
  52. package/patch/500-CF-009-minimal-v3-defaults/sentinel +2 -0
  53. package/patch/530-WM-007-wire-dead-config-keys/README.md +49 -0
  54. package/patch/530-WM-007-wire-dead-config-keys/fix.py +254 -0
  55. package/patch/530-WM-007-wire-dead-config-keys/sentinel +15 -0
  56. package/patch/540-SG-010-init-cli-options/README.md +47 -0
  57. package/patch/540-SG-010-init-cli-options/fix.py +418 -0
  58. package/patch/540-SG-010-init-cli-options/sentinel +19 -0
  59. package/patch/550-SG-011-topology-hierarchical-refs/README.md +34 -0
  60. package/patch/550-SG-011-topology-hierarchical-refs/fix.py +28 -0
  61. package/patch/550-SG-011-topology-hierarchical-refs/sentinel +5 -0
  62. package/patch/560-WM-008-agentdb-v3-upgrade/README.md +57 -0
  63. package/patch/560-WM-008-agentdb-v3-upgrade/fix.py +257 -0
  64. package/patch/560-WM-008-agentdb-v3-upgrade/fix.sh +49 -0
  65. package/patch/560-WM-008-agentdb-v3-upgrade/sentinel +13 -0
  66. package/patch/570-WM-009-agentdb-learning-loop/README.md +35 -0
  67. package/patch/570-WM-009-agentdb-learning-loop/fix.py +141 -0
  68. package/patch/570-WM-009-agentdb-learning-loop/sentinel +3 -0
  69. package/patch/580-WM-010-witness-chain-verify/README.md +33 -0
  70. package/patch/580-WM-010-witness-chain-verify/fix.py +45 -0
  71. package/patch/580-WM-010-witness-chain-verify/sentinel +1 -0
  72. package/patch/590-WM-011-reasoning-bank-controller/README.md +34 -0
  73. package/patch/590-WM-011-reasoning-bank-controller/fix.py +381 -0
  74. package/patch/590-WM-011-reasoning-bank-controller/sentinel +4 -0
  75. package/patch/060-DM-004-preload-worker-stub/README.md +0 -11
  76. package/patch/060-DM-004-preload-worker-stub/fix.py +0 -34
  77. package/patch/060-DM-004-preload-worker-stub/sentinel +0 -1
  78. package/patch/070-DM-005-consolidation-worker-stub/README.md +0 -11
  79. package/patch/070-DM-005-consolidation-worker-stub/fix.py +0 -46
package/CLAUDE.md CHANGED
@@ -6,7 +6,7 @@ Runtime patches for `@claude-flow/cli` **v3.1.0-alpha.41**, `ruvector`, and `ruv
6
6
 
7
7
  | Term | Meaning | Example |
8
8
  |------|---------|---------|
9
- | **Defect** | A tracked problem (bug or missing feature). Each defect has its own directory under `patch/` with a README.md and fix.py. | "Defect HW-001", "29 defects across 13 categories" |
9
+ | **Defect** | A tracked problem (bug or missing feature). Each defect has its own directory under `patch/` with a README.md and fix.py. | "Defect HW-001", "60 defects across 15 categories" |
10
10
  | **Patch** | The code change that addresses a defect. Implemented as `fix.py` (or `fix.sh`) using `patch()`/`patch_all()` calls. We patch because we can't fix upstream. | "fix.py contains 3 patch ops" |
11
11
  | **GitHub issue** | The upstream issue on github.com/ruvnet/claude-flow. Always say "GitHub issue", never just "issue". | "GitHub issue #1111" |
12
12
  | **Defect ID** | The unique identifier for a defect: `{PREFIX}-{NNN}`. | HW-001, NS-003, RS-001 |
@@ -145,8 +145,8 @@ Save the returned GitHub issue number for the defect README.md.
145
145
  <!-- GENERATED:defect-tables:begin -->
146
146
  | Prefix | Category | Count |
147
147
  |--------|----------|-------|
148
- | CF | Config & Doctor | 2 |
149
- | DM | Daemon & Workers | 6 |
148
+ | CF | Config & Doctor | 6 |
149
+ | DM | Daemon & Workers | 5 |
150
150
  | EM | Embeddings & HNSW | 2 |
151
151
  | GV | Ghost Vectors | 1 |
152
152
  | HK | Hooks | 5 |
@@ -156,10 +156,12 @@ Save the returned GitHub issue number for the defect README.md.
156
156
  | NS | Memory Namespace | 3 |
157
157
  | RS | ruv-swarm | 1 |
158
158
  | RV | RuVector Intelligence | 3 |
159
- | SG | Settings Generator | 4 |
159
+ | SG | Settings Generator | 10 |
160
160
  | UI | Display & Cosmetic | 2 |
161
+ | WM | Wiring / Memory Integration | 9 |
162
+ | DOC | Documentation | 1 |
161
163
 
162
- ## All 35 Defects
164
+ ## All 54 Defects
163
165
 
164
166
  | ID | GitHub Issue | Severity |
165
167
  |----|-------------|----------|
@@ -168,8 +170,7 @@ Save the returned GitHub issue number for the defect README.md.
168
170
  | DM-001 | [#1116 daemon.log always 0 bytes](https://github.com/ruvnet/claude-flow/issues/1116) | Medium |
169
171
  | DM-002 | [#1138 maxCpuLoad=2.0 blocks all workers on multi-core](https://github.com/ruvnet/claude-flow/issues/1138) | Critical |
170
172
  | DM-003 | [#1077 macOS freemem() always ~0% — workers blocked](https://github.com/ruvnet/claude-flow/issues/1077) | Critical |
171
- | DM-004 | [#1139 Preload worker stub + missing from defaults](https://github.com/ruvnet/claude-flow/issues/1139) | Enhancement |
172
- | DM-005 | [#1140 Consolidation worker stub (no decay/rebuild)](https://github.com/ruvnet/claude-flow/issues/1140) | Enhancement |
173
+ | DM-004 | [#1139 Worker stubs preload + consolidation](https://github.com/ruvnet/claude-flow/issues/1139) | Enhancement |
173
174
  | EM-001 | [#1143 Embedding system ignores project config (model + HNSW dims)](https://github.com/ruvnet/claude-flow/issues/1143) | High |
174
175
  | EM-002 | [#1144 @xenova/transformers cache EACCES](https://github.com/ruvnet/claude-flow/issues/1144) | Medium |
175
176
  | GV-001 | [#1122 HNSW ghost vectors persist after memory delete](https://github.com/ruvnet/claude-flow/issues/1122) | Medium |
@@ -198,6 +199,26 @@ Save the returned GitHub issue number for the defect README.md.
198
199
  | HW-004 | [#1117 runWithTimeout rejects but does not kill child process](https://github.com/ruvnet/claude-flow/issues/1117) | Medium |
199
200
  | SG-004 | [#1181 init wizard lacks parity with init](https://github.com/ruvnet/claude-flow/issues/1181) | High |
200
201
  | SG-005 | [#1177 add 'start all' subcommand to start everything at once](https://github.com/ruvnet/claude-flow/issues/1177) | Enhancement |
202
+ | SG-006 | [#1184 Wizard captures permissionRequest hook but never assigns it + topology hardcoded](https://github.com/ruvnet/claude-flow/issues/1184) | Medium |
203
+ | WM-001 | [#829 Wire @claude-flow/memory HybridBackend into CLI](https://github.com/ruvnet/claude-flow/issues/829) | Critical |
204
+ | WM-002 | [#1185 Neural config gating (neural.enabled not consumed at runtime)](https://github.com/ruvnet/claude-flow/issues/1185) | Medium |
205
+ | WM-003 | [#1102 Activate AutoMemoryBridge in auto-memory-hook.mjs](https://github.com/ruvnet/claude-flow/issues/1102) | High |
206
+ | CF-003 | [#1186 Doctor --install native dependency resolution](https://github.com/ruvnet/claude-flow/issues/1186) | Medium |
207
+ | SG-007 | [#1188 --skip-claude / --only-claude mutate shared init options via shallow copy](https://github.com/ruvnet/claude-flow/issues/1188) | Medium |
208
+ | WM-004 | [#1190 Source hook silently falls back to JsonFileBackend](https://github.com/ruvnet/claude-flow/issues/1190) | High |
209
+ | CF-004 | [#1193 config get/export uses hand-rolled YAML parser instead of config.json](https://github.com/ruvnet/claude-flow/issues/1193) | Medium |
210
+ | SG-008 | [#1195 init should generate .claude-flow/config.json (not config.yaml)](https://github.com/ruvnet/claude-flow/issues/1195) | Enhancement |
211
+ | CF-006 | [#1197 config.yaml -> config.json migration in start.js, status.js, init.js](https://github.com/ruvnet/claude-flow/issues/1197) | Medium |
212
+ | DOC-001 | [#1201 Update upstream README.md to match patched CLI behavior](https://github.com/ruvnet/claude-flow/issues/1201) | Enhancement |
213
+ | SG-009 | [#1202 Remove --v3-mode from swarm init, make v3 the default](https://github.com/ruvnet/claude-flow/issues/1202) | High |
214
+ | CF-009 | [#1203 Upgrade MINIMAL init preset to v3 runtime defaults](https://github.com/ruvnet/claude-flow/issues/1203) | High |
215
+ | WM-007 | [#1204 Wire dead config.json keys into runtime consumers](https://github.com/ruvnet/claude-flow/issues/1204) | High |
216
+ | SG-010 | [#1205 Add CLI options to init for all config.json settings](https://github.com/ruvnet/claude-flow/issues/1205) | Enhancement |
217
+ | SG-011 | [#1206 Fix stale --topology hierarchical references](https://github.com/ruvnet/claude-flow/issues/1206) | Medium |
218
+ | WM-008 | [#1207 Upgrade AgentDB v2 to v3 (RVF backend, self-learning, witness chain)](https://github.com/ruvnet/claude-flow/issues/1207) | High |
219
+ | WM-009 | [#1209 Wire AgentDB learning loop (recordFeedback)](https://github.com/ruvnet/claude-flow/issues/1209) | High |
220
+ | WM-010 | [#1208 Wire witness chain verification at session start](https://github.com/ruvnet/claude-flow/issues/1208) | High |
221
+ | WM-011 | [#1210 Instantiate ReasoningBank controller](https://github.com/ruvnet/claude-flow/issues/1210) | High |
201
222
  <!-- GENERATED:defect-tables:end -->
202
223
 
203
224
  ---
@@ -464,15 +485,30 @@ Execution order is controlled by the 3-digit numeric prefix on each directory na
464
485
  `patch-all.sh` globs `patch/*/fix.py` which sorts lexicographically, so numeric prefixes
465
486
  execute in the correct order automatically.
466
487
 
467
- Two dependency chains exist:
488
+ Three dependency chains exist:
468
489
 
469
490
  | Chain | Directories | Reason |
470
491
  |-------|-------------|--------|
471
492
  | IN-001 -> SG-003 | `170-IN-001-*` before `270-SG-003-*` | SG-003's `old_string` contains code introduced by IN-001 |
472
493
  | NS-001 -> NS-002 -> NS-003 | `190-NS-001-*` before `200-NS-002-*` before `210-NS-003-*` | Sequential namespace fixes |
494
+ | WM-003 -> WM-004 | `370-WM-003-*` before `390-WM-004-*` | WM-004's `old_string` matches code written by WM-003 (doImport/doSync HybridBackend stubs) |
473
495
 
474
496
  All other patches are independent.
475
497
 
498
+ ### Absorbed Patches
499
+
500
+ Three patches have been absorbed into their parent patches to eliminate dead YAML
501
+ regex code that was immediately replaced by later config.json readers:
502
+
503
+ | Absorbed | Into | Reason |
504
+ |----------|------|--------|
505
+ | WM-005 | WM-001 | WM-001a now writes config.json reader directly |
506
+ | WM-006 | WM-002 | WM-002c now writes config.json reader directly; WM-002d deleted (regex fix for removed code) |
507
+ | CF-005 | CF-003 | CF-003a now writes config.json reader and updated error messages directly |
508
+
509
+ These patches retain their directories and README files for GitHub issue tracking
510
+ but their `fix.py` files are empty (no ops) and sentinels are set to `none`.
511
+
476
512
  ## Preflight & Pre-Commit Hook
477
513
 
478
514
  A git pre-commit hook at `hooks/pre-commit` runs automatically on every commit. It calls `npm run preflight:check` (read-only) and `npm test`. If anything is stale or tests fail, the commit is blocked.
@@ -498,6 +534,49 @@ Then `git add -u` to stage the regenerated files.
498
534
 
499
535
  Manual edits to generated sections (`<!-- GENERATED:*:begin/end -->`) will be overwritten.
500
536
 
537
+ ## Auto-Reapply on Update (Sentinel Watch)
538
+
539
+ When `npx` fetches a new version of `@claude-flow/cli`, `ruvector`, or `ruv-swarm`, it replaces cached files and wipes all patches. Projects using these patches need a sentinel to detect and auto-reapply.
540
+
541
+ ### Claude Code Hook (recommended for AI agents)
542
+
543
+ Add to the project's `.claude/settings.json`:
544
+
545
+ ```jsonc
546
+ {
547
+ "hooks": {
548
+ "session_start": [
549
+ {
550
+ "command": "bash /absolute/path/to/claude-flow-patch/check-patches.sh --global",
551
+ "timeout": 30000
552
+ }
553
+ ]
554
+ }
555
+ }
556
+ ```
557
+
558
+ For projects with a local install, use `--global --target .` instead.
559
+
560
+ ### Cron (headless environments)
561
+
562
+ ```bash
563
+ */5 * * * * bash /path/to/claude-flow-patch/check-patches.sh --global >> /tmp/patch-sentinel.log 2>&1
564
+ ```
565
+
566
+ ### npm postinstall (project dependency)
567
+
568
+ ```jsonc
569
+ {
570
+ "scripts": {
571
+ "postinstall": "npx --yes @sparkleideas/claude-flow-patch --target ."
572
+ }
573
+ }
574
+ ```
575
+
576
+ ### How it works
577
+
578
+ `check-patches.sh` reads each `patch/*/sentinel` file and verifies the patched strings exist in the target files. If any sentinel fails, it auto-runs `patch-all.sh` and restarts the daemon. The check is idempotent and takes ~2s when patches are intact.
579
+
501
580
  ## Key Design Decisions
502
581
 
503
582
  - **Idempotent**: `patch()` checks if `new` string is already present before replacing.
package/README.md CHANGED
@@ -10,8 +10,10 @@
10
10
  - [Dependency Order](#dependency-order)
11
11
  - [Key Design Decisions](#key-design-decisions)
12
12
  - [Repository Structure](#repository-structure)
13
+ - [Memory System](#memory-system)
13
14
  - [Defect Index](#defect-index)
14
15
  - [Init-Script Patches](#init-script-patches)
16
+ - [Auto-Reapply on Update](#auto-reapply-on-update)
15
17
  - [Compatibility](#compatibility)
16
18
  - [Links](#links)
17
19
 
@@ -19,7 +21,7 @@
19
21
 
20
22
  Community patches for [`@claude-flow/cli`](https://www.npmjs.com/package/@claude-flow/cli) **v3.1.0-alpha.41**, [`ruvector`](https://www.npmjs.com/package/ruvector), and [`ruv-swarm`](https://www.npmjs.com/package/ruv-swarm) **v1.0.20**.
21
23
 
22
- These patches fix 29 defects across 13 categories. They are applied at runtime via idempotent Python scripts that perform targeted string replacements on the npx-cached source files.
24
+ These patches fix 60 defects across 15 categories. They are applied at runtime via idempotent Python scripts that perform targeted string replacements on the npx-cached source files.
23
25
 
24
26
  <a id="quick-start"></a>
25
27
 
@@ -168,12 +170,50 @@ claude-flow-patch/
168
170
  (29 defect directories total)
169
171
  ```
170
172
 
173
+ <a id="memory-system"></a>
174
+
175
+ ## Memory System
176
+
177
+ The patched CLI runs a dual-write memory backend (SQLite + AgentDB v3) with three learning subsystems:
178
+
179
+ | Layer | What It Does | Key Patch |
180
+ |-------|-------------|-----------|
181
+ | **HybridBackend** | Dual-writes entries to SQLite (structured) + AgentDB RVF (vector search) | [WM-001](patch/350-WM-001-memory-wiring/) |
182
+ | **AutoMemoryBridge** | Syncs `~/.claude/memory/*.json` into the backend at session start/end | [WM-003](patch/370-WM-003-auto-memory-bridge/) |
183
+ | **Intelligence.cjs** | PageRank graph + trigram matching + confidence decay/boost | [IN-001](patch/170-IN-001-intelligence-stub/) |
184
+ | **AgentDB self-learning** | Records search feedback to improve future vector search relevance | [WM-009](patch/570-WM-009-agentdb-learning-loop/) |
185
+ | **Witness chain** | SHAKE-256 tamper detection on the memory database at session start | [WM-010](patch/580-WM-010-witness-chain-verify/) |
186
+ | **ReasoningBank** | Stores and retrieves successful reasoning patterns across sessions | [WM-011](patch/590-WM-011-reasoning-bank-controller/) |
187
+
188
+ Database files live in `.swarm/`:
189
+
190
+ ```
191
+ .swarm/
192
+ hybrid-memory.db # SQLite (structured queries, WAL mode)
193
+ agentdb-memory.rvf # AgentDB v3 (HNSW vectors, learning state, witness chain)
194
+ ```
195
+
196
+ All memory config is in `.claude-flow/config.json` under `memory.*`. Key settings:
197
+
198
+ ```json
199
+ {
200
+ "memory": {
201
+ "backend": "hybrid",
202
+ "agentdb": { "enableLearning": true, "vectorBackend": "rvf" },
203
+ "learningBridge": { "enabled": true, "sonaMode": "balanced" },
204
+ "memoryGraph": { "enabled": true, "pageRankDamping": 0.85 }
205
+ }
206
+ }
207
+ ```
208
+
209
+ Full documentation: **[docs/memory-system.md](docs/memory-system.md)**
210
+
171
211
  <a id="defect-index"></a>
172
212
 
173
213
  ## Defect Index
174
214
 
175
215
  <!-- GENERATED:defect-index:begin -->
176
- 35 defects across 13 categories.
216
+ 54 defects across 15 categories.
177
217
 
178
218
  ### CF -- Config & Doctor
179
219
 
@@ -181,6 +221,10 @@ claude-flow-patch/
181
221
  |----|-------------|----------|--------------|
182
222
  | [CF&#8209;001](patch/010-CF-001-doctor-yaml/) | Doctor ignores YAML config files | Low | [#1141](https://github.com/ruvnet/claude-flow/issues/1141) |
183
223
  | [CF&#8209;002](patch/020-CF-002-config-export-yaml/) | Config export shows hardcoded defaults | Medium | [#1142](https://github.com/ruvnet/claude-flow/issues/1142) |
224
+ | [CF&#8209;003](patch/380-CF-003-doctor-native-deps/) | Doctor --install native dependency resolution | Medium | [#1186](https://github.com/ruvnet/claude-flow/issues/1186) |
225
+ | [CF&#8209;004](patch/420-CF-004-config-export-json/) | config get/export uses hand-rolled YAML parser instead of config.json | Medium | [#1193](https://github.com/ruvnet/claude-flow/issues/1193) |
226
+ | [CF&#8209;006](patch/450-CF-006-config-yaml-to-json/) | config.yaml -> config.json migration in start.js, status.js, init.js | Medium | [#1197](https://github.com/ruvnet/claude-flow/issues/1197) |
227
+ | [CF&#8209;009](patch/500-CF-009-minimal-v3-defaults/) | Upgrade MINIMAL init preset to v3 runtime defaults | High | [#1203](https://github.com/ruvnet/claude-flow/issues/1203) |
184
228
 
185
229
  ### DM -- Daemon & Workers
186
230
 
@@ -189,8 +233,7 @@ claude-flow-patch/
189
233
  | [DM&#8209;001](patch/030-DM-001-daemon-log-zero/) | daemon.log always 0 bytes | Medium | [#1116](https://github.com/ruvnet/claude-flow/issues/1116) |
190
234
  | [DM&#8209;002](patch/040-DM-002-cpu-load-threshold/) | maxCpuLoad=2.0 blocks all workers on multi-core | Critical | [#1138](https://github.com/ruvnet/claude-flow/issues/1138) |
191
235
  | [DM&#8209;003](patch/050-DM-003-macos-freemem/) | macOS freemem() always ~0% — workers blocked | Critical | [#1077](https://github.com/ruvnet/claude-flow/issues/1077) |
192
- | [DM&#8209;004](patch/060-DM-004-preload-worker-stub/) | Preload worker stub + missing from defaults | Enhancement | [#1139](https://github.com/ruvnet/claude-flow/issues/1139) |
193
- | [DM&#8209;005](patch/070-DM-005-consolidation-worker-stub/) | Consolidation worker stub (no decay/rebuild) | Enhancement | [#1140](https://github.com/ruvnet/claude-flow/issues/1140) |
236
+ | [DM&#8209;004](patch/060-DM-004-worker-stubs/) | Worker stubs preload + consolidation | Enhancement | [#1139](https://github.com/ruvnet/claude-flow/issues/1139) |
194
237
  | [DM&#8209;006](patch/300-DM-006-log-rotation/) | No log rotation — logs grow unbounded | Medium | [#1114](https://github.com/ruvnet/claude-flow/issues/1114) |
195
238
 
196
239
  ### EM -- Embeddings & HNSW
@@ -267,6 +310,12 @@ claude-flow-patch/
267
310
  | [SG&#8209;003](patch/270-SG-003-init-helpers-all-paths/) | Init missing helpers for --dual, --minimal, hooks, and upgrade paths | Critical | [#1169](https://github.com/ruvnet/claude-flow/issues/1169) |
268
311
  | [SG&#8209;004](patch/320-SG-004-wizard-parity/) | init wizard lacks parity with init | High | [#1181](https://github.com/ruvnet/claude-flow/issues/1181) |
269
312
  | [SG&#8209;005](patch/330-SG-005-start-all-subcommand/) | add 'start all' subcommand to start everything at once | Enhancement | [#1177](https://github.com/ruvnet/claude-flow/issues/1177) |
313
+ | [SG&#8209;006](patch/340-SG-006-wizard-capture/) | Wizard captures permissionRequest hook but never assigns it + topology hardcoded | Medium | [#1184](https://github.com/ruvnet/claude-flow/issues/1184) |
314
+ | [SG&#8209;007](patch/385-SG-007-init-shallow-copy/) | --skip-claude / --only-claude mutate shared init options via shallow copy | Medium | [#1188](https://github.com/ruvnet/claude-flow/issues/1188) |
315
+ | [SG&#8209;008](patch/440-SG-008-init-config-json/) | init should generate .claude-flow/config.json (not config.yaml) | Enhancement | [#1195](https://github.com/ruvnet/claude-flow/issues/1195) |
316
+ | [SG&#8209;009](patch/490-SG-009-remove-v3-mode/) | Remove --v3-mode from swarm init, make v3 the default | High | [#1202](https://github.com/ruvnet/claude-flow/issues/1202) |
317
+ | [SG&#8209;010](patch/540-SG-010-init-cli-options/) | Add CLI options to init for all config.json settings | Enhancement | [#1205](https://github.com/ruvnet/claude-flow/issues/1205) |
318
+ | [SG&#8209;011](patch/550-SG-011-topology-hierarchical-refs/) | Fix stale --topology hierarchical references | Medium | [#1206](https://github.com/ruvnet/claude-flow/issues/1206) |
270
319
 
271
320
  ### UI -- Display & Cosmetic
272
321
 
@@ -274,6 +323,26 @@ claude-flow-patch/
274
323
  |----|-------------|----------|--------------|
275
324
  | [UI&#8209;001](patch/280-UI-001-intelligence-stats-crash/) | intelligence stats crashes on .toFixed() | Critical | [#1145](https://github.com/ruvnet/claude-flow/issues/1145) |
276
325
  | [UI&#8209;002](patch/290-UI-002-neural-status-not-loaded/) | neural status shows "Not loaded" | Low | [#1146](https://github.com/ruvnet/claude-flow/issues/1146) |
326
+
327
+ ### WM -- Wiring / Memory Integration
328
+
329
+ | ID | Description <img width="500" height="1" /> | Severity | GitHub&nbsp;Issue |
330
+ |----|-------------|----------|--------------|
331
+ | [WM&#8209;001](patch/350-WM-001-memory-wiring/) | Wire @claude-flow/memory HybridBackend into CLI | Critical | [#829](https://github.com/ruvnet/claude-flow/issues/829) |
332
+ | [WM&#8209;002](patch/360-WM-002-config-respect/) | Neural config gating (neural.enabled not consumed at runtime) | Medium | [#1185](https://github.com/ruvnet/claude-flow/issues/1185) |
333
+ | [WM&#8209;003](patch/370-WM-003-auto-memory-bridge/) | Activate AutoMemoryBridge in auto-memory-hook.mjs | High | [#1102](https://github.com/ruvnet/claude-flow/issues/1102) |
334
+ | [WM&#8209;004](patch/390-WM-004-source-hook-fail-loud/) | Source hook silently falls back to JsonFileBackend | High | [#1190](https://github.com/ruvnet/claude-flow/issues/1190) |
335
+ | [WM&#8209;007](patch/530-WM-007-wire-dead-config-keys/) | Wire dead config.json keys into runtime consumers | High | [#1204](https://github.com/ruvnet/claude-flow/issues/1204) |
336
+ | [WM&#8209;008](patch/560-WM-008-agentdb-v3-upgrade/) | Upgrade AgentDB v2 to v3 (RVF backend, self-learning, witness chain) | High | [#1207](https://github.com/ruvnet/claude-flow/issues/1207) |
337
+ | [WM&#8209;009](patch/570-WM-009-agentdb-learning-loop/) | Wire AgentDB learning loop (recordFeedback) | High | [#1209](https://github.com/ruvnet/claude-flow/issues/1209) |
338
+ | [WM&#8209;010](patch/580-WM-010-witness-chain-verify/) | Wire witness chain verification at session start | High | [#1208](https://github.com/ruvnet/claude-flow/issues/1208) |
339
+ | [WM&#8209;011](patch/590-WM-011-reasoning-bank-controller/) | Instantiate ReasoningBank controller | High | [#1210](https://github.com/ruvnet/claude-flow/issues/1210) |
340
+
341
+ ### DOC -- Documentation
342
+
343
+ | ID | Description <img width="500" height="1" /> | Severity | GitHub&nbsp;Issue |
344
+ |----|-------------|----------|--------------|
345
+ | [DOC&#8209;001](patch/480-DOC-001-readme-docs/) | Update upstream README.md to match patched CLI behavior | Enhancement | [#1201](https://github.com/ruvnet/claude-flow/issues/1201) |
277
346
  <!-- GENERATED:defect-index:end -->
278
347
 
279
348
  <a id="init-script-patches"></a>
@@ -329,6 +398,89 @@ These patches fix the **generator functions** inside the npm package (e.g., `gen
329
398
 
330
399
  Additionally, `init upgrade` only force-overwrites 3 "critical" helpers (`auto-memory-hook.mjs`, `hook-handler.cjs`, `intelligence.cjs`). The other 30+ helper files (shell scripts for daemon management, health monitoring, security scanning, swarm hooks, etc.) are only copied on fresh `init`, not on upgrade. If these are missing, use Option A above.
331
400
 
401
+ <a id="auto-reapply-on-update"></a>
402
+
403
+ ## Auto-Reapply on Update
404
+
405
+ When `npx` fetches a new version of `@claude-flow/cli`, `ruvector`, or `ruv-swarm`, it replaces the cached files and wipes all patches. Use one of these approaches to detect this and auto-reapply.
406
+
407
+ ### Option A: Claude Code Hook (Recommended for AI Agents)
408
+
409
+ Add a `session_start` hook to your project's `.claude/settings.json`. This runs `check-patches.sh` every time Claude starts a session — it detects missing patches and reapplies automatically:
410
+
411
+ ```jsonc
412
+ // .claude/settings.json
413
+ {
414
+ "hooks": {
415
+ "session_start": [
416
+ {
417
+ "command": "bash /path/to/claude-flow-patch/check-patches.sh --global",
418
+ "timeout": 30000
419
+ }
420
+ ]
421
+ }
422
+ }
423
+ ```
424
+
425
+ Replace `/path/to/claude-flow-patch` with the absolute path to your clone. If your project also has a local install, use `--global --target .` instead.
426
+
427
+ `check-patches.sh` is fast and idempotent — if patches are intact it prints `OK` and exits. If any sentinel fails, it runs `patch-all.sh`, restarts the daemon, and reports what happened.
428
+
429
+ ### Option B: Cron / systemd Timer
430
+
431
+ Poll every 5 minutes with cron:
432
+
433
+ ```bash
434
+ # crontab -e
435
+ */5 * * * * bash /path/to/claude-flow-patch/check-patches.sh --global >> /tmp/patch-sentinel.log 2>&1
436
+ ```
437
+
438
+ Or with a systemd user timer:
439
+
440
+ ```ini
441
+ # ~/.config/systemd/user/patch-sentinel.timer
442
+ [Timer]
443
+ OnBootSec=60
444
+ OnUnitActiveSec=300
445
+
446
+ [Install]
447
+ WantedBy=timers.target
448
+ ```
449
+
450
+ ```ini
451
+ # ~/.config/systemd/user/patch-sentinel.service
452
+ [Service]
453
+ Type=oneshot
454
+ ExecStart=/bin/bash /path/to/claude-flow-patch/check-patches.sh --global
455
+ ```
456
+
457
+ ```bash
458
+ systemctl --user enable --now patch-sentinel.timer
459
+ ```
460
+
461
+ ### Option C: npm postinstall Hook
462
+
463
+ If you install `@claude-flow/cli` as a project dependency, add a postinstall script that reapplies patches whenever `npm install` refreshes it:
464
+
465
+ ```jsonc
466
+ // package.json
467
+ {
468
+ "scripts": {
469
+ "postinstall": "npx --yes @sparkleideas/claude-flow-patch --target ."
470
+ }
471
+ }
472
+ ```
473
+
474
+ ### How the Sentinel Works
475
+
476
+ `check-patches.sh` reads the `sentinel` file in each `patch/*/` directory and checks whether the patched strings are present in the target files. If any check fails:
477
+
478
+ 1. Prints a warning identifying the likely cause (npx cache update)
479
+ 2. Runs `patch-all.sh` to reapply all patches
480
+ 3. Stops and restarts the claude-flow daemon so it picks up the patched code
481
+
482
+ The entire check takes under 2 seconds when patches are intact. Reapplication takes 5-10 seconds.
483
+
332
484
  <a id="compatibility"></a>
333
485
 
334
486
  ## Compatibility
package/check-patches.sh CHANGED
@@ -59,6 +59,13 @@ resolve_path() {
59
59
  case "$pkg" in
60
60
  ruvector) echo "$rv_base/$relpath" ;;
61
61
  ruv-swarm) echo "$rs_base/$relpath" ;;
62
+ @claude-flow/*)
63
+ # base is <nm>/@claude-flow/cli/dist/src → derive <nm>/@claude-flow/<pkg>
64
+ local cf_scope
65
+ cf_scope="$(cd "$base/../../../.." 2>/dev/null && pwd)"
66
+ local subpkg="${pkg#@claude-flow/}"
67
+ echo "$cf_scope/@claude-flow/$subpkg/$relpath"
68
+ ;;
62
69
  *) echo "$base/$relpath" ;;
63
70
  esac
64
71
  }
@@ -93,27 +100,39 @@ check_sentinels_for_install() {
93
100
  continue
94
101
  fi
95
102
 
96
- # Read package line (default: claude-flow)
103
+ # Default package context (can be switched by "package:" directives in the file)
97
104
  local pkg="claude-flow"
98
- local pkg_line
99
- pkg_line=$(grep -m1 '^package:' "$sentinel_file" 2>/dev/null || true)
100
- if [ -n "$pkg_line" ]; then
101
- pkg="${pkg_line#package:}"
102
- pkg="${pkg#"${pkg%%[![:space:]]*}"}" # trim leading whitespace
103
- pkg="${pkg%%[[:space:]]*}" # trim trailing whitespace
104
- fi
105
105
 
106
- # Skip if required package not installed
107
- case "$pkg" in
108
- ruvector) [ -z "$rv_cli" ] && continue ;;
109
- ruv-swarm) [ -z "$rs_root" ] && continue ;;
110
- esac
106
+ # Check if first package: line is for an optional package we don't have
107
+ local first_pkg_line
108
+ first_pkg_line=$(grep -m1 '^package:' "$sentinel_file" 2>/dev/null || true)
109
+ if [ -n "$first_pkg_line" ]; then
110
+ local first_pkg="${first_pkg_line#package:}"
111
+ first_pkg="${first_pkg#"${first_pkg%%[![:space:]]*}"}"
112
+ first_pkg="${first_pkg%%[[:space:]]*}"
113
+ # Only skip the whole file if ALL lines are for a single unavailable package
114
+ local has_non_pkg_default=false
115
+ grep -v '^package:' "$sentinel_file" | grep -v '^$' | grep -v '^none$' | head -1 | grep -q '.' && has_non_pkg_default=true
116
+ if ! $has_non_pkg_default; then
117
+ case "$first_pkg" in
118
+ ruvector) [ -z "$rv_cli" ] && continue ;;
119
+ ruv-swarm) [ -z "$rs_root" ] && continue ;;
120
+ esac
121
+ fi
122
+ fi
111
123
 
112
- # Process each line
124
+ # Process each line — "package:" switches the current package context
113
125
  while IFS= read -r line; do
114
126
  line="${line#"${line%%[![:space:]]*}"}" # trim leading whitespace
115
127
  [[ -z "$line" ]] && continue
116
- [[ "$line" == package:* ]] && continue
128
+
129
+ # package: directive switches context for subsequent grep/absent lines
130
+ if [[ "$line" == package:* ]]; then
131
+ pkg="${line#package:}"
132
+ pkg="${pkg#"${pkg%%[![:space:]]*}"}" # trim leading whitespace
133
+ pkg="${pkg%%[[:space:]]*}" # trim trailing whitespace
134
+ continue
135
+ fi
117
136
 
118
137
  if [[ "$line" == "none" ]]; then
119
138
  continue
@@ -130,7 +149,8 @@ check_sentinels_for_install() {
130
149
  local pattern="${BASH_REMATCH[1]}"
131
150
  local filepath
132
151
  filepath=$(resolve_path "$base" "$rv_base" "$rs_root" "$pkg" "${BASH_REMATCH[2]}")
133
- if ! grep -q "$pattern" "$filepath" 2>/dev/null; then
152
+ # Skip if target file doesn't exist (e.g. umbrella layout missing .claude/helpers/)
153
+ if [ -f "$filepath" ] && ! grep -q "$pattern" "$filepath" 2>/dev/null; then
134
154
  all_ok=false
135
155
  fi
136
156
  fi
@@ -158,6 +178,60 @@ for entry in "${INSTALLS[@]}"; do
158
178
  fi
159
179
  done
160
180
 
181
+ # ── Syntax validation: node --check on ALL patched JS files ──
182
+ # Runs independently of sentinel checks so SyntaxErrors are always caught.
183
+
184
+ syntax_failed=false
185
+ for entry in "${INSTALLS[@]}"; do
186
+ IFS=$'\t' read -r dist_src version rv_cli rs_root writable <<< "$entry"
187
+
188
+ # Derive @claude-flow scope from dist/src path
189
+ cf_scope="$(cd "$dist_src/../../../.." 2>/dev/null && pwd)"
190
+
191
+ SYNTAX_FILES=(
192
+ # @claude-flow/cli
193
+ "$dist_src/commands/config.js"
194
+ "$dist_src/commands/start.js"
195
+ "$dist_src/commands/init.js"
196
+ "$dist_src/commands/doctor.js"
197
+ "$dist_src/commands/status.js"
198
+ "$dist_src/commands/swarm.js"
199
+ "$dist_src/commands/daemon.js"
200
+ "$dist_src/commands/hooks.js"
201
+ "$dist_src/commands/memory.js"
202
+ "$dist_src/commands/neural.js"
203
+ "$dist_src/memory/memory-initializer.js"
204
+ "$dist_src/memory/intelligence.js"
205
+ "$dist_src/init/executor.js"
206
+ "$dist_src/init/helpers-generator.js"
207
+ "$dist_src/init/settings-generator.js"
208
+ "$dist_src/init/types.js"
209
+ "$dist_src/init/claudemd-generator.js"
210
+ "$dist_src/mcp-tools/hooks-tools.js"
211
+ "$dist_src/mcp-tools/memory-tools.js"
212
+ "$dist_src/mcp-tools/embeddings-tools.js"
213
+ "$dist_src/services/worker-daemon.js"
214
+ "$dist_src/services/headless-worker-executor.js"
215
+ "$dist_src/index.js"
216
+ # @claude-flow/memory (WM-008)
217
+ "$cf_scope/@claude-flow/memory/dist/agentdb-backend.js"
218
+ # @claude-flow/neural (WM-008)
219
+ "$cf_scope/@claude-flow/neural/dist/reasoning-bank.js"
220
+ # @claude-flow/shared (WM-008)
221
+ "$cf_scope/@claude-flow/shared/dist/core/config/defaults.js"
222
+ )
223
+ for js_file in "${SYNTAX_FILES[@]}"; do
224
+ [ -f "$js_file" ] || continue
225
+ if ! node --check "$js_file" 2>/tmp/syntax-check-err.$$; then
226
+ echo "[PATCHES] SYNTAX ERROR: $js_file"
227
+ cat /tmp/syntax-check-err.$$
228
+ syntax_failed=true
229
+ any_failed=true
230
+ fi
231
+ rm -f /tmp/syntax-check-err.$$
232
+ done
233
+ done
234
+
161
235
  VERSION="${first_version:-unknown}"
162
236
 
163
237
  if ! $any_failed; then
@@ -11,5 +11,7 @@
11
11
  "MM": "Memory Management",
12
12
  "HK": "Hooks",
13
13
  "RV": "RuVector Intelligence",
14
- "RS": "ruv-swarm"
14
+ "RS": "ruv-swarm",
15
+ "WM": "Wiring / Memory Integration",
16
+ "DOC": "Documentation"
15
17
  }
package/lib/common.py CHANGED
@@ -67,6 +67,7 @@ WD = services + "/worker-daemon.js" if services else ""
67
67
  DJ = commands + "/daemon.js" if commands else ""
68
68
  DOC = commands + "/doctor.js" if commands else ""
69
69
  MI = memory + "/memory-initializer.js" if memory else ""
70
+ INTEL = memory + "/intelligence.js" if memory else ""
70
71
 
71
72
  MCP_MEMORY = base + "/mcp-tools/memory-tools.js" if base else ""
72
73
  MCP_HOOKS = base + "/mcp-tools/hooks-tools.js" if base else ""
@@ -82,13 +83,27 @@ SETTINGS_GEN = init + "/settings-generator.js" if init else ""
82
83
  HELPERS_GEN = init + "/helpers-generator.js" if init else ""
83
84
  EXECUTOR = init + "/executor.js" if init else ""
84
85
  TYPES = init + "/types.js" if init else ""
86
+ SWARM_CMD = commands + "/swarm.js" if commands else ""
87
+ CLI_INDEX = base + "/index.js" if base else ""
88
+ CLAUDEMD_GEN = init + "/claudemd-generator.js" if init else ""
85
89
  INIT_CMD = commands + "/init.js" if commands else ""
86
90
  START_CMD = commands + "/start.js" if commands else ""
91
+ STATUS_CMD = commands + "/status.js" if commands else ""
87
92
  CMDS_INDEX = commands + "/index.js" if commands else ""
88
93
 
89
94
  # Source helpers (shipped with package, copied by writeHelpers when source dir found)
90
95
  _pkg_root = os.path.dirname(os.path.dirname(base)) if base else ""
96
+ _cf_scope = os.path.dirname(_pkg_root) if _pkg_root else ""
97
+ AGENTDB_BACKEND = os.path.join(_cf_scope, "memory", "dist", "agentdb-backend.js") if _cf_scope else ""
98
+ MEMORY_PKG_JSON = os.path.join(_cf_scope, "memory", "package.json") if _cf_scope else ""
91
99
  SRC_HOOK_HANDLER = os.path.join(_pkg_root, ".claude", "helpers", "hook-handler.cjs") if _pkg_root else ""
100
+ SRC_AUTO_MEMORY_HOOK = os.path.join(_pkg_root, ".claude", "helpers", "auto-memory-hook.mjs") if _pkg_root else ""
101
+ README_MD = os.path.join(_pkg_root, "README.md") if _pkg_root else ""
102
+
103
+ # Cross-package targets (sibling packages under node_modules/)
104
+ _nm_root = os.path.dirname(_cf_scope) if _cf_scope else ""
105
+ NEURAL_REASONING_BANK = os.path.join(_cf_scope, "neural", "dist", "reasoning-bank.js") if _cf_scope else ""
106
+ SHARED_DEFAULTS = os.path.join(_cf_scope, "shared", "dist", "core", "config", "defaults.js") if _cf_scope else ""
92
107
 
93
108
  # RuVector (separate package, path set by patch-all.sh)
94
109
  ruvector_cli = os.environ.get("RUVECTOR_CLI", "")
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sparkleideas/claude-flow-patch",
3
- "version": "3.1.0-alpha.44.patch.10",
3
+ "version": "3.1.0-alpha.44.patch.11",
4
4
  "description": "Patch toolkit for @claude-flow/cli init/runtime defects with verify and post-init repair commands",
5
5
  "scripts": {
6
6
  "preflight": "node scripts/preflight.mjs",
7
7
  "preflight:check": "node scripts/preflight.mjs --check",
8
8
  "prepublishOnly": "npm run preflight && npm test",
9
- "test": "node --test tests/*.test.mjs",
9
+ "test": "node --test --test-concurrency=1 tests/*.test.mjs",
10
10
  "package": "bash npm/package.sh",
11
11
  "package:dry": "bash npm/package.sh --dry-run",
12
12
  "publish:npm": "bash npm/publish.sh",
@@ -82,5 +82,8 @@
82
82
  "ruv-swarm",
83
83
  "automation"
84
84
  ],
85
- "packageManager": "npm@10"
85
+ "packageManager": "npm@10",
86
+ "dependencies": {
87
+ "@sparkleideas/claude-flow-guidance": "file:../../claude-flow-guidance-implementation"
88
+ }
86
89
  }
@@ -1 +1 @@
1
- grep "config.yaml" commands/doctor.js
1
+ grep "configPath.endsWith('.json')" commands/doctor.js
@@ -8,4 +8,4 @@ Add `readYamlConfig()` helper function. Merge YAML config values over defaults i
8
8
  ## Files Patched
9
9
  - commands/config.js
10
10
  ## Ops
11
- 3 ops in fix.py
11
+ 2 ops in fix.py (16a removed — bundler already provides readYamlConfig)
@@ -3,49 +3,9 @@
3
3
  # NOTE: This patch was originally applied via sed, not via patch().
4
4
  # The patch() calls below replicate the same changes.
5
5
 
6
- # Add fs/path imports after existing imports
7
- patch("16a: config.js add readYamlConfig",
8
- CONF,
9
- "const getCommand = {",
10
- """import { readFileSync, existsSync } from 'fs';
11
- import { join } from 'path';
12
-
13
- // Helper to read config.yaml if it exists
14
- function readYamlConfig() {
15
- const configPath = join(process.cwd(), '.claude-flow', 'config.yaml');
16
- if (!existsSync(configPath)) { return {}; }
17
- try {
18
- const content = readFileSync(configPath, 'utf8');
19
- const config = {};
20
- const lines = content.split('\\n');
21
- let currentSection = null;
22
- for (const line of lines) {
23
- const trimmed = line.trim();
24
- if (!trimmed || trimmed.startsWith('#')) continue;
25
- if (!trimmed.includes(':')) continue;
26
- const indent = line.match(/^\\s*/)[0].length;
27
- if (indent === 0) {
28
- const [key, ...rest] = trimmed.split(':');
29
- const value = rest.join(':').trim();
30
- if (value && value !== '') {
31
- config[key.trim()] = value.replace(/^["']|["']$/g, '');
32
- } else {
33
- currentSection = key.trim();
34
- config[currentSection] = {};
35
- }
36
- } else if (currentSection && indent > 0) {
37
- const [key, ...rest] = trimmed.split(':');
38
- const value = rest.join(':').trim();
39
- if (value && value !== '') {
40
- config[currentSection][key.trim()] = value.replace(/^["']|["']$/g, '');
41
- }
42
- }
43
- }
44
- return config;
45
- } catch (error) { return {}; }
46
- }
47
-
48
- const getCommand = {""")
6
+ # Op 16a removed: the upstream bundler already emits readYamlConfig() twice.
7
+ # CF-004 (order 420) upgrades the first copy to read config.json and removes the second.
8
+ # Inserting a third copy here caused a re-application conflict on every run.
49
9
 
50
10
  # Update getCommand to merge YAML config
51
11
  patch("16b: config get merge yaml",