kynjal-cli 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/appliance/gguf-engine.d.ts +91 -0
- package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
- package/dist/src/appliance/gguf-engine.js +286 -525
- package/dist/src/appliance/gguf-engine.js.map +1 -1
- package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
- package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
- package/dist/src/appliance/ruvllm-bridge.js +203 -403
- package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
- package/dist/src/appliance/rvfa-builder.d.ts +44 -0
- package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-builder.js +154 -208
- package/dist/src/appliance/rvfa-builder.js.map +1 -1
- package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
- package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-distribution.js +260 -423
- package/dist/src/appliance/rvfa-distribution.js.map +1 -1
- package/dist/src/appliance/rvfa-format.d.ts +111 -0
- package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-format.js +128 -200
- package/dist/src/appliance/rvfa-format.js.map +1 -1
- package/dist/src/appliance/rvfa-runner.d.ts +69 -0
- package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-runner.js +168 -304
- package/dist/src/appliance/rvfa-runner.js.map +1 -1
- package/dist/src/appliance/rvfa-signing.d.ts +123 -0
- package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-signing.js +173 -295
- package/dist/src/appliance/rvfa-signing.js.map +1 -1
- package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
- package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
- package/dist/src/benchmarks/pretrain/index.js +331 -542
- package/dist/src/benchmarks/pretrain/index.js.map +1 -1
- package/dist/src/commands/agent.js +574 -697
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.js +1218 -1548
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/appliance-advanced.js +158 -267
- package/dist/src/commands/appliance-advanced.js.map +1 -1
- package/dist/src/commands/appliance.js +318 -493
- package/dist/src/commands/appliance.js.map +1 -1
- package/dist/src/commands/benchmark.js +372 -523
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/claims.js +274 -364
- package/dist/src/commands/claims.js.map +1 -1
- package/dist/src/commands/cleanup.js +113 -157
- package/dist/src/commands/cleanup.js.map +1 -1
- package/dist/src/commands/completions.js +477 -118
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +237 -303
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.js +487 -596
- package/dist/src/commands/daemon.js.map +1 -1
- package/dist/src/commands/deployment.js +194 -275
- package/dist/src/commands/deployment.js.map +1 -1
- package/dist/src/commands/doctor.js +504 -686
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/embeddings.js +1293 -1543
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/guidance.js +449 -596
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind.js +854 -938
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.js +3112 -3519
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +115 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +126 -308
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.js +788 -940
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/issues.js +383 -558
- package/dist/src/commands/issues.js.map +1 -1
- package/dist/src/commands/mcp.js +493 -605
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.js +833 -1026
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +282 -347
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.js +1289 -1563
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.js +497 -643
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/plugins.js +668 -841
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/process.js +392 -447
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/progress.js +162 -256
- package/dist/src/commands/progress.js.map +1 -1
- package/dist/src/commands/providers.js +150 -220
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/route.js +520 -665
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/ruvector/backup.js +505 -651
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js +349 -401
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/import.js +224 -266
- package/dist/src/commands/ruvector/import.js.map +1 -1
- package/dist/src/commands/ruvector/index.js +37 -75
- package/dist/src/commands/ruvector/index.js.map +1 -1
- package/dist/src/commands/ruvector/init.js +336 -359
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js +335 -322
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js +375 -431
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/setup.js +703 -117
- package/dist/src/commands/ruvector/setup.js.map +1 -1
- package/dist/src/commands/ruvector/status.js +364 -419
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/security.js +485 -608
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.js +504 -626
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.js +267 -364
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.js +380 -486
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +408 -488
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.js +423 -538
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/transfer-store.js +322 -412
- package/dist/src/commands/transfer-store.js.map +1 -1
- package/dist/src/commands/update.js +196 -291
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/workflow.js +386 -486
- package/dist/src/commands/workflow.js.map +1 -1
- package/dist/src/config-adapter.d.ts +15 -0
- package/dist/src/config-adapter.d.ts.map +1 -0
- package/dist/src/config-adapter.js +38 -39
- package/dist/src/config-adapter.js.map +1 -1
- package/dist/src/index.d.ts +77 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +309 -411
- package/dist/src/index.js.map +1 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
- package/dist/src/infrastructure/in-memory-repositories.js +246 -507
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts +25 -0
- package/dist/src/init/claudemd-generator.d.ts.map +1 -0
- package/dist/src/init/claudemd-generator.js +368 -78
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts +41 -0
- package/dist/src/init/executor.d.ts.map +1 -0
- package/dist/src/init/executor.js +1307 -996
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts +60 -0
- package/dist/src/init/helpers-generator.d.ts.map +1 -0
- package/dist/src/init/helpers-generator.js +657 -12
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/index.d.ts +1 -1
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +1 -1
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/mcp-generator.js +33 -37
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.js +76 -77
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.js +801 -3
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +1 -1
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +76 -59
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-client.d.ts +92 -0
- package/dist/src/mcp-client.d.ts.map +1 -0
- package/dist/src/mcp-client.js +81 -125
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts +161 -0
- package/dist/src/mcp-server.d.ts.map +1 -0
- package/dist/src/mcp-server.js +470 -757
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +391 -492
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/agentdb-tools.js +332 -533
- package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.js +172 -236
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.d.ts +83 -0
- package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
- package/dist/src/mcp-tools/auto-install.js +80 -142
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +252 -375
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +473 -565
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +197 -272
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.js +500 -572
- package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
- package/dist/src/mcp-tools/daa-tools.js +286 -364
- package/dist/src/mcp-tools/daa-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +582 -693
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +260 -311
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +350 -505
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +315 -412
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +420 -480
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/progress-tools.js +204 -278
- package/dist/src/mcp-tools/progress-tools.js.map +1 -1
- package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
- package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
- package/dist/src/mcp-tools/security-tools.js +297 -429
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +185 -234
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +207 -260
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +276 -325
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +270 -336
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +148 -196
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +186 -333
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/types.d.ts +31 -0
- package/dist/src/mcp-tools/types.d.ts.map +1 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/workflow-tools.js +405 -450
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.d.ts +295 -0
- package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
- package/dist/src/memory/ewc-consolidation.js +190 -303
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts +338 -0
- package/dist/src/memory/intelligence.d.ts.map +1 -0
- package/dist/src/memory/intelligence.js +569 -794
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +407 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge.js +1170 -1640
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +412 -0
- package/dist/src/memory/memory-initializer.d.ts.map +1 -0
- package/dist/src/memory/memory-initializer.js +1836 -1851
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +227 -0
- package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
- package/dist/src/memory/sona-optimizer.js +199 -329
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/output.d.ts +2 -2
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +242 -272
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.d.ts +51 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +140 -187
- package/dist/src/parser.js.map +1 -1
- package/dist/src/plugins/manager.d.ts +133 -0
- package/dist/src/plugins/manager.d.ts.map +1 -0
- package/dist/src/plugins/manager.js +285 -521
- package/dist/src/plugins/manager.js.map +1 -1
- package/dist/src/plugins/store/discovery.d.ts +88 -0
- package/dist/src/plugins/store/discovery.d.ts.map +1 -0
- package/dist/src/plugins/store/discovery.js +271 -358
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/index.d.ts +76 -0
- package/dist/src/plugins/store/index.d.ts.map +1 -0
- package/dist/src/plugins/store/index.js +48 -105
- package/dist/src/plugins/store/index.js.map +1 -1
- package/dist/src/plugins/store/search.d.ts +46 -0
- package/dist/src/plugins/store/search.d.ts.map +1 -0
- package/dist/src/plugins/store/search.js +69 -107
- package/dist/src/plugins/store/search.js.map +1 -1
- package/dist/src/plugins/store/types.d.ts +274 -0
- package/dist/src/plugins/store/types.d.ts.map +1 -0
- package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
- package/dist/src/plugins/tests/standalone-test.js +172 -223
- package/dist/src/plugins/tests/standalone-test.js.map +1 -1
- package/dist/src/plugins/tests/test-plugin-store.js +190 -228
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
- package/dist/src/production/circuit-breaker.d.ts +101 -0
- package/dist/src/production/circuit-breaker.d.ts.map +1 -0
- package/dist/src/production/circuit-breaker.js +62 -126
- package/dist/src/production/circuit-breaker.js.map +1 -1
- package/dist/src/production/error-handler.d.ts +92 -0
- package/dist/src/production/error-handler.d.ts.map +1 -0
- package/dist/src/production/error-handler.js +86 -156
- package/dist/src/production/error-handler.js.map +1 -1
- package/dist/src/production/monitoring.d.ts +161 -0
- package/dist/src/production/monitoring.d.ts.map +1 -0
- package/dist/src/production/monitoring.js +139 -220
- package/dist/src/production/monitoring.js.map +1 -1
- package/dist/src/production/rate-limiter.d.ts +80 -0
- package/dist/src/production/rate-limiter.d.ts.map +1 -0
- package/dist/src/production/rate-limiter.js +74 -93
- package/dist/src/production/rate-limiter.js.map +1 -1
- package/dist/src/production/retry.d.ts +48 -0
- package/dist/src/production/retry.d.ts.map +1 -0
- package/dist/src/production/retry.js +75 -167
- package/dist/src/production/retry.js.map +1 -1
- package/dist/src/prompt.d.ts +44 -0
- package/dist/src/prompt.d.ts.map +1 -0
- package/dist/src/prompt.js +436 -560
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/runtime/headless.d.ts +60 -0
- package/dist/src/runtime/headless.d.ts.map +1 -0
- package/dist/src/runtime/headless.js +197 -286
- package/dist/src/runtime/headless.js.map +1 -1
- package/dist/src/ruvector/agent-wasm.d.ts +182 -0
- package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/agent-wasm.js +156 -351
- package/dist/src/ruvector/agent-wasm.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +145 -232
- package/dist/src/ruvector/ast-analyzer.js.map +1 -1
- package/dist/src/ruvector/coverage-router.d.ts +160 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +287 -419
- package/dist/src/ruvector/coverage-router.js.map +1 -1
- package/dist/src/ruvector/coverage-tools.js +56 -101
- package/dist/src/ruvector/coverage-tools.js.map +1 -1
- package/dist/src/ruvector/diff-classifier.d.ts +175 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +324 -451
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
- package/dist/src/ruvector/enhanced-model-router.js +260 -336
- package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
- package/dist/src/ruvector/flash-attention.d.ts +195 -0
- package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
- package/dist/src/ruvector/flash-attention.js +223 -254
- package/dist/src/ruvector/flash-attention.js.map +1 -1
- package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +486 -680
- package/dist/src/ruvector/graph-analyzer.js.map +1 -1
- package/dist/src/ruvector/index.d.ts +40 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +36 -106
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.d.ts +218 -0
- package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
- package/dist/src/ruvector/lora-adapter.js +155 -248
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/ruvector/model-router.d.ts +220 -0
- package/dist/src/ruvector/model-router.d.ts.map +1 -0
- package/dist/src/ruvector/model-router.js +175 -248
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/moe-router.d.ts +206 -0
- package/dist/src/ruvector/moe-router.d.ts.map +1 -0
- package/dist/src/ruvector/moe-router.js +228 -286
- package/dist/src/ruvector/moe-router.js.map +1 -1
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +257 -338
- package/dist/src/ruvector/q-learning-router.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
- package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/ruvllm-wasm.js +270 -434
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
- package/dist/src/ruvector/semantic-router.d.ts +77 -0
- package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
- package/dist/src/ruvector/semantic-router.js +60 -67
- package/dist/src/ruvector/semantic-router.js.map +1 -1
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +119 -205
- package/dist/src/ruvector/vector-db.js.map +1 -1
- package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
- package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
- package/dist/src/services/agentic-flow-bridge.js +32 -105
- package/dist/src/services/agentic-flow-bridge.js.map +1 -1
- package/dist/src/services/claim-service.d.ts +204 -0
- package/dist/src/services/claim-service.d.ts.map +1 -0
- package/dist/src/services/claim-service.js +615 -940
- package/dist/src/services/claim-service.js.map +1 -1
- package/dist/src/services/container-worker-pool.d.ts +197 -0
- package/dist/src/services/container-worker-pool.d.ts.map +1 -0
- package/dist/src/services/container-worker-pool.js +398 -666
- package/dist/src/services/container-worker-pool.js.map +1 -1
- package/dist/src/services/headless-worker-executor.d.ts +304 -0
- package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
- package/dist/src/services/headless-worker-executor.js +441 -467
- package/dist/src/services/headless-worker-executor.js.map +1 -1
- package/dist/src/services/index.d.ts +4 -4
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +4 -4
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/registry-api.d.ts +58 -0
- package/dist/src/services/registry-api.d.ts.map +1 -0
- package/dist/src/services/registry-api.js +92 -200
- package/dist/src/services/registry-api.js.map +1 -1
- package/dist/src/services/ruvector-training.d.ts +222 -0
- package/dist/src/services/ruvector-training.d.ts.map +1 -0
- package/dist/src/services/ruvector-training.js +257 -337
- package/dist/src/services/ruvector-training.js.map +1 -1
- package/dist/src/services/worker-daemon.d.ts +228 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +591 -849
- package/dist/src/services/worker-daemon.js.map +1 -1
- package/dist/src/services/worker-queue.d.ts +194 -0
- package/dist/src/services/worker-queue.d.ts.map +1 -0
- package/dist/src/services/worker-queue.js +331 -548
- package/dist/src/services/worker-queue.js.map +1 -1
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.d.ts.map +1 -0
- package/dist/src/suggest.js +45 -55
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +29 -37
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/transfer/deploy-seraphine.js +128 -155
- package/dist/src/transfer/deploy-seraphine.js.map +1 -1
- package/dist/src/transfer/export.d.ts +25 -0
- package/dist/src/transfer/export.d.ts.map +1 -0
- package/dist/src/transfer/export.js +84 -142
- package/dist/src/transfer/export.js.map +1 -1
- package/dist/src/transfer/index.d.ts +1 -1
- package/dist/src/transfer/index.d.ts.map +1 -1
- package/dist/src/transfer/index.js +0 -2
- package/dist/src/transfer/index.js.map +1 -1
- package/dist/src/transfer/ipfs/client.d.ts +109 -0
- package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/client.js +187 -337
- package/dist/src/transfer/ipfs/client.js.map +1 -1
- package/dist/src/transfer/ipfs/upload.d.ts +95 -0
- package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/upload.js +288 -434
- package/dist/src/transfer/ipfs/upload.js.map +1 -1
- package/dist/src/transfer/models/seraphine.d.ts +72 -0
- package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
- package/dist/src/transfer/models/seraphine.js +55 -55
- package/dist/src/transfer/models/seraphine.js.map +1 -1
- package/dist/src/transfer/serialization/cfp.d.ts +49 -0
- package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
- package/dist/src/transfer/serialization/cfp.js +30 -31
- package/dist/src/transfer/serialization/cfp.js.map +1 -1
- package/dist/src/transfer/storage/gcs.d.ts +82 -0
- package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
- package/dist/src/transfer/storage/gcs.js +165 -232
- package/dist/src/transfer/storage/gcs.js.map +1 -1
- package/dist/src/transfer/store/discovery.d.ts +84 -0
- package/dist/src/transfer/store/discovery.d.ts.map +1 -0
- package/dist/src/transfer/store/discovery.js +239 -349
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/transfer/store/download.d.ts +70 -0
- package/dist/src/transfer/store/download.d.ts.map +1 -0
- package/dist/src/transfer/store/download.js +243 -365
- package/dist/src/transfer/store/download.js.map +1 -1
- package/dist/src/transfer/store/index.d.ts +84 -0
- package/dist/src/transfer/store/index.d.ts.map +1 -0
- package/dist/src/transfer/store/index.js +63 -130
- package/dist/src/transfer/store/index.js.map +1 -1
- package/dist/src/transfer/store/publish.d.ts +76 -0
- package/dist/src/transfer/store/publish.d.ts.map +1 -0
- package/dist/src/transfer/store/publish.js +184 -258
- package/dist/src/transfer/store/publish.js.map +1 -1
- package/dist/src/transfer/store/registry.js +50 -72
- package/dist/src/transfer/store/registry.js.map +1 -1
- package/dist/src/transfer/store/search.d.ts +54 -0
- package/dist/src/transfer/store/search.d.ts.map +1 -0
- package/dist/src/transfer/store/search.js +64 -96
- package/dist/src/transfer/store/search.js.map +1 -1
- package/dist/src/transfer/store/tests/standalone-test.js +174 -231
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
- package/dist/src/transfer/test-seraphine.js +95 -130
- package/dist/src/transfer/test-seraphine.js.map +1 -1
- package/dist/src/transfer/tests/test-store.js +194 -239
- package/dist/src/transfer/tests/test-store.js.map +1 -1
- package/dist/src/transfer/types.d.ts +245 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/types.d.ts +198 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +26 -55
- package/dist/src/types.js.map +1 -1
- package/dist/src/update/checker.d.ts +34 -0
- package/dist/src/update/checker.d.ts.map +1 -0
- package/dist/src/update/checker.js +106 -183
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.d.ts +32 -0
- package/dist/src/update/executor.d.ts.map +1 -0
- package/dist/src/update/executor.js +135 -198
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.d.ts +33 -0
- package/dist/src/update/index.d.ts.map +1 -0
- package/dist/src/update/index.js +38 -85
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.d.ts +20 -0
- package/dist/src/update/rate-limiter.d.ts.map +1 -0
- package/dist/src/update/rate-limiter.js +19 -31
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.d.ts +17 -0
- package/dist/src/update/validator.d.ts.map +1 -0
- package/dist/src/update/validator.js +38 -64
- package/dist/src/update/validator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -2,425 +2,316 @@
|
|
|
2
2
|
* V3 CLI Guidance Command
|
|
3
3
|
* Guidance Control Plane - compile, retrieve, enforce, optimize
|
|
4
4
|
*/
|
|
5
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
15
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
16
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
17
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
18
|
-
function step(op) {
|
|
19
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
20
|
-
while (_) try {
|
|
21
|
-
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;
|
|
22
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
23
|
-
switch (op[0]) {
|
|
24
|
-
case 0: case 1: t = op; break;
|
|
25
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
26
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
27
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
28
|
-
default:
|
|
29
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
30
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
31
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
32
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
33
|
-
if (t[2]) _.ops.pop();
|
|
34
|
-
_.trys.pop(); continue;
|
|
35
|
-
}
|
|
36
|
-
op = body.call(thisArg, _);
|
|
37
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
38
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
5
|
import { output } from '../output.js';
|
|
42
6
|
// compile subcommand
|
|
43
|
-
|
|
7
|
+
const compileCommand = {
|
|
44
8
|
name: 'compile',
|
|
45
9
|
description: 'Compile CLAUDE.md into a policy bundle (constitution + shards + manifest)',
|
|
46
10
|
options: [
|
|
47
|
-
{ name: 'root', short: 'r', type: 'string', description: 'Root guidance file path',
|
|
11
|
+
{ name: 'root', short: 'r', type: 'string', description: 'Root guidance file path', default: './CLAUDE.md' },
|
|
48
12
|
{ name: 'local', short: 'l', type: 'string', description: 'Local guidance overlay file path' },
|
|
49
13
|
{ name: 'output', short: 'o', type: 'string', description: 'Output directory for compiled bundle' },
|
|
50
|
-
{ name: 'json', type: 'boolean', description: 'Output as JSON',
|
|
14
|
+
{ name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
|
|
51
15
|
],
|
|
52
16
|
examples: [
|
|
53
17
|
{ command: 'claude-flow guidance compile', description: 'Compile default CLAUDE.md' },
|
|
54
18
|
{ command: 'claude-flow guidance compile -r ./CLAUDE.md -l ./CLAUDE.local.md', description: 'Compile with local overlay' },
|
|
55
19
|
{ command: 'claude-flow guidance compile --json', description: 'Output compiled bundle as JSON' },
|
|
56
20
|
],
|
|
57
|
-
action:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
risk = rule.riskClass === 'critical' ? output.error(rule.riskClass) :
|
|
114
|
-
rule.riskClass === 'high' ? output.warning(rule.riskClass) :
|
|
115
|
-
output.dim(rule.riskClass);
|
|
116
|
-
output.writeln(" " + output.bold(rule.id) + " [" + risk + "] " + rule.source.slice(0, 60) + (rule.source.length > 60 ? '...' : ''));
|
|
117
|
-
}
|
|
118
|
-
if (bundle.manifest.rules.length > 10) {
|
|
119
|
-
output.writeln(output.dim(" ... and " + (bundle.manifest.rules.length - 10) + " more"));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return [2 /*return*/, { success: true, data: bundle }];
|
|
123
|
-
case 8:
|
|
124
|
-
error_1 = _b.sent();
|
|
125
|
-
msg = error_1 instanceof Error ? error_1.message : String(error_1);
|
|
126
|
-
output.writeln(output.error("Compilation failed: " + msg));
|
|
127
|
-
return [2 /*return*/, { success: false, message: msg }];
|
|
128
|
-
case 9: return [2 /*return*/];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}); }
|
|
21
|
+
action: async (ctx) => {
|
|
22
|
+
const rootPath = ctx.flags.root || './CLAUDE.md';
|
|
23
|
+
const localPath = ctx.flags.local;
|
|
24
|
+
const jsonOutput = ctx.flags.json === true;
|
|
25
|
+
output.writeln();
|
|
26
|
+
output.writeln(output.bold('Guidance Compiler'));
|
|
27
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
28
|
+
try {
|
|
29
|
+
const { readFile } = await import('node:fs/promises');
|
|
30
|
+
const { existsSync } = await import('node:fs');
|
|
31
|
+
if (!existsSync(rootPath)) {
|
|
32
|
+
output.writeln(output.error(`Root guidance file not found: ${rootPath}`));
|
|
33
|
+
return { success: false, message: `File not found: ${rootPath}` };
|
|
34
|
+
}
|
|
35
|
+
const rootContent = await readFile(rootPath, 'utf-8');
|
|
36
|
+
let localContent;
|
|
37
|
+
if (localPath && existsSync(localPath)) {
|
|
38
|
+
localContent = await readFile(localPath, 'utf-8');
|
|
39
|
+
}
|
|
40
|
+
const { GuidanceCompiler } = await import('@claude-flow/guidance/compiler');
|
|
41
|
+
const compiler = new GuidanceCompiler();
|
|
42
|
+
const bundle = compiler.compile(rootContent, localContent);
|
|
43
|
+
if (jsonOutput) {
|
|
44
|
+
output.writeln(JSON.stringify(bundle, null, 2));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
output.writeln(output.success('Compiled successfully'));
|
|
48
|
+
output.writeln();
|
|
49
|
+
output.writeln(` Constitution rules: ${output.bold(String(bundle.constitution.rules.length))}`);
|
|
50
|
+
output.writeln(` Constitution hash: ${output.dim(bundle.constitution.hash)}`);
|
|
51
|
+
output.writeln(` Shard count: ${output.bold(String(bundle.shards.length))}`);
|
|
52
|
+
output.writeln(` Total rules: ${output.bold(String(bundle.manifest.totalRules))}`);
|
|
53
|
+
output.writeln(` Compiled at: ${output.dim(new Date(bundle.manifest.compiledAt).toISOString())}`);
|
|
54
|
+
if (localContent) {
|
|
55
|
+
output.writeln(` Local overlay: ${output.success('applied')}`);
|
|
56
|
+
}
|
|
57
|
+
output.writeln();
|
|
58
|
+
output.writeln(output.dim('Rule summary:'));
|
|
59
|
+
for (const rule of bundle.manifest.rules.slice(0, 10)) {
|
|
60
|
+
const risk = rule.riskClass === 'critical' ? output.error(rule.riskClass) :
|
|
61
|
+
rule.riskClass === 'high' ? output.warning(rule.riskClass) :
|
|
62
|
+
output.dim(rule.riskClass);
|
|
63
|
+
output.writeln(` ${output.bold(rule.id)} [${risk}] ${rule.source.slice(0, 60)}${rule.source.length > 60 ? '...' : ''}`);
|
|
64
|
+
}
|
|
65
|
+
if (bundle.manifest.rules.length > 10) {
|
|
66
|
+
output.writeln(output.dim(` ... and ${bundle.manifest.rules.length - 10} more`));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { success: true, data: bundle };
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
73
|
+
output.writeln(output.error(`Compilation failed: ${msg}`));
|
|
74
|
+
return { success: false, message: msg };
|
|
75
|
+
}
|
|
76
|
+
},
|
|
132
77
|
};
|
|
133
78
|
// retrieve subcommand
|
|
134
|
-
|
|
79
|
+
const retrieveCommand = {
|
|
135
80
|
name: 'retrieve',
|
|
136
81
|
description: 'Retrieve task-relevant guidance shards for a given task description',
|
|
137
82
|
options: [
|
|
138
83
|
{ name: 'task', short: 't', type: 'string', description: 'Task description', required: true },
|
|
139
|
-
{ name: 'root', short: 'r', type: 'string', description: 'Root guidance file path',
|
|
84
|
+
{ name: 'root', short: 'r', type: 'string', description: 'Root guidance file path', default: './CLAUDE.md' },
|
|
140
85
|
{ name: 'local', short: 'l', type: 'string', description: 'Local overlay file path' },
|
|
141
|
-
{ name: 'max-shards', short: 'n', type: 'number', description: 'Maximum number of shards to retrieve',
|
|
86
|
+
{ name: 'max-shards', short: 'n', type: 'number', description: 'Maximum number of shards to retrieve', default: '5' },
|
|
142
87
|
{ name: 'intent', short: 'i', type: 'string', description: 'Override detected intent' },
|
|
143
|
-
{ name: 'json', type: 'boolean', description: 'Output as JSON',
|
|
88
|
+
{ name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
|
|
144
89
|
],
|
|
145
90
|
examples: [
|
|
146
91
|
{ command: 'claude-flow guidance retrieve -t "Fix SQL injection in user search"', description: 'Retrieve guidance for a security task' },
|
|
147
92
|
{ command: 'claude-flow guidance retrieve -t "Add unit tests" -n 3', description: 'Retrieve top 3 shards for testing' },
|
|
148
93
|
],
|
|
149
|
-
action:
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return [4 /*yield*/, retriever.loadBundle(bundle)];
|
|
200
|
-
case 9:
|
|
201
|
-
_d.sent();
|
|
202
|
-
return [4 /*yield*/, retriever.retrieve({
|
|
203
|
-
taskDescription: task,
|
|
204
|
-
maxShards: maxShards,
|
|
205
|
-
intent: intentOverride
|
|
206
|
-
})];
|
|
207
|
-
case 10:
|
|
208
|
-
result = _d.sent();
|
|
209
|
-
if (jsonOutput) {
|
|
210
|
-
output.writeln(JSON.stringify(result, null, 2));
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
output.writeln(" Detected intent: " + output.bold(result.detectedIntent));
|
|
214
|
-
output.writeln(" Retrieval time: " + output.dim(result.latencyMs + 'ms'));
|
|
215
|
-
output.writeln(" Constitution: " + output.bold(String(result.constitution.rules.length)) + " rules");
|
|
216
|
-
output.writeln(" Shards: " + output.bold(String(result.shards.length)) + " retrieved");
|
|
217
|
-
output.writeln();
|
|
218
|
-
if (result.shards.length > 0) {
|
|
219
|
-
output.writeln(output.dim('Retrieved shards:'));
|
|
220
|
-
for (_i = 0, _b = result.shards; _i < _b.length; _i++) {
|
|
221
|
-
shard = _b[_i];
|
|
222
|
-
output.writeln(" " + output.bold(shard.shard.rule.id) + " [" + shard.shard.rule.riskClass + "] " + shard.shard.rule.text.slice(0, 60));
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
output.writeln();
|
|
226
|
-
output.writeln(output.dim('Policy text preview:'));
|
|
227
|
-
lines = result.policyText.split('\n').slice(0, 15);
|
|
228
|
-
for (_c = 0, lines_1 = lines; _c < lines_1.length; _c++) {
|
|
229
|
-
line = lines_1[_c];
|
|
230
|
-
output.writeln(" " + line);
|
|
231
|
-
}
|
|
232
|
-
if (result.policyText.split('\n').length > 15) {
|
|
233
|
-
output.writeln(output.dim(' ...'));
|
|
234
|
-
}
|
|
94
|
+
action: async (ctx) => {
|
|
95
|
+
const task = ctx.flags.task;
|
|
96
|
+
const rootPath = ctx.flags.root || './CLAUDE.md';
|
|
97
|
+
const localPath = ctx.flags.local;
|
|
98
|
+
const maxShards = parseInt(ctx.flags['max-shards'] || '5', 10);
|
|
99
|
+
const intentOverride = ctx.flags.intent;
|
|
100
|
+
const jsonOutput = ctx.flags.json === true;
|
|
101
|
+
if (!task) {
|
|
102
|
+
output.writeln(output.error('Task description is required (-t "...")'));
|
|
103
|
+
return { success: false, message: 'Missing task description' };
|
|
104
|
+
}
|
|
105
|
+
output.writeln();
|
|
106
|
+
output.writeln(output.bold('Guidance Retriever'));
|
|
107
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
108
|
+
try {
|
|
109
|
+
const { readFile } = await import('node:fs/promises');
|
|
110
|
+
const { existsSync } = await import('node:fs');
|
|
111
|
+
const { GuidanceCompiler } = await import('@claude-flow/guidance/compiler');
|
|
112
|
+
const { ShardRetriever, HashEmbeddingProvider } = await import('@claude-flow/guidance/retriever');
|
|
113
|
+
if (!existsSync(rootPath)) {
|
|
114
|
+
output.writeln(output.error(`Root guidance file not found: ${rootPath}`));
|
|
115
|
+
return { success: false, message: `File not found: ${rootPath}` };
|
|
116
|
+
}
|
|
117
|
+
const rootContent = await readFile(rootPath, 'utf-8');
|
|
118
|
+
let localContent;
|
|
119
|
+
if (localPath && existsSync(localPath)) {
|
|
120
|
+
localContent = await readFile(localPath, 'utf-8');
|
|
121
|
+
}
|
|
122
|
+
const compiler = new GuidanceCompiler();
|
|
123
|
+
const bundle = compiler.compile(rootContent, localContent);
|
|
124
|
+
const retriever = new ShardRetriever(new HashEmbeddingProvider(128));
|
|
125
|
+
await retriever.loadBundle(bundle);
|
|
126
|
+
const result = await retriever.retrieve({
|
|
127
|
+
taskDescription: task,
|
|
128
|
+
maxShards,
|
|
129
|
+
intent: intentOverride,
|
|
130
|
+
});
|
|
131
|
+
if (jsonOutput) {
|
|
132
|
+
output.writeln(JSON.stringify(result, null, 2));
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
output.writeln(` Detected intent: ${output.bold(result.detectedIntent)}`);
|
|
136
|
+
output.writeln(` Retrieval time: ${output.dim(result.latencyMs + 'ms')}`);
|
|
137
|
+
output.writeln(` Constitution: ${output.bold(String(result.constitution.rules.length))} rules`);
|
|
138
|
+
output.writeln(` Shards: ${output.bold(String(result.shards.length))} retrieved`);
|
|
139
|
+
output.writeln();
|
|
140
|
+
if (result.shards.length > 0) {
|
|
141
|
+
output.writeln(output.dim('Retrieved shards:'));
|
|
142
|
+
for (const shard of result.shards) {
|
|
143
|
+
output.writeln(` ${output.bold(shard.shard.rule.id)} [${shard.shard.rule.riskClass}] ${shard.shard.rule.text.slice(0, 60)}`);
|
|
235
144
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
145
|
+
}
|
|
146
|
+
output.writeln();
|
|
147
|
+
output.writeln(output.dim('Policy text preview:'));
|
|
148
|
+
const lines = result.policyText.split('\n').slice(0, 15);
|
|
149
|
+
for (const line of lines) {
|
|
150
|
+
output.writeln(` ${line}`);
|
|
151
|
+
}
|
|
152
|
+
if (result.policyText.split('\n').length > 15) {
|
|
153
|
+
output.writeln(output.dim(' ...'));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return { success: true, data: result };
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
160
|
+
output.writeln(output.error(`Retrieval failed: ${msg}`));
|
|
161
|
+
return { success: false, message: msg };
|
|
162
|
+
}
|
|
163
|
+
},
|
|
246
164
|
};
|
|
247
165
|
// gates subcommand
|
|
248
|
-
|
|
166
|
+
const gatesCommand = {
|
|
249
167
|
name: 'gates',
|
|
250
168
|
description: 'Evaluate enforcement gates against a command or content',
|
|
251
169
|
options: [
|
|
252
170
|
{ name: 'command', short: 'c', type: 'string', description: 'Command to evaluate' },
|
|
253
171
|
{ name: 'content', type: 'string', description: 'Content to check for secrets' },
|
|
254
172
|
{ name: 'tool', short: 't', type: 'string', description: 'Tool name to check against allowlist' },
|
|
255
|
-
{ name: 'json', type: 'boolean', description: 'Output as JSON',
|
|
173
|
+
{ name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
|
|
256
174
|
],
|
|
257
175
|
examples: [
|
|
258
176
|
{ command: 'claude-flow guidance gates -c "rm -rf /tmp"', description: 'Check if a command is destructive' },
|
|
259
177
|
{ command: 'claude-flow guidance gates --content "api_key=sk-abc123..."', description: 'Check content for secrets' },
|
|
260
178
|
],
|
|
261
|
-
action:
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (jsonOutput) {
|
|
298
|
-
output.writeln(JSON.stringify(results, null, 2));
|
|
179
|
+
action: async (ctx) => {
|
|
180
|
+
const command = ctx.flags.command;
|
|
181
|
+
const content = ctx.flags.content;
|
|
182
|
+
const tool = ctx.flags.tool;
|
|
183
|
+
const jsonOutput = ctx.flags.json === true;
|
|
184
|
+
output.writeln();
|
|
185
|
+
output.writeln(output.bold('Enforcement Gates'));
|
|
186
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
187
|
+
try {
|
|
188
|
+
const { EnforcementGates } = await import('@claude-flow/guidance/gates');
|
|
189
|
+
const gates = new EnforcementGates();
|
|
190
|
+
const results = [];
|
|
191
|
+
if (command) {
|
|
192
|
+
const gateResults = gates.evaluateCommand(command);
|
|
193
|
+
results.push({ type: 'command', result: gateResults });
|
|
194
|
+
}
|
|
195
|
+
if (content) {
|
|
196
|
+
const secretResult = gates.evaluateSecrets(content);
|
|
197
|
+
results.push({ type: 'secrets', result: secretResult });
|
|
198
|
+
}
|
|
199
|
+
if (tool) {
|
|
200
|
+
const toolResult = gates.evaluateToolAllowlist(tool);
|
|
201
|
+
results.push({ type: 'tool-allowlist', result: toolResult });
|
|
202
|
+
}
|
|
203
|
+
if (results.length === 0) {
|
|
204
|
+
output.writeln(output.warning('No input provided. Use -c, --content, or -t to evaluate.'));
|
|
205
|
+
return { success: false, message: 'No input' };
|
|
206
|
+
}
|
|
207
|
+
if (jsonOutput) {
|
|
208
|
+
output.writeln(JSON.stringify(results, null, 2));
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
for (const { type, result } of results) {
|
|
212
|
+
output.writeln(` ${output.bold(type)}:`);
|
|
213
|
+
if (result === null) {
|
|
214
|
+
output.writeln(` ${output.success('ALLOW')} - No gate triggered`);
|
|
299
215
|
}
|
|
300
|
-
else {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
if (result.length === 0) {
|
|
309
|
-
output.writeln(" " + output.success('ALLOW') + " - All gates passed");
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
for (_b = 0, result_1 = result; _b < result_1.length; _b++) {
|
|
313
|
-
r = result_1[_b];
|
|
314
|
-
color = r.decision === 'block' ? output.error.bind(output) :
|
|
315
|
-
r.decision === 'require-confirmation' ? output.warning.bind(output) :
|
|
316
|
-
output.dim.bind(output);
|
|
317
|
-
output.writeln(" " + color(r.decision.toUpperCase()) + " [" + r.gateName + "] " + r.reason);
|
|
318
|
-
if (r.remediation) {
|
|
319
|
-
output.writeln(" Remediation: " + output.dim(r.remediation));
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
color = result.decision === 'block' ? output.error.bind(output) :
|
|
326
|
-
result.decision === 'require-confirmation' ? output.warning.bind(output) :
|
|
216
|
+
else if (Array.isArray(result)) {
|
|
217
|
+
if (result.length === 0) {
|
|
218
|
+
output.writeln(` ${output.success('ALLOW')} - All gates passed`);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
for (const r of result) {
|
|
222
|
+
const color = r.decision === 'block' ? output.error.bind(output) :
|
|
223
|
+
r.decision === 'require-confirmation' ? output.warning.bind(output) :
|
|
327
224
|
output.dim.bind(output);
|
|
328
|
-
output.writeln(
|
|
329
|
-
if (
|
|
330
|
-
output.writeln(
|
|
225
|
+
output.writeln(` ${color(r.decision.toUpperCase())} [${r.gateName}] ${r.reason}`);
|
|
226
|
+
if (r.remediation) {
|
|
227
|
+
output.writeln(` Remediation: ${output.dim(r.remediation)}`);
|
|
331
228
|
}
|
|
332
229
|
}
|
|
333
230
|
}
|
|
334
231
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
232
|
+
else {
|
|
233
|
+
const color = result.decision === 'block' ? output.error.bind(output) :
|
|
234
|
+
result.decision === 'require-confirmation' ? output.warning.bind(output) :
|
|
235
|
+
output.dim.bind(output);
|
|
236
|
+
output.writeln(` ${color(result.decision.toUpperCase())} [${result.gateName}] ${result.reason}`);
|
|
237
|
+
if (result.remediation) {
|
|
238
|
+
output.writeln(` Remediation: ${output.dim(result.remediation)}`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return { success: true, data: results };
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
247
|
+
output.writeln(output.error(`Gate evaluation failed: ${msg}`));
|
|
248
|
+
return { success: false, message: msg };
|
|
249
|
+
}
|
|
250
|
+
},
|
|
345
251
|
};
|
|
346
252
|
// status subcommand
|
|
347
|
-
|
|
253
|
+
const statusCommand = {
|
|
348
254
|
name: 'status',
|
|
349
255
|
description: 'Show guidance control plane status and metrics',
|
|
350
256
|
options: [
|
|
351
|
-
{ name: 'json', type: 'boolean', description: 'Output as JSON',
|
|
257
|
+
{ name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
|
|
352
258
|
],
|
|
353
|
-
action:
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
output.writeln(" Local overlay: " + (localExists ? output.success('CLAUDE.local.md found') : output.dim('not configured')));
|
|
381
|
-
output.writeln(" Data directory: " + (statusData.dataDir === 'exists' ? output.success('exists') : output.dim('not created')));
|
|
382
|
-
if (!rootExists) return [3 /*break*/, 7];
|
|
383
|
-
return [4 /*yield*/, import('node:fs/promises')];
|
|
384
|
-
case 4:
|
|
385
|
-
readFile = (_a.sent()).readFile;
|
|
386
|
-
return [4 /*yield*/, import('@claude-flow/guidance/compiler')];
|
|
387
|
-
case 5:
|
|
388
|
-
GuidanceCompiler = (_a.sent()).GuidanceCompiler;
|
|
389
|
-
return [4 /*yield*/, readFile('./CLAUDE.md', 'utf-8')];
|
|
390
|
-
case 6:
|
|
391
|
-
rootContent = _a.sent();
|
|
392
|
-
compiler = new GuidanceCompiler();
|
|
393
|
-
bundle = compiler.compile(rootContent);
|
|
259
|
+
action: async (ctx) => {
|
|
260
|
+
const jsonOutput = ctx.flags.json === true;
|
|
261
|
+
output.writeln();
|
|
262
|
+
output.writeln(output.bold('Guidance Control Plane Status'));
|
|
263
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
264
|
+
try {
|
|
265
|
+
const { existsSync } = await import('node:fs');
|
|
266
|
+
const rootExists = existsSync('./CLAUDE.md');
|
|
267
|
+
const localExists = existsSync('./CLAUDE.local.md');
|
|
268
|
+
const statusData = {
|
|
269
|
+
rootGuidance: rootExists ? 'found' : 'not found',
|
|
270
|
+
localOverlay: localExists ? 'found' : 'not configured',
|
|
271
|
+
dataDir: existsSync('./.claude-flow/guidance') ? 'exists' : 'not created',
|
|
272
|
+
};
|
|
273
|
+
if (jsonOutput) {
|
|
274
|
+
output.writeln(JSON.stringify(statusData, null, 2));
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
output.writeln(` Root guidance: ${rootExists ? output.success('CLAUDE.md found') : output.warning('CLAUDE.md not found')}`);
|
|
278
|
+
output.writeln(` Local overlay: ${localExists ? output.success('CLAUDE.local.md found') : output.dim('not configured')}`);
|
|
279
|
+
output.writeln(` Data directory: ${statusData.dataDir === 'exists' ? output.success('exists') : output.dim('not created')}`);
|
|
280
|
+
if (rootExists) {
|
|
281
|
+
const { readFile } = await import('node:fs/promises');
|
|
282
|
+
const { GuidanceCompiler } = await import('@claude-flow/guidance/compiler');
|
|
283
|
+
const rootContent = await readFile('./CLAUDE.md', 'utf-8');
|
|
284
|
+
const compiler = new GuidanceCompiler();
|
|
285
|
+
const bundle = compiler.compile(rootContent);
|
|
394
286
|
output.writeln();
|
|
395
287
|
output.writeln(output.dim('Compiled bundle:'));
|
|
396
|
-
output.writeln(
|
|
397
|
-
output.writeln(
|
|
398
|
-
output.writeln(
|
|
399
|
-
output.writeln(
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}); }
|
|
288
|
+
output.writeln(` Constitution rules: ${output.bold(String(bundle.constitution.rules.length))}`);
|
|
289
|
+
output.writeln(` Shard count: ${output.bold(String(bundle.shards.length))}`);
|
|
290
|
+
output.writeln(` Total rules: ${output.bold(String(bundle.manifest.totalRules))}`);
|
|
291
|
+
output.writeln(` Hash: ${output.dim(bundle.constitution.hash)}`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return { success: true, data: statusData };
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
298
|
+
output.writeln(output.error(`Status check failed: ${msg}`));
|
|
299
|
+
return { success: false, message: msg };
|
|
300
|
+
}
|
|
301
|
+
},
|
|
411
302
|
};
|
|
412
303
|
// optimize subcommand
|
|
413
|
-
|
|
304
|
+
const optimizeCommand = {
|
|
414
305
|
name: 'optimize',
|
|
415
306
|
description: 'Analyze and optimize a CLAUDE.md file for structure, coverage, and enforceability',
|
|
416
307
|
options: [
|
|
417
|
-
{ name: 'root', short: 'r', type: 'string', description: 'Root guidance file path',
|
|
308
|
+
{ name: 'root', short: 'r', type: 'string', description: 'Root guidance file path', default: './CLAUDE.md' },
|
|
418
309
|
{ name: 'local', short: 'l', type: 'string', description: 'Local overlay file path' },
|
|
419
|
-
{ name: 'apply', short: 'a', type: 'boolean', description: 'Apply optimizations to the file',
|
|
420
|
-
{ name: 'context-size', short: 's', type: 'string', description: 'Target context size: compact, standard, full',
|
|
421
|
-
{ name: 'target-score', type: 'number', description: 'Target composite score (0-100)',
|
|
422
|
-
{ name: 'max-iterations', type: 'number', description: 'Maximum optimization iterations',
|
|
423
|
-
{ name: 'json', type: 'boolean', description: 'Output as JSON',
|
|
310
|
+
{ name: 'apply', short: 'a', type: 'boolean', description: 'Apply optimizations to the file', default: 'false' },
|
|
311
|
+
{ name: 'context-size', short: 's', type: 'string', description: 'Target context size: compact, standard, full', default: 'standard' },
|
|
312
|
+
{ name: 'target-score', type: 'number', description: 'Target composite score (0-100)', default: '90' },
|
|
313
|
+
{ name: 'max-iterations', type: 'number', description: 'Maximum optimization iterations', default: '5' },
|
|
314
|
+
{ name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
|
|
424
315
|
],
|
|
425
316
|
examples: [
|
|
426
317
|
{ command: 'claude-flow guidance optimize', description: 'Analyze current CLAUDE.md and show suggestions' },
|
|
@@ -428,121 +319,102 @@ var optimizeCommand = {
|
|
|
428
319
|
{ command: 'claude-flow guidance optimize -s compact --apply', description: 'Optimize for compact context window' },
|
|
429
320
|
{ command: 'claude-flow guidance optimize --target-score 95', description: 'Optimize until score reaches 95' },
|
|
430
321
|
],
|
|
431
|
-
action:
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
output.writeln(output.success("Optimized CLAUDE.md written to " + rootPath));
|
|
517
|
-
output.writeln(" Before: " + analysis.compositeScore + "/100 (" + analysis.grade + ")");
|
|
518
|
-
output.writeln(" After: " + result.benchmark.after.compositeScore + "/100 (" + result.benchmark.after.grade + ")");
|
|
519
|
-
output.writeln(" Delta: " + (result.benchmark.delta >= 0 ? '+' : '') + result.benchmark.delta);
|
|
520
|
-
return [3 /*break*/, 10];
|
|
521
|
-
case 9:
|
|
522
|
-
output.writeln(output.warning('Dry run - use --apply to write changes.'));
|
|
523
|
-
output.writeln(" Projected: " + analysis.compositeScore + " \u2192 " + result.benchmark.after.compositeScore + "/100");
|
|
524
|
-
_d.label = 10;
|
|
525
|
-
case 10: return [2 /*return*/, { success: true, data: result }];
|
|
526
|
-
case 11:
|
|
527
|
-
error_5 = _d.sent();
|
|
528
|
-
msg = error_5 instanceof Error ? error_5.message : String(error_5);
|
|
529
|
-
output.writeln(output.error("Optimization failed: " + msg));
|
|
530
|
-
return [2 /*return*/, { success: false, message: msg }];
|
|
531
|
-
case 12: return [2 /*return*/];
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
}); }
|
|
322
|
+
action: async (ctx) => {
|
|
323
|
+
const rootPath = ctx.flags.root || './CLAUDE.md';
|
|
324
|
+
const localPath = ctx.flags.local;
|
|
325
|
+
const applyChanges = ctx.flags.apply === true;
|
|
326
|
+
const contextSize = (ctx.flags['context-size'] || 'standard');
|
|
327
|
+
const targetScore = parseInt(ctx.flags['target-score'] || '90', 10);
|
|
328
|
+
const maxIterations = parseInt(ctx.flags['max-iterations'] || '5', 10);
|
|
329
|
+
const jsonOutput = ctx.flags.json === true;
|
|
330
|
+
output.writeln();
|
|
331
|
+
output.writeln(output.bold('Guidance Optimizer'));
|
|
332
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
333
|
+
try {
|
|
334
|
+
const { readFile, writeFile } = await import('node:fs/promises');
|
|
335
|
+
const { existsSync } = await import('node:fs');
|
|
336
|
+
if (!existsSync(rootPath)) {
|
|
337
|
+
output.writeln(output.error(`Root guidance file not found: ${rootPath}`));
|
|
338
|
+
return { success: false, message: `File not found: ${rootPath}` };
|
|
339
|
+
}
|
|
340
|
+
const rootContent = await readFile(rootPath, 'utf-8');
|
|
341
|
+
let localContent;
|
|
342
|
+
if (localPath && existsSync(localPath)) {
|
|
343
|
+
localContent = await readFile(localPath, 'utf-8');
|
|
344
|
+
}
|
|
345
|
+
// Step 1: Analyze current state
|
|
346
|
+
const { analyze, formatReport, optimizeForSize, formatBenchmark } = await import('@claude-flow/guidance/analyzer');
|
|
347
|
+
const analysis = analyze(rootContent, localContent);
|
|
348
|
+
if (jsonOutput && !applyChanges) {
|
|
349
|
+
output.writeln(JSON.stringify(analysis, null, 2));
|
|
350
|
+
return { success: true, data: analysis };
|
|
351
|
+
}
|
|
352
|
+
// Show current analysis
|
|
353
|
+
output.writeln(formatReport(analysis));
|
|
354
|
+
output.writeln();
|
|
355
|
+
if (analysis.compositeScore >= targetScore) {
|
|
356
|
+
output.writeln(output.success(`Score ${analysis.compositeScore}/100 already meets target ${targetScore}. No optimization needed.`));
|
|
357
|
+
return { success: true, data: analysis };
|
|
358
|
+
}
|
|
359
|
+
// Step 2: Run optimization
|
|
360
|
+
output.writeln(output.dim(`Optimizing (target: ${targetScore}, context: ${contextSize}, max iterations: ${maxIterations})...`));
|
|
361
|
+
const result = optimizeForSize(rootContent, {
|
|
362
|
+
contextSize,
|
|
363
|
+
localContent,
|
|
364
|
+
maxIterations,
|
|
365
|
+
targetScore,
|
|
366
|
+
});
|
|
367
|
+
if (jsonOutput) {
|
|
368
|
+
output.writeln(JSON.stringify({
|
|
369
|
+
before: analysis,
|
|
370
|
+
after: result.benchmark.after,
|
|
371
|
+
delta: result.benchmark.delta,
|
|
372
|
+
steps: result.appliedSteps,
|
|
373
|
+
}, null, 2));
|
|
374
|
+
return { success: true, data: result };
|
|
375
|
+
}
|
|
376
|
+
// Show benchmark comparison
|
|
377
|
+
output.writeln();
|
|
378
|
+
output.writeln(formatBenchmark(result.benchmark));
|
|
379
|
+
output.writeln();
|
|
380
|
+
if (result.appliedSteps.length > 0) {
|
|
381
|
+
output.writeln(`Applied ${output.bold(String(result.appliedSteps.length))} optimization steps:`);
|
|
382
|
+
for (const step of result.appliedSteps) {
|
|
383
|
+
output.writeln(` ${output.success('+')} ${step}`);
|
|
384
|
+
}
|
|
385
|
+
output.writeln();
|
|
386
|
+
}
|
|
387
|
+
// Step 3: Apply if requested
|
|
388
|
+
if (applyChanges) {
|
|
389
|
+
await writeFile(rootPath, result.optimized, 'utf-8');
|
|
390
|
+
output.writeln(output.success(`Optimized CLAUDE.md written to ${rootPath}`));
|
|
391
|
+
output.writeln(` Before: ${analysis.compositeScore}/100 (${analysis.grade})`);
|
|
392
|
+
output.writeln(` After: ${result.benchmark.after.compositeScore}/100 (${result.benchmark.after.grade})`);
|
|
393
|
+
output.writeln(` Delta: ${result.benchmark.delta >= 0 ? '+' : ''}${result.benchmark.delta}`);
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
output.writeln(output.warning('Dry run - use --apply to write changes.'));
|
|
397
|
+
output.writeln(` Projected: ${analysis.compositeScore} → ${result.benchmark.after.compositeScore}/100`);
|
|
398
|
+
}
|
|
399
|
+
return { success: true, data: result };
|
|
400
|
+
}
|
|
401
|
+
catch (error) {
|
|
402
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
403
|
+
output.writeln(output.error(`Optimization failed: ${msg}`));
|
|
404
|
+
return { success: false, message: msg };
|
|
405
|
+
}
|
|
406
|
+
},
|
|
535
407
|
};
|
|
536
408
|
// ab-test subcommand
|
|
537
|
-
|
|
409
|
+
const abTestCommand = {
|
|
538
410
|
name: 'ab-test',
|
|
539
411
|
description: 'Run A/B behavioral comparison between two CLAUDE.md versions',
|
|
540
412
|
options: [
|
|
541
413
|
{ name: 'config-a', short: 'a', type: 'string', description: 'Path to Config A (baseline CLAUDE.md). Defaults to no guidance.' },
|
|
542
|
-
{ name: 'config-b', short: 'b', type: 'string', description: 'Path to Config B (candidate CLAUDE.md)',
|
|
414
|
+
{ name: 'config-b', short: 'b', type: 'string', description: 'Path to Config B (candidate CLAUDE.md)', default: './CLAUDE.md' },
|
|
543
415
|
{ name: 'tasks', short: 't', type: 'string', description: 'Path to custom task JSON file (array of ABTask objects)' },
|
|
544
416
|
{ name: 'work-dir', short: 'w', type: 'string', description: 'Working directory for test execution' },
|
|
545
|
-
{ name: 'json', type: 'boolean', description: 'Output as JSON',
|
|
417
|
+
{ name: 'json', type: 'boolean', description: 'Output as JSON', default: 'false' },
|
|
546
418
|
],
|
|
547
419
|
examples: [
|
|
548
420
|
{ command: 'claude-flow guidance ab-test', description: 'Run default A/B test (no guidance vs ./CLAUDE.md)' },
|
|
@@ -550,120 +422,103 @@ var abTestCommand = {
|
|
|
550
422
|
{ command: 'claude-flow guidance ab-test --tasks custom-tasks.json', description: 'Run with custom test tasks' },
|
|
551
423
|
{ command: 'claude-flow guidance ab-test --json', description: 'Output full report as JSON' },
|
|
552
424
|
],
|
|
553
|
-
action:
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
output.writeln(output.warning("No significant difference (" + delta + " composite delta)"));
|
|
650
|
-
}
|
|
651
|
-
if (report.categoryShift) {
|
|
652
|
-
output.writeln(output.success('Category shift detected: 3+ task classes improved by 20%+'));
|
|
653
|
-
}
|
|
654
|
-
return [2 /*return*/, { success: true, data: report }];
|
|
655
|
-
case 9:
|
|
656
|
-
error_6 = _b.sent();
|
|
657
|
-
msg = error_6 instanceof Error ? error_6.message : String(error_6);
|
|
658
|
-
output.writeln(output.error("A/B benchmark failed: " + msg));
|
|
659
|
-
return [2 /*return*/, { success: false, message: msg }];
|
|
660
|
-
case 10: return [2 /*return*/];
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
}); }
|
|
425
|
+
action: async (ctx) => {
|
|
426
|
+
const configAPath = ctx.flags['config-a'];
|
|
427
|
+
const configBPath = ctx.flags['config-b'] || './CLAUDE.md';
|
|
428
|
+
const tasksPath = ctx.flags.tasks;
|
|
429
|
+
const workDir = ctx.flags['work-dir'];
|
|
430
|
+
const jsonOutput = ctx.flags.json === true;
|
|
431
|
+
output.writeln();
|
|
432
|
+
output.writeln(output.bold('A/B Behavioral Benchmark'));
|
|
433
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
434
|
+
try {
|
|
435
|
+
const { readFile } = await import('node:fs/promises');
|
|
436
|
+
const { existsSync } = await import('node:fs');
|
|
437
|
+
const { abBenchmark, getDefaultABTasks } = await import('@claude-flow/guidance/analyzer');
|
|
438
|
+
// Load Config B (candidate) content
|
|
439
|
+
if (!existsSync(configBPath)) {
|
|
440
|
+
output.writeln(output.error(`Config B file not found: ${configBPath}`));
|
|
441
|
+
return { success: false, message: `File not found: ${configBPath}` };
|
|
442
|
+
}
|
|
443
|
+
const configBContent = await readFile(configBPath, 'utf-8');
|
|
444
|
+
// Optionally load Config A for display context
|
|
445
|
+
let configALabel = 'No control plane (baseline)';
|
|
446
|
+
if (configAPath) {
|
|
447
|
+
if (!existsSync(configAPath)) {
|
|
448
|
+
output.writeln(output.error(`Config A file not found: ${configAPath}`));
|
|
449
|
+
return { success: false, message: `File not found: ${configAPath}` };
|
|
450
|
+
}
|
|
451
|
+
configALabel = configAPath;
|
|
452
|
+
}
|
|
453
|
+
// Load custom tasks if provided
|
|
454
|
+
let customTasks;
|
|
455
|
+
if (tasksPath) {
|
|
456
|
+
if (!existsSync(tasksPath)) {
|
|
457
|
+
output.writeln(output.error(`Tasks file not found: ${tasksPath}`));
|
|
458
|
+
return { success: false, message: `File not found: ${tasksPath}` };
|
|
459
|
+
}
|
|
460
|
+
const tasksJson = await readFile(tasksPath, 'utf-8');
|
|
461
|
+
customTasks = JSON.parse(tasksJson);
|
|
462
|
+
output.writeln(` Custom tasks: ${output.bold(String(customTasks.length))} loaded from ${tasksPath}`);
|
|
463
|
+
}
|
|
464
|
+
output.writeln(` Config A: ${output.dim(configALabel)}`);
|
|
465
|
+
output.writeln(` Config B: ${output.dim(configBPath)}`);
|
|
466
|
+
output.writeln(` Tasks: ${output.dim(customTasks ? `${customTasks.length} custom` : `${getDefaultABTasks().length} default`)}`);
|
|
467
|
+
output.writeln();
|
|
468
|
+
output.writeln(output.dim('Running benchmark...'));
|
|
469
|
+
// Run the A/B benchmark
|
|
470
|
+
const report = await abBenchmark(configBContent, {
|
|
471
|
+
tasks: customTasks,
|
|
472
|
+
workDir,
|
|
473
|
+
});
|
|
474
|
+
if (jsonOutput) {
|
|
475
|
+
output.writeln(JSON.stringify({
|
|
476
|
+
configA: { label: configALabel, metrics: report.configA.metrics },
|
|
477
|
+
configB: { label: configBPath, metrics: report.configB.metrics },
|
|
478
|
+
compositeDelta: report.compositeDelta,
|
|
479
|
+
classDeltas: report.classDeltas,
|
|
480
|
+
categoryShift: report.categoryShift,
|
|
481
|
+
taskResults: {
|
|
482
|
+
configA: report.configA.taskResults.map(r => ({
|
|
483
|
+
taskId: r.taskId, taskClass: r.taskClass, passed: r.passed,
|
|
484
|
+
violations: r.violations.length, toolCalls: r.toolCalls,
|
|
485
|
+
})),
|
|
486
|
+
configB: report.configB.taskResults.map(r => ({
|
|
487
|
+
taskId: r.taskId, taskClass: r.taskClass, passed: r.passed,
|
|
488
|
+
violations: r.violations.length, toolCalls: r.toolCalls,
|
|
489
|
+
})),
|
|
490
|
+
},
|
|
491
|
+
}, null, 2));
|
|
492
|
+
return { success: true, data: report };
|
|
493
|
+
}
|
|
494
|
+
// Print formatted report
|
|
495
|
+
output.writeln(report.report);
|
|
496
|
+
output.writeln();
|
|
497
|
+
// Summary verdict
|
|
498
|
+
const delta = report.compositeDelta;
|
|
499
|
+
if (delta > 0.05) {
|
|
500
|
+
output.writeln(output.success(`Config B is better (+${delta} composite delta)`));
|
|
501
|
+
}
|
|
502
|
+
else if (delta < -0.05) {
|
|
503
|
+
output.writeln(output.error(`Config B is worse (${delta} composite delta)`));
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
output.writeln(output.warning(`No significant difference (${delta} composite delta)`));
|
|
507
|
+
}
|
|
508
|
+
if (report.categoryShift) {
|
|
509
|
+
output.writeln(output.success('Category shift detected: 3+ task classes improved by 20%+'));
|
|
510
|
+
}
|
|
511
|
+
return { success: true, data: report };
|
|
512
|
+
}
|
|
513
|
+
catch (error) {
|
|
514
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
515
|
+
output.writeln(output.error(`A/B benchmark failed: ${msg}`));
|
|
516
|
+
return { success: false, message: msg };
|
|
517
|
+
}
|
|
518
|
+
},
|
|
664
519
|
};
|
|
665
520
|
// Main guidance command
|
|
666
|
-
export
|
|
521
|
+
export const guidanceCommand = {
|
|
667
522
|
name: 'guidance',
|
|
668
523
|
description: 'Guidance Control Plane - compile, retrieve, enforce, and optimize guidance rules',
|
|
669
524
|
aliases: ['guide', 'policy'],
|
|
@@ -684,24 +539,22 @@ export var guidanceCommand = {
|
|
|
684
539
|
{ command: 'claude-flow guidance optimize', description: 'Analyze and optimize CLAUDE.md' },
|
|
685
540
|
{ command: 'claude-flow guidance ab-test', description: 'Run A/B behavioral comparison' },
|
|
686
541
|
],
|
|
687
|
-
action:
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
});
|
|
704
|
-
}); }
|
|
542
|
+
action: async (ctx) => {
|
|
543
|
+
output.writeln();
|
|
544
|
+
output.writeln(output.bold('Guidance Control Plane'));
|
|
545
|
+
output.writeln(output.dim('─'.repeat(50)));
|
|
546
|
+
output.writeln();
|
|
547
|
+
output.writeln('Available subcommands:');
|
|
548
|
+
output.writeln(` ${output.bold('compile')} Compile CLAUDE.md into policy bundle`);
|
|
549
|
+
output.writeln(` ${output.bold('retrieve')} Retrieve task-relevant guidance shards`);
|
|
550
|
+
output.writeln(` ${output.bold('gates')} Evaluate enforcement gates`);
|
|
551
|
+
output.writeln(` ${output.bold('status')} Show control plane status`);
|
|
552
|
+
output.writeln(` ${output.bold('optimize')} Analyze and optimize CLAUDE.md`);
|
|
553
|
+
output.writeln(` ${output.bold('ab-test')} Run A/B behavioral comparison`);
|
|
554
|
+
output.writeln();
|
|
555
|
+
output.writeln(output.dim('Use claude-flow guidance <subcommand> --help for details'));
|
|
556
|
+
return { success: true };
|
|
557
|
+
},
|
|
705
558
|
};
|
|
706
559
|
export default guidanceCommand;
|
|
707
560
|
//# sourceMappingURL=guidance.js.map
|