@monoes/monomindcli 1.18.15 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/core/researcher.md +29 -24
- package/.claude/agents/github/code-review-swarm.md +1 -1
- package/.claude/agents/github/github-modes.md +1 -1
- package/.claude/agents/github/issue-tracker.md +1 -3
- package/.claude/agents/github/multi-repo-swarm.md +1 -1
- package/.claude/agents/github/pr-manager.md +1 -3
- package/.claude/agents/github/project-board-sync.md +1 -1
- package/.claude/agents/github/release-manager.md +1 -1
- package/.claude/agents/github/repo-architect.md +4 -12
- package/.claude/agents/github/swarm-issue.md +1 -1
- package/.claude/agents/github/swarm-pr.md +1 -1
- package/.claude/agents/github/sync-coordinator.md +1 -1
- package/.claude/agents/github/workflow-automation.md +1 -1
- package/.claude/agents/goal/goal-planner.md +1 -2
- package/.claude/agents/specialized/specialized-workflow-architect.md +11 -14
- package/.claude/agents/testing/production-validator.md +8 -7
- package/.claude/agents/testing/testing-evidence-collector.md +3 -1
- package/.claude/commands/github/issue-tracker.md +0 -2
- package/.claude/commands/github/pr-manager.md +0 -2
- package/.claude/commands/github/repo-architect.md +3 -10
- package/.claude/commands/mastermind/code-review.md +4 -4
- package/.claude/commands/mastermind/help.md +5 -5
- package/.claude/commands/mastermind/okf-export.md +14 -0
- package/.claude/commands/mastermind/okf-import.md +15 -0
- package/.claude/commands/workflows/README.md +0 -1
- package/.claude/commands/workflows/workflow-create.md +0 -1
- package/.claude/commands/workflows/workflow-execute.md +1 -3
- package/.claude/commands/workflows/workflow-export.md +0 -2
- package/.claude/helpers/handlers/agent-start-handler.cjs +28 -36
- package/.claude/helpers/handlers/capture-handler.cjs +110 -0
- package/.claude/helpers/handlers/edit-handler.cjs +15 -0
- package/.claude/helpers/handlers/gates-handler.cjs +2 -8
- package/.claude/helpers/handlers/route-handler.cjs +314 -245
- package/.claude/helpers/handlers/session-handler.cjs +182 -163
- package/.claude/helpers/handlers/session-restore-handler.cjs +95 -53
- package/.claude/helpers/handlers/task-handler.cjs +17 -160
- package/.claude/helpers/hook-handler.cjs +153 -16
- package/.claude/helpers/intelligence.cjs +255 -15
- package/.claude/helpers/learning-service.mjs +1 -0
- package/.claude/helpers/mastermind-activate.cjs +33 -51
- package/.claude/helpers/monolean-activate.cjs +13 -3
- package/.claude/helpers/monolean-propagate.cjs +7 -3
- package/.claude/helpers/router.cjs +122 -11
- package/.claude/helpers/skill-registry.json +0 -189
- package/.claude/skills/github-toolkit/SKILL.md +60 -0
- package/.claude/skills/hive-mind-advanced/SKILL.md +0 -15
- package/.claude/skills/hooks-automation/SKILL.md +0 -1
- package/.claude/skills/mastermind-skills/_protocol.md +1 -1
- package/.claude/skills/mastermind-skills/architect.md +5 -6
- package/.claude/skills/mastermind-skills/autodev.md +8 -5
- package/.claude/skills/mastermind-skills/build.md +1 -2
- package/.claude/skills/mastermind-skills/review.md +8 -5
- package/.claude/skills/mastermind-skills/techport.md +37 -3
- package/.claude/skills/memory-toolkit/SKILL.md +75 -0
- package/.claude/skills/monodesign/document.md +9 -6
- package/.claude/skills/monodesign/extract.md +1 -1
- package/.claude/skills/monodesign/reference/document.md +1 -1
- package/.claude/skills/monodesign/reference/live.md +1 -1
- package/.claude/skills/monolean/SKILL.md +1 -1
- package/.claude/skills/specialagent/SKILL.md +2 -4
- package/.claude/skills/swarm-advanced/SKILL.md +0 -1
- package/README.md +2 -5
- package/bin/mcp-server.js +11 -1
- package/dist/src/autopilot-state.d.ts.map +1 -1
- package/dist/src/autopilot-state.js +4 -5
- package/dist/src/autopilot-state.js.map +1 -1
- package/dist/src/browser/dashboard/server.d.ts.map +1 -1
- package/dist/src/browser/dashboard/server.js +69 -1
- package/dist/src/browser/dashboard/server.js.map +1 -1
- package/dist/src/browser/dashboard/ui.html +214 -1764
- package/dist/src/capabilities/index.d.ts +0 -2
- package/dist/src/capabilities/index.d.ts.map +1 -1
- package/dist/src/capabilities/index.js +0 -1
- package/dist/src/capabilities/index.js.map +1 -1
- package/dist/src/commands/agent-lifecycle.d.ts.map +1 -1
- package/dist/src/commands/agent-lifecycle.js +2 -6
- package/dist/src/commands/agent-lifecycle.js.map +1 -1
- package/dist/src/commands/agent-ops.d.ts +1 -2
- package/dist/src/commands/agent-ops.d.ts.map +1 -1
- package/dist/src/commands/agent-ops.js +1 -59
- package/dist/src/commands/agent-ops.js.map +1 -1
- package/dist/src/commands/agent.d.ts.map +1 -1
- package/dist/src/commands/agent.js +2 -3
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze-diff.js +1 -1
- package/dist/src/commands/analyze-diff.js.map +1 -1
- package/dist/src/commands/analyze.d.ts +0 -4
- package/dist/src/commands/analyze.d.ts.map +1 -1
- package/dist/src/commands/analyze.js +1 -29
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/browse-action.d.ts.map +1 -1
- package/dist/src/commands/browse-action.js +94 -2
- package/dist/src/commands/browse-action.js.map +1 -1
- package/dist/src/commands/completions.d.ts.map +1 -1
- package/dist/src/commands/completions.js +12 -76
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.d.ts.map +1 -1
- package/dist/src/commands/config.js +0 -6
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/doctor-project-checks.d.ts +13 -3
- package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
- package/dist/src/commands/doctor-project-checks.js +131 -23
- package/dist/src/commands/doctor-project-checks.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +6 -5
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/guidance.d.ts +5 -1
- package/dist/src/commands/guidance.d.ts.map +1 -1
- package/dist/src/commands/guidance.js +11 -556
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind-comms.d.ts.map +1 -1
- package/dist/src/commands/hive-mind-comms.js +11 -4
- package/dist/src/commands/hive-mind-comms.js.map +1 -1
- package/dist/src/commands/hive-mind-helpers.js +2 -2
- package/dist/src/commands/hive-mind-helpers.js.map +1 -1
- package/dist/src/commands/hive-mind-ops.d.ts +1 -3
- package/dist/src/commands/hive-mind-ops.d.ts.map +1 -1
- package/dist/src/commands/hive-mind-ops.js +2 -116
- package/dist/src/commands/hive-mind-ops.js.map +1 -1
- package/dist/src/commands/hive-mind.d.ts +4 -4
- package/dist/src/commands/hive-mind.d.ts.map +1 -1
- package/dist/src/commands/hive-mind.js +11 -11
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks-coverage-commands.d.ts.map +1 -1
- package/dist/src/commands/hooks-coverage-commands.js +8 -7
- package/dist/src/commands/hooks-coverage-commands.js.map +1 -1
- package/dist/src/commands/hooks-coverage-gaps.js +1 -1
- package/dist/src/commands/hooks-coverage-gaps.js.map +1 -1
- package/dist/src/commands/hooks-coverage-routing.js +2 -2
- package/dist/src/commands/hooks-coverage-routing.js.map +1 -1
- package/dist/src/commands/hooks-extended-commands.d.ts +0 -3
- package/dist/src/commands/hooks-extended-commands.d.ts.map +1 -1
- package/dist/src/commands/hooks-extended-commands.js +0 -307
- package/dist/src/commands/hooks-extended-commands.js.map +1 -1
- package/dist/src/commands/hooks-formatting.d.ts +1 -5
- package/dist/src/commands/hooks-formatting.d.ts.map +1 -1
- package/dist/src/commands/hooks-formatting.js +1 -18
- package/dist/src/commands/hooks-formatting.js.map +1 -1
- package/dist/src/commands/hooks-workers.d.ts +1 -1
- package/dist/src/commands/hooks-workers.d.ts.map +1 -1
- package/dist/src/commands/hooks-workers.js +82 -330
- package/dist/src/commands/hooks-workers.js.map +1 -1
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +1 -12
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +2 -55
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +23 -216
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init-wizard.d.ts.map +1 -1
- package/dist/src/commands/init-wizard.js +3 -5
- package/dist/src/commands/init-wizard.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +4 -24
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/mcp.d.ts.map +1 -1
- package/dist/src/commands/mcp.js +32 -4
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory-admin.d.ts +1 -2
- package/dist/src/commands/memory-admin.d.ts.map +1 -1
- package/dist/src/commands/memory-admin.js +1 -118
- package/dist/src/commands/memory-admin.js.map +1 -1
- package/dist/src/commands/memory-transfer.d.ts +1 -2
- package/dist/src/commands/memory-transfer.d.ts.map +1 -1
- package/dist/src/commands/memory-transfer.js +5 -171
- package/dist/src/commands/memory-transfer.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +3 -6
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/neural-core.d.ts +3 -1
- package/dist/src/commands/neural-core.d.ts.map +1 -1
- package/dist/src/commands/neural-core.js +154 -15
- package/dist/src/commands/neural-core.js.map +1 -1
- package/dist/src/commands/neural-optimize.d.ts.map +1 -1
- package/dist/src/commands/neural-optimize.js +13 -15
- package/dist/src/commands/neural-optimize.js.map +1 -1
- package/dist/src/commands/neural-registry.d.ts +1 -1
- package/dist/src/commands/neural-registry.js +14 -14
- package/dist/src/commands/neural-registry.js.map +1 -1
- package/dist/src/commands/neural.d.ts +1 -1
- package/dist/src/commands/neural.js +6 -6
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.d.ts.map +1 -1
- package/dist/src/commands/performance.js +68 -58
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/providers.d.ts.map +1 -1
- package/dist/src/commands/providers.js +77 -117
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/search-universal.d.ts +7 -1
- package/dist/src/commands/search-universal.d.ts.map +1 -1
- package/dist/src/commands/search-universal.js +59 -5
- package/dist/src/commands/search-universal.js.map +1 -1
- package/dist/src/commands/security-cve.d.ts.map +1 -1
- package/dist/src/commands/security-cve.js +3 -5
- package/dist/src/commands/security-cve.js.map +1 -1
- package/dist/src/commands/security-misc.d.ts +0 -1
- package/dist/src/commands/security-misc.d.ts.map +1 -1
- package/dist/src/commands/security-misc.js +69 -45
- package/dist/src/commands/security-misc.js.map +1 -1
- package/dist/src/commands/security.d.ts.map +1 -1
- package/dist/src/commands/security.js +2 -4
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.d.ts.map +1 -1
- package/dist/src/commands/session.js +137 -281
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.d.ts.map +1 -1
- package/dist/src/commands/start.js +2 -59
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +18 -29
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.d.ts.map +1 -1
- package/dist/src/commands/swarm.js +113 -66
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.d.ts.map +1 -1
- package/dist/src/commands/task.js +2 -49
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/consensus/audit-writer.d.ts.map +1 -1
- package/dist/src/consensus/audit-writer.js +43 -1
- package/dist/src/consensus/audit-writer.js.map +1 -1
- package/dist/src/consensus/tally.d.ts +19 -0
- package/dist/src/consensus/tally.d.ts.map +1 -0
- package/dist/src/consensus/tally.js +34 -0
- package/dist/src/consensus/tally.js.map +1 -0
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +13 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts.map +1 -1
- package/dist/src/init/claudemd-generator.js +10 -14
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +42 -100
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts.map +1 -1
- package/dist/src/init/helpers-generator.js +2 -22
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +0 -13
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.d.ts.map +1 -1
- package/dist/src/init/statusline-generator.js +62 -0
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +3 -9
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +0 -5
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/knowledge/document-pipeline.d.ts.map +1 -1
- package/dist/src/knowledge/document-pipeline.js +18 -8
- package/dist/src/knowledge/document-pipeline.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +0 -8
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp-server.js +14 -0
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +0 -17
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/coherence/causal-infer.d.ts +5 -5
- package/dist/src/mcp-tools/coherence/causal-infer.d.ts.map +1 -1
- package/dist/src/mcp-tools/coherence/causal-infer.js +32 -46
- package/dist/src/mcp-tools/coherence/causal-infer.js.map +1 -1
- package/dist/src/mcp-tools/coherence/coherence-check.d.ts.map +1 -1
- package/dist/src/mcp-tools/coherence/coherence-check.js +1 -19
- package/dist/src/mcp-tools/coherence/coherence-check.js.map +1 -1
- package/dist/src/mcp-tools/coherence/consensus-verify.d.ts +2 -3
- package/dist/src/mcp-tools/coherence/consensus-verify.d.ts.map +1 -1
- package/dist/src/mcp-tools/coherence/consensus-verify.js +22 -20
- package/dist/src/mcp-tools/coherence/consensus-verify.js.map +1 -1
- package/dist/src/mcp-tools/coherence/memory-gate.d.ts +3 -2
- package/dist/src/mcp-tools/coherence/memory-gate.d.ts.map +1 -1
- package/dist/src/mcp-tools/coherence/memory-gate.js +32 -19
- package/dist/src/mcp-tools/coherence/memory-gate.js.map +1 -1
- package/dist/src/mcp-tools/coherence/quantum-topology.d.ts +4 -4
- package/dist/src/mcp-tools/coherence/quantum-topology.d.ts.map +1 -1
- package/dist/src/mcp-tools/coherence/quantum-topology.js +11 -17
- package/dist/src/mcp-tools/coherence/quantum-topology.js.map +1 -1
- package/dist/src/mcp-tools/coherence/spectral-analyze.d.ts +2 -3
- package/dist/src/mcp-tools/coherence/spectral-analyze.d.ts.map +1 -1
- package/dist/src/mcp-tools/coherence/spectral-analyze.js +51 -32
- package/dist/src/mcp-tools/coherence/spectral-analyze.js.map +1 -1
- package/dist/src/mcp-tools/coherence/types.d.ts +8 -11
- package/dist/src/mcp-tools/coherence/types.d.ts.map +1 -1
- package/dist/src/mcp-tools/coherence/types.js +3 -18
- package/dist/src/mcp-tools/coherence/types.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +1 -7
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/graphify-tools.js +2 -2
- package/dist/src/mcp-tools/graphify-tools.js.map +1 -1
- package/dist/src/mcp-tools/guidance-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/guidance-tools.js +9 -19
- package/dist/src/mcp-tools/guidance-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +198 -40
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-advanced.d.ts +18 -0
- package/dist/src/mcp-tools/hooks-advanced.d.ts.map +1 -0
- package/dist/src/mcp-tools/hooks-advanced.js +25 -0
- package/dist/src/mcp-tools/hooks-advanced.js.map +1 -0
- package/dist/src/mcp-tools/hooks-intelligence.d.ts +4 -8
- package/dist/src/mcp-tools/hooks-intelligence.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-intelligence.js +33 -482
- package/dist/src/mcp-tools/hooks-intelligence.js.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.d.ts +1 -3
- package/dist/src/mcp-tools/hooks-routing.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.js +96 -202
- package/dist/src/mcp-tools/hooks-routing.js.map +1 -1
- package/dist/src/mcp-tools/hooks-synthesis.d.ts +31 -0
- package/dist/src/mcp-tools/hooks-synthesis.d.ts.map +1 -0
- package/dist/src/mcp-tools/hooks-synthesis.js +196 -0
- package/dist/src/mcp-tools/hooks-synthesis.js.map +1 -0
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +10 -11
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +0 -3
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +0 -4
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +24 -9
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/monograph-tools.d.ts +6 -0
- package/dist/src/mcp-tools/monograph-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph-tools.js +370 -95
- package/dist/src/mcp-tools/monograph-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.d.ts +8 -9
- package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +249 -539
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +5 -17
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js +2 -2
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js.map +1 -1
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +4 -4
- package/dist/src/mcp-tools/quality-tools.d.ts +7 -2
- package/dist/src/mcp-tools/quality-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/quality-tools.js +7 -257
- package/dist/src/mcp-tools/quality-tools.js.map +1 -1
- package/dist/src/mcp-tools/security-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/security-tools.js +103 -0
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts +9 -9
- package/dist/src/memory/intelligence.d.ts.map +1 -1
- package/dist/src/memory/intelligence.js +71 -59
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +1 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -1
- package/dist/src/memory/memory-bridge.js +47 -5
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-read.d.ts.map +1 -1
- package/dist/src/memory/memory-read.js +1 -19
- package/dist/src/memory/memory-read.js.map +1 -1
- package/dist/src/suggest.d.ts.map +1 -1
- package/dist/src/suggest.js +1 -12
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/store/discovery.d.ts +3 -2
- package/dist/src/transfer/store/discovery.d.ts.map +1 -1
- package/dist/src/transfer/store/discovery.js +22 -70
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/update/checker.d.ts.map +1 -1
- package/dist/src/update/checker.js +0 -1
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/utils/cosine-similarity.d.ts +22 -0
- package/dist/src/utils/cosine-similarity.d.ts.map +1 -0
- package/dist/src/utils/cosine-similarity.js +38 -0
- package/dist/src/utils/cosine-similarity.js.map +1 -0
- package/dist/src/utils/input-guards.d.ts +51 -0
- package/dist/src/utils/input-guards.d.ts.map +1 -0
- package/dist/src/utils/input-guards.js +223 -0
- package/dist/src/utils/input-guards.js.map +1 -0
- package/dist/src/utils/json-file.d.ts +33 -0
- package/dist/src/utils/json-file.d.ts.map +1 -0
- package/dist/src/utils/json-file.js +57 -0
- package/dist/src/utils/json-file.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -6
- package/scripts/sync-claude-assets.sh +16 -20
- package/.claude/agents/generated/case-analyst.md +0 -50
- package/.claude/agents/generated/channel-intelligence-director.md +0 -87
- package/.claude/agents/generated/chief-growth-officer.md +0 -88
- package/.claude/agents/generated/churn-analyst.md +0 -53
- package/.claude/agents/generated/code-reviewer.md +0 -55
- package/.claude/agents/generated/code-validator.md +0 -57
- package/.claude/agents/generated/complexity-scanner.md +0 -56
- package/.claude/agents/generated/content-seo-strategist.md +0 -90
- package/.claude/agents/generated/copy-editor.md +0 -45
- package/.claude/agents/generated/court-reporter.md +0 -50
- package/.claude/agents/generated/defender.md +0 -51
- package/.claude/agents/generated/devbot-orchestrator.md +0 -58
- package/.claude/agents/generated/devbot-planner.md +0 -63
- package/.claude/agents/generated/developer-community-strategist.md +0 -91
- package/.claude/agents/generated/editor-in-chief.md +0 -45
- package/.claude/agents/generated/fact-checker.md +0 -45
- package/.claude/agents/generated/impact-assessor.md +0 -54
- package/.claude/agents/generated/judge.md +0 -51
- package/.claude/agents/generated/outreach-partnership-strategist.md +0 -90
- package/.claude/agents/generated/prosecutor.md +0 -51
- package/.claude/agents/generated/reporter.md +0 -45
- package/.claude/agents/generated/social-media-strategist.md +0 -91
- package/.claude/agents/generated/video-visual-strategist.md +0 -90
- package/.claude/agents/reengineer-squad/boss.md +0 -113
- package/.claude/agents/reengineer-squad/critic-architect.md +0 -132
- package/.claude/agents/reengineer-squad/git-manager.md +0 -145
- package/.claude/agents/reengineer-squad/idea-generator.md +0 -95
- package/.claude/agents/reengineer-squad/implementer.md +0 -112
- package/.claude/agents/reengineer-squad/integration-planner.md +0 -112
- package/.claude/agents/reengineer-squad/source-analyst.md +0 -103
- package/.claude/agents/reengineer-squad/target-analyst.md +0 -118
- package/.claude/agents/reengineer-squad/tester.md +0 -105
- package/.claude/agents/sparc/architecture.md +0 -453
- package/.claude/agents/sparc/pseudocode.md +0 -299
- package/.claude/agents/sparc/refinement.md +0 -504
- package/.claude/agents/sparc/specification.md +0 -258
- package/.claude/agents/templates/implementer-sparc-coder.md +0 -231
- package/.claude/commands/sparc/analyzer.md +0 -35
- package/.claude/commands/sparc/architect.md +0 -36
- package/.claude/commands/sparc/ask.md +0 -56
- package/.claude/commands/sparc/batch-executor.md +0 -37
- package/.claude/commands/sparc/code.md +0 -48
- package/.claude/commands/sparc/coder.md +0 -37
- package/.claude/commands/sparc/debug.md +0 -42
- package/.claude/commands/sparc/debugger.md +0 -37
- package/.claude/commands/sparc/designer.md +0 -36
- package/.claude/commands/sparc/devops.md +0 -68
- package/.claude/commands/sparc/docs-writer.md +0 -39
- package/.claude/commands/sparc/documenter.md +0 -37
- package/.claude/commands/sparc/innovator.md +0 -37
- package/.claude/commands/sparc/integration.md +0 -42
- package/.claude/commands/sparc/mcp.md +0 -76
- package/.claude/commands/sparc/memory-manager.md +0 -57
- package/.claude/commands/sparc/optimizer.md +0 -37
- package/.claude/commands/sparc/orchestrator.md +0 -70
- package/.claude/commands/sparc/post-deployment-monitoring-mode.md +0 -42
- package/.claude/commands/sparc/refinement-optimization-mode.md +0 -42
- package/.claude/commands/sparc/researcher.md +0 -37
- package/.claude/commands/sparc/reviewer.md +0 -37
- package/.claude/commands/sparc/security-review.md +0 -39
- package/.claude/commands/sparc/sparc-modes.md +0 -120
- package/.claude/commands/sparc/sparc.md +0 -71
- package/.claude/commands/sparc/spec-pseudocode.md +0 -39
- package/.claude/commands/sparc/supabase-admin.md +0 -301
- package/.claude/commands/sparc/swarm-coordinator.md +0 -50
- package/.claude/commands/sparc/tdd.md +0 -37
- package/.claude/commands/sparc/tester.md +0 -37
- package/.claude/commands/sparc/tutorial.md +0 -38
- package/.claude/commands/sparc/workflow-manager.md +0 -37
- package/.claude/commands/sparc.md +0 -112
- package/.claude/helpers/auto-memory-hook.mjs +0 -503
- package/.claude/skills/sparc-methodology/SKILL.md +0 -950
- package/dist/src/capabilities/enrichment.d.ts +0 -44
- package/dist/src/capabilities/enrichment.d.ts.map +0 -1
- package/dist/src/capabilities/enrichment.js +0 -141
- package/dist/src/capabilities/enrichment.js.map +0 -1
- package/dist/src/commands/analyze-boundaries.d.ts +0 -14
- package/dist/src/commands/analyze-boundaries.d.ts.map +0 -1
- package/dist/src/commands/analyze-boundaries.js +0 -295
- package/dist/src/commands/analyze-boundaries.js.map +0 -1
- package/dist/src/commands/analyze-graph.d.ts +0 -14
- package/dist/src/commands/analyze-graph.d.ts.map +0 -1
- package/dist/src/commands/analyze-graph.js +0 -304
- package/dist/src/commands/analyze-graph.js.map +0 -1
- package/dist/src/commands/claims.d.ts +0 -10
- package/dist/src/commands/claims.d.ts.map +0 -1
- package/dist/src/commands/claims.js +0 -650
- package/dist/src/commands/claims.js.map +0 -1
- package/dist/src/commands/daemon.d.ts +0 -8
- package/dist/src/commands/daemon.d.ts.map +0 -1
- package/dist/src/commands/daemon.js +0 -681
- package/dist/src/commands/daemon.js.map +0 -1
- package/dist/src/commands/deployment.d.ts +0 -10
- package/dist/src/commands/deployment.d.ts.map +0 -1
- package/dist/src/commands/deployment.js +0 -706
- package/dist/src/commands/deployment.js.map +0 -1
- package/dist/src/commands/enrich.d.ts +0 -10
- package/dist/src/commands/enrich.d.ts.map +0 -1
- package/dist/src/commands/enrich.js +0 -58
- package/dist/src/commands/enrich.js.map +0 -1
- package/dist/src/commands/issues.d.ts +0 -21
- package/dist/src/commands/issues.d.ts.map +0 -1
- package/dist/src/commands/issues.js +0 -575
- package/dist/src/commands/issues.js.map +0 -1
- package/dist/src/commands/workflow.d.ts +0 -8
- package/dist/src/commands/workflow.d.ts.map +0 -1
- package/dist/src/commands/workflow.js +0 -677
- package/dist/src/commands/workflow.js.map +0 -1
- package/dist/src/mcp-tools/workflow-tools.d.ts +0 -8
- package/dist/src/mcp-tools/workflow-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/workflow-tools.js +0 -717
- package/dist/src/mcp-tools/workflow-tools.js.map +0 -1
- package/dist/src/services/claim-service.d.ts +0 -198
- package/dist/src/services/claim-service.d.ts.map +0 -1
- package/dist/src/services/claim-service.js +0 -890
- package/dist/src/services/claim-service.js.map +0 -1
- package/dist/src/services/headless-worker-executor.d.ts +0 -311
- package/dist/src/services/headless-worker-executor.d.ts.map +0 -1
- package/dist/src/services/headless-worker-executor.js +0 -1183
- package/dist/src/services/headless-worker-executor.js.map +0 -1
- package/dist/src/services/worker-daemon.d.ts +0 -248
- package/dist/src/services/worker-daemon.d.ts.map +0 -1
- package/dist/src/services/worker-daemon.js +0 -1417
- package/dist/src/services/worker-daemon.js.map +0 -1
- package/dist/src/ui/.monomind/capture/active-run.json +0 -1
- package/dist/src/ui/.monomind/orgs/system-trial-qa/runs/real-events-1782290897.convs.jsonl +0 -3
- package/dist/src/ui/.monomind/orgs/system-trial-qa/runs/real-events-1782290897.jsonl +0 -11
- package/dist/src/ui/.monomind/orgs/system-trial-qa/runs/rigid-qa-restart-1782288201.jsonl +0 -540
- package/dist/src/ui/.monomind/orgs/system-trial-qa-threads.jsonl +0 -3
- package/dist/src/ui/.monomind/orgs/test-event-fix/runs/rigid-qa-restart-1782288201.jsonl +0 -2
|
@@ -22,29 +22,18 @@ module.exports = {
|
|
|
22
22
|
console.log('[SESSION] Skipping consolidation — daemon holds lock');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (consResult.newEntries > 0) msg += ', ' + consResult.newEntries + ' new';
|
|
31
|
-
msg += ', PageRank recomputed';
|
|
32
|
-
console.log(msg);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
if (session && session.end) {
|
|
37
|
-
session.end();
|
|
38
|
-
} else {
|
|
39
|
-
console.log('[OK] Session ended');
|
|
40
|
-
}
|
|
41
|
-
} catch (e) { console.log('[WARN] Session end failed: ' + e.message); }
|
|
25
|
+
// ── Session-end feedback BEFORE consolidation ──────────────────────────
|
|
26
|
+
// IMPORTANT: feedback() must run BEFORE consolidate() so that the session-end
|
|
27
|
+
// outcome record captures recentEdits from disk. consolidate() clears
|
|
28
|
+
// recent-edits.jsonl, so calling it first leaves the outcome empty.
|
|
29
|
+
// (Fixed: all outcomes previously had recentEdits: [].)
|
|
42
30
|
|
|
43
31
|
// ── Routing Feedback Loop (SE-001) ────────────────────────────────────
|
|
44
32
|
// Persist routing accuracy feedback so the router improves over sessions.
|
|
45
33
|
// sessionSuccess is derived from intelligence-outcomes.jsonl entries written
|
|
46
34
|
// during this session (last 30 minutes). A session is marked failed when the
|
|
47
35
|
// majority of feedback() calls carried success=false in that window.
|
|
36
|
+
var sessionSuccess = null; // null = no evidence; only set to a boolean from real signals
|
|
48
37
|
try {
|
|
49
38
|
var feedbackPath = path.join(CWD, '.monomind', 'routing-feedback.jsonl');
|
|
50
39
|
var lastRoutePath = path.join(CWD, '.monomind', 'last-route.json');
|
|
@@ -52,80 +41,106 @@ module.exports = {
|
|
|
52
41
|
if (fs.existsSync(lastRoutePath) && (function() { try { return fs.statSync(lastRoutePath).size <= MAX_ROUTE; } catch(_) { return false; } }())) {
|
|
53
42
|
var lastRoute = JSON.parse(fs.readFileSync(lastRoutePath, 'utf-8'));
|
|
54
43
|
|
|
55
|
-
// Derive sessionSuccess from
|
|
56
|
-
var sessionSuccess = true; // optimistic default when no signal exists
|
|
44
|
+
// Derive sessionSuccess from git commits (strongest signal: user committed = success)
|
|
57
45
|
try {
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
46
|
+
var execSync = require('child_process').execSync;
|
|
47
|
+
var recentCommits = execSync('git log --oneline --since="30 minutes ago" 2>/dev/null || true', { cwd: CWD, timeout: 3000, encoding: 'utf-8' }).trim();
|
|
48
|
+
if (recentCommits.length > 0) {
|
|
49
|
+
sessionSuccess = true;
|
|
50
|
+
} else {
|
|
51
|
+
// No commits — check if files were modified (work in progress, not failure)
|
|
52
|
+
var gitStatus = execSync('git diff --name-only 2>/dev/null || true', { cwd: CWD, timeout: 3000, encoding: 'utf-8' }).trim();
|
|
53
|
+
// Modified files = probably still working; no changes at all = exploration or failure
|
|
54
|
+
if (gitStatus.length === 0) {
|
|
55
|
+
// Fall back to intelligence-outcomes as a weak signal
|
|
56
|
+
var outcomesPath = path.join(CWD, '.monomind', 'data', 'intelligence-outcomes.jsonl');
|
|
57
|
+
var MAX_OUTCOMES = 512 * 1024;
|
|
58
|
+
if (fs.existsSync(outcomesPath) && (function() { try { return fs.statSync(outcomesPath).size <= MAX_OUTCOMES; } catch(_) { return false; } }())) {
|
|
59
|
+
var windowMs = 30 * 60 * 1000;
|
|
60
|
+
var cutoff = Date.now() - windowMs;
|
|
61
|
+
var outcomeLines = fs.readFileSync(outcomesPath, 'utf-8').trim().split('\n').filter(Boolean);
|
|
62
|
+
var recent = outcomeLines.map(function(l) {
|
|
63
|
+
try { return JSON.parse(l); } catch { return null; }
|
|
64
|
+
}).filter(function(e) { return e && e.ts && e.ts >= cutoff; });
|
|
65
|
+
if (recent.length > 0) {
|
|
66
|
+
var failures = recent.filter(function(e) { return e.success === false; }).length;
|
|
67
|
+
sessionSuccess = failures / recent.length < 0.5;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
71
70
|
}
|
|
71
|
+
// else: modified files exist — work in progress, not evidence either way (leave null)
|
|
72
72
|
}
|
|
73
|
-
} catch (e) { /* non-critical —
|
|
73
|
+
} catch (e) { /* non-critical — leave null (no evidence) */ }
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
// Record session-end feedback WITH recentEdits (before consolidate clears them)
|
|
76
|
+
if (intelligence && intelligence.feedback && typeof sessionSuccess === 'boolean') {
|
|
76
77
|
try { intelligence.feedback(sessionSuccess); } catch (e) { /* non-fatal */ }
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
79
|
+
// Normalize agent label to a lowercase slug ("Coder" → "coder", "backend dev" → "backend-dev")
|
|
80
|
+
var agentSlug = String(lastRoute.agent || '').trim().toLowerCase().replace(/\s+/g, '-');
|
|
81
|
+
// Skip non-agent placeholders — "AI selecting" etc. carry no routing signal
|
|
82
|
+
if (agentSlug && agentSlug !== 'ai-selecting' && agentSlug !== 'unknown') {
|
|
83
|
+
var feedbackEntry = {
|
|
84
|
+
timestamp: new Date().toISOString(),
|
|
85
|
+
suggestedAgent: agentSlug,
|
|
86
|
+
confidence: lastRoute.confidence,
|
|
87
|
+
sessionId: String(hookInput.sessionId || hookInput.session_id || '').slice(0, 128),
|
|
88
|
+
};
|
|
89
|
+
// Only write the success flag when derived from actual evidence (commits, outcomes)
|
|
90
|
+
if (typeof sessionSuccess === 'boolean') feedbackEntry.intelligenceFeedback = sessionSuccess;
|
|
91
|
+
fs.appendFileSync(feedbackPath, JSON.stringify(feedbackEntry) + '\n', 'utf-8');
|
|
92
|
+
// Rotate: keep last 1000 lines to prevent unbounded growth
|
|
93
|
+
try {
|
|
94
|
+
var MAX_FEEDBACK = 512 * 1024; // 512 KiB
|
|
95
|
+
if (fs.existsSync(feedbackPath) && fs.statSync(feedbackPath).size > MAX_FEEDBACK) {
|
|
96
|
+
// File too large — emergency trim without full read
|
|
97
|
+
throw new Error('skip-rotation');
|
|
98
|
+
}
|
|
99
|
+
var raw = fs.readFileSync(feedbackPath, 'utf-8');
|
|
100
|
+
var lines = raw.split('\n').filter(Boolean);
|
|
101
|
+
if (lines.length > 1000) {
|
|
102
|
+
fs.writeFileSync(feedbackPath, lines.slice(-1000).join('\n') + '\n', 'utf-8');
|
|
103
|
+
}
|
|
104
|
+
} catch (e2) { /* rotation is best-effort */ }
|
|
105
|
+
}
|
|
99
106
|
}
|
|
100
107
|
} catch (e) { /* non-fatal */ }
|
|
101
108
|
|
|
102
|
-
//
|
|
109
|
+
// Now consolidate AFTER feedback has been recorded (so the outcome has recentEdits)
|
|
110
|
+
if (!daemonHoldsLock && intelligence && intelligence.consolidate) {
|
|
111
|
+
var consResult = await hCtx.runWithTimeout(function() { return intelligence.consolidate(); }, 'intelligence.consolidate()');
|
|
112
|
+
if (consResult && consResult.entries > 0) {
|
|
113
|
+
var msg = '[INTELLIGENCE] Consolidated: ' + consResult.entries + ' entries';
|
|
114
|
+
if (consResult.newEntries > 0) msg += ', ' + consResult.newEntries + ' new patterns learned';
|
|
115
|
+
console.log(msg);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
if (session && session.end) {
|
|
120
|
+
session.end();
|
|
121
|
+
} else {
|
|
122
|
+
console.log('[OK] Session ended');
|
|
123
|
+
}
|
|
124
|
+
} catch (e) { console.log('[WARN] Session end failed: ' + e.message); }
|
|
103
125
|
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (!daemonHoldsLock) {
|
|
126
|
+
// Bridge to @monomind/hooks registry — fires SessionEnd hooks (episode-binner closeEpisode, observability bus).
|
|
127
|
+
// Each hook event runs in a fresh process, so hCtx._hooksModule set by session-restore in an
|
|
128
|
+
// earlier invocation is never visible here — must (re)load lazily via _ensureHooksModule().
|
|
129
|
+
var _hooksModule = hCtx._hooksModule || (hCtx._ensureHooksModule ? await hCtx._ensureHooksModule() : null);
|
|
130
|
+
if (_hooksModule && _hooksModule.executeHooks && _hooksModule.HookEvent) {
|
|
110
131
|
try {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
var promResult = await hCtx.runWithTimeout(function() { return ls.promoteEpisodic(); }, 'learning.promoteEpisodic()');
|
|
121
|
-
if (promResult && promResult.promoted > 0) {
|
|
122
|
-
console.log('[LEARNING] Promoted ' + promResult.promoted + ' episodic patterns to semantic memory');
|
|
123
|
-
}
|
|
124
|
-
} catch (e) { /* non-fatal */ }
|
|
125
|
-
}
|
|
126
|
-
} catch (e) { /* non-fatal — learning-service may need better-sqlite3 */ }
|
|
132
|
+
await _hooksModule.executeHooks(_hooksModule.HookEvent.SessionEnd, {
|
|
133
|
+
session: {
|
|
134
|
+
id: String(hookInput.sessionId || hookInput.session_id || ''),
|
|
135
|
+
startedAt: new Date(),
|
|
136
|
+
},
|
|
137
|
+
success: sessionSuccess !== false, // null (no evidence) still counts as non-failure here
|
|
138
|
+
}, { continueOnError: true, timeout: 2000 });
|
|
139
|
+
} catch (e) { /* non-fatal */ }
|
|
127
140
|
}
|
|
128
141
|
|
|
142
|
+
// Memory Palace tombstone writes removed — redundant with raw session JSONL
|
|
143
|
+
|
|
129
144
|
// ── Context Persistence Auto-Archive ─────────────────────────────────
|
|
130
145
|
// Archive conversation context so it survives compaction and new sessions
|
|
131
146
|
try {
|
|
@@ -139,99 +154,103 @@ module.exports = {
|
|
|
139
154
|
}
|
|
140
155
|
} catch (e) { /* non-fatal — context-persistence may not export archive() */ }
|
|
141
156
|
|
|
142
|
-
// ──
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
|
|
157
|
+
// ── Auto-populate: write session episode for every session ─────
|
|
158
|
+
// Even solo sessions (no subagents) produce an episode so the
|
|
159
|
+
// route handler can surface relevant past sessions.
|
|
160
|
+
try {
|
|
161
|
+
var episodicDir = path.join(CWD, '.monomind', 'episodic');
|
|
162
|
+
fs.mkdirSync(episodicDir, { recursive: true });
|
|
163
|
+
var epPath = path.join(episodicDir, 'episodes.jsonl');
|
|
164
|
+
|
|
165
|
+
// Collect session context
|
|
166
|
+
var sessId = String(hookInput.sessionId || hookInput.session_id || process.env.CLAUDE_SESSION_ID || '');
|
|
167
|
+
var lastRouteFile = path.join(CWD, '.monomind', 'last-route.json');
|
|
168
|
+
var routeAgent = 'unknown';
|
|
169
|
+
var routePrompt = '';
|
|
146
170
|
try {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (episodes.length >= 5) {
|
|
154
|
-
// Get learning service for scaffold optimizer metrics
|
|
155
|
-
var ls2 = await hCtx.getLearningService();
|
|
156
|
-
|
|
157
|
-
// Phase 2a: Scaffold optimization (gated revision)
|
|
158
|
-
if (ls2 && ls2.getLearningBridge) {
|
|
159
|
-
try {
|
|
160
|
-
var bridge = ls2.getLearningBridge();
|
|
161
|
-
if (bridge) {
|
|
162
|
-
// Load tunable thresholds from .monomind/automem-config.json
|
|
163
|
-
var scaffoldConfig = {};
|
|
164
|
-
try {
|
|
165
|
-
var amcPath = path.join(CWD, '.monomind', 'automem-config.json');
|
|
166
|
-
if (fs.existsSync(amcPath) && fs.statSync(amcPath).size < 64 * 1024) {
|
|
167
|
-
var amc = JSON.parse(fs.readFileSync(amcPath, 'utf-8'));
|
|
168
|
-
if (amc.scaffold) scaffoldConfig = amc.scaffold;
|
|
169
|
-
}
|
|
170
|
-
} catch (e5) { /* non-fatal */ }
|
|
171
|
-
var optimizer = new memMod.ScaffoldOptimizer(scaffoldConfig);
|
|
172
|
-
var optResult = await hCtx.runWithTimeout(function() { return optimizer.optimize(epStore, bridge); }, 'scaffold.optimize()');
|
|
173
|
-
if (optResult && optResult.accepted.length > 0) {
|
|
174
|
-
console.log('[AUTOMEM_SCAFFOLD] Accepted ' + optResult.accepted.length + ' revision(s): ' + optResult.accepted.map(function(r) { return r.description; }).join(', '));
|
|
175
|
-
// Persist revisions for diagnostics
|
|
176
|
-
try {
|
|
177
|
-
var revPath = path.join(CWD, '.monomind', 'data', 'scaffold-revisions.jsonl');
|
|
178
|
-
fs.mkdirSync(path.dirname(revPath), { recursive: true });
|
|
179
|
-
optResult.accepted.forEach(function(r) {
|
|
180
|
-
fs.appendFileSync(revPath, JSON.stringify(r) + '\n', 'utf-8');
|
|
181
|
-
});
|
|
182
|
-
} catch (e6) { /* non-fatal */ }
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
} catch (e3) { /* non-fatal */ }
|
|
186
|
-
}
|
|
171
|
+
if (fs.existsSync(lastRouteFile) && fs.statSync(lastRouteFile).size < 16384) {
|
|
172
|
+
var lr = JSON.parse(fs.readFileSync(lastRouteFile, 'utf-8'));
|
|
173
|
+
routeAgent = lr.agent || 'unknown';
|
|
174
|
+
routePrompt = lr.prompt || '';
|
|
175
|
+
}
|
|
176
|
+
} catch (e) {}
|
|
187
177
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
178
|
+
// Strip system noise (task notifications, XML tags) from prompt
|
|
179
|
+
if (routePrompt && (routePrompt.includes('<task-notification>') || routePrompt.includes('<system-reminder>'))) {
|
|
180
|
+
routePrompt = '';
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Determine session success from git commits (strongest signal)
|
|
184
|
+
var sessionOutcome = 'unknown';
|
|
185
|
+
var commitMessages = [];
|
|
186
|
+
var editedFiles = [];
|
|
187
|
+
try {
|
|
188
|
+
var execSync = require('child_process').execSync;
|
|
189
|
+
// Get recent commits as success signal
|
|
190
|
+
var commitLog = execSync('git log --oneline --since="30 minutes ago" 2>/dev/null || true', { cwd: CWD, timeout: 3000, encoding: 'utf-8' }).trim();
|
|
191
|
+
if (commitLog.length > 0) {
|
|
192
|
+
sessionOutcome = 'success';
|
|
193
|
+
commitMessages = commitLog.split('\n').filter(Boolean).map(function(l) {
|
|
194
|
+
return l.replace(/^[a-f0-9]+ /, '');
|
|
195
|
+
}).slice(0, 5);
|
|
196
|
+
}
|
|
197
|
+
// Get modified files from working tree
|
|
198
|
+
var diffOut = execSync('git diff --name-only HEAD 2>/dev/null || true', { cwd: CWD, timeout: 3000, encoding: 'utf-8' });
|
|
199
|
+
editedFiles = diffOut.trim().split('\n').filter(Boolean).map(function(f) { return path.basename(f); }).slice(0, 15);
|
|
200
|
+
if (sessionOutcome === 'unknown' && editedFiles.length > 0) {
|
|
201
|
+
sessionOutcome = 'in-progress';
|
|
202
|
+
}
|
|
203
|
+
} catch (e) {}
|
|
204
|
+
|
|
205
|
+
// Write episode with rich searchable content (commit messages are the user's own words)
|
|
206
|
+
var summaryParts = [];
|
|
207
|
+
if (routePrompt) summaryParts.push(routePrompt.slice(0, 300));
|
|
208
|
+
if (commitMessages.length > 0) summaryParts.push('Commits: ' + commitMessages.join('; '));
|
|
209
|
+
if (editedFiles.length > 0) summaryParts.push('Modified: ' + editedFiles.join(', '));
|
|
210
|
+
if (sessionOutcome !== 'unknown') summaryParts.push('Outcome: ' + sessionOutcome);
|
|
211
|
+
if (summaryParts.length === 0) summaryParts.push('Session with ' + routeAgent);
|
|
212
|
+
|
|
213
|
+
var soloEpisode = {
|
|
214
|
+
episodeId: require('crypto').randomUUID(),
|
|
215
|
+
sessionId: sessId,
|
|
216
|
+
runIds: [sessId],
|
|
217
|
+
summary: summaryParts.join('\n'),
|
|
218
|
+
startedAt: Date.now() - 300000,
|
|
219
|
+
endedAt: Date.now(),
|
|
220
|
+
agentSlugs: [routeAgent],
|
|
221
|
+
taskTypes: [routeAgent],
|
|
222
|
+
tokenEstimate: 0
|
|
223
|
+
};
|
|
224
|
+
fs.appendFileSync(epPath, JSON.stringify(soloEpisode) + '\n', 'utf-8');
|
|
225
|
+
|
|
226
|
+
// Rotate: keep last 500 episodes
|
|
227
|
+
try {
|
|
228
|
+
var epStat = fs.statSync(epPath);
|
|
229
|
+
if (epStat.size > 256 * 1024) {
|
|
230
|
+
var epLines = fs.readFileSync(epPath, 'utf-8').trim().split('\n').filter(Boolean);
|
|
231
|
+
if (epLines.length > 500) {
|
|
232
|
+
fs.writeFileSync(epPath, epLines.slice(-500).join('\n') + '\n', 'utf-8');
|
|
200
233
|
}
|
|
201
234
|
}
|
|
202
|
-
} catch (
|
|
203
|
-
}
|
|
235
|
+
} catch (e) {}
|
|
236
|
+
} catch (e) { /* non-fatal */ }
|
|
204
237
|
|
|
205
|
-
// ──
|
|
206
|
-
// Process and clean up any pending worker dispatch files
|
|
238
|
+
// ── Memory ops summary ──────────────────────────────────────
|
|
207
239
|
try {
|
|
208
|
-
var
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
240
|
+
var memOpsSessionId = String(hookInput.sessionId || hookInput.session_id || process.env.CLAUDE_SESSION_ID || '');
|
|
241
|
+
var memOpsPath = path.join(CWD, '.monomind', 'memory-ops-' + memOpsSessionId.slice(0, 16) + '.json');
|
|
242
|
+
if (fs.existsSync(memOpsPath)) {
|
|
243
|
+
var memOps = JSON.parse(fs.readFileSync(memOpsPath, 'utf-8'));
|
|
244
|
+
if (memOps.writes > 0 || memOps.searches > 0) {
|
|
245
|
+
var parts = [];
|
|
246
|
+
if (memOps.writes > 0) parts.push(memOps.writes + ' writes' + (memOps.redundantWrites > 0 ? ' (' + memOps.redundantWrites + ' redundant)' : ''));
|
|
247
|
+
if (memOps.searches > 0) parts.push(memOps.searches + ' searches' + (memOps.emptySearches > 0 ? ' (' + memOps.emptySearches + ' empty)' : ''));
|
|
248
|
+
console.log('[MEMORY_OPS] Session: ' + parts.join(', '));
|
|
213
249
|
}
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
fs.mkdirSync(processedDir, { recursive: true });
|
|
217
|
-
pending.forEach(function(f) {
|
|
218
|
-
try {
|
|
219
|
-
fs.renameSync(path.join(dispatchDir, f), path.join(processedDir, f));
|
|
220
|
-
} catch (e) { /* ignore */ }
|
|
221
|
-
});
|
|
222
|
-
// Trim processed/ to last 200 files to prevent unbounded growth
|
|
223
|
-
try {
|
|
224
|
-
var processedFiles = fs.readdirSync(processedDir)
|
|
225
|
-
.filter(function(f) { return f.startsWith('pending-'); })
|
|
226
|
-
.map(function(f) { var fp = path.join(processedDir, f); var mt = 0; try { mt = fs.statSync(fp).mtimeMs; } catch(e2){} return { f: f, mt: mt }; })
|
|
227
|
-
.sort(function(a, b) { return a.mt - b.mt; });
|
|
228
|
-
if (processedFiles.length > 200) {
|
|
229
|
-
processedFiles.slice(0, processedFiles.length - 200).forEach(function(item) {
|
|
230
|
-
try { fs.unlinkSync(path.join(processedDir, item.f)); } catch (e2) { /* ignore */ }
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
} catch (e2) { /* non-fatal */ }
|
|
250
|
+
// Clean up session stats file
|
|
251
|
+
try { fs.unlinkSync(memOpsPath); } catch (e) {}
|
|
234
252
|
}
|
|
235
253
|
} catch (e) { /* non-fatal */ }
|
|
254
|
+
|
|
236
255
|
}
|
|
237
256
|
};
|
|
@@ -30,6 +30,21 @@ module.exports = {
|
|
|
30
30
|
}
|
|
31
31
|
} catch (e) { console.log('[WARN] Session restore failed: ' + e.message); }
|
|
32
32
|
|
|
33
|
+
// ── Non-blocking security scan via @monomind/hooks worker ─────────────
|
|
34
|
+
// The hooks package ships a security worker (worker-security.ts) that scans
|
|
35
|
+
// for hardcoded secrets and vulnerability patterns. We run it at session
|
|
36
|
+
// start as a fire-and-forget check — failures are silently ignored since
|
|
37
|
+
// the package may not be installed or built.
|
|
38
|
+
try {
|
|
39
|
+
var hooksWorkersMod = require('@monomind/hooks/dist/workers/worker-security.js');
|
|
40
|
+
var _createSecurityWorker = hooksWorkersMod.createSecurityWorker;
|
|
41
|
+
if (typeof _createSecurityWorker === 'function') {
|
|
42
|
+
var _securityScan = _createSecurityWorker(CWD);
|
|
43
|
+
// Fire-and-forget: do not await — must not delay session restore
|
|
44
|
+
Promise.resolve(_securityScan()).catch(function() {});
|
|
45
|
+
}
|
|
46
|
+
} catch (e) { /* @monomind/hooks not available or not built — skip */ }
|
|
47
|
+
|
|
33
48
|
// Stale helper detection — warn when project helpers drift from the bundled npm copy.
|
|
34
49
|
// Skip when running inside the monomind dev repo itself: local helpers ARE the
|
|
35
50
|
// source of truth there, so any diff vs. the npm global install is expected.
|
|
@@ -105,15 +120,92 @@ module.exports = {
|
|
|
105
120
|
}
|
|
106
121
|
|
|
107
122
|
// Bridge to @monomind/hooks compiled workers (GAP-001).
|
|
123
|
+
// Uses the shared hCtx._ensureHooksModule() (defined in hook-handler.cjs) so worker
|
|
124
|
+
// registration happens exactly once per process instead of being duplicated here —
|
|
125
|
+
// every other bridging handler (agent-start, pre-task, post-task, post-edit,
|
|
126
|
+
// session-end) calls the same lazy loader since each hook event is its own process.
|
|
108
127
|
try {
|
|
109
|
-
var hooksModule = await import('@monomind/hooks');
|
|
110
|
-
if (hooksModule
|
|
111
|
-
await runWithTimeout(function() { return hooksModule.initDefaultWorkers(); }, '@monomind/hooks.initDefaultWorkers()');
|
|
128
|
+
var hooksModule = hCtx._ensureHooksModule ? await hCtx._ensureHooksModule() : await import('@monomind/hooks');
|
|
129
|
+
if (hooksModule) {
|
|
112
130
|
hCtx._hooksModule = hooksModule;
|
|
113
131
|
console.log('[INFO] @monomind/hooks workers initialized');
|
|
132
|
+
|
|
133
|
+
// Gate enforcement lives entirely in gates-handler.cjs (its own regex
|
|
134
|
+
// table, run on every PreToolUse). The @monomind/guidance package that
|
|
135
|
+
// used to compile gate configs here was removed.
|
|
136
|
+
|
|
137
|
+
// Fire SessionStart event so observability bus and other SessionStart hooks activate
|
|
138
|
+
if (hooksModule.executeHooks && hooksModule.HookEvent) {
|
|
139
|
+
try {
|
|
140
|
+
await runWithTimeout(function() {
|
|
141
|
+
return hooksModule.executeHooks(hooksModule.HookEvent.SessionStart, {
|
|
142
|
+
session: {
|
|
143
|
+
id: String(hookInput.sessionId || hookInput.session_id || ''),
|
|
144
|
+
startedAt: new Date(),
|
|
145
|
+
},
|
|
146
|
+
}, { continueOnError: true, timeout: 1500 });
|
|
147
|
+
}, '@monomind/hooks.SessionStart');
|
|
148
|
+
} catch (e2) { /* non-fatal */ }
|
|
149
|
+
}
|
|
114
150
|
}
|
|
115
151
|
} catch (e) { /* @monomind/hooks not compiled yet — skip */ }
|
|
116
152
|
|
|
153
|
+
// Refresh worker metrics once per session start — the statusline
|
|
154
|
+
// (.claude/helpers/statusline.cjs) reads .monomind/metrics/ddd-progress.json,
|
|
155
|
+
// route-handler.cjs and doctor read codebase-map/security-audit/performance/
|
|
156
|
+
// consolidation.json; the @monomind/hooks workers are never otherwise
|
|
157
|
+
// scheduled on the live hook path (the worker daemon that used to produce
|
|
158
|
+
// these files was deleted).
|
|
159
|
+
//
|
|
160
|
+
// Staleness gating keeps session start fast: the metrics-producing workers
|
|
161
|
+
// only run when their output file is missing or older than 6 hours (ddd is
|
|
162
|
+
// refreshed every session, as before). Each run is capped by runWithTimeout
|
|
163
|
+
// (1.5s) — on timeout the awaiting stops but the worker keeps running and
|
|
164
|
+
// flushes atomically via tmp+rename, so a slow worker never blocks session
|
|
165
|
+
// start and never leaves a partial file.
|
|
166
|
+
try {
|
|
167
|
+
var _metricsDir = path.join(CWD, '.monomind', 'metrics');
|
|
168
|
+
fs.mkdirSync(_metricsDir, { recursive: true });
|
|
169
|
+
var STALE_MS = 6 * 60 * 60 * 1000; // 6 hours
|
|
170
|
+
var _isStale = function(outFile) {
|
|
171
|
+
try {
|
|
172
|
+
var st = fs.statSync(path.join(_metricsDir, outFile));
|
|
173
|
+
return (Date.now() - st.mtimeMs) > STALE_MS;
|
|
174
|
+
} catch (e) { return true; } // missing → run
|
|
175
|
+
};
|
|
176
|
+
var _hooksWorkers = [
|
|
177
|
+
{ factory: 'createDDDWorker', file: 'worker-ddd.js', out: 'ddd-progress.json', always: true },
|
|
178
|
+
{ factory: 'createMapWorker', file: 'worker-map.js', out: 'codebase-map.json' },
|
|
179
|
+
{ factory: 'createAuditWorker', file: 'worker-audit.js', out: 'security-audit.json' },
|
|
180
|
+
{ factory: 'createOptimizeWorker', file: 'worker-optimize.js', out: 'performance.json' },
|
|
181
|
+
{ factory: 'createConsolidateWorker', file: 'worker-consolidate.js', out: 'consolidation.json' },
|
|
182
|
+
];
|
|
183
|
+
var _hooksDistDir = path.join(CWD, 'packages', '@monomind', 'hooks', 'dist', 'workers');
|
|
184
|
+
for (var wi = 0; wi < _hooksWorkers.length; wi++) {
|
|
185
|
+
var _w = _hooksWorkers[wi];
|
|
186
|
+
if (!_w.always && !_isStale(_w.out)) continue;
|
|
187
|
+
try {
|
|
188
|
+
var _create = (hooksModule && typeof hooksModule[_w.factory] === 'function')
|
|
189
|
+
? hooksModule[_w.factory] : null;
|
|
190
|
+
if (!_create) {
|
|
191
|
+
// Dev-repo fallback: bare '@monomind/hooks' does not resolve from .claude/helpers
|
|
192
|
+
// in the monorepo (pnpm workspace link lives under packages/@monomind/cli), so
|
|
193
|
+
// import the compiled worker directly by path.
|
|
194
|
+
var _wDist = path.join(_hooksDistDir, _w.file);
|
|
195
|
+
if (fs.existsSync(_wDist)) {
|
|
196
|
+
var _wMod = await import('file://' + _wDist);
|
|
197
|
+
if (_wMod && typeof _wMod[_w.factory] === 'function') _create = _wMod[_w.factory];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (_create) {
|
|
201
|
+
var _wRun = _create(CWD);
|
|
202
|
+
// runWithTimeout caps each at 1.5s so a slow worker can never block session start.
|
|
203
|
+
await runWithTimeout(function() { return _wRun(); }, '@monomind/hooks.' + _w.factory);
|
|
204
|
+
}
|
|
205
|
+
} catch (e) { /* non-fatal — worker unavailable */ }
|
|
206
|
+
}
|
|
207
|
+
} catch (e) { /* non-fatal — hooks workers unavailable */ }
|
|
208
|
+
|
|
117
209
|
// Context Persistence Auto-Restore
|
|
118
210
|
try {
|
|
119
211
|
var cpHook = await import('file://' + path.join(helpersDir, 'context-persistence-hook.mjs'));
|
|
@@ -260,46 +352,6 @@ module.exports = {
|
|
|
260
352
|
} catch (e) {}
|
|
261
353
|
} catch (e) { /* non-fatal */ }
|
|
262
354
|
|
|
263
|
-
// Daemon Auto-Start Check.
|
|
264
|
-
try {
|
|
265
|
-
var daemonPid = path.join(CWD, '.monomind', 'daemon.pid');
|
|
266
|
-
var daemonRunning = false;
|
|
267
|
-
if (fs.existsSync(daemonPid)) {
|
|
268
|
-
try {
|
|
269
|
-
var MAX_PID = 32; // 32 bytes — enough for any pid
|
|
270
|
-
if (fs.statSync(daemonPid).size <= MAX_PID) {
|
|
271
|
-
var pid = parseInt(fs.readFileSync(daemonPid, 'utf-8').trim(), 10);
|
|
272
|
-
if (Number.isInteger(pid) && pid > 0 && pid < 4194304) {
|
|
273
|
-
process.kill(pid, 0);
|
|
274
|
-
daemonRunning = true;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
} catch (e) { /* pid stale */ }
|
|
278
|
-
}
|
|
279
|
-
if (!daemonRunning) {
|
|
280
|
-
var daemonCfg = {};
|
|
281
|
-
try {
|
|
282
|
-
var cfgPath = path.join(CWD, 'monomind.config.json');
|
|
283
|
-
var MAX_CFG = 256 * 1024; // 256 KiB
|
|
284
|
-
if (fs.existsSync(cfgPath) && fs.statSync(cfgPath).size <= MAX_CFG) daemonCfg = JSON.parse(fs.readFileSync(cfgPath, 'utf-8')).daemon || {};
|
|
285
|
-
} catch (e) {}
|
|
286
|
-
if (daemonCfg.autoStart) {
|
|
287
|
-
var spawn = require('child_process').spawn;
|
|
288
|
-
var daemonChild = spawn('npx', ['monomind', 'daemon', 'start'], {
|
|
289
|
-
cwd: CWD, detached: true, stdio: 'ignore'
|
|
290
|
-
});
|
|
291
|
-
daemonChild.on('error', function() {});
|
|
292
|
-
daemonChild.unref();
|
|
293
|
-
console.log('[DAEMON_AUTOSTART] Background daemon started (pid ' + daemonChild.pid + ')');
|
|
294
|
-
}
|
|
295
|
-
// Daemon not running + no autoStart: emit only if this project has a config
|
|
296
|
-
// (i.e. daemon was intentionally set up). Avoids noisy output in daemon-less projects.
|
|
297
|
-
else if (fs.existsSync(path.join(CWD, 'monomind.config.json'))) {
|
|
298
|
-
console.log('[DAEMON_STOPPED] Run `npx monomind daemon start` to enable background workers');
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
} catch (e) { /* non-fatal */ }
|
|
302
|
-
|
|
303
355
|
// Token Usage — inject daily/monthly cost summary.
|
|
304
356
|
try {
|
|
305
357
|
var tokenTracker = require(path.join(helpersDir, 'token-tracker.cjs'));
|
|
@@ -356,15 +408,5 @@ module.exports = {
|
|
|
356
408
|
} catch (e) { /* non-fatal */ }
|
|
357
409
|
}
|
|
358
410
|
|
|
359
|
-
// Worker Queue Resume (SR-003).
|
|
360
|
-
try {
|
|
361
|
-
var dispatchDir = path.join(CWD, '.monomind', 'worker-dispatch');
|
|
362
|
-
if (fs.existsSync(dispatchDir)) {
|
|
363
|
-
var pendingFiles = fs.readdirSync(dispatchDir).filter(function(f) { return f.startsWith('pending-'); }).slice(0, 500);
|
|
364
|
-
if (pendingFiles.length > 0) {
|
|
365
|
-
console.log('[WORKER_RESUME] ' + pendingFiles.length + ' worker dispatch(es) pending from prior session');
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
} catch (e) { /* non-fatal */ }
|
|
369
411
|
},
|
|
370
412
|
};
|