@claude-flow/cli 3.21.0 → 3.22.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/helpers/auto-memory-hook.mjs +35 -3
- package/.claude/helpers/helpers.manifest.json +12 -0
- package/.claude/helpers/hook-handler.cjs +26 -5
- package/.claude/helpers/intelligence.cjs +4 -1
- package/dist/src/commands/daemon.js +23 -2
- package/dist/src/commands/doctor.js +56 -0
- package/dist/src/commands/memory-distill.d.ts +27 -0
- package/dist/src/commands/memory-distill.js +374 -0
- package/dist/src/commands/memory.js +4 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +22 -1
- package/dist/src/init/executor.js +37 -0
- package/dist/src/init/helper-refresh.d.ts +19 -0
- package/dist/src/init/helper-refresh.js +175 -0
- package/dist/src/init/helper-signing.d.ts +30 -0
- package/dist/src/init/helper-signing.js +60 -0
- package/dist/src/init/helpers-generator.d.ts +16 -0
- package/dist/src/init/helpers-generator.js +89 -8
- package/dist/src/init/memory-package-resolver.d.ts +53 -0
- package/dist/src/init/memory-package-resolver.js +118 -0
- package/dist/src/init/statusline-generator.js +18 -7
- package/dist/src/mcp-client.js +13 -0
- package/dist/src/mcp-tools/agenticow-speculate-tools.js +9 -2
- package/dist/src/mcp-tools/browser-intent-tools.d.ts +162 -0
- package/dist/src/mcp-tools/browser-intent-tools.js +548 -0
- package/dist/src/mcp-tools/browser-tools.d.ts +9 -1
- package/dist/src/mcp-tools/browser-tools.js +4 -1
- package/dist/src/memory/memory-bridge.js +115 -54
- package/dist/src/memory/memory-initializer.d.ts +71 -0
- package/dist/src/memory/memory-initializer.js +330 -2
- package/dist/src/services/distill-tuning.d.ts +111 -0
- package/dist/src/services/distill-tuning.js +510 -0
- package/dist/src/services/memory-distillation.d.ts +41 -0
- package/dist/src/services/memory-distillation.js +277 -0
- package/dist/src/services/worker-daemon.d.ts +22 -1
- package/dist/src/services/worker-daemon.js +117 -6
- package/package.json +5 -2
- package/dist/src/agenticow/speculative-exploration.d.ts.map +0 -1
- package/dist/src/agenticow/speculative-exploration.js.map +0 -1
- package/dist/src/appliance/gguf-engine.d.ts.map +0 -1
- package/dist/src/appliance/gguf-engine.js.map +0 -1
- package/dist/src/appliance/ruvllm-bridge.d.ts.map +0 -1
- package/dist/src/appliance/ruvllm-bridge.js.map +0 -1
- package/dist/src/appliance/rvfa-builder.d.ts.map +0 -1
- package/dist/src/appliance/rvfa-builder.js.map +0 -1
- package/dist/src/appliance/rvfa-distribution.d.ts.map +0 -1
- package/dist/src/appliance/rvfa-distribution.js.map +0 -1
- package/dist/src/appliance/rvfa-format.d.ts.map +0 -1
- package/dist/src/appliance/rvfa-format.js.map +0 -1
- package/dist/src/appliance/rvfa-runner.d.ts.map +0 -1
- package/dist/src/appliance/rvfa-runner.js.map +0 -1
- package/dist/src/appliance/rvfa-signing.d.ts.map +0 -1
- package/dist/src/appliance/rvfa-signing.js.map +0 -1
- package/dist/src/autopilot-state.d.ts.map +0 -1
- package/dist/src/autopilot-state.js.map +0 -1
- package/dist/src/benchmarks/gaia-agent-planning.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-agent-planning.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-agent.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-agent.js.map +0 -1
- package/dist/src/benchmarks/gaia-causal-memory.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-causal-memory.js.map +0 -1
- package/dist/src/benchmarks/gaia-causal-memory.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-causal-memory.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-convergence.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-convergence.js.map +0 -1
- package/dist/src/benchmarks/gaia-convergence.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-convergence.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-critic.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-critic.js.map +0 -1
- package/dist/src/benchmarks/gaia-critic.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-critic.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-decomposer.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-decomposer.js.map +0 -1
- package/dist/src/benchmarks/gaia-decomposer.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-decomposer.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-e2e-smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-e2e-smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-extract.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-extract.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/features.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/features.js.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/predictor.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/predictor.js.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/predictor.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/predictor.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/train-data-loader.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-hardness/train-data-loader.js.map +0 -1
- package/dist/src/benchmarks/gaia-judge.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-judge.js.map +0 -1
- package/dist/src/benchmarks/gaia-loader.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-loader.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/file_read.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/file_read.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/grounded_query.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/grounded_query.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/index.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/index.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/types.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/types.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_search.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_search.js.map +0 -1
- package/dist/src/benchmarks/gaia-voting.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-voting.js.map +0 -1
- package/dist/src/benchmarks/gaia-voting.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-voting.smoke.js.map +0 -1
- package/dist/src/benchmarks/pretrain/index.d.ts.map +0 -1
- package/dist/src/benchmarks/pretrain/index.js.map +0 -1
- package/dist/src/business-pods/bbs-budget-tracker.d.ts.map +0 -1
- package/dist/src/business-pods/bbs-budget-tracker.js.map +0 -1
- package/dist/src/business-pods/domain-affinity-policy.d.ts.map +0 -1
- package/dist/src/business-pods/domain-affinity-policy.js.map +0 -1
- package/dist/src/business-pods/pod-schema.d.ts.map +0 -1
- package/dist/src/business-pods/pod-schema.js.map +0 -1
- package/dist/src/commands/agent-wasm.d.ts.map +0 -1
- package/dist/src/commands/agent-wasm.js.map +0 -1
- package/dist/src/commands/agent.d.ts.map +0 -1
- package/dist/src/commands/agent.js.map +0 -1
- package/dist/src/commands/analyze.d.ts.map +0 -1
- package/dist/src/commands/analyze.js.map +0 -1
- package/dist/src/commands/appliance-advanced.d.ts.map +0 -1
- package/dist/src/commands/appliance-advanced.js.map +0 -1
- package/dist/src/commands/appliance.d.ts.map +0 -1
- package/dist/src/commands/appliance.js.map +0 -1
- package/dist/src/commands/autopilot.d.ts.map +0 -1
- package/dist/src/commands/autopilot.js.map +0 -1
- package/dist/src/commands/benchmark.d.ts.map +0 -1
- package/dist/src/commands/benchmark.js.map +0 -1
- package/dist/src/commands/claims.d.ts.map +0 -1
- package/dist/src/commands/claims.js.map +0 -1
- package/dist/src/commands/cleanup.d.ts.map +0 -1
- package/dist/src/commands/cleanup.js.map +0 -1
- package/dist/src/commands/completions.d.ts.map +0 -1
- package/dist/src/commands/completions.js.map +0 -1
- package/dist/src/commands/config.d.ts.map +0 -1
- package/dist/src/commands/config.js.map +0 -1
- package/dist/src/commands/daemon.d.ts.map +0 -1
- package/dist/src/commands/daemon.js.map +0 -1
- package/dist/src/commands/deployment.d.ts.map +0 -1
- package/dist/src/commands/deployment.js.map +0 -1
- package/dist/src/commands/doctor.d.ts.map +0 -1
- package/dist/src/commands/doctor.js.map +0 -1
- package/dist/src/commands/eject.d.ts.map +0 -1
- package/dist/src/commands/eject.js.map +0 -1
- package/dist/src/commands/embeddings.d.ts.map +0 -1
- package/dist/src/commands/embeddings.js.map +0 -1
- package/dist/src/commands/gaia-bench.d.ts.map +0 -1
- package/dist/src/commands/gaia-bench.js.map +0 -1
- package/dist/src/commands/guidance.d.ts.map +0 -1
- package/dist/src/commands/guidance.js.map +0 -1
- package/dist/src/commands/hive-mind.d.ts.map +0 -1
- package/dist/src/commands/hive-mind.js.map +0 -1
- package/dist/src/commands/hooks.d.ts.map +0 -1
- package/dist/src/commands/hooks.js.map +0 -1
- package/dist/src/commands/index.d.ts.map +0 -1
- package/dist/src/commands/index.js.map +0 -1
- package/dist/src/commands/init.d.ts.map +0 -1
- package/dist/src/commands/init.js.map +0 -1
- package/dist/src/commands/issues.d.ts.map +0 -1
- package/dist/src/commands/issues.js.map +0 -1
- package/dist/src/commands/mcp.d.ts.map +0 -1
- package/dist/src/commands/mcp.js.map +0 -1
- package/dist/src/commands/memory.d.ts.map +0 -1
- package/dist/src/commands/memory.js.map +0 -1
- package/dist/src/commands/metaharness.d.ts.map +0 -1
- package/dist/src/commands/metaharness.js.map +0 -1
- package/dist/src/commands/migrate.d.ts.map +0 -1
- package/dist/src/commands/migrate.js.map +0 -1
- package/dist/src/commands/neural.d.ts.map +0 -1
- package/dist/src/commands/neural.js.map +0 -1
- package/dist/src/commands/performance.d.ts.map +0 -1
- package/dist/src/commands/performance.js.map +0 -1
- package/dist/src/commands/plugins.d.ts.map +0 -1
- package/dist/src/commands/plugins.js.map +0 -1
- package/dist/src/commands/process.d.ts.map +0 -1
- package/dist/src/commands/process.js.map +0 -1
- package/dist/src/commands/progress.d.ts.map +0 -1
- package/dist/src/commands/progress.js.map +0 -1
- package/dist/src/commands/providers.d.ts.map +0 -1
- package/dist/src/commands/providers.js.map +0 -1
- package/dist/src/commands/route.d.ts.map +0 -1
- package/dist/src/commands/route.js.map +0 -1
- package/dist/src/commands/ruvector/backup.d.ts.map +0 -1
- package/dist/src/commands/ruvector/backup.js.map +0 -1
- package/dist/src/commands/ruvector/benchmark.d.ts.map +0 -1
- package/dist/src/commands/ruvector/benchmark.js.map +0 -1
- package/dist/src/commands/ruvector/import.d.ts.map +0 -1
- package/dist/src/commands/ruvector/import.js.map +0 -1
- package/dist/src/commands/ruvector/index.d.ts.map +0 -1
- package/dist/src/commands/ruvector/index.js.map +0 -1
- package/dist/src/commands/ruvector/init.d.ts.map +0 -1
- package/dist/src/commands/ruvector/init.js.map +0 -1
- package/dist/src/commands/ruvector/migrate.d.ts.map +0 -1
- package/dist/src/commands/ruvector/migrate.js.map +0 -1
- package/dist/src/commands/ruvector/optimize.d.ts.map +0 -1
- package/dist/src/commands/ruvector/optimize.js.map +0 -1
- package/dist/src/commands/ruvector/pg-utils.d.ts.map +0 -1
- package/dist/src/commands/ruvector/pg-utils.js.map +0 -1
- package/dist/src/commands/ruvector/setup.d.ts.map +0 -1
- package/dist/src/commands/ruvector/setup.js.map +0 -1
- package/dist/src/commands/ruvector/status.d.ts.map +0 -1
- package/dist/src/commands/ruvector/status.js.map +0 -1
- package/dist/src/commands/security.d.ts.map +0 -1
- package/dist/src/commands/security.js.map +0 -1
- package/dist/src/commands/session.d.ts.map +0 -1
- package/dist/src/commands/session.js.map +0 -1
- package/dist/src/commands/start.d.ts.map +0 -1
- package/dist/src/commands/start.js.map +0 -1
- package/dist/src/commands/status.d.ts.map +0 -1
- package/dist/src/commands/status.js.map +0 -1
- package/dist/src/commands/swarm.d.ts.map +0 -1
- package/dist/src/commands/swarm.js.map +0 -1
- package/dist/src/commands/task.d.ts.map +0 -1
- package/dist/src/commands/task.js.map +0 -1
- package/dist/src/commands/transfer-store.d.ts.map +0 -1
- package/dist/src/commands/transfer-store.js.map +0 -1
- package/dist/src/commands/update.d.ts.map +0 -1
- package/dist/src/commands/update.js.map +0 -1
- package/dist/src/commands/verify.d.ts.map +0 -1
- package/dist/src/commands/verify.js.map +0 -1
- package/dist/src/commands/workflow.d.ts.map +0 -1
- package/dist/src/commands/workflow.js.map +0 -1
- package/dist/src/config-adapter.d.ts.map +0 -1
- package/dist/src/config-adapter.js.map +0 -1
- package/dist/src/encryption/vault.d.ts.map +0 -1
- package/dist/src/encryption/vault.js.map +0 -1
- package/dist/src/fs-secure.d.ts.map +0 -1
- package/dist/src/fs-secure.js.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +0 -1
- package/dist/src/infrastructure/in-memory-repositories.js.map +0 -1
- package/dist/src/init/claudemd-generator.d.ts.map +0 -1
- package/dist/src/init/claudemd-generator.js.map +0 -1
- package/dist/src/init/executor.d.ts.map +0 -1
- package/dist/src/init/executor.js.map +0 -1
- package/dist/src/init/helpers-generator.d.ts.map +0 -1
- package/dist/src/init/helpers-generator.js.map +0 -1
- package/dist/src/init/index.d.ts.map +0 -1
- package/dist/src/init/index.js.map +0 -1
- package/dist/src/init/mcp-generator.d.ts.map +0 -1
- package/dist/src/init/mcp-generator.js.map +0 -1
- package/dist/src/init/settings-generator.d.ts.map +0 -1
- package/dist/src/init/settings-generator.js.map +0 -1
- package/dist/src/init/statusline-generator.d.ts.map +0 -1
- package/dist/src/init/statusline-generator.js.map +0 -1
- package/dist/src/init/types.d.ts.map +0 -1
- package/dist/src/init/types.js.map +0 -1
- package/dist/src/log-filters.d.ts.map +0 -1
- package/dist/src/log-filters.js.map +0 -1
- package/dist/src/mcp-client.d.ts.map +0 -1
- package/dist/src/mcp-client.js.map +0 -1
- package/dist/src/mcp-server.d.ts.map +0 -1
- package/dist/src/mcp-server.js.map +0 -1
- package/dist/src/mcp-tools/agent-execute-core.d.ts.map +0 -1
- package/dist/src/mcp-tools/agent-execute-core.js.map +0 -1
- package/dist/src/mcp-tools/agent-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/agent-tools.js.map +0 -1
- package/dist/src/mcp-tools/agentbbs-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/agentbbs-tools.js.map +0 -1
- package/dist/src/mcp-tools/agentdb-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/agentdb-tools.js.map +0 -1
- package/dist/src/mcp-tools/agenticow-loader.d.ts.map +0 -1
- package/dist/src/mcp-tools/agenticow-loader.js.map +0 -1
- package/dist/src/mcp-tools/agenticow-speculate-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/agenticow-speculate-tools.js.map +0 -1
- package/dist/src/mcp-tools/agenticow-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/agenticow-tools.js.map +0 -1
- package/dist/src/mcp-tools/analyze-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/analyze-tools.js.map +0 -1
- package/dist/src/mcp-tools/auto-install.d.ts.map +0 -1
- package/dist/src/mcp-tools/auto-install.js.map +0 -1
- package/dist/src/mcp-tools/autopilot-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/autopilot-tools.js.map +0 -1
- package/dist/src/mcp-tools/browser-session-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/browser-session-tools.js.map +0 -1
- package/dist/src/mcp-tools/browser-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/browser-tools.js.map +0 -1
- package/dist/src/mcp-tools/business-pod-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/business-pod-tools.js.map +0 -1
- package/dist/src/mcp-tools/claims-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/claims-tools.js.map +0 -1
- package/dist/src/mcp-tools/config-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/config-tools.js.map +0 -1
- package/dist/src/mcp-tools/coordination-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/coordination-tools.js.map +0 -1
- package/dist/src/mcp-tools/daa-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/daa-tools.js.map +0 -1
- package/dist/src/mcp-tools/embeddings-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/embeddings-tools.js.map +0 -1
- package/dist/src/mcp-tools/github-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/github-tools.js.map +0 -1
- package/dist/src/mcp-tools/guidance-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/guidance-tools.js.map +0 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/hive-mind-tools.js.map +0 -1
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/hooks-tools.js.map +0 -1
- package/dist/src/mcp-tools/http-fetch-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/http-fetch-tools.js.map +0 -1
- package/dist/src/mcp-tools/index.d.ts.map +0 -1
- package/dist/src/mcp-tools/index.js.map +0 -1
- package/dist/src/mcp-tools/managed-agent-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/managed-agent-tools.js.map +0 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/memory-tools.js.map +0 -1
- package/dist/src/mcp-tools/metaharness-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/metaharness-tools.js.map +0 -1
- package/dist/src/mcp-tools/neural-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/neural-tools.js.map +0 -1
- package/dist/src/mcp-tools/performance-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/performance-tools.js.map +0 -1
- package/dist/src/mcp-tools/progress-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/progress-tools.js.map +0 -1
- package/dist/src/mcp-tools/request-tracker.d.ts.map +0 -1
- package/dist/src/mcp-tools/request-tracker.js.map +0 -1
- package/dist/src/mcp-tools/ruvllm-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/ruvllm-tools.js.map +0 -1
- package/dist/src/mcp-tools/security-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/security-tools.js.map +0 -1
- package/dist/src/mcp-tools/session-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/session-tools.js.map +0 -1
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/swarm-tools.js.map +0 -1
- package/dist/src/mcp-tools/system-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/system-tools.js.map +0 -1
- package/dist/src/mcp-tools/task-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/task-tools.js.map +0 -1
- package/dist/src/mcp-tools/terminal-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/terminal-tools.js.map +0 -1
- package/dist/src/mcp-tools/testgen-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/testgen-tools.js.map +0 -1
- package/dist/src/mcp-tools/tool-loop-guardrail.d.ts.map +0 -1
- package/dist/src/mcp-tools/tool-loop-guardrail.js.map +0 -1
- package/dist/src/mcp-tools/transfer-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/transfer-tools.js.map +0 -1
- package/dist/src/mcp-tools/types.d.ts.map +0 -1
- package/dist/src/mcp-tools/types.js.map +0 -1
- package/dist/src/mcp-tools/validate-input.d.ts.map +0 -1
- package/dist/src/mcp-tools/validate-input.js.map +0 -1
- package/dist/src/mcp-tools/wasm-agent-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +0 -1
- package/dist/src/mcp-tools/workflow-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/workflow-tools.js.map +0 -1
- package/dist/src/memory/bge-embedder.d.ts.map +0 -1
- package/dist/src/memory/bge-embedder.js.map +0 -1
- package/dist/src/memory/cross-encoder-rerank.d.ts.map +0 -1
- package/dist/src/memory/cross-encoder-rerank.js.map +0 -1
- package/dist/src/memory/embedding-quantization.d.ts.map +0 -1
- package/dist/src/memory/embedding-quantization.js.map +0 -1
- package/dist/src/memory/ewc-consolidation.d.ts.map +0 -1
- package/dist/src/memory/ewc-consolidation.js.map +0 -1
- package/dist/src/memory/graph-edge-writer.d.ts.map +0 -1
- package/dist/src/memory/graph-edge-writer.js.map +0 -1
- package/dist/src/memory/hybrid-retrieval.d.ts.map +0 -1
- package/dist/src/memory/hybrid-retrieval.js.map +0 -1
- package/dist/src/memory/intelligence.d.ts.map +0 -1
- package/dist/src/memory/intelligence.js.map +0 -1
- package/dist/src/memory/lucene-bm25.d.ts.map +0 -1
- package/dist/src/memory/lucene-bm25.js.map +0 -1
- package/dist/src/memory/memory-bridge.d.ts.map +0 -1
- package/dist/src/memory/memory-bridge.js.map +0 -1
- package/dist/src/memory/memory-initializer.d.ts.map +0 -1
- package/dist/src/memory/memory-initializer.js.map +0 -1
- package/dist/src/memory/neural-package-bridge.d.ts.map +0 -1
- package/dist/src/memory/neural-package-bridge.js.map +0 -1
- package/dist/src/memory/rabitq-index.d.ts.map +0 -1
- package/dist/src/memory/rabitq-index.js.map +0 -1
- package/dist/src/memory/sona-optimizer.d.ts.map +0 -1
- package/dist/src/memory/sona-optimizer.js.map +0 -1
- package/dist/src/memory/structured-distill.d.ts.map +0 -1
- package/dist/src/memory/structured-distill.js.map +0 -1
- package/dist/src/output.d.ts.map +0 -1
- package/dist/src/output.js.map +0 -1
- package/dist/src/parser.d.ts.map +0 -1
- package/dist/src/parser.js.map +0 -1
- package/dist/src/plugins/manager.d.ts.map +0 -1
- package/dist/src/plugins/manager.js.map +0 -1
- package/dist/src/plugins/store/discovery.d.ts.map +0 -1
- package/dist/src/plugins/store/discovery.js.map +0 -1
- package/dist/src/plugins/store/index.d.ts.map +0 -1
- package/dist/src/plugins/store/index.js.map +0 -1
- package/dist/src/plugins/store/search.d.ts.map +0 -1
- package/dist/src/plugins/store/search.js.map +0 -1
- package/dist/src/plugins/store/types.d.ts.map +0 -1
- package/dist/src/plugins/store/types.js.map +0 -1
- package/dist/src/plugins/tests/demo-plugin-store.d.ts.map +0 -1
- package/dist/src/plugins/tests/demo-plugin-store.js.map +0 -1
- package/dist/src/plugins/tests/standalone-test.d.ts.map +0 -1
- package/dist/src/plugins/tests/standalone-test.js.map +0 -1
- package/dist/src/plugins/tests/test-plugin-store.d.ts.map +0 -1
- package/dist/src/plugins/tests/test-plugin-store.js.map +0 -1
- package/dist/src/production/circuit-breaker.d.ts.map +0 -1
- package/dist/src/production/circuit-breaker.js.map +0 -1
- package/dist/src/production/error-handler.d.ts.map +0 -1
- package/dist/src/production/error-handler.js.map +0 -1
- package/dist/src/production/index.d.ts.map +0 -1
- package/dist/src/production/index.js.map +0 -1
- package/dist/src/production/monitoring.d.ts.map +0 -1
- package/dist/src/production/monitoring.js.map +0 -1
- package/dist/src/production/rate-limiter.d.ts.map +0 -1
- package/dist/src/production/rate-limiter.js.map +0 -1
- package/dist/src/production/retry.d.ts.map +0 -1
- package/dist/src/production/retry.js.map +0 -1
- package/dist/src/prompt.d.ts.map +0 -1
- package/dist/src/prompt.js.map +0 -1
- package/dist/src/runtime/headless.d.ts.map +0 -1
- package/dist/src/runtime/headless.js.map +0 -1
- package/dist/src/runtime/parent-death-watchdog.d.ts.map +0 -1
- package/dist/src/runtime/parent-death-watchdog.js.map +0 -1
- package/dist/src/ruvector/agent-wasm.d.ts.map +0 -1
- package/dist/src/ruvector/agent-wasm.js.map +0 -1
- package/dist/src/ruvector/ast-analyzer.d.ts.map +0 -1
- package/dist/src/ruvector/ast-analyzer.js.map +0 -1
- package/dist/src/ruvector/codemods/engine.d.ts.map +0 -1
- package/dist/src/ruvector/codemods/engine.js.map +0 -1
- package/dist/src/ruvector/codemods/scope-analysis.d.ts.map +0 -1
- package/dist/src/ruvector/codemods/scope-analysis.js.map +0 -1
- package/dist/src/ruvector/coverage-router.d.ts.map +0 -1
- package/dist/src/ruvector/coverage-router.js.map +0 -1
- package/dist/src/ruvector/coverage-tools.d.ts.map +0 -1
- package/dist/src/ruvector/coverage-tools.js.map +0 -1
- package/dist/src/ruvector/diff-classifier.d.ts.map +0 -1
- package/dist/src/ruvector/diff-classifier.js.map +0 -1
- package/dist/src/ruvector/diskann-backend.d.ts.map +0 -1
- package/dist/src/ruvector/diskann-backend.js.map +0 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +0 -1
- package/dist/src/ruvector/enhanced-model-router.js.map +0 -1
- package/dist/src/ruvector/graph-analyzer.d.ts.map +0 -1
- package/dist/src/ruvector/graph-analyzer.js.map +0 -1
- package/dist/src/ruvector/graph-backend.d.ts.map +0 -1
- package/dist/src/ruvector/graph-backend.js.map +0 -1
- package/dist/src/ruvector/index.d.ts.map +0 -1
- package/dist/src/ruvector/index.js.map +0 -1
- package/dist/src/ruvector/lora-adapter.d.ts.map +0 -1
- package/dist/src/ruvector/lora-adapter.js.map +0 -1
- package/dist/src/ruvector/model-prices.d.ts.map +0 -1
- package/dist/src/ruvector/model-prices.js.map +0 -1
- package/dist/src/ruvector/model-router.d.ts.map +0 -1
- package/dist/src/ruvector/model-router.js.map +0 -1
- package/dist/src/ruvector/neural-router.d.ts.map +0 -1
- package/dist/src/ruvector/neural-router.js.map +0 -1
- package/dist/src/ruvector/output-verifier.d.ts.map +0 -1
- package/dist/src/ruvector/output-verifier.js.map +0 -1
- package/dist/src/ruvector/q-learning-router.d.ts.map +0 -1
- package/dist/src/ruvector/q-learning-router.js.map +0 -1
- package/dist/src/ruvector/router-calibrator.d.ts.map +0 -1
- package/dist/src/ruvector/router-calibrator.js.map +0 -1
- package/dist/src/ruvector/router-parallel-recorder.d.ts.map +0 -1
- package/dist/src/ruvector/router-parallel-recorder.js.map +0 -1
- package/dist/src/ruvector/router-trajectory.d.ts.map +0 -1
- package/dist/src/ruvector/router-trajectory.js.map +0 -1
- package/dist/src/ruvector/run-transcript-recorder.d.ts.map +0 -1
- package/dist/src/ruvector/run-transcript-recorder.js.map +0 -1
- package/dist/src/ruvector/ruvllm-wasm.d.ts.map +0 -1
- package/dist/src/ruvector/ruvllm-wasm.js.map +0 -1
- package/dist/src/ruvector/semantic-router.d.ts.map +0 -1
- package/dist/src/ruvector/semantic-router.js.map +0 -1
- package/dist/src/ruvector/task-embedder.d.ts.map +0 -1
- package/dist/src/ruvector/task-embedder.js.map +0 -1
- package/dist/src/ruvector/trajectory-tree.d.ts.map +0 -1
- package/dist/src/ruvector/trajectory-tree.js.map +0 -1
- package/dist/src/ruvector/vector-db.d.ts.map +0 -1
- package/dist/src/ruvector/vector-db.js.map +0 -1
- package/dist/src/services/agentic-flow-bridge.d.ts.map +0 -1
- package/dist/src/services/agentic-flow-bridge.js.map +0 -1
- package/dist/src/services/checkpoint-gate.d.ts.map +0 -1
- package/dist/src/services/checkpoint-gate.js.map +0 -1
- package/dist/src/services/claim-service.d.ts.map +0 -1
- package/dist/src/services/claim-service.js.map +0 -1
- package/dist/src/services/config-file-manager.d.ts.map +0 -1
- package/dist/src/services/config-file-manager.js.map +0 -1
- package/dist/src/services/container-worker-pool.d.ts.map +0 -1
- package/dist/src/services/container-worker-pool.js.map +0 -1
- package/dist/src/services/distill-oracle.d.ts.map +0 -1
- package/dist/src/services/distill-oracle.js.map +0 -1
- package/dist/src/services/fable-harness.d.ts.map +0 -1
- package/dist/src/services/fable-harness.js.map +0 -1
- package/dist/src/services/headless-worker-executor.d.ts.map +0 -1
- package/dist/src/services/headless-worker-executor.js.map +0 -1
- package/dist/src/services/index.d.ts.map +0 -1
- package/dist/src/services/index.js.map +0 -1
- package/dist/src/services/native-training.d.ts.map +0 -1
- package/dist/src/services/native-training.js.map +0 -1
- package/dist/src/services/registry-api.d.ts.map +0 -1
- package/dist/src/services/registry-api.js.map +0 -1
- package/dist/src/services/ruvector-training.d.ts.map +0 -1
- package/dist/src/services/ruvector-training.js.map +0 -1
- package/dist/src/services/swarm-memory-branches.d.ts.map +0 -1
- package/dist/src/services/swarm-memory-branches.js.map +0 -1
- package/dist/src/services/weight-eft.d.ts.map +0 -1
- package/dist/src/services/weight-eft.js.map +0 -1
- package/dist/src/services/worker-daemon.d.ts.map +0 -1
- package/dist/src/services/worker-daemon.js.map +0 -1
- package/dist/src/services/worker-queue.d.ts.map +0 -1
- package/dist/src/services/worker-queue.js.map +0 -1
- package/dist/src/suggest.d.ts.map +0 -1
- package/dist/src/suggest.js.map +0 -1
- package/dist/src/transfer/anonymization/index.d.ts.map +0 -1
- package/dist/src/transfer/anonymization/index.js.map +0 -1
- package/dist/src/transfer/deploy-seraphine.d.ts.map +0 -1
- package/dist/src/transfer/deploy-seraphine.js.map +0 -1
- package/dist/src/transfer/export.d.ts.map +0 -1
- package/dist/src/transfer/export.js.map +0 -1
- package/dist/src/transfer/index.d.ts.map +0 -1
- package/dist/src/transfer/index.js.map +0 -1
- package/dist/src/transfer/ipfs/client.d.ts.map +0 -1
- package/dist/src/transfer/ipfs/client.js.map +0 -1
- package/dist/src/transfer/ipfs/upload.d.ts.map +0 -1
- package/dist/src/transfer/ipfs/upload.js.map +0 -1
- package/dist/src/transfer/models/seraphine.d.ts.map +0 -1
- package/dist/src/transfer/models/seraphine.js.map +0 -1
- package/dist/src/transfer/serialization/cfp.d.ts.map +0 -1
- package/dist/src/transfer/serialization/cfp.js.map +0 -1
- package/dist/src/transfer/storage/gcs.d.ts.map +0 -1
- package/dist/src/transfer/storage/gcs.js.map +0 -1
- package/dist/src/transfer/storage/index.d.ts.map +0 -1
- package/dist/src/transfer/storage/index.js.map +0 -1
- package/dist/src/transfer/store/discovery.d.ts.map +0 -1
- package/dist/src/transfer/store/discovery.js.map +0 -1
- package/dist/src/transfer/store/download.d.ts.map +0 -1
- package/dist/src/transfer/store/download.js.map +0 -1
- package/dist/src/transfer/store/index.d.ts.map +0 -1
- package/dist/src/transfer/store/index.js.map +0 -1
- package/dist/src/transfer/store/publish.d.ts.map +0 -1
- package/dist/src/transfer/store/publish.js.map +0 -1
- package/dist/src/transfer/store/registry.d.ts.map +0 -1
- package/dist/src/transfer/store/registry.js.map +0 -1
- package/dist/src/transfer/store/search.d.ts.map +0 -1
- package/dist/src/transfer/store/search.js.map +0 -1
- package/dist/src/transfer/store/tests/standalone-test.d.ts.map +0 -1
- package/dist/src/transfer/store/tests/standalone-test.js.map +0 -1
- package/dist/src/transfer/store/types.d.ts.map +0 -1
- package/dist/src/transfer/store/types.js.map +0 -1
- package/dist/src/transfer/test-seraphine.d.ts.map +0 -1
- package/dist/src/transfer/test-seraphine.js.map +0 -1
- package/dist/src/transfer/tests/test-store.d.ts.map +0 -1
- package/dist/src/transfer/tests/test-store.js.map +0 -1
- package/dist/src/transfer/types.d.ts.map +0 -1
- package/dist/src/transfer/types.js.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js.map +0 -1
- package/dist/src/update/checker.d.ts.map +0 -1
- package/dist/src/update/checker.js.map +0 -1
- package/dist/src/update/executor.d.ts.map +0 -1
- package/dist/src/update/executor.js.map +0 -1
- package/dist/src/update/index.d.ts.map +0 -1
- package/dist/src/update/index.js.map +0 -1
- package/dist/src/update/rate-limiter.d.ts.map +0 -1
- package/dist/src/update/rate-limiter.js.map +0 -1
- package/dist/src/update/validator.d.ts.map +0 -1
- package/dist/src/update/validator.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/scripts/beir-bootstrap-significance.mjs +0 -162
- package/scripts/bench-rvagent.mjs +0 -312
- package/scripts/benchmark-codemods.mjs +0 -127
- package/scripts/benchmark-cross-repo.mjs +0 -206
- package/scripts/benchmark-pretrained-retrieval.mjs +0 -305
- package/scripts/benchmark-self-learning.mjs +0 -241
- package/scripts/benchmark-trajectory-mrr.mjs +0 -191
- package/scripts/deploy-ipfs-node.sh +0 -153
- package/scripts/grid-search-retrieval.mjs +0 -216
- package/scripts/pretrain-from-github.mjs +0 -358
- package/scripts/publish-registry.ts +0 -345
- package/scripts/publish.sh +0 -57
- package/scripts/run-beir-bge.mjs +0 -324
- package/scripts/run-beir-hybrid.mjs +0 -284
- package/scripts/run-beir-lucene-bm25.mjs +0 -154
- package/scripts/run-beir-nfcorpus.mjs +0 -231
- package/scripts/run-beir-rrf-ablation.mjs +0 -221
- package/scripts/setup-ipfs-registry.md +0 -366
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version-stamped critical-helper auto-refresh.
|
|
3
|
+
*
|
|
4
|
+
* The Claude Code hooks run the PROJECT-LOCAL `.claude/helpers/*.cjs` copies,
|
|
5
|
+
* not the installed npm package — so `npx ruflo@latest` does NOT update them,
|
|
6
|
+
* and users don't know to re-run `init`. This module stamps the helpers with
|
|
7
|
+
* the installed CLI version and, on the next CLI command, silently re-copies
|
|
8
|
+
* them when the stamp is stale. Hook fixes (e.g. the ADR-174 failure-capture
|
|
9
|
+
* change) then propagate to every user on their next `ruflo` command with zero
|
|
10
|
+
* action required.
|
|
11
|
+
*
|
|
12
|
+
* This file is intentionally LIGHTWEIGHT — it is imported on every CLI startup,
|
|
13
|
+
* so it depends only on `fs`/`path`/`module` at load time and lazily imports the
|
|
14
|
+
* heavy generators only on the rare fallback path (source dir unresolvable).
|
|
15
|
+
*/
|
|
16
|
+
import * as fs from 'fs';
|
|
17
|
+
import * as path from 'path';
|
|
18
|
+
import { fileURLToPath } from 'url';
|
|
19
|
+
import { createRequire } from 'module';
|
|
20
|
+
import { verifyHelpersManifest, sha256Hex, HELPERS_MANIFEST_FILE, } from './helper-signing.js';
|
|
21
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
export const HELPERS_STAMP_FILE = '.helpers-version';
|
|
23
|
+
/** ruflo-owned helpers that carry hook logic and must track the package version. */
|
|
24
|
+
export const CRITICAL_HELPERS = ['auto-memory-hook.mjs', 'hook-handler.cjs', 'intelligence.cjs'];
|
|
25
|
+
/** Installed @claude-flow/cli version — the value the helpers are stamped with. */
|
|
26
|
+
export function getInstalledCliVersion() {
|
|
27
|
+
try {
|
|
28
|
+
const esmRequire = createRequire(import.meta.url);
|
|
29
|
+
const pkg = JSON.parse(fs.readFileSync(esmRequire.resolve('@claude-flow/cli/package.json'), 'utf-8'));
|
|
30
|
+
return String(pkg.version || '0.0.0');
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// dist/src/init → package root
|
|
34
|
+
try {
|
|
35
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', '..', '..', 'package.json'), 'utf-8'));
|
|
36
|
+
return String(pkg.version || '0.0.0');
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return '0.0.0';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Locate the in-package `.claude/helpers` dir (the copy source). Null if not found. */
|
|
44
|
+
function findPackageHelpersDir() {
|
|
45
|
+
const candidates = [];
|
|
46
|
+
try {
|
|
47
|
+
const esmRequire = createRequire(import.meta.url);
|
|
48
|
+
const pkgRoot = path.dirname(esmRequire.resolve('@claude-flow/cli/package.json'));
|
|
49
|
+
candidates.push(path.join(pkgRoot, '.claude', 'helpers'));
|
|
50
|
+
}
|
|
51
|
+
catch { /* not resolvable */ }
|
|
52
|
+
candidates.push(path.resolve(__dirname, '..', '..', '..', '.claude', 'helpers'));
|
|
53
|
+
for (const c of candidates) {
|
|
54
|
+
if (fs.existsSync(path.join(c, 'hook-handler.cjs')))
|
|
55
|
+
return c;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Re-copy the critical helpers into `helpersDir` and stamp `version`.
|
|
61
|
+
*
|
|
62
|
+
* SECURITY (fail-closed): when copying from the installed package, every source
|
|
63
|
+
* helper is verified against ruflo's Ed25519-signed manifest FIRST — nothing is
|
|
64
|
+
* copied unless the manifest signature is valid AND each helper's SHA-256
|
|
65
|
+
* matches. A tampered helper or manifest (e.g. a sibling package's postinstall
|
|
66
|
+
* overwriting on-disk hook code) is REFUSED, not propagated. The generator
|
|
67
|
+
* fallback needs no manifest — that content comes from the CLI's own compiled
|
|
68
|
+
* code, which is already the trust root.
|
|
69
|
+
*/
|
|
70
|
+
async function writeCriticalHelpers(helpersDir, version) {
|
|
71
|
+
const source = findPackageHelpersDir();
|
|
72
|
+
if (source) {
|
|
73
|
+
// 1. Verify the signed manifest against the baked public key.
|
|
74
|
+
let trusted = null;
|
|
75
|
+
try {
|
|
76
|
+
trusted = verifyHelpersManifest(fs.readFileSync(path.join(source, HELPERS_MANIFEST_FILE), 'utf-8'));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
trusted = null;
|
|
80
|
+
}
|
|
81
|
+
if (!trusted)
|
|
82
|
+
return { wrote: false, blocked: 'signed helpers manifest missing or signature invalid' };
|
|
83
|
+
// 2. Verify EVERY source helper's hash before copying ANYTHING (atomic gate).
|
|
84
|
+
const toCopy = [];
|
|
85
|
+
for (const name of CRITICAL_HELPERS) {
|
|
86
|
+
const sp = path.join(source, name);
|
|
87
|
+
if (!fs.existsSync(sp))
|
|
88
|
+
continue;
|
|
89
|
+
const expected = trusted.files[name];
|
|
90
|
+
if (!expected || sha256Hex(fs.readFileSync(sp)) !== expected) {
|
|
91
|
+
return { wrote: false, blocked: `integrity check failed for ${name} — refusing to install` };
|
|
92
|
+
}
|
|
93
|
+
toCopy.push(name);
|
|
94
|
+
}
|
|
95
|
+
// 3. All verified — copy, plus the signed manifest itself as an audit trail.
|
|
96
|
+
let wrote = false;
|
|
97
|
+
for (const name of toCopy) {
|
|
98
|
+
const tp = path.join(helpersDir, name);
|
|
99
|
+
fs.copyFileSync(path.join(source, name), tp);
|
|
100
|
+
try {
|
|
101
|
+
fs.chmodSync(tp, '755');
|
|
102
|
+
}
|
|
103
|
+
catch { /* non-fatal */ }
|
|
104
|
+
wrote = true;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
fs.copyFileSync(path.join(source, HELPERS_MANIFEST_FILE), path.join(helpersDir, HELPERS_MANIFEST_FILE));
|
|
108
|
+
}
|
|
109
|
+
catch { /* non-fatal */ }
|
|
110
|
+
if (wrote) {
|
|
111
|
+
try {
|
|
112
|
+
fs.writeFileSync(path.join(helpersDir, HELPERS_STAMP_FILE), version, 'utf-8');
|
|
113
|
+
}
|
|
114
|
+
catch { /* non-fatal */ }
|
|
115
|
+
}
|
|
116
|
+
return { wrote };
|
|
117
|
+
}
|
|
118
|
+
// Fallback: source unresolvable (broken npx paths) — regenerate from the CLI's
|
|
119
|
+
// OWN compiled generators (the trust root; no external file to verify).
|
|
120
|
+
const gen = await import('./helpers-generator.js');
|
|
121
|
+
const files = {
|
|
122
|
+
'hook-handler.cjs': gen.generateHookHandler(),
|
|
123
|
+
'intelligence.cjs': gen.generateIntelligenceStub(),
|
|
124
|
+
'auto-memory-hook.mjs': gen.generateAutoMemoryHook(),
|
|
125
|
+
};
|
|
126
|
+
let wrote = false;
|
|
127
|
+
for (const [name, content] of Object.entries(files)) {
|
|
128
|
+
const tp = path.join(helpersDir, name);
|
|
129
|
+
fs.writeFileSync(tp, content, 'utf-8');
|
|
130
|
+
try {
|
|
131
|
+
fs.chmodSync(tp, '755');
|
|
132
|
+
}
|
|
133
|
+
catch { /* non-fatal */ }
|
|
134
|
+
wrote = true;
|
|
135
|
+
}
|
|
136
|
+
if (wrote) {
|
|
137
|
+
try {
|
|
138
|
+
fs.writeFileSync(path.join(helpersDir, HELPERS_STAMP_FILE), version, 'utf-8');
|
|
139
|
+
}
|
|
140
|
+
catch { /* non-fatal */ }
|
|
141
|
+
}
|
|
142
|
+
return { wrote };
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* On CLI startup: if an initialized project's critical helpers are stamped older
|
|
146
|
+
* than the installed CLI version, silently re-copy them. Fast path is a single
|
|
147
|
+
* stamp read + string compare (sub-ms); the copy runs at most once per version
|
|
148
|
+
* bump. Best-effort, never throws. No-op outside a ruflo project (requires an
|
|
149
|
+
* existing hook-handler.cjs — never creates files in an unrelated directory).
|
|
150
|
+
*/
|
|
151
|
+
export async function autoRefreshHelpersIfStale(cwd) {
|
|
152
|
+
try {
|
|
153
|
+
const helpersDir = path.join(cwd, '.claude', 'helpers');
|
|
154
|
+
if (!fs.existsSync(path.join(helpersDir, 'hook-handler.cjs')))
|
|
155
|
+
return { refreshed: false };
|
|
156
|
+
const version = getInstalledCliVersion();
|
|
157
|
+
let stamped = '';
|
|
158
|
+
try {
|
|
159
|
+
stamped = fs.readFileSync(path.join(helpersDir, HELPERS_STAMP_FILE), 'utf-8').trim();
|
|
160
|
+
}
|
|
161
|
+
catch { /* pre-feature: unstamped */ }
|
|
162
|
+
if (stamped === version)
|
|
163
|
+
return { refreshed: false }; // up to date — fast path
|
|
164
|
+
const res = await writeCriticalHelpers(helpersDir, version);
|
|
165
|
+
// A blocked refresh is a SECURITY signal (tampered source/manifest) — surface
|
|
166
|
+
// it, don't advance the stamp, and leave the project's existing helpers intact.
|
|
167
|
+
if (res.blocked)
|
|
168
|
+
return { refreshed: false, blocked: res.blocked };
|
|
169
|
+
return res.wrote ? { refreshed: true, from: stamped || '(unstamped)', to: version } : { refreshed: false };
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return { refreshed: false };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=helper-refresh.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ruflo helper-signing PUBLIC key (safe to commit). The matching private key is
|
|
3
|
+
* held out-of-repo and provided to scripts/sign-helpers.mjs at publish time via
|
|
4
|
+
* $RUFLO_HELPERS_SIGNING_KEY. Rotating the key = replace this constant + re-sign.
|
|
5
|
+
*/
|
|
6
|
+
export declare const RUFLO_HELPERS_PUBKEY = "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAhnFv74/CRcGWd0hL8zjyZ+52bIJ9SfcSgOutuKgo0Vg=\n-----END PUBLIC KEY-----";
|
|
7
|
+
export declare const HELPERS_MANIFEST_FILE = "helpers.manifest.json";
|
|
8
|
+
export interface HelpersManifest {
|
|
9
|
+
version: string;
|
|
10
|
+
files: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
export interface SignedHelpersManifest {
|
|
13
|
+
manifest: HelpersManifest;
|
|
14
|
+
signature: string;
|
|
15
|
+
algorithm: 'ed25519';
|
|
16
|
+
}
|
|
17
|
+
export declare function sha256Hex(content: string | Buffer): string;
|
|
18
|
+
/**
|
|
19
|
+
* Deterministic canonical bytes of a manifest — file keys sorted so the signer
|
|
20
|
+
* and verifier agree byte-for-byte regardless of object insertion order.
|
|
21
|
+
*/
|
|
22
|
+
export declare function canonicalManifestBytes(m: HelpersManifest): Buffer;
|
|
23
|
+
/**
|
|
24
|
+
* Verify a signed helpers manifest against ruflo's public key. Returns the
|
|
25
|
+
* trusted file->sha256 manifest, or null on ANY failure (bad signature,
|
|
26
|
+
* malformed JSON, wrong algorithm). Fail-closed — the caller MUST refuse to
|
|
27
|
+
* install unverified helpers.
|
|
28
|
+
*/
|
|
29
|
+
export declare function verifyHelpersManifest(signedJson: string, pubkeyPem?: string): HelpersManifest | null;
|
|
30
|
+
//# sourceMappingURL=helper-signing.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ed25519 provenance for the auto-refreshed critical helpers (ADR-174 security).
|
|
3
|
+
*
|
|
4
|
+
* The helper auto-refresh copies auto-EXECUTING hook code (`hook-handler.cjs`
|
|
5
|
+
* etc.) from the installed package into a project. npm verifies the tarball at
|
|
6
|
+
* INSTALL time, but not the files on disk afterward — a sibling package's
|
|
7
|
+
* postinstall (or disk tampering) could overwrite them, and the refresh would
|
|
8
|
+
* faithfully propagate the tampered code. This gate closes that: every helper
|
|
9
|
+
* is verified against a ruflo-signed manifest before install, and a mismatch is
|
|
10
|
+
* REFUSED (fail-closed). The public key is baked in below; the private key is
|
|
11
|
+
* never in the repo (see scripts/sign-helpers.mjs).
|
|
12
|
+
*
|
|
13
|
+
* Native Node crypto (RFC 8032 Ed25519), zero external deps — same primitive as
|
|
14
|
+
* src/appliance/rvfa-signing.ts.
|
|
15
|
+
*/
|
|
16
|
+
import { createHash, verify as edVerify } from 'crypto';
|
|
17
|
+
/**
|
|
18
|
+
* Ruflo helper-signing PUBLIC key (safe to commit). The matching private key is
|
|
19
|
+
* held out-of-repo and provided to scripts/sign-helpers.mjs at publish time via
|
|
20
|
+
* $RUFLO_HELPERS_SIGNING_KEY. Rotating the key = replace this constant + re-sign.
|
|
21
|
+
*/
|
|
22
|
+
export const RUFLO_HELPERS_PUBKEY = `-----BEGIN PUBLIC KEY-----
|
|
23
|
+
MCowBQYDK2VwAyEAhnFv74/CRcGWd0hL8zjyZ+52bIJ9SfcSgOutuKgo0Vg=
|
|
24
|
+
-----END PUBLIC KEY-----`;
|
|
25
|
+
export const HELPERS_MANIFEST_FILE = 'helpers.manifest.json';
|
|
26
|
+
export function sha256Hex(content) {
|
|
27
|
+
return createHash('sha256').update(content).digest('hex');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Deterministic canonical bytes of a manifest — file keys sorted so the signer
|
|
31
|
+
* and verifier agree byte-for-byte regardless of object insertion order.
|
|
32
|
+
*/
|
|
33
|
+
export function canonicalManifestBytes(m) {
|
|
34
|
+
const files = {};
|
|
35
|
+
for (const k of Object.keys(m.files).sort())
|
|
36
|
+
files[k] = m.files[k];
|
|
37
|
+
return Buffer.from(JSON.stringify({ version: m.version, files }), 'utf-8');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Verify a signed helpers manifest against ruflo's public key. Returns the
|
|
41
|
+
* trusted file->sha256 manifest, or null on ANY failure (bad signature,
|
|
42
|
+
* malformed JSON, wrong algorithm). Fail-closed — the caller MUST refuse to
|
|
43
|
+
* install unverified helpers.
|
|
44
|
+
*/
|
|
45
|
+
export function verifyHelpersManifest(signedJson, pubkeyPem = RUFLO_HELPERS_PUBKEY) {
|
|
46
|
+
try {
|
|
47
|
+
const signed = JSON.parse(signedJson);
|
|
48
|
+
if (!signed || signed.algorithm !== 'ed25519' || !signed.signature || !signed.manifest)
|
|
49
|
+
return null;
|
|
50
|
+
if (!signed.manifest.files || typeof signed.manifest.files !== 'object')
|
|
51
|
+
return null;
|
|
52
|
+
const bytes = canonicalManifestBytes(signed.manifest);
|
|
53
|
+
const ok = edVerify(null, bytes, pubkeyPem, Buffer.from(signed.signature, 'base64'));
|
|
54
|
+
return ok ? signed.manifest : null;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=helper-signing.js.map
|
|
@@ -4,6 +4,22 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { InitOptions } from './types.js';
|
|
6
6
|
export declare const ATTRIBUTION_FOOTER = "\uD83E\uDD16 Generated with [RuFlo](https://github.com/ruvnet/ruflo)";
|
|
7
|
+
/**
|
|
8
|
+
* Detect whether a Claude Code PostToolUse payload represents a FAILED tool run.
|
|
9
|
+
*
|
|
10
|
+
* Why this matters: the learning substrate had 898 feedback records, 100%
|
|
11
|
+
* success, 0 failures — because the post-edit/post-task hooks recorded a
|
|
12
|
+
* hardcoded `success:true` and never inspected the tool outcome. With no
|
|
13
|
+
* negative examples, the oracle tier can't teach good-vs-bad (see the DB
|
|
14
|
+
* analysis + ADR-174). Claude Code passes the tool result in the PostToolUse
|
|
15
|
+
* hook payload (`tool_response`), which for a failed Write/Edit/Bash carries an
|
|
16
|
+
* error marker. This predicate is the single source of truth the generated
|
|
17
|
+
* hook inlines, and is unit-tested here so the detection stays honest.
|
|
18
|
+
*
|
|
19
|
+
* Conservative: returns true only on a POSITIVE error signal; ambiguous/missing
|
|
20
|
+
* payloads default to success (matches prior behavior, avoids false failures).
|
|
21
|
+
*/
|
|
22
|
+
export declare function isToolFailure(hookInput: unknown): boolean;
|
|
7
23
|
/**
|
|
8
24
|
* Generate pre-commit hook script
|
|
9
25
|
*/
|
|
@@ -9,6 +9,58 @@ import { generateStatuslineScript, generateStatuslineHook } from './statusline-g
|
|
|
9
9
|
// PR body templates and release notes. It is NEVER hard-wired into the
|
|
10
10
|
// static command-file templates — those are user-owned content.
|
|
11
11
|
export const ATTRIBUTION_FOOTER = '🤖 Generated with [RuFlo](https://github.com/ruvnet/ruflo)';
|
|
12
|
+
/**
|
|
13
|
+
* Detect whether a Claude Code PostToolUse payload represents a FAILED tool run.
|
|
14
|
+
*
|
|
15
|
+
* Why this matters: the learning substrate had 898 feedback records, 100%
|
|
16
|
+
* success, 0 failures — because the post-edit/post-task hooks recorded a
|
|
17
|
+
* hardcoded `success:true` and never inspected the tool outcome. With no
|
|
18
|
+
* negative examples, the oracle tier can't teach good-vs-bad (see the DB
|
|
19
|
+
* analysis + ADR-174). Claude Code passes the tool result in the PostToolUse
|
|
20
|
+
* hook payload (`tool_response`), which for a failed Write/Edit/Bash carries an
|
|
21
|
+
* error marker. This predicate is the single source of truth the generated
|
|
22
|
+
* hook inlines, and is unit-tested here so the detection stays honest.
|
|
23
|
+
*
|
|
24
|
+
* Conservative: returns true only on a POSITIVE error signal; ambiguous/missing
|
|
25
|
+
* payloads default to success (matches prior behavior, avoids false failures).
|
|
26
|
+
*/
|
|
27
|
+
export function isToolFailure(hookInput) {
|
|
28
|
+
if (!hookInput || typeof hookInput !== 'object')
|
|
29
|
+
return false;
|
|
30
|
+
const h = hookInput;
|
|
31
|
+
const tr = (h.tool_response ?? h.toolResponse ?? h.result);
|
|
32
|
+
if (tr == null)
|
|
33
|
+
return false;
|
|
34
|
+
if (typeof tr === 'string') {
|
|
35
|
+
return /\b(error|failed|failure|exception|not found|no such|permission denied|traceback)\b/i.test(tr);
|
|
36
|
+
}
|
|
37
|
+
if (typeof tr === 'object') {
|
|
38
|
+
const o = tr;
|
|
39
|
+
if (o.is_error === true || o.isError === true || o.success === false || o.error != null)
|
|
40
|
+
return true;
|
|
41
|
+
// Bash tool: non-zero exit code is a failure.
|
|
42
|
+
const code = (o.exit_code ?? o.exitCode ?? o.code);
|
|
43
|
+
if (typeof code === 'number' && code !== 0)
|
|
44
|
+
return true;
|
|
45
|
+
// Nested content array (Claude tool result shape): {content:[...], is_error:true}
|
|
46
|
+
if (Array.isArray(o.content) && o.is_error === true)
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
// The exact predicate the generated hook inlines — kept in sync with
|
|
52
|
+
// isToolFailure() above (mirrored, since the generated .cjs has no imports).
|
|
53
|
+
const TOOL_FAILURE_EXPR = '(function(hi){' +
|
|
54
|
+
'if(!hi||typeof hi!=="object")return false;' +
|
|
55
|
+
'var tr=hi.tool_response!=null?hi.tool_response:(hi.toolResponse!=null?hi.toolResponse:hi.result);' +
|
|
56
|
+
'if(tr==null)return false;' +
|
|
57
|
+
'if(typeof tr==="string")return /\\b(error|failed|failure|exception|not found|no such|permission denied|traceback)\\b/i.test(tr);' +
|
|
58
|
+
'if(typeof tr==="object"){' +
|
|
59
|
+
'if(tr.is_error===true||tr.isError===true||tr.success===false||tr.error!=null)return true;' +
|
|
60
|
+
'var code=tr.exit_code!=null?tr.exit_code:(tr.exitCode!=null?tr.exitCode:tr.code);' +
|
|
61
|
+
'if(typeof code==="number"&&code!==0)return true;' +
|
|
62
|
+
'if(Array.isArray(tr.content)&&tr.is_error===true)return true;' +
|
|
63
|
+
'}return false;})(hookInput)';
|
|
12
64
|
/**
|
|
13
65
|
* Generate pre-commit hook script
|
|
14
66
|
*/
|
|
@@ -459,6 +511,9 @@ export function generateHookHandler() {
|
|
|
459
511
|
' // hook (#1944). Pull `.command` off whichever stdin shape Claude Code sent.',
|
|
460
512
|
' var toolInputObj = hookInput.toolInput || hookInput.tool_input || {};',
|
|
461
513
|
" var prompt = hookInput.prompt || hookInput.command || toolInputObj.command || process.env.PROMPT || process.env.TOOL_INPUT_command || args.join(' ') || '';",
|
|
514
|
+
' // Capture FAILURES, not just successes, so the learning substrate has',
|
|
515
|
+
' // negative examples (see ADR-174 / DB analysis). Mirrors isToolFailure().',
|
|
516
|
+
' var toolFailed = ' + TOOL_FAILURE_EXPR + ';',
|
|
462
517
|
'',
|
|
463
518
|
'const handlers = {',
|
|
464
519
|
" 'route': () => {",
|
|
@@ -503,10 +558,10 @@ export function generateHookHandler() {
|
|
|
503
558
|
' if (intelligence && intelligence.recordEdit) {',
|
|
504
559
|
' try {',
|
|
505
560
|
" var file = process.env.TOOL_INPUT_file_path || args[0] || '';",
|
|
506
|
-
' intelligence.recordEdit(file);',
|
|
561
|
+
' intelligence.recordEdit(file, !toolFailed);',
|
|
507
562
|
' } catch (e) { /* non-fatal */ }',
|
|
508
563
|
' }',
|
|
509
|
-
" console.log('[OK] Edit recorded');",
|
|
564
|
+
" console.log(toolFailed ? '[LEARN] Edit FAILURE recorded' : '[OK] Edit recorded');",
|
|
510
565
|
' },',
|
|
511
566
|
'',
|
|
512
567
|
" 'session-restore': () => {",
|
|
@@ -562,10 +617,10 @@ export function generateHookHandler() {
|
|
|
562
617
|
" 'post-task': () => {",
|
|
563
618
|
' if (intelligence && intelligence.feedback) {',
|
|
564
619
|
' try {',
|
|
565
|
-
' intelligence.feedback(
|
|
620
|
+
' intelligence.feedback(!toolFailed);',
|
|
566
621
|
' } catch (e) { /* non-fatal */ }',
|
|
567
622
|
' }',
|
|
568
|
-
" console.log('[OK] Task completed');",
|
|
623
|
+
" console.log(toolFailed ? '[LEARN] Task FAILURE recorded' : '[OK] Task completed');",
|
|
569
624
|
' },',
|
|
570
625
|
'',
|
|
571
626
|
" 'compact-manual': () => {",
|
|
@@ -809,10 +864,12 @@ export function generateIntelligenceStub() {
|
|
|
809
864
|
' return lines2.join("\\n");',
|
|
810
865
|
' },',
|
|
811
866
|
'',
|
|
812
|
-
' recordEdit: function(file) {',
|
|
867
|
+
' recordEdit: function(file, success) {',
|
|
813
868
|
' if (!file) return;',
|
|
814
869
|
' ensureDir(DATA_DIR);',
|
|
815
|
-
'
|
|
870
|
+
' // success defaults to true; an explicit false (failed edit) is recorded',
|
|
871
|
+
' // so consolidation/distillation gets a negative example (ADR-174).',
|
|
872
|
+
' var line = JSON.stringify({ type: "edit", file: file, success: success !== false, timestamp: Date.now() }) + "\\n";',
|
|
816
873
|
' fs.appendFileSync(PENDING_PATH, line, "utf-8");',
|
|
817
874
|
' },',
|
|
818
875
|
'',
|
|
@@ -863,13 +920,37 @@ const DATA_DIR = join(PROJECT_ROOT, '.claude-flow', 'data');
|
|
|
863
920
|
const STORE_PATH = join(DATA_DIR, 'auto-memory-store.json');
|
|
864
921
|
|
|
865
922
|
const DIM = '\\x1b[2m';
|
|
923
|
+
const YELLOW = '\\x1b[0;33m';
|
|
866
924
|
const RESET = '\\x1b[0m';
|
|
867
925
|
const dim = (msg) => console.log(\` \${DIM}\${msg}\${RESET}\`);
|
|
868
926
|
|
|
927
|
+
// #2545: fail LOUD instead of a silent dim skip when @claude-flow/memory is
|
|
928
|
+
// unresolvable — self-learning imports are a no-op and the user must be told.
|
|
929
|
+
function warnMemoryUnavailable() {
|
|
930
|
+
const l1 = \`[AutoMemory] @claude-flow/memory not resolvable from \${PROJECT_ROOT} — self-learning imports are DISABLED.\`;
|
|
931
|
+
const l2 = ' Fix: npm i -D @claude-flow/memory (or re-run: npx ruflo@latest init, then npx ruflo@latest doctor --fix)';
|
|
932
|
+
console.log(\`\${YELLOW}\${l1}\${RESET}\`);
|
|
933
|
+
console.log(\`\${YELLOW}\${l2}\${RESET}\`);
|
|
934
|
+
process.stderr.write(\`\${l1}\\n\${l2}\\n\`);
|
|
935
|
+
}
|
|
936
|
+
|
|
869
937
|
// Ensure data dir
|
|
870
938
|
if (!existsSync(DATA_DIR)) mkdirSync(DATA_DIR, { recursive: true });
|
|
871
939
|
|
|
872
940
|
async function loadMemoryPackage() {
|
|
941
|
+
// Strategy 0 (#2545): sidecar recorded by \`init\` / \`doctor --fix\`. On the npx
|
|
942
|
+
// path @claude-flow/memory lands in the npx cache (unreachable by walk-up), so
|
|
943
|
+
// init records its absolute path here — the only strategy that works there.
|
|
944
|
+
try {
|
|
945
|
+
const sidecar = join(PROJECT_ROOT, '.claude-flow', 'memory-package.json');
|
|
946
|
+
if (existsSync(sidecar)) {
|
|
947
|
+
const rec = JSON.parse(readFileSync(sidecar, 'utf-8'));
|
|
948
|
+
if (rec && rec.distPath && existsSync(rec.distPath)) {
|
|
949
|
+
return await import(\`file://\${rec.distPath}\`);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
} catch { /* fall through */ }
|
|
953
|
+
|
|
873
954
|
// Strategy 1: Use createRequire for CJS-style resolution (handles nested node_modules
|
|
874
955
|
// when installed as a transitive dependency via npx ruflo / npx claude-flow)
|
|
875
956
|
try {
|
|
@@ -899,7 +980,7 @@ async function doImport() {
|
|
|
899
980
|
const memPkg = await loadMemoryPackage();
|
|
900
981
|
|
|
901
982
|
if (!memPkg || !memPkg.AutoMemoryBridge) {
|
|
902
|
-
|
|
983
|
+
warnMemoryUnavailable();
|
|
903
984
|
return;
|
|
904
985
|
}
|
|
905
986
|
|
|
@@ -916,7 +997,7 @@ async function doSync() {
|
|
|
916
997
|
const memPkg = await loadMemoryPackage();
|
|
917
998
|
|
|
918
999
|
if (!memPkg || !memPkg.AutoMemoryBridge) {
|
|
919
|
-
|
|
1000
|
+
warnMemoryUnavailable();
|
|
920
1001
|
return;
|
|
921
1002
|
}
|
|
922
1003
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Package Resolver (#2545)
|
|
3
|
+
*
|
|
4
|
+
* `@claude-flow/memory` is an *optionalDependency* of `@claude-flow/cli`. On the
|
|
5
|
+
* documented `npx ruflo` install path it lands in the npx cache
|
|
6
|
+
* (`~/.npm/_npx/<hash>/node_modules`), which is NOT on the node_modules walk-up
|
|
7
|
+
* path from the user's project. The SessionStart auto-memory hook therefore
|
|
8
|
+
* could never resolve it and self-learning silently no-op'd.
|
|
9
|
+
*
|
|
10
|
+
* At init time, however, the CLI *can* resolve the package from its own module
|
|
11
|
+
* context (it is installed alongside the CLI in that same npx cache). We resolve
|
|
12
|
+
* it once and record the absolute path in a machine-local project sidecar
|
|
13
|
+
* (`.claude-flow/memory-package.json`). The hook reads this sidecar first, so it
|
|
14
|
+
* reuses the copy npx already downloaded — no second install, no vendoring.
|
|
15
|
+
*
|
|
16
|
+
* This module is deliberately dependency-free and best-effort: nothing here ever
|
|
17
|
+
* throws into the init/doctor flow.
|
|
18
|
+
*/
|
|
19
|
+
export declare const MEMORY_PACKAGE = "@claude-flow/memory";
|
|
20
|
+
/** Project-relative path of the resolver sidecar written by init / doctor --fix. */
|
|
21
|
+
export declare const MEMORY_SIDECAR_REL: string;
|
|
22
|
+
export interface MemoryPackageRecord {
|
|
23
|
+
/** Absolute path to the package's main entry (dist/index.js). */
|
|
24
|
+
distPath: string;
|
|
25
|
+
/** Resolved package version, if readable. */
|
|
26
|
+
version: string | null;
|
|
27
|
+
/** What produced this record ("init" | "doctor" | "upgrade"). */
|
|
28
|
+
resolvedBy: string;
|
|
29
|
+
/** ISO timestamp of resolution. */
|
|
30
|
+
resolvedAt: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve `@claude-flow/memory`'s main entry from the CLI's own module context.
|
|
34
|
+
* Returns the absolute dist path, or null when the optional dependency is absent
|
|
35
|
+
* (e.g. installed with `--omit=optional`).
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveMemoryPackageFromCli(): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve `@claude-flow/memory` the same way the runtime hook does, from a target
|
|
40
|
+
* project directory: sidecar → project package.json → node_modules walk-up.
|
|
41
|
+
* Used by `doctor` so its verdict matches what the hook will actually experience.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveMemoryPackageFromProject(targetDir: string): string | null;
|
|
44
|
+
/** Read the version of the resolved memory package (dist/index.js → ../package.json). */
|
|
45
|
+
export declare function readMemoryPackageVersion(distPath: string): string | null;
|
|
46
|
+
/**
|
|
47
|
+
* Best-effort: resolve `@claude-flow/memory` from the CLI and record its path in
|
|
48
|
+
* the project sidecar so the runtime hook can find it on the npx install path.
|
|
49
|
+
* Returns the written record, or null when the package is not resolvable from the
|
|
50
|
+
* CLI (in which case the hook fails loud and `doctor` flags it).
|
|
51
|
+
*/
|
|
52
|
+
export declare function recordMemoryPackagePath(targetDir: string, resolvedBy?: string): MemoryPackageRecord | null;
|
|
53
|
+
//# sourceMappingURL=memory-package-resolver.d.ts.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Package Resolver (#2545)
|
|
3
|
+
*
|
|
4
|
+
* `@claude-flow/memory` is an *optionalDependency* of `@claude-flow/cli`. On the
|
|
5
|
+
* documented `npx ruflo` install path it lands in the npx cache
|
|
6
|
+
* (`~/.npm/_npx/<hash>/node_modules`), which is NOT on the node_modules walk-up
|
|
7
|
+
* path from the user's project. The SessionStart auto-memory hook therefore
|
|
8
|
+
* could never resolve it and self-learning silently no-op'd.
|
|
9
|
+
*
|
|
10
|
+
* At init time, however, the CLI *can* resolve the package from its own module
|
|
11
|
+
* context (it is installed alongside the CLI in that same npx cache). We resolve
|
|
12
|
+
* it once and record the absolute path in a machine-local project sidecar
|
|
13
|
+
* (`.claude-flow/memory-package.json`). The hook reads this sidecar first, so it
|
|
14
|
+
* reuses the copy npx already downloaded — no second install, no vendoring.
|
|
15
|
+
*
|
|
16
|
+
* This module is deliberately dependency-free and best-effort: nothing here ever
|
|
17
|
+
* throws into the init/doctor flow.
|
|
18
|
+
*/
|
|
19
|
+
import { createRequire } from 'module';
|
|
20
|
+
import * as fs from 'fs';
|
|
21
|
+
import * as path from 'path';
|
|
22
|
+
export const MEMORY_PACKAGE = '@claude-flow/memory';
|
|
23
|
+
/** Project-relative path of the resolver sidecar written by init / doctor --fix. */
|
|
24
|
+
export const MEMORY_SIDECAR_REL = path.join('.claude-flow', 'memory-package.json');
|
|
25
|
+
/**
|
|
26
|
+
* Resolve `@claude-flow/memory`'s main entry from the CLI's own module context.
|
|
27
|
+
* Returns the absolute dist path, or null when the optional dependency is absent
|
|
28
|
+
* (e.g. installed with `--omit=optional`).
|
|
29
|
+
*/
|
|
30
|
+
export function resolveMemoryPackageFromCli() {
|
|
31
|
+
try {
|
|
32
|
+
const require = createRequire(import.meta.url);
|
|
33
|
+
return require.resolve(MEMORY_PACKAGE);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolve `@claude-flow/memory` the same way the runtime hook does, from a target
|
|
41
|
+
* project directory: sidecar → project package.json → node_modules walk-up.
|
|
42
|
+
* Used by `doctor` so its verdict matches what the hook will actually experience.
|
|
43
|
+
*/
|
|
44
|
+
export function resolveMemoryPackageFromProject(targetDir) {
|
|
45
|
+
// 1. Sidecar written by a previous init / doctor --fix
|
|
46
|
+
try {
|
|
47
|
+
const sidecar = path.join(targetDir, MEMORY_SIDECAR_REL);
|
|
48
|
+
if (fs.existsSync(sidecar)) {
|
|
49
|
+
const rec = JSON.parse(fs.readFileSync(sidecar, 'utf-8'));
|
|
50
|
+
if (rec?.distPath && fs.existsSync(rec.distPath))
|
|
51
|
+
return rec.distPath;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
/* fall through */
|
|
56
|
+
}
|
|
57
|
+
// 2. createRequire from the project's package.json (direct/transitive dep)
|
|
58
|
+
try {
|
|
59
|
+
const require = createRequire(path.join(targetDir, 'package.json'));
|
|
60
|
+
return require.resolve(MEMORY_PACKAGE);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
/* fall through */
|
|
64
|
+
}
|
|
65
|
+
// 3. node_modules walk-up from the project root
|
|
66
|
+
let dir = path.resolve(targetDir);
|
|
67
|
+
// eslint-disable-next-line no-constant-condition
|
|
68
|
+
while (true) {
|
|
69
|
+
const candidate = path.join(dir, 'node_modules', '@claude-flow', 'memory', 'dist', 'index.js');
|
|
70
|
+
if (fs.existsSync(candidate))
|
|
71
|
+
return candidate;
|
|
72
|
+
const parent = path.dirname(dir);
|
|
73
|
+
if (parent === dir)
|
|
74
|
+
break;
|
|
75
|
+
dir = parent;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
/** Read the version of the resolved memory package (dist/index.js → ../package.json). */
|
|
80
|
+
export function readMemoryPackageVersion(distPath) {
|
|
81
|
+
try {
|
|
82
|
+
const pkgJson = path.resolve(path.dirname(distPath), '..', 'package.json');
|
|
83
|
+
if (fs.existsSync(pkgJson)) {
|
|
84
|
+
const parsed = JSON.parse(fs.readFileSync(pkgJson, 'utf-8'));
|
|
85
|
+
return parsed.version ?? null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
/* ignore */
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Best-effort: resolve `@claude-flow/memory` from the CLI and record its path in
|
|
95
|
+
* the project sidecar so the runtime hook can find it on the npx install path.
|
|
96
|
+
* Returns the written record, or null when the package is not resolvable from the
|
|
97
|
+
* CLI (in which case the hook fails loud and `doctor` flags it).
|
|
98
|
+
*/
|
|
99
|
+
export function recordMemoryPackagePath(targetDir, resolvedBy = 'init') {
|
|
100
|
+
const distPath = resolveMemoryPackageFromCli();
|
|
101
|
+
if (!distPath)
|
|
102
|
+
return null;
|
|
103
|
+
const record = {
|
|
104
|
+
distPath,
|
|
105
|
+
version: readMemoryPackageVersion(distPath),
|
|
106
|
+
resolvedBy,
|
|
107
|
+
resolvedAt: new Date().toISOString(),
|
|
108
|
+
};
|
|
109
|
+
try {
|
|
110
|
+
fs.mkdirSync(path.join(targetDir, '.claude-flow'), { recursive: true });
|
|
111
|
+
fs.writeFileSync(path.join(targetDir, MEMORY_SIDECAR_REL), JSON.stringify(record, null, 2), 'utf-8');
|
|
112
|
+
return record;
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=memory-package-resolver.js.map
|
|
@@ -211,13 +211,24 @@ function getLocalAgentDB() {
|
|
|
211
211
|
const memDb = path.join(CWD, '.swarm', 'memory.db');
|
|
212
212
|
if (fs.existsSync(memDb)) {
|
|
213
213
|
const Q = String.fromCharCode(34);
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
214
|
+
// Two INDEPENDENT statements -- do NOT combine into one. Coupling the
|
|
215
|
+
// vector count with the vector_indexes row count in a single statement
|
|
216
|
+
// meant that on a DB missing the vector_indexes table (older/agentdb-
|
|
217
|
+
// written DBs), the whole statement failed at PREPARE time (SQLite
|
|
218
|
+
// compiles the full SQL before running), so the valid memory_entries
|
|
219
|
+
// count was discarded too and the statusline showed Vectors 0 despite
|
|
220
|
+
// thousands of real vectors. Split so a missing table can only zero the
|
|
221
|
+
// HNSW flag, never the count. The init self-heal provisions the table so
|
|
222
|
+
// the flag recovers on the next ruflo init / MCP start.
|
|
223
|
+
const countSql = Q + 'SELECT COUNT(*) FROM memory_entries WHERE embedding IS NOT NULL;' + Q;
|
|
224
|
+
const vc = safeExec("sqlite3 'file:" + memDb + "?mode=ro' " + countSql, 1500);
|
|
225
|
+
if (vc) result.vectorCount = parseInt(vc, 10) || 0;
|
|
226
|
+
// HNSW flag: separate statement. If vector_indexes is absent, sqlite3
|
|
227
|
+
// exits non-zero and safeExec returns empty -- hasHnsw stays false (exact
|
|
228
|
+
// original semantics: at least one index-config row present).
|
|
229
|
+
const hnswSql = Q + 'SELECT COUNT(*) FROM vector_indexes;' + Q;
|
|
230
|
+
const hn = safeExec("sqlite3 'file:" + memDb + "?mode=ro' " + hnswSql, 1500);
|
|
231
|
+
if (hn) result.hasHnsw = (parseInt(hn, 10) || 0) > 0;
|
|
221
232
|
}
|
|
222
233
|
} catch { /* ignore */ }
|
|
223
234
|
return result;
|