@monoes/monomindcli 1.10.54 → 1.10.56
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/optimization/benchmark-suite.md +2 -0
- package/.claude/agents/optimization/load-balancer.md +2 -0
- package/.claude/agents/optimization/performance-monitor.md +2 -0
- package/.claude/agents/optimization/resource-allocator.md +3 -1
- package/.claude/agents/optimization/topology-optimizer.md +2 -0
- package/.claude/commands/mastermind/_repeat.md +21 -0
- package/.claude/commands/mastermind/_taskfile.md +235 -0
- package/.claude/commands/mastermind/adr.md +11 -0
- package/.claude/commands/mastermind/approve.md +94 -0
- package/.claude/commands/mastermind/autodev.md +32 -0
- package/.claude/commands/mastermind/budget.md +7 -0
- package/.claude/commands/mastermind/code-review.md +317 -0
- package/.claude/commands/mastermind/createorg.md +40 -1
- package/.claude/commands/mastermind/createtask.md +383 -0
- package/.claude/commands/mastermind/debug.md +22 -0
- package/.claude/commands/mastermind/design.md +20 -0
- package/.claude/commands/mastermind/do.md +526 -0
- package/.claude/commands/mastermind/execute.md +20 -0
- package/.claude/commands/mastermind/finish.md +20 -0
- package/.claude/commands/mastermind/graph-status.md +7 -0
- package/.claude/commands/mastermind/help.md +118 -0
- package/.claude/commands/mastermind/ideate.md +261 -0
- package/.claude/commands/mastermind/improve.md +345 -0
- package/.claude/commands/mastermind/loops.md +7 -0
- package/.claude/commands/mastermind/master.md +186 -6
- package/.claude/commands/mastermind/memory.md +230 -0
- package/.claude/commands/mastermind/plan.md +26 -0
- package/.claude/commands/mastermind/receive-review.md +20 -0
- package/.claude/commands/mastermind/repeat.md +257 -0
- package/.claude/commands/mastermind/runorg.md +3 -0
- package/.claude/commands/mastermind/skill-builder.md +20 -0
- package/.claude/commands/mastermind/specialagents.md +125 -0
- package/.claude/commands/mastermind/swarm.md +161 -0
- package/.claude/commands/mastermind/taskdev.md +26 -0
- package/.claude/commands/mastermind/tdd.md +22 -0
- package/.claude/commands/mastermind/techport.md +4 -0
- package/.claude/commands/mastermind/understand.md +139 -0
- package/.claude/commands/mastermind/verify.md +22 -0
- package/.claude/commands/mastermind/worktree.md +20 -0
- package/.claude/helpers/handlers/graph-status-handler.cjs +2 -1
- package/.claude/helpers/hook-handler.cjs +19 -0
- package/.claude/helpers/skill-registry.json +23 -0
- package/.claude/helpers/statusline.cjs +1 -1
- package/.claude/skills/mastermind/approve.md +15 -7
- package/.claude/skills/mastermind/autodev.md +534 -0
- package/.claude/skills/mastermind/createorg.md +21 -5
- package/.claude/skills/mastermind/debug.md +232 -0
- package/.claude/skills/mastermind/design.md +187 -0
- package/.claude/skills/mastermind/execute.md +104 -0
- package/.claude/skills/mastermind/finish.md +251 -0
- package/.claude/skills/mastermind/plan.md +180 -0
- package/.claude/skills/mastermind/receive-review.md +213 -0
- package/.claude/skills/mastermind/runorg.md +23 -8
- package/.claude/skills/mastermind/skill-builder.md +274 -0
- package/.claude/skills/mastermind/taskdev.md +307 -0
- package/.claude/skills/mastermind/tdd.md +394 -0
- package/.claude/skills/mastermind/verify.md +196 -0
- package/.claude/skills/mastermind/worktree.md +160 -132
- package/README.md +320 -253
- package/dist/src/commands/analyze.d.ts.map +1 -1
- package/dist/src/commands/analyze.js +9 -2
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/completions.js +1 -1
- package/dist/src/commands/guidance.js +7 -7
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +16 -3
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +3 -2
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +7 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +47 -13
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/neural.d.ts.map +1 -1
- package/dist/src/commands/neural.js +100 -14
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/platforms.d.ts +11 -0
- package/dist/src/commands/platforms.d.ts.map +1 -0
- package/dist/src/commands/platforms.js +195 -0
- package/dist/src/commands/platforms.js.map +1 -0
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/update.js +6 -6
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +28 -0
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/statusline-generator.js +1 -1
- package/dist/src/init/types.d.ts +1 -0
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp-server.js +92 -0
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +52 -0
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +106 -5
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +0 -5
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +0 -5
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/monograph-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph-tools.js +507 -5587
- package/dist/src/mcp-tools/monograph-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +64 -4
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/security-tools.js +4 -4
- package/dist/src/memory/intelligence.d.ts +2 -2
- package/dist/src/memory/intelligence.d.ts.map +1 -1
- package/dist/src/memory/intelligence.js +108 -3
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.js +1 -1
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +1 -10
- package/dist/src/memory/sona-optimizer.d.ts.map +1 -1
- package/dist/src/memory/sona-optimizer.js +0 -46
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/runtime/headless.js +3 -3
- package/dist/src/ruvector/diff-classifier.d.ts +0 -2
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -1
- package/dist/src/ruvector/diff-classifier.js +2 -14
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/index.d.ts +26 -9
- package/dist/src/ruvector/index.d.ts.map +1 -1
- package/dist/src/ruvector/index.js +3 -21
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.js +2 -2
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
- package/dist/src/types.d.ts +0 -15
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +0 -18
- package/dist/src/types.js.map +1 -1
- package/dist/src/ui/dashboard.html +8763 -9766
- package/dist/src/ui/orgs.html +1 -1
- package/dist/src/ui/server.mjs +504 -35
- package/dist/src/update/index.js +1 -1
- package/dist/src/update/validator.js +8 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/.claude/agents/academic/academic-anthropologist.md +0 -126
- package/.claude/agents/academic/academic-geographer.md +0 -128
- package/.claude/agents/academic/academic-historian.md +0 -124
- package/.claude/agents/academic/academic-narratologist.md +0 -119
- package/.claude/agents/academic/academic-psychologist.md +0 -119
- package/.claude/agents/analysis/analyze-code-quality.md +0 -58
- package/.claude/agents/analysis/code-analyzer.md +0 -189
- package/.claude/agents/analysis/code-review/analyze-code-quality.md +0 -58
- package/.claude/agents/consensus/performance-benchmarker.md +0 -831
- package/.claude/agents/data/ml/data-ml-model.md +0 -76
- package/.claude/agents/development/dev-backend-api.md +0 -178
- package/.claude/agents/devops/ci-cd/ops-cicd-github.md +0 -52
- package/.claude/agents/documentation/api-docs/docs-api-openapi.md +0 -63
- package/.claude/agents/game-development/blender/blender-addon-engineer.md +0 -235
- package/.claude/agents/game-development/game-audio-engineer.md +0 -265
- package/.claude/agents/game-development/game-designer.md +0 -168
- package/.claude/agents/game-development/godot/godot-gameplay-scripter.md +0 -335
- package/.claude/agents/game-development/godot/godot-multiplayer-engineer.md +0 -298
- package/.claude/agents/game-development/godot/godot-shader-developer.md +0 -267
- package/.claude/agents/game-development/level-designer.md +0 -209
- package/.claude/agents/game-development/narrative-designer.md +0 -244
- package/.claude/agents/game-development/roblox-studio/roblox-avatar-creator.md +0 -298
- package/.claude/agents/game-development/roblox-studio/roblox-experience-designer.md +0 -306
- package/.claude/agents/game-development/roblox-studio/roblox-systems-scripter.md +0 -326
- package/.claude/agents/game-development/technical-artist.md +0 -230
- package/.claude/agents/game-development/unity/unity-architect.md +0 -272
- package/.claude/agents/game-development/unity/unity-editor-tool-developer.md +0 -311
- package/.claude/agents/game-development/unity/unity-multiplayer-engineer.md +0 -322
- package/.claude/agents/game-development/unity/unity-shader-graph-artist.md +0 -270
- package/.claude/agents/game-development/unreal-engine/unreal-multiplayer-architect.md +0 -314
- package/.claude/agents/game-development/unreal-engine/unreal-systems-engineer.md +0 -311
- package/.claude/agents/game-development/unreal-engine/unreal-technical-artist.md +0 -257
- package/.claude/agents/game-development/unreal-engine/unreal-world-builder.md +0 -274
- package/.claude/agents/github/release-swarm.md +0 -597
- package/.claude/agents/goal/agent.md +0 -804
- package/.claude/agents/goal/code-goal-planner.md +0 -445
- package/.claude/agents/marketing/marketing-ai-citation-strategist.md +0 -171
- package/.claude/agents/marketing/marketing-app-store-optimizer.md +0 -322
- package/.claude/agents/marketing/marketing-baidu-seo-specialist.md +0 -227
- package/.claude/agents/marketing/marketing-bilibili-content-strategist.md +0 -200
- package/.claude/agents/marketing/marketing-book-co-author.md +0 -111
- package/.claude/agents/marketing/marketing-carousel-growth-engine.md +0 -200
- package/.claude/agents/marketing/marketing-china-ecommerce-operator.md +0 -284
- package/.claude/agents/marketing/marketing-content-creator.md +0 -67
- package/.claude/agents/marketing/marketing-cross-border-ecommerce.md +0 -260
- package/.claude/agents/marketing/marketing-douyin-strategist.md +0 -150
- package/.claude/agents/marketing/marketing-growth-hacker.md +0 -54
- package/.claude/agents/marketing/marketing-instagram-curator.md +0 -114
- package/.claude/agents/marketing/marketing-kuaishou-strategist.md +0 -224
- package/.claude/agents/marketing/marketing-linkedin-content-creator.md +0 -215
- package/.claude/agents/marketing/marketing-livestream-commerce-coach.md +0 -306
- package/.claude/agents/marketing/marketing-podcast-strategist.md +0 -278
- package/.claude/agents/marketing/marketing-private-domain-operator.md +0 -309
- package/.claude/agents/marketing/marketing-reddit-community-builder.md +0 -124
- package/.claude/agents/marketing/marketing-seo-specialist.md +0 -279
- package/.claude/agents/marketing/marketing-short-video-editing-coach.md +0 -413
- package/.claude/agents/marketing/marketing-social-media-strategist.md +0 -125
- package/.claude/agents/marketing/marketing-tiktok-strategist.md +0 -126
- package/.claude/agents/marketing/marketing-twitter-engager.md +0 -127
- package/.claude/agents/marketing/marketing-wechat-official-account.md +0 -146
- package/.claude/agents/marketing/marketing-weibo-strategist.md +0 -241
- package/.claude/agents/marketing/marketing-xiaohongshu-specialist.md +0 -139
- package/.claude/agents/marketing/marketing-zhihu-strategist.md +0 -163
- package/.claude/agents/neural/safla-neural.md +0 -74
- package/.claude/agents/paid-media/paid-media-auditor.md +0 -71
- package/.claude/agents/paid-media/paid-media-creative-strategist.md +0 -71
- package/.claude/agents/paid-media/paid-media-paid-social-strategist.md +0 -71
- package/.claude/agents/paid-media/paid-media-ppc-strategist.md +0 -71
- package/.claude/agents/paid-media/paid-media-programmatic-buyer.md +0 -71
- package/.claude/agents/paid-media/paid-media-search-query-analyst.md +0 -71
- package/.claude/agents/paid-media/paid-media-tracking-specialist.md +0 -71
- package/.claude/agents/payments/agentic-payments.md +0 -126
- package/.claude/agents/product/product-behavioral-nudge-engine.md +0 -81
- package/.claude/agents/product/product-feedback-synthesizer.md +0 -119
- package/.claude/agents/product/product-manager.md +0 -469
- package/.claude/agents/product/product-sprint-prioritizer.md +0 -154
- package/.claude/agents/product/product-trend-researcher.md +0 -159
- package/.claude/agents/project-management/project-management-experiment-tracker.md +0 -199
- package/.claude/agents/project-management/project-management-jira-workflow-steward.md +0 -231
- package/.claude/agents/project-management/project-management-project-shepherd.md +0 -195
- package/.claude/agents/project-management/project-management-studio-operations.md +0 -201
- package/.claude/agents/project-management/project-management-studio-producer.md +0 -204
- package/.claude/agents/project-management/project-manager-senior.md +0 -136
- package/.claude/agents/reasoning/agent.md +0 -804
- package/.claude/agents/reasoning/goal-planner.md +0 -73
- package/.claude/agents/sales/sales-account-strategist.md +0 -228
- package/.claude/agents/sales/sales-coach.md +0 -272
- package/.claude/agents/sales/sales-deal-strategist.md +0 -181
- package/.claude/agents/sales/sales-discovery-coach.md +0 -226
- package/.claude/agents/sales/sales-engineer.md +0 -183
- package/.claude/agents/sales/sales-outbound-strategist.md +0 -202
- package/.claude/agents/sales/sales-pipeline-analyst.md +0 -268
- package/.claude/agents/sales/sales-proposal-strategist.md +0 -218
- package/.claude/agents/sona/sona-learning-optimizer.md +0 -65
- package/.claude/agents/spatial-computing/macos-spatial-metal-engineer.md +0 -338
- package/.claude/agents/spatial-computing/terminal-integration-specialist.md +0 -71
- package/.claude/agents/spatial-computing/visionos-spatial-engineer.md +0 -55
- package/.claude/agents/specialists/memory-specialist.md +0 -298
- package/.claude/agents/specialists/performance-engineer.md +0 -387
- package/.claude/agents/specialists/queen-coordinator.md +0 -67
- package/.claude/agents/specialists/security-architect.md +0 -154
- package/.claude/agents/specialized/accounts-payable-agent.md +0 -186
- package/.claude/agents/specialized/corporate-training-designer.md +0 -193
- package/.claude/agents/specialized/data-consolidation-agent.md +0 -61
- package/.claude/agents/specialized/government-digital-presales-consultant.md +0 -364
- package/.claude/agents/specialized/healthcare-marketing-compliance.md +0 -396
- package/.claude/agents/specialized/recruitment-specialist.md +0 -510
- package/.claude/agents/specialized/report-distribution-agent.md +0 -66
- package/.claude/agents/specialized/sales-data-extraction-agent.md +0 -68
- package/.claude/agents/specialized/specialized-french-consulting-market.md +0 -193
- package/.claude/agents/specialized/specialized-korean-business-navigator.md +0 -217
- package/.claude/agents/specialized/specialized-salesforce-architect.md +0 -181
- package/.claude/agents/specialized/study-abroad-advisor.md +0 -283
- package/.claude/agents/specialized/supply-chain-strategist.md +0 -583
- package/.claude/agents/sublinear/consensus-coordinator.md +0 -333
- package/.claude/agents/sublinear/matrix-optimizer.md +0 -180
- package/.claude/agents/sublinear/pagerank-analyzer.md +0 -295
- package/.claude/agents/sublinear/performance-optimizer.md +0 -363
- package/.claude/agents/sublinear/trading-predictor.md +0 -242
- package/.claude/agents/support/support-analytics-reporter.md +0 -366
- package/.claude/agents/support/support-executive-summary-generator.md +0 -213
- package/.claude/agents/support/support-finance-tracker.md +0 -443
- package/.claude/agents/support/support-infrastructure-maintainer.md +0 -619
- package/.claude/agents/support/support-legal-compliance-checker.md +0 -589
- package/.claude/agents/support/support-support-responder.md +0 -586
- package/.claude/agents/swarm/adaptive-coordinator.md +0 -364
- package/.claude/agents/swarm/hierarchical-coordinator.md +0 -318
- package/.claude/agents/templates/github-pr-manager.md +0 -155
- package/.claude/agents/templates/memory-coordinator.md +0 -163
- package/.claude/agents/templates/migration-plan.md +0 -724
- package/.claude/agents/templates/orchestrator-task.md +0 -120
- package/.claude/agents/templates/performance-analyzer.md +0 -179
- package/.claude/agents/templates/sparc-coordinator.md +0 -163
- package/.claude/agents/testing/testing-reality-checker.md +0 -237
- package/.claude/commands/analysis/token-efficiency.md +0 -42
- package/.claude/commands/optimization/README.md +0 -73
- package/.claude/commands/optimization/parallel-execution.md +0 -76
- package/.claude/commands/swarm/swarm-analysis.md +0 -62
- package/.claude/commands/swarm/swarm-background.md +0 -65
- package/.claude/commands/swarm/swarm-modes.md +0 -67
- package/.claude/commands/swarm/swarm-monitor.md +0 -54
- package/.claude/commands/swarm/swarm-status.md +0 -44
- package/.claude/commands/swarm/swarm-strategies.md +0 -76
- package/.claude/commands/training/model-update.md +0 -78
- package/.claude/commands/training/pattern-learn.md +0 -69
- package/.claude/commands/training/specialization.md +0 -92
- package/.claude/commands/verify/check.md +0 -106
- package/.claude/commands/verify/start.md +0 -105
- package/.claude/helpers/README.md +0 -105
- package/.claude/helpers/context-persistence-hook.mjs +0 -1988
- package/.claude/helpers/intelligence.cjs +0 -247
- package/.claude/helpers/learning-service.mjs +0 -1302
- package/.claude/helpers/memory-palace.cjs +0 -461
- package/.claude/helpers/memory.cjs +0 -84
- package/.claude/helpers/metrics-db.mjs +0 -488
- package/.claude/helpers/router.cjs +0 -559
- package/.claude/helpers/session.cjs +0 -126
- package/.claude/helpers/swarm-hooks.sh +0 -761
- package/.claude/helpers/toggle-statusline.cjs +0 -58
- package/.claude/helpers/token-tracker.cjs +0 -934
- package/.claude/skills/agentdb-advanced/SKILL.md +0 -549
- package/.claude/skills/agentdb-learning/SKILL.md +0 -544
- package/.claude/skills/agentdb-memory-patterns/SKILL.md +0 -337
- package/.claude/skills/agentdb-optimization/SKILL.md +0 -508
- package/.claude/skills/agentdb-vector-search/SKILL.md +0 -335
- package/.claude/skills/agentic-integration/SKILL.md +0 -265
- package/.claude/skills/cli-modernization/SKILL.md +0 -950
- package/.claude/skills/core-implementation/SKILL.md +0 -892
- package/.claude/skills/ddd-architecture/SKILL.md +0 -444
- package/.claude/skills/github-code-review/SKILL.md +0 -1147
- package/.claude/skills/github-multi-repo/SKILL.md +0 -912
- package/.claude/skills/github-project-management/SKILL.md +0 -1245
- package/.claude/skills/github-release-management/SKILL.md +0 -1118
- package/.claude/skills/github-workflow-automation/SKILL.md +0 -1107
- package/.claude/skills/mcp-optimization/SKILL.md +0 -837
- package/.claude/skills/memory-unification/SKILL.md +0 -196
- package/.claude/skills/performance-optimization/SKILL.md +0 -416
- package/.claude/skills/reasoningbank-agentdb/SKILL.md +0 -444
- package/.claude/skills/reasoningbank-intelligence/SKILL.md +0 -199
- package/.claude/skills/security-hardening/SKILL.md +0 -101
- package/.claude/skills/stream-chain/SKILL.md +0 -560
- package/.claude/skills/swarm-coordination/SKILL.md +0 -451
- package/bundled-graph/dist/src/analyze.d.ts +0 -32
- package/bundled-graph/dist/src/analyze.d.ts.map +0 -1
- package/bundled-graph/dist/src/analyze.js +0 -297
- package/bundled-graph/dist/src/analyze.js.map +0 -1
- package/bundled-graph/dist/src/build.d.ts +0 -8
- package/bundled-graph/dist/src/build.d.ts.map +0 -1
- package/bundled-graph/dist/src/build.js.map +0 -1
- package/bundled-graph/dist/src/cache.d.ts +0 -12
- package/bundled-graph/dist/src/cache.d.ts.map +0 -1
- package/bundled-graph/dist/src/cache.js +0 -43
- package/bundled-graph/dist/src/cache.js.map +0 -1
- package/bundled-graph/dist/src/cluster.d.ts +0 -5
- package/bundled-graph/dist/src/cluster.d.ts.map +0 -1
- package/bundled-graph/dist/src/cluster.js.map +0 -1
- package/bundled-graph/dist/src/detect.d.ts +0 -21
- package/bundled-graph/dist/src/detect.d.ts.map +0 -1
- package/bundled-graph/dist/src/detect.js +0 -195
- package/bundled-graph/dist/src/detect.js.map +0 -1
- package/bundled-graph/dist/src/export.d.ts +0 -21
- package/bundled-graph/dist/src/export.d.ts.map +0 -1
- package/bundled-graph/dist/src/export.js +0 -68
- package/bundled-graph/dist/src/export.js.map +0 -1
- package/bundled-graph/dist/src/extract/index.d.ts +0 -20
- package/bundled-graph/dist/src/extract/index.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/index.js +0 -158
- package/bundled-graph/dist/src/extract/index.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/c.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/c.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/c.js +0 -88
- package/bundled-graph/dist/src/extract/languages/c.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/cpp.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/cpp.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/cpp.js +0 -121
- package/bundled-graph/dist/src/extract/languages/cpp.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/csharp.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/csharp.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/csharp.js +0 -121
- package/bundled-graph/dist/src/extract/languages/csharp.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/go.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/go.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/go.js +0 -181
- package/bundled-graph/dist/src/extract/languages/go.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/java.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/java.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/java.js +0 -117
- package/bundled-graph/dist/src/extract/languages/java.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/kotlin.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/kotlin.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/kotlin.js +0 -112
- package/bundled-graph/dist/src/extract/languages/kotlin.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/php.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/php.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/php.js +0 -130
- package/bundled-graph/dist/src/extract/languages/php.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/python.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/python.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/python.js +0 -230
- package/bundled-graph/dist/src/extract/languages/python.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/ruby.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/ruby.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/ruby.js +0 -120
- package/bundled-graph/dist/src/extract/languages/ruby.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/rust.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/rust.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/rust.js +0 -195
- package/bundled-graph/dist/src/extract/languages/rust.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/scala.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/scala.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/scala.js +0 -110
- package/bundled-graph/dist/src/extract/languages/scala.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/swift.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/swift.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/swift.js +0 -122
- package/bundled-graph/dist/src/extract/languages/swift.js.map +0 -1
- package/bundled-graph/dist/src/extract/languages/typescript.d.ts +0 -3
- package/bundled-graph/dist/src/extract/languages/typescript.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/languages/typescript.js +0 -295
- package/bundled-graph/dist/src/extract/languages/typescript.js.map +0 -1
- package/bundled-graph/dist/src/extract/semantic.d.ts +0 -38
- package/bundled-graph/dist/src/extract/semantic.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/semantic.js +0 -242
- package/bundled-graph/dist/src/extract/semantic.js.map +0 -1
- package/bundled-graph/dist/src/extract/tree-sitter-runner.d.ts +0 -48
- package/bundled-graph/dist/src/extract/tree-sitter-runner.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/tree-sitter-runner.js +0 -137
- package/bundled-graph/dist/src/extract/tree-sitter-runner.js.map +0 -1
- package/bundled-graph/dist/src/extract/types.d.ts +0 -7
- package/bundled-graph/dist/src/extract/types.d.ts.map +0 -1
- package/bundled-graph/dist/src/extract/types.js +0 -2
- package/bundled-graph/dist/src/extract/types.js.map +0 -1
- package/bundled-graph/dist/src/index.d.ts +0 -28
- package/bundled-graph/dist/src/index.d.ts.map +0 -1
- package/bundled-graph/dist/src/index.js +0 -26
- package/bundled-graph/dist/src/index.js.map +0 -1
- package/bundled-graph/dist/src/pipeline.d.ts +0 -27
- package/bundled-graph/dist/src/pipeline.d.ts.map +0 -1
- package/bundled-graph/dist/src/pipeline.js +0 -269
- package/bundled-graph/dist/src/pipeline.js.map +0 -1
- package/bundled-graph/dist/src/report.d.ts +0 -26
- package/bundled-graph/dist/src/report.d.ts.map +0 -1
- package/bundled-graph/dist/src/report.js +0 -214
- package/bundled-graph/dist/src/report.js.map +0 -1
- package/bundled-graph/dist/src/types.d.ts +0 -124
- package/bundled-graph/dist/src/types.d.ts.map +0 -1
- package/bundled-graph/dist/src/types.js +0 -2
- package/bundled-graph/dist/src/types.js.map +0 -1
- package/bundled-graph/dist/src/visualize.d.ts +0 -4
- package/bundled-graph/dist/src/visualize.d.ts.map +0 -1
- package/bundled-graph/dist/src/visualize.js +0 -574
- package/bundled-graph/dist/src/visualize.js.map +0 -1
- package/bundled-graph/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/src/ui/dashboard-v2.html +0 -5316
|
@@ -1,461 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* memory-palace.cjs — MemPalace-inspired cross-session memory for Monomind
|
|
4
|
-
*
|
|
5
|
-
* Architecture (Wing → Room → Hall namespace hierarchy):
|
|
6
|
-
* Drawers verbatim 800-char chunks with 100-char overlap → drawers.jsonl
|
|
7
|
-
* Closets regex topic-pointer index (no AI calls) → closets.jsonl
|
|
8
|
-
* KG temporal knowledge graph (SQLite-free triples) → kg.json
|
|
9
|
-
*
|
|
10
|
-
* Memory stack:
|
|
11
|
-
* L0 identity identity.md — static, user-maintained
|
|
12
|
-
* L1 essential top-scored recent drawers → injected on session-restore
|
|
13
|
-
* L2 on-demand recall(wing, room) — explicit namespace pull
|
|
14
|
-
* L3 deep search search(query) — Okapi BM25 across all drawers
|
|
15
|
-
*
|
|
16
|
-
* Wire points in hook-handler.cjs:
|
|
17
|
-
* session-restore → wakeUp(CWD) injects L0 + L1 into session context
|
|
18
|
-
* post-task → storeVerbatim(...) files the verbatim task chunks
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
const fs = require('fs');
|
|
22
|
-
const path = require('path');
|
|
23
|
-
|
|
24
|
-
// ── constants ─────────────────────────────────────────────────────────────────
|
|
25
|
-
const DRAWER_SIZE = 800; // chars per verbatim chunk
|
|
26
|
-
const OVERLAP = 100; // overlap between consecutive chunks
|
|
27
|
-
const L1_LIMIT = 5; // max drawers surfaced in essential story
|
|
28
|
-
const L1_DAYS = 30; // look-back window for L1 drawers (days)
|
|
29
|
-
const BM25_K1 = 1.5; // term-frequency saturation
|
|
30
|
-
const BM25_B = 0.75; // length normalisation
|
|
31
|
-
|
|
32
|
-
// ── filesystem helpers ────────────────────────────────────────────────────────
|
|
33
|
-
function palaceDir(cwd) {
|
|
34
|
-
return path.join(cwd, '.monomind', 'palace');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function ensureDir(dir) {
|
|
38
|
-
if (!fs.existsSync(dir)) {
|
|
39
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function readJsonl(filePath) {
|
|
44
|
-
if (!fs.existsSync(filePath)) return [];
|
|
45
|
-
try {
|
|
46
|
-
return fs.readFileSync(filePath, 'utf-8')
|
|
47
|
-
.split('\n')
|
|
48
|
-
.filter(Boolean)
|
|
49
|
-
.map(function(line) { return JSON.parse(line); });
|
|
50
|
-
} catch (e) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function appendJsonl(filePath, record) {
|
|
56
|
-
fs.appendFileSync(filePath, JSON.stringify(record) + '\n', 'utf-8');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function readJson(filePath, fallback) {
|
|
60
|
-
if (!fs.existsSync(filePath)) return fallback;
|
|
61
|
-
try {
|
|
62
|
-
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
63
|
-
} catch (e) {
|
|
64
|
-
return fallback;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function writeJson(filePath, data) {
|
|
69
|
-
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function uid() {
|
|
73
|
-
return Date.now().toString(36) + Math.random().toString(36).slice(2, 7);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ── Okapi BM25 ────────────────────────────────────────────────────────────────
|
|
77
|
-
function tokenize(text) {
|
|
78
|
-
return (text || '').toLowerCase().replace(/[^a-z0-9\s]/g, ' ').split(/\s+/).filter(Boolean);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* bm25(query, docs) → [{ id, score }, …] sorted descending
|
|
83
|
-
* docs: array of { id, text }
|
|
84
|
-
*/
|
|
85
|
-
function bm25(query, docs) {
|
|
86
|
-
if (!docs || docs.length === 0) return [];
|
|
87
|
-
var qTerms = tokenize(query);
|
|
88
|
-
if (qTerms.length === 0) return docs.map(function(d) { return { id: d.id, score: 0 }; });
|
|
89
|
-
|
|
90
|
-
// Pre-tokenize every document
|
|
91
|
-
var tokenized = docs.map(function(d) {
|
|
92
|
-
return { id: d.id, tokens: tokenize(d.text || '') };
|
|
93
|
-
});
|
|
94
|
-
var N = tokenized.length;
|
|
95
|
-
var avgdl = tokenized.reduce(function(s, d) { return s + d.tokens.length; }, 0) / (N || 1);
|
|
96
|
-
|
|
97
|
-
// Document frequency per term
|
|
98
|
-
var df = {};
|
|
99
|
-
tokenized.forEach(function(d) {
|
|
100
|
-
var seen = {};
|
|
101
|
-
d.tokens.forEach(function(t) { seen[t] = true; });
|
|
102
|
-
Object.keys(seen).forEach(function(t) { df[t] = (df[t] || 0) + 1; });
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// Score each document
|
|
106
|
-
return tokenized.map(function(d) {
|
|
107
|
-
var tf = {};
|
|
108
|
-
d.tokens.forEach(function(t) { tf[t] = (tf[t] || 0) + 1; });
|
|
109
|
-
var dl = d.tokens.length;
|
|
110
|
-
var score = 0;
|
|
111
|
-
qTerms.forEach(function(term) {
|
|
112
|
-
var f = tf[term] || 0;
|
|
113
|
-
if (f === 0) return;
|
|
114
|
-
var dfTerm = df[term] || 0;
|
|
115
|
-
var idf = Math.log((N - dfTerm + 0.5) / (dfTerm + 0.5) + 1);
|
|
116
|
-
score += idf * (f * (BM25_K1 + 1)) / (f + BM25_K1 * (1 - BM25_B + BM25_B * dl / avgdl));
|
|
117
|
-
});
|
|
118
|
-
return { id: d.id, score: score };
|
|
119
|
-
}).sort(function(a, b) { return b.score - a.score; });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// ── closet extraction (no AI, regex only) ─────────────────────────────────────
|
|
123
|
-
/**
|
|
124
|
-
* buildClosets(content, drawerId) → [closet record, …]
|
|
125
|
-
* Extracts: section headers, action phrases, proper nouns, quoted passages.
|
|
126
|
-
*/
|
|
127
|
-
function buildClosets(content, drawerId) {
|
|
128
|
-
var results = [];
|
|
129
|
-
var ts = new Date().toISOString();
|
|
130
|
-
var m;
|
|
131
|
-
|
|
132
|
-
// Section headers (Markdown)
|
|
133
|
-
var headerRe = /^#{1,3}\s+(.+)$/gm;
|
|
134
|
-
while ((m = headerRe.exec(content)) !== null) {
|
|
135
|
-
results.push({ drawerId: drawerId, term: m[1].trim(), type: 'header', ts: ts });
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Action phrases: "verb Object"
|
|
139
|
-
var actionRe = /\b(built|fixed|added|implemented|created|removed|updated|refactored|deployed|configured|enabled|disabled|migrated|merged|published|released|optimized|rewrote|designed|analyzed|reviewed)\s+([A-Za-z][A-Za-z0-9_/.-]{1,50})/g;
|
|
140
|
-
while ((m = actionRe.exec(content)) !== null) {
|
|
141
|
-
results.push({ drawerId: drawerId, term: m[1] + ' ' + m[2], type: 'action', ts: ts });
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Proper nouns: consecutive Title Case words
|
|
145
|
-
var properRe = /\b([A-Z][a-z]+(?:\s+[A-Z][a-z]+)+)\b/g;
|
|
146
|
-
var properSeen = {};
|
|
147
|
-
while ((m = properRe.exec(content)) !== null) {
|
|
148
|
-
if (!properSeen[m[1]]) {
|
|
149
|
-
properSeen[m[1]] = true;
|
|
150
|
-
results.push({ drawerId: drawerId, term: m[1], type: 'proper', ts: ts });
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Quoted passages (3–60 chars)
|
|
155
|
-
var quotedRe = /"([^"]{3,60})"|`([^`]{3,60})`/g;
|
|
156
|
-
while ((m = quotedRe.exec(content)) !== null) {
|
|
157
|
-
var phrase = (m[1] || m[2]).trim();
|
|
158
|
-
results.push({ drawerId: drawerId, term: phrase, type: 'quoted', ts: ts });
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return results;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// ── storeVerbatim ─────────────────────────────────────────────────────────────
|
|
165
|
-
/**
|
|
166
|
-
* storeVerbatim(cwd, content, { wing, room, hall })
|
|
167
|
-
* Chunks content into DRAWER_SIZE-char segments (with OVERLAP), stores each
|
|
168
|
-
* as a drawer and extracts closet topics from each chunk.
|
|
169
|
-
*/
|
|
170
|
-
function storeVerbatim(cwd, content, meta) {
|
|
171
|
-
if (!content || typeof content !== 'string' || content.trim().length < 20) return;
|
|
172
|
-
var pDir = palaceDir(cwd);
|
|
173
|
-
ensureDir(pDir);
|
|
174
|
-
|
|
175
|
-
var wing = (meta && meta.wing) || 'general';
|
|
176
|
-
var room = (meta && meta.room) || 'default';
|
|
177
|
-
var hall = (meta && meta.hall) || '';
|
|
178
|
-
var ts = new Date().toISOString();
|
|
179
|
-
|
|
180
|
-
var drawersFile = path.join(pDir, 'drawers.jsonl');
|
|
181
|
-
var closetsFile = path.join(pDir, 'closets.jsonl');
|
|
182
|
-
|
|
183
|
-
var step = DRAWER_SIZE - OVERLAP;
|
|
184
|
-
var i = 0;
|
|
185
|
-
while (i < content.length) {
|
|
186
|
-
var chunk = content.slice(i, i + DRAWER_SIZE);
|
|
187
|
-
if (chunk.trim().length >= 20) {
|
|
188
|
-
var id = uid();
|
|
189
|
-
var drawer = { id: id, content: chunk, wing: wing, room: room, hall: hall, score: 1.0, ts: ts };
|
|
190
|
-
appendJsonl(drawersFile, drawer);
|
|
191
|
-
var closets = buildClosets(chunk, id);
|
|
192
|
-
closets.forEach(function(c) { appendJsonl(closetsFile, c); });
|
|
193
|
-
}
|
|
194
|
-
if (i + DRAWER_SIZE >= content.length) break;
|
|
195
|
-
i += step;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// ── score persistence ─────────────────────────────────────────────────────────
|
|
200
|
-
/**
|
|
201
|
-
* _bumpScores(drawersFile, ids)
|
|
202
|
-
* Appends score bumps to a sidecar .score-diffs.jsonl instead of rewriting
|
|
203
|
-
* the full drawers.jsonl on every search. Compacts when sidecar reaches 100 entries.
|
|
204
|
-
* Called after search/recall so frequently-retrieved drawers rise to L1.
|
|
205
|
-
*/
|
|
206
|
-
function _bumpScores(drawersFile, ids) {
|
|
207
|
-
if (!ids || ids.length === 0) return;
|
|
208
|
-
var diffPath = drawersFile.replace('.jsonl', '-score-diffs.jsonl');
|
|
209
|
-
try {
|
|
210
|
-
var entry = JSON.stringify({ ts: Date.now(), bumpIds: ids, delta: 1 });
|
|
211
|
-
fs.appendFileSync(diffPath, entry + '\n', 'utf-8');
|
|
212
|
-
_maybeCompactScoreDiffs(drawersFile, diffPath);
|
|
213
|
-
} catch (e) { /* non-fatal */ }
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* _maybeCompactScoreDiffs(drawersFile, diffPath)
|
|
218
|
-
* When the sidecar accumulates >= 100 entries, apply all diffs to the drawers
|
|
219
|
-
* file atomically and delete the sidecar.
|
|
220
|
-
*/
|
|
221
|
-
function _maybeCompactScoreDiffs(drawersFile, diffPath) {
|
|
222
|
-
var lines;
|
|
223
|
-
try {
|
|
224
|
-
lines = fs.readFileSync(diffPath, 'utf-8').split('\n').filter(Boolean);
|
|
225
|
-
} catch { return; }
|
|
226
|
-
if (lines.length < 100) return;
|
|
227
|
-
_applyScoreDiffs(drawersFile, diffPath, lines);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* _applyScoreDiffs(drawersFile, diffPath, lines)
|
|
232
|
-
* Apply accumulated score diffs to drawers.jsonl atomically, then remove sidecar.
|
|
233
|
-
*/
|
|
234
|
-
function _applyScoreDiffs(drawersFile, diffPath, lines) {
|
|
235
|
-
try {
|
|
236
|
-
var drawers = readJsonl(drawersFile);
|
|
237
|
-
var diffs = (lines || fs.readFileSync(diffPath, 'utf-8').split('\n').filter(Boolean))
|
|
238
|
-
.map(function(l) { try { return JSON.parse(l); } catch { return null; } })
|
|
239
|
-
.filter(Boolean);
|
|
240
|
-
for (var i = 0; i < diffs.length; i++) {
|
|
241
|
-
var diff = diffs[i];
|
|
242
|
-
var delta = diff.delta || 1;
|
|
243
|
-
(diff.bumpIds || []).forEach(function(id) {
|
|
244
|
-
var d = drawers.find(function(x) { return x.id === id; });
|
|
245
|
-
if (d) d.score = (d.score || 1.0) + delta;
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
var tmpPath = drawersFile + '.tmp';
|
|
249
|
-
fs.writeFileSync(tmpPath, drawers.map(function(d) { return JSON.stringify(d); }).join('\n') + '\n', 'utf-8');
|
|
250
|
-
fs.renameSync(tmpPath, drawersFile);
|
|
251
|
-
try { fs.unlinkSync(diffPath); } catch {}
|
|
252
|
-
} catch (e) { /* non-fatal — leave sidecar intact for next attempt */ }
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* _getEffectiveDrawers(drawersFile)
|
|
257
|
-
* Read drawers.jsonl and apply any pending score diffs from the sidecar,
|
|
258
|
-
* returning the merged result without compacting. Used by wakeUp/recall/search
|
|
259
|
-
* to get accurate scores without triggering a full compact.
|
|
260
|
-
*/
|
|
261
|
-
function _getEffectiveDrawers(drawersFile) {
|
|
262
|
-
var drawers = readJsonl(drawersFile);
|
|
263
|
-
var diffPath = drawersFile.replace('.jsonl', '-score-diffs.jsonl');
|
|
264
|
-
try {
|
|
265
|
-
var lines = fs.readFileSync(diffPath, 'utf-8').split('\n').filter(Boolean);
|
|
266
|
-
var diffs = lines.map(function(l) { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean);
|
|
267
|
-
// Build score bump totals per id
|
|
268
|
-
var bumps = {};
|
|
269
|
-
diffs.forEach(function(diff) {
|
|
270
|
-
(diff.bumpIds || []).forEach(function(id) {
|
|
271
|
-
bumps[id] = (bumps[id] || 0) + (diff.delta || 1);
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
drawers.forEach(function(d) {
|
|
275
|
-
if (bumps[d.id]) d.score = (d.score || 1.0) + bumps[d.id];
|
|
276
|
-
});
|
|
277
|
-
} catch { /* sidecar absent — use raw drawers */ }
|
|
278
|
-
return drawers;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// ── search (L3 deep) ──────────────────────────────────────────────────────────
|
|
282
|
-
/**
|
|
283
|
-
* search(cwd, query, { wing, room, limit }) → drawer[]
|
|
284
|
-
* BM25 across all drawers + closet-topic boost, filtered by wing/room.
|
|
285
|
-
* Bumps score on retrieved drawers so L1 surfaces actually-used content.
|
|
286
|
-
*/
|
|
287
|
-
function search(cwd, query, opts) {
|
|
288
|
-
opts = opts || {};
|
|
289
|
-
var limit = opts.limit || 5;
|
|
290
|
-
var pDir = palaceDir(cwd);
|
|
291
|
-
var drawersFile = path.join(pDir, 'drawers.jsonl');
|
|
292
|
-
var drawers = _getEffectiveDrawers(drawersFile);
|
|
293
|
-
|
|
294
|
-
if (opts.wing) drawers = drawers.filter(function(d) { return d.wing === opts.wing; });
|
|
295
|
-
if (opts.room) drawers = drawers.filter(function(d) { return d.room === opts.room; });
|
|
296
|
-
if (drawers.length === 0) return [];
|
|
297
|
-
|
|
298
|
-
// BM25 baseline
|
|
299
|
-
var docs = drawers.map(function(d) { return { id: d.id, text: d.content }; });
|
|
300
|
-
var ranked = bm25(query, docs);
|
|
301
|
-
|
|
302
|
-
// Closet boost: drawers whose topic terms match query words get +0.5
|
|
303
|
-
try {
|
|
304
|
-
var closets = readJsonl(path.join(pDir, 'closets.jsonl'));
|
|
305
|
-
var qWords = tokenize(query);
|
|
306
|
-
var closetBoost = {};
|
|
307
|
-
closets.forEach(function(c) {
|
|
308
|
-
var termWords = tokenize(c.term);
|
|
309
|
-
var hit = termWords.some(function(w) { return qWords.indexOf(w) !== -1; });
|
|
310
|
-
if (hit) closetBoost[c.drawerId] = (closetBoost[c.drawerId] || 0) + 0.5;
|
|
311
|
-
});
|
|
312
|
-
if (Object.keys(closetBoost).length > 0) {
|
|
313
|
-
ranked.forEach(function(r) { r.score += (closetBoost[r.id] || 0); });
|
|
314
|
-
ranked.sort(function(a, b) { return b.score - a.score; });
|
|
315
|
-
}
|
|
316
|
-
} catch (e) { /* non-fatal */ }
|
|
317
|
-
|
|
318
|
-
var topIds = ranked.slice(0, limit).map(function(r) { return r.id; });
|
|
319
|
-
_bumpScores(drawersFile, topIds);
|
|
320
|
-
|
|
321
|
-
var drawerMap = {};
|
|
322
|
-
drawers.forEach(function(d) { drawerMap[d.id] = d; });
|
|
323
|
-
return topIds.map(function(id) { return drawerMap[id]; }).filter(Boolean);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// ── recall (L2 on-demand) ─────────────────────────────────────────────────────
|
|
327
|
-
/**
|
|
328
|
-
* recall(cwd, { wing, room, limit }) → drawer[]
|
|
329
|
-
* Returns drawers matching the namespace, sorted by score desc.
|
|
330
|
-
* Bumps score on returned drawers.
|
|
331
|
-
*/
|
|
332
|
-
function recall(cwd, opts) {
|
|
333
|
-
opts = opts || {};
|
|
334
|
-
var limit = opts.limit || 10;
|
|
335
|
-
var drawersFile = path.join(palaceDir(cwd), 'drawers.jsonl');
|
|
336
|
-
var drawers = _getEffectiveDrawers(drawersFile);
|
|
337
|
-
if (opts.wing) drawers = drawers.filter(function(d) { return d.wing === opts.wing; });
|
|
338
|
-
if (opts.room) drawers = drawers.filter(function(d) { return d.room === opts.room; });
|
|
339
|
-
var top = drawers
|
|
340
|
-
.sort(function(a, b) { return (b.score || 0) - (a.score || 0); })
|
|
341
|
-
.slice(0, limit);
|
|
342
|
-
_bumpScores(drawersFile, top.map(function(d) { return d.id; }));
|
|
343
|
-
return top;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// ── knowledge graph ───────────────────────────────────────────────────────────
|
|
347
|
-
/**
|
|
348
|
-
* kgAdd(cwd, subject, predicate, object, validFrom, confidence, sourceId)
|
|
349
|
-
* Appends a temporal triple. validFrom defaults to now; valid_to = null (open).
|
|
350
|
-
*/
|
|
351
|
-
function kgAdd(cwd, subject, predicate, object, validFrom, confidence, sourceId) {
|
|
352
|
-
var pDir = palaceDir(cwd);
|
|
353
|
-
ensureDir(pDir);
|
|
354
|
-
var kgFile = path.join(pDir, 'kg.json');
|
|
355
|
-
var kg = readJson(kgFile, []);
|
|
356
|
-
kg.push({
|
|
357
|
-
id: uid(),
|
|
358
|
-
subject: String(subject),
|
|
359
|
-
predicate: String(predicate),
|
|
360
|
-
object: String(object),
|
|
361
|
-
valid_from: validFrom || new Date().toISOString(),
|
|
362
|
-
valid_to: null,
|
|
363
|
-
confidence: typeof confidence === 'number' ? confidence : 1.0,
|
|
364
|
-
source_id: sourceId || null,
|
|
365
|
-
created_at: new Date().toISOString(),
|
|
366
|
-
});
|
|
367
|
-
writeJson(kgFile, kg);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* kgQuery(cwd, entity, asOf) → triple[]
|
|
372
|
-
* Triples where subject = entity, valid at the given time (defaults to now).
|
|
373
|
-
*/
|
|
374
|
-
function kgQuery(cwd, entity, asOf) {
|
|
375
|
-
var kgFile = path.join(palaceDir(cwd), 'kg.json');
|
|
376
|
-
var kg = readJson(kgFile, []);
|
|
377
|
-
var t = asOf ? new Date(asOf).getTime() : Date.now();
|
|
378
|
-
return kg.filter(function(triple) {
|
|
379
|
-
if (triple.subject !== entity) return false;
|
|
380
|
-
var from = triple.valid_from ? new Date(triple.valid_from).getTime() : 0;
|
|
381
|
-
var to = triple.valid_to ? new Date(triple.valid_to).getTime() : Infinity;
|
|
382
|
-
return t >= from && t <= to;
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* kgTimeline(cwd, entity) → triple[] (chronological)
|
|
388
|
-
* Full history of facts about entity, sorted by valid_from.
|
|
389
|
-
*/
|
|
390
|
-
function kgTimeline(cwd, entity) {
|
|
391
|
-
var kgFile = path.join(palaceDir(cwd), 'kg.json');
|
|
392
|
-
var kg = readJson(kgFile, []);
|
|
393
|
-
return kg
|
|
394
|
-
.filter(function(t) { return t.subject === entity; })
|
|
395
|
-
.sort(function(a, b) {
|
|
396
|
-
return new Date(a.valid_from).getTime() - new Date(b.valid_from).getTime();
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
// ── wakeUp (L0 + L1 injection) ───────────────────────────────────────────────
|
|
401
|
-
/**
|
|
402
|
-
* wakeUp(cwd) → string
|
|
403
|
-
* Loads L0 identity context + generates L1 essential story from top-scored
|
|
404
|
-
* recent drawers. Returns a string for console.log injection into session.
|
|
405
|
-
*/
|
|
406
|
-
function wakeUp(cwd) {
|
|
407
|
-
var pDir = palaceDir(cwd);
|
|
408
|
-
var lines = [];
|
|
409
|
-
|
|
410
|
-
// L0 — identity.md (user-maintained, static)
|
|
411
|
-
var identityFile = path.join(pDir, 'identity.md');
|
|
412
|
-
if (fs.existsSync(identityFile)) {
|
|
413
|
-
try {
|
|
414
|
-
var identity = fs.readFileSync(identityFile, 'utf-8').trim();
|
|
415
|
-
if (identity) {
|
|
416
|
-
lines.push('[MEMORY_PALACE_L0] Identity:');
|
|
417
|
-
lines.push(identity);
|
|
418
|
-
}
|
|
419
|
-
} catch (e) { /* non-fatal */ }
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// L1 — essential story: top-scored drawers from last L1_DAYS days
|
|
423
|
-
var drawersFile = path.join(pDir, 'drawers.jsonl');
|
|
424
|
-
if (fs.existsSync(drawersFile)) {
|
|
425
|
-
try {
|
|
426
|
-
var drawers = _getEffectiveDrawers(drawersFile);
|
|
427
|
-
var cutoff = Date.now() - L1_DAYS * 24 * 60 * 60 * 1000;
|
|
428
|
-
var recent = drawers.filter(function(d) {
|
|
429
|
-
return d.ts && new Date(d.ts).getTime() > cutoff;
|
|
430
|
-
});
|
|
431
|
-
var top = recent
|
|
432
|
-
.sort(function(a, b) { return (b.score || 0) - (a.score || 0); })
|
|
433
|
-
.slice(0, L1_LIMIT);
|
|
434
|
-
|
|
435
|
-
if (top.length > 0) {
|
|
436
|
-
lines.push('[MEMORY_PALACE_L1] Essential story (' + top.length + ' drawer' + (top.length !== 1 ? 's' : '') + '):');
|
|
437
|
-
top.forEach(function(d) {
|
|
438
|
-
var ns = (d.wing || '?') + '/' + (d.room || '?') + (d.hall ? '/' + d.hall : '');
|
|
439
|
-
var dateStr = d.ts ? d.ts.slice(0, 10) : '?';
|
|
440
|
-
var snippet = (d.content || '').slice(0, 300).replace(/\n/g, ' ');
|
|
441
|
-
lines.push('[' + ns + ' ' + dateStr + '] ' + snippet);
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
} catch (e) { /* non-fatal */ }
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
return lines.join('\n');
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
// ── exports ───────────────────────────────────────────────────────────────────
|
|
451
|
-
module.exports = {
|
|
452
|
-
wakeUp,
|
|
453
|
-
storeVerbatim,
|
|
454
|
-
buildClosets,
|
|
455
|
-
search,
|
|
456
|
-
recall,
|
|
457
|
-
bm25,
|
|
458
|
-
kgAdd,
|
|
459
|
-
kgQuery,
|
|
460
|
-
kgTimeline,
|
|
461
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Monomind Memory Helper
|
|
4
|
-
* Simple key-value memory for cross-session context
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
|
|
10
|
-
const MEMORY_DIR = path.join(process.cwd(), '.monomind', 'data');
|
|
11
|
-
const MEMORY_FILE = path.join(MEMORY_DIR, 'memory.json');
|
|
12
|
-
|
|
13
|
-
function loadMemory() {
|
|
14
|
-
try {
|
|
15
|
-
if (fs.existsSync(MEMORY_FILE)) {
|
|
16
|
-
return JSON.parse(fs.readFileSync(MEMORY_FILE, 'utf-8'));
|
|
17
|
-
}
|
|
18
|
-
} catch (e) {
|
|
19
|
-
// Ignore
|
|
20
|
-
}
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function saveMemory(memory) {
|
|
25
|
-
fs.mkdirSync(MEMORY_DIR, { recursive: true });
|
|
26
|
-
fs.writeFileSync(MEMORY_FILE, JSON.stringify(memory, null, 2));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const commands = {
|
|
30
|
-
get: (key) => {
|
|
31
|
-
const memory = loadMemory();
|
|
32
|
-
const value = key ? memory[key] : memory;
|
|
33
|
-
console.log(JSON.stringify(value, null, 2));
|
|
34
|
-
return value;
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
set: (key, value) => {
|
|
38
|
-
if (!key) {
|
|
39
|
-
console.error('Key required');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const memory = loadMemory();
|
|
43
|
-
memory[key] = value;
|
|
44
|
-
memory._updated = new Date().toISOString();
|
|
45
|
-
saveMemory(memory);
|
|
46
|
-
console.log(`Set: ${key}`);
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
delete: (key) => {
|
|
50
|
-
if (!key) {
|
|
51
|
-
console.error('Key required');
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const memory = loadMemory();
|
|
55
|
-
delete memory[key];
|
|
56
|
-
saveMemory(memory);
|
|
57
|
-
console.log(`Deleted: ${key}`);
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
clear: () => {
|
|
61
|
-
saveMemory({});
|
|
62
|
-
console.log('Memory cleared');
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
keys: () => {
|
|
66
|
-
const memory = loadMemory();
|
|
67
|
-
const keys = Object.keys(memory).filter(k => !k.startsWith('_'));
|
|
68
|
-
console.log(keys.join('\n'));
|
|
69
|
-
return keys;
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
module.exports = commands;
|
|
74
|
-
|
|
75
|
-
// CLI - only run when executed directly
|
|
76
|
-
if (require.main === module) {
|
|
77
|
-
const [,, command, key, ...valueParts] = process.argv;
|
|
78
|
-
const value = valueParts.join(' ');
|
|
79
|
-
if (command && commands[command]) {
|
|
80
|
-
commands[command](key, value);
|
|
81
|
-
} else {
|
|
82
|
-
console.log('Usage: memory.js <get|set|delete|clear|keys> [key] [value]');
|
|
83
|
-
}
|
|
84
|
-
}
|