@monoes/monomindcli 2.9.23 → 2.9.25
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/dist/src/agents/registry-builder.d.ts.map +1 -1
- package/dist/src/agents/registry-builder.js +8 -9
- package/dist/src/agents/registry-builder.js.map +1 -1
- package/dist/src/autopilot-state.js +6 -6
- package/dist/src/autopilot-state.js.map +1 -1
- package/dist/src/browser/action-builder/analyzer.d.ts.map +1 -1
- package/dist/src/browser/action-builder/analyzer.js +6 -6
- package/dist/src/browser/action-builder/analyzer.js.map +1 -1
- package/dist/src/browser/action-builder/types.d.ts.map +1 -1
- package/dist/src/browser/adapters/gemini.d.ts.map +1 -1
- package/dist/src/browser/adapters/index.d.ts.map +1 -1
- package/dist/src/browser/adapters/index.js +2 -2
- package/dist/src/browser/adapters/index.js.map +1 -1
- package/dist/src/browser/adapters/instagram.d.ts.map +1 -1
- package/dist/src/browser/adapters/linkedin.d.ts.map +1 -1
- package/dist/src/browser/adapters/linkedin.js +9 -1
- package/dist/src/browser/adapters/linkedin.js.map +1 -1
- package/dist/src/browser/adapters/x.d.ts.map +1 -1
- package/dist/src/browser/adapters/x.js +14 -2
- package/dist/src/browser/adapters/x.js.map +1 -1
- package/dist/src/browser/dashboard/server.d.ts.map +1 -1
- package/dist/src/browser/dashboard/server.js +22 -12
- package/dist/src/browser/dashboard/server.js.map +1 -1
- package/dist/src/browser/dashboard/ui.html +3 -3
- package/dist/src/browser/workflow/engine.d.ts +1 -1
- package/dist/src/browser/workflow/engine.d.ts.map +1 -1
- package/dist/src/browser/workflow/engine.js +74 -25
- package/dist/src/browser/workflow/engine.js.map +1 -1
- package/dist/src/browser/workflow/store.d.ts +1 -1
- package/dist/src/browser/workflow/store.d.ts.map +1 -1
- package/dist/src/browser/workflow/store.js +54 -26
- package/dist/src/browser/workflow/store.js.map +1 -1
- package/dist/src/browser/workflow/types.d.ts.map +1 -1
- package/dist/src/capabilities/cap-code.d.ts.map +1 -1
- package/dist/src/capabilities/cap-code.js.map +1 -1
- package/dist/src/capabilities/cap-data.d.ts.map +1 -1
- package/dist/src/capabilities/cap-data.js +28 -8
- package/dist/src/capabilities/cap-data.js.map +1 -1
- package/dist/src/capabilities/cap-documents.d.ts.map +1 -1
- package/dist/src/capabilities/cap-documents.js +93 -22
- package/dist/src/capabilities/cap-documents.js.map +1 -1
- package/dist/src/capabilities/cap-graph.d.ts.map +1 -1
- package/dist/src/capabilities/cap-graph.js +3 -3
- package/dist/src/capabilities/cap-graph.js.map +1 -1
- package/dist/src/capabilities/cap-media.d.ts.map +1 -1
- package/dist/src/capabilities/cap-media.js +1 -1
- package/dist/src/capabilities/cap-media.js.map +1 -1
- package/dist/src/capabilities/cap-timeline.d.ts.map +1 -1
- package/dist/src/capabilities/cap-timeline.js +33 -7
- package/dist/src/capabilities/cap-timeline.js.map +1 -1
- package/dist/src/capabilities/index.d.ts +5 -5
- package/dist/src/capabilities/index.d.ts.map +1 -1
- package/dist/src/capabilities/index.js +5 -5
- package/dist/src/capabilities/index.js.map +1 -1
- package/dist/src/capabilities/manager.d.ts.map +1 -1
- package/dist/src/capabilities/manager.js +6 -6
- package/dist/src/capabilities/manager.js.map +1 -1
- package/dist/src/capabilities/scanner.d.ts.map +1 -1
- package/dist/src/capabilities/scanner.js +103 -14
- package/dist/src/capabilities/scanner.js.map +1 -1
- package/dist/src/commands/agent-lifecycle.d.ts.map +1 -1
- package/dist/src/commands/agent-lifecycle.js +116 -32
- package/dist/src/commands/agent-lifecycle.js.map +1 -1
- package/dist/src/commands/agent-ops.d.ts.map +1 -1
- package/dist/src/commands/agent-ops.js +72 -19
- package/dist/src/commands/agent-ops.js.map +1 -1
- package/dist/src/commands/agent.d.ts.map +1 -1
- package/dist/src/commands/agent.js +11 -3
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze-ast.d.ts.map +1 -1
- package/dist/src/commands/analyze-ast.js +41 -16
- package/dist/src/commands/analyze-ast.js.map +1 -1
- package/dist/src/commands/analyze-diff.d.ts.map +1 -1
- package/dist/src/commands/analyze-diff.js +147 -35
- package/dist/src/commands/analyze-diff.js.map +1 -1
- package/dist/src/commands/analyze-imports.d.ts.map +1 -1
- package/dist/src/commands/analyze-imports.js +59 -16
- package/dist/src/commands/analyze-imports.js.map +1 -1
- package/dist/src/commands/analyze-symbols.d.ts.map +1 -1
- package/dist/src/commands/analyze-symbols.js +48 -20
- package/dist/src/commands/analyze-symbols.js.map +1 -1
- package/dist/src/commands/analyze.d.ts.map +1 -1
- package/dist/src/commands/analyze.js +30 -14
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/autopilot.d.ts.map +1 -1
- package/dist/src/commands/autopilot.js +2 -2
- package/dist/src/commands/autopilot.js.map +1 -1
- package/dist/src/commands/browse-action.d.ts.map +1 -1
- package/dist/src/commands/browse-action.js +65 -17
- package/dist/src/commands/browse-action.js.map +1 -1
- package/dist/src/commands/browse-platform.d.ts.map +1 -1
- package/dist/src/commands/browse-platform.js +13 -10
- package/dist/src/commands/browse-platform.js.map +1 -1
- package/dist/src/commands/browse-workflow.d.ts.map +1 -1
- package/dist/src/commands/browse-workflow.js +54 -20
- package/dist/src/commands/browse-workflow.js.map +1 -1
- package/dist/src/commands/browse.js +2 -2
- package/dist/src/commands/browse.js.map +1 -1
- package/dist/src/commands/cleanup.d.ts.map +1 -1
- package/dist/src/commands/cleanup.js +111 -47
- package/dist/src/commands/cleanup.js.map +1 -1
- package/dist/src/commands/completions.d.ts.map +1 -1
- package/dist/src/commands/completions.js +34 -20
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.d.ts.map +1 -1
- package/dist/src/commands/config.js +90 -49
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/crash-reporting.d.ts.map +1 -1
- package/dist/src/commands/crash-reporting.js +10 -4
- package/dist/src/commands/crash-reporting.js.map +1 -1
- package/dist/src/commands/design-detect.d.ts.map +1 -1
- package/dist/src/commands/design-detect.js +33 -12
- package/dist/src/commands/design-detect.js.map +1 -1
- package/dist/src/commands/design-palette.d.ts.map +1 -1
- package/dist/src/commands/design-palette.js +770 -380
- package/dist/src/commands/design-palette.js.map +1 -1
- package/dist/src/commands/doc.d.ts.map +1 -1
- package/dist/src/commands/doc.js +272 -60
- package/dist/src/commands/doc.js.map +1 -1
- package/dist/src/commands/doctor-env-checks.d.ts.map +1 -1
- package/dist/src/commands/doctor-env-checks.js +130 -31
- package/dist/src/commands/doctor-env-checks.js.map +1 -1
- package/dist/src/commands/doctor-monoes-checks.d.ts.map +1 -1
- package/dist/src/commands/doctor-monoes-checks.js +20 -7
- package/dist/src/commands/doctor-monoes-checks.js.map +1 -1
- package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
- package/dist/src/commands/doctor-project-checks.js +442 -112
- package/dist/src/commands/doctor-project-checks.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +132 -59
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/download-embeddings.d.ts.map +1 -1
- package/dist/src/commands/download-embeddings.js +1 -1
- package/dist/src/commands/download-embeddings.js.map +1 -1
- package/dist/src/commands/events.d.ts.map +1 -1
- package/dist/src/commands/events.js +5 -2
- package/dist/src/commands/events.js.map +1 -1
- package/dist/src/commands/guidance.d.ts.map +1 -1
- package/dist/src/commands/guidance.js +38 -14
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hooks-core-commands.d.ts.map +1 -1
- package/dist/src/commands/hooks-core-commands.js +71 -44
- package/dist/src/commands/hooks-core-commands.js.map +1 -1
- package/dist/src/commands/hooks-coverage-commands.d.ts +1 -2
- package/dist/src/commands/hooks-coverage-commands.d.ts.map +1 -1
- package/dist/src/commands/hooks-coverage-commands.js +140 -58
- package/dist/src/commands/hooks-coverage-commands.js.map +1 -1
- package/dist/src/commands/hooks-coverage-gaps.d.ts.map +1 -1
- package/dist/src/commands/hooks-coverage-gaps.js +74 -36
- package/dist/src/commands/hooks-coverage-gaps.js.map +1 -1
- package/dist/src/commands/hooks-coverage-routing.d.ts.map +1 -1
- package/dist/src/commands/hooks-coverage-routing.js +139 -66
- package/dist/src/commands/hooks-coverage-routing.js.map +1 -1
- package/dist/src/commands/hooks-coverage-utils.d.ts.map +1 -1
- package/dist/src/commands/hooks-coverage-utils.js +27 -8
- package/dist/src/commands/hooks-coverage-utils.js.map +1 -1
- package/dist/src/commands/hooks-extended-commands.d.ts.map +1 -1
- package/dist/src/commands/hooks-extended-commands.js +86 -21
- package/dist/src/commands/hooks-extended-commands.js.map +1 -1
- package/dist/src/commands/hooks-routing-commands.d.ts.map +1 -1
- package/dist/src/commands/hooks-routing-commands.js +174 -82
- package/dist/src/commands/hooks-routing-commands.js.map +1 -1
- package/dist/src/commands/hooks-workers.d.ts.map +1 -1
- package/dist/src/commands/hooks-workers.js +96 -61
- package/dist/src/commands/hooks-workers.js.map +1 -1
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +6 -6
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/init-subcommands.d.ts.map +1 -1
- package/dist/src/commands/init-subcommands.js +12 -5
- package/dist/src/commands/init-subcommands.js.map +1 -1
- package/dist/src/commands/init-upgrade.d.ts.map +1 -1
- package/dist/src/commands/init-upgrade.js +46 -23
- package/dist/src/commands/init-upgrade.js.map +1 -1
- package/dist/src/commands/init-wizard.d.ts.map +1 -1
- package/dist/src/commands/init-wizard.js +161 -36
- 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 +132 -47
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/mcp.d.ts.map +1 -1
- package/dist/src/commands/mcp.js +128 -84
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory-admin.d.ts.map +1 -1
- package/dist/src/commands/memory-admin.js +67 -48
- package/dist/src/commands/memory-admin.js.map +1 -1
- package/dist/src/commands/memory-crud.d.ts.map +1 -1
- package/dist/src/commands/memory-crud.js +65 -41
- package/dist/src/commands/memory-crud.js.map +1 -1
- package/dist/src/commands/memory-list.d.ts.map +1 -1
- package/dist/src/commands/memory-list.js +6 -6
- package/dist/src/commands/memory-list.js.map +1 -1
- package/dist/src/commands/memory-transfer.d.ts.map +1 -1
- package/dist/src/commands/memory-transfer.js +46 -23
- package/dist/src/commands/memory-transfer.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +63 -35
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/monograph.d.ts.map +1 -1
- package/dist/src/commands/monograph.js +170 -57
- package/dist/src/commands/monograph.js.map +1 -1
- package/dist/src/commands/monoswarm.d.ts.map +1 -1
- package/dist/src/commands/monoswarm.js +11 -19
- package/dist/src/commands/monoswarm.js.map +1 -1
- package/dist/src/commands/neural-core.d.ts.map +1 -1
- package/dist/src/commands/neural-core.js +114 -31
- package/dist/src/commands/neural-core.js.map +1 -1
- package/dist/src/commands/neural-optimize.d.ts.map +1 -1
- package/dist/src/commands/neural-optimize.js +67 -22
- package/dist/src/commands/neural-optimize.js.map +1 -1
- package/dist/src/commands/neural-registry.d.ts.map +1 -1
- package/dist/src/commands/neural-registry.js +50 -14
- package/dist/src/commands/neural-registry.js.map +1 -1
- package/dist/src/commands/org-observe.d.ts.map +1 -1
- package/dist/src/commands/org-observe.js +180 -92
- package/dist/src/commands/org-observe.js.map +1 -1
- package/dist/src/commands/org-visualize.d.ts.map +1 -1
- package/dist/src/commands/org-visualize.js +10 -5
- package/dist/src/commands/org-visualize.js.map +1 -1
- package/dist/src/commands/org.d.ts +1 -1
- package/dist/src/commands/org.d.ts.map +1 -1
- package/dist/src/commands/org.js +580 -188
- package/dist/src/commands/org.js.map +1 -1
- package/dist/src/commands/performance.d.ts.map +1 -1
- package/dist/src/commands/performance.js +200 -54
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/platforms.d.ts +1 -1
- package/dist/src/commands/platforms.d.ts.map +1 -1
- package/dist/src/commands/platforms.js +89 -49
- package/dist/src/commands/platforms.js.map +1 -1
- package/dist/src/commands/providers.d.ts.map +1 -1
- package/dist/src/commands/providers.js +31 -18
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/report-crash.d.ts.map +1 -1
- package/dist/src/commands/report-crash.js +17 -5
- package/dist/src/commands/report-crash.js.map +1 -1
- package/dist/src/commands/route.d.ts.map +1 -1
- package/dist/src/commands/route.js +123 -41
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/search-universal.d.ts +1 -1
- package/dist/src/commands/search-universal.d.ts.map +1 -1
- package/dist/src/commands/search-universal.js +29 -14
- package/dist/src/commands/search-universal.js.map +1 -1
- package/dist/src/commands/security-cve.d.ts.map +1 -1
- package/dist/src/commands/security-cve.js +75 -34
- package/dist/src/commands/security-cve.js.map +1 -1
- package/dist/src/commands/security-misc.d.ts.map +1 -1
- package/dist/src/commands/security-misc.js +173 -43
- package/dist/src/commands/security-misc.js.map +1 -1
- package/dist/src/commands/security-scan.d.ts +1 -1
- package/dist/src/commands/security-scan.d.ts.map +1 -1
- package/dist/src/commands/security-scan.js +135 -39
- package/dist/src/commands/security-scan.js.map +1 -1
- package/dist/src/commands/security.d.ts.map +1 -1
- package/dist/src/commands/security.js +9 -2
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.d.ts.map +1 -1
- package/dist/src/commands/session.js +81 -75
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.d.ts.map +1 -1
- package/dist/src/commands/start.js +43 -34
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +88 -75
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/task.d.ts.map +1 -1
- package/dist/src/commands/task.js +115 -84
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/tokens.d.ts.map +1 -1
- package/dist/src/commands/tokens.js +64 -28
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/update.d.ts.map +1 -1
- package/dist/src/commands/update.js +3 -5
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/consensus/audit-writer.d.ts +5 -0
- package/dist/src/consensus/audit-writer.d.ts.map +1 -1
- package/dist/src/consensus/audit-writer.js +18 -10
- package/dist/src/consensus/audit-writer.js.map +1 -1
- package/dist/src/consensus/tally.d.ts.map +1 -1
- package/dist/src/consensus/tally.js +2 -2
- package/dist/src/consensus/tally.js.map +1 -1
- package/dist/src/index.d.ts +6 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +41 -35
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts +1 -1
- package/dist/src/init/claudemd-generator.d.ts.map +1 -1
- package/dist/src/init/claudemd-generator.js +22 -7
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/codex-generator.d.ts +7 -1
- package/dist/src/init/codex-generator.d.ts.map +1 -1
- package/dist/src/init/codex-generator.js +114 -1
- package/dist/src/init/codex-generator.js.map +1 -1
- package/dist/src/init/copy-assets.d.ts.map +1 -1
- package/dist/src/init/copy-assets.js +13 -12
- package/dist/src/init/copy-assets.js.map +1 -1
- package/dist/src/init/executor.d.ts +1 -1
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +49 -29
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/geminimd-generator.d.ts +1 -1
- package/dist/src/init/geminimd-generator.d.ts.map +1 -1
- package/dist/src/init/geminimd-generator.js +2 -2
- package/dist/src/init/geminimd-generator.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts.map +1 -1
- package/dist/src/init/helpers-generator.js +6 -6
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/index.d.ts +8 -8
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +9 -9
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/kimi-generator.d.ts +1 -1
- package/dist/src/init/kimi-generator.d.ts.map +1 -1
- package/dist/src/init/kimi-generator.js +34 -28
- package/dist/src/init/kimi-generator.js.map +1 -1
- package/dist/src/init/mcp-generator.d.ts.map +1 -1
- package/dist/src/init/mcp-generator.js +3 -11
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/opencode-generator.d.ts.map +1 -1
- package/dist/src/init/opencode-generator.js +33 -20
- package/dist/src/init/opencode-generator.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +2 -5
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/shared-instructions-generator.d.ts.map +1 -1
- package/dist/src/init/shared-instructions-generator.js +124 -76
- package/dist/src/init/shared-instructions-generator.js.map +1 -1
- package/dist/src/init/shared.d.ts.map +1 -1
- package/dist/src/init/shared.js +23 -18
- package/dist/src/init/shared.js.map +1 -1
- package/dist/src/init/types.js +2 -2
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/init/upgrade.d.ts.map +1 -1
- package/dist/src/init/upgrade.js +19 -17
- package/dist/src/init/upgrade.js.map +1 -1
- package/dist/src/init/write-antigravity.d.ts.map +1 -1
- package/dist/src/init/write-antigravity.js +15 -7
- package/dist/src/init/write-antigravity.js.map +1 -1
- package/dist/src/init/write-capabilities.d.ts.map +1 -1
- package/dist/src/init/write-capabilities.js +3 -3
- package/dist/src/init/write-capabilities.js.map +1 -1
- package/dist/src/init/write-claude.d.ts.map +1 -1
- package/dist/src/init/write-claude.js +18 -14
- package/dist/src/init/write-claude.js.map +1 -1
- package/dist/src/init/write-codex.d.ts.map +1 -1
- package/dist/src/init/write-codex.js +76 -7
- package/dist/src/init/write-codex.js.map +1 -1
- package/dist/src/init/write-kimicode.d.ts.map +1 -1
- package/dist/src/init/write-kimicode.js +10 -6
- package/dist/src/init/write-kimicode.js.map +1 -1
- package/dist/src/init/write-opencode.d.ts.map +1 -1
- package/dist/src/init/write-opencode.js +4 -4
- package/dist/src/init/write-opencode.js.map +1 -1
- package/dist/src/init/write-runtime-config.d.ts.map +1 -1
- package/dist/src/init/write-runtime-config.js +20 -19
- package/dist/src/init/write-runtime-config.js.map +1 -1
- package/dist/src/init/write-sample-org.js +1 -1
- package/dist/src/init/write-sample-org.js.map +1 -1
- package/dist/src/knowledge/document-pipeline.d.ts.map +1 -1
- package/dist/src/knowledge/document-pipeline.js +144 -48
- package/dist/src/knowledge/document-pipeline.js.map +1 -1
- package/dist/src/knowledge/eval/corpus.d.ts.map +1 -1
- package/dist/src/knowledge/eval/corpus.js +18 -9
- package/dist/src/knowledge/eval/corpus.js.map +1 -1
- package/dist/src/knowledge/eval/golden-set.d.ts.map +1 -1
- package/dist/src/knowledge/eval/golden-set.js +4286 -136
- package/dist/src/knowledge/eval/golden-set.js.map +1 -1
- package/dist/src/knowledge/eval/harness.d.ts +2 -2
- package/dist/src/knowledge/eval/harness.d.ts.map +1 -1
- package/dist/src/knowledge/eval/harness.js +163 -70
- package/dist/src/knowledge/eval/harness.js.map +1 -1
- package/dist/src/knowledge/eval/metrics.d.ts.map +1 -1
- package/dist/src/knowledge/eval/metrics.js +25 -18
- package/dist/src/knowledge/eval/metrics.js.map +1 -1
- package/dist/src/knowledge/eval/model-presence.d.ts.map +1 -1
- package/dist/src/knowledge/eval/model-presence.js +40 -14
- package/dist/src/knowledge/eval/model-presence.js.map +1 -1
- package/dist/src/knowledge/eval/network-guard.d.ts.map +1 -1
- package/dist/src/knowledge/eval/network-guard.js +22 -10
- package/dist/src/knowledge/eval/network-guard.js.map +1 -1
- package/dist/src/knowledge/eval/retrievers.d.ts.map +1 -1
- package/dist/src/knowledge/eval/retrievers.js +14 -10
- package/dist/src/knowledge/eval/retrievers.js.map +1 -1
- package/dist/src/knowledge/eval/signals.d.ts.map +1 -1
- package/dist/src/knowledge/eval/signals.js +54 -18
- package/dist/src/knowledge/eval/signals.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +69 -33
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts +1 -9
- package/dist/src/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp-server.js +19 -42
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +84 -49
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.js +34 -17
- 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 +3 -3
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/autopilot-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/autopilot-tools.js +29 -9
- package/dist/src/mcp-tools/autopilot-tools.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +119 -37
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +100 -44
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +36 -15
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +34 -23
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +200 -43
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/graphify-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/graphify-tools.js +2 -2
- package/dist/src/mcp-tools/graphify-tools.js.map +1 -1
- package/dist/src/mcp-tools/guidance-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/guidance-tools.js +449 -93
- package/dist/src/mcp-tools/guidance-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-embedding.d.ts +0 -6
- package/dist/src/mcp-tools/hooks-embedding.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-embedding.js +170 -59
- package/dist/src/mcp-tools/hooks-embedding.js.map +1 -1
- package/dist/src/mcp-tools/hooks-intelligence.d.ts +0 -8
- package/dist/src/mcp-tools/hooks-intelligence.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-intelligence.js +9 -17
- package/dist/src/mcp-tools/hooks-intelligence.js.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.js +16 -15
- package/dist/src/mcp-tools/hooks-routing.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.d.ts +1 -1
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2 -2
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +18 -18
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +18 -18
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/knowledge-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/knowledge-tools.js +88 -28
- package/dist/src/mcp-tools/knowledge-tools.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +156 -39
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/monodesign-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monodesign-tools.js +63 -22
- package/dist/src/mcp-tools/monodesign-tools.js.map +1 -1
- package/dist/src/mcp-tools/monograph/agent-history-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph/agent-history-tools.js +22 -9
- package/dist/src/mcp-tools/monograph/agent-history-tools.js.map +1 -1
- package/dist/src/mcp-tools/monograph/build-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph/build-tools.js +37 -16
- package/dist/src/mcp-tools/monograph/build-tools.js.map +1 -1
- package/dist/src/mcp-tools/monograph/group-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph/group-tools.js +57 -20
- package/dist/src/mcp-tools/monograph/group-tools.js.map +1 -1
- package/dist/src/mcp-tools/monograph/health-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph/health-tools.js +13 -7
- package/dist/src/mcp-tools/monograph/health-tools.js.map +1 -1
- package/dist/src/mcp-tools/monograph/impact-tools.js +6 -6
- package/dist/src/mcp-tools/monograph/impact-tools.js.map +1 -1
- package/dist/src/mcp-tools/monograph/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph/index.js +8 -8
- package/dist/src/mcp-tools/monograph/index.js.map +1 -1
- package/dist/src/mcp-tools/monograph/query-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph/query-tools.js +131 -56
- package/dist/src/mcp-tools/monograph/query-tools.js.map +1 -1
- package/dist/src/mcp-tools/monograph/shared.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph/shared.js +42 -22
- package/dist/src/mcp-tools/monograph/shared.js.map +1 -1
- package/dist/src/mcp-tools/monograph/visualize-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph/visualize-tools.js +87 -36
- package/dist/src/mcp-tools/monograph/visualize-tools.js.map +1 -1
- package/dist/src/mcp-tools/monograph-compat.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph-compat.js +25 -14
- package/dist/src/mcp-tools/monograph-compat.js.map +1 -1
- package/dist/src/mcp-tools/monograph-tools.d.ts +1 -1
- package/dist/src/mcp-tools/monograph-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph-tools.js +1 -1
- package/dist/src/mcp-tools/monograph-tools.js.map +1 -1
- package/dist/src/mcp-tools/monomind-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monomind-tools.js +1 -1
- package/dist/src/mcp-tools/monomind-tools.js.map +1 -1
- package/dist/src/mcp-tools/monoswarm-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monoswarm-tools.js +217 -81
- package/dist/src/mcp-tools/monoswarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +280 -83
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts.map +1 -1
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js +9 -4
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js.map +1 -1
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +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 +36 -14
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.js.map +1 -1
- package/dist/src/mcp-tools/quality-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/quality-tools.js.map +1 -1
- package/dist/src/mcp-tools/request-tracker.d.ts.map +1 -1
- package/dist/src/mcp-tools/request-tracker.js +2 -1
- package/dist/src/mcp-tools/request-tracker.js.map +1 -1
- package/dist/src/mcp-tools/security-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/security-tools.js +117 -53
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +22 -13
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +7 -7
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +59 -22
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +43 -16
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +2 -1
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/types.d.ts +1 -1
- package/dist/src/mcp-tools/types.d.ts.map +1 -1
- package/dist/src/mcp-tools/types.js +1 -1
- package/dist/src/mcp-tools/types.js.map +1 -1
- package/dist/src/memory/bm25-index.d.ts.map +1 -1
- package/dist/src/memory/bm25-index.js.map +1 -1
- package/dist/src/memory/embedding-operations.d.ts.map +1 -1
- package/dist/src/memory/embedding-operations.js +23 -19
- package/dist/src/memory/embedding-operations.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.d.ts.map +1 -1
- package/dist/src/memory/ewc-consolidation.js +31 -27
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/hnsw-operations.d.ts +1 -1
- package/dist/src/memory/hnsw-operations.d.ts.map +1 -1
- package/dist/src/memory/hnsw-operations.js +5 -6
- package/dist/src/memory/hnsw-operations.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts.map +1 -1
- package/dist/src/memory/intelligence.js +122 -84
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts.map +1 -1
- package/dist/src/memory/memory-bridge.js +7 -7
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-crud.d.ts +1 -1
- package/dist/src/memory/memory-crud.d.ts.map +1 -1
- package/dist/src/memory/memory-crud.js +82 -47
- package/dist/src/memory/memory-crud.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +7 -7
- package/dist/src/memory/memory-initializer.d.ts.map +1 -1
- package/dist/src/memory/memory-initializer.js +38 -34
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/memory-kg.d.ts.map +1 -1
- package/dist/src/memory/memory-kg.js +173 -41
- package/dist/src/memory/memory-kg.js.map +1 -1
- package/dist/src/memory/memory-migrations.d.ts.map +1 -1
- package/dist/src/memory/memory-migrations.js +11 -7
- package/dist/src/memory/memory-migrations.js.map +1 -1
- package/dist/src/memory/memory-read.d.ts.map +1 -1
- package/dist/src/memory/memory-read.js +45 -21
- package/dist/src/memory/memory-read.js.map +1 -1
- package/dist/src/memory/query-router.d.ts.map +1 -1
- package/dist/src/memory/query-router.js +29 -12
- package/dist/src/memory/query-router.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts.map +1 -1
- package/dist/src/memory/sona-optimizer.js +163 -41
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/memory/text-tokens.d.ts.map +1 -1
- package/dist/src/memory/text-tokens.js +78 -8
- package/dist/src/memory/text-tokens.js.map +1 -1
- package/dist/src/monovector/command-outcomes.d.ts.map +1 -1
- package/dist/src/monovector/command-outcomes.js +23 -8
- package/dist/src/monovector/command-outcomes.js.map +1 -1
- package/dist/src/monovector/coverage-router.d.ts.map +1 -1
- package/dist/src/monovector/coverage-router.js +29 -14
- package/dist/src/monovector/coverage-router.js.map +1 -1
- package/dist/src/monovector/coverage-tools.d.ts.map +1 -1
- package/dist/src/monovector/coverage-tools.js +21 -6
- package/dist/src/monovector/coverage-tools.js.map +1 -1
- package/dist/src/monovector/diff-classifier.d.ts +1 -1
- package/dist/src/monovector/diff-classifier.d.ts.map +1 -1
- package/dist/src/monovector/diff-classifier.js +100 -45
- package/dist/src/monovector/diff-classifier.js.map +1 -1
- package/dist/src/monovector/index.d.ts +3 -4
- package/dist/src/monovector/index.d.ts.map +1 -1
- package/dist/src/monovector/index.js +18 -6
- package/dist/src/monovector/index.js.map +1 -1
- package/dist/src/monovector/init-state.d.ts.map +1 -1
- package/dist/src/monovector/init-state.js +15 -5
- package/dist/src/monovector/init-state.js.map +1 -1
- package/dist/src/monovector/model-outcomes.js +2 -2
- package/dist/src/monovector/model-outcomes.js.map +1 -1
- package/dist/src/monovector/route-outcomes.d.ts.map +1 -1
- package/dist/src/monovector/route-outcomes.js +40 -21
- package/dist/src/monovector/route-outcomes.js.map +1 -1
- package/dist/src/observability/replay-reader.d.ts.map +1 -1
- package/dist/src/observability/replay-reader.js +6 -8
- package/dist/src/observability/replay-reader.js.map +1 -1
- package/dist/src/orgrt/agent-runner.d.ts +1 -1
- package/dist/src/orgrt/agent-runner.d.ts.map +1 -1
- package/dist/src/orgrt/agent-runner.js +1 -1
- package/dist/src/orgrt/agent-runner.js.map +1 -1
- package/dist/src/orgrt/antigravity-runner.d.ts +1 -1
- package/dist/src/orgrt/antigravity-runner.d.ts.map +1 -1
- package/dist/src/orgrt/antigravity-runner.js +46 -17
- package/dist/src/orgrt/antigravity-runner.js.map +1 -1
- package/dist/src/orgrt/approvals.d.ts.map +1 -1
- package/dist/src/orgrt/approvals.js +24 -8
- package/dist/src/orgrt/approvals.js.map +1 -1
- package/dist/src/orgrt/broker.d.ts.map +1 -1
- package/dist/src/orgrt/broker.js +11 -4
- package/dist/src/orgrt/broker.js.map +1 -1
- package/dist/src/orgrt/bus.d.ts.map +1 -1
- package/dist/src/orgrt/bus.js +28 -15
- package/dist/src/orgrt/bus.js.map +1 -1
- package/dist/src/orgrt/checkpoint-ops.d.ts +1 -1
- package/dist/src/orgrt/checkpoint-ops.d.ts.map +1 -1
- package/dist/src/orgrt/checkpoint-ops.js +36 -19
- package/dist/src/orgrt/checkpoint-ops.js.map +1 -1
- package/dist/src/orgrt/checkpoint.d.ts.map +1 -1
- package/dist/src/orgrt/checkpoint.js +3 -1
- package/dist/src/orgrt/checkpoint.js.map +1 -1
- package/dist/src/orgrt/codex-runner.d.ts +1 -1
- package/dist/src/orgrt/codex-runner.d.ts.map +1 -1
- package/dist/src/orgrt/codex-runner.js +45 -18
- package/dist/src/orgrt/codex-runner.js.map +1 -1
- package/dist/src/orgrt/copilot-runner.d.ts +1 -1
- package/dist/src/orgrt/copilot-runner.d.ts.map +1 -1
- package/dist/src/orgrt/copilot-runner.js +48 -16
- package/dist/src/orgrt/copilot-runner.js.map +1 -1
- package/dist/src/orgrt/cross-org.d.ts.map +1 -1
- package/dist/src/orgrt/cross-org.js +213 -41
- package/dist/src/orgrt/cross-org.js.map +1 -1
- package/dist/src/orgrt/crush-runner.d.ts +1 -1
- package/dist/src/orgrt/crush-runner.d.ts.map +1 -1
- package/dist/src/orgrt/crush-runner.js +51 -17
- package/dist/src/orgrt/crush-runner.js.map +1 -1
- package/dist/src/orgrt/daemon.d.ts +5 -6
- package/dist/src/orgrt/daemon.d.ts.map +1 -1
- package/dist/src/orgrt/daemon.js +55 -47
- package/dist/src/orgrt/daemon.js.map +1 -1
- package/dist/src/orgrt/decisions.d.ts +2 -2
- package/dist/src/orgrt/decisions.d.ts.map +1 -1
- package/dist/src/orgrt/decisions.js +83 -34
- package/dist/src/orgrt/decisions.js.map +1 -1
- package/dist/src/orgrt/fence.d.ts +2 -2
- package/dist/src/orgrt/fence.d.ts.map +1 -1
- package/dist/src/orgrt/fence.js +13 -5
- package/dist/src/orgrt/fence.js.map +1 -1
- package/dist/src/orgrt/forwarder.js +1 -1
- package/dist/src/orgrt/forwarder.js.map +1 -1
- package/dist/src/orgrt/grok-runner.d.ts +1 -1
- package/dist/src/orgrt/grok-runner.d.ts.map +1 -1
- package/dist/src/orgrt/grok-runner.js +36 -16
- package/dist/src/orgrt/grok-runner.js.map +1 -1
- package/dist/src/orgrt/inbox.d.ts.map +1 -1
- package/dist/src/orgrt/inbox.js +5 -3
- package/dist/src/orgrt/inbox.js.map +1 -1
- package/dist/src/orgrt/kimicode-runner.d.ts +1 -1
- package/dist/src/orgrt/kimicode-runner.d.ts.map +1 -1
- package/dist/src/orgrt/kimicode-runner.js +40 -15
- package/dist/src/orgrt/kimicode-runner.js.map +1 -1
- package/dist/src/orgrt/mailbox.d.ts.map +1 -1
- package/dist/src/orgrt/mailbox.js +15 -5
- package/dist/src/orgrt/mailbox.js.map +1 -1
- package/dist/src/orgrt/migrate.d.ts.map +1 -1
- package/dist/src/orgrt/migrate.js +38 -25
- package/dist/src/orgrt/migrate.js.map +1 -1
- package/dist/src/orgrt/opencode-runner.d.ts +1 -1
- package/dist/src/orgrt/opencode-runner.d.ts.map +1 -1
- package/dist/src/orgrt/opencode-runner.js +16 -5
- package/dist/src/orgrt/opencode-runner.js.map +1 -1
- package/dist/src/orgrt/org-memory.d.ts +2 -2
- package/dist/src/orgrt/org-memory.d.ts.map +1 -1
- package/dist/src/orgrt/org-memory.js +66 -26
- package/dist/src/orgrt/org-memory.js.map +1 -1
- package/dist/src/orgrt/pi-rpc-runner.d.ts +1 -1
- package/dist/src/orgrt/pi-rpc-runner.d.ts.map +1 -1
- package/dist/src/orgrt/pi-rpc-runner.js +60 -25
- package/dist/src/orgrt/pi-rpc-runner.js.map +1 -1
- package/dist/src/orgrt/pi-runner.d.ts +1 -1
- package/dist/src/orgrt/pi-runner.d.ts.map +1 -1
- package/dist/src/orgrt/pi-runner.js +35 -16
- package/dist/src/orgrt/pi-runner.js.map +1 -1
- package/dist/src/orgrt/policy.d.ts.map +1 -1
- package/dist/src/orgrt/policy.js +65 -20
- package/dist/src/orgrt/policy.js.map +1 -1
- package/dist/src/orgrt/prechecks.d.ts.map +1 -1
- package/dist/src/orgrt/prechecks.js +9 -4
- package/dist/src/orgrt/prechecks.js.map +1 -1
- package/dist/src/orgrt/provider.d.ts +1 -1
- package/dist/src/orgrt/provider.d.ts.map +1 -1
- package/dist/src/orgrt/provider.js.map +1 -1
- package/dist/src/orgrt/questions.d.ts.map +1 -1
- package/dist/src/orgrt/questions.js +34 -10
- package/dist/src/orgrt/questions.js.map +1 -1
- package/dist/src/orgrt/qwen-rpc-runner.d.ts +1 -1
- package/dist/src/orgrt/qwen-rpc-runner.d.ts.map +1 -1
- package/dist/src/orgrt/qwen-rpc-runner.js +61 -26
- package/dist/src/orgrt/qwen-rpc-runner.js.map +1 -1
- package/dist/src/orgrt/qwen-runner.d.ts +1 -1
- package/dist/src/orgrt/qwen-runner.d.ts.map +1 -1
- package/dist/src/orgrt/qwen-runner.js +31 -15
- package/dist/src/orgrt/qwen-runner.js.map +1 -1
- package/dist/src/orgrt/remote.js +1 -1
- package/dist/src/orgrt/remote.js.map +1 -1
- package/dist/src/orgrt/reporting.d.ts.map +1 -1
- package/dist/src/orgrt/reporting.js +61 -27
- package/dist/src/orgrt/reporting.js.map +1 -1
- package/dist/src/orgrt/scheduler-integration.d.ts.map +1 -1
- package/dist/src/orgrt/scheduler-integration.js +57 -20
- package/dist/src/orgrt/scheduler-integration.js.map +1 -1
- package/dist/src/orgrt/scheduler.d.ts.map +1 -1
- package/dist/src/orgrt/scheduler.js +7 -3
- package/dist/src/orgrt/scheduler.js.map +1 -1
- package/dist/src/orgrt/server.js +1 -1
- package/dist/src/orgrt/server.js.map +1 -1
- package/dist/src/orgrt/session.d.ts +3 -3
- package/dist/src/orgrt/session.d.ts.map +1 -1
- package/dist/src/orgrt/session.js +165 -66
- package/dist/src/orgrt/session.js.map +1 -1
- package/dist/src/orgrt/state-detector.d.ts.map +1 -1
- package/dist/src/orgrt/state-detector.js +6 -2
- package/dist/src/orgrt/state-detector.js.map +1 -1
- package/dist/src/orgrt/task-dag.d.ts.map +1 -1
- package/dist/src/orgrt/task-dag.js +22 -12
- package/dist/src/orgrt/task-dag.js.map +1 -1
- package/dist/src/orgrt/templates.d.ts.map +1 -1
- package/dist/src/orgrt/templates.js +198 -36
- package/dist/src/orgrt/templates.js.map +1 -1
- package/dist/src/orgrt/test-loop.d.ts.map +1 -1
- package/dist/src/orgrt/test-loop.js +61 -34
- package/dist/src/orgrt/test-loop.js.map +1 -1
- package/dist/src/orgrt/tool-fence.d.ts.map +1 -1
- package/dist/src/orgrt/tool-fence.js +6 -3
- package/dist/src/orgrt/tool-fence.js.map +1 -1
- package/dist/src/orgrt/types.d.ts.map +1 -1
- package/dist/src/orgrt/types.js +148 -38
- package/dist/src/orgrt/types.js.map +1 -1
- package/dist/src/orgrt/usage-proxy.d.ts +20 -0
- package/dist/src/orgrt/usage-proxy.d.ts.map +1 -1
- package/dist/src/orgrt/usage-proxy.js +25 -15
- package/dist/src/orgrt/usage-proxy.js.map +1 -1
- package/dist/src/orgrt/vercel-providers.d.ts.map +1 -1
- package/dist/src/orgrt/vercel-providers.js +11 -1
- package/dist/src/orgrt/vercel-providers.js.map +1 -1
- package/dist/src/orgrt/vercel-runner.d.ts +1 -1
- package/dist/src/orgrt/vercel-runner.d.ts.map +1 -1
- package/dist/src/orgrt/vercel-runner.js +3 -5
- package/dist/src/orgrt/vercel-runner.js.map +1 -1
- package/dist/src/orgrt/vercel-session-store.d.ts +14 -0
- package/dist/src/orgrt/vercel-session-store.d.ts.map +1 -1
- package/dist/src/orgrt/vercel-session-store.js +3 -3
- package/dist/src/orgrt/vercel-session-store.js.map +1 -1
- package/dist/src/orgrt/visualization.js +3 -4
- package/dist/src/orgrt/visualization.js.map +1 -1
- package/dist/src/output.d.ts +1 -1
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +68 -39
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.d.ts.map +1 -1
- package/dist/src/parser.js +35 -24
- package/dist/src/parser.js.map +1 -1
- package/dist/src/pricing/model-pricing.d.ts.map +1 -1
- package/dist/src/pricing/model-pricing.js +3 -3
- package/dist/src/pricing/model-pricing.js.map +1 -1
- package/dist/src/prompt.d.ts +2 -2
- package/dist/src/prompt.d.ts.map +1 -1
- package/dist/src/prompt.js +49 -41
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/routing/embedder.d.ts.map +1 -1
- package/dist/src/routing/embedder.js +0 -0
- package/dist/src/routing/embedder.js.map +1 -1
- package/dist/src/routing/llm-caller.d.ts.map +1 -1
- package/dist/src/routing/llm-caller.js +27 -8
- package/dist/src/routing/llm-caller.js.map +1 -1
- package/dist/src/routing/model-download.d.ts.map +1 -1
- package/dist/src/routing/model-download.js +3 -3
- package/dist/src/routing/model-download.js.map +1 -1
- package/dist/src/routing/route-layer-factory.d.ts.map +1 -1
- package/dist/src/routing/route-layer-factory.js +22 -14
- package/dist/src/routing/route-layer-factory.js.map +1 -1
- package/dist/src/security/audit-log.d.ts.map +1 -1
- package/dist/src/security/audit-log.js +9 -5
- package/dist/src/security/audit-log.js.map +1 -1
- package/dist/src/services/config-file-manager.d.ts.map +1 -1
- package/dist/src/services/config-file-manager.js +40 -15
- package/dist/src/services/config-file-manager.js.map +1 -1
- package/dist/src/services/crash-reporter.d.ts.map +1 -1
- package/dist/src/services/crash-reporter.js +44 -16
- package/dist/src/services/crash-reporter.js.map +1 -1
- package/dist/src/suggest.d.ts +1 -1
- package/dist/src/suggest.d.ts.map +1 -1
- package/dist/src/suggest.js +57 -56
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/sync/checker.d.ts.map +1 -1
- package/dist/src/sync/checker.js +7 -8
- package/dist/src/sync/checker.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +2 -2
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/ui/collector.mjs +270 -150
- package/dist/src/ui/dashboard.html +731 -732
- package/dist/src/ui/data/agent-avatars.html +3 -3
- package/dist/src/ui/data/agent-avatars.json +1 -1
- package/dist/src/ui/markdown.js +243 -62
- package/dist/src/ui/mastermind-diagram-fallback.html +29 -29
- package/dist/src/ui/orgs-files.js +99 -46
- package/dist/src/ui/orgs.html +54 -54
- package/dist/src/ui/routes-monograph.mjs +918 -246
- package/dist/src/ui/routes-org.mjs +4237 -2415
- package/dist/src/ui/server.mjs +103 -94
- package/dist/src/update/checker.d.ts.map +1 -1
- package/dist/src/update/checker.js +17 -12
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.d.ts +2 -2
- package/dist/src/update/executor.d.ts.map +1 -1
- package/dist/src/update/executor.js +21 -11
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.d.ts +6 -6
- package/dist/src/update/index.d.ts.map +1 -1
- package/dist/src/update/index.js +9 -9
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.d.ts.map +1 -1
- package/dist/src/update/rate-limiter.js +11 -7
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.d.ts.map +1 -1
- package/dist/src/update/validator.js +8 -12
- package/dist/src/update/validator.js.map +1 -1
- package/dist/src/utils/cosine-similarity.d.ts.map +1 -1
- package/dist/src/utils/cosine-similarity.js.map +1 -1
- package/dist/src/utils/input-guards.d.ts +1 -1
- package/dist/src/utils/input-guards.d.ts.map +1 -1
- package/dist/src/utils/input-guards.js +24 -9
- package/dist/src/utils/input-guards.js.map +1 -1
- package/dist/src/utils/json-file.d.ts.map +1 -1
- package/dist/src/utils/json-file.js +3 -3
- package/dist/src/utils/json-file.js.map +1 -1
- package/dist/src/utils/parse-jsonl.d.ts.map +1 -1
- package/dist/src/utils/parse-jsonl.js +1 -3
- package/dist/src/utils/parse-jsonl.js.map +1 -1
- package/dist/src/utils/paths.d.ts.map +1 -1
- package/dist/src/utils/paths.js +2 -2
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/redaction.d.ts.map +1 -1
- package/dist/src/utils/redaction.js +1 -1
- package/dist/src/utils/redaction.js.map +1 -1
- package/dist/src/utils/resource-governor.d.ts.map +1 -1
- package/dist/src/utils/resource-governor.js +38 -14
- package/dist/src/utils/resource-governor.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
3
|
|
|
4
4
|
const _MAX_BUILD_DOCS_STATE = 500;
|
|
5
5
|
|
|
@@ -17,61 +17,130 @@ export async function handleMonographRoutes(req, res, url, corsOrigin, ctx) {
|
|
|
17
17
|
let html;
|
|
18
18
|
try {
|
|
19
19
|
// Try better-sqlite3 first (fast, in-process)
|
|
20
|
-
const { openDb, closeDb } = await import(
|
|
21
|
-
|
|
20
|
+
const { openDb, closeDb } = await import(
|
|
21
|
+
new URL('../../../../monograph/dist/src/storage/db.js', import.meta.url).href
|
|
22
|
+
);
|
|
23
|
+
const { toHtml } = await import(
|
|
24
|
+
new URL('../../../../monograph/dist/src/export/html.js', import.meta.url).href
|
|
25
|
+
);
|
|
22
26
|
const db = openDb(dbPath);
|
|
23
27
|
try {
|
|
24
28
|
const rawNodes = db.prepare('SELECT * FROM nodes LIMIT 5000').all();
|
|
25
29
|
const rawEdges = db.prepare('SELECT * FROM edges').all();
|
|
26
|
-
const parsedNodes = rawNodes.map(n => ({
|
|
27
|
-
id: n.id,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
const parsedNodes = rawNodes.map((n) => ({
|
|
31
|
+
id: n.id,
|
|
32
|
+
label: n.label,
|
|
33
|
+
name: n.name,
|
|
34
|
+
normLabel: n.norm_label,
|
|
35
|
+
filePath: n.file_path,
|
|
36
|
+
startLine: n.start_line,
|
|
37
|
+
endLine: n.end_line,
|
|
38
|
+
communityId: n.community_id,
|
|
39
|
+
isExported: !!n.is_exported,
|
|
40
|
+
language: n.language,
|
|
41
|
+
properties: n.properties ? JSON.parse(n.properties) : {},
|
|
31
42
|
}));
|
|
32
|
-
const parsedEdges = rawEdges.map(e => ({
|
|
33
|
-
id: e.id,
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
const parsedEdges = rawEdges.map((e) => ({
|
|
44
|
+
id: e.id,
|
|
45
|
+
sourceId: e.source_id,
|
|
46
|
+
targetId: e.target_id,
|
|
47
|
+
relation: e.relation,
|
|
48
|
+
confidence: e.confidence,
|
|
49
|
+
confidenceScore: e.confidence_score,
|
|
50
|
+
weight: e.weight,
|
|
36
51
|
}));
|
|
37
52
|
html = toHtml(parsedNodes, parsedEdges);
|
|
38
|
-
} finally {
|
|
53
|
+
} finally {
|
|
54
|
+
closeDb(db);
|
|
55
|
+
}
|
|
39
56
|
} catch {
|
|
40
57
|
// Fallback: sqlite3 CLI + inline Sigma.js graph
|
|
41
|
-
const { execFileSync } = await import('child_process');
|
|
58
|
+
const { execFileSync } = await import('node:child_process');
|
|
42
59
|
const runSql = (sql) => {
|
|
43
|
-
try {
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(
|
|
62
|
+
execFileSync('sqlite3', ['-json', dbPath], {
|
|
63
|
+
encoding: 'utf-8',
|
|
64
|
+
timeout: 15000,
|
|
65
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
66
|
+
input: `${sql};`,
|
|
67
|
+
}) || '[]',
|
|
68
|
+
);
|
|
69
|
+
} catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
44
72
|
};
|
|
45
|
-
const rawNodes = runSql(
|
|
73
|
+
const rawNodes = runSql(
|
|
74
|
+
'SELECT id, name, label, file_path, community_id FROM nodes LIMIT 2000',
|
|
75
|
+
);
|
|
46
76
|
const rawEdges = runSql('SELECT source_id, target_id, relation FROM edges');
|
|
47
77
|
const degree = new Map();
|
|
48
78
|
for (const n of rawNodes) degree.set(n.id, 0);
|
|
49
79
|
for (const e of rawEdges) {
|
|
50
|
-
if (degree.has(e.source_id))
|
|
51
|
-
|
|
80
|
+
if (degree.has(e.source_id))
|
|
81
|
+
degree.set(e.source_id, (degree.get(e.source_id) || 0) + 1);
|
|
82
|
+
if (degree.has(e.target_id))
|
|
83
|
+
degree.set(e.target_id, (degree.get(e.target_id) || 0) + 1);
|
|
52
84
|
}
|
|
53
|
-
const topNodes = [...rawNodes]
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
85
|
+
const topNodes = [...rawNodes]
|
|
86
|
+
.sort((a, b) => (degree.get(b.id) || 0) - (degree.get(a.id) || 0))
|
|
87
|
+
.slice(0, 500);
|
|
88
|
+
const topIds = new Set(topNodes.map((n) => n.id));
|
|
89
|
+
const filteredEdges = rawEdges
|
|
90
|
+
.filter((e) => topIds.has(e.source_id) && topIds.has(e.target_id))
|
|
91
|
+
.slice(0, 2000);
|
|
92
|
+
const colors = [
|
|
93
|
+
'#4E79A7',
|
|
94
|
+
'#F28E2B',
|
|
95
|
+
'#E15759',
|
|
96
|
+
'#76B7B2',
|
|
97
|
+
'#59A14F',
|
|
98
|
+
'#EDC948',
|
|
99
|
+
'#B07AA1',
|
|
100
|
+
'#FF9DA7',
|
|
101
|
+
'#9C755F',
|
|
102
|
+
'#BAB0AC',
|
|
103
|
+
];
|
|
104
|
+
const nodesJson = JSON.stringify(
|
|
105
|
+
topNodes.map((n, i) => {
|
|
106
|
+
const d = degree.get(n.id) || 1;
|
|
107
|
+
const c =
|
|
108
|
+
n.community_id != null
|
|
109
|
+
? colors[n.community_id % colors.length]
|
|
110
|
+
: colors[i % colors.length];
|
|
111
|
+
return {
|
|
112
|
+
id: n.id,
|
|
113
|
+
label: n.name || n.id,
|
|
114
|
+
x: Math.cos(i * 0.618 * Math.PI * 2) * 300 + Math.random() * 50,
|
|
115
|
+
y: Math.sin(i * 0.618 * Math.PI * 2) * 300 + Math.random() * 50,
|
|
116
|
+
size: Math.min(3 + Math.sqrt(d) * 2, 20),
|
|
117
|
+
color: c,
|
|
118
|
+
};
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
const edgesJson = JSON.stringify(
|
|
122
|
+
filteredEdges.map((e, i) => ({
|
|
123
|
+
id: `e${i}`,
|
|
124
|
+
source: e.source_id,
|
|
125
|
+
target: e.target_id,
|
|
126
|
+
})),
|
|
127
|
+
);
|
|
63
128
|
html = `<!DOCTYPE html><html><head><meta charset="utf-8"><title>Monograph</title>
|
|
64
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/sigma.js/2.4.0/sigma.min.js"
|
|
65
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/graphology/0.25.4/graphology.umd.min.js"
|
|
129
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/sigma.js/2.4.0/sigma.min.js"></script>
|
|
130
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/graphology/0.25.4/graphology.umd.min.js"></script>
|
|
66
131
|
<style>*{margin:0;padding:0}body{background:#0f0f1a;overflow:hidden}#g{width:100vw;height:100vh}</style></head>
|
|
67
132
|
<body><div id="g"></div><script>
|
|
68
133
|
const g=new graphology.Graph();
|
|
69
134
|
${nodesJson}.forEach(n=>g.addNode(n.id,{label:n.label,x:n.x,y:n.y,size:n.size,color:n.color}));
|
|
70
135
|
${edgesJson}.forEach(e=>{try{g.addEdge(e.source,e.target,{size:0.5,color:'#333'})}catch{}});
|
|
71
136
|
new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{color:'#ccc'},labelSize:10});
|
|
72
|
-
|
|
137
|
+
</script></body></html>`;
|
|
73
138
|
}
|
|
74
|
-
res.writeHead(200, {
|
|
139
|
+
res.writeHead(200, {
|
|
140
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
141
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
142
|
+
'Cache-Control': 'no-cache',
|
|
143
|
+
});
|
|
75
144
|
res.end(html);
|
|
76
145
|
return true;
|
|
77
146
|
}
|
|
@@ -79,11 +148,17 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
79
148
|
// Fallback: try legacy graph.html on disk
|
|
80
149
|
const htmlPath = path.join(d, '.monomind', 'graph', 'graph.html');
|
|
81
150
|
const html = fs.readFileSync(htmlPath, 'utf-8');
|
|
82
|
-
res.writeHead(200, {
|
|
151
|
+
res.writeHead(200, {
|
|
152
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
153
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
154
|
+
'Cache-Control': 'no-cache',
|
|
155
|
+
});
|
|
83
156
|
res.end(html);
|
|
84
|
-
} catch (
|
|
157
|
+
} catch (_err) {
|
|
85
158
|
res.writeHead(404, { 'Content-Type': 'text/html' });
|
|
86
|
-
res.end(
|
|
159
|
+
res.end(
|
|
160
|
+
'<html><body style="background:#0f0f1a;color:#888;font-family:monospace;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;"><div style="text-align:center;"><h3 style="color:#4E79A7;">No Graph Built Yet</h3><p>Run <code style="color:#00E5C8;">mcp__monomind__monograph_build</code> or click BUILD in the sidebar.</p></div></body></html>',
|
|
161
|
+
);
|
|
87
162
|
}
|
|
88
163
|
return true;
|
|
89
164
|
}
|
|
@@ -95,16 +170,28 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
95
170
|
const dir = qs.get('dir') || ctx.projectDir || process.cwd();
|
|
96
171
|
const d = path.resolve(dir || process.cwd());
|
|
97
172
|
const dbPath = path.join(d, '.monomind', 'monograph.db');
|
|
98
|
-
let report = null,
|
|
173
|
+
let report = null,
|
|
174
|
+
exists = false,
|
|
175
|
+
stats = null;
|
|
99
176
|
if (fs.existsSync(dbPath)) {
|
|
100
177
|
exists = true;
|
|
101
|
-
const { openDb, closeDb } = await import(
|
|
178
|
+
const { openDb, closeDb } = await import(
|
|
179
|
+
new URL('../../../../monograph/dist/src/storage/db.js', import.meta.url).href
|
|
180
|
+
);
|
|
102
181
|
const db = openDb(dbPath);
|
|
103
182
|
try {
|
|
104
183
|
const nodeCount = db.prepare('SELECT COUNT(*) AS c FROM nodes').get().c;
|
|
105
184
|
const edgeCount = db.prepare('SELECT COUNT(*) AS c FROM edges').get().c;
|
|
106
|
-
const topNodes = db
|
|
107
|
-
|
|
185
|
+
const topNodes = db
|
|
186
|
+
.prepare(
|
|
187
|
+
`SELECT n.id, n.name, n.label, (SELECT COUNT(*) FROM edges e WHERE e.source_id=n.id OR e.target_id=n.id) AS deg FROM nodes n ORDER BY deg DESC LIMIT 20`,
|
|
188
|
+
)
|
|
189
|
+
.all();
|
|
190
|
+
const labelDist = db
|
|
191
|
+
.prepare(
|
|
192
|
+
'SELECT label, COUNT(*) AS cnt FROM nodes GROUP BY label ORDER BY cnt DESC LIMIT 10',
|
|
193
|
+
)
|
|
194
|
+
.all();
|
|
108
195
|
const dbStat = fs.statSync(dbPath);
|
|
109
196
|
stats = { nodes: nodeCount, edges: edgeCount, size: dbStat.size, mtime: dbStat.mtimeMs };
|
|
110
197
|
report = [
|
|
@@ -116,14 +203,23 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
116
203
|
`- **Last built**: ${new Date(dbStat.mtimeMs).toLocaleString()}`,
|
|
117
204
|
'',
|
|
118
205
|
'## Top 20 Nodes by Degree',
|
|
119
|
-
...topNodes.map(
|
|
206
|
+
...topNodes.map(
|
|
207
|
+
(n, i) =>
|
|
208
|
+
`${String(i + 1).padStart(3, ' ')}. **${n.name || n.id}** \`${n.label}\` — ${n.deg} connections`,
|
|
209
|
+
),
|
|
120
210
|
'',
|
|
121
211
|
'## Node Type Distribution',
|
|
122
|
-
...labelDist.map(r => `- **${r.label}**: ${r.cnt}`),
|
|
212
|
+
...labelDist.map((r) => `- **${r.label}**: ${r.cnt}`),
|
|
123
213
|
].join('\n');
|
|
124
|
-
} finally {
|
|
214
|
+
} finally {
|
|
215
|
+
closeDb(db);
|
|
216
|
+
}
|
|
125
217
|
}
|
|
126
|
-
res.writeHead(200, {
|
|
218
|
+
res.writeHead(200, {
|
|
219
|
+
'Content-Type': 'application/json',
|
|
220
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
221
|
+
'Cache-Control': 'no-cache',
|
|
222
|
+
});
|
|
127
223
|
res.end(JSON.stringify({ exists, report, stats }));
|
|
128
224
|
} catch (err) {
|
|
129
225
|
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
@@ -139,19 +235,35 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
139
235
|
const dir = qs.get('dir') || ctx.projectDir || process.cwd();
|
|
140
236
|
const d = path.resolve(dir || process.cwd());
|
|
141
237
|
const dbPath = path.join(d, '.monomind', 'monograph.db');
|
|
142
|
-
let nodes = [],
|
|
238
|
+
let nodes = [],
|
|
239
|
+
edges = [];
|
|
143
240
|
if (fs.existsSync(dbPath)) {
|
|
144
|
-
const { execFileSync } = await import('child_process');
|
|
241
|
+
const { execFileSync } = await import('node:child_process');
|
|
145
242
|
const runSql = (sql, timeout = 10000) => {
|
|
146
243
|
try {
|
|
147
|
-
return JSON.parse(
|
|
148
|
-
|
|
149
|
-
|
|
244
|
+
return JSON.parse(
|
|
245
|
+
execFileSync('sqlite3', ['-json', dbPath], {
|
|
246
|
+
encoding: 'utf-8',
|
|
247
|
+
timeout,
|
|
248
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
249
|
+
input: `${sql};`,
|
|
250
|
+
}) || '[]',
|
|
251
|
+
);
|
|
252
|
+
} catch {
|
|
253
|
+
return [];
|
|
254
|
+
}
|
|
150
255
|
};
|
|
151
256
|
const nodeLimit = Math.min(parseInt(qs.get('limit') || '500', 10), 5000);
|
|
152
|
-
const labelFilter = qs.get('labels')
|
|
257
|
+
const labelFilter = qs.get('labels')
|
|
258
|
+
? qs
|
|
259
|
+
.get('labels')
|
|
260
|
+
.split(',')
|
|
261
|
+
.map((s) => s.trim())
|
|
262
|
+
: null;
|
|
153
263
|
const rawNodes = labelFilter
|
|
154
|
-
? runSql(
|
|
264
|
+
? runSql(
|
|
265
|
+
`SELECT id, name, label, file_path, community_id FROM nodes WHERE label IN (${labelFilter.map((l) => `'${l.replace(/'/g, "''")}'`).join(',')}) LIMIT 5000`,
|
|
266
|
+
)
|
|
155
267
|
: runSql(`SELECT id, name, label, file_path, community_id FROM nodes LIMIT 5000`);
|
|
156
268
|
const rawEdges = runSql('SELECT source_id, target_id, relation FROM edges');
|
|
157
269
|
const degree = new Map();
|
|
@@ -162,15 +274,34 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
162
274
|
}
|
|
163
275
|
const topNodes = labelFilter
|
|
164
276
|
? rawNodes
|
|
165
|
-
: [...rawNodes]
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
277
|
+
: [...rawNodes]
|
|
278
|
+
.sort((a, b) => (degree.get(b.id) || 0) - (degree.get(a.id) || 0))
|
|
279
|
+
.slice(0, nodeLimit);
|
|
280
|
+
const topIds = new Set(topNodes.map((n) => n.id));
|
|
281
|
+
nodes = topNodes.map((n) => ({
|
|
282
|
+
id: n.id,
|
|
283
|
+
label: n.name || n.id,
|
|
284
|
+
type: n.label || 'unknown',
|
|
285
|
+
degree: degree.get(n.id) || 0,
|
|
286
|
+
}));
|
|
287
|
+
edges = rawEdges
|
|
288
|
+
.filter((e) => topIds.has(e.source_id) && topIds.has(e.target_id))
|
|
289
|
+
.slice(0, 2000)
|
|
290
|
+
.map((e) => ({
|
|
291
|
+
source: e.source_id,
|
|
292
|
+
target: e.target_id,
|
|
293
|
+
relation: e.relation || 'REF',
|
|
294
|
+
}));
|
|
169
295
|
}
|
|
170
|
-
res.writeHead(200, {
|
|
296
|
+
res.writeHead(200, {
|
|
297
|
+
'Content-Type': 'application/json',
|
|
298
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
299
|
+
'Cache-Control': 'no-cache',
|
|
300
|
+
});
|
|
171
301
|
res.end(JSON.stringify({ nodes, edges }));
|
|
172
302
|
} catch (err) {
|
|
173
|
-
res.writeHead(500);
|
|
303
|
+
res.writeHead(500);
|
|
304
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
174
305
|
}
|
|
175
306
|
return true;
|
|
176
307
|
}
|
|
@@ -192,24 +323,41 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
192
323
|
path.join(d, '.ua', 'knowledge-graph.json'),
|
|
193
324
|
path.join(d, '.ua', 'graph.json'),
|
|
194
325
|
];
|
|
195
|
-
const uaGraph = uaGraphCandidates.find(p => fs.existsSync(p));
|
|
326
|
+
const uaGraph = uaGraphCandidates.find((p) => fs.existsSync(p));
|
|
196
327
|
const importScript = path.join(process.cwd(), 'scripts', 'ua-import.mjs');
|
|
197
328
|
const enrichScript = path.join(process.cwd(), 'scripts', 'ua-enrich.mjs');
|
|
198
329
|
|
|
199
|
-
res.writeHead(202, {
|
|
330
|
+
res.writeHead(202, {
|
|
331
|
+
'Content-Type': 'application/json',
|
|
332
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
333
|
+
});
|
|
200
334
|
|
|
201
335
|
if (uaGraph && fs.existsSync(importScript)) {
|
|
202
336
|
res.end(JSON.stringify({ status: 'importing', source: uaGraph }));
|
|
203
|
-
const { spawn: sp } = await import('child_process');
|
|
204
|
-
const child = sp(process.execPath, [importScript, uaGraph, dbFilePath], {
|
|
337
|
+
const { spawn: sp } = await import('node:child_process');
|
|
338
|
+
const child = sp(process.execPath, [importScript, uaGraph, dbFilePath], {
|
|
339
|
+
stdio: 'ignore',
|
|
340
|
+
detached: true,
|
|
341
|
+
cwd: d,
|
|
342
|
+
});
|
|
205
343
|
child.unref();
|
|
206
344
|
} else if (fs.existsSync(enrichScript)) {
|
|
207
345
|
res.end(JSON.stringify({ status: 'enriching', mode: 'structural-only' }));
|
|
208
|
-
const { spawn: sp } = await import('child_process');
|
|
209
|
-
const child = sp(
|
|
346
|
+
const { spawn: sp } = await import('node:child_process');
|
|
347
|
+
const child = sp(
|
|
348
|
+
process.execPath,
|
|
349
|
+
[enrichScript, '--dir', d, '--db', dbFilePath, '--full'],
|
|
350
|
+
{ stdio: 'ignore', detached: true, cwd: d },
|
|
351
|
+
);
|
|
210
352
|
child.unref();
|
|
211
353
|
} else {
|
|
212
|
-
res.end(
|
|
354
|
+
res.end(
|
|
355
|
+
JSON.stringify({
|
|
356
|
+
status: 'skipped',
|
|
357
|
+
reason:
|
|
358
|
+
'No understand graph.json found. Run /monomind:understand in Claude Code first.',
|
|
359
|
+
}),
|
|
360
|
+
);
|
|
213
361
|
}
|
|
214
362
|
} catch (err) {
|
|
215
363
|
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
@@ -232,18 +380,28 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
232
380
|
// would achieve RCE. (See P0-6.)
|
|
233
381
|
const _serverRoot = path.resolve(ctx.projectDir || process.cwd());
|
|
234
382
|
if (d !== _serverRoot) {
|
|
235
|
-
res.writeHead(400, {
|
|
383
|
+
res.writeHead(400, {
|
|
384
|
+
'Content-Type': 'application/json',
|
|
385
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
386
|
+
});
|
|
236
387
|
res.end(JSON.stringify({ error: 'monograph-build only supports the server project root' }));
|
|
237
388
|
return true;
|
|
238
389
|
}
|
|
239
390
|
|
|
240
|
-
res.writeHead(202, {
|
|
391
|
+
res.writeHead(202, {
|
|
392
|
+
'Content-Type': 'application/json',
|
|
393
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
394
|
+
});
|
|
241
395
|
res.end(JSON.stringify({ status: 'building', dir: d }));
|
|
242
396
|
|
|
243
397
|
// Build via monograph in background
|
|
244
|
-
const { spawn: sp } = await import('child_process');
|
|
398
|
+
const { spawn: sp } = await import('node:child_process');
|
|
245
399
|
const script = `import { buildAsync } from '@monoes/monograph'; await buildAsync(${JSON.stringify(d)});`;
|
|
246
|
-
const child = sp(process.execPath, ['--input-type=module', '--eval', script], {
|
|
400
|
+
const child = sp(process.execPath, ['--input-type=module', '--eval', script], {
|
|
401
|
+
stdio: 'ignore',
|
|
402
|
+
detached: true,
|
|
403
|
+
cwd: d,
|
|
404
|
+
});
|
|
247
405
|
child.unref();
|
|
248
406
|
console.log(`[graph] build started for ${d} via monograph`);
|
|
249
407
|
} catch (err) {
|
|
@@ -258,7 +416,10 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
258
416
|
const qs2 = new URL(req.url, 'http://localhost').searchParams;
|
|
259
417
|
const d2 = path.resolve(qs2.get('dir') || ctx.projectDir || process.cwd());
|
|
260
418
|
const state = ctx.buildDocsState.get(d2) || { status: 'idle' };
|
|
261
|
-
res.writeHead(200, {
|
|
419
|
+
res.writeHead(200, {
|
|
420
|
+
'Content-Type': 'application/json',
|
|
421
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
422
|
+
});
|
|
262
423
|
res.end(JSON.stringify(state));
|
|
263
424
|
return true;
|
|
264
425
|
}
|
|
@@ -271,7 +432,10 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
271
432
|
const d = path.resolve(dir || process.cwd());
|
|
272
433
|
const dbPath = path.join(d, '.monomind', 'monograph.db');
|
|
273
434
|
if (!fs.existsSync(dbPath)) {
|
|
274
|
-
res.writeHead(400, {
|
|
435
|
+
res.writeHead(400, {
|
|
436
|
+
'Content-Type': 'application/json',
|
|
437
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
438
|
+
});
|
|
275
439
|
res.end(JSON.stringify({ error: 'monograph.db not found — run BUILD GRAPH first' }));
|
|
276
440
|
return true;
|
|
277
441
|
}
|
|
@@ -279,7 +443,10 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
279
443
|
// Reject if already running
|
|
280
444
|
const existing = ctx.buildDocsState.get(d);
|
|
281
445
|
if (existing && existing.status === 'pending') {
|
|
282
|
-
res.writeHead(200, {
|
|
446
|
+
res.writeHead(200, {
|
|
447
|
+
'Content-Type': 'application/json',
|
|
448
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
449
|
+
});
|
|
283
450
|
res.end(JSON.stringify({ status: 'pending', message: 'Build already in progress' }));
|
|
284
451
|
return true;
|
|
285
452
|
}
|
|
@@ -289,53 +456,114 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
289
456
|
const oldest = ctx.buildDocsState.keys().next().value;
|
|
290
457
|
ctx.buildDocsState.delete(oldest);
|
|
291
458
|
}
|
|
292
|
-
ctx.buildDocsState.set(d, {
|
|
293
|
-
|
|
459
|
+
ctx.buildDocsState.set(d, {
|
|
460
|
+
status: 'pending',
|
|
461
|
+
sections: 0,
|
|
462
|
+
files: 0,
|
|
463
|
+
error: null,
|
|
464
|
+
startedAt,
|
|
465
|
+
});
|
|
466
|
+
res.writeHead(202, {
|
|
467
|
+
'Content-Type': 'application/json',
|
|
468
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
469
|
+
});
|
|
294
470
|
res.end(JSON.stringify({ status: 'pending', dir: d }));
|
|
295
471
|
|
|
296
472
|
// Run doc parsing in background
|
|
297
473
|
(async () => {
|
|
298
|
-
const { openDb, closeDb } = await import(
|
|
299
|
-
|
|
474
|
+
const { openDb, closeDb } = await import(
|
|
475
|
+
new URL('../../../../monograph/dist/src/storage/db.js', import.meta.url).href
|
|
476
|
+
);
|
|
477
|
+
const { isFileCached, updateFileCache, hashFileContent } = await import(
|
|
478
|
+
new URL('../../../../monograph/dist/src/storage/file-cache.js', import.meta.url).href
|
|
479
|
+
);
|
|
300
480
|
const { readFileSync, readdirSync, statSync } = fs;
|
|
301
481
|
|
|
302
482
|
const docExts = new Set(['.md', '.mdx', '.txt', '.rst']);
|
|
303
|
-
const ignoreDirs = new Set([
|
|
483
|
+
const ignoreDirs = new Set([
|
|
484
|
+
'node_modules',
|
|
485
|
+
'.git',
|
|
486
|
+
'dist',
|
|
487
|
+
'build',
|
|
488
|
+
'.next',
|
|
489
|
+
'.nuxt',
|
|
490
|
+
'coverage',
|
|
491
|
+
'.monomind',
|
|
492
|
+
'__pycache__',
|
|
493
|
+
'vendor',
|
|
494
|
+
]);
|
|
304
495
|
const docFiles = [];
|
|
305
496
|
function walk(dir2, depth = 0) {
|
|
306
497
|
if (depth > 12) return;
|
|
307
498
|
let entries;
|
|
308
|
-
try {
|
|
499
|
+
try {
|
|
500
|
+
entries = readdirSync(dir2);
|
|
501
|
+
} catch {
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
309
504
|
for (const e of entries) {
|
|
310
505
|
if (ignoreDirs.has(e) || e.startsWith('.')) continue;
|
|
311
506
|
const full = path.join(dir2, e);
|
|
312
507
|
let st;
|
|
313
|
-
try {
|
|
314
|
-
|
|
315
|
-
|
|
508
|
+
try {
|
|
509
|
+
st = statSync(full);
|
|
510
|
+
} catch {
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
if (st.isDirectory()) {
|
|
514
|
+
walk(full, depth + 1);
|
|
515
|
+
} else if (docExts.has(path.extname(e).toLowerCase()) && st.size < 600000)
|
|
516
|
+
docFiles.push(full);
|
|
316
517
|
}
|
|
317
518
|
}
|
|
318
519
|
walk(d);
|
|
319
520
|
|
|
320
521
|
const db = openDb(dbPath);
|
|
321
522
|
try {
|
|
322
|
-
const insertNode = db.prepare(
|
|
323
|
-
|
|
523
|
+
const insertNode = db.prepare(
|
|
524
|
+
`INSERT OR REPLACE INTO nodes (id, label, name, norm_label, file_path, start_line, end_line, language, is_exported) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0)`,
|
|
525
|
+
);
|
|
526
|
+
const insertEdge = db.prepare(
|
|
527
|
+
`INSERT OR IGNORE INTO edges (id, source_id, target_id, relation, confidence, confidence_score, weight) VALUES (?, ?, ?, ?, 'EXTRACTED', 1.0, 1.0)`,
|
|
528
|
+
);
|
|
324
529
|
|
|
325
530
|
const insertAll = db.transaction((nodes, edges) => {
|
|
326
531
|
for (const n of nodes) {
|
|
327
|
-
try {
|
|
532
|
+
try {
|
|
533
|
+
insertNode.run(
|
|
534
|
+
n.id,
|
|
535
|
+
n.label,
|
|
536
|
+
n.name,
|
|
537
|
+
n.norm_label,
|
|
538
|
+
n.file_path,
|
|
539
|
+
n.start_line,
|
|
540
|
+
n.end_line,
|
|
541
|
+
n.language,
|
|
542
|
+
);
|
|
543
|
+
} catch {}
|
|
544
|
+
}
|
|
545
|
+
for (const e of edges) {
|
|
546
|
+
try {
|
|
547
|
+
insertEdge.run(e.id, e.src, e.dst, e.rel);
|
|
548
|
+
} catch {}
|
|
328
549
|
}
|
|
329
|
-
for (const e of edges) { try { insertEdge.run(e.id, e.src, e.dst, e.rel); } catch {} }
|
|
330
550
|
});
|
|
331
551
|
|
|
332
|
-
const normTitle = t =>
|
|
552
|
+
const normTitle = (t) =>
|
|
553
|
+
t
|
|
554
|
+
.toLowerCase()
|
|
555
|
+
.replace(/[^a-z0-9]+/g, '_')
|
|
556
|
+
.replace(/^_|_$/g, '');
|
|
333
557
|
|
|
334
558
|
let totalSections = 0;
|
|
335
559
|
let skipped = 0;
|
|
336
560
|
for (const filePath of docFiles) {
|
|
337
561
|
let content;
|
|
338
|
-
try {
|
|
562
|
+
try {
|
|
563
|
+
content = readFileSync(filePath, 'utf-8');
|
|
564
|
+
} catch {
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
339
567
|
|
|
340
568
|
// Skip unchanged files using file cache
|
|
341
569
|
let isCached = false;
|
|
@@ -344,13 +572,27 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
344
572
|
contentHash = hashFileContent(content);
|
|
345
573
|
isCached = isFileCached(db, filePath, contentHash);
|
|
346
574
|
} catch {}
|
|
347
|
-
if (isCached) {
|
|
575
|
+
if (isCached) {
|
|
576
|
+
skipped++;
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
348
579
|
const relPath = path.relative(d, filePath);
|
|
349
580
|
const ext = path.extname(filePath).slice(1).toLowerCase();
|
|
350
|
-
const fileId =
|
|
581
|
+
const fileId = `doc:${relPath}`;
|
|
351
582
|
const lineCount = content.split('\n').length;
|
|
352
583
|
|
|
353
|
-
const nodes = [
|
|
584
|
+
const nodes = [
|
|
585
|
+
{
|
|
586
|
+
id: fileId,
|
|
587
|
+
label: 'File',
|
|
588
|
+
name: relPath,
|
|
589
|
+
norm_label: normTitle(relPath),
|
|
590
|
+
file_path: relPath,
|
|
591
|
+
start_line: 1,
|
|
592
|
+
end_line: lineCount,
|
|
593
|
+
language: ext,
|
|
594
|
+
},
|
|
595
|
+
];
|
|
354
596
|
const edges = [];
|
|
355
597
|
const lines = content.split('\n');
|
|
356
598
|
const sectionStack = [{ id: fileId, depth: 0 }];
|
|
@@ -367,14 +609,31 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
367
609
|
inCodeBlock = true;
|
|
368
610
|
codeBlockLang = fenceMatch[1].trim() || null;
|
|
369
611
|
if (codeBlockLang) {
|
|
370
|
-
const cId =
|
|
371
|
-
if (!nodes.find(n => n.id === cId)) {
|
|
372
|
-
nodes.push({
|
|
612
|
+
const cId = `concept:lang:${codeBlockLang.toLowerCase()}`;
|
|
613
|
+
if (!nodes.find((n) => n.id === cId)) {
|
|
614
|
+
nodes.push({
|
|
615
|
+
id: cId,
|
|
616
|
+
label: 'Concept',
|
|
617
|
+
name: codeBlockLang,
|
|
618
|
+
norm_label: normTitle(codeBlockLang),
|
|
619
|
+
file_path: null,
|
|
620
|
+
start_line: 0,
|
|
621
|
+
end_line: 0,
|
|
622
|
+
language: null,
|
|
623
|
+
});
|
|
373
624
|
}
|
|
374
625
|
const curSec = sectionStack[sectionStack.length - 1].id;
|
|
375
|
-
edges.push({
|
|
626
|
+
edges.push({
|
|
627
|
+
id: `e:${curSec}:${cId}:code`,
|
|
628
|
+
src: curSec,
|
|
629
|
+
dst: cId,
|
|
630
|
+
rel: 'TAGGED_AS',
|
|
631
|
+
});
|
|
376
632
|
}
|
|
377
|
-
} else {
|
|
633
|
+
} else {
|
|
634
|
+
inCodeBlock = false;
|
|
635
|
+
codeBlockLang = null;
|
|
636
|
+
}
|
|
378
637
|
continue;
|
|
379
638
|
}
|
|
380
639
|
if (inCodeBlock) continue;
|
|
@@ -383,29 +642,73 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
383
642
|
const hMatch = line.match(/^(#{1,6})\s+(.+)/);
|
|
384
643
|
if (hMatch) {
|
|
385
644
|
const depth = hMatch[1].length;
|
|
386
|
-
const title = hMatch[2]
|
|
387
|
-
|
|
388
|
-
|
|
645
|
+
const title = hMatch[2]
|
|
646
|
+
.trim()
|
|
647
|
+
.replace(/\s+#+\s*$/, '')
|
|
648
|
+
.trim();
|
|
649
|
+
const secId = `sec:${relPath}:${i + 1}`;
|
|
650
|
+
nodes.push({
|
|
651
|
+
id: secId,
|
|
652
|
+
label: 'Section',
|
|
653
|
+
name: title,
|
|
654
|
+
norm_label: normTitle(title),
|
|
655
|
+
file_path: relPath,
|
|
656
|
+
start_line: i + 1,
|
|
657
|
+
end_line: i + 1,
|
|
658
|
+
language: ext,
|
|
659
|
+
});
|
|
389
660
|
totalSections++;
|
|
390
|
-
while (
|
|
661
|
+
while (
|
|
662
|
+
sectionStack.length > 1 &&
|
|
663
|
+
sectionStack[sectionStack.length - 1].depth >= depth
|
|
664
|
+
)
|
|
665
|
+
sectionStack.pop();
|
|
391
666
|
const parentId = sectionStack[sectionStack.length - 1].id;
|
|
392
|
-
edges.push({
|
|
667
|
+
edges.push({
|
|
668
|
+
id: `e:${secId}:${parentId}:parent`,
|
|
669
|
+
src: parentId,
|
|
670
|
+
dst: secId,
|
|
671
|
+
rel: 'DEFINES',
|
|
672
|
+
});
|
|
393
673
|
sectionStack.push({ id: secId, depth });
|
|
394
674
|
continue;
|
|
395
675
|
}
|
|
396
676
|
|
|
397
677
|
// RST-style headings: line followed by ===, ---, ~~~, ^^^, etc.
|
|
398
|
-
if (
|
|
678
|
+
if (
|
|
679
|
+
i + 1 < lines.length &&
|
|
680
|
+
lines[i + 1].match(/^[=\-~^"'`#*+!]{3,}\s*$/) &&
|
|
681
|
+
line.trim().length > 0 &&
|
|
682
|
+
line.trim().length <= lines[i + 1].trim().length + 2
|
|
683
|
+
) {
|
|
399
684
|
const underlineChar = lines[i + 1].trim()[0];
|
|
400
685
|
const rstDepth = '=-~^"\'`#*+!'.indexOf(underlineChar) + 1 || 3;
|
|
401
686
|
const title = line.trim();
|
|
402
|
-
const secId =
|
|
403
|
-
nodes.push({
|
|
687
|
+
const secId = `sec:${relPath}:${i + 1}`;
|
|
688
|
+
nodes.push({
|
|
689
|
+
id: secId,
|
|
690
|
+
label: 'Section',
|
|
691
|
+
name: title,
|
|
692
|
+
norm_label: normTitle(title),
|
|
693
|
+
file_path: relPath,
|
|
694
|
+
start_line: i + 1,
|
|
695
|
+
end_line: i + 1,
|
|
696
|
+
language: ext,
|
|
697
|
+
});
|
|
404
698
|
totalSections++;
|
|
405
699
|
const depth = Math.min(6, Math.ceil(rstDepth / 2));
|
|
406
|
-
while (
|
|
700
|
+
while (
|
|
701
|
+
sectionStack.length > 1 &&
|
|
702
|
+
sectionStack[sectionStack.length - 1].depth >= depth
|
|
703
|
+
)
|
|
704
|
+
sectionStack.pop();
|
|
407
705
|
const parentId = sectionStack[sectionStack.length - 1].id;
|
|
408
|
-
edges.push({
|
|
706
|
+
edges.push({
|
|
707
|
+
id: `e:${secId}:${parentId}:parent`,
|
|
708
|
+
src: parentId,
|
|
709
|
+
dst: secId,
|
|
710
|
+
rel: 'DEFINES',
|
|
711
|
+
});
|
|
409
712
|
sectionStack.push({ id: secId, depth });
|
|
410
713
|
i++; // skip underline line
|
|
411
714
|
continue;
|
|
@@ -416,12 +719,26 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
416
719
|
if (tags) {
|
|
417
720
|
for (const tag of tags) {
|
|
418
721
|
const concept = tag.slice(1);
|
|
419
|
-
const cId =
|
|
420
|
-
if (!nodes.find(n => n.id === cId)) {
|
|
421
|
-
nodes.push({
|
|
722
|
+
const cId = `concept:tag:${concept.toLowerCase()}`;
|
|
723
|
+
if (!nodes.find((n) => n.id === cId)) {
|
|
724
|
+
nodes.push({
|
|
725
|
+
id: cId,
|
|
726
|
+
label: 'Concept',
|
|
727
|
+
name: concept,
|
|
728
|
+
norm_label: normTitle(concept),
|
|
729
|
+
file_path: null,
|
|
730
|
+
start_line: 0,
|
|
731
|
+
end_line: 0,
|
|
732
|
+
language: null,
|
|
733
|
+
});
|
|
422
734
|
}
|
|
423
735
|
const curSec = sectionStack[sectionStack.length - 1].id;
|
|
424
|
-
edges.push({
|
|
736
|
+
edges.push({
|
|
737
|
+
id: `e:${curSec}:${cId}:tag`,
|
|
738
|
+
src: curSec,
|
|
739
|
+
dst: cId,
|
|
740
|
+
rel: 'TAGGED_AS',
|
|
741
|
+
});
|
|
425
742
|
}
|
|
426
743
|
}
|
|
427
744
|
}
|
|
@@ -430,16 +747,43 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
430
747
|
insertAll(nodes, edges);
|
|
431
748
|
// Update file cache so we skip unchanged files next run
|
|
432
749
|
try {
|
|
433
|
-
updateFileCache(db, {
|
|
750
|
+
updateFileCache(db, {
|
|
751
|
+
filePath,
|
|
752
|
+
contentHash,
|
|
753
|
+
lastParsed: Date.now(),
|
|
754
|
+
nodeCount: nodes.length,
|
|
755
|
+
edgeCount: edges.length,
|
|
756
|
+
});
|
|
434
757
|
} catch {}
|
|
435
|
-
} catch (e) {
|
|
758
|
+
} catch (e) {
|
|
759
|
+
console.error('[docs-build] error inserting', relPath, e.message);
|
|
760
|
+
}
|
|
436
761
|
}
|
|
437
|
-
console.log(
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
762
|
+
console.log(
|
|
763
|
+
`[docs-build] indexed ${docFiles.length - skipped} docs (${skipped} cached), ${totalSections} sections → ${dbPath}`,
|
|
764
|
+
);
|
|
765
|
+
ctx.buildDocsState.set(d, {
|
|
766
|
+
status: 'done',
|
|
767
|
+
sections: totalSections,
|
|
768
|
+
files: docFiles.length - skipped,
|
|
769
|
+
cached: skipped,
|
|
770
|
+
error: null,
|
|
771
|
+
startedAt,
|
|
772
|
+
completedAt: Date.now(),
|
|
773
|
+
});
|
|
774
|
+
} finally {
|
|
775
|
+
closeDb(db);
|
|
776
|
+
}
|
|
777
|
+
})().catch((e) => {
|
|
441
778
|
console.error('[docs-build] fatal:', e.message);
|
|
442
|
-
ctx.buildDocsState.set(d, {
|
|
779
|
+
ctx.buildDocsState.set(d, {
|
|
780
|
+
status: 'error',
|
|
781
|
+
sections: 0,
|
|
782
|
+
files: 0,
|
|
783
|
+
error: e.message,
|
|
784
|
+
startedAt,
|
|
785
|
+
completedAt: Date.now(),
|
|
786
|
+
});
|
|
443
787
|
});
|
|
444
788
|
} catch (err) {
|
|
445
789
|
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
@@ -457,14 +801,34 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
457
801
|
const id = qs.get('id') || '';
|
|
458
802
|
const d = path.resolve(dir || process.cwd());
|
|
459
803
|
const dbPath = path.join(d, '.monomind', 'monograph.db');
|
|
460
|
-
if (!id) {
|
|
461
|
-
|
|
462
|
-
|
|
804
|
+
if (!id) {
|
|
805
|
+
res.writeHead(400);
|
|
806
|
+
res.end(JSON.stringify({ error: 'Missing ?id=' }));
|
|
807
|
+
return true;
|
|
808
|
+
}
|
|
809
|
+
if (!fs.existsSync(dbPath)) {
|
|
810
|
+
res.writeHead(404);
|
|
811
|
+
res.end(JSON.stringify({ error: 'Graph not built' }));
|
|
812
|
+
return true;
|
|
813
|
+
}
|
|
814
|
+
const { openDb, closeDb } = await import(
|
|
815
|
+
new URL('../../../../monograph/dist/src/storage/db.js', import.meta.url).href
|
|
816
|
+
);
|
|
463
817
|
const db = openDb(dbPath);
|
|
464
|
-
let content = '',
|
|
818
|
+
let content = '',
|
|
819
|
+
filePath = '',
|
|
820
|
+
startLine = 0,
|
|
821
|
+
endLine = 0,
|
|
822
|
+
language = '',
|
|
823
|
+
name = '',
|
|
824
|
+
type = '';
|
|
465
825
|
try {
|
|
466
826
|
const node = db.prepare('SELECT * FROM nodes WHERE id=?').get(id);
|
|
467
|
-
if (!node) {
|
|
827
|
+
if (!node) {
|
|
828
|
+
res.writeHead(404);
|
|
829
|
+
res.end(JSON.stringify({ error: 'Node not found' }));
|
|
830
|
+
return true;
|
|
831
|
+
}
|
|
468
832
|
name = node.name || id;
|
|
469
833
|
type = node.label || 'Unknown';
|
|
470
834
|
filePath = node.file_path || '';
|
|
@@ -475,7 +839,9 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
475
839
|
if (node.properties) {
|
|
476
840
|
try {
|
|
477
841
|
const props = JSON.parse(node.properties);
|
|
478
|
-
if (props.content
|
|
842
|
+
if (props.content?.trim()) {
|
|
843
|
+
content = props.content;
|
|
844
|
+
}
|
|
479
845
|
} catch {}
|
|
480
846
|
}
|
|
481
847
|
// Fallback: read from actual file
|
|
@@ -488,11 +854,17 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
488
854
|
content = lines.slice(sl, Math.min(el, sl + 120)).join('\n');
|
|
489
855
|
} catch {}
|
|
490
856
|
}
|
|
491
|
-
} finally {
|
|
492
|
-
|
|
857
|
+
} finally {
|
|
858
|
+
closeDb(db);
|
|
859
|
+
}
|
|
860
|
+
res.writeHead(200, {
|
|
861
|
+
'Content-Type': 'application/json',
|
|
862
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
863
|
+
});
|
|
493
864
|
res.end(JSON.stringify({ content, filePath, startLine, endLine, language, name, type }));
|
|
494
865
|
} catch (err) {
|
|
495
|
-
res.writeHead(500);
|
|
866
|
+
res.writeHead(500);
|
|
867
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
496
868
|
}
|
|
497
869
|
return true;
|
|
498
870
|
}
|
|
@@ -508,24 +880,58 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
508
880
|
const limit = Math.min(100, parseInt(qs.get('limit') || '50', 10));
|
|
509
881
|
const d = path.resolve(dir || process.cwd());
|
|
510
882
|
const dbPath = path.join(d, '.monomind', 'monograph.db');
|
|
511
|
-
if (!q) {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
883
|
+
if (!q) {
|
|
884
|
+
res.writeHead(400);
|
|
885
|
+
res.end(JSON.stringify({ error: 'Missing ?q=' }));
|
|
886
|
+
return true;
|
|
887
|
+
}
|
|
888
|
+
if (!fs.existsSync(dbPath)) {
|
|
889
|
+
res.writeHead(200, {
|
|
890
|
+
'Content-Type': 'application/json',
|
|
891
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
892
|
+
});
|
|
893
|
+
res.end(JSON.stringify({ nodes: [] }));
|
|
894
|
+
return true;
|
|
895
|
+
}
|
|
896
|
+
const { openDb, closeDb } = await import(
|
|
897
|
+
new URL('../../../../monograph/dist/src/storage/db.js', import.meta.url).href
|
|
898
|
+
);
|
|
899
|
+
const { ftsSearch } = await import(
|
|
900
|
+
new URL('../../../../monograph/dist/src/storage/fts-store.js', import.meta.url).href
|
|
901
|
+
);
|
|
515
902
|
const db = openDb(dbPath);
|
|
516
903
|
let nodes = [];
|
|
517
904
|
try {
|
|
518
905
|
const hits = ftsSearch(db, q, limit);
|
|
519
|
-
nodes = hits.map(h => {
|
|
906
|
+
nodes = hits.map((h) => {
|
|
520
907
|
let snippet = '';
|
|
521
|
-
if (h.properties) {
|
|
522
|
-
|
|
908
|
+
if (h.properties) {
|
|
909
|
+
try {
|
|
910
|
+
const p = JSON.parse(h.properties);
|
|
911
|
+
snippet = (p.content || '').slice(0, 200);
|
|
912
|
+
} catch {}
|
|
913
|
+
}
|
|
914
|
+
return {
|
|
915
|
+
id: h.id,
|
|
916
|
+
label: h.name,
|
|
917
|
+
type: h.label,
|
|
918
|
+
degree: 0,
|
|
919
|
+
filePath: h.filePath || h.file_path,
|
|
920
|
+
startLine: h.startLine || h.start_line,
|
|
921
|
+
snippet,
|
|
922
|
+
};
|
|
523
923
|
});
|
|
524
|
-
} finally {
|
|
525
|
-
|
|
924
|
+
} finally {
|
|
925
|
+
closeDb(db);
|
|
926
|
+
}
|
|
927
|
+
res.writeHead(200, {
|
|
928
|
+
'Content-Type': 'application/json',
|
|
929
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
930
|
+
});
|
|
526
931
|
res.end(JSON.stringify({ nodes }));
|
|
527
932
|
} catch (err) {
|
|
528
|
-
res.writeHead(500);
|
|
933
|
+
res.writeHead(500);
|
|
934
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
529
935
|
}
|
|
530
936
|
return true;
|
|
531
937
|
}
|
|
@@ -541,17 +947,34 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
541
947
|
const maxDepth = Math.min(4, parseInt(qs.get('depth') || '3', 10));
|
|
542
948
|
const d = path.resolve(dir || process.cwd());
|
|
543
949
|
const dbPath = path.join(d, '.monomind', 'monograph.db');
|
|
544
|
-
if (!id || !fs.existsSync(dbPath)) {
|
|
545
|
-
|
|
950
|
+
if (!id || !fs.existsSync(dbPath)) {
|
|
951
|
+
res.writeHead(200, {
|
|
952
|
+
'Content-Type': 'application/json',
|
|
953
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
954
|
+
});
|
|
955
|
+
res.end(JSON.stringify({ related: [] }));
|
|
956
|
+
return true;
|
|
957
|
+
}
|
|
958
|
+
const { openDb, closeDb } = await import(
|
|
959
|
+
new URL('../../../../monograph/dist/src/storage/db.js', import.meta.url).href
|
|
960
|
+
);
|
|
546
961
|
const db = openDb(dbPath);
|
|
547
962
|
const related = [];
|
|
548
963
|
try {
|
|
549
964
|
const visited = new Set([id]);
|
|
550
965
|
let frontier = [id];
|
|
551
|
-
for (
|
|
966
|
+
for (
|
|
967
|
+
let depth = 1;
|
|
968
|
+
depth <= maxDepth && frontier.length > 0 && related.length < limit;
|
|
969
|
+
depth++
|
|
970
|
+
) {
|
|
552
971
|
const next = [];
|
|
553
972
|
for (const nodeId of frontier) {
|
|
554
|
-
const rows = db
|
|
973
|
+
const rows = db
|
|
974
|
+
.prepare(
|
|
975
|
+
`SELECT DISTINCT target_id as nid FROM edges WHERE source_id=? UNION SELECT DISTINCT source_id as nid FROM edges WHERE target_id=? LIMIT 30`,
|
|
976
|
+
)
|
|
977
|
+
.all(nodeId, nodeId);
|
|
555
978
|
for (const r of rows) {
|
|
556
979
|
if (!visited.has(r.nid)) {
|
|
557
980
|
visited.add(r.nid);
|
|
@@ -564,11 +987,17 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
564
987
|
}
|
|
565
988
|
frontier = next;
|
|
566
989
|
}
|
|
567
|
-
} finally {
|
|
568
|
-
|
|
990
|
+
} finally {
|
|
991
|
+
closeDb(db);
|
|
992
|
+
}
|
|
993
|
+
res.writeHead(200, {
|
|
994
|
+
'Content-Type': 'application/json',
|
|
995
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
996
|
+
});
|
|
569
997
|
res.end(JSON.stringify({ related }));
|
|
570
998
|
} catch (err) {
|
|
571
|
-
res.writeHead(500);
|
|
999
|
+
res.writeHead(500);
|
|
1000
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
572
1001
|
}
|
|
573
1002
|
return true;
|
|
574
1003
|
}
|
|
@@ -582,53 +1011,120 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
582
1011
|
const id = qs.get('id') || '';
|
|
583
1012
|
const d = path.resolve(dir || process.cwd());
|
|
584
1013
|
const dbPath = path.join(d, '.monomind', 'monograph.db');
|
|
585
|
-
if (!id || !fs.existsSync(dbPath)) {
|
|
586
|
-
|
|
1014
|
+
if (!id || !fs.existsSync(dbPath)) {
|
|
1015
|
+
res.writeHead(404);
|
|
1016
|
+
res.end(JSON.stringify({ error: 'Not found' }));
|
|
1017
|
+
return true;
|
|
1018
|
+
}
|
|
1019
|
+
const { openDb, closeDb } = await import(
|
|
1020
|
+
new URL('../../../../monograph/dist/src/storage/db.js', import.meta.url).href
|
|
1021
|
+
);
|
|
587
1022
|
const db = openDb(dbPath);
|
|
588
|
-
|
|
1023
|
+
const result = { node: null, content: '', neighbors: [], markdown: '' };
|
|
589
1024
|
try {
|
|
590
1025
|
const node = db.prepare('SELECT * FROM nodes WHERE id=?').get(id);
|
|
591
|
-
if (!node) {
|
|
592
|
-
|
|
1026
|
+
if (!node) {
|
|
1027
|
+
res.writeHead(404);
|
|
1028
|
+
res.end(JSON.stringify({ error: 'Node not found' }));
|
|
1029
|
+
return true;
|
|
1030
|
+
}
|
|
1031
|
+
result.node = {
|
|
1032
|
+
id: node.id,
|
|
1033
|
+
name: node.name,
|
|
1034
|
+
type: node.label,
|
|
1035
|
+
filePath: node.file_path,
|
|
1036
|
+
startLine: node.start_line,
|
|
1037
|
+
endLine: node.end_line,
|
|
1038
|
+
};
|
|
593
1039
|
// Get content
|
|
594
1040
|
let content = '';
|
|
595
|
-
if (node.properties) {
|
|
1041
|
+
if (node.properties) {
|
|
1042
|
+
try {
|
|
1043
|
+
const p = JSON.parse(node.properties);
|
|
1044
|
+
content = p.content || '';
|
|
1045
|
+
} catch {}
|
|
1046
|
+
}
|
|
596
1047
|
if (!content && node.file_path) {
|
|
597
|
-
const absPath = path.isAbsolute(node.file_path)
|
|
1048
|
+
const absPath = path.isAbsolute(node.file_path)
|
|
1049
|
+
? node.file_path
|
|
1050
|
+
: path.join(d, node.file_path);
|
|
598
1051
|
try {
|
|
599
1052
|
const lines = fs.readFileSync(absPath, 'utf-8').split('\n');
|
|
600
1053
|
const sl = Math.max(0, (node.start_line || 1) - 1);
|
|
601
|
-
const el = Math.min(
|
|
1054
|
+
const el = Math.min(
|
|
1055
|
+
lines.length,
|
|
1056
|
+
(node.end_line || node.start_line || lines.length) + 5,
|
|
1057
|
+
);
|
|
602
1058
|
content = lines.slice(sl, Math.min(el, sl + 80)).join('\n');
|
|
603
1059
|
} catch {}
|
|
604
1060
|
}
|
|
605
1061
|
result.content = content;
|
|
606
1062
|
// Get 1-hop neighbors
|
|
607
|
-
const outEdges = db
|
|
608
|
-
|
|
1063
|
+
const outEdges = db
|
|
1064
|
+
.prepare(
|
|
1065
|
+
'SELECT e.relation, n.id, n.name, n.label, n.file_path FROM edges e JOIN nodes n ON n.id=e.target_id WHERE e.source_id=? LIMIT 20',
|
|
1066
|
+
)
|
|
1067
|
+
.all(id);
|
|
1068
|
+
const inEdges = db
|
|
1069
|
+
.prepare(
|
|
1070
|
+
'SELECT e.relation, n.id, n.name, n.label, n.file_path FROM edges e JOIN nodes n ON n.id=e.source_id WHERE e.target_id=? LIMIT 20',
|
|
1071
|
+
)
|
|
1072
|
+
.all(id);
|
|
609
1073
|
result.neighbors = [
|
|
610
|
-
...outEdges.map(e => ({
|
|
611
|
-
|
|
1074
|
+
...outEdges.map((e) => ({
|
|
1075
|
+
direction: 'out',
|
|
1076
|
+
relation: e.relation,
|
|
1077
|
+
id: e.id,
|
|
1078
|
+
name: e.name,
|
|
1079
|
+
type: e.label,
|
|
1080
|
+
filePath: e.file_path,
|
|
1081
|
+
})),
|
|
1082
|
+
...inEdges.map((e) => ({
|
|
1083
|
+
direction: 'in',
|
|
1084
|
+
relation: e.relation,
|
|
1085
|
+
id: e.id,
|
|
1086
|
+
name: e.name,
|
|
1087
|
+
type: e.label,
|
|
1088
|
+
filePath: e.file_path,
|
|
1089
|
+
})),
|
|
612
1090
|
];
|
|
613
1091
|
// Build markdown for clipboard/AI
|
|
614
1092
|
const lines2 = [];
|
|
615
1093
|
lines2.push(`# ${node.name} [${node.label}]`);
|
|
616
|
-
if (node.file_path)
|
|
617
|
-
|
|
1094
|
+
if (node.file_path)
|
|
1095
|
+
lines2.push(
|
|
1096
|
+
`**File:** \`${node.file_path}\`${node.start_line ? ` (line ${node.start_line})` : ''}`,
|
|
1097
|
+
);
|
|
1098
|
+
if (content)
|
|
1099
|
+
lines2.push(`\n\`\`\`${node.language || ''}\n${content.slice(0, 3000)}\n\`\`\``);
|
|
618
1100
|
if (outEdges.length) {
|
|
619
1101
|
lines2.push(`\n**Depends on (${outEdges.length}):**`);
|
|
620
|
-
outEdges.forEach(e =>
|
|
1102
|
+
outEdges.forEach((e) =>
|
|
1103
|
+
lines2.push(
|
|
1104
|
+
`- ${e.relation} → ${e.name} [${e.label}]${e.file_path ? ` \`${e.file_path}\`` : ''}`,
|
|
1105
|
+
),
|
|
1106
|
+
);
|
|
621
1107
|
}
|
|
622
1108
|
if (inEdges.length) {
|
|
623
1109
|
lines2.push(`\n**Used by (${inEdges.length}):**`);
|
|
624
|
-
inEdges.forEach(e =>
|
|
1110
|
+
inEdges.forEach((e) =>
|
|
1111
|
+
lines2.push(
|
|
1112
|
+
`- ${e.relation} ← ${e.name} [${e.label}]${e.file_path ? ` \`${e.file_path}\`` : ''}`,
|
|
1113
|
+
),
|
|
1114
|
+
);
|
|
625
1115
|
}
|
|
626
1116
|
result.markdown = lines2.join('\n');
|
|
627
|
-
} finally {
|
|
628
|
-
|
|
1117
|
+
} finally {
|
|
1118
|
+
closeDb(db);
|
|
1119
|
+
}
|
|
1120
|
+
res.writeHead(200, {
|
|
1121
|
+
'Content-Type': 'application/json',
|
|
1122
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1123
|
+
});
|
|
629
1124
|
res.end(JSON.stringify(result));
|
|
630
1125
|
} catch (err) {
|
|
631
|
-
res.writeHead(500);
|
|
1126
|
+
res.writeHead(500);
|
|
1127
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
632
1128
|
}
|
|
633
1129
|
return true;
|
|
634
1130
|
}
|
|
@@ -641,10 +1137,30 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
641
1137
|
const q = (qs.get('q') || '').trim().slice(0, 4096);
|
|
642
1138
|
const d = path.resolve(dir || process.cwd());
|
|
643
1139
|
const dbPath = path.join(d, '.monomind', 'monograph.db');
|
|
644
|
-
if (!q) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
1140
|
+
if (!q) {
|
|
1141
|
+
res.writeHead(400);
|
|
1142
|
+
res.end(JSON.stringify({ error: 'Missing ?q= parameter' }));
|
|
1143
|
+
return true;
|
|
1144
|
+
}
|
|
1145
|
+
if (!fs.existsSync(dbPath)) {
|
|
1146
|
+
res.writeHead(200, {
|
|
1147
|
+
'Content-Type': 'application/json',
|
|
1148
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1149
|
+
});
|
|
1150
|
+
res.end(
|
|
1151
|
+
JSON.stringify({
|
|
1152
|
+
success: false,
|
|
1153
|
+
result: 'Graph not built yet. Run: monomind monograph build',
|
|
1154
|
+
}),
|
|
1155
|
+
);
|
|
1156
|
+
return true;
|
|
1157
|
+
}
|
|
1158
|
+
const { openDb, closeDb } = await import(
|
|
1159
|
+
new URL('../../../../monograph/dist/src/storage/db.js', import.meta.url).href
|
|
1160
|
+
);
|
|
1161
|
+
const { ftsSearch } = await import(
|
|
1162
|
+
new URL('../../../../monograph/dist/src/storage/fts-store.js', import.meta.url).href
|
|
1163
|
+
);
|
|
648
1164
|
const db = openDb(dbPath);
|
|
649
1165
|
let result = '';
|
|
650
1166
|
try {
|
|
@@ -652,16 +1168,32 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
652
1168
|
if (!hits.length) {
|
|
653
1169
|
result = `No matches found for: "${q}"`;
|
|
654
1170
|
} else {
|
|
655
|
-
result = hits
|
|
1171
|
+
result = hits
|
|
1172
|
+
.map(
|
|
1173
|
+
(h, i) =>
|
|
1174
|
+
`${String(i + 1).padStart(3, ' ')}. ${h.name} [${h.normLabel}]${h.filePath ? `\n ${h.filePath}` : ''}`,
|
|
1175
|
+
)
|
|
1176
|
+
.join('\n');
|
|
656
1177
|
// Show outgoing edges for top hit
|
|
657
1178
|
const topHit = hits[0];
|
|
658
|
-
const neighbors = db
|
|
1179
|
+
const neighbors = db
|
|
1180
|
+
.prepare('SELECT target_id, relation FROM edges WHERE source_id=? LIMIT 10')
|
|
1181
|
+
.all(topHit.id);
|
|
659
1182
|
if (neighbors.length) {
|
|
660
|
-
result +=
|
|
1183
|
+
result +=
|
|
1184
|
+
`\n\n── ${topHit.name} references:\n` +
|
|
1185
|
+
neighbors
|
|
1186
|
+
.map((n) => ` ${n.relation} → ${n.target_id.split('/').pop() || n.target_id}`)
|
|
1187
|
+
.join('\n');
|
|
661
1188
|
}
|
|
662
1189
|
}
|
|
663
|
-
} finally {
|
|
664
|
-
|
|
1190
|
+
} finally {
|
|
1191
|
+
closeDb(db);
|
|
1192
|
+
}
|
|
1193
|
+
res.writeHead(200, {
|
|
1194
|
+
'Content-Type': 'application/json',
|
|
1195
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1196
|
+
});
|
|
665
1197
|
res.end(JSON.stringify({ success: true, query: q, result }));
|
|
666
1198
|
} catch (err) {
|
|
667
1199
|
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
@@ -678,32 +1210,78 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
678
1210
|
const nodeQ = (qs.get('node') || '').trim().slice(0, 4096);
|
|
679
1211
|
const d = path.resolve(dir || process.cwd());
|
|
680
1212
|
const dbPath = path.join(d, '.monomind', 'monograph.db');
|
|
681
|
-
if (!nodeQ) {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
1213
|
+
if (!nodeQ) {
|
|
1214
|
+
res.writeHead(400);
|
|
1215
|
+
res.end(JSON.stringify({ error: 'Missing ?node= parameter' }));
|
|
1216
|
+
return true;
|
|
1217
|
+
}
|
|
1218
|
+
if (!fs.existsSync(dbPath)) {
|
|
1219
|
+
res.writeHead(200, {
|
|
1220
|
+
'Content-Type': 'application/json',
|
|
1221
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1222
|
+
});
|
|
1223
|
+
res.end(
|
|
1224
|
+
JSON.stringify({
|
|
1225
|
+
success: false,
|
|
1226
|
+
explanation: 'Graph not built yet. Run: monomind monograph build',
|
|
1227
|
+
}),
|
|
1228
|
+
);
|
|
1229
|
+
return true;
|
|
1230
|
+
}
|
|
1231
|
+
const { openDb, closeDb } = await import(
|
|
1232
|
+
new URL('../../../../monograph/dist/src/storage/db.js', import.meta.url).href
|
|
1233
|
+
);
|
|
1234
|
+
const { ftsSearch } = await import(
|
|
1235
|
+
new URL('../../../../monograph/dist/src/storage/fts-store.js', import.meta.url).href
|
|
1236
|
+
);
|
|
685
1237
|
const db = openDb(dbPath);
|
|
686
1238
|
let explanation = '';
|
|
687
1239
|
try {
|
|
688
|
-
let nd =
|
|
689
|
-
|
|
1240
|
+
let nd =
|
|
1241
|
+
db.prepare('SELECT * FROM nodes WHERE id=?').get(nodeQ) ||
|
|
1242
|
+
db.prepare('SELECT * FROM nodes WHERE name=?').get(nodeQ);
|
|
1243
|
+
if (!nd) {
|
|
1244
|
+
const hits = ftsSearch(db, nodeQ, 1);
|
|
1245
|
+
if (hits[0]) nd = db.prepare('SELECT * FROM nodes WHERE id=?').get(hits[0].id);
|
|
1246
|
+
}
|
|
690
1247
|
if (!nd) {
|
|
691
1248
|
explanation = `No node found matching: "${nodeQ}"`;
|
|
692
1249
|
} else {
|
|
693
|
-
const outEdges = db
|
|
694
|
-
|
|
1250
|
+
const outEdges = db
|
|
1251
|
+
.prepare('SELECT target_id, relation FROM edges WHERE source_id=? LIMIT 20')
|
|
1252
|
+
.all(nd.id);
|
|
1253
|
+
const inEdges = db
|
|
1254
|
+
.prepare('SELECT source_id, relation FROM edges WHERE target_id=? LIMIT 20')
|
|
1255
|
+
.all(nd.id);
|
|
695
1256
|
explanation = [
|
|
696
1257
|
`## ${nd.name} [${nd.label}]`,
|
|
697
|
-
nd.file_path ? `File: ${nd.file_path}${nd.start_line ?
|
|
1258
|
+
nd.file_path ? `File: ${nd.file_path}${nd.start_line ? `:${nd.start_line}` : ''}` : '',
|
|
698
1259
|
nd.language ? `Language: ${nd.language}` : '',
|
|
699
1260
|
nd.is_exported ? 'Exported: yes' : 'Exported: no',
|
|
700
1261
|
'',
|
|
701
|
-
outEdges.length
|
|
702
|
-
|
|
703
|
-
|
|
1262
|
+
outEdges.length
|
|
1263
|
+
? `References (${outEdges.length}):\n` +
|
|
1264
|
+
outEdges
|
|
1265
|
+
.map((e) => ` ${e.relation} → ${e.target_id.split('/').pop() || e.target_id}`)
|
|
1266
|
+
.join('\n')
|
|
1267
|
+
: 'No outgoing references.',
|
|
1268
|
+
inEdges.length
|
|
1269
|
+
? `\nReferenced by (${inEdges.length}):\n` +
|
|
1270
|
+
inEdges
|
|
1271
|
+
.map((e) => ` ${e.source_id.split('/').pop() || e.source_id} [${e.relation}]`)
|
|
1272
|
+
.join('\n')
|
|
1273
|
+
: '',
|
|
1274
|
+
]
|
|
1275
|
+
.filter(Boolean)
|
|
1276
|
+
.join('\n');
|
|
704
1277
|
}
|
|
705
|
-
} finally {
|
|
706
|
-
|
|
1278
|
+
} finally {
|
|
1279
|
+
closeDb(db);
|
|
1280
|
+
}
|
|
1281
|
+
res.writeHead(200, {
|
|
1282
|
+
'Content-Type': 'application/json',
|
|
1283
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1284
|
+
});
|
|
707
1285
|
res.end(JSON.stringify({ success: true, node: nodeQ, explanation }));
|
|
708
1286
|
} catch (err) {
|
|
709
1287
|
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
@@ -721,11 +1299,26 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
721
1299
|
const to = (qs.get('to') || '').trim().slice(0, 4096);
|
|
722
1300
|
const d = path.resolve(dir || process.cwd());
|
|
723
1301
|
const dbPath = path.join(d, '.monomind', 'monograph.db');
|
|
724
|
-
if (!from || !to) {
|
|
725
|
-
|
|
1302
|
+
if (!from || !to) {
|
|
1303
|
+
res.writeHead(400);
|
|
1304
|
+
res.end(JSON.stringify({ error: 'Missing ?from= and ?to= parameters' }));
|
|
1305
|
+
return true;
|
|
1306
|
+
}
|
|
1307
|
+
if (!fs.existsSync(dbPath)) {
|
|
1308
|
+
res.writeHead(200, {
|
|
1309
|
+
'Content-Type': 'application/json',
|
|
1310
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1311
|
+
});
|
|
1312
|
+
res.end(JSON.stringify({ success: false, path: 'Graph not built yet.' }));
|
|
1313
|
+
return true;
|
|
1314
|
+
}
|
|
726
1315
|
// Import only graphology-free storage modules to avoid broken graphology dep
|
|
727
|
-
const { openDb, closeDb } = await import(
|
|
728
|
-
|
|
1316
|
+
const { openDb, closeDb } = await import(
|
|
1317
|
+
new URL('../../../../monograph/dist/src/storage/db.js', import.meta.url).href
|
|
1318
|
+
);
|
|
1319
|
+
const { ftsSearch } = await import(
|
|
1320
|
+
new URL('../../../../monograph/dist/src/storage/fts-store.js', import.meta.url).href
|
|
1321
|
+
);
|
|
729
1322
|
// SQL-based BFS for shortest path (avoids graphology)
|
|
730
1323
|
const getShortestPath = (db, fromId, toId, maxDepth = 6) => {
|
|
731
1324
|
if (fromId === toId) return [fromId];
|
|
@@ -735,7 +1328,11 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
735
1328
|
const next = [];
|
|
736
1329
|
for (const chain of frontier) {
|
|
737
1330
|
const cur = chain[chain.length - 1];
|
|
738
|
-
const neighbors = db
|
|
1331
|
+
const neighbors = db
|
|
1332
|
+
.prepare(
|
|
1333
|
+
'SELECT target_id AS id FROM edges WHERE source_id=? UNION SELECT source_id AS id FROM edges WHERE target_id=?',
|
|
1334
|
+
)
|
|
1335
|
+
.all(cur, cur);
|
|
739
1336
|
for (const { id } of neighbors) {
|
|
740
1337
|
if (!visited.has(id)) {
|
|
741
1338
|
const newChain = [...chain, id];
|
|
@@ -762,14 +1359,22 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
762
1359
|
const fromId = resolveId(from);
|
|
763
1360
|
const toId = resolveId(to);
|
|
764
1361
|
const p = getShortestPath(db, fromId, toId);
|
|
765
|
-
if (!p
|
|
1362
|
+
if (!p?.length) {
|
|
766
1363
|
pathResult = `No path found between "${from}" and "${to}"`;
|
|
767
1364
|
} else {
|
|
768
|
-
const names = p.map(id => {
|
|
769
|
-
|
|
1365
|
+
const names = p.map((id) => {
|
|
1366
|
+
const n = db.prepare('SELECT name FROM nodes WHERE id=?').get(id);
|
|
1367
|
+
return n ? n.name : id.split('/').pop() || id;
|
|
1368
|
+
});
|
|
1369
|
+
pathResult = `${names.join(' → ')} (${p.length - 1} hop${p.length !== 2 ? 's' : ''})`;
|
|
770
1370
|
}
|
|
771
|
-
} finally {
|
|
772
|
-
|
|
1371
|
+
} finally {
|
|
1372
|
+
closeDb(db);
|
|
1373
|
+
}
|
|
1374
|
+
res.writeHead(200, {
|
|
1375
|
+
'Content-Type': 'application/json',
|
|
1376
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1377
|
+
});
|
|
773
1378
|
res.end(JSON.stringify({ success: true, from, to, path: pathResult }));
|
|
774
1379
|
} catch (err) {
|
|
775
1380
|
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
@@ -784,7 +1389,8 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
784
1389
|
const qs = new URL(req.url, 'http://localhost').searchParams;
|
|
785
1390
|
const dir = qs.get('dir') || ctx.projectDir || process.cwd();
|
|
786
1391
|
const d = path.resolve(dir || process.cwd());
|
|
787
|
-
let running = false,
|
|
1392
|
+
let running = false,
|
|
1393
|
+
pid = null;
|
|
788
1394
|
for (const pidName of ['monograph.watch.pid', 'monograph-watch.pid']) {
|
|
789
1395
|
try {
|
|
790
1396
|
const pp = path.join(d, '.monomind', pidName);
|
|
@@ -795,7 +1401,10 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
795
1401
|
break;
|
|
796
1402
|
} catch {}
|
|
797
1403
|
}
|
|
798
|
-
res.writeHead(200, {
|
|
1404
|
+
res.writeHead(200, {
|
|
1405
|
+
'Content-Type': 'application/json',
|
|
1406
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1407
|
+
});
|
|
799
1408
|
res.end(JSON.stringify({ running, pid }));
|
|
800
1409
|
} catch (err) {
|
|
801
1410
|
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
@@ -820,20 +1429,37 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
820
1429
|
if (!ctx.looksLikeOurProcess(pid, d)) continue;
|
|
821
1430
|
wasRunning = true;
|
|
822
1431
|
process.kill(pid, 'SIGTERM');
|
|
823
|
-
try {
|
|
1432
|
+
try {
|
|
1433
|
+
fs.unlinkSync(pp);
|
|
1434
|
+
} catch {}
|
|
824
1435
|
} catch {}
|
|
825
1436
|
}
|
|
826
1437
|
|
|
827
1438
|
if (wasRunning) {
|
|
828
|
-
res.writeHead(200, {
|
|
1439
|
+
res.writeHead(200, {
|
|
1440
|
+
'Content-Type': 'application/json',
|
|
1441
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1442
|
+
});
|
|
829
1443
|
res.end(JSON.stringify({ running: false, action: 'stopped' }));
|
|
830
1444
|
} else {
|
|
831
|
-
const { spawn: sp } = await import('child_process');
|
|
832
|
-
const child = sp(process.execPath, [process.argv[1], 'monograph', 'watch'], {
|
|
1445
|
+
const { spawn: sp } = await import('node:child_process');
|
|
1446
|
+
const child = sp(process.execPath, [process.argv[1], 'monograph', 'watch'], {
|
|
1447
|
+
stdio: 'ignore',
|
|
1448
|
+
detached: true,
|
|
1449
|
+
cwd: d,
|
|
1450
|
+
env: process.env,
|
|
1451
|
+
});
|
|
833
1452
|
child.unref();
|
|
834
|
-
try {
|
|
835
|
-
|
|
836
|
-
|
|
1453
|
+
try {
|
|
1454
|
+
fs.mkdirSync(path.join(d, '.monomind'), { recursive: true });
|
|
1455
|
+
} catch {}
|
|
1456
|
+
try {
|
|
1457
|
+
fs.writeFileSync(pidPath, String(child.pid));
|
|
1458
|
+
} catch {}
|
|
1459
|
+
res.writeHead(200, {
|
|
1460
|
+
'Content-Type': 'application/json',
|
|
1461
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1462
|
+
});
|
|
837
1463
|
res.end(JSON.stringify({ running: true, pid: child.pid, action: 'started' }));
|
|
838
1464
|
}
|
|
839
1465
|
} catch (err) {
|
|
@@ -851,17 +1477,32 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
851
1477
|
const d = path.resolve(dir || process.cwd());
|
|
852
1478
|
const graphPath = path.join(d, '.monomind', 'graph', 'graph.json');
|
|
853
1479
|
const legacyPath = path.join(d, 'graphify-out', 'graph.json');
|
|
854
|
-
const gp = fs.existsSync(graphPath)
|
|
1480
|
+
const gp = fs.existsSync(graphPath)
|
|
1481
|
+
? graphPath
|
|
1482
|
+
: fs.existsSync(legacyPath)
|
|
1483
|
+
? legacyPath
|
|
1484
|
+
: null;
|
|
855
1485
|
|
|
856
1486
|
if (!gp) {
|
|
857
|
-
res.writeHead(200, {
|
|
1487
|
+
res.writeHead(200, {
|
|
1488
|
+
'Content-Type': 'application/json',
|
|
1489
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1490
|
+
});
|
|
858
1491
|
res.end(JSON.stringify({ available: false }));
|
|
859
1492
|
return true;
|
|
860
1493
|
}
|
|
861
1494
|
|
|
862
|
-
const { execSync: ex } = await import('child_process');
|
|
863
|
-
const out = ex(`graphify benchmark ${gp}`, {
|
|
864
|
-
|
|
1495
|
+
const { execSync: ex } = await import('node:child_process');
|
|
1496
|
+
const out = ex(`graphify benchmark ${gp}`, {
|
|
1497
|
+
encoding: 'utf8',
|
|
1498
|
+
cwd: d,
|
|
1499
|
+
timeout: 30000,
|
|
1500
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1501
|
+
});
|
|
1502
|
+
res.writeHead(200, {
|
|
1503
|
+
'Content-Type': 'application/json',
|
|
1504
|
+
...(corsOrigin ? { 'Access-Control-Allow-Origin': corsOrigin } : {}),
|
|
1505
|
+
});
|
|
865
1506
|
res.end(JSON.stringify({ available: true, result: out }));
|
|
866
1507
|
} catch (err) {
|
|
867
1508
|
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
@@ -879,54 +1520,85 @@ new Sigma(g,document.getElementById('g'),{renderEdgeLabels:false,labelColor:{col
|
|
|
879
1520
|
res.end(JSON.stringify({ exists: false }));
|
|
880
1521
|
return true;
|
|
881
1522
|
}
|
|
882
|
-
const { execFileSync } = await import('child_process');
|
|
1523
|
+
const { execFileSync } = await import('node:child_process');
|
|
883
1524
|
// Pipe SQL via stdin to avoid shell quoting issues with single-quoted SQL strings.
|
|
884
1525
|
const runSql = (sql, timeout = 5000) => {
|
|
885
1526
|
try {
|
|
886
|
-
return execFileSync('sqlite3', ['-json', dbPath],
|
|
887
|
-
|
|
888
|
-
|
|
1527
|
+
return execFileSync('sqlite3', ['-json', dbPath], {
|
|
1528
|
+
encoding: 'utf-8',
|
|
1529
|
+
timeout: timeout,
|
|
1530
|
+
input: `${sql};`,
|
|
1531
|
+
});
|
|
1532
|
+
} catch (_e) {
|
|
1533
|
+
return '[]';
|
|
1534
|
+
}
|
|
889
1535
|
};
|
|
890
|
-
const counts = JSON.parse(
|
|
891
|
-
|
|
892
|
-
|
|
1536
|
+
const counts = JSON.parse(
|
|
1537
|
+
runSql(
|
|
1538
|
+
'SELECT (SELECT COUNT(*) FROM nodes) AS nodes, (SELECT COUNT(*) FROM edges) AS edges;',
|
|
1539
|
+
) || '[{}]',
|
|
1540
|
+
)[0] || { nodes: 0, edges: 0 };
|
|
893
1541
|
// Compute degree in one pass via GROUP BY (much faster than per-row subquery).
|
|
894
|
-
const gods = JSON.parse(
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
1542
|
+
const gods = JSON.parse(
|
|
1543
|
+
runSql(
|
|
1544
|
+
'WITH deg(node_id, d) AS (' +
|
|
1545
|
+
' SELECT source_id, COUNT(*) FROM edges GROUP BY source_id ' +
|
|
1546
|
+
' UNION ALL ' +
|
|
1547
|
+
' SELECT target_id, COUNT(*) FROM edges GROUP BY target_id' +
|
|
1548
|
+
'), totals AS (' +
|
|
1549
|
+
' SELECT node_id, SUM(d) AS deg FROM deg GROUP BY node_id' +
|
|
1550
|
+
') ' +
|
|
1551
|
+
'SELECT n.name, n.label, n.file_path, t.deg ' +
|
|
1552
|
+
'FROM nodes n JOIN totals t ON t.node_id = n.id ' +
|
|
1553
|
+
"WHERE n.label NOT IN ('Concept') " +
|
|
1554
|
+
"AND n.file_path IS NOT NULL AND n.file_path != '' " +
|
|
1555
|
+
"AND n.name NOT LIKE '(%' AND length(n.name) >= 3 " +
|
|
1556
|
+
'ORDER BY t.deg DESC LIMIT 20',
|
|
1557
|
+
10000,
|
|
1558
|
+
) || '[]',
|
|
1559
|
+
);
|
|
1560
|
+
const types = JSON.parse(
|
|
1561
|
+
runSql(
|
|
1562
|
+
'SELECT label, COUNT(*) AS count FROM nodes GROUP BY label ORDER BY count DESC LIMIT 12',
|
|
1563
|
+
) || '[]',
|
|
1564
|
+
);
|
|
1565
|
+
const relations = JSON.parse(
|
|
1566
|
+
runSql(
|
|
1567
|
+
'SELECT relation, COUNT(*) AS count FROM edges GROUP BY relation ORDER BY count DESC',
|
|
1568
|
+
) || '[]',
|
|
1569
|
+
);
|
|
916
1570
|
|
|
917
1571
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
918
|
-
res.end(
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
1572
|
+
res.end(
|
|
1573
|
+
JSON.stringify({
|
|
1574
|
+
exists: true,
|
|
1575
|
+
nodes: counts.nodes,
|
|
1576
|
+
edges: counts.edges,
|
|
1577
|
+
godNodes: gods,
|
|
1578
|
+
typeDistribution: types,
|
|
1579
|
+
relationDistribution: relations,
|
|
1580
|
+
updatedAt: (() => {
|
|
1581
|
+
try {
|
|
1582
|
+
return fs.statSync(dbPath).mtime;
|
|
1583
|
+
} catch {
|
|
1584
|
+
return null;
|
|
1585
|
+
}
|
|
1586
|
+
})(),
|
|
1587
|
+
}),
|
|
1588
|
+
);
|
|
927
1589
|
} catch (err) {
|
|
928
1590
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
929
|
-
res.end(
|
|
1591
|
+
res.end(
|
|
1592
|
+
JSON.stringify({
|
|
1593
|
+
exists: true,
|
|
1594
|
+
nodes: 0,
|
|
1595
|
+
edges: 0,
|
|
1596
|
+
godNodes: [],
|
|
1597
|
+
typeDistribution: [],
|
|
1598
|
+
relationDistribution: [],
|
|
1599
|
+
error: String(err),
|
|
1600
|
+
}),
|
|
1601
|
+
);
|
|
930
1602
|
}
|
|
931
1603
|
return true;
|
|
932
1604
|
}
|