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