kynjal-cli 4.0.0 → 4.0.1
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/dist/src/appliance/gguf-engine.d.ts +91 -0
- package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
- package/dist/src/appliance/gguf-engine.js +286 -525
- package/dist/src/appliance/gguf-engine.js.map +1 -1
- package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
- package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
- package/dist/src/appliance/ruvllm-bridge.js +203 -403
- package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
- package/dist/src/appliance/rvfa-builder.d.ts +44 -0
- package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-builder.js +154 -208
- package/dist/src/appliance/rvfa-builder.js.map +1 -1
- package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
- package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-distribution.js +260 -423
- package/dist/src/appliance/rvfa-distribution.js.map +1 -1
- package/dist/src/appliance/rvfa-format.d.ts +111 -0
- package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-format.js +128 -200
- package/dist/src/appliance/rvfa-format.js.map +1 -1
- package/dist/src/appliance/rvfa-runner.d.ts +69 -0
- package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-runner.js +168 -304
- package/dist/src/appliance/rvfa-runner.js.map +1 -1
- package/dist/src/appliance/rvfa-signing.d.ts +123 -0
- package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-signing.js +173 -295
- package/dist/src/appliance/rvfa-signing.js.map +1 -1
- package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
- package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
- package/dist/src/benchmarks/pretrain/index.js +331 -542
- package/dist/src/benchmarks/pretrain/index.js.map +1 -1
- package/dist/src/commands/agent.js +574 -697
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.js +1218 -1548
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/appliance-advanced.js +158 -267
- package/dist/src/commands/appliance-advanced.js.map +1 -1
- package/dist/src/commands/appliance.js +318 -493
- package/dist/src/commands/appliance.js.map +1 -1
- package/dist/src/commands/benchmark.js +372 -523
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/claims.js +274 -364
- package/dist/src/commands/claims.js.map +1 -1
- package/dist/src/commands/cleanup.js +113 -157
- package/dist/src/commands/cleanup.js.map +1 -1
- package/dist/src/commands/completions.js +477 -118
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +237 -303
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.js +487 -596
- package/dist/src/commands/daemon.js.map +1 -1
- package/dist/src/commands/deployment.js +194 -275
- package/dist/src/commands/deployment.js.map +1 -1
- package/dist/src/commands/doctor.js +504 -686
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/embeddings.js +1293 -1543
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/guidance.js +449 -596
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind.js +854 -938
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.js +3112 -3519
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +115 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +126 -308
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.js +788 -940
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/issues.js +383 -558
- package/dist/src/commands/issues.js.map +1 -1
- package/dist/src/commands/mcp.js +493 -605
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.js +833 -1026
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +282 -347
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.js +1289 -1563
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.js +497 -643
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/plugins.js +668 -841
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/process.js +392 -447
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/progress.js +162 -256
- package/dist/src/commands/progress.js.map +1 -1
- package/dist/src/commands/providers.js +150 -220
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/route.js +520 -665
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/ruvector/backup.js +505 -651
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js +349 -401
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/import.js +224 -266
- package/dist/src/commands/ruvector/import.js.map +1 -1
- package/dist/src/commands/ruvector/index.js +37 -75
- package/dist/src/commands/ruvector/index.js.map +1 -1
- package/dist/src/commands/ruvector/init.js +336 -359
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js +335 -322
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js +375 -431
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/setup.js +703 -117
- package/dist/src/commands/ruvector/setup.js.map +1 -1
- package/dist/src/commands/ruvector/status.js +364 -419
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/security.js +485 -608
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.js +504 -626
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.js +267 -364
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.js +380 -486
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +408 -488
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.js +423 -538
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/transfer-store.js +322 -412
- package/dist/src/commands/transfer-store.js.map +1 -1
- package/dist/src/commands/update.js +196 -291
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/workflow.js +386 -486
- package/dist/src/commands/workflow.js.map +1 -1
- package/dist/src/config-adapter.d.ts +15 -0
- package/dist/src/config-adapter.d.ts.map +1 -0
- package/dist/src/config-adapter.js +38 -39
- package/dist/src/config-adapter.js.map +1 -1
- package/dist/src/index.d.ts +77 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +309 -411
- package/dist/src/index.js.map +1 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
- package/dist/src/infrastructure/in-memory-repositories.js +246 -507
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts +25 -0
- package/dist/src/init/claudemd-generator.d.ts.map +1 -0
- package/dist/src/init/claudemd-generator.js +368 -78
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts +41 -0
- package/dist/src/init/executor.d.ts.map +1 -0
- package/dist/src/init/executor.js +1307 -996
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts +60 -0
- package/dist/src/init/helpers-generator.d.ts.map +1 -0
- package/dist/src/init/helpers-generator.js +657 -12
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/index.d.ts +1 -1
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +1 -1
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/mcp-generator.js +33 -37
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.js +76 -77
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.js +801 -3
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +1 -1
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +76 -59
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-client.d.ts +92 -0
- package/dist/src/mcp-client.d.ts.map +1 -0
- package/dist/src/mcp-client.js +81 -125
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts +161 -0
- package/dist/src/mcp-server.d.ts.map +1 -0
- package/dist/src/mcp-server.js +470 -757
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +391 -492
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/agentdb-tools.js +332 -533
- package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.js +172 -236
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.d.ts +83 -0
- package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
- package/dist/src/mcp-tools/auto-install.js +80 -142
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +252 -375
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +473 -565
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +197 -272
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.js +500 -572
- package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
- package/dist/src/mcp-tools/daa-tools.js +286 -364
- package/dist/src/mcp-tools/daa-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +582 -693
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +260 -311
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +350 -505
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +315 -412
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +420 -480
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/progress-tools.js +204 -278
- package/dist/src/mcp-tools/progress-tools.js.map +1 -1
- package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
- package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
- package/dist/src/mcp-tools/security-tools.js +297 -429
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +185 -234
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +207 -260
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +276 -325
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +270 -336
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +148 -196
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +186 -333
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/types.d.ts +31 -0
- package/dist/src/mcp-tools/types.d.ts.map +1 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/workflow-tools.js +405 -450
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.d.ts +295 -0
- package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
- package/dist/src/memory/ewc-consolidation.js +190 -303
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts +338 -0
- package/dist/src/memory/intelligence.d.ts.map +1 -0
- package/dist/src/memory/intelligence.js +569 -794
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +407 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge.js +1170 -1640
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +412 -0
- package/dist/src/memory/memory-initializer.d.ts.map +1 -0
- package/dist/src/memory/memory-initializer.js +1836 -1851
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +227 -0
- package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
- package/dist/src/memory/sona-optimizer.js +199 -329
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/output.d.ts +2 -2
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +242 -272
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.d.ts +51 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +140 -187
- package/dist/src/parser.js.map +1 -1
- package/dist/src/plugins/manager.d.ts +133 -0
- package/dist/src/plugins/manager.d.ts.map +1 -0
- package/dist/src/plugins/manager.js +285 -521
- package/dist/src/plugins/manager.js.map +1 -1
- package/dist/src/plugins/store/discovery.d.ts +88 -0
- package/dist/src/plugins/store/discovery.d.ts.map +1 -0
- package/dist/src/plugins/store/discovery.js +271 -358
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/index.d.ts +76 -0
- package/dist/src/plugins/store/index.d.ts.map +1 -0
- package/dist/src/plugins/store/index.js +48 -105
- package/dist/src/plugins/store/index.js.map +1 -1
- package/dist/src/plugins/store/search.d.ts +46 -0
- package/dist/src/plugins/store/search.d.ts.map +1 -0
- package/dist/src/plugins/store/search.js +69 -107
- package/dist/src/plugins/store/search.js.map +1 -1
- package/dist/src/plugins/store/types.d.ts +274 -0
- package/dist/src/plugins/store/types.d.ts.map +1 -0
- package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
- package/dist/src/plugins/tests/standalone-test.js +172 -223
- package/dist/src/plugins/tests/standalone-test.js.map +1 -1
- package/dist/src/plugins/tests/test-plugin-store.js +190 -228
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
- package/dist/src/production/circuit-breaker.d.ts +101 -0
- package/dist/src/production/circuit-breaker.d.ts.map +1 -0
- package/dist/src/production/circuit-breaker.js +62 -126
- package/dist/src/production/circuit-breaker.js.map +1 -1
- package/dist/src/production/error-handler.d.ts +92 -0
- package/dist/src/production/error-handler.d.ts.map +1 -0
- package/dist/src/production/error-handler.js +86 -156
- package/dist/src/production/error-handler.js.map +1 -1
- package/dist/src/production/monitoring.d.ts +161 -0
- package/dist/src/production/monitoring.d.ts.map +1 -0
- package/dist/src/production/monitoring.js +139 -220
- package/dist/src/production/monitoring.js.map +1 -1
- package/dist/src/production/rate-limiter.d.ts +80 -0
- package/dist/src/production/rate-limiter.d.ts.map +1 -0
- package/dist/src/production/rate-limiter.js +74 -93
- package/dist/src/production/rate-limiter.js.map +1 -1
- package/dist/src/production/retry.d.ts +48 -0
- package/dist/src/production/retry.d.ts.map +1 -0
- package/dist/src/production/retry.js +75 -167
- package/dist/src/production/retry.js.map +1 -1
- package/dist/src/prompt.d.ts +44 -0
- package/dist/src/prompt.d.ts.map +1 -0
- package/dist/src/prompt.js +436 -560
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/runtime/headless.d.ts +60 -0
- package/dist/src/runtime/headless.d.ts.map +1 -0
- package/dist/src/runtime/headless.js +197 -286
- package/dist/src/runtime/headless.js.map +1 -1
- package/dist/src/ruvector/agent-wasm.d.ts +182 -0
- package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/agent-wasm.js +156 -351
- package/dist/src/ruvector/agent-wasm.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +145 -232
- package/dist/src/ruvector/ast-analyzer.js.map +1 -1
- package/dist/src/ruvector/coverage-router.d.ts +160 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +287 -419
- package/dist/src/ruvector/coverage-router.js.map +1 -1
- package/dist/src/ruvector/coverage-tools.js +56 -101
- package/dist/src/ruvector/coverage-tools.js.map +1 -1
- package/dist/src/ruvector/diff-classifier.d.ts +175 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +324 -451
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
- package/dist/src/ruvector/enhanced-model-router.js +260 -336
- package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
- package/dist/src/ruvector/flash-attention.d.ts +195 -0
- package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
- package/dist/src/ruvector/flash-attention.js +223 -254
- package/dist/src/ruvector/flash-attention.js.map +1 -1
- package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +486 -680
- package/dist/src/ruvector/graph-analyzer.js.map +1 -1
- package/dist/src/ruvector/index.d.ts +40 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +36 -106
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.d.ts +218 -0
- package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
- package/dist/src/ruvector/lora-adapter.js +155 -248
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/ruvector/model-router.d.ts +220 -0
- package/dist/src/ruvector/model-router.d.ts.map +1 -0
- package/dist/src/ruvector/model-router.js +175 -248
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/moe-router.d.ts +206 -0
- package/dist/src/ruvector/moe-router.d.ts.map +1 -0
- package/dist/src/ruvector/moe-router.js +228 -286
- package/dist/src/ruvector/moe-router.js.map +1 -1
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +257 -338
- package/dist/src/ruvector/q-learning-router.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
- package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/ruvllm-wasm.js +270 -434
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
- package/dist/src/ruvector/semantic-router.d.ts +77 -0
- package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
- package/dist/src/ruvector/semantic-router.js +60 -67
- package/dist/src/ruvector/semantic-router.js.map +1 -1
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +119 -205
- package/dist/src/ruvector/vector-db.js.map +1 -1
- package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
- package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
- package/dist/src/services/agentic-flow-bridge.js +32 -105
- package/dist/src/services/agentic-flow-bridge.js.map +1 -1
- package/dist/src/services/claim-service.d.ts +204 -0
- package/dist/src/services/claim-service.d.ts.map +1 -0
- package/dist/src/services/claim-service.js +615 -940
- package/dist/src/services/claim-service.js.map +1 -1
- package/dist/src/services/container-worker-pool.d.ts +197 -0
- package/dist/src/services/container-worker-pool.d.ts.map +1 -0
- package/dist/src/services/container-worker-pool.js +398 -666
- package/dist/src/services/container-worker-pool.js.map +1 -1
- package/dist/src/services/headless-worker-executor.d.ts +304 -0
- package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
- package/dist/src/services/headless-worker-executor.js +441 -467
- package/dist/src/services/headless-worker-executor.js.map +1 -1
- package/dist/src/services/index.d.ts +4 -4
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +4 -4
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/registry-api.d.ts +58 -0
- package/dist/src/services/registry-api.d.ts.map +1 -0
- package/dist/src/services/registry-api.js +92 -200
- package/dist/src/services/registry-api.js.map +1 -1
- package/dist/src/services/ruvector-training.d.ts +222 -0
- package/dist/src/services/ruvector-training.d.ts.map +1 -0
- package/dist/src/services/ruvector-training.js +257 -337
- package/dist/src/services/ruvector-training.js.map +1 -1
- package/dist/src/services/worker-daemon.d.ts +228 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +591 -849
- package/dist/src/services/worker-daemon.js.map +1 -1
- package/dist/src/services/worker-queue.d.ts +194 -0
- package/dist/src/services/worker-queue.d.ts.map +1 -0
- package/dist/src/services/worker-queue.js +331 -548
- package/dist/src/services/worker-queue.js.map +1 -1
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.d.ts.map +1 -0
- package/dist/src/suggest.js +45 -55
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +29 -37
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/transfer/deploy-seraphine.js +128 -155
- package/dist/src/transfer/deploy-seraphine.js.map +1 -1
- package/dist/src/transfer/export.d.ts +25 -0
- package/dist/src/transfer/export.d.ts.map +1 -0
- package/dist/src/transfer/export.js +84 -142
- package/dist/src/transfer/export.js.map +1 -1
- package/dist/src/transfer/index.d.ts +1 -1
- package/dist/src/transfer/index.d.ts.map +1 -1
- package/dist/src/transfer/index.js +0 -2
- package/dist/src/transfer/index.js.map +1 -1
- package/dist/src/transfer/ipfs/client.d.ts +109 -0
- package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/client.js +187 -337
- package/dist/src/transfer/ipfs/client.js.map +1 -1
- package/dist/src/transfer/ipfs/upload.d.ts +95 -0
- package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/upload.js +288 -434
- package/dist/src/transfer/ipfs/upload.js.map +1 -1
- package/dist/src/transfer/models/seraphine.d.ts +72 -0
- package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
- package/dist/src/transfer/models/seraphine.js +55 -55
- package/dist/src/transfer/models/seraphine.js.map +1 -1
- package/dist/src/transfer/serialization/cfp.d.ts +49 -0
- package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
- package/dist/src/transfer/serialization/cfp.js +30 -31
- package/dist/src/transfer/serialization/cfp.js.map +1 -1
- package/dist/src/transfer/storage/gcs.d.ts +82 -0
- package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
- package/dist/src/transfer/storage/gcs.js +165 -232
- package/dist/src/transfer/storage/gcs.js.map +1 -1
- package/dist/src/transfer/store/discovery.d.ts +84 -0
- package/dist/src/transfer/store/discovery.d.ts.map +1 -0
- package/dist/src/transfer/store/discovery.js +239 -349
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/transfer/store/download.d.ts +70 -0
- package/dist/src/transfer/store/download.d.ts.map +1 -0
- package/dist/src/transfer/store/download.js +243 -365
- package/dist/src/transfer/store/download.js.map +1 -1
- package/dist/src/transfer/store/index.d.ts +84 -0
- package/dist/src/transfer/store/index.d.ts.map +1 -0
- package/dist/src/transfer/store/index.js +63 -130
- package/dist/src/transfer/store/index.js.map +1 -1
- package/dist/src/transfer/store/publish.d.ts +76 -0
- package/dist/src/transfer/store/publish.d.ts.map +1 -0
- package/dist/src/transfer/store/publish.js +184 -258
- package/dist/src/transfer/store/publish.js.map +1 -1
- package/dist/src/transfer/store/registry.js +50 -72
- package/dist/src/transfer/store/registry.js.map +1 -1
- package/dist/src/transfer/store/search.d.ts +54 -0
- package/dist/src/transfer/store/search.d.ts.map +1 -0
- package/dist/src/transfer/store/search.js +64 -96
- package/dist/src/transfer/store/search.js.map +1 -1
- package/dist/src/transfer/store/tests/standalone-test.js +174 -231
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
- package/dist/src/transfer/test-seraphine.js +95 -130
- package/dist/src/transfer/test-seraphine.js.map +1 -1
- package/dist/src/transfer/tests/test-store.js +194 -239
- package/dist/src/transfer/tests/test-store.js.map +1 -1
- package/dist/src/transfer/types.d.ts +245 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/types.d.ts +198 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +26 -55
- package/dist/src/types.js.map +1 -1
- package/dist/src/update/checker.d.ts +34 -0
- package/dist/src/update/checker.d.ts.map +1 -0
- package/dist/src/update/checker.js +106 -183
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.d.ts +32 -0
- package/dist/src/update/executor.d.ts.map +1 -0
- package/dist/src/update/executor.js +135 -198
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.d.ts +33 -0
- package/dist/src/update/index.d.ts.map +1 -0
- package/dist/src/update/index.js +38 -85
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.d.ts +20 -0
- package/dist/src/update/rate-limiter.d.ts.map +1 -0
- package/dist/src/update/rate-limiter.js +19 -31
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.d.ts +17 -0
- package/dist/src/update/validator.d.ts.map +1 -0
- package/dist/src/update/validator.js +38 -64
- package/dist/src/update/validator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -2,70 +2,14 @@
|
|
|
2
2
|
* Init Executor
|
|
3
3
|
* Main execution logic for V3 initialization
|
|
4
4
|
*/
|
|
5
|
-
var __assign = (this && this.__assign) || function () {
|
|
6
|
-
__assign = Object.assign || function(t) {
|
|
7
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
-
s = arguments[i];
|
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
-
t[p] = s[p];
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
};
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
-
function step(op) {
|
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (_) try {
|
|
32
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
-
switch (op[0]) {
|
|
35
|
-
case 0: case 1: t = op; break;
|
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
46
|
-
}
|
|
47
|
-
op = body.call(thisArg, _);
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
53
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
54
|
-
if (ar || !(i in from)) {
|
|
55
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
56
|
-
ar[i] = from[i];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
60
|
-
};
|
|
61
5
|
import * as fs from 'fs';
|
|
62
6
|
import * as path from 'path';
|
|
63
7
|
import { fileURLToPath } from 'url';
|
|
64
8
|
import { createRequire } from 'module';
|
|
65
9
|
import { dirname } from 'path';
|
|
66
10
|
// ESM-compatible __dirname
|
|
67
|
-
|
|
68
|
-
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = dirname(__filename);
|
|
69
13
|
import { detectPlatform, DEFAULT_INIT_OPTIONS } from './types.js';
|
|
70
14
|
import { generateSettingsJson, generateSettings } from './settings-generator.js';
|
|
71
15
|
import { generateMCPJson } from './mcp-generator.js';
|
|
@@ -75,7 +19,7 @@ import { generateClaudeMd } from './claudemd-generator.js';
|
|
|
75
19
|
/**
|
|
76
20
|
* Skills to copy based on configuration
|
|
77
21
|
*/
|
|
78
|
-
|
|
22
|
+
const SKILLS_MAP = {
|
|
79
23
|
core: [
|
|
80
24
|
'swarm-orchestration',
|
|
81
25
|
'swarm-advanced',
|
|
@@ -86,8 +30,8 @@ var SKILLS_MAP = {
|
|
|
86
30
|
'stream-chain',
|
|
87
31
|
'skill-builder',
|
|
88
32
|
],
|
|
89
|
-
browser: ['browser'],
|
|
90
|
-
dualMode: ['dual-mode'],
|
|
33
|
+
browser: ['browser'], // agent-browser integration
|
|
34
|
+
dualMode: ['dual-mode'], // Claude Code + Codex hybrid execution
|
|
91
35
|
agentdb: [
|
|
92
36
|
'agentdb-advanced',
|
|
93
37
|
'agentdb-learning',
|
|
@@ -120,12 +64,12 @@ var SKILLS_MAP = {
|
|
|
120
64
|
'v3-performance-optimization',
|
|
121
65
|
'v3-security-overhaul',
|
|
122
66
|
'v3-swarm-coordination',
|
|
123
|
-
]
|
|
67
|
+
],
|
|
124
68
|
};
|
|
125
69
|
/**
|
|
126
70
|
* Commands to copy based on configuration
|
|
127
71
|
*/
|
|
128
|
-
|
|
72
|
+
const COMMANDS_MAP = {
|
|
129
73
|
core: ['claude-flow-help.md', 'claude-flow-swarm.md', 'claude-flow-memory.md'],
|
|
130
74
|
analysis: ['analysis'],
|
|
131
75
|
automation: ['automation'],
|
|
@@ -133,20 +77,20 @@ var COMMANDS_MAP = {
|
|
|
133
77
|
hooks: ['hooks'],
|
|
134
78
|
monitoring: ['monitoring'],
|
|
135
79
|
optimization: ['optimization'],
|
|
136
|
-
sparc: ['sparc']
|
|
80
|
+
sparc: ['sparc'],
|
|
137
81
|
};
|
|
138
82
|
/**
|
|
139
83
|
* Agents to copy based on configuration
|
|
140
84
|
*/
|
|
141
|
-
|
|
85
|
+
const AGENTS_MAP = {
|
|
142
86
|
core: ['core'],
|
|
143
87
|
consensus: ['consensus'],
|
|
144
88
|
github: ['github'],
|
|
145
89
|
hiveMind: ['hive-mind'],
|
|
146
90
|
sparc: ['sparc'],
|
|
147
91
|
swarm: ['swarm'],
|
|
148
|
-
browser: ['browser'],
|
|
149
|
-
dualMode: ['dual-mode'],
|
|
92
|
+
browser: ['browser'], // agent-browser integration
|
|
93
|
+
dualMode: ['dual-mode'], // Claude Code + Codex hybrid execution
|
|
150
94
|
// V3-specific agents
|
|
151
95
|
v3: ['v3'],
|
|
152
96
|
optimization: ['optimization'],
|
|
@@ -165,12 +109,12 @@ var AGENTS_MAP = {
|
|
|
165
109
|
payments: ['payments'],
|
|
166
110
|
data: ['data'],
|
|
167
111
|
design: ['design'],
|
|
168
|
-
custom: ['custom']
|
|
112
|
+
custom: ['custom'],
|
|
169
113
|
};
|
|
170
114
|
/**
|
|
171
115
|
* Directory structure to create
|
|
172
116
|
*/
|
|
173
|
-
|
|
117
|
+
const DIRECTORIES = {
|
|
174
118
|
claude: [
|
|
175
119
|
'.claude',
|
|
176
120
|
'.claude/skills',
|
|
@@ -186,115 +130,82 @@ var DIRECTORIES = {
|
|
|
186
130
|
'.claude-flow/hooks',
|
|
187
131
|
'.claude-flow/agents',
|
|
188
132
|
'.claude-flow/workflows',
|
|
189
|
-
]
|
|
133
|
+
],
|
|
190
134
|
};
|
|
191
135
|
/**
|
|
192
136
|
* Execute initialization
|
|
193
137
|
*/
|
|
194
|
-
export function executeInit(options) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
_a.sent();
|
|
266
|
-
_a.label = 16;
|
|
267
|
-
case 16:
|
|
268
|
-
if (!options.components.runtime) return [3 /*break*/, 18];
|
|
269
|
-
return [4 /*yield*/, writeRuntimeConfig(targetDir, options, result)];
|
|
270
|
-
case 17:
|
|
271
|
-
_a.sent();
|
|
272
|
-
_a.label = 18;
|
|
273
|
-
case 18:
|
|
274
|
-
if (!options.components.statusline) return [3 /*break*/, 20];
|
|
275
|
-
return [4 /*yield*/, writeInitialMetrics(targetDir, options, result)];
|
|
276
|
-
case 19:
|
|
277
|
-
_a.sent();
|
|
278
|
-
_a.label = 20;
|
|
279
|
-
case 20:
|
|
280
|
-
if (!options.components.claudeMd) return [3 /*break*/, 22];
|
|
281
|
-
return [4 /*yield*/, writeClaudeMd(targetDir, options, result)];
|
|
282
|
-
case 21:
|
|
283
|
-
_a.sent();
|
|
284
|
-
_a.label = 22;
|
|
285
|
-
case 22:
|
|
286
|
-
// Count enabled hooks
|
|
287
|
-
result.summary.hooksEnabled = countEnabledHooks(options);
|
|
288
|
-
return [3 /*break*/, 24];
|
|
289
|
-
case 23:
|
|
290
|
-
error_1 = _a.sent();
|
|
291
|
-
result.success = false;
|
|
292
|
-
result.errors.push(error_1 instanceof Error ? error_1.message : String(error_1));
|
|
293
|
-
return [3 /*break*/, 24];
|
|
294
|
-
case 24: return [2 /*return*/, result];
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
});
|
|
138
|
+
export async function executeInit(options) {
|
|
139
|
+
// Detect platform
|
|
140
|
+
const platform = detectPlatform();
|
|
141
|
+
const result = {
|
|
142
|
+
success: true,
|
|
143
|
+
platform,
|
|
144
|
+
created: {
|
|
145
|
+
directories: [],
|
|
146
|
+
files: [],
|
|
147
|
+
},
|
|
148
|
+
skipped: [],
|
|
149
|
+
errors: [],
|
|
150
|
+
summary: {
|
|
151
|
+
skillsCount: 0,
|
|
152
|
+
commandsCount: 0,
|
|
153
|
+
agentsCount: 0,
|
|
154
|
+
hooksEnabled: 0,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
const targetDir = options.targetDir;
|
|
158
|
+
try {
|
|
159
|
+
// Create directory structure
|
|
160
|
+
await createDirectories(targetDir, options, result);
|
|
161
|
+
// Generate and write settings.json
|
|
162
|
+
if (options.components.settings) {
|
|
163
|
+
await writeSettings(targetDir, options, result);
|
|
164
|
+
}
|
|
165
|
+
// Generate and write .mcp.json
|
|
166
|
+
if (options.components.mcp) {
|
|
167
|
+
await writeMCPConfig(targetDir, options, result);
|
|
168
|
+
}
|
|
169
|
+
// Copy skills
|
|
170
|
+
if (options.components.skills) {
|
|
171
|
+
await copySkills(targetDir, options, result);
|
|
172
|
+
}
|
|
173
|
+
// Copy commands
|
|
174
|
+
if (options.components.commands) {
|
|
175
|
+
await copyCommands(targetDir, options, result);
|
|
176
|
+
}
|
|
177
|
+
// Copy agents
|
|
178
|
+
if (options.components.agents) {
|
|
179
|
+
await copyAgents(targetDir, options, result);
|
|
180
|
+
}
|
|
181
|
+
// Generate helpers
|
|
182
|
+
if (options.components.helpers) {
|
|
183
|
+
await writeHelpers(targetDir, options, result);
|
|
184
|
+
}
|
|
185
|
+
// Generate statusline
|
|
186
|
+
if (options.components.statusline) {
|
|
187
|
+
await writeStatusline(targetDir, options, result);
|
|
188
|
+
}
|
|
189
|
+
// Generate runtime config
|
|
190
|
+
if (options.components.runtime) {
|
|
191
|
+
await writeRuntimeConfig(targetDir, options, result);
|
|
192
|
+
}
|
|
193
|
+
// Create initial metrics for statusline (prevents "all zeros" display)
|
|
194
|
+
if (options.components.statusline) {
|
|
195
|
+
await writeInitialMetrics(targetDir, options, result);
|
|
196
|
+
}
|
|
197
|
+
// Generate CLAUDE.md
|
|
198
|
+
if (options.components.claudeMd) {
|
|
199
|
+
await writeClaudeMd(targetDir, options, result);
|
|
200
|
+
}
|
|
201
|
+
// Count enabled hooks
|
|
202
|
+
result.summary.hooksEnabled = countEnabledHooks(options);
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
result.success = false;
|
|
206
|
+
result.errors.push(error instanceof Error ? error.message : String(error));
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
298
209
|
}
|
|
299
210
|
/**
|
|
300
211
|
* Merge new settings into existing settings.json
|
|
@@ -302,10 +213,9 @@ export function executeInit(options) {
|
|
|
302
213
|
* Uses platform-specific commands for Mac, Linux, and Windows
|
|
303
214
|
*/
|
|
304
215
|
function mergeSettingsForUpgrade(existing) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
var isWindows = platform.os === 'windows';
|
|
216
|
+
const merged = { ...existing };
|
|
217
|
+
const platform = detectPlatform();
|
|
218
|
+
const isWindows = platform.os === 'windows';
|
|
309
219
|
// Platform-specific command wrappers
|
|
310
220
|
// Windows: Use PowerShell-compatible commands
|
|
311
221
|
// Mac/Linux: Use bash-compatible commands with 2>/dev/null
|
|
@@ -313,46 +223,51 @@ function mergeSettingsForUpgrade(existing) {
|
|
|
313
223
|
// TeammateIdle/TaskCompleted are not valid Claude Code hook events and caused warnings.
|
|
314
224
|
// Agent Teams hook config lives in claudeFlow.agentTeams.hooks instead.
|
|
315
225
|
// 1. Merge env vars (preserve existing, add new)
|
|
316
|
-
|
|
317
|
-
merged.env =
|
|
226
|
+
const existingEnv = existing.env || {};
|
|
227
|
+
merged.env = {
|
|
228
|
+
...existingEnv,
|
|
229
|
+
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: '1',
|
|
230
|
+
CLAUDE_FLOW_V3_ENABLED: existingEnv.CLAUDE_FLOW_V3_ENABLED || 'true',
|
|
231
|
+
CLAUDE_FLOW_HOOKS_ENABLED: existingEnv.CLAUDE_FLOW_HOOKS_ENABLED || 'true',
|
|
232
|
+
};
|
|
318
233
|
// 2. Merge hooks (preserve existing, add new Agent Teams + auto-memory hooks)
|
|
319
|
-
|
|
320
|
-
merged.hooks =
|
|
234
|
+
const existingHooks = existing.hooks || {};
|
|
235
|
+
merged.hooks = { ...existingHooks };
|
|
321
236
|
// Cross-platform auto-memory hook commands that resolve paths via git root.
|
|
322
237
|
// Uses node -e with git rev-parse so hooks work regardless of CWD (#1259, #1284).
|
|
323
|
-
|
|
238
|
+
const gitRootResolver = "var c=require('child_process'),p=require('path'),u=require('url'),r;"
|
|
324
239
|
+ "try{r=c.execSync('git rev-parse --show-toplevel',{encoding:'utf8'}).trim()}"
|
|
325
240
|
+ 'catch(e){r=process.cwd()}';
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
241
|
+
const autoMemoryScript = '.claude/helpers/auto-memory-hook.mjs';
|
|
242
|
+
const autoMemoryImportCmd = `node -e "${gitRootResolver}var f=p.join(r,'${autoMemoryScript}');import(u.pathToFileURL(f).href)" import`;
|
|
243
|
+
const autoMemorySyncCmd = `node -e "${gitRootResolver}var f=p.join(r,'${autoMemoryScript}');import(u.pathToFileURL(f).href)" sync`;
|
|
329
244
|
// Add auto-memory import to SessionStart (if not already present)
|
|
330
|
-
|
|
331
|
-
|
|
245
|
+
const sessionStartHooks = existingHooks.SessionStart;
|
|
246
|
+
const hasAutoMemoryImport = sessionStartHooks?.some(group => group.hooks?.some(h => h.command?.includes('auto-memory-hook')));
|
|
332
247
|
if (!hasAutoMemoryImport) {
|
|
333
|
-
|
|
248
|
+
const startHooks = merged.hooks;
|
|
334
249
|
if (!startHooks.SessionStart) {
|
|
335
250
|
startHooks.SessionStart = [{ hooks: [] }];
|
|
336
251
|
}
|
|
337
|
-
|
|
252
|
+
const startGroup = startHooks.SessionStart[0];
|
|
338
253
|
if (!startGroup.hooks)
|
|
339
254
|
startGroup.hooks = [];
|
|
340
255
|
startGroup.hooks.push({
|
|
341
256
|
type: 'command',
|
|
342
257
|
command: autoMemoryImportCmd,
|
|
343
258
|
timeout: 6000,
|
|
344
|
-
continueOnError: true
|
|
259
|
+
continueOnError: true,
|
|
345
260
|
});
|
|
346
261
|
}
|
|
347
262
|
// Add auto-memory sync to SessionEnd (if not already present)
|
|
348
|
-
|
|
349
|
-
|
|
263
|
+
const sessionEndHooks = existingHooks.SessionEnd;
|
|
264
|
+
const hasAutoMemorySync = sessionEndHooks?.some(group => group.hooks?.some(h => h.command?.includes('auto-memory-hook')));
|
|
350
265
|
if (!hasAutoMemorySync) {
|
|
351
|
-
|
|
266
|
+
const endHooks = merged.hooks;
|
|
352
267
|
if (!endHooks.SessionEnd) {
|
|
353
268
|
endHooks.SessionEnd = [{ hooks: [] }];
|
|
354
269
|
}
|
|
355
|
-
|
|
270
|
+
const endGroup = endHooks.SessionEnd[0];
|
|
356
271
|
if (!endGroup.hooks)
|
|
357
272
|
endGroup.hooks = [];
|
|
358
273
|
// Insert at beginning so sync runs before other cleanup
|
|
@@ -360,7 +275,7 @@ function mergeSettingsForUpgrade(existing) {
|
|
|
360
275
|
type: 'command',
|
|
361
276
|
command: autoMemorySyncCmd,
|
|
362
277
|
timeout: 8000,
|
|
363
|
-
continueOnError: true
|
|
278
|
+
continueOnError: true,
|
|
364
279
|
});
|
|
365
280
|
}
|
|
366
281
|
// NOTE: TeammateIdle and TaskCompleted are NOT valid Claude Code hook events.
|
|
@@ -371,17 +286,22 @@ function mergeSettingsForUpgrade(existing) {
|
|
|
371
286
|
// Their configuration lives in claudeFlow.agentTeams.hooks instead.
|
|
372
287
|
// 3. Fix statusLine config (remove invalid fields, ensure correct format)
|
|
373
288
|
// Claude Code only supports: type, command, padding
|
|
374
|
-
|
|
289
|
+
const existingStatusLine = existing.statusLine;
|
|
375
290
|
if (existingStatusLine) {
|
|
376
291
|
merged.statusLine = {
|
|
377
292
|
type: 'command',
|
|
378
|
-
command: existingStatusLine.command ||
|
|
293
|
+
command: existingStatusLine.command || `node -e "var c=require('child_process'),p=require('path'),r;try{r=c.execSync('git rev-parse --show-toplevel',{encoding:'utf8'}).trim()}catch(e){r=process.cwd()}var s=p.join(r,'.claude/helpers/statusline.cjs');process.argv.splice(1,0,s);require(s)"`,
|
|
294
|
+
// Remove invalid fields: refreshMs, enabled (not supported by Claude Code)
|
|
379
295
|
};
|
|
380
296
|
}
|
|
381
297
|
// 4. Merge claudeFlow settings (preserve existing, add agentTeams + memory)
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
merged.claudeFlow =
|
|
298
|
+
const existingClaudeFlow = existing.claudeFlow || {};
|
|
299
|
+
const existingMemory = existingClaudeFlow.memory || {};
|
|
300
|
+
merged.claudeFlow = {
|
|
301
|
+
...existingClaudeFlow,
|
|
302
|
+
version: existingClaudeFlow.version || '3.0.0',
|
|
303
|
+
enabled: existingClaudeFlow.enabled !== false,
|
|
304
|
+
agentTeams: {
|
|
385
305
|
enabled: true,
|
|
386
306
|
teammateMode: 'auto',
|
|
387
307
|
taskListEnabled: true,
|
|
@@ -390,13 +310,20 @@ function mergeSettingsForUpgrade(existing) {
|
|
|
390
310
|
autoAssignOnIdle: true,
|
|
391
311
|
trainPatternsOnComplete: true,
|
|
392
312
|
notifyLeadOnComplete: true,
|
|
393
|
-
sharedMemoryNamespace: 'agent-teams'
|
|
313
|
+
sharedMemoryNamespace: 'agent-teams',
|
|
394
314
|
},
|
|
395
315
|
hooks: {
|
|
396
316
|
teammateIdle: { enabled: true, autoAssign: true, checkTaskList: true },
|
|
397
|
-
taskCompleted: { enabled: true, trainPatterns: true, notifyLead: true }
|
|
398
|
-
}
|
|
399
|
-
},
|
|
317
|
+
taskCompleted: { enabled: true, trainPatterns: true, notifyLead: true },
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
memory: {
|
|
321
|
+
...existingMemory,
|
|
322
|
+
learningBridge: existingMemory.learningBridge ?? { enabled: true },
|
|
323
|
+
memoryGraph: existingMemory.memoryGraph ?? { enabled: true },
|
|
324
|
+
agentScopes: existingMemory.agentScopes ?? { enabled: true },
|
|
325
|
+
},
|
|
326
|
+
};
|
|
400
327
|
return merged;
|
|
401
328
|
}
|
|
402
329
|
/**
|
|
@@ -405,190 +332,200 @@ function mergeSettingsForUpgrade(existing) {
|
|
|
405
332
|
* @param targetDir - Target directory
|
|
406
333
|
* @param upgradeSettings - If true, merge new settings into existing settings.json
|
|
407
334
|
*/
|
|
408
|
-
export function executeUpgrade(targetDir, upgradeSettings) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
335
|
+
export async function executeUpgrade(targetDir, upgradeSettings = false) {
|
|
336
|
+
const result = {
|
|
337
|
+
success: true,
|
|
338
|
+
updated: [],
|
|
339
|
+
created: [],
|
|
340
|
+
preserved: [],
|
|
341
|
+
errors: [],
|
|
342
|
+
settingsUpdated: [],
|
|
343
|
+
};
|
|
344
|
+
try {
|
|
345
|
+
// Ensure required directories exist
|
|
346
|
+
const dirs = [
|
|
347
|
+
'.claude/helpers',
|
|
348
|
+
'.claude-flow/metrics',
|
|
349
|
+
'.claude-flow/security',
|
|
350
|
+
'.claude-flow/learning',
|
|
351
|
+
];
|
|
352
|
+
for (const dir of dirs) {
|
|
353
|
+
const fullPath = path.join(targetDir, dir);
|
|
354
|
+
if (!fs.existsSync(fullPath)) {
|
|
355
|
+
fs.mkdirSync(fullPath, { recursive: true });
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// 0. ALWAYS update critical helpers (force overwrite)
|
|
359
|
+
const sourceHelpersForUpgrade = findSourceHelpersDir();
|
|
360
|
+
if (sourceHelpersForUpgrade) {
|
|
361
|
+
const criticalHelpers = ['auto-memory-hook.mjs', 'hook-handler.cjs', 'intelligence.cjs'];
|
|
362
|
+
for (const helperName of criticalHelpers) {
|
|
363
|
+
const targetPath = path.join(targetDir, '.claude', 'helpers', helperName);
|
|
364
|
+
const sourcePath = path.join(sourceHelpersForUpgrade, helperName);
|
|
365
|
+
if (fs.existsSync(sourcePath)) {
|
|
366
|
+
if (fs.existsSync(targetPath)) {
|
|
367
|
+
result.updated.push(`.claude/helpers/${helperName}`);
|
|
433
368
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
if (sourceHelpersForUpgrade) {
|
|
437
|
-
criticalHelpers = ['auto-memory-hook.mjs', 'hook-handler.cjs', 'intelligence.cjs'];
|
|
438
|
-
for (_a = 0, criticalHelpers_1 = criticalHelpers; _a < criticalHelpers_1.length; _a++) {
|
|
439
|
-
helperName = criticalHelpers_1[_a];
|
|
440
|
-
targetPath = path.join(targetDir, '.claude', 'helpers', helperName);
|
|
441
|
-
sourcePath = path.join(sourceHelpersForUpgrade, helperName);
|
|
442
|
-
if (fs.existsSync(sourcePath)) {
|
|
443
|
-
if (fs.existsSync(targetPath)) {
|
|
444
|
-
result.updated.push(".claude/helpers/" + helperName);
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
result.created.push(".claude/helpers/" + helperName);
|
|
448
|
-
}
|
|
449
|
-
fs.copyFileSync(sourcePath, targetPath);
|
|
450
|
-
try {
|
|
451
|
-
fs.chmodSync(targetPath, '755');
|
|
452
|
-
}
|
|
453
|
-
catch (_f) { }
|
|
454
|
-
}
|
|
369
|
+
else {
|
|
370
|
+
result.created.push(`.claude/helpers/${helperName}`);
|
|
455
371
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
'hook-handler.cjs': generateHookHandler(),
|
|
460
|
-
'intelligence.cjs': generateIntelligenceStub(),
|
|
461
|
-
'auto-memory-hook.mjs': generateAutoMemoryHook()
|
|
462
|
-
};
|
|
463
|
-
for (_b = 0, _c = Object.entries(generatedCritical); _b < _c.length; _b++) {
|
|
464
|
-
_d = _c[_b], helperName = _d[0], content = _d[1];
|
|
465
|
-
targetPath = path.join(targetDir, '.claude', 'helpers', helperName);
|
|
466
|
-
if (fs.existsSync(targetPath)) {
|
|
467
|
-
result.updated.push(".claude/helpers/" + helperName);
|
|
468
|
-
}
|
|
469
|
-
else {
|
|
470
|
-
result.created.push(".claude/helpers/" + helperName);
|
|
471
|
-
}
|
|
472
|
-
fs.writeFileSync(targetPath, content, 'utf-8');
|
|
473
|
-
try {
|
|
474
|
-
fs.chmodSync(targetPath, '755');
|
|
475
|
-
}
|
|
476
|
-
catch (_g) { }
|
|
372
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
373
|
+
try {
|
|
374
|
+
fs.chmodSync(targetPath, '755');
|
|
477
375
|
}
|
|
376
|
+
catch { }
|
|
478
377
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
if (!fs.existsSync(progressPath)) {
|
|
493
|
-
progress = {
|
|
494
|
-
version: '3.0.0',
|
|
495
|
-
initialized: new Date().toISOString(),
|
|
496
|
-
domains: { completed: 0, total: 5, status: 'INITIALIZING' },
|
|
497
|
-
ddd: { progress: 0, modules: 0, totalFiles: 0, totalLines: 0 },
|
|
498
|
-
swarm: { activeAgents: 0, maxAgents: 15, topology: 'hierarchical-mesh' },
|
|
499
|
-
learning: { status: 'READY', patternsLearned: 0, sessionsCompleted: 0 },
|
|
500
|
-
_note: 'Metrics will update as you use Ruflo'
|
|
501
|
-
};
|
|
502
|
-
fs.writeFileSync(progressPath, JSON.stringify(progress, null, 2), 'utf-8');
|
|
503
|
-
result.created.push('.claude-flow/metrics/v3-progress.json');
|
|
504
|
-
}
|
|
505
|
-
else {
|
|
506
|
-
result.preserved.push('.claude-flow/metrics/v3-progress.json');
|
|
507
|
-
}
|
|
508
|
-
activityPath = path.join(metricsDir, 'swarm-activity.json');
|
|
509
|
-
if (!fs.existsSync(activityPath)) {
|
|
510
|
-
activity = {
|
|
511
|
-
timestamp: new Date().toISOString(),
|
|
512
|
-
processes: { agentic_flow: 0, mcp_server: 0, estimated_agents: 0 },
|
|
513
|
-
swarm: { active: false, agent_count: 0, coordination_active: false },
|
|
514
|
-
integration: { agentic_flow_active: false, mcp_active: false },
|
|
515
|
-
_initialized: true
|
|
516
|
-
};
|
|
517
|
-
fs.writeFileSync(activityPath, JSON.stringify(activity, null, 2), 'utf-8');
|
|
518
|
-
result.created.push('.claude-flow/metrics/swarm-activity.json');
|
|
519
|
-
}
|
|
520
|
-
else {
|
|
521
|
-
result.preserved.push('.claude-flow/metrics/swarm-activity.json');
|
|
522
|
-
}
|
|
523
|
-
learningPath = path.join(metricsDir, 'learning.json');
|
|
524
|
-
if (!fs.existsSync(learningPath)) {
|
|
525
|
-
learning = {
|
|
526
|
-
initialized: new Date().toISOString(),
|
|
527
|
-
routing: { accuracy: 0, decisions: 0 },
|
|
528
|
-
patterns: { shortTerm: 0, longTerm: 0, quality: 0 },
|
|
529
|
-
sessions: { total: 0, current: null },
|
|
530
|
-
_note: 'Intelligence grows as you use Ruflo'
|
|
531
|
-
};
|
|
532
|
-
fs.writeFileSync(learningPath, JSON.stringify(learning, null, 2), 'utf-8');
|
|
533
|
-
result.created.push('.claude-flow/metrics/learning.json');
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
// Source not found (npx with broken paths) — use generated fallbacks
|
|
382
|
+
const generatedCritical = {
|
|
383
|
+
'hook-handler.cjs': generateHookHandler(),
|
|
384
|
+
'intelligence.cjs': generateIntelligenceStub(),
|
|
385
|
+
'auto-memory-hook.mjs': generateAutoMemoryHook(),
|
|
386
|
+
};
|
|
387
|
+
for (const [helperName, content] of Object.entries(generatedCritical)) {
|
|
388
|
+
const targetPath = path.join(targetDir, '.claude', 'helpers', helperName);
|
|
389
|
+
if (fs.existsSync(targetPath)) {
|
|
390
|
+
result.updated.push(`.claude/helpers/${helperName}`);
|
|
534
391
|
}
|
|
535
392
|
else {
|
|
536
|
-
result.
|
|
393
|
+
result.created.push(`.claude/helpers/${helperName}`);
|
|
537
394
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
initialized: new Date().toISOString(),
|
|
542
|
-
status: 'PENDING',
|
|
543
|
-
cvesFixed: 0,
|
|
544
|
-
totalCves: 3,
|
|
545
|
-
lastScan: null,
|
|
546
|
-
_note: 'Run: npx @claude-flow/cli@latest security scan'
|
|
547
|
-
};
|
|
548
|
-
fs.writeFileSync(auditPath, JSON.stringify(audit, null, 2), 'utf-8');
|
|
549
|
-
result.created.push('.claude-flow/security/audit-status.json');
|
|
395
|
+
fs.writeFileSync(targetPath, content, 'utf-8');
|
|
396
|
+
try {
|
|
397
|
+
fs.chmodSync(targetPath, '755');
|
|
550
398
|
}
|
|
551
|
-
|
|
552
|
-
|
|
399
|
+
catch { }
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
// 1. ALWAYS update statusline helper (force overwrite)
|
|
403
|
+
const statuslinePath = path.join(targetDir, '.claude', 'helpers', 'statusline.cjs');
|
|
404
|
+
// Use default options with statusline config
|
|
405
|
+
const upgradeOptions = {
|
|
406
|
+
...DEFAULT_INIT_OPTIONS,
|
|
407
|
+
targetDir,
|
|
408
|
+
force: true,
|
|
409
|
+
statusline: {
|
|
410
|
+
...DEFAULT_INIT_OPTIONS.statusline,
|
|
411
|
+
refreshInterval: 5000,
|
|
412
|
+
},
|
|
413
|
+
};
|
|
414
|
+
const statuslineContent = generateStatuslineScript(upgradeOptions);
|
|
415
|
+
if (fs.existsSync(statuslinePath)) {
|
|
416
|
+
result.updated.push('.claude/helpers/statusline.cjs');
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
result.created.push('.claude/helpers/statusline.cjs');
|
|
420
|
+
}
|
|
421
|
+
fs.writeFileSync(statuslinePath, statuslineContent, 'utf-8');
|
|
422
|
+
// 2. Create MISSING metrics files only (preserve existing data)
|
|
423
|
+
const metricsDir = path.join(targetDir, '.claude-flow', 'metrics');
|
|
424
|
+
const securityDir = path.join(targetDir, '.claude-flow', 'security');
|
|
425
|
+
// v3-progress.json
|
|
426
|
+
const progressPath = path.join(metricsDir, 'v3-progress.json');
|
|
427
|
+
if (!fs.existsSync(progressPath)) {
|
|
428
|
+
const progress = {
|
|
429
|
+
version: '3.0.0',
|
|
430
|
+
initialized: new Date().toISOString(),
|
|
431
|
+
domains: { completed: 0, total: 5, status: 'INITIALIZING' },
|
|
432
|
+
ddd: { progress: 0, modules: 0, totalFiles: 0, totalLines: 0 },
|
|
433
|
+
swarm: { activeAgents: 0, maxAgents: 15, topology: 'hierarchical-mesh' },
|
|
434
|
+
learning: { status: 'READY', patternsLearned: 0, sessionsCompleted: 0 },
|
|
435
|
+
_note: 'Metrics will update as you use Ruflo'
|
|
436
|
+
};
|
|
437
|
+
fs.writeFileSync(progressPath, JSON.stringify(progress, null, 2), 'utf-8');
|
|
438
|
+
result.created.push('.claude-flow/metrics/v3-progress.json');
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
result.preserved.push('.claude-flow/metrics/v3-progress.json');
|
|
442
|
+
}
|
|
443
|
+
// swarm-activity.json
|
|
444
|
+
const activityPath = path.join(metricsDir, 'swarm-activity.json');
|
|
445
|
+
if (!fs.existsSync(activityPath)) {
|
|
446
|
+
const activity = {
|
|
447
|
+
timestamp: new Date().toISOString(),
|
|
448
|
+
processes: { agentic_flow: 0, mcp_server: 0, estimated_agents: 0 },
|
|
449
|
+
swarm: { active: false, agent_count: 0, coordination_active: false },
|
|
450
|
+
integration: { agentic_flow_active: false, mcp_active: false },
|
|
451
|
+
_initialized: true
|
|
452
|
+
};
|
|
453
|
+
fs.writeFileSync(activityPath, JSON.stringify(activity, null, 2), 'utf-8');
|
|
454
|
+
result.created.push('.claude-flow/metrics/swarm-activity.json');
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
result.preserved.push('.claude-flow/metrics/swarm-activity.json');
|
|
458
|
+
}
|
|
459
|
+
// learning.json
|
|
460
|
+
const learningPath = path.join(metricsDir, 'learning.json');
|
|
461
|
+
if (!fs.existsSync(learningPath)) {
|
|
462
|
+
const learning = {
|
|
463
|
+
initialized: new Date().toISOString(),
|
|
464
|
+
routing: { accuracy: 0, decisions: 0 },
|
|
465
|
+
patterns: { shortTerm: 0, longTerm: 0, quality: 0 },
|
|
466
|
+
sessions: { total: 0, current: null },
|
|
467
|
+
_note: 'Intelligence grows as you use Ruflo'
|
|
468
|
+
};
|
|
469
|
+
fs.writeFileSync(learningPath, JSON.stringify(learning, null, 2), 'utf-8');
|
|
470
|
+
result.created.push('.claude-flow/metrics/learning.json');
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
result.preserved.push('.claude-flow/metrics/learning.json');
|
|
474
|
+
}
|
|
475
|
+
// audit-status.json
|
|
476
|
+
const auditPath = path.join(securityDir, 'audit-status.json');
|
|
477
|
+
if (!fs.existsSync(auditPath)) {
|
|
478
|
+
const audit = {
|
|
479
|
+
initialized: new Date().toISOString(),
|
|
480
|
+
status: 'PENDING',
|
|
481
|
+
cvesFixed: 0,
|
|
482
|
+
totalCves: 3,
|
|
483
|
+
lastScan: null,
|
|
484
|
+
_note: 'Run: npx @claude-flow/cli@latest security scan'
|
|
485
|
+
};
|
|
486
|
+
fs.writeFileSync(auditPath, JSON.stringify(audit, null, 2), 'utf-8');
|
|
487
|
+
result.created.push('.claude-flow/security/audit-status.json');
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
result.preserved.push('.claude-flow/security/audit-status.json');
|
|
491
|
+
}
|
|
492
|
+
// 3. Merge settings if requested
|
|
493
|
+
if (upgradeSettings) {
|
|
494
|
+
const settingsPath = path.join(targetDir, '.claude', 'settings.json');
|
|
495
|
+
if (fs.existsSync(settingsPath)) {
|
|
496
|
+
try {
|
|
497
|
+
const existingSettings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
|
|
498
|
+
const mergedSettings = mergeSettingsForUpgrade(existingSettings);
|
|
499
|
+
fs.writeFileSync(settingsPath, JSON.stringify(mergedSettings, null, 2), 'utf-8');
|
|
500
|
+
result.updated.push('.claude/settings.json');
|
|
501
|
+
result.settingsUpdated = [
|
|
502
|
+
'env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS',
|
|
503
|
+
'hooks.SessionStart (auto-memory import)',
|
|
504
|
+
'hooks.SessionEnd (auto-memory sync)',
|
|
505
|
+
'hooks.TeammateIdle (removed — not a valid Claude Code hook)',
|
|
506
|
+
'hooks.TaskCompleted (removed — not a valid Claude Code hook)',
|
|
507
|
+
'claudeFlow.agentTeams',
|
|
508
|
+
'claudeFlow.memory (learningBridge, memoryGraph, agentScopes)',
|
|
509
|
+
];
|
|
553
510
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
settingsPath = path.join(targetDir, '.claude', 'settings.json');
|
|
557
|
-
if (fs.existsSync(settingsPath)) {
|
|
558
|
-
try {
|
|
559
|
-
existingSettings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
|
|
560
|
-
mergedSettings = mergeSettingsForUpgrade(existingSettings);
|
|
561
|
-
fs.writeFileSync(settingsPath, JSON.stringify(mergedSettings, null, 2), 'utf-8');
|
|
562
|
-
result.updated.push('.claude/settings.json');
|
|
563
|
-
result.settingsUpdated = [
|
|
564
|
-
'env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS',
|
|
565
|
-
'hooks.SessionStart (auto-memory import)',
|
|
566
|
-
'hooks.SessionEnd (auto-memory sync)',
|
|
567
|
-
'hooks.TeammateIdle (removed — not a valid Claude Code hook)',
|
|
568
|
-
'hooks.TaskCompleted (removed — not a valid Claude Code hook)',
|
|
569
|
-
'claudeFlow.agentTeams',
|
|
570
|
-
'claudeFlow.memory (learningBridge, memoryGraph, agentScopes)',
|
|
571
|
-
];
|
|
572
|
-
}
|
|
573
|
-
catch (settingsError) {
|
|
574
|
-
result.errors.push("Settings merge failed: " + (settingsError instanceof Error ? settingsError.message : String(settingsError)));
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
defaultSettings = generateSettings(DEFAULT_INIT_OPTIONS);
|
|
579
|
-
fs.writeFileSync(settingsPath, JSON.stringify(defaultSettings, null, 2), 'utf-8');
|
|
580
|
-
result.created.push('.claude/settings.json');
|
|
581
|
-
result.settingsUpdated = ['Created new settings.json with Agent Teams'];
|
|
582
|
-
}
|
|
511
|
+
catch (settingsError) {
|
|
512
|
+
result.errors.push(`Settings merge failed: ${settingsError instanceof Error ? settingsError.message : String(settingsError)}`);
|
|
583
513
|
}
|
|
584
514
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
515
|
+
else {
|
|
516
|
+
// Create new settings.json with defaults
|
|
517
|
+
const defaultSettings = generateSettings(DEFAULT_INIT_OPTIONS);
|
|
518
|
+
fs.writeFileSync(settingsPath, JSON.stringify(defaultSettings, null, 2), 'utf-8');
|
|
519
|
+
result.created.push('.claude/settings.json');
|
|
520
|
+
result.settingsUpdated = ['Created new settings.json with Agent Teams'];
|
|
588
521
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
catch (error) {
|
|
525
|
+
result.success = false;
|
|
526
|
+
result.errors.push(error instanceof Error ? error.message : String(error));
|
|
527
|
+
}
|
|
528
|
+
return result;
|
|
592
529
|
}
|
|
593
530
|
/**
|
|
594
531
|
* Execute upgrade with --add-missing flag
|
|
@@ -596,351 +533,310 @@ export function executeUpgrade(targetDir, upgradeSettings) {
|
|
|
596
533
|
* @param targetDir - Target directory
|
|
597
534
|
* @param upgradeSettings - If true, merge new settings into existing settings.json
|
|
598
535
|
*/
|
|
599
|
-
export function executeUpgradeWithMissing(targetDir, upgradeSettings) {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
return
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
allCommands = Object.values(COMMANDS_MAP).flat();
|
|
675
|
-
for (_f = 0, _g = __spreadArray([], new Set(allCommands), true); _f < _g.length; _f++) {
|
|
676
|
-
cmdName = _g[_f];
|
|
677
|
-
sourcePath = path.join(sourceCommandsDir, cmdName);
|
|
678
|
-
targetPath = path.join(commandsDir, cmdName);
|
|
679
|
-
if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) {
|
|
680
|
-
if (fs.statSync(sourcePath).isDirectory()) {
|
|
681
|
-
copyDirRecursive(sourcePath, targetPath);
|
|
682
|
-
}
|
|
683
|
-
else {
|
|
684
|
-
fs.copyFileSync(sourcePath, targetPath);
|
|
685
|
-
}
|
|
686
|
-
result.addedCommands.push(cmdName);
|
|
687
|
-
result.created.push(".claude/commands/" + cmdName);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
}
|
|
536
|
+
export async function executeUpgradeWithMissing(targetDir, upgradeSettings = false) {
|
|
537
|
+
// First do the normal upgrade (pass through upgradeSettings)
|
|
538
|
+
const result = await executeUpgrade(targetDir, upgradeSettings);
|
|
539
|
+
if (!result.success) {
|
|
540
|
+
return result;
|
|
541
|
+
}
|
|
542
|
+
// Initialize tracking arrays
|
|
543
|
+
result.addedSkills = [];
|
|
544
|
+
result.addedAgents = [];
|
|
545
|
+
result.addedCommands = [];
|
|
546
|
+
try {
|
|
547
|
+
// Ensure target directories exist
|
|
548
|
+
const skillsDir = path.join(targetDir, '.claude', 'skills');
|
|
549
|
+
const agentsDir = path.join(targetDir, '.claude', 'agents');
|
|
550
|
+
const commandsDir = path.join(targetDir, '.claude', 'commands');
|
|
551
|
+
for (const dir of [skillsDir, agentsDir, commandsDir]) {
|
|
552
|
+
if (!fs.existsSync(dir)) {
|
|
553
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
// Find source directories
|
|
557
|
+
const sourceSkillsDir = findSourceDir('skills');
|
|
558
|
+
const sourceAgentsDir = findSourceDir('agents');
|
|
559
|
+
const sourceCommandsDir = findSourceDir('commands');
|
|
560
|
+
// Debug: Log source directories found
|
|
561
|
+
if (process.env.DEBUG || process.env.CLAUDE_FLOW_DEBUG) {
|
|
562
|
+
console.log('[DEBUG] Source directories:');
|
|
563
|
+
console.log(` Skills: ${sourceSkillsDir || 'NOT FOUND'}`);
|
|
564
|
+
console.log(` Agents: ${sourceAgentsDir || 'NOT FOUND'}`);
|
|
565
|
+
console.log(` Commands: ${sourceCommandsDir || 'NOT FOUND'}`);
|
|
566
|
+
}
|
|
567
|
+
// Add missing skills
|
|
568
|
+
if (sourceSkillsDir) {
|
|
569
|
+
const allSkills = Object.values(SKILLS_MAP).flat();
|
|
570
|
+
const debugMode = process.env.DEBUG || process.env.CLAUDE_FLOW_DEBUG;
|
|
571
|
+
if (debugMode) {
|
|
572
|
+
console.log(`[DEBUG] Checking ${allSkills.length} skills from SKILLS_MAP`);
|
|
573
|
+
}
|
|
574
|
+
for (const skillName of [...new Set(allSkills)]) {
|
|
575
|
+
const sourcePath = path.join(sourceSkillsDir, skillName);
|
|
576
|
+
const targetPath = path.join(skillsDir, skillName);
|
|
577
|
+
const sourceExists = fs.existsSync(sourcePath);
|
|
578
|
+
const targetExists = fs.existsSync(targetPath);
|
|
579
|
+
if (debugMode) {
|
|
580
|
+
console.log(`[DEBUG] Skill '${skillName}': source=${sourceExists}, target=${targetExists}`);
|
|
581
|
+
}
|
|
582
|
+
if (sourceExists && !targetExists) {
|
|
583
|
+
copyDirRecursive(sourcePath, targetPath);
|
|
584
|
+
result.addedSkills.push(skillName);
|
|
585
|
+
result.created.push(`.claude/skills/${skillName}`);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
// Add missing agents
|
|
590
|
+
if (sourceAgentsDir) {
|
|
591
|
+
const allAgents = Object.values(AGENTS_MAP).flat();
|
|
592
|
+
for (const agentCategory of [...new Set(allAgents)]) {
|
|
593
|
+
const sourcePath = path.join(sourceAgentsDir, agentCategory);
|
|
594
|
+
const targetPath = path.join(agentsDir, agentCategory);
|
|
595
|
+
if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) {
|
|
596
|
+
copyDirRecursive(sourcePath, targetPath);
|
|
597
|
+
result.addedAgents.push(agentCategory);
|
|
598
|
+
result.created.push(`.claude/agents/${agentCategory}`);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
// Add missing commands
|
|
603
|
+
if (sourceCommandsDir) {
|
|
604
|
+
const allCommands = Object.values(COMMANDS_MAP).flat();
|
|
605
|
+
for (const cmdName of [...new Set(allCommands)]) {
|
|
606
|
+
const sourcePath = path.join(sourceCommandsDir, cmdName);
|
|
607
|
+
const targetPath = path.join(commandsDir, cmdName);
|
|
608
|
+
if (fs.existsSync(sourcePath) && !fs.existsSync(targetPath)) {
|
|
609
|
+
if (fs.statSync(sourcePath).isDirectory()) {
|
|
610
|
+
copyDirRecursive(sourcePath, targetPath);
|
|
691
611
|
}
|
|
692
|
-
|
|
693
|
-
|
|
612
|
+
else {
|
|
613
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
694
614
|
}
|
|
695
|
-
|
|
615
|
+
result.addedCommands.push(cmdName);
|
|
616
|
+
result.created.push(`.claude/commands/${cmdName}`);
|
|
617
|
+
}
|
|
696
618
|
}
|
|
697
|
-
}
|
|
698
|
-
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
catch (error) {
|
|
622
|
+
result.errors.push(`Add missing failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
623
|
+
}
|
|
624
|
+
return result;
|
|
699
625
|
}
|
|
700
626
|
/**
|
|
701
627
|
* Create directory structure
|
|
702
628
|
*/
|
|
703
|
-
function createDirectories(targetDir, options, result) {
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
}
|
|
716
|
-
return [2 /*return*/];
|
|
717
|
-
});
|
|
718
|
-
});
|
|
629
|
+
async function createDirectories(targetDir, options, result) {
|
|
630
|
+
const dirs = [
|
|
631
|
+
...DIRECTORIES.claude,
|
|
632
|
+
...(options.components.runtime ? DIRECTORIES.runtime : []),
|
|
633
|
+
];
|
|
634
|
+
for (const dir of dirs) {
|
|
635
|
+
const fullPath = path.join(targetDir, dir);
|
|
636
|
+
if (!fs.existsSync(fullPath)) {
|
|
637
|
+
fs.mkdirSync(fullPath, { recursive: true });
|
|
638
|
+
result.created.directories.push(dir);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
719
641
|
}
|
|
720
642
|
/**
|
|
721
643
|
* Write settings.json
|
|
722
644
|
*/
|
|
723
|
-
function writeSettings(targetDir, options, result) {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
content = generateSettingsJson(options);
|
|
733
|
-
fs.writeFileSync(settingsPath, content, 'utf-8');
|
|
734
|
-
result.created.files.push('.claude/settings.json');
|
|
735
|
-
return [2 /*return*/];
|
|
736
|
-
});
|
|
737
|
-
});
|
|
645
|
+
async function writeSettings(targetDir, options, result) {
|
|
646
|
+
const settingsPath = path.join(targetDir, '.claude', 'settings.json');
|
|
647
|
+
if (fs.existsSync(settingsPath) && !options.force) {
|
|
648
|
+
result.skipped.push('.claude/settings.json');
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
const content = generateSettingsJson(options);
|
|
652
|
+
fs.writeFileSync(settingsPath, content, 'utf-8');
|
|
653
|
+
result.created.files.push('.claude/settings.json');
|
|
738
654
|
}
|
|
739
655
|
/**
|
|
740
656
|
* Write .mcp.json
|
|
741
657
|
*/
|
|
742
|
-
function writeMCPConfig(targetDir, options, result) {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
content = generateMCPJson(options);
|
|
752
|
-
fs.writeFileSync(mcpPath, content, 'utf-8');
|
|
753
|
-
result.created.files.push('.mcp.json');
|
|
754
|
-
return [2 /*return*/];
|
|
755
|
-
});
|
|
756
|
-
});
|
|
658
|
+
async function writeMCPConfig(targetDir, options, result) {
|
|
659
|
+
const mcpPath = path.join(targetDir, '.mcp.json');
|
|
660
|
+
if (fs.existsSync(mcpPath) && !options.force) {
|
|
661
|
+
result.skipped.push('.mcp.json');
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
const content = generateMCPJson(options);
|
|
665
|
+
fs.writeFileSync(mcpPath, content, 'utf-8');
|
|
666
|
+
result.created.files.push('.mcp.json');
|
|
757
667
|
}
|
|
758
668
|
/**
|
|
759
669
|
* Copy skills from source
|
|
760
670
|
*/
|
|
761
|
-
function copySkills(targetDir, options, result) {
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
671
|
+
async function copySkills(targetDir, options, result) {
|
|
672
|
+
const skillsConfig = options.skills;
|
|
673
|
+
const targetSkillsDir = path.join(targetDir, '.claude', 'skills');
|
|
674
|
+
// Determine which skills to copy
|
|
675
|
+
const skillsToCopy = [];
|
|
676
|
+
if (skillsConfig.all) {
|
|
677
|
+
// Copy all available skills
|
|
678
|
+
Object.values(SKILLS_MAP).forEach(skills => skillsToCopy.push(...skills));
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
if (skillsConfig.core)
|
|
682
|
+
skillsToCopy.push(...SKILLS_MAP.core);
|
|
683
|
+
if (skillsConfig.agentdb)
|
|
684
|
+
skillsToCopy.push(...SKILLS_MAP.agentdb);
|
|
685
|
+
if (skillsConfig.github)
|
|
686
|
+
skillsToCopy.push(...SKILLS_MAP.github);
|
|
687
|
+
if (skillsConfig.flowNexus)
|
|
688
|
+
skillsToCopy.push(...SKILLS_MAP.flowNexus);
|
|
689
|
+
if (skillsConfig.browser)
|
|
690
|
+
skillsToCopy.push(...SKILLS_MAP.browser);
|
|
691
|
+
if (skillsConfig.v3)
|
|
692
|
+
skillsToCopy.push(...SKILLS_MAP.v3);
|
|
693
|
+
if (skillsConfig.dualMode)
|
|
694
|
+
skillsToCopy.push(...SKILLS_MAP.dualMode);
|
|
695
|
+
if (skillsConfig.design)
|
|
696
|
+
skillsToCopy.push(...(SKILLS_MAP.design || []));
|
|
697
|
+
}
|
|
698
|
+
// Find source skills directory
|
|
699
|
+
const sourceSkillsDir = findSourceDir('skills', options.sourceBaseDir);
|
|
700
|
+
if (!sourceSkillsDir) {
|
|
701
|
+
result.errors.push('Could not find source skills directory');
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
// Copy each skill
|
|
705
|
+
for (const skillName of [...new Set(skillsToCopy)]) {
|
|
706
|
+
const sourcePath = path.join(sourceSkillsDir, skillName);
|
|
707
|
+
const targetPath = path.join(targetSkillsDir, skillName);
|
|
708
|
+
if (fs.existsSync(sourcePath)) {
|
|
709
|
+
if (!fs.existsSync(targetPath) || options.force) {
|
|
710
|
+
copyDirRecursive(sourcePath, targetPath);
|
|
711
|
+
result.created.files.push(`.claude/skills/${skillName}`);
|
|
712
|
+
result.summary.skillsCount++;
|
|
771
713
|
}
|
|
772
714
|
else {
|
|
773
|
-
|
|
774
|
-
skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.core);
|
|
775
|
-
if (skillsConfig.agentdb)
|
|
776
|
-
skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.agentdb);
|
|
777
|
-
if (skillsConfig.github)
|
|
778
|
-
skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.github);
|
|
779
|
-
if (skillsConfig.flowNexus)
|
|
780
|
-
skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.flowNexus);
|
|
781
|
-
if (skillsConfig.browser)
|
|
782
|
-
skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.browser);
|
|
783
|
-
if (skillsConfig.v3)
|
|
784
|
-
skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.v3);
|
|
785
|
-
if (skillsConfig.dualMode)
|
|
786
|
-
skillsToCopy.push.apply(skillsToCopy, SKILLS_MAP.dualMode);
|
|
787
|
-
if (skillsConfig.design)
|
|
788
|
-
skillsToCopy.push.apply(skillsToCopy, (SKILLS_MAP.design || []));
|
|
789
|
-
}
|
|
790
|
-
sourceSkillsDir = findSourceDir('skills', options.sourceBaseDir);
|
|
791
|
-
if (!sourceSkillsDir) {
|
|
792
|
-
result.errors.push('Could not find source skills directory');
|
|
793
|
-
return [2 /*return*/];
|
|
794
|
-
}
|
|
795
|
-
// Copy each skill
|
|
796
|
-
for (_i = 0, _a = __spreadArray([], new Set(skillsToCopy), true); _i < _a.length; _i++) {
|
|
797
|
-
skillName = _a[_i];
|
|
798
|
-
sourcePath = path.join(sourceSkillsDir, skillName);
|
|
799
|
-
targetPath = path.join(targetSkillsDir, skillName);
|
|
800
|
-
if (fs.existsSync(sourcePath)) {
|
|
801
|
-
if (!fs.existsSync(targetPath) || options.force) {
|
|
802
|
-
copyDirRecursive(sourcePath, targetPath);
|
|
803
|
-
result.created.files.push(".claude/skills/" + skillName);
|
|
804
|
-
result.summary.skillsCount++;
|
|
805
|
-
}
|
|
806
|
-
else {
|
|
807
|
-
result.skipped.push(".claude/skills/" + skillName);
|
|
808
|
-
}
|
|
809
|
-
}
|
|
715
|
+
result.skipped.push(`.claude/skills/${skillName}`);
|
|
810
716
|
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
});
|
|
717
|
+
}
|
|
718
|
+
}
|
|
814
719
|
}
|
|
815
720
|
/**
|
|
816
721
|
* Copy commands from source
|
|
817
722
|
*/
|
|
818
|
-
function copyCommands(targetDir, options, result) {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
723
|
+
async function copyCommands(targetDir, options, result) {
|
|
724
|
+
const commandsConfig = options.commands;
|
|
725
|
+
const targetCommandsDir = path.join(targetDir, '.claude', 'commands');
|
|
726
|
+
// Determine which commands to copy
|
|
727
|
+
const commandsToCopy = [];
|
|
728
|
+
if (commandsConfig.all) {
|
|
729
|
+
Object.values(COMMANDS_MAP).forEach(cmds => commandsToCopy.push(...cmds));
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
if (commandsConfig.core)
|
|
733
|
+
commandsToCopy.push(...COMMANDS_MAP.core);
|
|
734
|
+
if (commandsConfig.analysis)
|
|
735
|
+
commandsToCopy.push(...COMMANDS_MAP.analysis);
|
|
736
|
+
if (commandsConfig.automation)
|
|
737
|
+
commandsToCopy.push(...COMMANDS_MAP.automation);
|
|
738
|
+
if (commandsConfig.github)
|
|
739
|
+
commandsToCopy.push(...COMMANDS_MAP.github);
|
|
740
|
+
if (commandsConfig.hooks)
|
|
741
|
+
commandsToCopy.push(...COMMANDS_MAP.hooks);
|
|
742
|
+
if (commandsConfig.monitoring)
|
|
743
|
+
commandsToCopy.push(...COMMANDS_MAP.monitoring);
|
|
744
|
+
if (commandsConfig.optimization)
|
|
745
|
+
commandsToCopy.push(...COMMANDS_MAP.optimization);
|
|
746
|
+
if (commandsConfig.sparc)
|
|
747
|
+
commandsToCopy.push(...COMMANDS_MAP.sparc);
|
|
748
|
+
}
|
|
749
|
+
// Find source commands directory
|
|
750
|
+
const sourceCommandsDir = findSourceDir('commands', options.sourceBaseDir);
|
|
751
|
+
if (!sourceCommandsDir) {
|
|
752
|
+
result.errors.push('Could not find source commands directory');
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
// Copy each command/directory
|
|
756
|
+
for (const cmdName of [...new Set(commandsToCopy)]) {
|
|
757
|
+
const sourcePath = path.join(sourceCommandsDir, cmdName);
|
|
758
|
+
const targetPath = path.join(targetCommandsDir, cmdName);
|
|
759
|
+
if (fs.existsSync(sourcePath)) {
|
|
760
|
+
if (!fs.existsSync(targetPath) || options.force) {
|
|
761
|
+
if (fs.statSync(sourcePath).isDirectory()) {
|
|
762
|
+
copyDirRecursive(sourcePath, targetPath);
|
|
763
|
+
}
|
|
764
|
+
else {
|
|
765
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
766
|
+
}
|
|
767
|
+
result.created.files.push(`.claude/commands/${cmdName}`);
|
|
768
|
+
result.summary.commandsCount++;
|
|
827
769
|
}
|
|
828
770
|
else {
|
|
829
|
-
|
|
830
|
-
commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.core);
|
|
831
|
-
if (commandsConfig.analysis)
|
|
832
|
-
commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.analysis);
|
|
833
|
-
if (commandsConfig.automation)
|
|
834
|
-
commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.automation);
|
|
835
|
-
if (commandsConfig.github)
|
|
836
|
-
commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.github);
|
|
837
|
-
if (commandsConfig.hooks)
|
|
838
|
-
commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.hooks);
|
|
839
|
-
if (commandsConfig.monitoring)
|
|
840
|
-
commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.monitoring);
|
|
841
|
-
if (commandsConfig.optimization)
|
|
842
|
-
commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.optimization);
|
|
843
|
-
if (commandsConfig.sparc)
|
|
844
|
-
commandsToCopy.push.apply(commandsToCopy, COMMANDS_MAP.sparc);
|
|
771
|
+
result.skipped.push(`.claude/commands/${cmdName}`);
|
|
845
772
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
result.errors.push('Could not find source commands directory');
|
|
849
|
-
return [2 /*return*/];
|
|
850
|
-
}
|
|
851
|
-
// Copy each command/directory
|
|
852
|
-
for (_i = 0, _a = __spreadArray([], new Set(commandsToCopy), true); _i < _a.length; _i++) {
|
|
853
|
-
cmdName = _a[_i];
|
|
854
|
-
sourcePath = path.join(sourceCommandsDir, cmdName);
|
|
855
|
-
targetPath = path.join(targetCommandsDir, cmdName);
|
|
856
|
-
if (fs.existsSync(sourcePath)) {
|
|
857
|
-
if (!fs.existsSync(targetPath) || options.force) {
|
|
858
|
-
if (fs.statSync(sourcePath).isDirectory()) {
|
|
859
|
-
copyDirRecursive(sourcePath, targetPath);
|
|
860
|
-
}
|
|
861
|
-
else {
|
|
862
|
-
fs.copyFileSync(sourcePath, targetPath);
|
|
863
|
-
}
|
|
864
|
-
result.created.files.push(".claude/commands/" + cmdName);
|
|
865
|
-
result.summary.commandsCount++;
|
|
866
|
-
}
|
|
867
|
-
else {
|
|
868
|
-
result.skipped.push(".claude/commands/" + cmdName);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
return [2 /*return*/];
|
|
873
|
-
});
|
|
874
|
-
});
|
|
773
|
+
}
|
|
774
|
+
}
|
|
875
775
|
}
|
|
876
776
|
/**
|
|
877
777
|
* Copy agents from source
|
|
878
778
|
*/
|
|
879
|
-
function copyAgents(targetDir, options, result) {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
779
|
+
async function copyAgents(targetDir, options, result) {
|
|
780
|
+
const agentsConfig = options.agents;
|
|
781
|
+
const targetAgentsDir = path.join(targetDir, '.claude', 'agents');
|
|
782
|
+
// Determine which agents to copy
|
|
783
|
+
const agentsToCopy = [];
|
|
784
|
+
if (agentsConfig.all) {
|
|
785
|
+
Object.values(AGENTS_MAP).forEach(agents => agentsToCopy.push(...agents));
|
|
786
|
+
}
|
|
787
|
+
else {
|
|
788
|
+
if (agentsConfig.core)
|
|
789
|
+
agentsToCopy.push(...AGENTS_MAP.core);
|
|
790
|
+
if (agentsConfig.consensus)
|
|
791
|
+
agentsToCopy.push(...AGENTS_MAP.consensus);
|
|
792
|
+
if (agentsConfig.github)
|
|
793
|
+
agentsToCopy.push(...AGENTS_MAP.github);
|
|
794
|
+
if (agentsConfig.hiveMind)
|
|
795
|
+
agentsToCopy.push(...AGENTS_MAP.hiveMind);
|
|
796
|
+
if (agentsConfig.sparc)
|
|
797
|
+
agentsToCopy.push(...AGENTS_MAP.sparc);
|
|
798
|
+
if (agentsConfig.swarm)
|
|
799
|
+
agentsToCopy.push(...AGENTS_MAP.swarm);
|
|
800
|
+
if (agentsConfig.browser)
|
|
801
|
+
agentsToCopy.push(...AGENTS_MAP.browser);
|
|
802
|
+
// V3-specific agent categories
|
|
803
|
+
if (agentsConfig.v3)
|
|
804
|
+
agentsToCopy.push(...(AGENTS_MAP.v3 || []));
|
|
805
|
+
if (agentsConfig.optimization)
|
|
806
|
+
agentsToCopy.push(...(AGENTS_MAP.optimization || []));
|
|
807
|
+
if (agentsConfig.testing)
|
|
808
|
+
agentsToCopy.push(...(AGENTS_MAP.testing || []));
|
|
809
|
+
// Design agents (design-architect, ux-researcher, ui-developer, accessibility-auditor)
|
|
810
|
+
if (agentsConfig.design)
|
|
811
|
+
agentsToCopy.push(...(AGENTS_MAP.design || []));
|
|
812
|
+
// Dual-mode agents (Claude Code + Codex hybrid)
|
|
813
|
+
if (agentsConfig.dualMode)
|
|
814
|
+
agentsToCopy.push(...(AGENTS_MAP.dualMode || []));
|
|
815
|
+
}
|
|
816
|
+
// Find source agents directory
|
|
817
|
+
const sourceAgentsDir = findSourceDir('agents', options.sourceBaseDir);
|
|
818
|
+
if (!sourceAgentsDir) {
|
|
819
|
+
result.errors.push('Could not find source agents directory');
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
// Copy each agent category
|
|
823
|
+
for (const agentCategory of [...new Set(agentsToCopy)]) {
|
|
824
|
+
const sourcePath = path.join(sourceAgentsDir, agentCategory);
|
|
825
|
+
const targetPath = path.join(targetAgentsDir, agentCategory);
|
|
826
|
+
if (fs.existsSync(sourcePath)) {
|
|
827
|
+
if (!fs.existsSync(targetPath) || options.force) {
|
|
828
|
+
copyDirRecursive(sourcePath, targetPath);
|
|
829
|
+
// Count agent files (.yaml and .md)
|
|
830
|
+
const yamlFiles = countFiles(sourcePath, '.yaml');
|
|
831
|
+
const mdFiles = countFiles(sourcePath, '.md');
|
|
832
|
+
result.summary.agentsCount += yamlFiles + mdFiles;
|
|
833
|
+
result.created.files.push(`.claude/agents/${agentCategory}`);
|
|
888
834
|
}
|
|
889
835
|
else {
|
|
890
|
-
|
|
891
|
-
agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.core);
|
|
892
|
-
if (agentsConfig.consensus)
|
|
893
|
-
agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.consensus);
|
|
894
|
-
if (agentsConfig.github)
|
|
895
|
-
agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.github);
|
|
896
|
-
if (agentsConfig.hiveMind)
|
|
897
|
-
agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.hiveMind);
|
|
898
|
-
if (agentsConfig.sparc)
|
|
899
|
-
agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.sparc);
|
|
900
|
-
if (agentsConfig.swarm)
|
|
901
|
-
agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.swarm);
|
|
902
|
-
if (agentsConfig.browser)
|
|
903
|
-
agentsToCopy.push.apply(agentsToCopy, AGENTS_MAP.browser);
|
|
904
|
-
// V3-specific agent categories
|
|
905
|
-
if (agentsConfig.v3)
|
|
906
|
-
agentsToCopy.push.apply(agentsToCopy, (AGENTS_MAP.v3 || []));
|
|
907
|
-
if (agentsConfig.optimization)
|
|
908
|
-
agentsToCopy.push.apply(agentsToCopy, (AGENTS_MAP.optimization || []));
|
|
909
|
-
if (agentsConfig.testing)
|
|
910
|
-
agentsToCopy.push.apply(agentsToCopy, (AGENTS_MAP.testing || []));
|
|
911
|
-
// Design agents (design-architect, ux-researcher, ui-developer, accessibility-auditor)
|
|
912
|
-
if (agentsConfig.design)
|
|
913
|
-
agentsToCopy.push.apply(agentsToCopy, (AGENTS_MAP.design || []));
|
|
914
|
-
// Dual-mode agents (Claude Code + Codex hybrid)
|
|
915
|
-
if (agentsConfig.dualMode)
|
|
916
|
-
agentsToCopy.push.apply(agentsToCopy, (AGENTS_MAP.dualMode || []));
|
|
836
|
+
result.skipped.push(`.claude/agents/${agentCategory}`);
|
|
917
837
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
result.errors.push('Could not find source agents directory');
|
|
921
|
-
return [2 /*return*/];
|
|
922
|
-
}
|
|
923
|
-
// Copy each agent category
|
|
924
|
-
for (_i = 0, _a = __spreadArray([], new Set(agentsToCopy), true); _i < _a.length; _i++) {
|
|
925
|
-
agentCategory = _a[_i];
|
|
926
|
-
sourcePath = path.join(sourceAgentsDir, agentCategory);
|
|
927
|
-
targetPath = path.join(targetAgentsDir, agentCategory);
|
|
928
|
-
if (fs.existsSync(sourcePath)) {
|
|
929
|
-
if (!fs.existsSync(targetPath) || options.force) {
|
|
930
|
-
copyDirRecursive(sourcePath, targetPath);
|
|
931
|
-
yamlFiles = countFiles(sourcePath, '.yaml');
|
|
932
|
-
mdFiles = countFiles(sourcePath, '.md');
|
|
933
|
-
result.summary.agentsCount += yamlFiles + mdFiles;
|
|
934
|
-
result.created.files.push(".claude/agents/" + agentCategory);
|
|
935
|
-
}
|
|
936
|
-
else {
|
|
937
|
-
result.skipped.push(".claude/agents/" + agentCategory);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
return [2 /*return*/];
|
|
942
|
-
});
|
|
943
|
-
});
|
|
838
|
+
}
|
|
839
|
+
}
|
|
944
840
|
}
|
|
945
841
|
/**
|
|
946
842
|
* Find source helpers directory.
|
|
@@ -948,46 +844,45 @@ function copyAgents(targetDir, options, result) {
|
|
|
948
844
|
* returning the target directory or an incomplete source.
|
|
949
845
|
*/
|
|
950
846
|
function findSourceHelpersDir(sourceBaseDir) {
|
|
951
|
-
|
|
952
|
-
|
|
847
|
+
const possiblePaths = [];
|
|
848
|
+
const SENTINEL_FILE = 'hook-handler.cjs'; // Must exist in valid source
|
|
953
849
|
// If explicit source base directory is provided, check it first
|
|
954
850
|
if (sourceBaseDir) {
|
|
955
851
|
possiblePaths.push(path.join(sourceBaseDir, '.claude', 'helpers'));
|
|
956
852
|
}
|
|
957
853
|
// Strategy 1: require.resolve to find package root (most reliable for npx)
|
|
958
854
|
try {
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
855
|
+
const esmRequire = createRequire(import.meta.url);
|
|
856
|
+
const pkgJsonPath = esmRequire.resolve('@claude-flow/cli/package.json');
|
|
857
|
+
const pkgRoot = path.dirname(pkgJsonPath);
|
|
962
858
|
possiblePaths.push(path.join(pkgRoot, '.claude', 'helpers'));
|
|
963
859
|
}
|
|
964
|
-
catch
|
|
860
|
+
catch {
|
|
965
861
|
// Not installed as a package — skip
|
|
966
862
|
}
|
|
967
863
|
// Strategy 2: __dirname-based (dist/src/init -> package root)
|
|
968
|
-
|
|
969
|
-
|
|
864
|
+
const packageRoot = path.resolve(__dirname, '..', '..', '..');
|
|
865
|
+
const packageHelpers = path.join(packageRoot, '.claude', 'helpers');
|
|
970
866
|
possiblePaths.push(packageHelpers);
|
|
971
867
|
// Strategy 3: Walk up from __dirname looking for package root
|
|
972
|
-
|
|
973
|
-
for (
|
|
974
|
-
|
|
868
|
+
let currentDir = __dirname;
|
|
869
|
+
for (let i = 0; i < 10; i++) {
|
|
870
|
+
const parentDir = path.dirname(currentDir);
|
|
975
871
|
if (parentDir === currentDir)
|
|
976
872
|
break; // hit filesystem root
|
|
977
|
-
|
|
873
|
+
const helpersPath = path.join(parentDir, '.claude', 'helpers');
|
|
978
874
|
possiblePaths.push(helpersPath);
|
|
979
875
|
currentDir = parentDir;
|
|
980
876
|
}
|
|
981
877
|
// Strategy 4: Check cwd-relative paths (for local dev)
|
|
982
|
-
|
|
878
|
+
const cwdBased = [
|
|
983
879
|
path.join(process.cwd(), '.claude', 'helpers'),
|
|
984
880
|
path.join(process.cwd(), '..', '.claude', 'helpers'),
|
|
985
881
|
path.join(process.cwd(), '..', '..', '.claude', 'helpers'),
|
|
986
882
|
];
|
|
987
|
-
possiblePaths.push
|
|
883
|
+
possiblePaths.push(...cwdBased);
|
|
988
884
|
// Return first path that exists AND contains the sentinel file
|
|
989
|
-
for (
|
|
990
|
-
var p = possiblePaths_1[_i];
|
|
885
|
+
for (const p of possiblePaths) {
|
|
991
886
|
if (fs.existsSync(p) && fs.existsSync(path.join(p, SENTINEL_FILE))) {
|
|
992
887
|
return p;
|
|
993
888
|
}
|
|
@@ -997,97 +892,90 @@ function findSourceHelpersDir(sourceBaseDir) {
|
|
|
997
892
|
/**
|
|
998
893
|
* Write helper scripts
|
|
999
894
|
*/
|
|
1000
|
-
function writeHelpers(targetDir, options, result) {
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
// Make shell scripts and mjs files executable
|
|
1020
|
-
if (file.endsWith('.sh') || file.endsWith('.mjs')) {
|
|
1021
|
-
fs.chmodSync(destPath, '755');
|
|
1022
|
-
}
|
|
1023
|
-
result.created.files.push(".claude/helpers/" + file);
|
|
1024
|
-
copiedCount++;
|
|
1025
|
-
}
|
|
1026
|
-
else {
|
|
1027
|
-
result.skipped.push(".claude/helpers/" + file);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
if (copiedCount > 0) {
|
|
1031
|
-
return [2 /*return*/]; // Skip generating if we copied from source
|
|
895
|
+
async function writeHelpers(targetDir, options, result) {
|
|
896
|
+
const helpersDir = path.join(targetDir, '.claude', 'helpers');
|
|
897
|
+
// Find source helpers directory (works for npm package and local dev)
|
|
898
|
+
const sourceHelpersDir = findSourceHelpersDir(options.sourceBaseDir);
|
|
899
|
+
// Try to copy existing helpers from source first
|
|
900
|
+
if (sourceHelpersDir && fs.existsSync(sourceHelpersDir)) {
|
|
901
|
+
const helperFiles = fs.readdirSync(sourceHelpersDir);
|
|
902
|
+
let copiedCount = 0;
|
|
903
|
+
for (const file of helperFiles) {
|
|
904
|
+
const sourcePath = path.join(sourceHelpersDir, file);
|
|
905
|
+
const destPath = path.join(helpersDir, file);
|
|
906
|
+
// Skip directories and only copy files
|
|
907
|
+
if (!fs.statSync(sourcePath).isFile())
|
|
908
|
+
continue;
|
|
909
|
+
if (!fs.existsSync(destPath) || options.force) {
|
|
910
|
+
fs.copyFileSync(sourcePath, destPath);
|
|
911
|
+
// Make shell scripts and mjs files executable
|
|
912
|
+
if (file.endsWith('.sh') || file.endsWith('.mjs')) {
|
|
913
|
+
fs.chmodSync(destPath, '755');
|
|
1032
914
|
}
|
|
915
|
+
result.created.files.push(`.claude/helpers/${file}`);
|
|
916
|
+
copiedCount++;
|
|
1033
917
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
'post-commit': generatePostCommitHook(),
|
|
1037
|
-
'session.js': generateSessionManager(),
|
|
1038
|
-
'router.js': generateAgentRouter(),
|
|
1039
|
-
'memory.js': generateMemoryHelper(),
|
|
1040
|
-
'hook-handler.cjs': generateHookHandler(),
|
|
1041
|
-
'intelligence.cjs': generateIntelligenceStub(),
|
|
1042
|
-
'auto-memory-hook.mjs': generateAutoMemoryHook()
|
|
1043
|
-
};
|
|
1044
|
-
for (_a = 0, _b = Object.entries(helpers); _a < _b.length; _a++) {
|
|
1045
|
-
_c = _b[_a], name = _c[0], content = _c[1];
|
|
1046
|
-
filePath = path.join(helpersDir, name);
|
|
1047
|
-
if (!fs.existsSync(filePath) || options.force) {
|
|
1048
|
-
fs.writeFileSync(filePath, content, 'utf-8');
|
|
1049
|
-
// Make shell scripts executable
|
|
1050
|
-
if (!name.endsWith('.js')) {
|
|
1051
|
-
fs.chmodSync(filePath, '755');
|
|
1052
|
-
}
|
|
1053
|
-
result.created.files.push(".claude/helpers/" + name);
|
|
1054
|
-
}
|
|
1055
|
-
else {
|
|
1056
|
-
result.skipped.push(".claude/helpers/" + name);
|
|
1057
|
-
}
|
|
918
|
+
else {
|
|
919
|
+
result.skipped.push(`.claude/helpers/${file}`);
|
|
1058
920
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
921
|
+
}
|
|
922
|
+
if (copiedCount > 0) {
|
|
923
|
+
return; // Skip generating if we copied from source
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
// Fall back to generating helpers if source not available
|
|
927
|
+
const helpers = {
|
|
928
|
+
'pre-commit': generatePreCommitHook(),
|
|
929
|
+
'post-commit': generatePostCommitHook(),
|
|
930
|
+
'session.js': generateSessionManager(),
|
|
931
|
+
'router.js': generateAgentRouter(),
|
|
932
|
+
'memory.js': generateMemoryHelper(),
|
|
933
|
+
'hook-handler.cjs': generateHookHandler(),
|
|
934
|
+
'intelligence.cjs': generateIntelligenceStub(),
|
|
935
|
+
'auto-memory-hook.mjs': generateAutoMemoryHook(),
|
|
936
|
+
};
|
|
937
|
+
for (const [name, content] of Object.entries(helpers)) {
|
|
938
|
+
const filePath = path.join(helpersDir, name);
|
|
939
|
+
if (!fs.existsSync(filePath) || options.force) {
|
|
940
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
941
|
+
// Make shell scripts executable
|
|
942
|
+
if (!name.endsWith('.js')) {
|
|
943
|
+
fs.chmodSync(filePath, '755');
|
|
944
|
+
}
|
|
945
|
+
result.created.files.push(`.claude/helpers/${name}`);
|
|
946
|
+
}
|
|
947
|
+
else {
|
|
948
|
+
result.skipped.push(`.claude/helpers/${name}`);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
1062
951
|
}
|
|
1063
952
|
/**
|
|
1064
953
|
* Find source .claude directory for statusline files
|
|
1065
954
|
*/
|
|
1066
955
|
function findSourceClaudeDir(sourceBaseDir) {
|
|
1067
|
-
|
|
956
|
+
const possiblePaths = [];
|
|
1068
957
|
// If explicit source base directory is provided, check it first
|
|
1069
958
|
if (sourceBaseDir) {
|
|
1070
959
|
possiblePaths.push(path.join(sourceBaseDir, '.claude'));
|
|
1071
960
|
}
|
|
1072
961
|
// IMPORTANT: Check the package's own .claude directory
|
|
1073
962
|
// Go up 3 levels: dist/src/init -> dist/src -> dist -> root
|
|
1074
|
-
|
|
1075
|
-
|
|
963
|
+
const packageRoot = path.resolve(__dirname, '..', '..', '..');
|
|
964
|
+
const packageClaude = path.join(packageRoot, '.claude');
|
|
1076
965
|
if (fs.existsSync(packageClaude)) {
|
|
1077
966
|
possiblePaths.unshift(packageClaude); // Add to beginning (highest priority)
|
|
1078
967
|
}
|
|
1079
968
|
// From dist/src/init -> go up to project root
|
|
1080
|
-
|
|
1081
|
-
for (
|
|
1082
|
-
|
|
1083
|
-
|
|
969
|
+
let currentDir = __dirname;
|
|
970
|
+
for (let i = 0; i < 10; i++) {
|
|
971
|
+
const parentDir = path.dirname(currentDir);
|
|
972
|
+
const claudePath = path.join(parentDir, '.claude');
|
|
1084
973
|
if (fs.existsSync(claudePath)) {
|
|
1085
974
|
possiblePaths.push(claudePath);
|
|
1086
975
|
}
|
|
1087
976
|
currentDir = parentDir;
|
|
1088
977
|
}
|
|
1089
|
-
for (
|
|
1090
|
-
var p = possiblePaths_2[_i];
|
|
978
|
+
for (const p of possiblePaths) {
|
|
1091
979
|
if (fs.existsSync(p)) {
|
|
1092
980
|
return p;
|
|
1093
981
|
}
|
|
@@ -1097,235 +985,661 @@ function findSourceClaudeDir(sourceBaseDir) {
|
|
|
1097
985
|
/**
|
|
1098
986
|
* Write statusline configuration
|
|
1099
987
|
*/
|
|
1100
|
-
function writeStatusline(targetDir, options, result) {
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
if (file.src.endsWith('.sh') || file.src.endsWith('.mjs')) {
|
|
1121
|
-
fs.chmodSync(destPath, '755');
|
|
1122
|
-
}
|
|
1123
|
-
result.created.files.push(".claude/" + file.dest);
|
|
1124
|
-
}
|
|
1125
|
-
else {
|
|
1126
|
-
result.skipped.push(".claude/" + file.dest);
|
|
1127
|
-
}
|
|
988
|
+
async function writeStatusline(targetDir, options, result) {
|
|
989
|
+
const claudeDir = path.join(targetDir, '.claude');
|
|
990
|
+
const helpersDir = path.join(targetDir, '.claude', 'helpers');
|
|
991
|
+
// Find source .claude directory (works for npm package and local dev)
|
|
992
|
+
const sourceClaudeDir = findSourceClaudeDir(options.sourceBaseDir);
|
|
993
|
+
// Try to copy existing advanced statusline files from source
|
|
994
|
+
const advancedStatuslineFiles = [
|
|
995
|
+
{ src: 'statusline.sh', dest: 'statusline.sh', dir: claudeDir },
|
|
996
|
+
{ src: 'statusline.mjs', dest: 'statusline.mjs', dir: claudeDir },
|
|
997
|
+
];
|
|
998
|
+
if (sourceClaudeDir) {
|
|
999
|
+
for (const file of advancedStatuslineFiles) {
|
|
1000
|
+
const sourcePath = path.join(sourceClaudeDir, file.src);
|
|
1001
|
+
const destPath = path.join(file.dir, file.dest);
|
|
1002
|
+
if (fs.existsSync(sourcePath)) {
|
|
1003
|
+
if (!fs.existsSync(destPath) || options.force) {
|
|
1004
|
+
fs.copyFileSync(sourcePath, destPath);
|
|
1005
|
+
// Make shell scripts and mjs executable
|
|
1006
|
+
if (file.src.endsWith('.sh') || file.src.endsWith('.mjs')) {
|
|
1007
|
+
fs.chmodSync(destPath, '755');
|
|
1128
1008
|
}
|
|
1009
|
+
result.created.files.push(`.claude/${file.dest}`);
|
|
1010
|
+
}
|
|
1011
|
+
else {
|
|
1012
|
+
result.skipped.push(`.claude/${file.dest}`);
|
|
1129
1013
|
}
|
|
1130
1014
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
// ALWAYS generate statusline.cjs — the generated version includes AgentDB
|
|
1018
|
+
// vectors/size, tests, ADRs, hooks, and integration stats that the
|
|
1019
|
+
// pre-installed static copy in the npm package lacks.
|
|
1020
|
+
// This must overwrite any copy from writeHelpers() which copies the legacy file.
|
|
1021
|
+
const statuslineScript = generateStatuslineScript(options);
|
|
1022
|
+
const statuslinePath = path.join(helpersDir, 'statusline.cjs');
|
|
1023
|
+
fs.writeFileSync(statuslinePath, statuslineScript, 'utf-8');
|
|
1024
|
+
result.created.files.push('.claude/helpers/statusline.cjs');
|
|
1138
1025
|
}
|
|
1139
1026
|
/**
|
|
1140
1027
|
* Write runtime configuration (.claude-flow/)
|
|
1141
1028
|
*/
|
|
1142
|
-
function writeRuntimeConfig(targetDir, options, result) {
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
return
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1029
|
+
async function writeRuntimeConfig(targetDir, options, result) {
|
|
1030
|
+
const configPath = path.join(targetDir, '.claude-flow', 'config.yaml');
|
|
1031
|
+
if (fs.existsSync(configPath) && !options.force) {
|
|
1032
|
+
result.skipped.push('.claude-flow/config.yaml');
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
const config = `# RuFlo V3 Runtime Configuration
|
|
1036
|
+
# Generated: ${new Date().toISOString()}
|
|
1037
|
+
|
|
1038
|
+
version: "3.0.0"
|
|
1039
|
+
|
|
1040
|
+
swarm:
|
|
1041
|
+
topology: ${options.runtime.topology}
|
|
1042
|
+
maxAgents: ${options.runtime.maxAgents}
|
|
1043
|
+
autoScale: true
|
|
1044
|
+
coordinationStrategy: consensus
|
|
1045
|
+
|
|
1046
|
+
memory:
|
|
1047
|
+
backend: ${options.runtime.memoryBackend}
|
|
1048
|
+
enableHNSW: ${options.runtime.enableHNSW}
|
|
1049
|
+
persistPath: .claude-flow/data
|
|
1050
|
+
cacheSize: 100
|
|
1051
|
+
# ADR-049: Self-Learning Memory
|
|
1052
|
+
learningBridge:
|
|
1053
|
+
enabled: ${options.runtime.enableLearningBridge ?? options.runtime.enableNeural}
|
|
1054
|
+
sonaMode: balanced
|
|
1055
|
+
confidenceDecayRate: 0.005
|
|
1056
|
+
accessBoostAmount: 0.03
|
|
1057
|
+
consolidationThreshold: 10
|
|
1058
|
+
memoryGraph:
|
|
1059
|
+
enabled: ${options.runtime.enableMemoryGraph ?? true}
|
|
1060
|
+
pageRankDamping: 0.85
|
|
1061
|
+
maxNodes: 5000
|
|
1062
|
+
similarityThreshold: 0.8
|
|
1063
|
+
agentScopes:
|
|
1064
|
+
enabled: ${options.runtime.enableAgentScopes ?? true}
|
|
1065
|
+
defaultScope: project
|
|
1066
|
+
|
|
1067
|
+
neural:
|
|
1068
|
+
enabled: ${options.runtime.enableNeural}
|
|
1069
|
+
modelPath: .claude-flow/neural
|
|
1070
|
+
|
|
1071
|
+
hooks:
|
|
1072
|
+
enabled: true
|
|
1073
|
+
autoExecute: true
|
|
1074
|
+
|
|
1075
|
+
mcp:
|
|
1076
|
+
autoStart: ${options.mcp.autoStart}
|
|
1077
|
+
port: ${options.mcp.port}
|
|
1078
|
+
`;
|
|
1079
|
+
fs.writeFileSync(configPath, config, 'utf-8');
|
|
1080
|
+
result.created.files.push('.claude-flow/config.yaml');
|
|
1081
|
+
// Write .gitignore
|
|
1082
|
+
const gitignorePath = path.join(targetDir, '.claude-flow', '.gitignore');
|
|
1083
|
+
const gitignore = `# Claude Flow runtime files
|
|
1084
|
+
data/
|
|
1085
|
+
logs/
|
|
1086
|
+
sessions/
|
|
1087
|
+
neural/
|
|
1088
|
+
*.log
|
|
1089
|
+
*.tmp
|
|
1090
|
+
`;
|
|
1091
|
+
if (!fs.existsSync(gitignorePath) || options.force) {
|
|
1092
|
+
fs.writeFileSync(gitignorePath, gitignore, 'utf-8');
|
|
1093
|
+
result.created.files.push('.claude-flow/.gitignore');
|
|
1094
|
+
}
|
|
1095
|
+
// Write CAPABILITIES.md with full system overview
|
|
1096
|
+
await writeCapabilitiesDoc(targetDir, options, result);
|
|
1172
1097
|
}
|
|
1173
1098
|
/**
|
|
1174
1099
|
* Write initial metrics files for statusline
|
|
1175
1100
|
* Creates baseline data so statusline shows meaningful state instead of all zeros
|
|
1176
1101
|
*/
|
|
1177
|
-
function writeInitialMetrics(targetDir, options, result) {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
return [2 /*return*/];
|
|
1281
|
-
});
|
|
1282
|
-
});
|
|
1102
|
+
async function writeInitialMetrics(targetDir, options, result) {
|
|
1103
|
+
const metricsDir = path.join(targetDir, '.claude-flow', 'metrics');
|
|
1104
|
+
const learningDir = path.join(targetDir, '.claude-flow', 'learning');
|
|
1105
|
+
const securityDir = path.join(targetDir, '.claude-flow', 'security');
|
|
1106
|
+
// Ensure directories exist
|
|
1107
|
+
for (const dir of [metricsDir, learningDir, securityDir]) {
|
|
1108
|
+
if (!fs.existsSync(dir)) {
|
|
1109
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
// Create initial v3-progress.json
|
|
1113
|
+
const progressPath = path.join(metricsDir, 'v3-progress.json');
|
|
1114
|
+
if (!fs.existsSync(progressPath) || options.force) {
|
|
1115
|
+
const progress = {
|
|
1116
|
+
version: '3.0.0',
|
|
1117
|
+
initialized: new Date().toISOString(),
|
|
1118
|
+
domains: {
|
|
1119
|
+
completed: 0,
|
|
1120
|
+
total: 5,
|
|
1121
|
+
status: 'INITIALIZING'
|
|
1122
|
+
},
|
|
1123
|
+
ddd: {
|
|
1124
|
+
progress: 0,
|
|
1125
|
+
modules: 0,
|
|
1126
|
+
totalFiles: 0,
|
|
1127
|
+
totalLines: 0
|
|
1128
|
+
},
|
|
1129
|
+
swarm: {
|
|
1130
|
+
activeAgents: 0,
|
|
1131
|
+
maxAgents: options.runtime.maxAgents,
|
|
1132
|
+
topology: options.runtime.topology
|
|
1133
|
+
},
|
|
1134
|
+
learning: {
|
|
1135
|
+
status: 'READY',
|
|
1136
|
+
patternsLearned: 0,
|
|
1137
|
+
sessionsCompleted: 0
|
|
1138
|
+
},
|
|
1139
|
+
_note: 'Metrics will update as you use Ruflo. Run: npx ruflo@latest daemon start'
|
|
1140
|
+
};
|
|
1141
|
+
fs.writeFileSync(progressPath, JSON.stringify(progress, null, 2), 'utf-8');
|
|
1142
|
+
result.created.files.push('.claude-flow/metrics/v3-progress.json');
|
|
1143
|
+
}
|
|
1144
|
+
// Create initial swarm-activity.json
|
|
1145
|
+
const activityPath = path.join(metricsDir, 'swarm-activity.json');
|
|
1146
|
+
if (!fs.existsSync(activityPath) || options.force) {
|
|
1147
|
+
const activity = {
|
|
1148
|
+
timestamp: new Date().toISOString(),
|
|
1149
|
+
processes: {
|
|
1150
|
+
agentic_flow: 0,
|
|
1151
|
+
mcp_server: 0,
|
|
1152
|
+
estimated_agents: 0
|
|
1153
|
+
},
|
|
1154
|
+
swarm: {
|
|
1155
|
+
active: false,
|
|
1156
|
+
agent_count: 0,
|
|
1157
|
+
coordination_active: false
|
|
1158
|
+
},
|
|
1159
|
+
integration: {
|
|
1160
|
+
agentic_flow_active: false,
|
|
1161
|
+
mcp_active: false
|
|
1162
|
+
},
|
|
1163
|
+
_initialized: true
|
|
1164
|
+
};
|
|
1165
|
+
fs.writeFileSync(activityPath, JSON.stringify(activity, null, 2), 'utf-8');
|
|
1166
|
+
result.created.files.push('.claude-flow/metrics/swarm-activity.json');
|
|
1167
|
+
}
|
|
1168
|
+
// Create initial learning.json
|
|
1169
|
+
const learningPath = path.join(metricsDir, 'learning.json');
|
|
1170
|
+
if (!fs.existsSync(learningPath) || options.force) {
|
|
1171
|
+
const learning = {
|
|
1172
|
+
initialized: new Date().toISOString(),
|
|
1173
|
+
routing: {
|
|
1174
|
+
accuracy: 0,
|
|
1175
|
+
decisions: 0
|
|
1176
|
+
},
|
|
1177
|
+
patterns: {
|
|
1178
|
+
shortTerm: 0,
|
|
1179
|
+
longTerm: 0,
|
|
1180
|
+
quality: 0
|
|
1181
|
+
},
|
|
1182
|
+
sessions: {
|
|
1183
|
+
total: 0,
|
|
1184
|
+
current: null
|
|
1185
|
+
},
|
|
1186
|
+
_note: 'Intelligence grows as you use Ruflo'
|
|
1187
|
+
};
|
|
1188
|
+
fs.writeFileSync(learningPath, JSON.stringify(learning, null, 2), 'utf-8');
|
|
1189
|
+
result.created.files.push('.claude-flow/metrics/learning.json');
|
|
1190
|
+
}
|
|
1191
|
+
// Create initial audit-status.json
|
|
1192
|
+
const auditPath = path.join(securityDir, 'audit-status.json');
|
|
1193
|
+
if (!fs.existsSync(auditPath) || options.force) {
|
|
1194
|
+
const audit = {
|
|
1195
|
+
initialized: new Date().toISOString(),
|
|
1196
|
+
status: 'PENDING',
|
|
1197
|
+
cvesFixed: 0,
|
|
1198
|
+
totalCves: 3,
|
|
1199
|
+
lastScan: null,
|
|
1200
|
+
_note: 'Run: npx @claude-flow/cli@latest security scan'
|
|
1201
|
+
};
|
|
1202
|
+
fs.writeFileSync(auditPath, JSON.stringify(audit, null, 2), 'utf-8');
|
|
1203
|
+
result.created.files.push('.claude-flow/security/audit-status.json');
|
|
1204
|
+
}
|
|
1283
1205
|
}
|
|
1284
1206
|
/**
|
|
1285
1207
|
* Write CAPABILITIES.md - comprehensive overview of all Ruflo features
|
|
1286
1208
|
*/
|
|
1287
|
-
function writeCapabilitiesDoc(targetDir, options, result) {
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
capabilities = "# RuFlo V3 - Complete Capabilities Reference\n> Generated: " + new Date().toISOString() + "\n> Full documentation: https://github.com/ruvnet/claude-flow\n\n## \uD83D\uDCCB Table of Contents\n\n1. [Overview](#overview)\n2. [Swarm Orchestration](#swarm-orchestration)\n3. [Available Agents (60+)](#available-agents)\n4. [CLI Commands (26 Commands, 140+ Subcommands)](#cli-commands)\n5. [Hooks System (27 Hooks + 12 Workers)](#hooks-system)\n6. [Memory & Intelligence (RuVector)](#memory--intelligence)\n7. [Hive-Mind Consensus](#hive-mind-consensus)\n8. [Performance Targets](#performance-targets)\n9. [Integration Ecosystem](#integration-ecosystem)\n\n---\n\n## Overview\n\nRuFlo V3 is a domain-driven design architecture for multi-agent AI coordination with:\n\n- **15-Agent Swarm Coordination** with hierarchical and mesh topologies\n- **HNSW Vector Search** - 150x-12,500x faster pattern retrieval\n- **SONA Neural Learning** - Self-optimizing with <0.05ms adaptation\n- **Byzantine Fault Tolerance** - Queen-led consensus mechanisms\n- **MCP Server Integration** - Model Context Protocol support\n\n### Current Configuration\n| Setting | Value |\n|---------|-------|\n| Topology | " + options.runtime.topology + " |\n| Max Agents | " + options.runtime.maxAgents + " |\n| Memory Backend | " + options.runtime.memoryBackend + " |\n| HNSW Indexing | " + (options.runtime.enableHNSW ? 'Enabled' : 'Disabled') + " |\n| Neural Learning | " + (options.runtime.enableNeural ? 'Enabled' : 'Disabled') + " |\n| LearningBridge | " + (options.runtime.enableLearningBridge ? 'Enabled (SONA + ReasoningBank)' : 'Disabled') + " |\n| Knowledge Graph | " + (options.runtime.enableMemoryGraph ? 'Enabled (PageRank + Communities)' : 'Disabled') + " |\n| Agent Scopes | " + (options.runtime.enableAgentScopes ? 'Enabled (project/local/user)' : 'Disabled') + " |\n\n---\n\n## Swarm Orchestration\n\n### Topologies\n| Topology | Description | Best For |\n|----------|-------------|----------|\n| `hierarchical` | Queen controls workers directly | Anti-drift, tight control |\n| `mesh` | Fully connected peer network | Distributed tasks |\n| `hierarchical-mesh` | V3 hybrid (recommended) | 10+ agents |\n| `ring` | Circular communication | Sequential workflows |\n| `star` | Central coordinator | Simple coordination |\n| `adaptive` | Dynamic based on load | Variable workloads |\n\n### Strategies\n- `balanced` - Even distribution across agents\n- `specialized` - Clear roles, no overlap (anti-drift)\n- `adaptive` - Dynamic task routing\n\n### Quick Commands\n```bash\n# Initialize swarm\nnpx @claude-flow/cli@latest swarm init --topology hierarchical --max-agents 8 --strategy specialized\n\n# Check status\nnpx @claude-flow/cli@latest swarm status\n\n# Monitor activity\nnpx @claude-flow/cli@latest swarm monitor\n```\n\n---\n\n## Available Agents\n\n### Core Development (5)\n`coder`, `reviewer`, `tester`, `planner`, `researcher`\n\n### V3 Specialized (4)\n`security-architect`, `security-auditor`, `memory-specialist`, `performance-engineer`\n\n### Swarm Coordination (5)\n`hierarchical-coordinator`, `mesh-coordinator`, `adaptive-coordinator`, `collective-intelligence-coordinator`, `swarm-memory-manager`\n\n### Consensus & Distributed (7)\n`byzantine-coordinator`, `raft-manager`, `gossip-coordinator`, `consensus-builder`, `crdt-synchronizer`, `quorum-manager`, `security-manager`\n\n### Performance & Optimization (5)\n`perf-analyzer`, `performance-benchmarker`, `task-orchestrator`, `memory-coordinator`, `smart-agent`\n\n### GitHub & Repository (9)\n`github-modes`, `pr-manager`, `code-review-swarm`, `issue-tracker`, `release-manager`, `workflow-automation`, `project-board-sync`, `repo-architect`, `multi-repo-swarm`\n\n### SPARC Methodology (6)\n`sparc-coord`, `sparc-coder`, `specification`, `pseudocode`, `architecture`, `refinement`\n\n### Specialized Development (8)\n`backend-dev`, `mobile-dev`, `ml-developer`, `cicd-engineer`, `api-docs`, `system-architect`, `code-analyzer`, `base-template-generator`\n\n### Testing & Validation (2)\n`tdd-london-swarm`, `production-validator`\n\n### Agent Routing by Task\n| Task Type | Recommended Agents | Topology |\n|-----------|-------------------|----------|\n| Bug Fix | researcher, coder, tester | mesh |\n| New Feature | coordinator, architect, coder, tester, reviewer | hierarchical |\n| Refactoring | architect, coder, reviewer | mesh |\n| Performance | researcher, perf-engineer, coder | hierarchical |\n| Security | security-architect, auditor, reviewer | hierarchical |\n| Docs | researcher, api-docs | mesh |\n\n---\n\n## CLI Commands\n\n### Core Commands (12)\n| Command | Subcommands | Description |\n|---------|-------------|-------------|\n| `init` | 4 | Project initialization |\n| `agent` | 8 | Agent lifecycle management |\n| `swarm` | 6 | Multi-agent coordination |\n| `memory` | 11 | AgentDB with HNSW search |\n| `mcp` | 9 | MCP server management |\n| `task` | 6 | Task assignment |\n| `session` | 7 | Session persistence |\n| `config` | 7 | Configuration |\n| `status` | 3 | System monitoring |\n| `workflow` | 6 | Workflow templates |\n| `hooks` | 17 | Self-learning hooks |\n| `hive-mind` | 6 | Consensus coordination |\n\n### Advanced Commands (14)\n| Command | Subcommands | Description |\n|---------|-------------|-------------|\n| `daemon` | 5 | Background workers |\n| `neural` | 5 | Pattern training |\n| `security` | 6 | Security scanning |\n| `performance` | 5 | Profiling & benchmarks |\n| `providers` | 5 | AI provider config |\n| `plugins` | 5 | Plugin management |\n| `deployment` | 5 | Deploy management |\n| `embeddings` | 4 | Vector embeddings |\n| `claims` | 4 | Authorization |\n| `migrate` | 5 | V2\u2192V3 migration |\n| `process` | 4 | Process management |\n| `doctor` | 1 | Health diagnostics |\n| `completions` | 4 | Shell completions |\n\n### Example Commands\n```bash\n# Initialize\nnpx @claude-flow/cli@latest init --wizard\n\n# Spawn agent\nnpx @claude-flow/cli@latest agent spawn -t coder --name my-coder\n\n# Memory operations\nnpx @claude-flow/cli@latest memory store --key \"pattern\" --value \"data\" --namespace patterns\nnpx @claude-flow/cli@latest memory search --query \"authentication\"\n\n# Diagnostics\nnpx @claude-flow/cli@latest doctor --fix\n```\n\n---\n\n## Hooks System\n\n### 27 Available Hooks\n\n#### Core Hooks (6)\n| Hook | Description |\n|------|-------------|\n| `pre-edit` | Context before file edits |\n| `post-edit` | Record edit outcomes |\n| `pre-command` | Risk assessment |\n| `post-command` | Command metrics |\n| `pre-task` | Task start + agent suggestions |\n| `post-task` | Task completion learning |\n\n#### Session Hooks (4)\n| Hook | Description |\n|------|-------------|\n| `session-start` | Start/restore session |\n| `session-end` | Persist state |\n| `session-restore` | Restore previous |\n| `notify` | Cross-agent notifications |\n\n#### Intelligence Hooks (5)\n| Hook | Description |\n|------|-------------|\n| `route` | Optimal agent routing |\n| `explain` | Routing decisions |\n| `pretrain` | Bootstrap intelligence |\n| `build-agents` | Generate configs |\n| `transfer` | Pattern transfer |\n\n#### Coverage Hooks (3)\n| Hook | Description |\n|------|-------------|\n| `coverage-route` | Coverage-based routing |\n| `coverage-suggest` | Improvement suggestions |\n| `coverage-gaps` | Gap analysis |\n\n### 12 Background Workers\n| Worker | Priority | Purpose |\n|--------|----------|---------|\n| `ultralearn` | normal | Deep knowledge |\n| `optimize` | high | Performance |\n| `consolidate` | low | Memory consolidation |\n| `predict` | normal | Predictive preload |\n| `audit` | critical | Security |\n| `map` | normal | Codebase mapping |\n| `preload` | low | Resource preload |\n| `deepdive` | normal | Deep analysis |\n| `document` | normal | Auto-docs |\n| `refactor` | normal | Suggestions |\n| `benchmark` | normal | Benchmarking |\n| `testgaps` | normal | Coverage gaps |\n\n---\n\n## Memory & Intelligence\n\n### RuVector Intelligence System\n- **SONA**: Self-Optimizing Neural Architecture (<0.05ms)\n- **MoE**: Mixture of Experts routing\n- **HNSW**: 150x-12,500x faster search\n- **EWC++**: Prevents catastrophic forgetting\n- **Flash Attention**: 2.49x-7.47x speedup\n- **Int8 Quantization**: 3.92x memory reduction\n\n### 4-Step Intelligence Pipeline\n1. **RETRIEVE** - HNSW pattern search\n2. **JUDGE** - Success/failure verdicts\n3. **DISTILL** - LoRA learning extraction\n4. **CONSOLIDATE** - EWC++ preservation\n\n### Self-Learning Memory (ADR-049)\n\n| Component | Status | Description |\n|-----------|--------|-------------|\n| **LearningBridge** | " + (options.runtime.enableLearningBridge ? '✅ Enabled' : '⏸ Disabled') + " | Connects insights to SONA/ReasoningBank neural pipeline |\n| **MemoryGraph** | " + (options.runtime.enableMemoryGraph ? '✅ Enabled' : '⏸ Disabled') + " | PageRank knowledge graph + community detection |\n| **AgentMemoryScope** | " + (options.runtime.enableAgentScopes ? '✅ Enabled' : '⏸ Disabled') + " | 3-scope agent memory (project/local/user) |\n\n**LearningBridge** - Insights trigger learning trajectories. Confidence evolves: +0.03 on access, -0.005/hour decay. Consolidation runs the JUDGE/DISTILL/CONSOLIDATE pipeline.\n\n**MemoryGraph** - Builds a knowledge graph from entry references. PageRank identifies influential insights. Communities group related knowledge. Graph-aware ranking blends vector + structural scores.\n\n**AgentMemoryScope** - Maps Claude Code 3-scope directories:\n- `project`: `<gitRoot>/.claude/agent-memory/<agent>/`\n- `local`: `<gitRoot>/.claude/agent-memory-local/<agent>/`\n- `user`: `~/.claude/agent-memory/<agent>/`\n\nHigh-confidence insights (>0.8) can transfer between agents.\n\n### Memory Commands\n```bash\n# Store pattern\nnpx @claude-flow/cli@latest memory store --key \"name\" --value \"data\" --namespace patterns\n\n# Semantic search\nnpx @claude-flow/cli@latest memory search --query \"authentication\"\n\n# List entries\nnpx @claude-flow/cli@latest memory list --namespace patterns\n\n# Initialize database\nnpx @claude-flow/cli@latest memory init --force\n```\n\n---\n\n## Hive-Mind Consensus\n\n### Queen Types\n| Type | Role |\n|------|------|\n| Strategic Queen | Long-term planning |\n| Tactical Queen | Execution coordination |\n| Adaptive Queen | Dynamic optimization |\n\n### Worker Types (8)\n`researcher`, `coder`, `analyst`, `tester`, `architect`, `reviewer`, `optimizer`, `documenter`\n\n### Consensus Mechanisms\n| Mechanism | Fault Tolerance | Use Case |\n|-----------|-----------------|----------|\n| `byzantine` | f < n/3 faulty | Adversarial |\n| `raft` | f < n/2 failed | Leader-based |\n| `gossip` | Eventually consistent | Large scale |\n| `crdt` | Conflict-free | Distributed |\n| `quorum` | Configurable | Flexible |\n\n### Hive-Mind Commands\n```bash\n# Initialize\nnpx @claude-flow/cli@latest hive-mind init --queen-type strategic\n\n# Status\nnpx @claude-flow/cli@latest hive-mind status\n\n# Spawn workers\nnpx @claude-flow/cli@latest hive-mind spawn --count 5 --type worker\n\n# Consensus\nnpx @claude-flow/cli@latest hive-mind consensus --propose \"task\"\n```\n\n---\n\n## Performance Targets\n\n| Metric | Target | Status |\n|--------|--------|--------|\n| HNSW Search | 150x-12,500x faster | \u2705 Implemented |\n| Memory Reduction | 50-75% | \u2705 Implemented (3.92x) |\n| SONA Integration | Pattern learning | \u2705 Implemented |\n| Flash Attention | 2.49x-7.47x | \uD83D\uDD04 In Progress |\n| MCP Response | <100ms | \u2705 Achieved |\n| CLI Startup | <500ms | \u2705 Achieved |\n| SONA Adaptation | <0.05ms | \uD83D\uDD04 In Progress |\n| Graph Build (1k) | <200ms | \u2705 2.78ms (71.9x headroom) |\n| PageRank (1k) | <100ms | \u2705 12.21ms (8.2x headroom) |\n| Insight Recording | <5ms/each | \u2705 0.12ms (41x headroom) |\n| Consolidation | <500ms | \u2705 0.26ms (1,955x headroom) |\n| Knowledge Transfer | <100ms | \u2705 1.25ms (80x headroom) |\n\n---\n\n## Integration Ecosystem\n\n### Integrated Packages\n| Package | Version | Purpose |\n|---------|---------|---------|\n| agentic-flow | 3.0.0-alpha.1 | Core coordination + ReasoningBank + Router |\n| agentdb | 3.0.0-alpha.10 | Vector database + 8 controllers |\n| @ruvector/attention | 0.1.3 | Flash attention |\n| @ruvector/sona | 0.1.5 | Neural learning |\n\n### Optional Integrations\n| Package | Command |\n|---------|---------|\n| ruv-swarm | `npx ruv-swarm mcp start` |\n| flow-nexus | `npx flow-nexus@latest mcp start` |\n| agentic-jujutsu | `npx agentic-jujutsu@latest` |\n\n### MCP Server Setup\n```bash\n# Add Ruflo MCP\nclaude mcp add ruflo -- npx -y ruflo@latest\n\n# Optional servers\nclaude mcp add ruv-swarm -- npx -y ruv-swarm mcp start\nclaude mcp add flow-nexus -- npx -y flow-nexus@latest mcp start\n```\n\n---\n\n## Quick Reference\n\n### Essential Commands\n```bash\n# Setup\nnpx ruflo@latest init --wizard\nnpx ruflo@latest daemon start\nnpx ruflo@latest doctor --fix\n\n# Swarm\nnpx ruflo@latest swarm init --topology hierarchical --max-agents 8\nnpx ruflo@latest swarm status\n\n# Agents\nnpx ruflo@latest agent spawn -t coder\nnpx ruflo@latest agent list\n\n# Memory\nnpx ruflo@latest memory search --query \"patterns\"\n\n# Hooks\nnpx ruflo@latest hooks pre-task --description \"task\"\nnpx ruflo@latest hooks worker dispatch --trigger optimize\n```\n\n### File Structure\n```\n.claude-flow/\n\u251C\u2500\u2500 config.yaml # Runtime configuration\n\u251C\u2500\u2500 CAPABILITIES.md # This file\n\u251C\u2500\u2500 data/ # Memory storage\n\u251C\u2500\u2500 logs/ # Operation logs\n\u251C\u2500\u2500 sessions/ # Session state\n\u251C\u2500\u2500 hooks/ # Custom hooks\n\u251C\u2500\u2500 agents/ # Agent configs\n\u2514\u2500\u2500 workflows/ # Workflow templates\n```\n\n---\n\n**Full Documentation**: https://github.com/ruvnet/claude-flow\n**Issues**: https://github.com/ruvnet/claude-flow/issues\n";
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1209
|
+
async function writeCapabilitiesDoc(targetDir, options, result) {
|
|
1210
|
+
const capabilitiesPath = path.join(targetDir, '.claude-flow', 'CAPABILITIES.md');
|
|
1211
|
+
if (fs.existsSync(capabilitiesPath) && !options.force) {
|
|
1212
|
+
result.skipped.push('.claude-flow/CAPABILITIES.md');
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
const capabilities = `# RuFlo V3 - Complete Capabilities Reference
|
|
1216
|
+
> Generated: ${new Date().toISOString()}
|
|
1217
|
+
> Full documentation: https://github.com/ruvnet/claude-flow
|
|
1218
|
+
|
|
1219
|
+
## 📋 Table of Contents
|
|
1220
|
+
|
|
1221
|
+
1. [Overview](#overview)
|
|
1222
|
+
2. [Swarm Orchestration](#swarm-orchestration)
|
|
1223
|
+
3. [Available Agents (60+)](#available-agents)
|
|
1224
|
+
4. [CLI Commands (26 Commands, 140+ Subcommands)](#cli-commands)
|
|
1225
|
+
5. [Hooks System (27 Hooks + 12 Workers)](#hooks-system)
|
|
1226
|
+
6. [Memory & Intelligence (RuVector)](#memory--intelligence)
|
|
1227
|
+
7. [Hive-Mind Consensus](#hive-mind-consensus)
|
|
1228
|
+
8. [Performance Targets](#performance-targets)
|
|
1229
|
+
9. [Integration Ecosystem](#integration-ecosystem)
|
|
1230
|
+
|
|
1231
|
+
---
|
|
1232
|
+
|
|
1233
|
+
## Overview
|
|
1234
|
+
|
|
1235
|
+
RuFlo V3 is a domain-driven design architecture for multi-agent AI coordination with:
|
|
1236
|
+
|
|
1237
|
+
- **15-Agent Swarm Coordination** with hierarchical and mesh topologies
|
|
1238
|
+
- **HNSW Vector Search** - 150x-12,500x faster pattern retrieval
|
|
1239
|
+
- **SONA Neural Learning** - Self-optimizing with <0.05ms adaptation
|
|
1240
|
+
- **Byzantine Fault Tolerance** - Queen-led consensus mechanisms
|
|
1241
|
+
- **MCP Server Integration** - Model Context Protocol support
|
|
1242
|
+
|
|
1243
|
+
### Current Configuration
|
|
1244
|
+
| Setting | Value |
|
|
1245
|
+
|---------|-------|
|
|
1246
|
+
| Topology | ${options.runtime.topology} |
|
|
1247
|
+
| Max Agents | ${options.runtime.maxAgents} |
|
|
1248
|
+
| Memory Backend | ${options.runtime.memoryBackend} |
|
|
1249
|
+
| HNSW Indexing | ${options.runtime.enableHNSW ? 'Enabled' : 'Disabled'} |
|
|
1250
|
+
| Neural Learning | ${options.runtime.enableNeural ? 'Enabled' : 'Disabled'} |
|
|
1251
|
+
| LearningBridge | ${options.runtime.enableLearningBridge ? 'Enabled (SONA + ReasoningBank)' : 'Disabled'} |
|
|
1252
|
+
| Knowledge Graph | ${options.runtime.enableMemoryGraph ? 'Enabled (PageRank + Communities)' : 'Disabled'} |
|
|
1253
|
+
| Agent Scopes | ${options.runtime.enableAgentScopes ? 'Enabled (project/local/user)' : 'Disabled'} |
|
|
1254
|
+
|
|
1255
|
+
---
|
|
1256
|
+
|
|
1257
|
+
## Swarm Orchestration
|
|
1258
|
+
|
|
1259
|
+
### Topologies
|
|
1260
|
+
| Topology | Description | Best For |
|
|
1261
|
+
|----------|-------------|----------|
|
|
1262
|
+
| \`hierarchical\` | Queen controls workers directly | Anti-drift, tight control |
|
|
1263
|
+
| \`mesh\` | Fully connected peer network | Distributed tasks |
|
|
1264
|
+
| \`hierarchical-mesh\` | V3 hybrid (recommended) | 10+ agents |
|
|
1265
|
+
| \`ring\` | Circular communication | Sequential workflows |
|
|
1266
|
+
| \`star\` | Central coordinator | Simple coordination |
|
|
1267
|
+
| \`adaptive\` | Dynamic based on load | Variable workloads |
|
|
1268
|
+
|
|
1269
|
+
### Strategies
|
|
1270
|
+
- \`balanced\` - Even distribution across agents
|
|
1271
|
+
- \`specialized\` - Clear roles, no overlap (anti-drift)
|
|
1272
|
+
- \`adaptive\` - Dynamic task routing
|
|
1273
|
+
|
|
1274
|
+
### Quick Commands
|
|
1275
|
+
\`\`\`bash
|
|
1276
|
+
# Initialize swarm
|
|
1277
|
+
npx @claude-flow/cli@latest swarm init --topology hierarchical --max-agents 8 --strategy specialized
|
|
1278
|
+
|
|
1279
|
+
# Check status
|
|
1280
|
+
npx @claude-flow/cli@latest swarm status
|
|
1281
|
+
|
|
1282
|
+
# Monitor activity
|
|
1283
|
+
npx @claude-flow/cli@latest swarm monitor
|
|
1284
|
+
\`\`\`
|
|
1285
|
+
|
|
1286
|
+
---
|
|
1287
|
+
|
|
1288
|
+
## Available Agents
|
|
1289
|
+
|
|
1290
|
+
### Core Development (5)
|
|
1291
|
+
\`coder\`, \`reviewer\`, \`tester\`, \`planner\`, \`researcher\`
|
|
1292
|
+
|
|
1293
|
+
### V3 Specialized (4)
|
|
1294
|
+
\`security-architect\`, \`security-auditor\`, \`memory-specialist\`, \`performance-engineer\`
|
|
1295
|
+
|
|
1296
|
+
### Swarm Coordination (5)
|
|
1297
|
+
\`hierarchical-coordinator\`, \`mesh-coordinator\`, \`adaptive-coordinator\`, \`collective-intelligence-coordinator\`, \`swarm-memory-manager\`
|
|
1298
|
+
|
|
1299
|
+
### Consensus & Distributed (7)
|
|
1300
|
+
\`byzantine-coordinator\`, \`raft-manager\`, \`gossip-coordinator\`, \`consensus-builder\`, \`crdt-synchronizer\`, \`quorum-manager\`, \`security-manager\`
|
|
1301
|
+
|
|
1302
|
+
### Performance & Optimization (5)
|
|
1303
|
+
\`perf-analyzer\`, \`performance-benchmarker\`, \`task-orchestrator\`, \`memory-coordinator\`, \`smart-agent\`
|
|
1304
|
+
|
|
1305
|
+
### GitHub & Repository (9)
|
|
1306
|
+
\`github-modes\`, \`pr-manager\`, \`code-review-swarm\`, \`issue-tracker\`, \`release-manager\`, \`workflow-automation\`, \`project-board-sync\`, \`repo-architect\`, \`multi-repo-swarm\`
|
|
1307
|
+
|
|
1308
|
+
### SPARC Methodology (6)
|
|
1309
|
+
\`sparc-coord\`, \`sparc-coder\`, \`specification\`, \`pseudocode\`, \`architecture\`, \`refinement\`
|
|
1310
|
+
|
|
1311
|
+
### Specialized Development (8)
|
|
1312
|
+
\`backend-dev\`, \`mobile-dev\`, \`ml-developer\`, \`cicd-engineer\`, \`api-docs\`, \`system-architect\`, \`code-analyzer\`, \`base-template-generator\`
|
|
1313
|
+
|
|
1314
|
+
### Testing & Validation (2)
|
|
1315
|
+
\`tdd-london-swarm\`, \`production-validator\`
|
|
1316
|
+
|
|
1317
|
+
### Agent Routing by Task
|
|
1318
|
+
| Task Type | Recommended Agents | Topology |
|
|
1319
|
+
|-----------|-------------------|----------|
|
|
1320
|
+
| Bug Fix | researcher, coder, tester | mesh |
|
|
1321
|
+
| New Feature | coordinator, architect, coder, tester, reviewer | hierarchical |
|
|
1322
|
+
| Refactoring | architect, coder, reviewer | mesh |
|
|
1323
|
+
| Performance | researcher, perf-engineer, coder | hierarchical |
|
|
1324
|
+
| Security | security-architect, auditor, reviewer | hierarchical |
|
|
1325
|
+
| Docs | researcher, api-docs | mesh |
|
|
1326
|
+
|
|
1327
|
+
---
|
|
1328
|
+
|
|
1329
|
+
## CLI Commands
|
|
1330
|
+
|
|
1331
|
+
### Core Commands (12)
|
|
1332
|
+
| Command | Subcommands | Description |
|
|
1333
|
+
|---------|-------------|-------------|
|
|
1334
|
+
| \`init\` | 4 | Project initialization |
|
|
1335
|
+
| \`agent\` | 8 | Agent lifecycle management |
|
|
1336
|
+
| \`swarm\` | 6 | Multi-agent coordination |
|
|
1337
|
+
| \`memory\` | 11 | AgentDB with HNSW search |
|
|
1338
|
+
| \`mcp\` | 9 | MCP server management |
|
|
1339
|
+
| \`task\` | 6 | Task assignment |
|
|
1340
|
+
| \`session\` | 7 | Session persistence |
|
|
1341
|
+
| \`config\` | 7 | Configuration |
|
|
1342
|
+
| \`status\` | 3 | System monitoring |
|
|
1343
|
+
| \`workflow\` | 6 | Workflow templates |
|
|
1344
|
+
| \`hooks\` | 17 | Self-learning hooks |
|
|
1345
|
+
| \`hive-mind\` | 6 | Consensus coordination |
|
|
1346
|
+
|
|
1347
|
+
### Advanced Commands (14)
|
|
1348
|
+
| Command | Subcommands | Description |
|
|
1349
|
+
|---------|-------------|-------------|
|
|
1350
|
+
| \`daemon\` | 5 | Background workers |
|
|
1351
|
+
| \`neural\` | 5 | Pattern training |
|
|
1352
|
+
| \`security\` | 6 | Security scanning |
|
|
1353
|
+
| \`performance\` | 5 | Profiling & benchmarks |
|
|
1354
|
+
| \`providers\` | 5 | AI provider config |
|
|
1355
|
+
| \`plugins\` | 5 | Plugin management |
|
|
1356
|
+
| \`deployment\` | 5 | Deploy management |
|
|
1357
|
+
| \`embeddings\` | 4 | Vector embeddings |
|
|
1358
|
+
| \`claims\` | 4 | Authorization |
|
|
1359
|
+
| \`migrate\` | 5 | V2→V3 migration |
|
|
1360
|
+
| \`process\` | 4 | Process management |
|
|
1361
|
+
| \`doctor\` | 1 | Health diagnostics |
|
|
1362
|
+
| \`completions\` | 4 | Shell completions |
|
|
1363
|
+
|
|
1364
|
+
### Example Commands
|
|
1365
|
+
\`\`\`bash
|
|
1366
|
+
# Initialize
|
|
1367
|
+
npx @claude-flow/cli@latest init --wizard
|
|
1368
|
+
|
|
1369
|
+
# Spawn agent
|
|
1370
|
+
npx @claude-flow/cli@latest agent spawn -t coder --name my-coder
|
|
1371
|
+
|
|
1372
|
+
# Memory operations
|
|
1373
|
+
npx @claude-flow/cli@latest memory store --key "pattern" --value "data" --namespace patterns
|
|
1374
|
+
npx @claude-flow/cli@latest memory search --query "authentication"
|
|
1375
|
+
|
|
1376
|
+
# Diagnostics
|
|
1377
|
+
npx @claude-flow/cli@latest doctor --fix
|
|
1378
|
+
\`\`\`
|
|
1379
|
+
|
|
1380
|
+
---
|
|
1381
|
+
|
|
1382
|
+
## Hooks System
|
|
1383
|
+
|
|
1384
|
+
### 27 Available Hooks
|
|
1385
|
+
|
|
1386
|
+
#### Core Hooks (6)
|
|
1387
|
+
| Hook | Description |
|
|
1388
|
+
|------|-------------|
|
|
1389
|
+
| \`pre-edit\` | Context before file edits |
|
|
1390
|
+
| \`post-edit\` | Record edit outcomes |
|
|
1391
|
+
| \`pre-command\` | Risk assessment |
|
|
1392
|
+
| \`post-command\` | Command metrics |
|
|
1393
|
+
| \`pre-task\` | Task start + agent suggestions |
|
|
1394
|
+
| \`post-task\` | Task completion learning |
|
|
1395
|
+
|
|
1396
|
+
#### Session Hooks (4)
|
|
1397
|
+
| Hook | Description |
|
|
1398
|
+
|------|-------------|
|
|
1399
|
+
| \`session-start\` | Start/restore session |
|
|
1400
|
+
| \`session-end\` | Persist state |
|
|
1401
|
+
| \`session-restore\` | Restore previous |
|
|
1402
|
+
| \`notify\` | Cross-agent notifications |
|
|
1403
|
+
|
|
1404
|
+
#### Intelligence Hooks (5)
|
|
1405
|
+
| Hook | Description |
|
|
1406
|
+
|------|-------------|
|
|
1407
|
+
| \`route\` | Optimal agent routing |
|
|
1408
|
+
| \`explain\` | Routing decisions |
|
|
1409
|
+
| \`pretrain\` | Bootstrap intelligence |
|
|
1410
|
+
| \`build-agents\` | Generate configs |
|
|
1411
|
+
| \`transfer\` | Pattern transfer |
|
|
1412
|
+
|
|
1413
|
+
#### Coverage Hooks (3)
|
|
1414
|
+
| Hook | Description |
|
|
1415
|
+
|------|-------------|
|
|
1416
|
+
| \`coverage-route\` | Coverage-based routing |
|
|
1417
|
+
| \`coverage-suggest\` | Improvement suggestions |
|
|
1418
|
+
| \`coverage-gaps\` | Gap analysis |
|
|
1419
|
+
|
|
1420
|
+
### 12 Background Workers
|
|
1421
|
+
| Worker | Priority | Purpose |
|
|
1422
|
+
|--------|----------|---------|
|
|
1423
|
+
| \`ultralearn\` | normal | Deep knowledge |
|
|
1424
|
+
| \`optimize\` | high | Performance |
|
|
1425
|
+
| \`consolidate\` | low | Memory consolidation |
|
|
1426
|
+
| \`predict\` | normal | Predictive preload |
|
|
1427
|
+
| \`audit\` | critical | Security |
|
|
1428
|
+
| \`map\` | normal | Codebase mapping |
|
|
1429
|
+
| \`preload\` | low | Resource preload |
|
|
1430
|
+
| \`deepdive\` | normal | Deep analysis |
|
|
1431
|
+
| \`document\` | normal | Auto-docs |
|
|
1432
|
+
| \`refactor\` | normal | Suggestions |
|
|
1433
|
+
| \`benchmark\` | normal | Benchmarking |
|
|
1434
|
+
| \`testgaps\` | normal | Coverage gaps |
|
|
1435
|
+
|
|
1436
|
+
---
|
|
1437
|
+
|
|
1438
|
+
## Memory & Intelligence
|
|
1439
|
+
|
|
1440
|
+
### RuVector Intelligence System
|
|
1441
|
+
- **SONA**: Self-Optimizing Neural Architecture (<0.05ms)
|
|
1442
|
+
- **MoE**: Mixture of Experts routing
|
|
1443
|
+
- **HNSW**: 150x-12,500x faster search
|
|
1444
|
+
- **EWC++**: Prevents catastrophic forgetting
|
|
1445
|
+
- **Flash Attention**: 2.49x-7.47x speedup
|
|
1446
|
+
- **Int8 Quantization**: 3.92x memory reduction
|
|
1447
|
+
|
|
1448
|
+
### 4-Step Intelligence Pipeline
|
|
1449
|
+
1. **RETRIEVE** - HNSW pattern search
|
|
1450
|
+
2. **JUDGE** - Success/failure verdicts
|
|
1451
|
+
3. **DISTILL** - LoRA learning extraction
|
|
1452
|
+
4. **CONSOLIDATE** - EWC++ preservation
|
|
1453
|
+
|
|
1454
|
+
### Self-Learning Memory (ADR-049)
|
|
1455
|
+
|
|
1456
|
+
| Component | Status | Description |
|
|
1457
|
+
|-----------|--------|-------------|
|
|
1458
|
+
| **LearningBridge** | ${options.runtime.enableLearningBridge ? '✅ Enabled' : '⏸ Disabled'} | Connects insights to SONA/ReasoningBank neural pipeline |
|
|
1459
|
+
| **MemoryGraph** | ${options.runtime.enableMemoryGraph ? '✅ Enabled' : '⏸ Disabled'} | PageRank knowledge graph + community detection |
|
|
1460
|
+
| **AgentMemoryScope** | ${options.runtime.enableAgentScopes ? '✅ Enabled' : '⏸ Disabled'} | 3-scope agent memory (project/local/user) |
|
|
1461
|
+
|
|
1462
|
+
**LearningBridge** - Insights trigger learning trajectories. Confidence evolves: +0.03 on access, -0.005/hour decay. Consolidation runs the JUDGE/DISTILL/CONSOLIDATE pipeline.
|
|
1463
|
+
|
|
1464
|
+
**MemoryGraph** - Builds a knowledge graph from entry references. PageRank identifies influential insights. Communities group related knowledge. Graph-aware ranking blends vector + structural scores.
|
|
1465
|
+
|
|
1466
|
+
**AgentMemoryScope** - Maps Claude Code 3-scope directories:
|
|
1467
|
+
- \`project\`: \`<gitRoot>/.claude/agent-memory/<agent>/\`
|
|
1468
|
+
- \`local\`: \`<gitRoot>/.claude/agent-memory-local/<agent>/\`
|
|
1469
|
+
- \`user\`: \`~/.claude/agent-memory/<agent>/\`
|
|
1470
|
+
|
|
1471
|
+
High-confidence insights (>0.8) can transfer between agents.
|
|
1472
|
+
|
|
1473
|
+
### Memory Commands
|
|
1474
|
+
\`\`\`bash
|
|
1475
|
+
# Store pattern
|
|
1476
|
+
npx @claude-flow/cli@latest memory store --key "name" --value "data" --namespace patterns
|
|
1477
|
+
|
|
1478
|
+
# Semantic search
|
|
1479
|
+
npx @claude-flow/cli@latest memory search --query "authentication"
|
|
1480
|
+
|
|
1481
|
+
# List entries
|
|
1482
|
+
npx @claude-flow/cli@latest memory list --namespace patterns
|
|
1483
|
+
|
|
1484
|
+
# Initialize database
|
|
1485
|
+
npx @claude-flow/cli@latest memory init --force
|
|
1486
|
+
\`\`\`
|
|
1487
|
+
|
|
1488
|
+
---
|
|
1489
|
+
|
|
1490
|
+
## Hive-Mind Consensus
|
|
1491
|
+
|
|
1492
|
+
### Queen Types
|
|
1493
|
+
| Type | Role |
|
|
1494
|
+
|------|------|
|
|
1495
|
+
| Strategic Queen | Long-term planning |
|
|
1496
|
+
| Tactical Queen | Execution coordination |
|
|
1497
|
+
| Adaptive Queen | Dynamic optimization |
|
|
1498
|
+
|
|
1499
|
+
### Worker Types (8)
|
|
1500
|
+
\`researcher\`, \`coder\`, \`analyst\`, \`tester\`, \`architect\`, \`reviewer\`, \`optimizer\`, \`documenter\`
|
|
1501
|
+
|
|
1502
|
+
### Consensus Mechanisms
|
|
1503
|
+
| Mechanism | Fault Tolerance | Use Case |
|
|
1504
|
+
|-----------|-----------------|----------|
|
|
1505
|
+
| \`byzantine\` | f < n/3 faulty | Adversarial |
|
|
1506
|
+
| \`raft\` | f < n/2 failed | Leader-based |
|
|
1507
|
+
| \`gossip\` | Eventually consistent | Large scale |
|
|
1508
|
+
| \`crdt\` | Conflict-free | Distributed |
|
|
1509
|
+
| \`quorum\` | Configurable | Flexible |
|
|
1510
|
+
|
|
1511
|
+
### Hive-Mind Commands
|
|
1512
|
+
\`\`\`bash
|
|
1513
|
+
# Initialize
|
|
1514
|
+
npx @claude-flow/cli@latest hive-mind init --queen-type strategic
|
|
1515
|
+
|
|
1516
|
+
# Status
|
|
1517
|
+
npx @claude-flow/cli@latest hive-mind status
|
|
1518
|
+
|
|
1519
|
+
# Spawn workers
|
|
1520
|
+
npx @claude-flow/cli@latest hive-mind spawn --count 5 --type worker
|
|
1521
|
+
|
|
1522
|
+
# Consensus
|
|
1523
|
+
npx @claude-flow/cli@latest hive-mind consensus --propose "task"
|
|
1524
|
+
\`\`\`
|
|
1525
|
+
|
|
1526
|
+
---
|
|
1527
|
+
|
|
1528
|
+
## Performance Targets
|
|
1529
|
+
|
|
1530
|
+
| Metric | Target | Status |
|
|
1531
|
+
|--------|--------|--------|
|
|
1532
|
+
| HNSW Search | 150x-12,500x faster | ✅ Implemented |
|
|
1533
|
+
| Memory Reduction | 50-75% | ✅ Implemented (3.92x) |
|
|
1534
|
+
| SONA Integration | Pattern learning | ✅ Implemented |
|
|
1535
|
+
| Flash Attention | 2.49x-7.47x | 🔄 In Progress |
|
|
1536
|
+
| MCP Response | <100ms | ✅ Achieved |
|
|
1537
|
+
| CLI Startup | <500ms | ✅ Achieved |
|
|
1538
|
+
| SONA Adaptation | <0.05ms | 🔄 In Progress |
|
|
1539
|
+
| Graph Build (1k) | <200ms | ✅ 2.78ms (71.9x headroom) |
|
|
1540
|
+
| PageRank (1k) | <100ms | ✅ 12.21ms (8.2x headroom) |
|
|
1541
|
+
| Insight Recording | <5ms/each | ✅ 0.12ms (41x headroom) |
|
|
1542
|
+
| Consolidation | <500ms | ✅ 0.26ms (1,955x headroom) |
|
|
1543
|
+
| Knowledge Transfer | <100ms | ✅ 1.25ms (80x headroom) |
|
|
1544
|
+
|
|
1545
|
+
---
|
|
1546
|
+
|
|
1547
|
+
## Integration Ecosystem
|
|
1548
|
+
|
|
1549
|
+
### Integrated Packages
|
|
1550
|
+
| Package | Version | Purpose |
|
|
1551
|
+
|---------|---------|---------|
|
|
1552
|
+
| agentic-flow | 3.0.0-alpha.1 | Core coordination + ReasoningBank + Router |
|
|
1553
|
+
| agentdb | 3.0.0-alpha.10 | Vector database + 8 controllers |
|
|
1554
|
+
| @ruvector/attention | 0.1.3 | Flash attention |
|
|
1555
|
+
| @ruvector/sona | 0.1.5 | Neural learning |
|
|
1556
|
+
|
|
1557
|
+
### Optional Integrations
|
|
1558
|
+
| Package | Command |
|
|
1559
|
+
|---------|---------|
|
|
1560
|
+
| ruv-swarm | \`npx ruv-swarm mcp start\` |
|
|
1561
|
+
| flow-nexus | \`npx flow-nexus@latest mcp start\` |
|
|
1562
|
+
| agentic-jujutsu | \`npx agentic-jujutsu@latest\` |
|
|
1563
|
+
|
|
1564
|
+
### MCP Server Setup
|
|
1565
|
+
\`\`\`bash
|
|
1566
|
+
# Add Ruflo MCP
|
|
1567
|
+
claude mcp add ruflo -- npx -y ruflo@latest
|
|
1568
|
+
|
|
1569
|
+
# Optional servers
|
|
1570
|
+
claude mcp add ruv-swarm -- npx -y ruv-swarm mcp start
|
|
1571
|
+
claude mcp add flow-nexus -- npx -y flow-nexus@latest mcp start
|
|
1572
|
+
\`\`\`
|
|
1573
|
+
|
|
1574
|
+
---
|
|
1575
|
+
|
|
1576
|
+
## Quick Reference
|
|
1577
|
+
|
|
1578
|
+
### Essential Commands
|
|
1579
|
+
\`\`\`bash
|
|
1580
|
+
# Setup
|
|
1581
|
+
npx ruflo@latest init --wizard
|
|
1582
|
+
npx ruflo@latest daemon start
|
|
1583
|
+
npx ruflo@latest doctor --fix
|
|
1584
|
+
|
|
1585
|
+
# Swarm
|
|
1586
|
+
npx ruflo@latest swarm init --topology hierarchical --max-agents 8
|
|
1587
|
+
npx ruflo@latest swarm status
|
|
1588
|
+
|
|
1589
|
+
# Agents
|
|
1590
|
+
npx ruflo@latest agent spawn -t coder
|
|
1591
|
+
npx ruflo@latest agent list
|
|
1592
|
+
|
|
1593
|
+
# Memory
|
|
1594
|
+
npx ruflo@latest memory search --query "patterns"
|
|
1595
|
+
|
|
1596
|
+
# Hooks
|
|
1597
|
+
npx ruflo@latest hooks pre-task --description "task"
|
|
1598
|
+
npx ruflo@latest hooks worker dispatch --trigger optimize
|
|
1599
|
+
\`\`\`
|
|
1600
|
+
|
|
1601
|
+
### File Structure
|
|
1602
|
+
\`\`\`
|
|
1603
|
+
.claude-flow/
|
|
1604
|
+
├── config.yaml # Runtime configuration
|
|
1605
|
+
├── CAPABILITIES.md # This file
|
|
1606
|
+
├── data/ # Memory storage
|
|
1607
|
+
├── logs/ # Operation logs
|
|
1608
|
+
├── sessions/ # Session state
|
|
1609
|
+
├── hooks/ # Custom hooks
|
|
1610
|
+
├── agents/ # Agent configs
|
|
1611
|
+
└── workflows/ # Workflow templates
|
|
1612
|
+
\`\`\`
|
|
1613
|
+
|
|
1614
|
+
---
|
|
1615
|
+
|
|
1616
|
+
**Full Documentation**: https://github.com/ruvnet/claude-flow
|
|
1617
|
+
**Issues**: https://github.com/ruvnet/claude-flow/issues
|
|
1618
|
+
`;
|
|
1619
|
+
fs.writeFileSync(capabilitiesPath, capabilities, 'utf-8');
|
|
1620
|
+
result.created.files.push('.claude-flow/CAPABILITIES.md');
|
|
1302
1621
|
}
|
|
1303
1622
|
/**
|
|
1304
1623
|
* Write CLAUDE.md with swarm guidance
|
|
1305
1624
|
*/
|
|
1306
|
-
function writeClaudeMd(targetDir, options, result) {
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
fs.writeFileSync(claudeMdPath, content, 'utf-8');
|
|
1318
|
-
result.created.files.push('CLAUDE.md');
|
|
1319
|
-
return [2 /*return*/];
|
|
1320
|
-
});
|
|
1321
|
-
});
|
|
1625
|
+
async function writeClaudeMd(targetDir, options, result) {
|
|
1626
|
+
const claudeMdPath = path.join(targetDir, 'CLAUDE.md');
|
|
1627
|
+
if (fs.existsSync(claudeMdPath) && !options.force) {
|
|
1628
|
+
result.skipped.push('CLAUDE.md');
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
// Determine template: explicit option > infer from components > 'standard'
|
|
1632
|
+
const inferredTemplate = (!options.components.commands && !options.components.agents) ? 'minimal' : undefined;
|
|
1633
|
+
const content = generateClaudeMd(options, inferredTemplate);
|
|
1634
|
+
fs.writeFileSync(claudeMdPath, content, 'utf-8');
|
|
1635
|
+
result.created.files.push('CLAUDE.md');
|
|
1322
1636
|
}
|
|
1323
1637
|
/**
|
|
1324
1638
|
* Find source directory for skills/commands/agents
|
|
1325
1639
|
*/
|
|
1326
1640
|
function findSourceDir(type, sourceBaseDir) {
|
|
1327
1641
|
// Build list of possible paths to check
|
|
1328
|
-
|
|
1642
|
+
const possiblePaths = [];
|
|
1329
1643
|
// If explicit source base directory is provided, use it first
|
|
1330
1644
|
if (sourceBaseDir) {
|
|
1331
1645
|
possiblePaths.push(path.join(sourceBaseDir, '.claude', type));
|
|
@@ -1334,38 +1648,37 @@ function findSourceDir(type, sourceBaseDir) {
|
|
|
1334
1648
|
// This is the primary path when running as an npm package
|
|
1335
1649
|
// __dirname is typically /path/to/node_modules/@claude-flow/cli/dist/src/init
|
|
1336
1650
|
// We need to go up 3 levels to reach the package root (dist/src/init -> dist/src -> dist -> root)
|
|
1337
|
-
|
|
1338
|
-
|
|
1651
|
+
const packageRoot = path.resolve(__dirname, '..', '..', '..');
|
|
1652
|
+
const packageDotClaude = path.join(packageRoot, '.claude', type);
|
|
1339
1653
|
if (fs.existsSync(packageDotClaude)) {
|
|
1340
1654
|
possiblePaths.unshift(packageDotClaude); // Add to beginning (highest priority)
|
|
1341
1655
|
}
|
|
1342
1656
|
// From dist/src/init -> go up to project root
|
|
1343
|
-
|
|
1657
|
+
const distPath = __dirname;
|
|
1344
1658
|
// Try to find the project root by looking for .claude directory
|
|
1345
|
-
|
|
1346
|
-
for (
|
|
1347
|
-
|
|
1348
|
-
|
|
1659
|
+
let currentDir = distPath;
|
|
1660
|
+
for (let i = 0; i < 10; i++) {
|
|
1661
|
+
const parentDir = path.dirname(currentDir);
|
|
1662
|
+
const dotClaudePath = path.join(parentDir, '.claude', type);
|
|
1349
1663
|
if (fs.existsSync(dotClaudePath)) {
|
|
1350
1664
|
possiblePaths.push(dotClaudePath);
|
|
1351
1665
|
}
|
|
1352
1666
|
currentDir = parentDir;
|
|
1353
1667
|
}
|
|
1354
1668
|
// Also check relative to process.cwd() for development
|
|
1355
|
-
|
|
1669
|
+
const cwdBased = [
|
|
1356
1670
|
path.join(process.cwd(), '.claude', type),
|
|
1357
1671
|
path.join(process.cwd(), '..', '.claude', type),
|
|
1358
1672
|
path.join(process.cwd(), '..', '..', '.claude', type),
|
|
1359
1673
|
];
|
|
1360
|
-
possiblePaths.push
|
|
1674
|
+
possiblePaths.push(...cwdBased);
|
|
1361
1675
|
// Check v2 directory for agents
|
|
1362
1676
|
if (type === 'agents') {
|
|
1363
1677
|
possiblePaths.push(path.join(process.cwd(), 'v2', '.claude', type), path.join(process.cwd(), '..', 'v2', '.claude', type));
|
|
1364
1678
|
}
|
|
1365
1679
|
// Plugin directory
|
|
1366
1680
|
possiblePaths.push(path.join(process.cwd(), 'plugin', type), path.join(process.cwd(), '..', 'plugin', type));
|
|
1367
|
-
for (
|
|
1368
|
-
var p = possiblePaths_3[_i];
|
|
1681
|
+
for (const p of possiblePaths) {
|
|
1369
1682
|
if (fs.existsSync(p)) {
|
|
1370
1683
|
return p;
|
|
1371
1684
|
}
|
|
@@ -1377,11 +1690,10 @@ function findSourceDir(type, sourceBaseDir) {
|
|
|
1377
1690
|
*/
|
|
1378
1691
|
function copyDirRecursive(src, dest) {
|
|
1379
1692
|
fs.mkdirSync(dest, { recursive: true });
|
|
1380
|
-
|
|
1381
|
-
for (
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
var destPath = path.join(dest, entry.name);
|
|
1693
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
1694
|
+
for (const entry of entries) {
|
|
1695
|
+
const srcPath = path.join(src, entry.name);
|
|
1696
|
+
const destPath = path.join(dest, entry.name);
|
|
1385
1697
|
if (entry.isDirectory()) {
|
|
1386
1698
|
copyDirRecursive(srcPath, destPath);
|
|
1387
1699
|
}
|
|
@@ -1394,11 +1706,10 @@ function copyDirRecursive(src, dest) {
|
|
|
1394
1706
|
* Count files with extension in directory
|
|
1395
1707
|
*/
|
|
1396
1708
|
function countFiles(dir, ext) {
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
for (
|
|
1400
|
-
|
|
1401
|
-
var fullPath = path.join(dir, entry.name);
|
|
1709
|
+
let count = 0;
|
|
1710
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
1711
|
+
for (const entry of entries) {
|
|
1712
|
+
const fullPath = path.join(dir, entry.name);
|
|
1402
1713
|
if (entry.isDirectory()) {
|
|
1403
1714
|
count += countFiles(fullPath, ext);
|
|
1404
1715
|
}
|
|
@@ -1412,8 +1723,8 @@ function countFiles(dir, ext) {
|
|
|
1412
1723
|
* Count enabled hooks
|
|
1413
1724
|
*/
|
|
1414
1725
|
function countEnabledHooks(options) {
|
|
1415
|
-
|
|
1416
|
-
|
|
1726
|
+
const hooks = options.hooks;
|
|
1727
|
+
let count = 0;
|
|
1417
1728
|
if (hooks.preToolUse)
|
|
1418
1729
|
count++;
|
|
1419
1730
|
if (hooks.postToolUse)
|