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
|
@@ -18,77 +18,6 @@
|
|
|
18
18
|
* - Execution logging for debugging
|
|
19
19
|
* - Event emission for monitoring
|
|
20
20
|
*/
|
|
21
|
-
var __extends = (this && this.__extends) || (function () {
|
|
22
|
-
var extendStatics = function (d, b) {
|
|
23
|
-
extendStatics = Object.setPrototypeOf ||
|
|
24
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
25
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
26
|
-
return extendStatics(d, b);
|
|
27
|
-
};
|
|
28
|
-
return function (d, b) {
|
|
29
|
-
if (typeof b !== "function" && b !== null)
|
|
30
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
31
|
-
extendStatics(d, b);
|
|
32
|
-
function __() { this.constructor = d; }
|
|
33
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
var __assign = (this && this.__assign) || function () {
|
|
37
|
-
__assign = Object.assign || function(t) {
|
|
38
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
39
|
-
s = arguments[i];
|
|
40
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
41
|
-
t[p] = s[p];
|
|
42
|
-
}
|
|
43
|
-
return t;
|
|
44
|
-
};
|
|
45
|
-
return __assign.apply(this, arguments);
|
|
46
|
-
};
|
|
47
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
48
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
49
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
50
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
51
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
52
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
53
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
57
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
58
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
59
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
60
|
-
function step(op) {
|
|
61
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
62
|
-
while (_) try {
|
|
63
|
-
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;
|
|
64
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
65
|
-
switch (op[0]) {
|
|
66
|
-
case 0: case 1: t = op; break;
|
|
67
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
68
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
69
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
70
|
-
default:
|
|
71
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
72
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
73
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
74
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
75
|
-
if (t[2]) _.ops.pop();
|
|
76
|
-
_.trys.pop(); continue;
|
|
77
|
-
}
|
|
78
|
-
op = body.call(thisArg, _);
|
|
79
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
80
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
84
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
85
|
-
if (ar || !(i in from)) {
|
|
86
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
87
|
-
ar[i] = from[i];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
91
|
-
};
|
|
92
21
|
import { spawn, execSync } from 'child_process';
|
|
93
22
|
import { EventEmitter } from 'events';
|
|
94
23
|
import { existsSync, readFileSync, readdirSync, mkdirSync, writeFileSync } from 'fs';
|
|
@@ -99,7 +28,7 @@ import { join } from 'path';
|
|
|
99
28
|
/**
|
|
100
29
|
* Array of headless worker types for runtime checking
|
|
101
30
|
*/
|
|
102
|
-
export
|
|
31
|
+
export const HEADLESS_WORKER_TYPES = [
|
|
103
32
|
'audit',
|
|
104
33
|
'optimize',
|
|
105
34
|
'testgaps',
|
|
@@ -112,7 +41,7 @@ export var HEADLESS_WORKER_TYPES = [
|
|
|
112
41
|
/**
|
|
113
42
|
* Array of local worker types
|
|
114
43
|
*/
|
|
115
|
-
export
|
|
44
|
+
export const LOCAL_WORKER_TYPES = [
|
|
116
45
|
'map',
|
|
117
46
|
'consolidate',
|
|
118
47
|
'benchmark',
|
|
@@ -121,15 +50,15 @@ export var LOCAL_WORKER_TYPES = [
|
|
|
121
50
|
/**
|
|
122
51
|
* Model ID mapping
|
|
123
52
|
*/
|
|
124
|
-
|
|
53
|
+
const MODEL_IDS = {
|
|
125
54
|
sonnet: 'claude-sonnet-4-5-20250929',
|
|
126
55
|
opus: 'claude-opus-4-6',
|
|
127
|
-
haiku: 'claude-haiku-4-5-20251001'
|
|
56
|
+
haiku: 'claude-haiku-4-5-20251001',
|
|
128
57
|
};
|
|
129
58
|
/**
|
|
130
59
|
* Default headless worker configurations based on ADR-020
|
|
131
60
|
*/
|
|
132
|
-
export
|
|
61
|
+
export const HEADLESS_WORKER_CONFIGS = {
|
|
133
62
|
audit: {
|
|
134
63
|
type: 'audit',
|
|
135
64
|
mode: 'headless',
|
|
@@ -138,13 +67,25 @@ export var HEADLESS_WORKER_CONFIGS = {
|
|
|
138
67
|
description: 'AI-powered security analysis',
|
|
139
68
|
enabled: true,
|
|
140
69
|
headless: {
|
|
141
|
-
promptTemplate:
|
|
70
|
+
promptTemplate: `Analyze this codebase for security vulnerabilities:
|
|
71
|
+
- Check for hardcoded secrets (API keys, passwords)
|
|
72
|
+
- Identify SQL injection risks
|
|
73
|
+
- Find XSS vulnerabilities
|
|
74
|
+
- Check for insecure dependencies
|
|
75
|
+
- Identify authentication/authorization issues
|
|
76
|
+
|
|
77
|
+
Provide a JSON report with:
|
|
78
|
+
{
|
|
79
|
+
"vulnerabilities": [{ "severity": "high|medium|low", "file": "...", "line": N, "description": "..." }],
|
|
80
|
+
"riskScore": 0-100,
|
|
81
|
+
"recommendations": ["..."]
|
|
82
|
+
}`,
|
|
142
83
|
sandbox: 'strict',
|
|
143
84
|
model: 'haiku',
|
|
144
85
|
outputFormat: 'json',
|
|
145
86
|
contextPatterns: ['**/*.ts', '**/*.js', '**/.env*', '**/package.json'],
|
|
146
|
-
timeoutMs: 5 * 60 * 1000
|
|
147
|
-
}
|
|
87
|
+
timeoutMs: 5 * 60 * 1000,
|
|
88
|
+
},
|
|
148
89
|
},
|
|
149
90
|
optimize: {
|
|
150
91
|
type: 'optimize',
|
|
@@ -154,13 +95,20 @@ export var HEADLESS_WORKER_CONFIGS = {
|
|
|
154
95
|
description: 'AI optimization suggestions',
|
|
155
96
|
enabled: true,
|
|
156
97
|
headless: {
|
|
157
|
-
promptTemplate:
|
|
98
|
+
promptTemplate: `Analyze this codebase for performance optimizations:
|
|
99
|
+
- Identify N+1 query patterns
|
|
100
|
+
- Find unnecessary re-renders in React
|
|
101
|
+
- Suggest caching opportunities
|
|
102
|
+
- Identify memory leaks
|
|
103
|
+
- Find redundant computations
|
|
104
|
+
|
|
105
|
+
Provide actionable suggestions with code examples.`,
|
|
158
106
|
sandbox: 'permissive',
|
|
159
107
|
model: 'sonnet',
|
|
160
108
|
outputFormat: 'markdown',
|
|
161
109
|
contextPatterns: ['src/**/*.ts', 'src/**/*.tsx'],
|
|
162
|
-
timeoutMs: 10 * 60 * 1000
|
|
163
|
-
}
|
|
110
|
+
timeoutMs: 10 * 60 * 1000,
|
|
111
|
+
},
|
|
164
112
|
},
|
|
165
113
|
testgaps: {
|
|
166
114
|
type: 'testgaps',
|
|
@@ -170,13 +118,20 @@ export var HEADLESS_WORKER_CONFIGS = {
|
|
|
170
118
|
description: 'AI test gap analysis',
|
|
171
119
|
enabled: true,
|
|
172
120
|
headless: {
|
|
173
|
-
promptTemplate:
|
|
121
|
+
promptTemplate: `Analyze test coverage and identify gaps:
|
|
122
|
+
- Find untested functions and classes
|
|
123
|
+
- Identify edge cases not covered
|
|
124
|
+
- Suggest new test scenarios
|
|
125
|
+
- Check for missing error handling tests
|
|
126
|
+
- Identify integration test gaps
|
|
127
|
+
|
|
128
|
+
For each gap, provide a test skeleton.`,
|
|
174
129
|
sandbox: 'permissive',
|
|
175
130
|
model: 'sonnet',
|
|
176
131
|
outputFormat: 'markdown',
|
|
177
132
|
contextPatterns: ['src/**/*.ts', 'tests/**/*.ts', '__tests__/**/*.ts'],
|
|
178
|
-
timeoutMs: 10 * 60 * 1000
|
|
179
|
-
}
|
|
133
|
+
timeoutMs: 10 * 60 * 1000,
|
|
134
|
+
},
|
|
180
135
|
},
|
|
181
136
|
document: {
|
|
182
137
|
type: 'document',
|
|
@@ -186,61 +141,95 @@ export var HEADLESS_WORKER_CONFIGS = {
|
|
|
186
141
|
description: 'AI documentation generation',
|
|
187
142
|
enabled: false,
|
|
188
143
|
headless: {
|
|
189
|
-
promptTemplate:
|
|
144
|
+
promptTemplate: `Generate documentation for undocumented code:
|
|
145
|
+
- Add JSDoc comments to functions
|
|
146
|
+
- Create README sections for modules
|
|
147
|
+
- Document API endpoints
|
|
148
|
+
- Add inline comments for complex logic
|
|
149
|
+
- Generate usage examples
|
|
150
|
+
|
|
151
|
+
Focus on public APIs and exported functions.`,
|
|
190
152
|
sandbox: 'permissive',
|
|
191
153
|
model: 'haiku',
|
|
192
154
|
outputFormat: 'markdown',
|
|
193
155
|
contextPatterns: ['src/**/*.ts'],
|
|
194
|
-
timeoutMs: 10 * 60 * 1000
|
|
195
|
-
}
|
|
156
|
+
timeoutMs: 10 * 60 * 1000,
|
|
157
|
+
},
|
|
196
158
|
},
|
|
197
159
|
ultralearn: {
|
|
198
160
|
type: 'ultralearn',
|
|
199
161
|
mode: 'headless',
|
|
200
|
-
intervalMs: 0,
|
|
162
|
+
intervalMs: 0, // Manual trigger only
|
|
201
163
|
priority: 'normal',
|
|
202
164
|
description: 'Deep knowledge acquisition',
|
|
203
165
|
enabled: false,
|
|
204
166
|
headless: {
|
|
205
|
-
promptTemplate:
|
|
167
|
+
promptTemplate: `Deeply analyze this codebase to learn:
|
|
168
|
+
- Architectural patterns used
|
|
169
|
+
- Coding conventions
|
|
170
|
+
- Domain-specific terminology
|
|
171
|
+
- Common patterns and idioms
|
|
172
|
+
- Team preferences
|
|
173
|
+
|
|
174
|
+
Provide insights as JSON:
|
|
175
|
+
{
|
|
176
|
+
"architecture": { "patterns": [...], "style": "..." },
|
|
177
|
+
"conventions": { "naming": "...", "formatting": "..." },
|
|
178
|
+
"domains": ["..."],
|
|
179
|
+
"insights": ["..."]
|
|
180
|
+
}`,
|
|
206
181
|
sandbox: 'strict',
|
|
207
182
|
model: 'opus',
|
|
208
183
|
outputFormat: 'json',
|
|
209
184
|
contextPatterns: ['**/*.ts', '**/CLAUDE.md', '**/README.md'],
|
|
210
|
-
timeoutMs: 15 * 60 * 1000
|
|
211
|
-
}
|
|
185
|
+
timeoutMs: 15 * 60 * 1000,
|
|
186
|
+
},
|
|
212
187
|
},
|
|
213
188
|
refactor: {
|
|
214
189
|
type: 'refactor',
|
|
215
190
|
mode: 'headless',
|
|
216
|
-
intervalMs: 0,
|
|
191
|
+
intervalMs: 0, // Manual trigger only
|
|
217
192
|
priority: 'normal',
|
|
218
193
|
description: 'AI refactoring suggestions',
|
|
219
194
|
enabled: false,
|
|
220
195
|
headless: {
|
|
221
|
-
promptTemplate:
|
|
196
|
+
promptTemplate: `Suggest refactoring opportunities:
|
|
197
|
+
- Identify code duplication
|
|
198
|
+
- Suggest better abstractions
|
|
199
|
+
- Find opportunities for design patterns
|
|
200
|
+
- Identify overly complex functions
|
|
201
|
+
- Suggest module reorganization
|
|
202
|
+
|
|
203
|
+
Provide before/after code examples.`,
|
|
222
204
|
sandbox: 'permissive',
|
|
223
205
|
model: 'sonnet',
|
|
224
206
|
outputFormat: 'markdown',
|
|
225
207
|
contextPatterns: ['src/**/*.ts'],
|
|
226
|
-
timeoutMs: 10 * 60 * 1000
|
|
227
|
-
}
|
|
208
|
+
timeoutMs: 10 * 60 * 1000,
|
|
209
|
+
},
|
|
228
210
|
},
|
|
229
211
|
deepdive: {
|
|
230
212
|
type: 'deepdive',
|
|
231
213
|
mode: 'headless',
|
|
232
|
-
intervalMs: 0,
|
|
214
|
+
intervalMs: 0, // Manual trigger only
|
|
233
215
|
priority: 'normal',
|
|
234
216
|
description: 'Deep code analysis',
|
|
235
217
|
enabled: false,
|
|
236
218
|
headless: {
|
|
237
|
-
promptTemplate:
|
|
219
|
+
promptTemplate: `Perform deep analysis of this codebase:
|
|
220
|
+
- Understand data flow
|
|
221
|
+
- Map dependencies
|
|
222
|
+
- Identify architectural issues
|
|
223
|
+
- Find potential bugs
|
|
224
|
+
- Analyze error handling
|
|
225
|
+
|
|
226
|
+
Provide comprehensive report.`,
|
|
238
227
|
sandbox: 'strict',
|
|
239
228
|
model: 'opus',
|
|
240
229
|
outputFormat: 'markdown',
|
|
241
230
|
contextPatterns: ['src/**/*.ts'],
|
|
242
|
-
timeoutMs: 15 * 60 * 1000
|
|
243
|
-
}
|
|
231
|
+
timeoutMs: 15 * 60 * 1000,
|
|
232
|
+
},
|
|
244
233
|
},
|
|
245
234
|
predict: {
|
|
246
235
|
type: 'predict',
|
|
@@ -250,26 +239,38 @@ export var HEADLESS_WORKER_CONFIGS = {
|
|
|
250
239
|
description: 'Predictive preloading',
|
|
251
240
|
enabled: false,
|
|
252
241
|
headless: {
|
|
253
|
-
promptTemplate:
|
|
242
|
+
promptTemplate: `Based on recent activity, predict what the developer needs:
|
|
243
|
+
- Files likely to be edited next
|
|
244
|
+
- Tests that should be run
|
|
245
|
+
- Documentation to reference
|
|
246
|
+
- Dependencies to check
|
|
247
|
+
|
|
248
|
+
Provide preload suggestions as JSON:
|
|
249
|
+
{
|
|
250
|
+
"filesToPreload": ["..."],
|
|
251
|
+
"testsToRun": ["..."],
|
|
252
|
+
"docsToReference": ["..."],
|
|
253
|
+
"confidence": 0.0-1.0
|
|
254
|
+
}`,
|
|
254
255
|
sandbox: 'strict',
|
|
255
256
|
model: 'haiku',
|
|
256
257
|
outputFormat: 'json',
|
|
257
258
|
contextPatterns: ['.claude-flow/metrics/*.json'],
|
|
258
|
-
timeoutMs: 2 * 60 * 1000
|
|
259
|
-
}
|
|
260
|
-
}
|
|
259
|
+
timeoutMs: 2 * 60 * 1000,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
261
262
|
};
|
|
262
263
|
/**
|
|
263
264
|
* Local worker configurations
|
|
264
265
|
*/
|
|
265
|
-
export
|
|
266
|
+
export const LOCAL_WORKER_CONFIGS = {
|
|
266
267
|
map: {
|
|
267
268
|
type: 'map',
|
|
268
269
|
mode: 'local',
|
|
269
270
|
intervalMs: 15 * 60 * 1000,
|
|
270
271
|
priority: 'normal',
|
|
271
272
|
description: 'Codebase mapping',
|
|
272
|
-
enabled: true
|
|
273
|
+
enabled: true,
|
|
273
274
|
},
|
|
274
275
|
consolidate: {
|
|
275
276
|
type: 'consolidate',
|
|
@@ -277,7 +278,7 @@ export var LOCAL_WORKER_CONFIGS = {
|
|
|
277
278
|
intervalMs: 30 * 60 * 1000,
|
|
278
279
|
priority: 'low',
|
|
279
280
|
description: 'Memory consolidation',
|
|
280
|
-
enabled: true
|
|
281
|
+
enabled: true,
|
|
281
282
|
},
|
|
282
283
|
benchmark: {
|
|
283
284
|
type: 'benchmark',
|
|
@@ -285,7 +286,7 @@ export var LOCAL_WORKER_CONFIGS = {
|
|
|
285
286
|
intervalMs: 60 * 60 * 1000,
|
|
286
287
|
priority: 'low',
|
|
287
288
|
description: 'Performance benchmarking',
|
|
288
|
-
enabled: false
|
|
289
|
+
enabled: false,
|
|
289
290
|
},
|
|
290
291
|
preload: {
|
|
291
292
|
type: 'preload',
|
|
@@ -293,13 +294,16 @@ export var LOCAL_WORKER_CONFIGS = {
|
|
|
293
294
|
intervalMs: 5 * 60 * 1000,
|
|
294
295
|
priority: 'low',
|
|
295
296
|
description: 'Resource preloading',
|
|
296
|
-
enabled: false
|
|
297
|
-
}
|
|
297
|
+
enabled: false,
|
|
298
|
+
},
|
|
298
299
|
};
|
|
299
300
|
/**
|
|
300
301
|
* Combined worker configurations
|
|
301
302
|
*/
|
|
302
|
-
export
|
|
303
|
+
export const ALL_WORKER_CONFIGS = [
|
|
304
|
+
...Object.values(HEADLESS_WORKER_CONFIGS),
|
|
305
|
+
...Object.values(LOCAL_WORKER_CONFIGS),
|
|
306
|
+
];
|
|
303
307
|
// ============================================
|
|
304
308
|
// Utility Functions
|
|
305
309
|
// ============================================
|
|
@@ -347,30 +351,29 @@ export function getWorkerConfig(type) {
|
|
|
347
351
|
* - Event emission for monitoring
|
|
348
352
|
* - Graceful termination
|
|
349
353
|
*/
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
354
|
+
export class HeadlessWorkerExecutor extends EventEmitter {
|
|
355
|
+
projectRoot;
|
|
356
|
+
config;
|
|
357
|
+
processPool = new Map();
|
|
358
|
+
pendingQueue = [];
|
|
359
|
+
contextCache = new Map();
|
|
360
|
+
claudeCodeAvailable = null;
|
|
361
|
+
claudeCodeVersion = null;
|
|
362
|
+
constructor(projectRoot, options) {
|
|
363
|
+
super();
|
|
364
|
+
this.projectRoot = projectRoot;
|
|
361
365
|
// Merge with defaults
|
|
362
|
-
|
|
363
|
-
maxConcurrent:
|
|
364
|
-
defaultTimeoutMs:
|
|
365
|
-
maxContextFiles:
|
|
366
|
-
maxCharsPerFile:
|
|
367
|
-
logDir:
|
|
368
|
-
cacheContext:
|
|
369
|
-
cacheTtlMs:
|
|
366
|
+
this.config = {
|
|
367
|
+
maxConcurrent: options?.maxConcurrent ?? 2,
|
|
368
|
+
defaultTimeoutMs: options?.defaultTimeoutMs ?? 5 * 60 * 1000,
|
|
369
|
+
maxContextFiles: options?.maxContextFiles ?? 20,
|
|
370
|
+
maxCharsPerFile: options?.maxCharsPerFile ?? 5000,
|
|
371
|
+
logDir: options?.logDir ?? join(projectRoot, '.claude-flow', 'logs', 'headless'),
|
|
372
|
+
cacheContext: options?.cacheContext ?? true,
|
|
373
|
+
cacheTtlMs: options?.cacheTtlMs ?? 60000, // 1 minute default
|
|
370
374
|
};
|
|
371
375
|
// Ensure log directory exists
|
|
372
|
-
|
|
373
|
-
return _this;
|
|
376
|
+
this.ensureLogDir();
|
|
374
377
|
}
|
|
375
378
|
// ============================================
|
|
376
379
|
// Public API
|
|
@@ -378,373 +381,333 @@ var HeadlessWorkerExecutor = /** @class */ (function (_super) {
|
|
|
378
381
|
/**
|
|
379
382
|
* Check if Claude Code CLI is available
|
|
380
383
|
*/
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
stdio: 'pipe',
|
|
392
|
-
timeout: 5000,
|
|
393
|
-
windowsHide: true
|
|
394
|
-
});
|
|
395
|
-
this.claudeCodeAvailable = true;
|
|
396
|
-
this.claudeCodeVersion = output.trim();
|
|
397
|
-
this.emit('status', { available: true, version: this.claudeCodeVersion });
|
|
398
|
-
return [2 /*return*/, true];
|
|
399
|
-
}
|
|
400
|
-
catch (_b) {
|
|
401
|
-
this.claudeCodeAvailable = false;
|
|
402
|
-
this.emit('status', { available: false });
|
|
403
|
-
return [2 /*return*/, false];
|
|
404
|
-
}
|
|
405
|
-
return [2 /*return*/];
|
|
384
|
+
async isAvailable() {
|
|
385
|
+
if (this.claudeCodeAvailable !== null) {
|
|
386
|
+
return this.claudeCodeAvailable;
|
|
387
|
+
}
|
|
388
|
+
try {
|
|
389
|
+
const output = execSync('claude --version', {
|
|
390
|
+
encoding: 'utf-8',
|
|
391
|
+
stdio: 'pipe',
|
|
392
|
+
timeout: 5000,
|
|
393
|
+
windowsHide: true, // Prevent phantom console windows on Windows
|
|
406
394
|
});
|
|
407
|
-
|
|
408
|
-
|
|
395
|
+
this.claudeCodeAvailable = true;
|
|
396
|
+
this.claudeCodeVersion = output.trim();
|
|
397
|
+
this.emit('status', { available: true, version: this.claudeCodeVersion });
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
catch {
|
|
401
|
+
this.claudeCodeAvailable = false;
|
|
402
|
+
this.emit('status', { available: false });
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
409
406
|
/**
|
|
410
407
|
* Get Claude Code version
|
|
411
408
|
*/
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
case 0: return [4 /*yield*/, this.isAvailable()];
|
|
417
|
-
case 1:
|
|
418
|
-
_a.sent();
|
|
419
|
-
return [2 /*return*/, this.claudeCodeVersion];
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
});
|
|
423
|
-
};
|
|
409
|
+
async getVersion() {
|
|
410
|
+
await this.isAvailable();
|
|
411
|
+
return this.claudeCodeVersion;
|
|
412
|
+
}
|
|
424
413
|
/**
|
|
425
414
|
* Execute a headless worker
|
|
426
415
|
*/
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
queuedAt: new Date()
|
|
456
|
-
};
|
|
457
|
-
_this.pendingQueue.push(entry);
|
|
458
|
-
_this.emit('queued', {
|
|
459
|
-
workerType: workerType,
|
|
460
|
-
queuePosition: _this.pendingQueue.length
|
|
461
|
-
});
|
|
462
|
-
})];
|
|
463
|
-
}
|
|
464
|
-
// Execute immediately
|
|
465
|
-
return [2 /*return*/, this.executeInternal(workerType, configOverrides)];
|
|
466
|
-
}
|
|
416
|
+
async execute(workerType, configOverrides) {
|
|
417
|
+
const baseConfig = HEADLESS_WORKER_CONFIGS[workerType];
|
|
418
|
+
if (!baseConfig) {
|
|
419
|
+
throw new Error(`Unknown headless worker type: ${workerType}`);
|
|
420
|
+
}
|
|
421
|
+
// Check availability
|
|
422
|
+
const available = await this.isAvailable();
|
|
423
|
+
if (!available) {
|
|
424
|
+
const result = this.createErrorResult(workerType, 'Claude Code CLI not available. Install with: npm install -g @anthropic-ai/claude-code');
|
|
425
|
+
this.emit('error', result);
|
|
426
|
+
return result;
|
|
427
|
+
}
|
|
428
|
+
// Check concurrent limit
|
|
429
|
+
if (this.processPool.size >= this.config.maxConcurrent) {
|
|
430
|
+
// Queue the request
|
|
431
|
+
return new Promise((resolve, reject) => {
|
|
432
|
+
const entry = {
|
|
433
|
+
workerType,
|
|
434
|
+
config: configOverrides,
|
|
435
|
+
resolve,
|
|
436
|
+
reject,
|
|
437
|
+
queuedAt: new Date(),
|
|
438
|
+
};
|
|
439
|
+
this.pendingQueue.push(entry);
|
|
440
|
+
this.emit('queued', {
|
|
441
|
+
workerType,
|
|
442
|
+
queuePosition: this.pendingQueue.length,
|
|
443
|
+
});
|
|
467
444
|
});
|
|
468
|
-
}
|
|
469
|
-
|
|
445
|
+
}
|
|
446
|
+
// Execute immediately
|
|
447
|
+
return this.executeInternal(workerType, configOverrides);
|
|
448
|
+
}
|
|
470
449
|
/**
|
|
471
450
|
* Get pool status
|
|
472
451
|
*/
|
|
473
|
-
|
|
474
|
-
|
|
452
|
+
getPoolStatus() {
|
|
453
|
+
const now = Date.now();
|
|
475
454
|
return {
|
|
476
455
|
activeCount: this.processPool.size,
|
|
477
456
|
queueLength: this.pendingQueue.length,
|
|
478
457
|
maxConcurrent: this.config.maxConcurrent,
|
|
479
|
-
activeWorkers: Array.from(this.processPool.values()).map(
|
|
458
|
+
activeWorkers: Array.from(this.processPool.values()).map((entry) => ({
|
|
480
459
|
executionId: entry.executionId,
|
|
481
460
|
workerType: entry.workerType,
|
|
482
461
|
startTime: entry.startTime,
|
|
483
|
-
elapsedMs: now - entry.startTime.getTime()
|
|
484
|
-
})
|
|
485
|
-
queuedWorkers: this.pendingQueue.map(
|
|
462
|
+
elapsedMs: now - entry.startTime.getTime(),
|
|
463
|
+
})),
|
|
464
|
+
queuedWorkers: this.pendingQueue.map((entry) => ({
|
|
486
465
|
workerType: entry.workerType,
|
|
487
466
|
queuedAt: entry.queuedAt,
|
|
488
|
-
waitingMs: now - entry.queuedAt.getTime()
|
|
489
|
-
})
|
|
467
|
+
waitingMs: now - entry.queuedAt.getTime(),
|
|
468
|
+
})),
|
|
490
469
|
};
|
|
491
|
-
}
|
|
470
|
+
}
|
|
492
471
|
/**
|
|
493
472
|
* Get number of active executions
|
|
494
473
|
*/
|
|
495
|
-
|
|
474
|
+
getActiveCount() {
|
|
496
475
|
return this.processPool.size;
|
|
497
|
-
}
|
|
476
|
+
}
|
|
498
477
|
/**
|
|
499
478
|
* Cancel a running execution
|
|
500
479
|
*/
|
|
501
|
-
|
|
502
|
-
|
|
480
|
+
cancel(executionId) {
|
|
481
|
+
const entry = this.processPool.get(executionId);
|
|
503
482
|
if (!entry) {
|
|
504
483
|
return false;
|
|
505
484
|
}
|
|
506
485
|
clearTimeout(entry.timeout);
|
|
507
486
|
entry.process.kill('SIGTERM');
|
|
508
|
-
this.processPool
|
|
509
|
-
this.emit('cancelled', { executionId
|
|
487
|
+
this.processPool.delete(executionId);
|
|
488
|
+
this.emit('cancelled', { executionId });
|
|
510
489
|
// Process next in queue
|
|
511
490
|
this.processQueue();
|
|
512
491
|
return true;
|
|
513
|
-
}
|
|
492
|
+
}
|
|
514
493
|
/**
|
|
515
494
|
* Cancel all running executions
|
|
516
495
|
*/
|
|
517
|
-
|
|
518
|
-
|
|
496
|
+
cancelAll() {
|
|
497
|
+
let cancelled = 0;
|
|
519
498
|
// Cancel active processes (convert to array to avoid iterator issues)
|
|
520
|
-
|
|
521
|
-
for (
|
|
522
|
-
var _a = entries_1[_i], executionId = _a[0], entry = _a[1];
|
|
499
|
+
const entries = Array.from(this.processPool.entries());
|
|
500
|
+
for (const [executionId, entry] of entries) {
|
|
523
501
|
clearTimeout(entry.timeout);
|
|
524
502
|
entry.process.kill('SIGTERM');
|
|
525
|
-
this.emit('cancelled', { executionId
|
|
503
|
+
this.emit('cancelled', { executionId });
|
|
526
504
|
cancelled++;
|
|
527
505
|
}
|
|
528
506
|
this.processPool.clear();
|
|
529
507
|
// Reject pending queue
|
|
530
|
-
for (
|
|
531
|
-
var entry = _c[_b];
|
|
508
|
+
for (const entry of this.pendingQueue) {
|
|
532
509
|
entry.reject(new Error('Executor cancelled all executions'));
|
|
533
510
|
}
|
|
534
511
|
this.pendingQueue = [];
|
|
535
512
|
this.emit('allCancelled', { count: cancelled });
|
|
536
513
|
return cancelled;
|
|
537
|
-
}
|
|
514
|
+
}
|
|
538
515
|
/**
|
|
539
516
|
* Clear context cache
|
|
540
517
|
*/
|
|
541
|
-
|
|
518
|
+
clearContextCache() {
|
|
542
519
|
this.contextCache.clear();
|
|
543
520
|
this.emit('cacheClear', {});
|
|
544
|
-
}
|
|
521
|
+
}
|
|
545
522
|
/**
|
|
546
523
|
* Get worker configuration
|
|
547
524
|
*/
|
|
548
|
-
|
|
525
|
+
getConfig(workerType) {
|
|
549
526
|
return HEADLESS_WORKER_CONFIGS[workerType];
|
|
550
|
-
}
|
|
527
|
+
}
|
|
551
528
|
/**
|
|
552
529
|
* Get all headless worker types
|
|
553
530
|
*/
|
|
554
|
-
|
|
555
|
-
return
|
|
556
|
-
}
|
|
531
|
+
getHeadlessWorkerTypes() {
|
|
532
|
+
return [...HEADLESS_WORKER_TYPES];
|
|
533
|
+
}
|
|
557
534
|
/**
|
|
558
535
|
* Get all local worker types
|
|
559
536
|
*/
|
|
560
|
-
|
|
561
|
-
return
|
|
562
|
-
}
|
|
537
|
+
getLocalWorkerTypes() {
|
|
538
|
+
return [...LOCAL_WORKER_TYPES];
|
|
539
|
+
}
|
|
563
540
|
// ============================================
|
|
564
541
|
// Private Methods
|
|
565
542
|
// ============================================
|
|
566
543
|
/**
|
|
567
544
|
* Ensure log directory exists
|
|
568
545
|
*/
|
|
569
|
-
|
|
546
|
+
ensureLogDir() {
|
|
570
547
|
try {
|
|
571
548
|
if (!existsSync(this.config.logDir)) {
|
|
572
549
|
mkdirSync(this.config.logDir, { recursive: true });
|
|
573
550
|
}
|
|
574
551
|
}
|
|
575
552
|
catch (error) {
|
|
576
|
-
this.emit('warning', { message: 'Failed to create log directory', error
|
|
553
|
+
this.emit('warning', { message: 'Failed to create log directory', error });
|
|
577
554
|
}
|
|
578
|
-
}
|
|
555
|
+
}
|
|
579
556
|
/**
|
|
580
557
|
* Internal execution logic
|
|
581
558
|
*/
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
return [4 /*yield*/, this.executeClaudeCode(fullPrompt, {
|
|
603
|
-
sandbox: headless.sandbox,
|
|
604
|
-
model: headless.model || 'sonnet',
|
|
605
|
-
timeoutMs: headless.timeoutMs || this.config.defaultTimeoutMs,
|
|
606
|
-
executionId: executionId,
|
|
607
|
-
workerType: workerType
|
|
608
|
-
})];
|
|
609
|
-
case 3:
|
|
610
|
-
result = _a.sent();
|
|
611
|
-
parsedOutput = void 0;
|
|
612
|
-
if (headless.outputFormat === 'json' && result.output) {
|
|
613
|
-
parsedOutput = this.parseJsonOutput(result.output);
|
|
614
|
-
}
|
|
615
|
-
else if (headless.outputFormat === 'markdown' && result.output) {
|
|
616
|
-
parsedOutput = this.parseMarkdownOutput(result.output);
|
|
617
|
-
}
|
|
618
|
-
executionResult = {
|
|
619
|
-
success: result.success,
|
|
620
|
-
output: result.output,
|
|
621
|
-
parsedOutput: parsedOutput,
|
|
622
|
-
durationMs: Date.now() - startTime,
|
|
623
|
-
tokensUsed: result.tokensUsed,
|
|
624
|
-
model: headless.model || 'sonnet',
|
|
625
|
-
sandboxMode: headless.sandbox,
|
|
626
|
-
workerType: workerType,
|
|
627
|
-
timestamp: new Date(),
|
|
628
|
-
executionId: executionId,
|
|
629
|
-
error: result.error
|
|
630
|
-
};
|
|
631
|
-
// Log result
|
|
632
|
-
this.logExecution(executionId, 'result', JSON.stringify(executionResult, null, 2));
|
|
633
|
-
this.emit('complete', executionResult);
|
|
634
|
-
return [2 /*return*/, executionResult];
|
|
635
|
-
case 4:
|
|
636
|
-
error_1 = _a.sent();
|
|
637
|
-
errorMessage = error_1 instanceof Error ? error_1.message : String(error_1);
|
|
638
|
-
executionResult = this.createErrorResult(workerType, errorMessage);
|
|
639
|
-
executionResult.executionId = executionId;
|
|
640
|
-
executionResult.durationMs = Date.now() - startTime;
|
|
641
|
-
this.logExecution(executionId, 'error', errorMessage);
|
|
642
|
-
this.emit('error', executionResult);
|
|
643
|
-
return [2 /*return*/, executionResult];
|
|
644
|
-
case 5:
|
|
645
|
-
// Process next in queue
|
|
646
|
-
this.processQueue();
|
|
647
|
-
return [7 /*endfinally*/];
|
|
648
|
-
case 6: return [2 /*return*/];
|
|
649
|
-
}
|
|
559
|
+
async executeInternal(workerType, configOverrides) {
|
|
560
|
+
const baseConfig = HEADLESS_WORKER_CONFIGS[workerType];
|
|
561
|
+
const headless = { ...baseConfig.headless, ...configOverrides };
|
|
562
|
+
const startTime = Date.now();
|
|
563
|
+
const executionId = `${workerType}_${startTime}_${Math.random().toString(36).slice(2, 8)}`;
|
|
564
|
+
this.emit('start', { executionId, workerType, config: headless });
|
|
565
|
+
try {
|
|
566
|
+
// Build context from file patterns
|
|
567
|
+
const context = await this.buildContext(headless.contextPatterns || []);
|
|
568
|
+
// Build the full prompt
|
|
569
|
+
const fullPrompt = this.buildPrompt(headless.promptTemplate, context);
|
|
570
|
+
// Log prompt for debugging
|
|
571
|
+
this.logExecution(executionId, 'prompt', fullPrompt);
|
|
572
|
+
// Execute Claude Code headlessly
|
|
573
|
+
const result = await this.executeClaudeCode(fullPrompt, {
|
|
574
|
+
sandbox: headless.sandbox,
|
|
575
|
+
model: headless.model || 'sonnet',
|
|
576
|
+
timeoutMs: headless.timeoutMs || this.config.defaultTimeoutMs,
|
|
577
|
+
executionId,
|
|
578
|
+
workerType,
|
|
650
579
|
});
|
|
651
|
-
|
|
652
|
-
|
|
580
|
+
// Parse output based on format
|
|
581
|
+
let parsedOutput;
|
|
582
|
+
if (headless.outputFormat === 'json' && result.output) {
|
|
583
|
+
parsedOutput = this.parseJsonOutput(result.output);
|
|
584
|
+
}
|
|
585
|
+
else if (headless.outputFormat === 'markdown' && result.output) {
|
|
586
|
+
parsedOutput = this.parseMarkdownOutput(result.output);
|
|
587
|
+
}
|
|
588
|
+
const executionResult = {
|
|
589
|
+
success: result.success,
|
|
590
|
+
output: result.output,
|
|
591
|
+
parsedOutput,
|
|
592
|
+
durationMs: Date.now() - startTime,
|
|
593
|
+
tokensUsed: result.tokensUsed,
|
|
594
|
+
model: headless.model || 'sonnet',
|
|
595
|
+
sandboxMode: headless.sandbox,
|
|
596
|
+
workerType,
|
|
597
|
+
timestamp: new Date(),
|
|
598
|
+
executionId,
|
|
599
|
+
error: result.error,
|
|
600
|
+
};
|
|
601
|
+
// Log result
|
|
602
|
+
this.logExecution(executionId, 'result', JSON.stringify(executionResult, null, 2));
|
|
603
|
+
this.emit('complete', executionResult);
|
|
604
|
+
return executionResult;
|
|
605
|
+
}
|
|
606
|
+
catch (error) {
|
|
607
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
608
|
+
const executionResult = this.createErrorResult(workerType, errorMessage);
|
|
609
|
+
executionResult.executionId = executionId;
|
|
610
|
+
executionResult.durationMs = Date.now() - startTime;
|
|
611
|
+
this.logExecution(executionId, 'error', errorMessage);
|
|
612
|
+
this.emit('error', executionResult);
|
|
613
|
+
return executionResult;
|
|
614
|
+
}
|
|
615
|
+
finally {
|
|
616
|
+
// Process next in queue
|
|
617
|
+
this.processQueue();
|
|
618
|
+
}
|
|
619
|
+
}
|
|
653
620
|
/**
|
|
654
621
|
* Process the pending queue
|
|
655
622
|
*/
|
|
656
|
-
|
|
623
|
+
processQueue() {
|
|
657
624
|
while (this.pendingQueue.length > 0 &&
|
|
658
625
|
this.processPool.size < this.config.maxConcurrent) {
|
|
659
|
-
|
|
626
|
+
const next = this.pendingQueue.shift();
|
|
660
627
|
if (!next)
|
|
661
628
|
break;
|
|
662
629
|
this.executeInternal(next.workerType, next.config)
|
|
663
|
-
.then(next.resolve)
|
|
630
|
+
.then(next.resolve)
|
|
631
|
+
.catch(next.reject);
|
|
664
632
|
}
|
|
665
|
-
}
|
|
633
|
+
}
|
|
666
634
|
/**
|
|
667
635
|
* Build context from file patterns
|
|
668
636
|
*/
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
patterns: patterns
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
return [2 /*return*/, contextContent];
|
|
637
|
+
async buildContext(patterns) {
|
|
638
|
+
if (patterns.length === 0)
|
|
639
|
+
return '';
|
|
640
|
+
// Check cache
|
|
641
|
+
const cacheKey = patterns.sort().join('|');
|
|
642
|
+
if (this.config.cacheContext) {
|
|
643
|
+
const cached = this.contextCache.get(cacheKey);
|
|
644
|
+
if (cached && Date.now() - cached.timestamp < this.config.cacheTtlMs) {
|
|
645
|
+
return cached.content;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
// Collect files matching patterns
|
|
649
|
+
const files = [];
|
|
650
|
+
for (const pattern of patterns) {
|
|
651
|
+
const matches = this.simpleGlob(pattern);
|
|
652
|
+
files.push(...matches);
|
|
653
|
+
}
|
|
654
|
+
// Deduplicate and limit
|
|
655
|
+
const uniqueFiles = Array.from(new Set(files)).slice(0, this.config.maxContextFiles);
|
|
656
|
+
// Build context
|
|
657
|
+
const contextParts = [];
|
|
658
|
+
for (const file of uniqueFiles) {
|
|
659
|
+
try {
|
|
660
|
+
const fullPath = join(this.projectRoot, file);
|
|
661
|
+
if (!existsSync(fullPath))
|
|
662
|
+
continue;
|
|
663
|
+
const content = readFileSync(fullPath, 'utf-8');
|
|
664
|
+
const truncated = content.slice(0, this.config.maxCharsPerFile);
|
|
665
|
+
const wasTruncated = content.length > this.config.maxCharsPerFile;
|
|
666
|
+
contextParts.push(`--- ${file}${wasTruncated ? ' (truncated)' : ''} ---\n${truncated}`);
|
|
667
|
+
}
|
|
668
|
+
catch {
|
|
669
|
+
// Skip unreadable files
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
const contextContent = contextParts.join('\n\n');
|
|
673
|
+
// Cache the result
|
|
674
|
+
if (this.config.cacheContext) {
|
|
675
|
+
this.contextCache.set(cacheKey, {
|
|
676
|
+
content: contextContent,
|
|
677
|
+
timestamp: Date.now(),
|
|
678
|
+
patterns,
|
|
715
679
|
});
|
|
716
|
-
}
|
|
717
|
-
|
|
680
|
+
}
|
|
681
|
+
return contextContent;
|
|
682
|
+
}
|
|
718
683
|
/**
|
|
719
684
|
* Simple glob implementation for file matching
|
|
720
685
|
*/
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
var results = [];
|
|
686
|
+
simpleGlob(pattern) {
|
|
687
|
+
const results = [];
|
|
724
688
|
// Handle simple patterns (no wildcards)
|
|
725
689
|
if (!pattern.includes('*')) {
|
|
726
|
-
|
|
690
|
+
const fullPath = join(this.projectRoot, pattern);
|
|
727
691
|
if (existsSync(fullPath)) {
|
|
728
692
|
results.push(pattern);
|
|
729
693
|
}
|
|
730
694
|
return results;
|
|
731
695
|
}
|
|
732
696
|
// Parse pattern parts
|
|
733
|
-
|
|
734
|
-
|
|
697
|
+
const parts = pattern.split('/');
|
|
698
|
+
const scanDir = (dir, remainingParts) => {
|
|
735
699
|
if (remainingParts.length === 0)
|
|
736
700
|
return;
|
|
737
701
|
if (results.length >= 100)
|
|
738
702
|
return; // Limit results
|
|
739
703
|
try {
|
|
740
|
-
|
|
704
|
+
const fullDir = join(this.projectRoot, dir);
|
|
741
705
|
if (!existsSync(fullDir))
|
|
742
706
|
return;
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
for (
|
|
747
|
-
var entry = entries_2[_i];
|
|
707
|
+
const entries = readdirSync(fullDir, { withFileTypes: true });
|
|
708
|
+
const currentPart = remainingParts[0];
|
|
709
|
+
const isLastPart = remainingParts.length === 1;
|
|
710
|
+
for (const entry of entries) {
|
|
748
711
|
// Skip common non-code directories
|
|
749
712
|
if (entry.name === 'node_modules' ||
|
|
750
713
|
entry.name === '.git' ||
|
|
@@ -755,7 +718,7 @@ var HeadlessWorkerExecutor = /** @class */ (function (_super) {
|
|
|
755
718
|
entry.name === '.cache') {
|
|
756
719
|
continue;
|
|
757
720
|
}
|
|
758
|
-
|
|
721
|
+
const entryPath = dir ? `${dir}/${entry.name}` : entry.name;
|
|
759
722
|
if (currentPart === '**') {
|
|
760
723
|
// Recursive glob
|
|
761
724
|
if (entry.isDirectory()) {
|
|
@@ -764,13 +727,13 @@ var HeadlessWorkerExecutor = /** @class */ (function (_super) {
|
|
|
764
727
|
}
|
|
765
728
|
else if (entry.isFile() && remainingParts.length > 1) {
|
|
766
729
|
// Check if file matches next pattern part
|
|
767
|
-
|
|
768
|
-
if (
|
|
730
|
+
const nextPart = remainingParts[1];
|
|
731
|
+
if (this.matchesPattern(entry.name, nextPart)) {
|
|
769
732
|
results.push(entryPath);
|
|
770
733
|
}
|
|
771
734
|
}
|
|
772
735
|
}
|
|
773
|
-
else if (
|
|
736
|
+
else if (this.matchesPattern(entry.name, currentPart)) {
|
|
774
737
|
if (isLastPart && entry.isFile()) {
|
|
775
738
|
results.push(entryPath);
|
|
776
739
|
}
|
|
@@ -780,17 +743,17 @@ var HeadlessWorkerExecutor = /** @class */ (function (_super) {
|
|
|
780
743
|
}
|
|
781
744
|
}
|
|
782
745
|
}
|
|
783
|
-
catch
|
|
746
|
+
catch {
|
|
784
747
|
// Skip unreadable directories
|
|
785
748
|
}
|
|
786
749
|
};
|
|
787
750
|
scanDir('', parts);
|
|
788
751
|
return results;
|
|
789
|
-
}
|
|
752
|
+
}
|
|
790
753
|
/**
|
|
791
754
|
* Match filename against a simple pattern
|
|
792
755
|
*/
|
|
793
|
-
|
|
756
|
+
matchesPattern(name, pattern) {
|
|
794
757
|
if (pattern === '*')
|
|
795
758
|
return true;
|
|
796
759
|
if (pattern === '**')
|
|
@@ -809,39 +772,53 @@ var HeadlessWorkerExecutor = /** @class */ (function (_super) {
|
|
|
809
772
|
}
|
|
810
773
|
// Exact match
|
|
811
774
|
return name === pattern;
|
|
812
|
-
}
|
|
775
|
+
}
|
|
813
776
|
/**
|
|
814
777
|
* Build full prompt with context
|
|
815
778
|
*/
|
|
816
|
-
|
|
779
|
+
buildPrompt(template, context) {
|
|
817
780
|
if (!context) {
|
|
818
|
-
return template
|
|
781
|
+
return `${template}
|
|
782
|
+
|
|
783
|
+
## Instructions
|
|
784
|
+
|
|
785
|
+
Analyze the codebase and provide your response following the format specified in the task.`;
|
|
819
786
|
}
|
|
820
|
-
return template
|
|
821
|
-
|
|
787
|
+
return `${template}
|
|
788
|
+
|
|
789
|
+
## Codebase Context
|
|
790
|
+
|
|
791
|
+
${context}
|
|
792
|
+
|
|
793
|
+
## Instructions
|
|
794
|
+
|
|
795
|
+
Analyze the above codebase context and provide your response following the format specified in the task.`;
|
|
796
|
+
}
|
|
822
797
|
/**
|
|
823
798
|
* Execute Claude Code in headless mode
|
|
824
799
|
*/
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
800
|
+
executeClaudeCode(prompt, options) {
|
|
801
|
+
return new Promise((resolve) => {
|
|
802
|
+
const env = {
|
|
803
|
+
...process.env,
|
|
804
|
+
CLAUDE_CODE_HEADLESS: 'true',
|
|
805
|
+
CLAUDE_CODE_SANDBOX_MODE: options.sandbox,
|
|
806
|
+
};
|
|
830
807
|
// Set model
|
|
831
808
|
env.ANTHROPIC_MODEL = MODEL_IDS[options.model];
|
|
832
809
|
// Spawn claude CLI process
|
|
833
|
-
|
|
834
|
-
cwd:
|
|
835
|
-
env
|
|
810
|
+
const child = spawn('claude', ['--print', prompt], {
|
|
811
|
+
cwd: this.projectRoot,
|
|
812
|
+
env,
|
|
836
813
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
837
|
-
windowsHide: true
|
|
814
|
+
windowsHide: true, // Prevent phantom console windows on Windows
|
|
838
815
|
});
|
|
839
816
|
// Setup timeout
|
|
840
|
-
|
|
841
|
-
if (
|
|
817
|
+
const timeoutHandle = setTimeout(() => {
|
|
818
|
+
if (this.processPool.has(options.executionId)) {
|
|
842
819
|
child.kill('SIGTERM');
|
|
843
820
|
// Give it a moment to terminate gracefully
|
|
844
|
-
setTimeout(
|
|
821
|
+
setTimeout(() => {
|
|
845
822
|
if (!child.killed) {
|
|
846
823
|
child.kill('SIGKILL');
|
|
847
824
|
}
|
|
@@ -849,40 +826,40 @@ var HeadlessWorkerExecutor = /** @class */ (function (_super) {
|
|
|
849
826
|
}
|
|
850
827
|
}, options.timeoutMs);
|
|
851
828
|
// Track in process pool
|
|
852
|
-
|
|
829
|
+
const poolEntry = {
|
|
853
830
|
process: child,
|
|
854
831
|
executionId: options.executionId,
|
|
855
832
|
workerType: options.workerType,
|
|
856
833
|
startTime: new Date(),
|
|
857
|
-
timeout: timeoutHandle
|
|
834
|
+
timeout: timeoutHandle,
|
|
858
835
|
};
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
836
|
+
this.processPool.set(options.executionId, poolEntry);
|
|
837
|
+
let stdout = '';
|
|
838
|
+
let stderr = '';
|
|
839
|
+
let resolved = false;
|
|
840
|
+
const cleanup = () => {
|
|
864
841
|
clearTimeout(timeoutHandle);
|
|
865
|
-
|
|
842
|
+
this.processPool.delete(options.executionId);
|
|
866
843
|
};
|
|
867
|
-
|
|
868
|
-
|
|
844
|
+
child.stdout?.on('data', (data) => {
|
|
845
|
+
const chunk = data.toString();
|
|
869
846
|
stdout += chunk;
|
|
870
|
-
|
|
847
|
+
this.emit('output', {
|
|
871
848
|
executionId: options.executionId,
|
|
872
849
|
type: 'stdout',
|
|
873
|
-
data: chunk
|
|
850
|
+
data: chunk,
|
|
874
851
|
});
|
|
875
852
|
});
|
|
876
|
-
|
|
877
|
-
|
|
853
|
+
child.stderr?.on('data', (data) => {
|
|
854
|
+
const chunk = data.toString();
|
|
878
855
|
stderr += chunk;
|
|
879
|
-
|
|
856
|
+
this.emit('output', {
|
|
880
857
|
executionId: options.executionId,
|
|
881
858
|
type: 'stderr',
|
|
882
|
-
data: chunk
|
|
859
|
+
data: chunk,
|
|
883
860
|
});
|
|
884
861
|
});
|
|
885
|
-
child.on('close',
|
|
862
|
+
child.on('close', (code) => {
|
|
886
863
|
if (resolved)
|
|
887
864
|
return;
|
|
888
865
|
resolved = true;
|
|
@@ -890,10 +867,10 @@ var HeadlessWorkerExecutor = /** @class */ (function (_super) {
|
|
|
890
867
|
resolve({
|
|
891
868
|
success: code === 0,
|
|
892
869
|
output: stdout || stderr,
|
|
893
|
-
error: code !== 0 ? stderr ||
|
|
870
|
+
error: code !== 0 ? stderr || `Process exited with code ${code}` : undefined,
|
|
894
871
|
});
|
|
895
872
|
});
|
|
896
|
-
child.on('error',
|
|
873
|
+
child.on('error', (error) => {
|
|
897
874
|
if (resolved)
|
|
898
875
|
return;
|
|
899
876
|
resolved = true;
|
|
@@ -901,14 +878,14 @@ var HeadlessWorkerExecutor = /** @class */ (function (_super) {
|
|
|
901
878
|
resolve({
|
|
902
879
|
success: false,
|
|
903
880
|
output: '',
|
|
904
|
-
error: error.message
|
|
881
|
+
error: error.message,
|
|
905
882
|
});
|
|
906
883
|
});
|
|
907
884
|
// Handle timeout
|
|
908
|
-
setTimeout(
|
|
885
|
+
setTimeout(() => {
|
|
909
886
|
if (resolved)
|
|
910
887
|
return;
|
|
911
|
-
if (!
|
|
888
|
+
if (!this.processPool.has(options.executionId))
|
|
912
889
|
return;
|
|
913
890
|
resolved = true;
|
|
914
891
|
child.kill('SIGTERM');
|
|
@@ -916,57 +893,56 @@ var HeadlessWorkerExecutor = /** @class */ (function (_super) {
|
|
|
916
893
|
resolve({
|
|
917
894
|
success: false,
|
|
918
895
|
output: stdout || stderr,
|
|
919
|
-
error:
|
|
896
|
+
error: `Execution timed out after ${options.timeoutMs}ms`,
|
|
920
897
|
});
|
|
921
898
|
}, options.timeoutMs + 100); // Slightly after the kill timeout
|
|
922
899
|
});
|
|
923
|
-
}
|
|
900
|
+
}
|
|
924
901
|
/**
|
|
925
902
|
* Parse JSON output from Claude Code
|
|
926
903
|
*/
|
|
927
|
-
|
|
904
|
+
parseJsonOutput(output) {
|
|
928
905
|
try {
|
|
929
906
|
// Try to find JSON in code blocks first
|
|
930
|
-
|
|
907
|
+
const codeBlockMatch = output.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
931
908
|
if (codeBlockMatch) {
|
|
932
909
|
return JSON.parse(codeBlockMatch[1].trim());
|
|
933
910
|
}
|
|
934
911
|
// Try to find any JSON object
|
|
935
|
-
|
|
912
|
+
const jsonMatch = output.match(/\{[\s\S]*\}/);
|
|
936
913
|
if (jsonMatch) {
|
|
937
914
|
return JSON.parse(jsonMatch[0]);
|
|
938
915
|
}
|
|
939
916
|
// Try direct parse
|
|
940
917
|
return JSON.parse(output.trim());
|
|
941
918
|
}
|
|
942
|
-
catch
|
|
919
|
+
catch {
|
|
943
920
|
return {
|
|
944
921
|
parseError: true,
|
|
945
|
-
rawOutput: output
|
|
922
|
+
rawOutput: output,
|
|
946
923
|
};
|
|
947
924
|
}
|
|
948
|
-
}
|
|
925
|
+
}
|
|
949
926
|
/**
|
|
950
927
|
* Parse markdown output into sections
|
|
951
928
|
*/
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
929
|
+
parseMarkdownOutput(output) {
|
|
930
|
+
const sections = [];
|
|
931
|
+
const codeBlocks = [];
|
|
955
932
|
// Extract code blocks first
|
|
956
|
-
|
|
957
|
-
|
|
933
|
+
const codeBlockRegex = /```(\w*)\n([\s\S]*?)```/g;
|
|
934
|
+
let codeMatch;
|
|
958
935
|
while ((codeMatch = codeBlockRegex.exec(output)) !== null) {
|
|
959
936
|
codeBlocks.push({
|
|
960
937
|
language: codeMatch[1] || 'text',
|
|
961
|
-
code: codeMatch[2].trim()
|
|
938
|
+
code: codeMatch[2].trim(),
|
|
962
939
|
});
|
|
963
940
|
}
|
|
964
941
|
// Parse sections
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
for (
|
|
968
|
-
|
|
969
|
-
var headerMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
|
942
|
+
const lines = output.split('\n');
|
|
943
|
+
let currentSection = null;
|
|
944
|
+
for (const line of lines) {
|
|
945
|
+
const headerMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
|
970
946
|
if (headerMatch) {
|
|
971
947
|
if (currentSection) {
|
|
972
948
|
sections.push(currentSection);
|
|
@@ -974,7 +950,7 @@ var HeadlessWorkerExecutor = /** @class */ (function (_super) {
|
|
|
974
950
|
currentSection = {
|
|
975
951
|
title: headerMatch[2].trim(),
|
|
976
952
|
content: '',
|
|
977
|
-
level: headerMatch[1].length
|
|
953
|
+
level: headerMatch[1].length,
|
|
978
954
|
};
|
|
979
955
|
}
|
|
980
956
|
else if (currentSection) {
|
|
@@ -985,41 +961,39 @@ var HeadlessWorkerExecutor = /** @class */ (function (_super) {
|
|
|
985
961
|
currentSection.content = currentSection.content.trim();
|
|
986
962
|
sections.push(currentSection);
|
|
987
963
|
}
|
|
988
|
-
return { sections
|
|
989
|
-
}
|
|
964
|
+
return { sections, codeBlocks };
|
|
965
|
+
}
|
|
990
966
|
/**
|
|
991
967
|
* Create an error result
|
|
992
968
|
*/
|
|
993
|
-
|
|
969
|
+
createErrorResult(workerType, error) {
|
|
994
970
|
return {
|
|
995
971
|
success: false,
|
|
996
972
|
output: '',
|
|
997
973
|
durationMs: 0,
|
|
998
974
|
model: 'unknown',
|
|
999
975
|
sandboxMode: 'strict',
|
|
1000
|
-
workerType
|
|
976
|
+
workerType,
|
|
1001
977
|
timestamp: new Date(),
|
|
1002
|
-
executionId:
|
|
1003
|
-
error
|
|
978
|
+
executionId: `error_${Date.now()}`,
|
|
979
|
+
error,
|
|
1004
980
|
};
|
|
1005
|
-
}
|
|
981
|
+
}
|
|
1006
982
|
/**
|
|
1007
983
|
* Log execution details for debugging
|
|
1008
984
|
*/
|
|
1009
|
-
|
|
985
|
+
logExecution(executionId, type, content) {
|
|
1010
986
|
try {
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
987
|
+
const timestamp = new Date().toISOString();
|
|
988
|
+
const logFile = join(this.config.logDir, `${executionId}_${type}.log`);
|
|
989
|
+
const logContent = `[${timestamp}] ${type.toUpperCase()}\n${'='.repeat(60)}\n${content}\n`;
|
|
1014
990
|
writeFileSync(logFile, logContent);
|
|
1015
991
|
}
|
|
1016
|
-
catch
|
|
992
|
+
catch {
|
|
1017
993
|
// Ignore log write errors
|
|
1018
994
|
}
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
}(EventEmitter));
|
|
1022
|
-
export { HeadlessWorkerExecutor };
|
|
995
|
+
}
|
|
996
|
+
}
|
|
1023
997
|
// Export default
|
|
1024
998
|
export default HeadlessWorkerExecutor;
|
|
1025
999
|
//# sourceMappingURL=headless-worker-executor.js.map
|