monomind 1.8.0 → 1.9.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/design/design-monodesign.md +121 -0
- package/.claude/agents/github/issue-tracker.md +12 -12
- package/.claude/agents/github/pr-manager.md +10 -10
- package/.claude/agents/github/release-manager.md +49 -105
- package/.claude/agents/github/repo-architect.md +73 -92
- package/.claude/agents/github/sync-coordinator.md +55 -123
- package/.claude/agents/marketing/marketing-competitive-content.md +155 -0
- package/.claude/agents/marketing/marketing-content-creator.md +13 -0
- package/.claude/agents/marketing/marketing-cro-specialist.md +147 -0
- package/.claude/agents/marketing/marketing-email-specialist.md +90 -0
- package/.claude/agents/marketing/marketing-launch-strategist.md +129 -0
- package/.claude/agents/marketing/marketing-pricing-strategist.md +127 -0
- package/.claude/agents/specialists/integration-architect.md +94 -0
- package/.claude/commands/agents/README.md +4 -0
- package/.claude/commands/agents/agent-capabilities.md +6 -2
- package/.claude/commands/agents/agent-coordination.md +4 -0
- package/.claude/commands/agents/agent-spawning.md +4 -0
- package/.claude/commands/agents/agent-types.md +6 -2
- package/.claude/commands/analysis/README.md +14 -5
- package/.claude/commands/analysis/bottleneck-detect.md +30 -123
- package/.claude/commands/analysis/performance-bottlenecks.md +14 -14
- package/.claude/commands/analysis/performance-report.md +38 -11
- package/.claude/commands/analysis/token-efficiency.md +13 -16
- package/.claude/commands/analysis/token-usage.md +34 -12
- package/.claude/commands/automation/README.md +15 -5
- package/.claude/commands/automation/auto-agent.md +49 -85
- package/.claude/commands/automation/self-healing.md +20 -18
- package/.claude/commands/automation/session-memory.md +28 -29
- package/.claude/commands/automation/smart-agents.md +17 -9
- package/.claude/commands/automation/smart-spawn.md +52 -11
- package/.claude/commands/automation/workflow-select.md +46 -11
- package/.claude/commands/browse.md +5 -0
- package/.claude/commands/coordination/README.md +9 -5
- package/.claude/commands/coordination/agent-spawn.md +53 -9
- package/.claude/commands/coordination/swarm-init.md +39 -42
- package/.claude/commands/coordination/task-orchestrate.md +65 -11
- package/.claude/commands/github/README.md +21 -8
- package/.claude/commands/github/github-modes.md +9 -5
- package/.claude/commands/github/issue-tracker.md +34 -33
- package/.claude/commands/github/pr-manager.md +20 -17
- package/.claude/commands/github/release-manager.md +37 -49
- package/.claude/commands/github/repo-architect.md +39 -41
- package/.claude/commands/github/sync-coordinator.md +45 -49
- package/.claude/commands/hive-mind/README.md +42 -17
- package/.claude/commands/hive-mind/hive-mind-consensus.md +68 -4
- package/.claude/commands/hive-mind/hive-mind-init.md +55 -5
- package/.claude/commands/hive-mind/hive-mind-memory.md +69 -4
- package/.claude/commands/hive-mind/hive-mind-spawn.md +71 -10
- package/.claude/commands/hive-mind/hive-mind-status.md +52 -4
- package/.claude/commands/hive-mind/hive-mind-stop.md +51 -4
- package/.claude/commands/hive-mind/hive-mind.md +74 -14
- package/.claude/commands/hooks/README.md +62 -7
- package/.claude/commands/hooks/overview.md +94 -35
- package/.claude/commands/hooks/post-edit.md +48 -87
- package/.claude/commands/hooks/post-task.md +37 -87
- package/.claude/commands/hooks/pre-edit.md +52 -84
- package/.claude/commands/hooks/pre-task.md +46 -81
- package/.claude/commands/hooks/session-end.md +49 -85
- package/.claude/commands/hooks/setup.md +87 -58
- package/.claude/commands/mastermind/_repeat.md +308 -0
- package/.claude/commands/mastermind/architect.md +49 -0
- package/.claude/commands/mastermind/brain.md +98 -0
- package/.claude/commands/mastermind/build.md +22 -0
- package/.claude/commands/mastermind/content.md +22 -0
- package/.claude/commands/mastermind/createorg.md +94 -0
- package/.claude/commands/mastermind/finance.md +22 -0
- package/.claude/commands/mastermind/idea.md +22 -0
- package/.claude/commands/mastermind/marketing.md +22 -0
- package/.claude/commands/mastermind/master.md +379 -0
- package/.claude/commands/mastermind/ops.md +22 -0
- package/.claude/commands/mastermind/release.md +22 -0
- package/.claude/commands/mastermind/research.md +22 -0
- package/.claude/commands/mastermind/review.md +22 -0
- package/.claude/commands/mastermind/runorg.md +106 -0
- package/.claude/commands/mastermind/sales.md +22 -0
- package/.claude/commands/mastermind/techport.md +17 -0
- package/.claude/commands/memory/README.md +75 -5
- package/.claude/commands/memory/memory-search.md +63 -11
- package/.claude/commands/monitoring/README.md +64 -4
- package/.claude/commands/monitoring/agent-metrics.md +50 -10
- package/.claude/commands/monitoring/agents.md +59 -32
- package/.claude/commands/monitoring/status.md +96 -34
- package/.claude/commands/monograph/README.md +102 -0
- package/.claude/commands/monograph/monograph-build.md +79 -0
- package/.claude/commands/monograph/monograph-search.md +96 -0
- package/.claude/commands/monograph/monograph-stats.md +53 -0
- package/.claude/commands/monograph/monograph-watch.md +63 -0
- package/.claude/commands/monograph/monograph-wiki.md +91 -0
- package/.claude/commands/monomind/createtask.md +277 -0
- package/.claude/commands/{monomind-do.md → monomind/do.md} +21 -8
- package/.claude/commands/monomind/help.md +118 -0
- package/.claude/commands/{monomind-idea.md → monomind/idea.md} +22 -28
- package/.claude/commands/{monomind-improve.md → monomind/improve.md} +21 -27
- package/.claude/commands/monomind/memory.md +230 -0
- package/.claude/commands/monomind/repeat.md +201 -0
- package/.claude/commands/monomind/review.md +313 -0
- package/.claude/commands/monomind/specialagents.md +125 -0
- package/.claude/commands/monomind/swarm.md +161 -0
- package/.claude/commands/monomind/understand.md +148 -0
- package/.claude/commands/optimization/README.md +69 -5
- package/.claude/commands/optimization/auto-topology.md +66 -43
- package/.claude/commands/optimization/parallel-execution.md +65 -39
- package/.claude/commands/optimization/performance-optimize.md +79 -0
- package/.claude/commands/pair/README.md +48 -230
- package/.claude/commands/pair/examples.md +85 -441
- package/.claude/commands/pair/modes.md +77 -303
- package/.claude/commands/pair/session.md +76 -359
- package/.claude/commands/sparc/analyzer.md +9 -26
- package/.claude/commands/sparc/architect.md +8 -25
- package/.claude/commands/sparc/ask.md +27 -68
- package/.claude/commands/sparc/batch-executor.md +8 -25
- package/.claude/commands/sparc/code.md +12 -53
- package/.claude/commands/sparc/coder.md +8 -25
- package/.claude/commands/sparc/debug.md +12 -53
- package/.claude/commands/sparc/debugger.md +8 -25
- package/.claude/commands/sparc/designer.md +8 -25
- package/.claude/commands/sparc/devops.md +16 -57
- package/.claude/commands/sparc/docs-writer.md +12 -53
- package/.claude/commands/sparc/documenter.md +8 -25
- package/.claude/commands/sparc/innovator.md +8 -25
- package/.claude/commands/sparc/integration.md +12 -53
- package/.claude/commands/sparc/mcp.md +12 -53
- package/.claude/commands/sparc/memory-manager.md +28 -25
- package/.claude/commands/sparc/optimizer.md +8 -25
- package/.claude/commands/sparc/orchestrator.md +35 -97
- package/.claude/commands/sparc/post-deployment-monitoring-mode.md +13 -54
- package/.claude/commands/sparc/refinement-optimization-mode.md +13 -54
- package/.claude/commands/sparc/researcher.md +8 -25
- package/.claude/commands/sparc/reviewer.md +8 -25
- package/.claude/commands/sparc/security-review.md +13 -54
- package/.claude/commands/sparc/sparc-modes.md +97 -151
- package/.claude/commands/sparc/sparc.md +16 -56
- package/.claude/commands/sparc/spec-pseudocode.md +13 -54
- package/.claude/commands/sparc/supabase-admin.md +19 -66
- package/.claude/commands/sparc/swarm-coordinator.md +21 -25
- package/.claude/commands/sparc/tdd.md +8 -25
- package/.claude/commands/sparc/tester.md +8 -25
- package/.claude/commands/sparc/tutorial.md +12 -53
- package/.claude/commands/sparc/workflow-manager.md +8 -25
- package/.claude/commands/sparc.md +76 -130
- package/.claude/commands/stream-chain/pipeline.md +72 -77
- package/.claude/commands/stream-chain/run.md +133 -47
- package/.claude/commands/swarm/README.md +37 -12
- package/.claude/commands/swarm/analysis.md +47 -69
- package/.claude/commands/swarm/development.md +45 -69
- package/.claude/commands/swarm/examples.md +77 -142
- package/.claude/commands/swarm/maintenance.md +47 -74
- package/.claude/commands/swarm/optimization.md +54 -87
- package/.claude/commands/swarm/research.md +47 -107
- package/.claude/commands/swarm/swarm-analysis.md +58 -4
- package/.claude/commands/swarm/swarm-background.md +61 -4
- package/.claude/commands/swarm/swarm-modes.md +63 -4
- package/.claude/commands/swarm/swarm-monitor.md +50 -4
- package/.claude/commands/swarm/swarm-status.md +40 -4
- package/.claude/commands/swarm/swarm-strategies.md +73 -5
- package/.claude/commands/swarm/swarm.md +70 -18
- package/.claude/commands/swarm/testing.md +51 -102
- package/.claude/commands/tokens.md +6 -1
- package/.claude/commands/training/README.md +36 -6
- package/.claude/commands/training/model-update.md +68 -15
- package/.claude/commands/training/neural-patterns.md +54 -55
- package/.claude/commands/training/neural-train.md +70 -16
- package/.claude/commands/training/pattern-learn.md +60 -16
- package/.claude/commands/training/specialization.md +78 -49
- package/.claude/commands/truth/start.md +87 -109
- package/.claude/commands/ts.md +7 -2
- package/.claude/commands/verify/check.md +90 -34
- package/.claude/commands/verify/start.md +71 -94
- package/.claude/commands/workflows/README.md +62 -6
- package/.claude/commands/workflows/development.md +69 -61
- package/.claude/commands/workflows/research.md +73 -47
- package/.claude/commands/workflows/workflow-create.md +75 -16
- package/.claude/commands/workflows/workflow-execute.md +94 -16
- package/.claude/commands/workflows/workflow-export.md +81 -16
- package/.claude/helpers/control-start.cjs +91 -0
- package/.claude/helpers/extras-registry.json +4104 -1991
- package/.claude/helpers/graphify-freshen.cjs +44 -13
- package/.claude/helpers/hook-handler.cjs +256 -1
- package/.claude/helpers/learning-service.mjs +0 -0
- package/.claude/helpers/loop-tracker.cjs +107 -0
- package/.claude/helpers/metrics-db.mjs +0 -0
- package/.claude/helpers/router.cjs +48 -68
- package/.claude/helpers/skill-registry.json +89 -104
- package/.claude/helpers/statusline.cjs +33 -2
- package/.claude/helpers/swarm-hooks.sh +0 -0
- package/.claude/scheduled_tasks.lock +1 -0
- package/.claude/settings.json +15 -0
- package/.claude/skills/.monomind/data/ranked-context.json +5 -0
- package/.claude/skills/.monomind/sessions/current.json +13 -0
- package/.claude/skills/.monomind/sessions/session-1777829336455.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777831614725.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777832095857.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777839814183.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777841847131.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777843309463.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777880867159.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777881884593.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777884090471.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777884808221.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777885672155.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777886852818.json +15 -0
- package/.claude/skills/.monomind/sessions/session-1777896532690.json +15 -0
- package/.claude/skills/agentdb-advanced/SKILL.md +11 -12
- package/.claude/skills/agentdb-learning/SKILL.md +20 -21
- package/.claude/skills/agentdb-memory-patterns/SKILL.md +28 -30
- package/.claude/skills/agentdb-optimization/SKILL.md +11 -12
- package/.claude/skills/agentdb-vector-search/SKILL.md +37 -41
- package/.claude/skills/{v3-integration-deep → agentic-integration}/SKILL.md +20 -13
- package/.claude/skills/agentic-jujutsu/SKILL.md +22 -22
- package/.claude/skills/{v3-cli-modernization → cli-modernization}/SKILL.md +17 -8
- package/.claude/skills/{v3-core-implementation → core-implementation}/SKILL.md +33 -8
- package/.claude/skills/{v3-ddd-architecture → ddd-architecture}/SKILL.md +18 -25
- package/.claude/skills/github-code-review/SKILL.md +82 -83
- package/.claude/skills/github-multi-repo/SKILL.md +42 -46
- package/.claude/skills/github-project-management/SKILL.md +83 -88
- package/.claude/skills/github-release-management/SKILL.md +12 -18
- package/.claude/skills/github-workflow-automation/SKILL.md +70 -74
- package/.claude/skills/hooks-automation/SKILL.md +9 -13
- package/.claude/skills/mastermind/_intake.md +83 -0
- package/.claude/skills/mastermind/_protocol.md +275 -0
- package/.claude/skills/mastermind/architect.md +847 -0
- package/.claude/skills/mastermind/build.md +158 -0
- package/.claude/skills/mastermind/content.md +185 -0
- package/.claude/skills/mastermind/createorg.md +318 -0
- package/.claude/skills/mastermind/finance.md +154 -0
- package/.claude/skills/mastermind/idea.md +158 -0
- package/.claude/skills/mastermind/marketing.md +216 -0
- package/.claude/skills/mastermind/monotask.md +350 -0
- package/.claude/skills/mastermind/ops.md +156 -0
- package/.claude/skills/mastermind/references/copywriting-frameworks.md +181 -0
- package/.claude/skills/mastermind/references/persuasion-psychology.md +158 -0
- package/.claude/skills/mastermind/release.md +156 -0
- package/.claude/skills/mastermind/research.md +156 -0
- package/.claude/skills/mastermind/review.md +157 -0
- package/.claude/skills/mastermind/runorg.md +308 -0
- package/.claude/skills/mastermind/sales.md +158 -0
- package/.claude/skills/mastermind/techport.md +743 -0
- package/.claude/skills/{v3-mcp-optimization → mcp-optimization}/SKILL.md +35 -14
- package/.claude/skills/{v3-memory-unification → memory-unification}/SKILL.md +20 -4
- package/.claude/skills/monodesign/SKILL.md +302 -0
- package/.claude/skills/monodesign/reference/adapt.md +190 -0
- package/.claude/skills/monodesign/reference/animate.md +175 -0
- package/.claude/skills/monodesign/reference/antipatterns-catalog.md +187 -0
- package/.claude/skills/monodesign/reference/audit.md +133 -0
- package/.claude/skills/monodesign/reference/bolder.md +113 -0
- package/.claude/skills/monodesign/reference/brand-workflow.md +180 -0
- package/.claude/skills/monodesign/reference/brand.md +114 -0
- package/.claude/skills/monodesign/reference/clarify.md +174 -0
- package/.claude/skills/monodesign/reference/cognitive-load.md +106 -0
- package/.claude/skills/monodesign/reference/color-and-contrast.md +105 -0
- package/.claude/skills/monodesign/reference/colorize.md +154 -0
- package/.claude/skills/monodesign/reference/component-specs.md +260 -0
- package/.claude/skills/monodesign/reference/component-states.md +274 -0
- package/.claude/skills/monodesign/reference/component-system.md +358 -0
- package/.claude/skills/monodesign/reference/copy-formulas.md +160 -0
- package/.claude/skills/monodesign/reference/craft.md +193 -0
- package/.claude/skills/monodesign/reference/critique.md +213 -0
- package/.claude/skills/monodesign/reference/delight.md +302 -0
- package/.claude/skills/monodesign/reference/design-principles.md +246 -0
- package/.claude/skills/monodesign/reference/distill.md +111 -0
- package/.claude/skills/monodesign/reference/document.md +427 -0
- package/.claude/skills/monodesign/reference/extract.md +69 -0
- package/.claude/skills/monodesign/reference/harden.md +347 -0
- package/.claude/skills/monodesign/reference/heuristics-scoring.md +234 -0
- package/.claude/skills/monodesign/reference/image-prompts.md +118 -0
- package/.claude/skills/monodesign/reference/interaction-design.md +195 -0
- package/.claude/skills/monodesign/reference/layout.md +141 -0
- package/.claude/skills/monodesign/reference/live.md +622 -0
- package/.claude/skills/monodesign/reference/motion-design.md +109 -0
- package/.claude/skills/monodesign/reference/onboard.md +234 -0
- package/.claude/skills/monodesign/reference/optimize.md +258 -0
- package/.claude/skills/monodesign/reference/overdrive.md +130 -0
- package/.claude/skills/monodesign/reference/personas.md +179 -0
- package/.claude/skills/monodesign/reference/polish.md +233 -0
- package/.claude/skills/monodesign/reference/pre-delivery-checklist.md +108 -0
- package/.claude/skills/monodesign/reference/product.md +62 -0
- package/.claude/skills/monodesign/reference/quieter.md +99 -0
- package/.claude/skills/monodesign/reference/responsive-design.md +114 -0
- package/.claude/skills/monodesign/reference/shape.md +151 -0
- package/.claude/skills/monodesign/reference/spatial-design.md +100 -0
- package/.claude/skills/monodesign/reference/teach.md +156 -0
- package/.claude/skills/monodesign/reference/token-architecture.md +222 -0
- package/.claude/skills/monodesign/reference/typeset.md +124 -0
- package/.claude/skills/monodesign/reference/typography.md +159 -0
- package/.claude/skills/monodesign/reference/ux-research.md +143 -0
- package/.claude/skills/monodesign/reference/ux-rules.md +211 -0
- package/.claude/skills/monodesign/reference/ux-writing.md +107 -0
- package/.claude/skills/monomotion/SKILL.md +145 -0
- package/.claude/skills/monomotion/rules/api-control.md +139 -0
- package/.claude/skills/monomotion/rules/effects.md +109 -0
- package/.claude/skills/monomotion/rules/integration.md +140 -0
- package/.claude/skills/monomotion/rules/scroll.md +131 -0
- package/.claude/skills/monomotion/rules/sequencing.md +105 -0
- package/.claude/skills/monomotion/rules/svg.md +101 -0
- package/.claude/skills/monomotion/rules/text.md +119 -0
- package/.claude/skills/pair-programming/SKILL.md +1 -1
- package/.claude/skills/performance-analysis/SKILL.md +3 -3
- package/.claude/skills/{v3-performance-optimization → performance-optimization}/SKILL.md +16 -8
- package/.claude/skills/reasoningbank-agentdb/SKILL.md +17 -19
- package/.claude/skills/reasoningbank-intelligence/SKILL.md +4 -6
- package/.claude/skills/{v3-security-overhaul → security-hardening}/SKILL.md +13 -3
- package/.claude/skills/skill-builder/SKILL.md +19 -19
- package/.claude/skills/sparc-methodology/SKILL.md +55 -211
- package/.claude/skills/stop-slop/SKILL.md +67 -0
- package/.claude/skills/stop-slop/references/examples.md +61 -0
- package/.claude/skills/stop-slop/references/phrases.md +130 -0
- package/.claude/skills/stop-slop/references/structures.md +136 -0
- package/.claude/skills/swarm-advanced/SKILL.md +13 -43
- package/.claude/skills/{v3-swarm-coordination → swarm-coordination}/SKILL.md +39 -21
- package/.claude/skills/swarm-orchestration/SKILL.md +12 -12
- package/.claude/skills/verification-quality/SKILL.md +5 -5
- package/.claude/statusline-command.sh +0 -0
- package/.claude/statusline.sh +0 -0
- package/.claude-plugin/scripts/install.sh +0 -0
- package/.claude-plugin/scripts/uninstall.sh +0 -0
- package/.claude-plugin/scripts/verify.sh +0 -0
- package/README.md +5 -5
- package/package.json +17 -17
- package/packages/@monomind/cli/README.md +441 -0
- package/packages/@monomind/cli/bin/cli.js +78 -13
- package/packages/@monomind/cli/bin/mcp-server.js +0 -0
- package/packages/@monomind/cli/dist/src/agents/halt-signal.js +33 -7
- package/packages/@monomind/cli/dist/src/agents/managed-agent.js +5 -2
- package/packages/@monomind/cli/dist/src/agents/prompt-experiment.d.ts +3 -2
- package/packages/@monomind/cli/dist/src/agents/prompt-experiment.js +1 -1
- package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.d.ts +5 -2
- package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.js +26 -4
- package/packages/@monomind/cli/dist/src/agents/specialization-scorer.js +17 -9
- package/packages/@monomind/cli/dist/src/agents/trigger-scanner.d.ts +5 -3
- package/packages/@monomind/cli/dist/src/agents/trigger-scanner.js +58 -10
- package/packages/@monomind/cli/dist/src/agents/version-store.d.ts +0 -1
- package/packages/@monomind/cli/dist/src/agents/version-store.js +44 -21
- package/packages/@monomind/cli/dist/src/autopilot-state.js +79 -28
- package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.d.ts +7 -2
- package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.js +20 -8
- package/packages/@monomind/cli/dist/src/benchmarks/metric-evaluators.d.ts +2 -1
- package/packages/@monomind/cli/dist/src/benchmarks/metric-evaluators.js +25 -2
- package/packages/@monomind/cli/dist/src/commands/agent.js +6 -4
- package/packages/@monomind/cli/dist/src/commands/appliance-advanced.js +23 -0
- package/packages/@monomind/cli/dist/src/commands/autopilot.js +3 -3
- package/packages/@monomind/cli/dist/src/commands/benchmark.js +119 -8
- package/packages/@monomind/cli/dist/src/commands/claims.js +22 -14
- package/packages/@monomind/cli/dist/src/commands/config.js +32 -0
- package/packages/@monomind/cli/dist/src/commands/daemon.js +13 -11
- package/packages/@monomind/cli/dist/src/commands/deployment.js +21 -2
- package/packages/@monomind/cli/dist/src/commands/doctor.js +5 -4
- package/packages/@monomind/cli/dist/src/commands/embeddings.js +124 -48
- package/packages/@monomind/cli/dist/src/commands/hive-mind.js +15 -14
- package/packages/@monomind/cli/dist/src/commands/hooks.js +45 -41
- package/packages/@monomind/cli/dist/src/commands/index.d.ts +2 -0
- package/packages/@monomind/cli/dist/src/commands/index.js +20 -7
- package/packages/@monomind/cli/dist/src/commands/init.js +53 -19
- package/packages/@monomind/cli/dist/src/commands/mcp.js +31 -44
- package/packages/@monomind/cli/dist/src/commands/memory.js +47 -15
- package/packages/@monomind/cli/dist/src/commands/migrate.js +156 -108
- package/packages/@monomind/cli/dist/src/commands/monograph.d.ts +8 -0
- package/packages/@monomind/cli/dist/src/commands/monograph.js +526 -0
- package/packages/@monomind/cli/dist/src/commands/neural.js +96 -56
- package/packages/@monomind/cli/dist/src/commands/performance.js +30 -8
- package/packages/@monomind/cli/dist/src/commands/plugins.js +13 -37
- package/packages/@monomind/cli/dist/src/commands/process.js +25 -2
- package/packages/@monomind/cli/dist/src/commands/providers.js +37 -5
- package/packages/@monomind/cli/dist/src/commands/replay.js +4 -4
- package/packages/@monomind/cli/dist/src/commands/route.js +37 -5
- package/packages/@monomind/cli/dist/src/commands/ruvector/import.js +12 -2
- package/packages/@monomind/cli/dist/src/commands/ruvector/init.js +15 -0
- package/packages/@monomind/cli/dist/src/commands/ruvector/status.js +16 -3
- package/packages/@monomind/cli/dist/src/commands/security.js +342 -193
- package/packages/@monomind/cli/dist/src/commands/session.js +51 -8
- package/packages/@monomind/cli/dist/src/commands/start.js +18 -4
- package/packages/@monomind/cli/dist/src/commands/swarm.js +47 -36
- package/packages/@monomind/cli/dist/src/commands/tokens.js +11 -11
- package/packages/@monomind/cli/dist/src/commands/transfer-store.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/workflow.js +31 -4
- package/packages/@monomind/cli/dist/src/config-adapter.d.ts +2 -1
- package/packages/@monomind/cli/dist/src/consensus/audit-writer.js +46 -13
- package/packages/@monomind/cli/dist/src/consensus/vote-signer.d.ts +0 -3
- package/packages/@monomind/cli/dist/src/consensus/vote-signer.js +9 -1
- package/packages/@monomind/cli/dist/src/dlq/dlq-reader.d.ts +4 -2
- package/packages/@monomind/cli/dist/src/dlq/dlq-reader.js +25 -8
- package/packages/@monomind/cli/dist/src/dlq/dlq-replayer.d.ts +10 -3
- package/packages/@monomind/cli/dist/src/dlq/dlq-replayer.js +50 -16
- package/packages/@monomind/cli/dist/src/dlq/dlq-writer.js +27 -5
- package/packages/@monomind/cli/dist/src/eval/dataset-manager.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/eval/dataset-manager.js +26 -16
- package/packages/@monomind/cli/dist/src/eval/trace-collector.js +23 -3
- package/packages/@monomind/cli/dist/src/index.js +12 -10
- package/packages/@monomind/cli/dist/src/init/claudemd-generator.js +8 -8
- package/packages/@monomind/cli/dist/src/init/executor.js +153 -70
- package/packages/@monomind/cli/dist/src/init/helpers-generator.js +35 -22
- package/packages/@monomind/cli/dist/src/init/mcp-generator.js +3 -3
- package/packages/@monomind/cli/dist/src/init/settings-generator.js +10 -3
- package/packages/@monomind/cli/dist/src/init/shared-instructions-generator.js +18 -3
- package/packages/@monomind/cli/dist/src/init/statusline-generator.js +3 -1
- package/packages/@monomind/cli/dist/src/init/types.d.ts +35 -11
- package/packages/@monomind/cli/dist/src/init/types.js +5 -9
- package/packages/@monomind/cli/dist/src/interactive/interrupt.js +8 -3
- package/packages/@monomind/cli/dist/src/mcp/tool-registry.js +38 -4
- package/packages/@monomind/cli/dist/src/mcp-client.js +10 -4
- package/packages/@monomind/cli/dist/src/mcp-server.d.ts +9 -2
- package/packages/@monomind/cli/dist/src/mcp-server.js +182 -35
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +66 -34
- package/packages/@monomind/cli/dist/src/mcp-tools/agentdb-tools.js +34 -7
- package/packages/@monomind/cli/dist/src/mcp-tools/analyze-tools.js +25 -16
- package/packages/@monomind/cli/dist/src/mcp-tools/auto-install.js +4 -6
- package/packages/@monomind/cli/dist/src/mcp-tools/autopilot-tools.js +12 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/browser-tools.js +199 -20
- package/packages/@monomind/cli/dist/src/mcp-tools/claims-tools.js +68 -18
- package/packages/@monomind/cli/dist/src/mcp-tools/config-tools.js +33 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/coordination-tools.js +59 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/daa-tools.js +46 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/embeddings-tools.js +46 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/github-tools.js +29 -16
- package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.js +38 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +96 -33
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +70 -37
- package/packages/@monomind/cli/dist/src/mcp-tools/memory-tools.js +29 -13
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +5867 -56
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.js +121 -37
- package/packages/@monomind/cli/dist/src/mcp-tools/performance-tools.js +21 -8
- package/packages/@monomind/cli/dist/src/mcp-tools/progress-tools.js +10 -8
- package/packages/@monomind/cli/dist/src/mcp-tools/request-tracker.js +4 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/ruvllm-tools.js +19 -8
- package/packages/@monomind/cli/dist/src/mcp-tools/session-tools.js +57 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +35 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/system-tools.js +4 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/task-tools.js +53 -13
- package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.js +63 -14
- package/packages/@monomind/cli/dist/src/mcp-tools/transfer-tools.js +21 -16
- package/packages/@monomind/cli/dist/src/mcp-tools/workflow-tools.js +92 -23
- package/packages/@monomind/cli/dist/src/memory/ewc-consolidation.js +41 -10
- package/packages/@monomind/cli/dist/src/memory/intelligence.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/memory/intelligence.js +39 -13
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +1 -0
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +149 -56
- package/packages/@monomind/cli/dist/src/memory/memory-initializer.js +107 -45
- package/packages/@monomind/cli/dist/src/memory/sona-optimizer.d.ts +8 -1
- package/packages/@monomind/cli/dist/src/memory/sona-optimizer.js +25 -8
- package/packages/@monomind/cli/dist/src/observability/replay-reader.d.ts +40 -0
- package/packages/@monomind/cli/dist/src/observability/replay-reader.js +138 -0
- package/packages/@monomind/cli/dist/src/orchestration/routing-modes.js +35 -5
- package/packages/@monomind/cli/dist/src/parser.d.ts +8 -0
- package/packages/@monomind/cli/dist/src/parser.js +48 -14
- package/packages/@monomind/cli/dist/src/plugins/manager.js +112 -19
- package/packages/@monomind/cli/dist/src/plugins/store/discovery.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/plugins/store/discovery.js +80 -62
- package/packages/@monomind/cli/dist/src/production/circuit-breaker.js +8 -1
- package/packages/@monomind/cli/dist/src/production/error-handler.d.ts +4 -2
- package/packages/@monomind/cli/dist/src/production/error-handler.js +27 -5
- package/packages/@monomind/cli/dist/src/production/monitoring.js +8 -4
- package/packages/@monomind/cli/dist/src/production/rate-limiter.js +30 -22
- package/packages/@monomind/cli/dist/src/ruvector/agent-wasm.js +2 -2
- package/packages/@monomind/cli/dist/src/ruvector/coverage-router.js +19 -9
- package/packages/@monomind/cli/dist/src/ruvector/diff-classifier.d.ts +1 -0
- package/packages/@monomind/cli/dist/src/ruvector/diff-classifier.js +26 -6
- package/packages/@monomind/cli/dist/src/ruvector/enhanced-model-router.js +24 -2
- package/packages/@monomind/cli/dist/src/ruvector/index.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/ruvector/index.js +2 -2
- package/packages/@monomind/cli/dist/src/ruvector/model-router.d.ts +4 -2
- package/packages/@monomind/cli/dist/src/ruvector/model-router.js +30 -6
- package/packages/@monomind/cli/dist/src/ruvector/moe-router.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/ruvector/moe-router.js +35 -12
- package/packages/@monomind/cli/dist/src/ruvector/q-learning-router.d.ts +7 -1
- package/packages/@monomind/cli/dist/src/ruvector/q-learning-router.js +40 -9
- package/packages/@monomind/cli/dist/src/services/claim-service.d.ts +3 -1
- package/packages/@monomind/cli/dist/src/services/claim-service.js +33 -2
- package/packages/@monomind/cli/dist/src/services/config-file-manager.d.ts +16 -2
- package/packages/@monomind/cli/dist/src/services/config-file-manager.js +105 -17
- package/packages/@monomind/cli/dist/src/services/container-worker-pool.js +51 -11
- package/packages/@monomind/cli/dist/src/services/headless-worker-executor.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/services/headless-worker-executor.js +188 -45
- package/packages/@monomind/cli/dist/src/services/registry-api.js +62 -9
- package/packages/@monomind/cli/dist/src/services/ruvector-training.js +8 -0
- package/packages/@monomind/cli/dist/src/services/worker-daemon.d.ts +4 -1
- package/packages/@monomind/cli/dist/src/services/worker-daemon.js +112 -28
- package/packages/@monomind/cli/dist/src/services/worker-queue.d.ts +9 -2
- package/packages/@monomind/cli/dist/src/services/worker-queue.js +86 -5
- package/packages/@monomind/cli/dist/src/suggest.js +9 -0
- package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.d.ts +5 -3
- package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.js +17 -5
- package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.d.ts +3 -0
- package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.js +30 -6
- package/packages/@monomind/cli/dist/src/transfer/anonymization/index.js +5 -3
- package/packages/@monomind/cli/dist/src/transfer/export.js +5 -3
- package/packages/@monomind/cli/dist/src/transfer/ipfs/client.js +84 -7
- package/packages/@monomind/cli/dist/src/transfer/ipfs/upload.js +13 -4
- package/packages/@monomind/cli/dist/src/transfer/storage/gcs.js +19 -10
- package/packages/@monomind/cli/dist/src/transfer/store/discovery.d.ts +9 -2
- package/packages/@monomind/cli/dist/src/transfer/store/discovery.js +68 -13
- package/packages/@monomind/cli/dist/src/transfer/store/download.d.ts +15 -6
- package/packages/@monomind/cli/dist/src/transfer/store/download.js +113 -24
- package/packages/@monomind/cli/dist/src/transfer/store/publish.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/transfer/store/publish.js +13 -14
- package/packages/@monomind/cli/dist/src/transfer/store/registry.d.ts +3 -3
- package/packages/@monomind/cli/dist/src/transfer/store/registry.js +32 -16
- package/packages/@monomind/cli/dist/src/update/checker.js +17 -4
- package/packages/@monomind/cli/dist/src/update/executor.js +25 -20
- package/packages/@monomind/cli/dist/src/update/rate-limiter.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/update/rate-limiter.js +23 -3
- package/packages/@monomind/cli/dist/src/utils/parse-jsonl.d.ts +6 -0
- package/packages/@monomind/cli/dist/src/utils/parse-jsonl.js +22 -0
- package/packages/@monomind/cli/dist/src/workflow/condition-evaluator.js +37 -3
- package/packages/@monomind/cli/dist/src/workflow/dag-builder.js +27 -11
- package/packages/@monomind/cli/dist/src/workflow/dag-executor.js +51 -13
- package/packages/@monomind/cli/dist/src/workflow/dsl-schema.d.ts +3 -0
- package/packages/@monomind/cli/dist/src/workflow/dsl-schema.js +6 -2
- package/packages/@monomind/cli/dist/src/workflow/template-engine.js +7 -0
- package/packages/@monomind/cli/dist/src/workflow/workflow-executor.js +95 -14
- package/packages/@monomind/cli/package.json +5 -3
- package/packages/@monomind/guidance/README.md +1192 -0
- package/packages/@monomind/shared/README.md +322 -0
- package/packages/@monomind/shared/dist/types/consensus-audit.d.ts +3 -1
- package/packages/README.md +513 -0
- package/.claude/agents/design/design-brand-guardian.md +0 -323
- package/.claude/agents/design/design-image-prompt-engineer.md +0 -237
- package/.claude/agents/design/design-inclusive-visuals-specialist.md +0 -72
- package/.claude/agents/design/design-ui-designer.md +0 -384
- package/.claude/agents/design/design-ux-architect.md +0 -470
- package/.claude/agents/design/design-ux-researcher.md +0 -330
- package/.claude/agents/design/design-visual-storyteller.md +0 -150
- package/.claude/agents/design/design-whimsy-injector.md +0 -439
- package/.claude/agents/v3/integration-architect.md +0 -338
- package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +0 -54
- package/.claude/commands/coordination/init.md +0 -44
- package/.claude/commands/coordination/orchestrate.md +0 -43
- package/.claude/commands/coordination/spawn.md +0 -45
- package/.claude/commands/github/code-review-swarm.md +0 -550
- package/.claude/commands/github/code-review.md +0 -25
- package/.claude/commands/github/github-swarm.md +0 -121
- package/.claude/commands/github/issue-triage.md +0 -25
- package/.claude/commands/github/multi-repo-swarm.md +0 -519
- package/.claude/commands/github/pr-enhance.md +0 -26
- package/.claude/commands/github/project-board-sync.md +0 -471
- package/.claude/commands/github/release-swarm.md +0 -590
- package/.claude/commands/github/repo-analyze.md +0 -25
- package/.claude/commands/github/swarm-issue.md +0 -482
- package/.claude/commands/github/swarm-pr.md +0 -310
- package/.claude/commands/github/workflow-automation.md +0 -468
- package/.claude/commands/hive-mind/hive-mind-metrics.md +0 -8
- package/.claude/commands/hive-mind/hive-mind-resume.md +0 -8
- package/.claude/commands/hive-mind/hive-mind-sessions.md +0 -8
- package/.claude/commands/hive-mind/hive-mind-wizard.md +0 -8
- package/.claude/commands/list-agents.md +0 -17
- package/.claude/commands/memory/memory-persist.md +0 -25
- package/.claude/commands/memory/memory-usage.md +0 -25
- package/.claude/commands/memory/neural.md +0 -47
- package/.claude/commands/metrics.md +0 -11
- package/.claude/commands/monitoring/real-time-view.md +0 -25
- package/.claude/commands/monitoring/swarm-monitor.md +0 -25
- package/.claude/commands/monomind-createtask.md +0 -302
- package/.claude/commands/monomind-help.md +0 -103
- package/.claude/commands/monomind-memory.md +0 -107
- package/.claude/commands/monomind-repeat.md +0 -149
- package/.claude/commands/monomind-swarm.md +0 -205
- package/.claude/commands/optimization/cache-manage.md +0 -25
- package/.claude/commands/optimization/topology-optimize.md +0 -25
- package/.claude/commands/pair/commands.md +0 -546
- package/.claude/commands/pair/config.md +0 -510
- package/.claude/commands/pair/start.md +0 -209
- package/.claude/commands/use-agent.md +0 -67
- package/.claude/skills/monomind-createtask/SKILL.md +0 -269
- package/.claude/skills/monomind-task-engine/SKILL.md +0 -358
- /package/.claude/agents/{v3 → specialists}/memory-specialist.md +0 -0
- /package/.claude/agents/{v3 → specialists}/performance-engineer.md +0 -0
- /package/.claude/agents/{v3 → specialists}/queen-coordinator.md +0 -0
- /package/.claude/agents/{v3 → specialists}/security-architect.md +0 -0
|
@@ -1,29 +1,60 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
// Runs at SessionStart — rebuilds the knowledge graph using
|
|
2
|
+
// Runs at SessionStart — rebuilds the knowledge graph using @monoes/monograph in the background.
|
|
3
3
|
// Fire-and-forget: spawns detached child, logs start, exits immediately without blocking session.
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const fs = require('fs');
|
|
6
|
-
const { spawn
|
|
6
|
+
const { spawn } = require('child_process');
|
|
7
7
|
|
|
8
8
|
const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
9
9
|
const graphDir = path.join(projectDir, '.monomind', 'graph');
|
|
10
|
-
|
|
11
|
-
// Check if graphify CLI is available
|
|
12
|
-
try {
|
|
13
|
-
execSync('graphify --help', { encoding: 'utf-8', stdio: 'ignore' });
|
|
14
|
-
} catch {
|
|
15
|
-
console.log('[graph] skip: graphify not installed (run: uv tool install graphifyy)');
|
|
16
|
-
process.exit(0);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
10
|
fs.mkdirSync(graphDir, { recursive: true });
|
|
20
11
|
|
|
21
12
|
const logPath = path.join(graphDir, 'build.log');
|
|
22
13
|
let logFd;
|
|
23
14
|
try { logFd = fs.openSync(logPath, 'a'); } catch { logFd = 'ignore'; }
|
|
24
15
|
|
|
25
|
-
//
|
|
26
|
-
|
|
16
|
+
// Resolve the monograph entry point — searches several common layouts
|
|
17
|
+
function resolveMonographEntry(dir) {
|
|
18
|
+
// pnpm virtual store — the reliable pre-built copy not affected by workspace symlinks
|
|
19
|
+
const pnpmStore = (() => {
|
|
20
|
+
try {
|
|
21
|
+
const storeBase = path.join(dir, 'node_modules', '.pnpm');
|
|
22
|
+
if (!fs.existsSync(storeBase)) return null;
|
|
23
|
+
const entries = fs.readdirSync(storeBase).filter(e => e.startsWith('@monoes+monograph@'));
|
|
24
|
+
for (const e of entries.sort().reverse()) { // newest version first
|
|
25
|
+
const p = path.join(storeBase, e, 'node_modules', '@monoes', 'monograph', 'dist', 'src', 'index.js');
|
|
26
|
+
if (fs.existsSync(p)) return p;
|
|
27
|
+
}
|
|
28
|
+
} catch {}
|
|
29
|
+
return null;
|
|
30
|
+
})();
|
|
31
|
+
|
|
32
|
+
const candidates = [
|
|
33
|
+
// pnpm store version (most reliable — pre-built, isolated from workspace source changes)
|
|
34
|
+
pnpmStore,
|
|
35
|
+
// Monorepo: monobrain root is the monograph package
|
|
36
|
+
path.join(dir, 'dist', 'src', 'index.js'),
|
|
37
|
+
// Monorepo: monograph lives under packages/@monomind/monograph (pnpm workspace)
|
|
38
|
+
path.join(dir, 'packages', '@monomind', 'monograph', 'dist', 'src', 'index.js'),
|
|
39
|
+
// Installed as a flat dependency
|
|
40
|
+
path.join(dir, 'node_modules', '@monoes', 'monograph', 'dist', 'src', 'index.js'),
|
|
41
|
+
path.join(dir, 'node_modules', '@monomind', 'monograph', 'dist', 'src', 'index.js'),
|
|
42
|
+
].filter(Boolean);
|
|
43
|
+
for (const c of candidates) {
|
|
44
|
+
if (fs.existsSync(c)) return c;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const entryPoint = resolveMonographEntry(projectDir);
|
|
50
|
+
if (!entryPoint) {
|
|
51
|
+
console.error('[graph] @monoes/monograph not found — skipping build');
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Spawn a detached node process to run buildAsync from @monoes/monograph (ESM)
|
|
56
|
+
const script = `import { buildAsync } from ${JSON.stringify('file://' + entryPoint)}; await buildAsync(${JSON.stringify(projectDir)});`;
|
|
57
|
+
const child = spawn(process.execPath, ['--input-type=module', '--eval', script], {
|
|
27
58
|
detached: true,
|
|
28
59
|
stdio: ['ignore', logFd, logFd],
|
|
29
60
|
cwd: projectDir,
|
|
@@ -10,6 +10,21 @@ const fs = require('fs');
|
|
|
10
10
|
const helpersDir = __dirname;
|
|
11
11
|
const CWD = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
12
12
|
|
|
13
|
+
// Resolve @monoes/monograph — it lives in pnpm's virtual store, not a named symlink.
|
|
14
|
+
// Try common locations; fall back gracefully so all hooks remain non-fatal.
|
|
15
|
+
function _requireMonograph() {
|
|
16
|
+
var candidates = [
|
|
17
|
+
path.join(CWD, 'node_modules/.pnpm/node_modules/@monoes/monograph'),
|
|
18
|
+
path.join(CWD, 'packages/node_modules/.pnpm/node_modules/@monoes/monograph'),
|
|
19
|
+
path.join(CWD, 'node_modules/@monoes/monograph'),
|
|
20
|
+
];
|
|
21
|
+
for (var i = 0; i < candidates.length; i++) {
|
|
22
|
+
try { if (fs.existsSync(candidates[i])) return require(candidates[i]); } catch(e) {}
|
|
23
|
+
}
|
|
24
|
+
try { return require('@monoes/monograph'); } catch(e) {}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
13
28
|
function safeRequire(modulePath) {
|
|
14
29
|
try {
|
|
15
30
|
if (fs.existsSync(modulePath)) {
|
|
@@ -240,6 +255,12 @@ function _autoIndexKnowledge(knowledgeDir) {
|
|
|
240
255
|
}
|
|
241
256
|
} catch (e) {}
|
|
242
257
|
}
|
|
258
|
+
// Include monograph graph build time in hash so re-index happens after graph rebuild
|
|
259
|
+
try {
|
|
260
|
+
var statsForHash = JSON.parse(fs.readFileSync(path.join(CWD, '.monomind', 'graph', 'stats.json'), 'utf-8'));
|
|
261
|
+
hashInput += 'monograph:' + (statsForHash.builtAt || 0) + ';';
|
|
262
|
+
} catch(e) {}
|
|
263
|
+
|
|
243
264
|
var contentHash = crypto.createHash('md5').update(hashInput).digest('hex');
|
|
244
265
|
|
|
245
266
|
var chunksFile = path.join(knowledgeDir, 'chunks.jsonl');
|
|
@@ -275,6 +296,60 @@ function _autoIndexKnowledge(knowledgeDir) {
|
|
|
275
296
|
} catch (e) {}
|
|
276
297
|
}
|
|
277
298
|
|
|
299
|
+
// Inject monograph graph summary as a knowledge chunk
|
|
300
|
+
try {
|
|
301
|
+
var statsPath = path.join(CWD, '.monomind', 'graph', 'stats.json');
|
|
302
|
+
var graphPath = path.join(CWD, '.monomind', 'graph', 'graph.json');
|
|
303
|
+
if (fs.existsSync(statsPath) && fs.existsSync(graphPath)) {
|
|
304
|
+
var stats = JSON.parse(fs.readFileSync(statsPath, 'utf-8'));
|
|
305
|
+
var graphStat = fs.statSync(graphPath);
|
|
306
|
+
// Only read graph if under 10MB
|
|
307
|
+
if (graphStat.size < 10 * 1024 * 1024) {
|
|
308
|
+
var graph = JSON.parse(fs.readFileSync(graphPath, 'utf-8'));
|
|
309
|
+
var rawNodes = Array.isArray(graph.nodes) ? graph.nodes : [];
|
|
310
|
+
var rawEdges = Array.isArray(graph.edges) ? graph.edges : (Array.isArray(graph.links) ? graph.links : []);
|
|
311
|
+
// Top 15 nodes by degree (god nodes)
|
|
312
|
+
var degree = {};
|
|
313
|
+
rawNodes.forEach(function(n) { degree[n.id] = 0; });
|
|
314
|
+
rawEdges.forEach(function(e) {
|
|
315
|
+
if (degree[e.source] !== undefined) degree[e.source]++;
|
|
316
|
+
if (degree[e.target] !== undefined) degree[e.target]++;
|
|
317
|
+
});
|
|
318
|
+
var topNodes = rawNodes
|
|
319
|
+
.filter(function(n) { return n.sourceFile && n.sourceFile !== ''; })
|
|
320
|
+
.sort(function(a, b) { return (degree[b.id] || 0) - (degree[a.id] || 0); })
|
|
321
|
+
.slice(0, 15);
|
|
322
|
+
// Community summary — group by type
|
|
323
|
+
var typeCounts = {};
|
|
324
|
+
rawNodes.forEach(function(n) { var t = n.type || n.label || 'unknown'; typeCounts[t] = (typeCounts[t] || 0) + 1; });
|
|
325
|
+
var topTypes = Object.entries(typeCounts).sort(function(a,b){return b[1]-a[1];}).slice(0,8).map(function(e){return e[0]+':'+e[1];}).join(', ');
|
|
326
|
+
var builtDate = stats.builtAt ? new Date(stats.builtAt).toISOString().slice(0,10) : 'unknown';
|
|
327
|
+
var summaryText = [
|
|
328
|
+
'MONOGRAPH KNOWLEDGE GRAPH SUMMARY',
|
|
329
|
+
'Built: ' + builtDate + ' | Nodes: ' + (stats.nodes || rawNodes.length) + ' | Edges: ' + (stats.edges || rawEdges.length) + ' | Files: ' + (stats.files || 0),
|
|
330
|
+
'',
|
|
331
|
+
'TOP GOD NODES (highest connectivity):',
|
|
332
|
+
topNodes.map(function(n) {
|
|
333
|
+
return ' ' + (n.name || n.id) + ' [' + (n.type || n.label || '?') + '] — ' + (n.sourceFile || '') + ' (degree: ' + (degree[n.id] || 0) + ')';
|
|
334
|
+
}).join('\n'),
|
|
335
|
+
'',
|
|
336
|
+
'NODE TYPE DISTRIBUTION: ' + topTypes,
|
|
337
|
+
'',
|
|
338
|
+
'Use mcp__monomind__monograph_suggest to find files relevant to your task.',
|
|
339
|
+
'Use mcp__monomind__monograph_query to search for symbols.',
|
|
340
|
+
'Use mcp__monomind__monograph_god_nodes for architecture overview.',
|
|
341
|
+
].join('\n');
|
|
342
|
+
var chunkId = crypto.createHash('md5').update('monograph-graph-summary').digest('hex').slice(0, 16);
|
|
343
|
+
newLines.push(JSON.stringify({
|
|
344
|
+
chunkId: chunkId,
|
|
345
|
+
namespace: 'knowledge:shared',
|
|
346
|
+
text: summaryText,
|
|
347
|
+
metadata: { label: 'monograph-graph-summary', builtAt: stats.builtAt }
|
|
348
|
+
}));
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
} catch (e) { /* graph not available yet, skip */ }
|
|
352
|
+
|
|
278
353
|
try {
|
|
279
354
|
fs.mkdirSync(knowledgeDir, { recursive: true });
|
|
280
355
|
fs.writeFileSync(chunksFile, newLines.length > 0 ? newLines.join('\n') + '\n' : '', 'utf-8');
|
|
@@ -564,6 +639,17 @@ const handlers = {
|
|
|
564
639
|
|
|
565
640
|
console.log(output.join('\n'));
|
|
566
641
|
|
|
642
|
+
// Inject monograph hint for complex tasks
|
|
643
|
+
try {
|
|
644
|
+
var graphStatsPath = path.join(CWD, '.monomind', 'graph', 'stats.json');
|
|
645
|
+
if (fs.existsSync(graphStatsPath)) {
|
|
646
|
+
var gStats = JSON.parse(fs.readFileSync(graphStatsPath, 'utf-8'));
|
|
647
|
+
if (gStats.nodes > 100) {
|
|
648
|
+
console.log('\n[MONOGRAPH] ' + gStats.nodes + ' nodes indexed. For this task, call mcp__monomind__monograph_suggest first.');
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
} catch(e) {}
|
|
652
|
+
|
|
567
653
|
// Swarm mode selection is available on-demand via /mastermind slash command.
|
|
568
654
|
} else {
|
|
569
655
|
console.log('[INFO] Router not available, using default routing');
|
|
@@ -657,7 +743,7 @@ const handlers = {
|
|
|
657
743
|
console.log('[OK] Command validated');
|
|
658
744
|
},
|
|
659
745
|
|
|
660
|
-
'post-edit': () => {
|
|
746
|
+
'post-edit': async () => {
|
|
661
747
|
if (session && session.metric) {
|
|
662
748
|
try { session.metric('edits'); } catch (e) { /* no active session */ }
|
|
663
749
|
}
|
|
@@ -695,6 +781,70 @@ const handlers = {
|
|
|
695
781
|
}
|
|
696
782
|
} catch (e) { /* non-fatal */ }
|
|
697
783
|
|
|
784
|
+
// ── Monograph Incremental Rebuild ─────────────────────────────────────
|
|
785
|
+
// After every code file edit, trigger a background monograph rebuild so
|
|
786
|
+
// the knowledge graph stays current. Debounced via a lock file (5s cooldown).
|
|
787
|
+
try {
|
|
788
|
+
var editedFile = (hookInput.file_path || toolInput.file_path
|
|
789
|
+
|| process.env.TOOL_INPUT_file_path || args[0] || '');
|
|
790
|
+
var codeExts = /\.(ts|tsx|js|jsx|mjs|cjs|py|go|rs|java|kt|cs|cpp|c|rb|swift|php)$/i;
|
|
791
|
+
if (editedFile && codeExts.test(editedFile)) {
|
|
792
|
+
var lockFile = path.join(CWD, '.monomind', 'graph', '.rebuild-lock');
|
|
793
|
+
var now = Date.now();
|
|
794
|
+
var lastBuild = 0;
|
|
795
|
+
try { lastBuild = parseInt(fs.readFileSync(lockFile, 'utf-8').trim(), 10) || 0; } catch (e) {}
|
|
796
|
+
var COOLDOWN_MS = 5000; // 5-second debounce
|
|
797
|
+
if (now - lastBuild > COOLDOWN_MS) {
|
|
798
|
+
fs.writeFileSync(lockFile, String(now), 'utf-8');
|
|
799
|
+
var { spawn: spawnRebuild } = require('child_process');
|
|
800
|
+
var rebuildScript = "import { buildAsync } from '@monoes/monograph'; await buildAsync(" + JSON.stringify(CWD) + ");";
|
|
801
|
+
var graphDir = path.join(CWD, '.monomind', 'graph');
|
|
802
|
+
var logPath = path.join(graphDir, 'build.log');
|
|
803
|
+
var logFd;
|
|
804
|
+
try { logFd = fs.openSync(logPath, 'a'); } catch(e) { logFd = 'ignore'; }
|
|
805
|
+
var child = spawnRebuild(process.execPath, ['--input-type=module', '--eval', rebuildScript], {
|
|
806
|
+
detached: true, stdio: ['ignore', logFd, logFd], cwd: CWD,
|
|
807
|
+
});
|
|
808
|
+
child.unref();
|
|
809
|
+
console.log('[MONOGRAPH] Incremental rebuild triggered for ' + path.basename(editedFile));
|
|
810
|
+
|
|
811
|
+
// Option C: fire ua-enrich.mjs in background after monograph rebuild
|
|
812
|
+
var uaEnrichScript = path.join(CWD, 'scripts', 'ua-enrich.mjs');
|
|
813
|
+
if (fs.existsSync(uaEnrichScript)) {
|
|
814
|
+
var uaChild = spawnRebuild(process.execPath, [uaEnrichScript, '--dir', CWD, '--file', editedFile, '--db', path.join(CWD, '.monomind', 'monograph.db')], {
|
|
815
|
+
detached: true, stdio: 'ignore', cwd: CWD,
|
|
816
|
+
});
|
|
817
|
+
uaChild.unref();
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
// Show importers of the edited file so Claude sees blast radius
|
|
821
|
+
try {
|
|
822
|
+
var mgDbPath4 = path.join(CWD, '.monomind', 'monograph.db');
|
|
823
|
+
if (fs.existsSync(mgDbPath4)) {
|
|
824
|
+
var mgMod4 = null;
|
|
825
|
+
mgMod4 = _requireMonograph();
|
|
826
|
+
if (mgMod4 && mgMod4.openDb) {
|
|
827
|
+
var db4 = mgMod4.openDb(mgDbPath4);
|
|
828
|
+
try {
|
|
829
|
+
var editedBase4 = path.basename(editedFile).replace(/\.[^.]+$/, '');
|
|
830
|
+
var editNode4 = db4.prepare("SELECT id, name, label FROM nodes WHERE file_path LIKE ? OR name = ? LIMIT 1")
|
|
831
|
+
.get('%' + path.sep + path.basename(editedFile), editedBase4);
|
|
832
|
+
if (editNode4) {
|
|
833
|
+
var editImporters4 = db4.prepare(
|
|
834
|
+
'SELECT n2.name FROM edges e JOIN nodes n2 ON n2.id = e.source_id WHERE e.target_id = ? LIMIT 8'
|
|
835
|
+
).all(editNode4.id);
|
|
836
|
+
if (editImporters4.length > 0) {
|
|
837
|
+
console.log('[MONOGRAPH_IMPACT] ' + editNode4.name + ' (' + editNode4.label + ') is depended on by: ' +
|
|
838
|
+
editImporters4.map(function(i) { return i.name; }).join(', '));
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
} finally { if (mgMod4.closeDb) mgMod4.closeDb(db4); }
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
} catch(e) { /* non-fatal */ }
|
|
845
|
+
}
|
|
846
|
+
} catch (e) { /* non-fatal */ }
|
|
847
|
+
|
|
698
848
|
console.log('[OK] Edit recorded');
|
|
699
849
|
},
|
|
700
850
|
|
|
@@ -789,6 +939,56 @@ const handlers = {
|
|
|
789
939
|
}
|
|
790
940
|
} catch (e) { /* non-fatal */ }
|
|
791
941
|
|
|
942
|
+
// ── Monograph Context Injection ──────────────────────────────────────────
|
|
943
|
+
// On session start, query monograph DB for god nodes, inject as context,
|
|
944
|
+
// and write them into knowledge/chunks.jsonl for semantic search recall.
|
|
945
|
+
try {
|
|
946
|
+
var mgDbPath = path.join(CWD, '.monomind', 'monograph.db');
|
|
947
|
+
if (fs.existsSync(mgDbPath)) {
|
|
948
|
+
var mgMod = null;
|
|
949
|
+
mgMod = _requireMonograph();
|
|
950
|
+
if (mgMod && mgMod.openDb) {
|
|
951
|
+
var mgDb = mgMod.openDb(mgDbPath);
|
|
952
|
+
try {
|
|
953
|
+
var mgNodeCount = mgDb.prepare('SELECT COUNT(*) AS c FROM nodes').get().c;
|
|
954
|
+
var mgEdgeCount = mgDb.prepare('SELECT COUNT(*) AS c FROM edges').get().c;
|
|
955
|
+
var mgGodNodes = mgDb.prepare(
|
|
956
|
+
'SELECT n.name, n.label, n.file_path, ' +
|
|
957
|
+
'(SELECT COUNT(*) FROM edges WHERE source_id=n.id OR target_id=n.id) AS deg ' +
|
|
958
|
+
'FROM nodes n ORDER BY deg DESC LIMIT 12'
|
|
959
|
+
).all();
|
|
960
|
+
if (mgGodNodes.length > 0) {
|
|
961
|
+
var mgGodStr = mgGodNodes.slice(0, 8).map(function(n) {
|
|
962
|
+
return n.name + ' (' + n.label + ', ' + n.deg + ' links)';
|
|
963
|
+
}).join(', ');
|
|
964
|
+
console.log('[MONOGRAPH_CONTEXT] ' + mgNodeCount + ' nodes · ' + mgEdgeCount + ' edges. Key nodes: ' + mgGodStr);
|
|
965
|
+
// Write god nodes into knowledge chunks so semantic search finds them
|
|
966
|
+
var mgKnowledgeDir = path.join(CWD, '.monomind', 'knowledge');
|
|
967
|
+
var mgChunksFile = path.join(mgKnowledgeDir, 'chunks.jsonl');
|
|
968
|
+
try {
|
|
969
|
+
fs.mkdirSync(mgKnowledgeDir, { recursive: true });
|
|
970
|
+
var mgGodChunk = JSON.stringify({
|
|
971
|
+
id: 'monograph-god-nodes',
|
|
972
|
+
text: 'Codebase architecture — high-centrality nodes (most depended-on): ' + mgGodNodes.map(function(n) {
|
|
973
|
+
return n.name + ' [' + n.label + '] at ' + (n.file_path || '') + ' (' + n.deg + ' connections)';
|
|
974
|
+
}).join('; '),
|
|
975
|
+
namespace: 'knowledge:monograph',
|
|
976
|
+
metadata: { label: 'monograph-god-nodes', nodes: mgNodeCount, edges: mgEdgeCount }
|
|
977
|
+
});
|
|
978
|
+
var mgExisting = [];
|
|
979
|
+
try { mgExisting = fs.readFileSync(mgChunksFile, 'utf-8').trim().split('\n').filter(Boolean); } catch(e) {}
|
|
980
|
+
mgExisting = mgExisting.filter(function(line) {
|
|
981
|
+
try { return JSON.parse(line).id !== 'monograph-god-nodes'; } catch(e) { return true; }
|
|
982
|
+
});
|
|
983
|
+
mgExisting.push(mgGodChunk);
|
|
984
|
+
fs.writeFileSync(mgChunksFile, mgExisting.join('\n') + '\n');
|
|
985
|
+
} catch(e) {}
|
|
986
|
+
}
|
|
987
|
+
} finally { if (mgMod.closeDb) mgMod.closeDb(mgDb); }
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
} catch(e) { /* non-fatal */ }
|
|
991
|
+
|
|
792
992
|
// Task 23: SharedInstructions — auto-load .agents/shared_instructions.md on session restore
|
|
793
993
|
// Hard limit: 1500 chars (~375 tokens). Content beyond this is truncated and flagged.
|
|
794
994
|
var SI_CHAR_LIMIT = 1500;
|
|
@@ -1156,6 +1356,61 @@ const handlers = {
|
|
|
1156
1356
|
}
|
|
1157
1357
|
} catch (e) { /* not available or no experiment */ }
|
|
1158
1358
|
|
|
1359
|
+
// Monograph impact — detect changed files and surface their dependents
|
|
1360
|
+
try {
|
|
1361
|
+
var mgDbPath1 = path.join(CWD, '.monomind', 'monograph.db');
|
|
1362
|
+
if (fs.existsSync(mgDbPath1)) {
|
|
1363
|
+
var execSync1 = require('child_process').execSync;
|
|
1364
|
+
var changedFiles1 = '';
|
|
1365
|
+
try { changedFiles1 = execSync1('git diff --name-only HEAD 2>/dev/null || git diff --name-only 2>/dev/null', { cwd: CWD, timeout: 3000, shell: true }).toString().trim(); } catch(e) {}
|
|
1366
|
+
if (changedFiles1) {
|
|
1367
|
+
var mgMod1 = null;
|
|
1368
|
+
mgMod1 = _requireMonograph();
|
|
1369
|
+
if (mgMod1 && mgMod1.openDb) {
|
|
1370
|
+
var db1 = mgMod1.openDb(mgDbPath1);
|
|
1371
|
+
try {
|
|
1372
|
+
var fileList1 = changedFiles1.split('\n').filter(Boolean).slice(0, 8);
|
|
1373
|
+
var impacted1 = [];
|
|
1374
|
+
for (var fi = 0; fi < fileList1.length; fi++) {
|
|
1375
|
+
var fBase = path.basename(fileList1[fi]);
|
|
1376
|
+
var fNode = db1.prepare("SELECT id, name, label FROM nodes WHERE file_path LIKE ? LIMIT 1").get('%' + fBase);
|
|
1377
|
+
if (fNode) {
|
|
1378
|
+
var fImporters = db1.prepare(
|
|
1379
|
+
'SELECT n2.name FROM edges e JOIN nodes n2 ON n2.id = e.source_id WHERE e.target_id = ? LIMIT 5'
|
|
1380
|
+
).all(fNode.id);
|
|
1381
|
+
var entry = fNode.name + ' (' + fNode.label + ')';
|
|
1382
|
+
if (fImporters.length) entry += ' ← ' + fImporters.map(function(i){ return i.name; }).join(', ');
|
|
1383
|
+
impacted1.push(entry);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
if (impacted1.length > 0) {
|
|
1387
|
+
console.log('[MONOGRAPH_IMPACT] Changed files and their dependents: ' + impacted1.join(' | '));
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
// Effective blast radius — second pass using first impacted node
|
|
1391
|
+
try {
|
|
1392
|
+
if (fileList1.length > 0 && mgMod1.effectiveBlastRadius) {
|
|
1393
|
+
var firstFile1 = path.basename(fileList1[0]);
|
|
1394
|
+
var firstNode1 = db1.prepare("SELECT id, name, label FROM nodes WHERE file_path LIKE ? LIMIT 1").get('%' + firstFile1);
|
|
1395
|
+
if (firstNode1) {
|
|
1396
|
+
var blastResults1 = mgMod1.effectiveBlastRadius(db1, firstNode1.id, { maxDepth: 4 });
|
|
1397
|
+
if (blastResults1 && blastResults1.length > 0) {
|
|
1398
|
+
var bwdCount1 = blastResults1.filter(function(r){ return r.direction === 'backward' || r.direction === 'both'; }).length;
|
|
1399
|
+
var fwdCount1 = blastResults1.filter(function(r){ return r.direction === 'forward' || r.direction === 'both'; }).length;
|
|
1400
|
+
var topBlast1 = blastResults1.slice(0, 8).map(function(r){
|
|
1401
|
+
return '[' + r.direction + ':' + r.hops + '] ' + r.nodeName + ' (' + r.nodeLabel + ')';
|
|
1402
|
+
});
|
|
1403
|
+
console.log('[MONOGRAPH_BLAST_RADIUS] Node: ' + firstNode1.name + ' | forward=' + fwdCount1 + ' backward=' + bwdCount1 + ' | ' + topBlast1.join(', '));
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
} catch(blastErr) { /* non-fatal */ }
|
|
1408
|
+
} finally { if (mgMod1.closeDb) mgMod1.closeDb(db1); }
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
} catch(e) { /* non-fatal */ }
|
|
1413
|
+
|
|
1159
1414
|
// Bridge to @monomind/hooks registry — fires Tasks 26 (PromptAssembler) and any other PreTask hooks
|
|
1160
1415
|
if (_hooksModule && _hooksModule.executeHooks && _hooksModule.HookEvent) {
|
|
1161
1416
|
try {
|
|
File without changes
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Loop Tracker — PostToolUse hook for ScheduleWakeup
|
|
4
|
+
* Writes loop state to .monomind/loops/<sessionId>.json so the
|
|
5
|
+
* Monomind Control dashboard can display active loops.
|
|
6
|
+
*
|
|
7
|
+
* Claude Code sends hook data as JSON via stdin:
|
|
8
|
+
* { tool_name, tool_input: { delaySeconds, prompt, reason }, session_id }
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
|
|
15
|
+
const CWD = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
16
|
+
const LOOPS_DIR = path.join(CWD, '.monomind', 'loops');
|
|
17
|
+
|
|
18
|
+
async function readStdin() {
|
|
19
|
+
if (process.stdin.isTTY) return '';
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
let data = '';
|
|
22
|
+
const timer = setTimeout(() => { process.stdin.removeAllListeners(); resolve(data); }, 3000);
|
|
23
|
+
process.stdin.setEncoding('utf8');
|
|
24
|
+
process.stdin.on('data', chunk => { data += chunk; });
|
|
25
|
+
process.stdin.on('end', () => { clearTimeout(timer); resolve(data); });
|
|
26
|
+
process.stdin.on('error', () => { clearTimeout(timer); resolve(data); });
|
|
27
|
+
process.stdin.resume();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parseRepInfo(prompt, reason) {
|
|
32
|
+
// Try reason first: "repeat run 2/10 of ..."
|
|
33
|
+
const reasonMatch = (reason || '').match(/(\d+)\s*\/\s*(\d+)/);
|
|
34
|
+
if (reasonMatch) {
|
|
35
|
+
return { currentRep: parseInt(reasonMatch[1]), maxReps: parseInt(reasonMatch[2]) };
|
|
36
|
+
}
|
|
37
|
+
// Try prompt flags: --rep 2, --times 10
|
|
38
|
+
const repMatch = (prompt || '').match(/--rep\s+(\d+)/);
|
|
39
|
+
const timesMatch = (prompt || '').match(/--times\s+(\d+)/);
|
|
40
|
+
if (repMatch || timesMatch) {
|
|
41
|
+
return {
|
|
42
|
+
currentRep: repMatch ? parseInt(repMatch[1]) : 1,
|
|
43
|
+
maxReps: timesMatch ? parseInt(timesMatch[1]) : 0,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return { currentRep: 1, maxReps: 0 };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function detectType(prompt, maxReps) {
|
|
50
|
+
if (maxReps > 0) return 'repeat';
|
|
51
|
+
if ((prompt || '').startsWith('/monomind-repeat') || (prompt || '').startsWith('/loop')) return 'repeat';
|
|
52
|
+
return 'do';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function main() {
|
|
56
|
+
const raw = await readStdin();
|
|
57
|
+
if (!raw.trim()) { process.exit(0); }
|
|
58
|
+
|
|
59
|
+
let hookInput = {};
|
|
60
|
+
try { hookInput = JSON.parse(raw); } catch { process.exit(0); }
|
|
61
|
+
|
|
62
|
+
const toolInput = hookInput.tool_input || hookInput.toolInput || {};
|
|
63
|
+
const sessionId = hookInput.session_id || hookInput.sessionId || hookInput.id || '';
|
|
64
|
+
|
|
65
|
+
if (!sessionId) { process.exit(0); }
|
|
66
|
+
|
|
67
|
+
const delaySeconds = toolInput.delaySeconds || toolInput.delay_seconds || 60;
|
|
68
|
+
const prompt = toolInput.prompt || '';
|
|
69
|
+
const reason = toolInput.reason || '';
|
|
70
|
+
|
|
71
|
+
const { currentRep, maxReps } = parseRepInfo(prompt, reason);
|
|
72
|
+
const type = detectType(prompt, maxReps);
|
|
73
|
+
|
|
74
|
+
const loopFile = path.join(LOOPS_DIR, `${sessionId}.json`);
|
|
75
|
+
let existing = {};
|
|
76
|
+
try {
|
|
77
|
+
if (fs.existsSync(loopFile)) {
|
|
78
|
+
existing = JSON.parse(fs.readFileSync(loopFile, 'utf-8'));
|
|
79
|
+
}
|
|
80
|
+
} catch { /* start fresh */ }
|
|
81
|
+
|
|
82
|
+
const now = Date.now();
|
|
83
|
+
const entry = {
|
|
84
|
+
id: sessionId,
|
|
85
|
+
sessionId,
|
|
86
|
+
type,
|
|
87
|
+
status: 'waiting',
|
|
88
|
+
prompt: (prompt || '').slice(0, 300),
|
|
89
|
+
reason,
|
|
90
|
+
startedAt: existing.startedAt || now,
|
|
91
|
+
lastRunAt: now,
|
|
92
|
+
nextRunAt: now + delaySeconds * 1000,
|
|
93
|
+
currentRep,
|
|
94
|
+
maxReps,
|
|
95
|
+
interval: Math.round(delaySeconds / 60),
|
|
96
|
+
source: 'schedule_wakeup_hook',
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
fs.mkdirSync(LOOPS_DIR, { recursive: true });
|
|
101
|
+
fs.writeFileSync(loopFile, JSON.stringify(entry, null, 2), 'utf-8');
|
|
102
|
+
} catch { /* ignore write errors */ }
|
|
103
|
+
|
|
104
|
+
process.exit(0);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
main().catch(() => process.exit(0));
|
|
File without changes
|
|
@@ -167,14 +167,10 @@ function isNonDevTask(taskLower) {
|
|
|
167
167
|
return false;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
// ─── Two-Stage
|
|
171
|
-
// Stage 1:
|
|
172
|
-
// Stage 2:
|
|
173
|
-
//
|
|
174
|
-
|
|
175
|
-
function getAnthropicKey() {
|
|
176
|
-
return process.env.ANTHROPIC_API_KEY || '';
|
|
177
|
-
}
|
|
170
|
+
// ─── Two-Stage Keyword Router (for non-dev and ambiguous tasks) ──────────────
|
|
171
|
+
// Stage 1: pick best category by scoring task tokens against category keywords
|
|
172
|
+
// Stage 2: pick best agent within that category by keyword overlap
|
|
173
|
+
// Pure in-process — no external API calls, no API key required.
|
|
178
174
|
|
|
179
175
|
function buildCategoryList() {
|
|
180
176
|
const registry = loadExtrasRegistry();
|
|
@@ -197,76 +193,60 @@ function getAgentsInCategory(category) {
|
|
|
197
193
|
.map(e => ({ slug: e.slug, name: e.name, description: (e.description || '').slice(0, 120) }));
|
|
198
194
|
}
|
|
199
195
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
},
|
|
213
|
-
body: JSON.stringify({
|
|
214
|
-
model: 'claude-haiku-4-5-20251001',
|
|
215
|
-
max_tokens: 60,
|
|
216
|
-
system: systemPrompt,
|
|
217
|
-
messages: [{ role: 'user', content: userPrompt }],
|
|
218
|
-
}),
|
|
219
|
-
signal: ac.signal,
|
|
220
|
-
});
|
|
221
|
-
clearTimeout(timer);
|
|
222
|
-
if (!resp.ok) return null;
|
|
223
|
-
const data = await resp.json();
|
|
224
|
-
const text = (data.content && data.content[0] && data.content[0].text) || '';
|
|
225
|
-
return text.trim();
|
|
226
|
-
} catch { return null; }
|
|
196
|
+
// Score a task string against an agent entry using keyword overlap
|
|
197
|
+
function scoreAgainstEntry(taskTokens, entry) {
|
|
198
|
+
let score = 0;
|
|
199
|
+
const nameTokens = (entry.name || '').toLowerCase().split(/\W+/).filter(Boolean);
|
|
200
|
+
const descTokens = (entry.description || '').toLowerCase().split(/\W+/).filter(Boolean);
|
|
201
|
+
const kwTokens = Array.isArray(entry.keywords) ? entry.keywords.map(k => k.toLowerCase()) : [];
|
|
202
|
+
const allTokens = new Set([...nameTokens, ...descTokens, ...kwTokens]);
|
|
203
|
+
for (const t of taskTokens) {
|
|
204
|
+
if (allTokens.has(t)) score += 2;
|
|
205
|
+
else for (const s of allTokens) { if (s.includes(t) || t.includes(s)) { score += 1; break; } }
|
|
206
|
+
}
|
|
207
|
+
return score;
|
|
227
208
|
}
|
|
228
209
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const catList = categories.map((c, i) => `${i + 1}. ${c.name} (${c.count} agents, e.g. ${c.examples})`).join('\n');
|
|
235
|
-
const stage1System = 'You route tasks to agent categories. Reply with ONLY the category name, nothing else.';
|
|
236
|
-
const stage1User = `Task: "${task}"\n\nCategories:\n${catList}\n\nWhich category best fits this task? Reply with the category name only.`;
|
|
210
|
+
// Category-level score: sum agent scores within the category
|
|
211
|
+
function scoreCategoryForTask(taskTokens, category, registry) {
|
|
212
|
+
const agents = registry.extras.filter(e => e.category === category);
|
|
213
|
+
return agents.reduce((sum, e) => sum + scoreAgainstEntry(taskTokens, e), 0);
|
|
214
|
+
}
|
|
237
215
|
|
|
238
|
-
|
|
239
|
-
|
|
216
|
+
async function routeTaskLLM(task) {
|
|
217
|
+
const registry = loadExtrasRegistry();
|
|
218
|
+
if (!registry.extras.length) return null;
|
|
240
219
|
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
const categoryName = matchedCat ? matchedCat.name : categories.find(c => catLower.includes(c.name.toLowerCase().replace(/[^a-z-]/g, '')))?.name;
|
|
245
|
-
if (!categoryName) return null;
|
|
220
|
+
const taskLower = task.toLowerCase();
|
|
221
|
+
const STOP = new Set(['the','and','for','are','but','not','you','all','can','had','her','was','one','our','out','day','get','has','him','his','how','its','may','new','now','old','see','two','way','who','did','let','put','say','she','too','use','will','with','that','this','from','they','been','have','make','then','than','when','what','does','into','your']);
|
|
222
|
+
const taskTokens = taskLower.split(/\W+/).filter(w => w.length > 3 && !STOP.has(w));
|
|
246
223
|
|
|
247
|
-
// Stage
|
|
248
|
-
const
|
|
249
|
-
|
|
224
|
+
// Stage 1: pick best category by aggregate keyword score
|
|
225
|
+
const categories = [...new Set(registry.extras.map(e => e.category))];
|
|
226
|
+
const catScores = categories.map(cat => ({
|
|
227
|
+
cat,
|
|
228
|
+
score: scoreCategoryForTask(taskTokens, cat, registry),
|
|
229
|
+
})).sort((a, b) => b.score - a.score);
|
|
250
230
|
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
const stage2User = `Task: "${task}"\n\nAgents in ${categoryName}:\n${agentList}\n\nWhich agent is the best fit? Reply with the exact agent name only.`;
|
|
231
|
+
const bestCat = catScores[0];
|
|
232
|
+
if (!bestCat || bestCat.score === 0) return null;
|
|
254
233
|
|
|
255
|
-
|
|
256
|
-
|
|
234
|
+
// Stage 2: pick best agent within the category
|
|
235
|
+
const candidates = registry.extras.filter(e => e.category === bestCat.cat);
|
|
236
|
+
const scored = candidates.map(e => ({ e, score: scoreAgainstEntry(taskTokens, e) }))
|
|
237
|
+
.sort((a, b) => b.score - a.score);
|
|
257
238
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const matched = agents.find(a => a.name.toLowerCase() === agentLower);
|
|
261
|
-
if (!matched) return null;
|
|
239
|
+
const top = scored[0];
|
|
240
|
+
if (!top || top.score === 0) return null;
|
|
262
241
|
|
|
242
|
+
const allInCat = candidates.map(e => ({ slug: e.slug, label: e.name, note: e.category }));
|
|
263
243
|
return {
|
|
264
|
-
agent:
|
|
265
|
-
agentSlug:
|
|
266
|
-
confidence: 0.
|
|
267
|
-
reason: `
|
|
268
|
-
category:
|
|
269
|
-
allInCategory:
|
|
244
|
+
agent: top.e.name,
|
|
245
|
+
agentSlug: top.e.slug,
|
|
246
|
+
confidence: Math.min(0.85, 0.5 + top.score * 0.05),
|
|
247
|
+
reason: `Keyword 2-stage: ${bestCat.cat} → ${top.e.name}`,
|
|
248
|
+
category: bestCat.cat,
|
|
249
|
+
allInCategory: allInCat,
|
|
270
250
|
};
|
|
271
251
|
}
|
|
272
252
|
|