@monoes/monomindcli 2.8.3 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/helpers/auto-memory-hook.mjs +0 -0
- package/.claude/helpers/handlers/route-handler.cjs +12 -0
- package/.claude/helpers/handlers/session-restore-handler.cjs +28 -7
- package/.claude/helpers/hook-handler.cjs +0 -0
- package/.claude/helpers/utils/micro-agents.cjs +22 -0
- package/.claude/skills/monodesign/scripts/live/sveltekit-adapter.mjs +11 -6
- package/.claude/skills/monodesign/scripts/live-inject.mjs +20 -7
- package/.claude/skills/monodesign/scripts/live-server.mjs +38 -2
- package/LICENSE +191 -0
- package/README.md +8 -6
- package/dist/src/browser/dashboard/server.d.ts +5 -0
- package/dist/src/browser/dashboard/server.d.ts.map +1 -1
- package/dist/src/browser/dashboard/server.js +59 -4
- package/dist/src/browser/dashboard/server.js.map +1 -1
- package/dist/src/browser/dashboard/ui.html +18 -8
- package/dist/src/browser/workflow/store.d.ts.map +1 -1
- package/dist/src/browser/workflow/store.js +3 -2
- package/dist/src/browser/workflow/store.js.map +1 -1
- package/dist/src/capabilities/cap-documents.d.ts.map +1 -1
- package/dist/src/capabilities/cap-documents.js +14 -9
- package/dist/src/capabilities/cap-documents.js.map +1 -1
- package/dist/src/commands/design-palette.d.ts +5 -0
- package/dist/src/commands/design-palette.d.ts.map +1 -1
- package/dist/src/commands/design-palette.js +8 -5
- package/dist/src/commands/design-palette.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +22 -18
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/download-embeddings.d.ts +8 -0
- package/dist/src/commands/download-embeddings.d.ts.map +1 -0
- package/dist/src/commands/download-embeddings.js +34 -0
- package/dist/src/commands/download-embeddings.js.map +1 -0
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +14 -0
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +4 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init-wizard.js +1 -1
- package/dist/src/commands/init-wizard.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +48 -1
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/monograph.d.ts.map +1 -1
- package/dist/src/commands/monograph.js +35 -1
- package/dist/src/commands/monograph.js.map +1 -1
- package/dist/src/commands/org-observe.d.ts +10 -0
- package/dist/src/commands/org-observe.d.ts.map +1 -1
- package/dist/src/commands/org-observe.js +195 -31
- package/dist/src/commands/org-observe.js.map +1 -1
- package/dist/src/commands/org.d.ts +1 -0
- package/dist/src/commands/org.d.ts.map +1 -1
- package/dist/src/commands/org.js +139 -3
- package/dist/src/commands/org.js.map +1 -1
- package/dist/src/commands/route.d.ts +1 -9
- package/dist/src/commands/route.d.ts.map +1 -1
- package/dist/src/commands/route.js +42 -65
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/security-cve.d.ts.map +1 -1
- package/dist/src/commands/security-cve.js +2 -1
- package/dist/src/commands/security-cve.js.map +1 -1
- package/dist/src/index.d.ts +0 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -15
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/copy-assets.d.ts +17 -0
- package/dist/src/init/copy-assets.d.ts.map +1 -0
- package/dist/src/init/copy-assets.js +271 -0
- package/dist/src/init/copy-assets.js.map +1 -0
- package/dist/src/init/executor.d.ts +2 -30
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +56 -2493
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/geminimd-generator.js +2 -2
- package/dist/src/init/helpers-generator.d.ts.map +1 -1
- package/dist/src/init/helpers-generator.js +9 -0
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/kimi-generator.js +3 -3
- package/dist/src/init/kimi-generator.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +0 -4
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/shared.d.ts +112 -0
- package/dist/src/init/shared.d.ts.map +1 -0
- package/dist/src/init/shared.js +475 -0
- package/dist/src/init/shared.js.map +1 -0
- package/dist/src/init/statusline-generator.d.ts.map +1 -1
- package/dist/src/init/statusline-generator.js +37 -0
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +1 -1
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/upgrade.d.ts +34 -0
- package/dist/src/init/upgrade.d.ts.map +1 -0
- package/dist/src/init/upgrade.js +477 -0
- package/dist/src/init/upgrade.js.map +1 -0
- package/dist/src/init/write-antigravity.d.ts +13 -0
- package/dist/src/init/write-antigravity.d.ts.map +1 -0
- package/dist/src/init/write-antigravity.js +117 -0
- package/dist/src/init/write-antigravity.js.map +1 -0
- package/dist/src/init/write-capabilities.d.ts +9 -0
- package/dist/src/init/write-capabilities.d.ts.map +1 -0
- package/dist/src/init/write-capabilities.js +392 -0
- package/dist/src/init/write-capabilities.js.map +1 -0
- package/dist/src/init/write-claude.d.ts +25 -0
- package/dist/src/init/write-claude.d.ts.map +1 -0
- package/dist/src/init/write-claude.js +279 -0
- package/dist/src/init/write-claude.js.map +1 -0
- package/dist/src/init/write-kimicode.d.ts +19 -0
- package/dist/src/init/write-kimicode.d.ts.map +1 -0
- package/dist/src/init/write-kimicode.js +223 -0
- package/dist/src/init/write-kimicode.js.map +1 -0
- package/dist/src/init/write-opencode.d.ts +14 -0
- package/dist/src/init/write-opencode.d.ts.map +1 -0
- package/dist/src/init/write-opencode.js +130 -0
- package/dist/src/init/write-opencode.js.map +1 -0
- package/dist/src/init/write-runtime-config.d.ts +14 -0
- package/dist/src/init/write-runtime-config.d.ts.map +1 -0
- package/dist/src/init/write-runtime-config.js +214 -0
- package/dist/src/init/write-runtime-config.js.map +1 -0
- package/dist/src/init/write-sample-org.d.ts +9 -0
- package/dist/src/init/write-sample-org.d.ts.map +1 -0
- package/dist/src/init/write-sample-org.js +39 -0
- package/dist/src/init/write-sample-org.js.map +1 -0
- package/dist/src/knowledge/eval/golden-set.js +1 -1
- package/dist/src/knowledge/eval/golden-set.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +7 -3
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.js +2 -25
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.d.ts.map +1 -1
- package/dist/src/mcp-tools/auto-install.js +2 -1
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.js +26 -0
- package/dist/src/mcp-tools/hooks-routing.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +2 -37
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/monodesign-tools.d.ts +19 -0
- package/dist/src/mcp-tools/monodesign-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monodesign-tools.js +233 -0
- package/dist/src/mcp-tools/monodesign-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/agent-history-tools.d.ts +5 -0
- package/dist/src/mcp-tools/monograph/agent-history-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/agent-history-tools.js +177 -0
- package/dist/src/mcp-tools/monograph/agent-history-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/build-tools.d.ts +9 -0
- package/dist/src/mcp-tools/monograph/build-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/build-tools.js +299 -0
- package/dist/src/mcp-tools/monograph/build-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/group-tools.d.ts +10 -0
- package/dist/src/mcp-tools/monograph/group-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/group-tools.js +225 -0
- package/dist/src/mcp-tools/monograph/group-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/health-tools.d.ts +6 -0
- package/dist/src/mcp-tools/monograph/health-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/health-tools.js +113 -0
- package/dist/src/mcp-tools/monograph/health-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/impact-tools.d.ts +9 -0
- package/dist/src/mcp-tools/monograph/impact-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/impact-tools.js +532 -0
- package/dist/src/mcp-tools/monograph/impact-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/index.d.ts +10 -0
- package/dist/src/mcp-tools/monograph/index.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/index.js +73 -0
- package/dist/src/mcp-tools/monograph/index.js.map +1 -0
- package/dist/src/mcp-tools/monograph/query-tools.d.ts +11 -0
- package/dist/src/mcp-tools/monograph/query-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/query-tools.js +500 -0
- package/dist/src/mcp-tools/monograph/query-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/shared.d.ts +64 -0
- package/dist/src/mcp-tools/monograph/shared.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/shared.js +215 -0
- package/dist/src/mcp-tools/monograph/shared.js.map +1 -0
- package/dist/src/mcp-tools/monograph/visualize-tools.d.ts +10 -0
- package/dist/src/mcp-tools/monograph/visualize-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/visualize-tools.js +382 -0
- package/dist/src/mcp-tools/monograph/visualize-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph-tools.d.ts +4 -23
- package/dist/src/mcp-tools/monograph-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph-tools.js +4 -2439
- package/dist/src/mcp-tools/monograph-tools.js.map +1 -1
- package/dist/src/mcp-tools/monomind-tools.d.ts +8 -0
- package/dist/src/mcp-tools/monomind-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monomind-tools.js +13 -1
- package/dist/src/mcp-tools/monomind-tools.js.map +1 -1
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts.map +1 -1
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.js +31 -2
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +31 -1
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/types.d.ts +8 -27
- package/dist/src/mcp-tools/types.d.ts.map +1 -1
- package/dist/src/mcp-tools/types.js +9 -91
- package/dist/src/mcp-tools/types.js.map +1 -1
- package/dist/src/memory/file-permissions.d.ts +15 -0
- package/dist/src/memory/file-permissions.d.ts.map +1 -0
- package/dist/src/memory/file-permissions.js +25 -0
- package/dist/src/memory/file-permissions.js.map +1 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -1
- package/dist/src/memory/memory-bridge.js +94 -34
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-crud.d.ts.map +1 -1
- package/dist/src/memory/memory-crud.js +298 -275
- package/dist/src/memory/memory-crud.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +2 -4
- package/dist/src/memory/memory-initializer.d.ts.map +1 -1
- package/dist/src/memory/memory-initializer.js +53 -76
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/memory-migrations.d.ts +1 -14
- package/dist/src/memory/memory-migrations.d.ts.map +1 -1
- package/dist/src/memory/memory-migrations.js +52 -105
- package/dist/src/memory/memory-migrations.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +1 -1
- package/dist/src/memory/sona-optimizer.js +1 -1
- package/dist/src/monovector/index.d.ts +16 -19
- package/dist/src/monovector/index.d.ts.map +1 -1
- package/dist/src/monovector/index.js +50 -8
- package/dist/src/monovector/index.js.map +1 -1
- package/dist/src/orgrt/approvals.d.ts +16 -0
- package/dist/src/orgrt/approvals.d.ts.map +1 -0
- package/dist/src/orgrt/approvals.js +72 -0
- package/dist/src/orgrt/approvals.js.map +1 -0
- package/dist/src/orgrt/bus.d.ts.map +1 -1
- package/dist/src/orgrt/bus.js +21 -0
- package/dist/src/orgrt/bus.js.map +1 -1
- package/dist/src/orgrt/checkpoint-ops.d.ts +19 -0
- package/dist/src/orgrt/checkpoint-ops.d.ts.map +1 -0
- package/dist/src/orgrt/checkpoint-ops.js +219 -0
- package/dist/src/orgrt/checkpoint-ops.js.map +1 -0
- package/dist/src/orgrt/checkpoint.d.ts +33 -1
- package/dist/src/orgrt/checkpoint.d.ts.map +1 -1
- package/dist/src/orgrt/checkpoint.js +50 -6
- package/dist/src/orgrt/checkpoint.js.map +1 -1
- package/dist/src/orgrt/cross-org.d.ts +32 -0
- package/dist/src/orgrt/cross-org.d.ts.map +1 -0
- package/dist/src/orgrt/cross-org.js +256 -0
- package/dist/src/orgrt/cross-org.js.map +1 -0
- package/dist/src/orgrt/daemon.d.ts +131 -157
- package/dist/src/orgrt/daemon.d.ts.map +1 -1
- package/dist/src/orgrt/daemon.js +356 -966
- package/dist/src/orgrt/daemon.js.map +1 -1
- package/dist/src/orgrt/decisions.d.ts +33 -0
- package/dist/src/orgrt/decisions.d.ts.map +1 -0
- package/dist/src/orgrt/decisions.js +169 -0
- package/dist/src/orgrt/decisions.js.map +1 -0
- package/dist/src/orgrt/kimicode-runner.d.ts.map +1 -1
- package/dist/src/orgrt/kimicode-runner.js +5 -1
- package/dist/src/orgrt/kimicode-runner.js.map +1 -1
- package/dist/src/orgrt/opencode-runner.d.ts.map +1 -1
- package/dist/src/orgrt/opencode-runner.js +10 -2
- package/dist/src/orgrt/opencode-runner.js.map +1 -1
- package/dist/src/orgrt/org-memory.d.ts +45 -0
- package/dist/src/orgrt/org-memory.d.ts.map +1 -0
- package/dist/src/orgrt/org-memory.js +220 -0
- package/dist/src/orgrt/org-memory.js.map +1 -0
- package/dist/src/orgrt/policy.d.ts +4 -0
- package/dist/src/orgrt/policy.d.ts.map +1 -1
- package/dist/src/orgrt/policy.js +13 -1
- package/dist/src/orgrt/policy.js.map +1 -1
- package/dist/src/orgrt/prechecks.d.ts +15 -0
- package/dist/src/orgrt/prechecks.d.ts.map +1 -0
- package/dist/src/orgrt/prechecks.js +21 -0
- package/dist/src/orgrt/prechecks.js.map +1 -0
- package/dist/src/orgrt/questions.d.ts +39 -0
- package/dist/src/orgrt/questions.d.ts.map +1 -0
- package/dist/src/orgrt/questions.js +135 -0
- package/dist/src/orgrt/questions.js.map +1 -0
- package/dist/src/orgrt/remote.d.ts +25 -0
- package/dist/src/orgrt/remote.d.ts.map +1 -0
- package/dist/src/orgrt/remote.js +73 -0
- package/dist/src/orgrt/remote.js.map +1 -0
- package/dist/src/orgrt/scheduler-integration.d.ts +19 -0
- package/dist/src/orgrt/scheduler-integration.d.ts.map +1 -0
- package/dist/src/orgrt/scheduler-integration.js +90 -0
- package/dist/src/orgrt/scheduler-integration.js.map +1 -0
- package/dist/src/orgrt/server.d.ts.map +1 -1
- package/dist/src/orgrt/server.js +70 -2
- package/dist/src/orgrt/server.js.map +1 -1
- package/dist/src/orgrt/session.d.ts +30 -1
- package/dist/src/orgrt/session.d.ts.map +1 -1
- package/dist/src/orgrt/session.js +184 -53
- package/dist/src/orgrt/session.js.map +1 -1
- package/dist/src/orgrt/state-detector.d.ts +19 -0
- package/dist/src/orgrt/state-detector.d.ts.map +1 -0
- package/dist/src/orgrt/state-detector.js +59 -0
- package/dist/src/orgrt/state-detector.js.map +1 -0
- package/dist/src/orgrt/task-dag.d.ts +27 -0
- package/dist/src/orgrt/task-dag.d.ts.map +1 -0
- package/dist/src/orgrt/task-dag.js +100 -0
- package/dist/src/orgrt/task-dag.js.map +1 -0
- package/dist/src/orgrt/tool-fence.d.ts +7 -4
- package/dist/src/orgrt/tool-fence.d.ts.map +1 -1
- package/dist/src/orgrt/tool-fence.js +47 -6
- package/dist/src/orgrt/tool-fence.js.map +1 -1
- package/dist/src/orgrt/types.d.ts +57 -2
- package/dist/src/orgrt/types.d.ts.map +1 -1
- package/dist/src/orgrt/types.js +34 -3
- package/dist/src/orgrt/types.js.map +1 -1
- package/dist/src/routing/model-download.d.ts +49 -0
- package/dist/src/routing/model-download.d.ts.map +1 -0
- package/dist/src/routing/model-download.js +106 -0
- package/dist/src/routing/model-download.js.map +1 -0
- package/dist/src/services/crash-reporter.d.ts +5 -0
- package/dist/src/services/crash-reporter.d.ts.map +1 -1
- package/dist/src/services/crash-reporter.js +49 -0
- package/dist/src/services/crash-reporter.js.map +1 -1
- package/dist/src/transfer/anonymization/index.d.ts +18 -15
- package/dist/src/transfer/anonymization/index.d.ts.map +1 -1
- package/dist/src/transfer/anonymization/index.js +7 -119
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/ui/dashboard.html +606 -7
- package/dist/src/ui/orgs.html +7 -1
- package/dist/src/ui/routes-monograph.mjs +6 -0
- package/dist/src/ui/server.mjs +327 -7
- package/dist/src/update/checker.d.ts.map +1 -1
- package/dist/src/update/checker.js +2 -1
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.d.ts.map +1 -1
- package/dist/src/update/executor.js +7 -3
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.d.ts +0 -1
- package/dist/src/update/index.d.ts.map +1 -1
- package/dist/src/update/index.js +5 -24
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/utils/db-mutex.d.ts +11 -0
- package/dist/src/utils/db-mutex.d.ts.map +1 -0
- package/dist/src/utils/db-mutex.js +23 -0
- package/dist/src/utils/db-mutex.js.map +1 -0
- package/dist/src/utils/input-guards.d.ts +23 -0
- package/dist/src/utils/input-guards.d.ts.map +1 -1
- package/dist/src/utils/input-guards.js +72 -0
- package/dist/src/utils/input-guards.js.map +1 -1
- package/dist/src/utils/npm-command.d.ts +10 -0
- package/dist/src/utils/npm-command.d.ts.map +1 -0
- package/dist/src/utils/npm-command.js +12 -0
- package/dist/src/utils/npm-command.js.map +1 -0
- package/dist/src/utils/paths.d.ts +28 -0
- package/dist/src/utils/paths.d.ts.map +1 -0
- package/dist/src/utils/paths.js +108 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/scripts/download-embedding-model.mjs +97 -0
- package/scripts/publish.sh +0 -0
- package/scripts/sync-claude-assets.sh +0 -0
- package/dist/src/production/circuit-breaker.d.ts +0 -121
- package/dist/src/production/circuit-breaker.d.ts.map +0 -1
- package/dist/src/production/circuit-breaker.js +0 -262
- package/dist/src/production/circuit-breaker.js.map +0 -1
- package/dist/src/production/error-handler.d.ts +0 -119
- package/dist/src/production/error-handler.d.ts.map +0 -1
- package/dist/src/production/error-handler.js +0 -324
- package/dist/src/production/error-handler.js.map +0 -1
- package/dist/src/production/index.d.ts +0 -6
- package/dist/src/production/index.d.ts.map +0 -1
- package/dist/src/production/index.js +0 -6
- package/dist/src/production/index.js.map +0 -1
- package/dist/src/production/monitoring.d.ts +0 -181
- package/dist/src/production/monitoring.d.ts.map +0 -1
- package/dist/src/production/monitoring.js +0 -375
- package/dist/src/production/monitoring.js.map +0 -1
- package/dist/src/production/rate-limiter.d.ts +0 -125
- package/dist/src/production/rate-limiter.d.ts.map +0 -1
- package/dist/src/production/rate-limiter.js +0 -218
- package/dist/src/production/rate-limiter.js.map +0 -1
- package/dist/src/production/retry.d.ts +0 -48
- package/dist/src/production/retry.d.ts.map +0 -1
- package/dist/src/production/retry.js +0 -189
- package/dist/src/production/retry.js.map +0 -1
- package/dist/src/transfer/types.d.ts +0 -245
- package/dist/src/transfer/types.d.ts.map +0 -1
- package/dist/src/transfer/types.js +0 -6
- package/dist/src/transfer/types.js.map +0 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { getProjectCwd } from '../types.js';
|
|
2
|
+
import { getDbPath, _isValidDb, text, computeCommitsBehind, triggerBackgroundBuildIfNeeded, STALENESS_THRESHOLD } from './shared.js';
|
|
3
|
+
// ── monograph_stats ─────────────────────────────────────────────────────────
|
|
4
|
+
export const monographStatsTool = {
|
|
5
|
+
name: 'monograph_stats',
|
|
6
|
+
description: 'Show node/edge/community counts and index freshness.',
|
|
7
|
+
inputSchema: { type: 'object', properties: {} },
|
|
8
|
+
handler: async () => {
|
|
9
|
+
const dbPath = getDbPath();
|
|
10
|
+
if (!_isValidDb(dbPath))
|
|
11
|
+
return text('Monograph index not built yet. Run monograph_build first.');
|
|
12
|
+
const { openDb, closeDb, countNodes, countEdges } = await import('@monoes/monograph');
|
|
13
|
+
const db = openDb(dbPath);
|
|
14
|
+
try {
|
|
15
|
+
const nodes = countNodes(db);
|
|
16
|
+
const edges = countEdges(db);
|
|
17
|
+
const meta = db.prepare('SELECT key, value FROM index_meta').all();
|
|
18
|
+
const metaStr = meta.map(m => ` ${m.key}: ${m.value}`).join('\n');
|
|
19
|
+
return text(`Monograph index stats:\n nodes: ${nodes}\n edges: ${edges}\n${metaStr}`);
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
closeDb(db);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
// ── monograph_health ────────────────────────────────────────────────────────
|
|
27
|
+
export const monographHealthTool = {
|
|
28
|
+
name: 'monograph_health',
|
|
29
|
+
description: 'Check index staleness: compares last indexed git commit vs current HEAD.',
|
|
30
|
+
inputSchema: { type: 'object', properties: {} },
|
|
31
|
+
handler: async () => {
|
|
32
|
+
const { openDb, closeDb } = await import('@monoes/monograph');
|
|
33
|
+
const { execSync } = await import('child_process');
|
|
34
|
+
const db = openDb(getDbPath());
|
|
35
|
+
try {
|
|
36
|
+
// The orchestrator writes the key as 'last_commit_hash' (orchestrator.ts:68).
|
|
37
|
+
// Fall back to legacy 'lastCommit' for indexes built with older versions.
|
|
38
|
+
const meta = db.prepare("SELECT value FROM index_meta WHERE key = 'last_commit_hash'").get() ?? db.prepare("SELECT value FROM index_meta WHERE key = 'lastCommit'").get();
|
|
39
|
+
const lastCommit = meta?.value ?? null;
|
|
40
|
+
if (!lastCommit) {
|
|
41
|
+
// last_commit_hash can be missing even when the index is populated
|
|
42
|
+
// (e.g. git rev-parse failed during build). Check actual data before
|
|
43
|
+
// claiming "never built".
|
|
44
|
+
const nodeCount = db.prepare('SELECT COUNT(*) AS c FROM nodes').get().c;
|
|
45
|
+
if (nodeCount > 0) {
|
|
46
|
+
const indexedAt = db.prepare("SELECT value FROM index_meta WHERE key = 'indexed_at'").get()?.value;
|
|
47
|
+
return text(`Index is built (${nodeCount} nodes${indexedAt ? `, indexed at ${indexedAt}` : ''}) but no commit hash was recorded — staleness tracking unavailable.\n` +
|
|
48
|
+
'Run monograph_build to fix commit tracking.');
|
|
49
|
+
}
|
|
50
|
+
return text('Index has never been built. Run monograph_build first.');
|
|
51
|
+
}
|
|
52
|
+
if (!/^[0-9a-f]{7,40}$/i.test(lastCommit)) {
|
|
53
|
+
return text('Index metadata is corrupt: invalid commit SHA. Run monograph_build to re-index.');
|
|
54
|
+
}
|
|
55
|
+
let commitsBehind = 0;
|
|
56
|
+
try {
|
|
57
|
+
const out = execSync(`git rev-list --count ${lastCommit}..HEAD`, {
|
|
58
|
+
cwd: getProjectCwd(), encoding: 'utf-8'
|
|
59
|
+
}).trim();
|
|
60
|
+
commitsBehind = parseInt(out, 10);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return text('Cannot check staleness: git error');
|
|
64
|
+
}
|
|
65
|
+
const status = commitsBehind === 0 ? 'FRESH' : `STALE (${commitsBehind} commits behind)`;
|
|
66
|
+
return text(`Index status: ${status}\nLast indexed commit: ${lastCommit}`);
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
closeDb(db);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
// ── monograph_staleness ─────────────────────────────────────────────────────
|
|
74
|
+
export const monographStalenessTool = {
|
|
75
|
+
name: 'monograph_staleness',
|
|
76
|
+
description: 'Git staleness detection: compares the commit hash at last index build against current HEAD. When the index is more than 3 commits behind HEAD it automatically triggers a background rebuild. Returns { commitsBehind, status, triggered }.',
|
|
77
|
+
inputSchema: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: {
|
|
80
|
+
path: { type: 'string', description: 'Absolute path to the repo (defaults to project cwd)' },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
handler: async (input) => {
|
|
84
|
+
const repoPath = input.path ?? getProjectCwd();
|
|
85
|
+
const result = await computeCommitsBehind(repoPath);
|
|
86
|
+
if (!result) {
|
|
87
|
+
return text(JSON.stringify({ commitsBehind: 0, status: 'unknown', triggered: false }));
|
|
88
|
+
}
|
|
89
|
+
const { commitsBehind } = result;
|
|
90
|
+
const triggered = triggerBackgroundBuildIfNeeded(repoPath, commitsBehind, STALENESS_THRESHOLD + 1);
|
|
91
|
+
const status = triggered ? 'building' : commitsBehind === 0 ? 'fresh' : 'stale';
|
|
92
|
+
return text(JSON.stringify({ commitsBehind, status, triggered }));
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
// ── monograph_doctor ────────────────────────────────────────────────────────
|
|
96
|
+
export const monographDoctorTool = {
|
|
97
|
+
name: 'monograph_doctor',
|
|
98
|
+
description: 'Run platform diagnostics — checks Node version, SQLite DB health, node count, disk space.',
|
|
99
|
+
inputSchema: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {},
|
|
102
|
+
},
|
|
103
|
+
handler: async (_input) => {
|
|
104
|
+
const { runDoctor } = await import('@monoes/monograph');
|
|
105
|
+
const repoPath = getProjectCwd();
|
|
106
|
+
const result = await runDoctor(repoPath);
|
|
107
|
+
const lines = result.checks.map(c => `${c.status === 'ok' ? '✅' : c.status === 'warn' ? '⚠️' : '❌'} ${c.name}: ${c.message}`);
|
|
108
|
+
if (!result.healthy)
|
|
109
|
+
lines.push('\nSome checks failed. Run monograph build to fix.');
|
|
110
|
+
return text(lines.join('\n'));
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=health-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-tools.js","sourceRoot":"","sources":["../../../../src/mcp-tools/monograph/health-tools.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MCPTool } from '../types.js';
|
|
2
|
+
export declare const monographImpactTool: MCPTool;
|
|
3
|
+
export declare const monographApiImpactTool: MCPTool;
|
|
4
|
+
export declare const monographDeadCodeTool: MCPTool;
|
|
5
|
+
export declare const monographRouteMapTool: MCPTool;
|
|
6
|
+
export declare const monographShapeCheckTool: MCPTool;
|
|
7
|
+
export declare const monographRenameTool: MCPTool;
|
|
8
|
+
export declare const monographToolMapTool: MCPTool;
|
|
9
|
+
//# sourceMappingURL=impact-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"impact-tools.d.ts","sourceRoot":"","sources":["../../../../src/mcp-tools/monograph/impact-tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAM3C,eAAO,MAAM,mBAAmB,EAAE,OAwEjC,CAAC;AAIF,eAAO,MAAM,sBAAsB,EAAE,OA+CpC,CAAC;AAIF,eAAO,MAAM,qBAAqB,EAAE,OAwHnC,CAAC;AAmGF,eAAO,MAAM,qBAAqB,EAAE,OAiCnC,CAAC;AAIF,eAAO,MAAM,uBAAuB,EAAE,OAsDrC,CAAC;AAIF,eAAO,MAAM,mBAAmB,EAAE,OA4CjC,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,OAyBlC,CAAC"}
|
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { existsSync, readdirSync } from 'fs';
|
|
3
|
+
import { getProjectCwd } from '../types.js';
|
|
4
|
+
import { getDbPath, _isValidDb, text } from './shared.js';
|
|
5
|
+
// ── monograph_impact ──────────────────────────────────────────────────────────
|
|
6
|
+
export const monographImpactTool = {
|
|
7
|
+
name: 'monograph_impact',
|
|
8
|
+
description: 'Blast radius analysis: finds all direct and transitive callers of a symbol and computes a risk score.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
name: { type: 'string', description: 'Symbol name to analyze' },
|
|
13
|
+
filePath: { type: 'string', description: 'Optional file path to disambiguate' },
|
|
14
|
+
depth: { type: 'number', description: 'Max BFS depth (default 3, max 6)' },
|
|
15
|
+
},
|
|
16
|
+
required: ['name'],
|
|
17
|
+
},
|
|
18
|
+
handler: async (input) => {
|
|
19
|
+
const { openDb, closeDb } = await import('@monoes/monograph');
|
|
20
|
+
const { getMonographImpact } = await import('@monoes/monograph');
|
|
21
|
+
const db = openDb(getDbPath());
|
|
22
|
+
try {
|
|
23
|
+
// Cap name/filePath; enforce depth ≤ 6 as documented in the schema description.
|
|
24
|
+
const MAX_IMPACT_NAME_LEN = 512;
|
|
25
|
+
const MAX_IMPACT_PATH_LEN = 4 * 1024;
|
|
26
|
+
const rawImpactName = input.name;
|
|
27
|
+
const impactName = typeof rawImpactName === 'string' && rawImpactName.length > MAX_IMPACT_NAME_LEN
|
|
28
|
+
? rawImpactName.slice(0, MAX_IMPACT_NAME_LEN) : rawImpactName;
|
|
29
|
+
const rawImpactPath = input.filePath;
|
|
30
|
+
const impactPath = typeof rawImpactPath === 'string' && rawImpactPath.length > MAX_IMPACT_PATH_LEN
|
|
31
|
+
? rawImpactPath.slice(0, MAX_IMPACT_PATH_LEN) : rawImpactPath;
|
|
32
|
+
const rawDepth = input.depth;
|
|
33
|
+
const depth = rawDepth === undefined
|
|
34
|
+
? undefined
|
|
35
|
+
: (typeof rawDepth === 'number' && Number.isFinite(rawDepth) && rawDepth > 0
|
|
36
|
+
? Math.min(Math.floor(rawDepth), 6) : 3);
|
|
37
|
+
const result = getMonographImpact(db, {
|
|
38
|
+
name: impactName,
|
|
39
|
+
filePath: impactPath,
|
|
40
|
+
depth,
|
|
41
|
+
});
|
|
42
|
+
if (!result || !result.node)
|
|
43
|
+
return text(`No symbol found: ${impactName}`);
|
|
44
|
+
// Format impact as structured text for direct LLM consumption
|
|
45
|
+
const root = result.node;
|
|
46
|
+
const rootLoc = root.filePath ? (root.startLine != null ? `${root.filePath}:${root.startLine}` : root.filePath) : '';
|
|
47
|
+
const lines = [
|
|
48
|
+
`[${root.label ?? '?'}] ${root.name} ${rootLoc}`,
|
|
49
|
+
'',
|
|
50
|
+
`Blast radius: ${result.affectedFiles?.length ?? 0} symbols affected`,
|
|
51
|
+
];
|
|
52
|
+
if (result.riskScore != null) {
|
|
53
|
+
const riskLabel = result.riskScore >= 0.8 ? 'HIGH' : result.riskScore >= 0.5 ? 'MEDIUM' : 'LOW';
|
|
54
|
+
lines.push(`Risk score: ${result.riskScore.toFixed(2)} (${riskLabel})`);
|
|
55
|
+
}
|
|
56
|
+
lines.push('');
|
|
57
|
+
const affected = [
|
|
58
|
+
...(result.directCallers ?? []),
|
|
59
|
+
...(result.transitiveCallers ?? []).flatMap(t => t.nodes ?? []),
|
|
60
|
+
];
|
|
61
|
+
if (affected.length > 0) {
|
|
62
|
+
lines.push(`Affected callers (${affected.length}):`);
|
|
63
|
+
for (const sym of affected.slice(0, 20)) {
|
|
64
|
+
const fp = sym.filePath ?? sym.file_path ?? '';
|
|
65
|
+
const ln = sym.startLine ?? sym.start_line;
|
|
66
|
+
const symLoc = fp ? (ln != null ? `${fp}:${ln}` : fp) : '';
|
|
67
|
+
const depth_marker = sym.depth != null ? ` [depth ${sym.depth}]` : '';
|
|
68
|
+
lines.push(` [${sym.label ?? '?'}] ${sym.name ?? sym.id} ${symLoc}${depth_marker}`);
|
|
69
|
+
}
|
|
70
|
+
if (affected.length > 20)
|
|
71
|
+
lines.push(` … ${affected.length - 20} more`);
|
|
72
|
+
}
|
|
73
|
+
return text(lines.join('\n').trim());
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
closeDb(db);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
// ── monograph_api_impact ──────────────────────────────────────────────────────
|
|
81
|
+
export const monographApiImpactTool = {
|
|
82
|
+
name: 'monograph_api_impact',
|
|
83
|
+
description: 'Analyze the blast radius of an API route: finds the handler, performs forward BFS through CALLS edges, and computes a risk score.',
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: 'object',
|
|
86
|
+
properties: {
|
|
87
|
+
routePath: { type: 'string', description: 'Route path to analyze (e.g. /api/users)' },
|
|
88
|
+
method: { type: 'string', description: 'Optional HTTP method filter: GET, POST, etc.' },
|
|
89
|
+
},
|
|
90
|
+
required: ['routePath'],
|
|
91
|
+
},
|
|
92
|
+
handler: async (input) => {
|
|
93
|
+
const { openDb, closeDb } = await import('@monoes/monograph');
|
|
94
|
+
const { getMonographApiImpact } = await import('@monoes/monograph');
|
|
95
|
+
const db = openDb(getDbPath());
|
|
96
|
+
try {
|
|
97
|
+
const result = getMonographApiImpact(db, {
|
|
98
|
+
routePath: input.routePath,
|
|
99
|
+
method: input.method,
|
|
100
|
+
});
|
|
101
|
+
if (!result.route)
|
|
102
|
+
return text(`Route not found: ${input.routePath}. Run monograph_build or check the path.`);
|
|
103
|
+
const riskLabel = result.riskScore >= 0.7 ? 'HIGH' : result.riskScore >= 0.4 ? 'MEDIUM' : 'LOW';
|
|
104
|
+
const lines = [
|
|
105
|
+
`Route: ${result.route.method} ${result.route.path} risk=${riskLabel} (${result.riskScore.toFixed(2)})`,
|
|
106
|
+
];
|
|
107
|
+
if (result.handler) {
|
|
108
|
+
const hLoc = result.handler.filePath
|
|
109
|
+
? (result.handler.startLine != null ? `${result.handler.filePath}:${result.handler.startLine}` : result.handler.filePath)
|
|
110
|
+
: '';
|
|
111
|
+
lines.push(`Handler: ${result.handler.name}${hLoc ? ` ${hLoc}` : ''}`);
|
|
112
|
+
}
|
|
113
|
+
if (result.callees.length > 0) {
|
|
114
|
+
lines.push(`Callees (${result.callees.length}):`);
|
|
115
|
+
for (const c of result.callees.slice(0, 15)) {
|
|
116
|
+
const loc = c.node.filePath
|
|
117
|
+
? (c.node.startLine != null ? `${c.node.filePath}:${c.node.startLine}` : c.node.filePath)
|
|
118
|
+
: '';
|
|
119
|
+
lines.push(` ${' '.repeat(c.depth)}→ ${c.node.name} [${c.node.label}]${loc ? ` ${loc}` : ''}`);
|
|
120
|
+
}
|
|
121
|
+
if (result.callees.length > 15)
|
|
122
|
+
lines.push(` … ${result.callees.length - 15} more`);
|
|
123
|
+
}
|
|
124
|
+
if (result.affectedProcesses.length > 0) {
|
|
125
|
+
lines.push(`Affected processes: ${result.affectedProcesses.map(p => p.name).join(', ')}`);
|
|
126
|
+
}
|
|
127
|
+
return text(lines.join('\n'));
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
closeDb(db);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
// ── monograph_dead_code ──────────────────────────────────────────────────────
|
|
135
|
+
export const monographDeadCodeTool = {
|
|
136
|
+
name: 'monograph_dead_code',
|
|
137
|
+
description: 'Detect dead code: exported functions with zero inbound references, files with no importers, and stale dist build artifacts. Returns structured JSON with candidates grouped by category. Always verify candidates with grep before deleting.',
|
|
138
|
+
inputSchema: {
|
|
139
|
+
type: 'object',
|
|
140
|
+
properties: {
|
|
141
|
+
path: { type: 'string', description: 'Absolute path to the repo (defaults to project cwd)' },
|
|
142
|
+
categories: {
|
|
143
|
+
type: 'array',
|
|
144
|
+
items: { type: 'string', enum: ['dead-functions', 'orphan-files', 'stale-dist'] },
|
|
145
|
+
description: 'Which categories to check (default: all three)',
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
handler: async (input) => {
|
|
150
|
+
const { openDb } = await import('@monoes/monograph');
|
|
151
|
+
const repoPath = input.path ?? getProjectCwd();
|
|
152
|
+
const cats = input.categories ?? ['dead-functions', 'orphan-files', 'stale-dist'];
|
|
153
|
+
const result = {};
|
|
154
|
+
const dbPath = getDbPath(repoPath);
|
|
155
|
+
// openDb's fileMustExist option isn't in the currently-published
|
|
156
|
+
// @monoes/monograph release this CLI depends on — check validity
|
|
157
|
+
// ourselves so a missing DB doesn't get silently auto-created empty.
|
|
158
|
+
if (!_isValidDb(dbPath)) {
|
|
159
|
+
return text(JSON.stringify({ error: 'No monograph index found. Run monograph_build first.' }));
|
|
160
|
+
}
|
|
161
|
+
let db = null;
|
|
162
|
+
try {
|
|
163
|
+
db = openDb(dbPath);
|
|
164
|
+
// _isValidDb's size check can't distinguish a real index from an
|
|
165
|
+
// empty-but-schema-migrated DB (better-sqlite3 auto-creates + migrates
|
|
166
|
+
// on open, and other unguarded openDb() call sites in this file can
|
|
167
|
+
// create exactly that as a side effect of an unrelated tool call before
|
|
168
|
+
// monograph_build ever runs). Verify actual content post-open so this
|
|
169
|
+
// reports "never built" instead of a misleading "0 dead functions found".
|
|
170
|
+
const { count } = db.prepare('SELECT COUNT(*) as count FROM nodes').get();
|
|
171
|
+
if (count === 0) {
|
|
172
|
+
return text(JSON.stringify({ error: 'No monograph index found. Run monograph_build first.' }));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return text(JSON.stringify({ error: 'No monograph index found. Run monograph_build first.' }));
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
if (cats.includes('dead-functions')) {
|
|
180
|
+
const { detectDeadCodeNodes } = await import('@monoes/monograph');
|
|
181
|
+
const { readFileSync } = await import('fs');
|
|
182
|
+
const nodes = detectDeadCodeNodes(db);
|
|
183
|
+
// Filter out stale graph nodes: verify the function name actually appears in the source file
|
|
184
|
+
const verified = nodes.filter(n => {
|
|
185
|
+
if (!n.filePath)
|
|
186
|
+
return false;
|
|
187
|
+
try {
|
|
188
|
+
const content = readFileSync(join(repoPath, n.filePath), 'utf-8');
|
|
189
|
+
return content.includes(n.name);
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
const staleCount = nodes.length - verified.length;
|
|
196
|
+
result['dead-functions'] = {
|
|
197
|
+
count: verified.length,
|
|
198
|
+
candidates: verified.map(n => ({
|
|
199
|
+
name: n.name,
|
|
200
|
+
location: n.filePath ? (n.startLine ? `${n.filePath}:${n.startLine}` : n.filePath) : null,
|
|
201
|
+
})),
|
|
202
|
+
...(staleCount > 0 ? { staleIndexEntries: staleCount, note: 'Some graph entries reference deleted functions. Rebuild the index with monograph_build to clean up.' } : {}),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
if (cats.includes('orphan-files')) {
|
|
206
|
+
const rows = db.prepare(`
|
|
207
|
+
SELECT n.name, n.file_path,
|
|
208
|
+
(SELECT COUNT(*) FROM edges e WHERE e.source_id = n.id AND e.relation = 'IMPORTS') as imports_out,
|
|
209
|
+
(SELECT COUNT(*) FROM edges e WHERE e.target_id = n.id AND e.relation = 'IMPORTS') as imported_by
|
|
210
|
+
FROM nodes n
|
|
211
|
+
WHERE n.label = 'File'
|
|
212
|
+
AND (SELECT COUNT(*) FROM edges e WHERE e.target_id = n.id AND e.relation = 'IMPORTS') = 0
|
|
213
|
+
AND n.file_path NOT LIKE '%/test/%'
|
|
214
|
+
AND n.file_path NOT LIKE '%/tests/%'
|
|
215
|
+
AND n.file_path NOT LIKE '%.test.%'
|
|
216
|
+
AND n.file_path NOT LIKE '%__tests__%'
|
|
217
|
+
AND n.file_path NOT LIKE '%/spec/%'
|
|
218
|
+
AND n.file_path NOT LIKE '%.spec.%'
|
|
219
|
+
AND n.file_path NOT LIKE '%/index.%'
|
|
220
|
+
AND n.file_path NOT LIKE 'bin/%'
|
|
221
|
+
AND n.file_path NOT LIKE 'scripts/%'
|
|
222
|
+
AND n.file_path NOT LIKE '%/cli.ts'
|
|
223
|
+
AND n.file_path NOT LIKE '%/cli.js'
|
|
224
|
+
AND n.file_path NOT LIKE '%/main.ts'
|
|
225
|
+
AND n.file_path NOT LIKE '%/main.js'
|
|
226
|
+
AND n.file_path NOT LIKE '%/dist/%'
|
|
227
|
+
AND n.file_path NOT LIKE '%node_modules%'
|
|
228
|
+
ORDER BY n.file_path
|
|
229
|
+
`).all();
|
|
230
|
+
const withOutbound = rows.filter((r) => r.imports_out > 0);
|
|
231
|
+
const isolated = rows.filter((r) => r.imports_out === 0);
|
|
232
|
+
result['orphan-files'] = {
|
|
233
|
+
count: withOutbound.length,
|
|
234
|
+
note: 'Files that import other modules but nothing imports them. May be lazy-loaded or dynamically imported — verify with grep.',
|
|
235
|
+
candidates: withOutbound.map((r) => ({ file: r.file_path, outboundImports: r.imports_out })),
|
|
236
|
+
...(isolated.length > 0 ? {
|
|
237
|
+
isolated: {
|
|
238
|
+
count: isolated.length,
|
|
239
|
+
note: 'Files with zero edges in either direction — likely standalone scripts or entry points.',
|
|
240
|
+
files: isolated.map((r) => r.file_path),
|
|
241
|
+
},
|
|
242
|
+
} : {}),
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
if (cats.includes('stale-dist')) {
|
|
246
|
+
result['stale-dist'] = findStaleDist(repoPath);
|
|
247
|
+
}
|
|
248
|
+
return text(JSON.stringify(result, null, 2));
|
|
249
|
+
}
|
|
250
|
+
finally {
|
|
251
|
+
db.close();
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
function findStaleDist(repoPath) {
|
|
256
|
+
const distSrc = join(repoPath, 'dist', 'src');
|
|
257
|
+
const src = join(repoPath, 'src');
|
|
258
|
+
// Scan a single package for stale dist artifacts
|
|
259
|
+
const scanPkg = (pkgPath, pkgName) => {
|
|
260
|
+
const pkgDistSrc = join(pkgPath, 'dist', 'src');
|
|
261
|
+
const pkgSrc = join(pkgPath, 'src');
|
|
262
|
+
if (!existsSync(pkgDistSrc) || !existsSync(pkgSrc))
|
|
263
|
+
return null;
|
|
264
|
+
const staleDirs = [];
|
|
265
|
+
const staleFiles = [];
|
|
266
|
+
let resourceForks = 0;
|
|
267
|
+
try {
|
|
268
|
+
const distDirs = readdirSync(pkgDistSrc, { withFileTypes: true })
|
|
269
|
+
.filter(d => d.isDirectory() && !d.name.startsWith('.') && !d.name.startsWith('._'));
|
|
270
|
+
const srcDirs = new Set(readdirSync(pkgSrc, { withFileTypes: true })
|
|
271
|
+
.filter(d => d.isDirectory() && !d.name.startsWith('.'))
|
|
272
|
+
.map(d => d.name));
|
|
273
|
+
for (const d of distDirs) {
|
|
274
|
+
if (!srcDirs.has(d.name))
|
|
275
|
+
staleDirs.push(d.name);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
catch { /* skip */ }
|
|
279
|
+
try {
|
|
280
|
+
const distFiles = readdirSync(pkgDistSrc)
|
|
281
|
+
.filter(f => f.endsWith('.js') && !f.startsWith('.') && !f.startsWith('._'));
|
|
282
|
+
for (const f of distFiles) {
|
|
283
|
+
const tsName = f.replace(/\.js$/, '.ts');
|
|
284
|
+
if (!existsSync(join(pkgSrc, tsName)))
|
|
285
|
+
staleFiles.push(f);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
catch { /* skip */ }
|
|
289
|
+
// Count macOS resource fork files
|
|
290
|
+
const countRF = (dir) => {
|
|
291
|
+
try {
|
|
292
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
293
|
+
if (entry.name.startsWith('._'))
|
|
294
|
+
resourceForks++;
|
|
295
|
+
else if (entry.isDirectory())
|
|
296
|
+
countRF(join(dir, entry.name));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
catch { /* skip */ }
|
|
300
|
+
};
|
|
301
|
+
countRF(pkgDistSrc);
|
|
302
|
+
if (staleDirs.length === 0 && staleFiles.length === 0 && resourceForks === 0)
|
|
303
|
+
return null;
|
|
304
|
+
return {
|
|
305
|
+
package: pkgName,
|
|
306
|
+
staleDirs,
|
|
307
|
+
staleFiles,
|
|
308
|
+
...(resourceForks > 0 ? { macosResourceForks: resourceForks } : {}),
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
// Single-package repo
|
|
312
|
+
if (existsSync(distSrc) && existsSync(src)) {
|
|
313
|
+
const finding = scanPkg(repoPath, '.');
|
|
314
|
+
return {
|
|
315
|
+
count: finding ? finding.staleDirs.length + finding.staleFiles.length : 0,
|
|
316
|
+
note: 'Directories/files in dist/src/ with no corresponding source. Fix: rm -rf dist && npm run build.',
|
|
317
|
+
...(finding ? { findings: [finding] } : {}),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
// Monorepo: scan all packages
|
|
321
|
+
const packagesDir = join(repoPath, 'packages');
|
|
322
|
+
if (!existsSync(packagesDir))
|
|
323
|
+
return { count: 0, note: 'No dist/src or packages/ found' };
|
|
324
|
+
const findings = [];
|
|
325
|
+
try {
|
|
326
|
+
for (const scope of readdirSync(packagesDir, { withFileTypes: true })) {
|
|
327
|
+
if (!scope.isDirectory())
|
|
328
|
+
continue;
|
|
329
|
+
const scopeDir = join(packagesDir, scope.name);
|
|
330
|
+
if (scope.name.startsWith('@')) {
|
|
331
|
+
for (const pkg of readdirSync(scopeDir, { withFileTypes: true })) {
|
|
332
|
+
if (!pkg.isDirectory())
|
|
333
|
+
continue;
|
|
334
|
+
const f = scanPkg(join(scopeDir, pkg.name), `${scope.name}/${pkg.name}`);
|
|
335
|
+
if (f)
|
|
336
|
+
findings.push(f);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
const f = scanPkg(scopeDir, scope.name);
|
|
341
|
+
if (f)
|
|
342
|
+
findings.push(f);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
catch { /* skip */ }
|
|
347
|
+
return {
|
|
348
|
+
count: findings.reduce((s, f) => s + (f.staleDirs?.length ?? 0) + (f.staleFiles?.length ?? 0), 0),
|
|
349
|
+
note: 'Directories/files in dist/src/ with no corresponding source. Fix: rm -rf dist && npm run build.',
|
|
350
|
+
findings,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
// ── monograph_route_map ───────────────────────────────────────────────────────
|
|
354
|
+
export const monographRouteMapTool = {
|
|
355
|
+
name: 'monograph_route_map',
|
|
356
|
+
description: 'List all HTTP routes in the codebase with their handler info. Supports filtering by URL prefix or HTTP method.',
|
|
357
|
+
inputSchema: {
|
|
358
|
+
type: 'object',
|
|
359
|
+
properties: {
|
|
360
|
+
prefix: { type: 'string', description: 'Filter routes whose path contains this prefix (e.g. /api)' },
|
|
361
|
+
method: { type: 'string', description: 'Filter by HTTP method: GET, POST, PUT, DELETE, PATCH, ANY' },
|
|
362
|
+
includeMiddleware: { type: 'boolean', description: 'Include middleware/use routes (default: false)' },
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
handler: async (input) => {
|
|
366
|
+
const { openDb, closeDb } = await import('@monoes/monograph');
|
|
367
|
+
const { getMonographRouteMap } = await import('@monoes/monograph');
|
|
368
|
+
const db = openDb(getDbPath());
|
|
369
|
+
try {
|
|
370
|
+
const result = getMonographRouteMap(db, {
|
|
371
|
+
prefix: input.prefix,
|
|
372
|
+
method: input.method,
|
|
373
|
+
includeMiddleware: input.includeMiddleware,
|
|
374
|
+
});
|
|
375
|
+
if (result.routes.length === 0)
|
|
376
|
+
return text('No routes found. Run monograph_build first or adjust your filters.');
|
|
377
|
+
const lines = [`Routes (${result.total} total):`];
|
|
378
|
+
for (const r of result.routes) {
|
|
379
|
+
const loc = r.handlerFile
|
|
380
|
+
? (r.handlerLine != null ? `${r.handlerFile}:${r.handlerLine}` : r.handlerFile)
|
|
381
|
+
: '';
|
|
382
|
+
const mw = r.middlewareChain.length > 0 ? ` middleware: ${r.middlewareChain.join(' → ')}` : '';
|
|
383
|
+
lines.push(` ${r.method} ${r.path}${r.handlerName ? ` → ${r.handlerName}` : ''}${loc ? ` (${loc})` : ''}${mw}`);
|
|
384
|
+
}
|
|
385
|
+
return text(lines.join('\n'));
|
|
386
|
+
}
|
|
387
|
+
finally {
|
|
388
|
+
closeDb(db);
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
// ── monograph_shape_check ─────────────────────────────────────────────────────
|
|
393
|
+
export const monographShapeCheckTool = {
|
|
394
|
+
name: 'monograph_shape_check',
|
|
395
|
+
description: 'Validate API route response shapes: checks that handler return keys match consumer property accesses. Detects shape mismatches between producer and consumer.',
|
|
396
|
+
inputSchema: {
|
|
397
|
+
type: 'object',
|
|
398
|
+
properties: {
|
|
399
|
+
route: { type: 'string', description: 'Filter by route path substring (e.g. /api/users)' },
|
|
400
|
+
file: { type: 'string', description: 'Filter by source file path substring' },
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
handler: async (input) => {
|
|
404
|
+
const { openDb, closeDb } = await import('@monoes/monograph');
|
|
405
|
+
const { getShapeCheck } = await import('@monoes/monograph');
|
|
406
|
+
const db = openDb(getDbPath());
|
|
407
|
+
const repoPath = getProjectCwd();
|
|
408
|
+
try {
|
|
409
|
+
const result = getShapeCheck(db, repoPath, {
|
|
410
|
+
route: input.route,
|
|
411
|
+
file: input.file,
|
|
412
|
+
});
|
|
413
|
+
// Render as structured text so LLMs can act on it directly without parsing JSON.
|
|
414
|
+
const lines = [];
|
|
415
|
+
lines.push(`Shape check: ${result.message}`);
|
|
416
|
+
if (result.route) {
|
|
417
|
+
const handlerLoc = result.route.handlerFile
|
|
418
|
+
? ` Handler: ${result.route.handlerName} [${result.route.handlerFile}]`
|
|
419
|
+
: ` Handler: ${result.route.handlerName}`;
|
|
420
|
+
lines.push(`Route: ${result.route.method} ${result.route.path}`);
|
|
421
|
+
lines.push(handlerLoc);
|
|
422
|
+
}
|
|
423
|
+
if (result.shape.returnedKeys.length > 0) {
|
|
424
|
+
lines.push(` Returned keys: ${result.shape.returnedKeys.join(', ')}`);
|
|
425
|
+
}
|
|
426
|
+
if (result.shape.accessedKeys.length > 0) {
|
|
427
|
+
lines.push(` Accessed keys: ${result.shape.accessedKeys.join(', ')}`);
|
|
428
|
+
}
|
|
429
|
+
if (result.shape.mismatches.length > 0) {
|
|
430
|
+
lines.push(` Mismatches (accessed but not returned): ${result.shape.mismatches.join(', ')}`);
|
|
431
|
+
}
|
|
432
|
+
if (result.shape.extra.length > 0) {
|
|
433
|
+
lines.push(` Unused returned keys: ${result.shape.extra.join(', ')}`);
|
|
434
|
+
}
|
|
435
|
+
if (result.consumers.length > 0) {
|
|
436
|
+
lines.push(` Consumers (${result.consumers.length}):`);
|
|
437
|
+
for (const c of result.consumers.slice(0, 10)) {
|
|
438
|
+
lines.push(` - ${c.name} [${c.filePath}]`);
|
|
439
|
+
}
|
|
440
|
+
if (result.consumers.length > 10) {
|
|
441
|
+
lines.push(` … ${result.consumers.length - 10} more`);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return text(lines.join('\n'));
|
|
445
|
+
}
|
|
446
|
+
finally {
|
|
447
|
+
closeDb(db);
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
// ── monograph_rename ──────────────────────────────────────────────────────────
|
|
452
|
+
export const monographRenameTool = {
|
|
453
|
+
name: 'monograph_rename',
|
|
454
|
+
description: 'Dry-run multi-file rename: finds all references to a symbol and shows before/after diffs without writing files.',
|
|
455
|
+
inputSchema: {
|
|
456
|
+
type: 'object',
|
|
457
|
+
properties: {
|
|
458
|
+
oldName: { type: 'string', description: 'Current symbol name' },
|
|
459
|
+
newName: { type: 'string', description: 'New symbol name' },
|
|
460
|
+
filePath: { type: 'string', description: 'Optional file path to disambiguate the symbol' },
|
|
461
|
+
dryRun: { type: 'boolean', description: 'Always true — files are never modified (default: true)' },
|
|
462
|
+
},
|
|
463
|
+
required: ['oldName', 'newName'],
|
|
464
|
+
},
|
|
465
|
+
handler: async (input) => {
|
|
466
|
+
const { openDb, closeDb } = await import('@monoes/monograph');
|
|
467
|
+
const { getMonographRename } = await import('@monoes/monograph');
|
|
468
|
+
const db = openDb(getDbPath());
|
|
469
|
+
try {
|
|
470
|
+
const result = getMonographRename(db, {
|
|
471
|
+
oldName: input.oldName,
|
|
472
|
+
newName: input.newName,
|
|
473
|
+
filePath: input.filePath,
|
|
474
|
+
dryRun: input.dryRun ?? true,
|
|
475
|
+
});
|
|
476
|
+
// Format as structured text for direct LLM navigation instead of raw JSON
|
|
477
|
+
const rn = result;
|
|
478
|
+
if (!rn)
|
|
479
|
+
return text(`Symbol not found: ${input.oldName}`);
|
|
480
|
+
const occurrences = rn.occurrences ?? rn.references ?? [];
|
|
481
|
+
const lines = [
|
|
482
|
+
`Rename: ${input.oldName} → ${input.newName} (dry-run)`,
|
|
483
|
+
`Occurrences: ${occurrences.length}`,
|
|
484
|
+
'',
|
|
485
|
+
];
|
|
486
|
+
for (const occ of occurrences.slice(0, 30)) {
|
|
487
|
+
const fp = occ.filePath ?? occ.file_path ?? '';
|
|
488
|
+
const ln = occ.line ?? occ.startLine ?? occ.start_line;
|
|
489
|
+
const loc = fp ? (ln != null ? `${fp}:${ln}` : fp) : '';
|
|
490
|
+
lines.push(` ${loc || occ}`);
|
|
491
|
+
}
|
|
492
|
+
if (occurrences.length > 30)
|
|
493
|
+
lines.push(` … ${occurrences.length - 30} more`);
|
|
494
|
+
return text(lines.join('\n').trim());
|
|
495
|
+
}
|
|
496
|
+
finally {
|
|
497
|
+
closeDb(db);
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
};
|
|
501
|
+
// ── monograph_tool_map ────────────────────────────────────────────────────────
|
|
502
|
+
export const monographToolMapTool = {
|
|
503
|
+
name: 'monograph_tool_map',
|
|
504
|
+
description: 'List MCP/RPC tool definitions in the knowledge graph with handler associations. Shows which functions handle each tool.',
|
|
505
|
+
inputSchema: {
|
|
506
|
+
type: 'object',
|
|
507
|
+
properties: {
|
|
508
|
+
tool: { type: 'string', description: 'Filter by tool name substring' },
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
handler: async (input) => {
|
|
512
|
+
const { openDb, closeDb } = await import('@monoes/monograph');
|
|
513
|
+
const { getToolMap } = await import('@monoes/monograph');
|
|
514
|
+
const db = openDb(getDbPath());
|
|
515
|
+
try {
|
|
516
|
+
const results = getToolMap(db, { tool: input.tool });
|
|
517
|
+
if (results.length === 0)
|
|
518
|
+
return text('No tools found. Run monograph_build first.');
|
|
519
|
+
const lines = results.map(r => {
|
|
520
|
+
const loc = r.handlerFile
|
|
521
|
+
? (r.handlerLine != null ? `${r.handlerFile}:${r.handlerLine}` : r.handlerFile)
|
|
522
|
+
: (r.filePath ?? '');
|
|
523
|
+
return `${r.name}${r.handlerName ? ` → ${r.handlerName}` : ''}${loc ? ` (${loc})` : ''}`;
|
|
524
|
+
});
|
|
525
|
+
return text(`Tools (${results.length}):\n${lines.join('\n')}`);
|
|
526
|
+
}
|
|
527
|
+
finally {
|
|
528
|
+
closeDb(db);
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
};
|
|
532
|
+
//# sourceMappingURL=impact-tools.js.map
|