specmem-hardwicksoftware 3.5.99
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/CHANGELOG.md +299 -0
- package/LICENSE.md +6406 -0
- package/README.md +539 -0
- package/bin/AegisTheme.cjs +1022 -0
- package/bin/AnsiRenderer.cjs +1055 -0
- package/bin/BoxRenderer.cjs +605 -0
- package/bin/ClaudeLiveScreen.cjs +1299 -0
- package/bin/DashboardModules.cjs +733 -0
- package/bin/LiveScreenCapture.cjs +1012 -0
- package/bin/MemoryBrowserScreen.cjs +1595 -0
- package/bin/TabManager.cjs +1414 -0
- package/bin/checkAgentStatus-fix.patch +30 -0
- package/bin/mcp-socket-client.cjs +462 -0
- package/bin/screen-utils.cjs +106 -0
- package/bin/specmem-autoclaude.cjs +663 -0
- package/bin/specmem-cleanup.cjs +421 -0
- package/bin/specmem-cli.cjs +794 -0
- package/bin/specmem-console-teamcomms-class.cjs +428 -0
- package/bin/specmem-console.cjs +8104 -0
- package/bin/specmem-statusbar.cjs +530 -0
- package/bootstrap.cjs +5065 -0
- package/claude-hooks/agent-chooser-hook.js +179 -0
- package/claude-hooks/agent-chooser-inject.js +121 -0
- package/claude-hooks/agent-loading-hook.js +990 -0
- package/claude-hooks/agent-output-fader.cjs +542 -0
- package/claude-hooks/agent-output-interceptor.js +193 -0
- package/claude-hooks/agent-type-matcher.js +419 -0
- package/claude-hooks/auto-bypass.py +74 -0
- package/claude-hooks/background-completion-silencer.js +134 -0
- package/claude-hooks/bash-auto-background.js +182 -0
- package/claude-hooks/build-cedict-dictionary.mjs +167 -0
- package/claude-hooks/bullshit-radar.cjs +323 -0
- package/claude-hooks/cedict-codes.json +270 -0
- package/claude-hooks/cedict-extracted.json +22632 -0
- package/claude-hooks/claude-watchdog.sh +401 -0
- package/claude-hooks/context-dedup.cjs +144 -0
- package/claude-hooks/context-yeeter.cjs +244 -0
- package/claude-hooks/debug-suffix.cjs +15 -0
- package/claude-hooks/debug2.cjs +7 -0
- package/claude-hooks/drilldown-enforcer.js +242 -0
- package/claude-hooks/english-morphology-standalone.cjs +149 -0
- package/claude-hooks/english-morphology.cjs +152 -0
- package/claude-hooks/extract-translations.mjs +193 -0
- package/claude-hooks/file-claim-enforcer.cjs +293 -0
- package/claude-hooks/file-claim-enforcer.js +293 -0
- package/claude-hooks/find-collisions.cjs +39 -0
- package/claude-hooks/fix-abbreviations.cjs +60 -0
- package/claude-hooks/fix-collisions.cjs +60 -0
- package/claude-hooks/fix-decompressor.cjs +79 -0
- package/claude-hooks/fix-suffixes.cjs +66 -0
- package/claude-hooks/grammar-engine.cjs +159 -0
- package/claude-hooks/input-aware-improver.js +231 -0
- package/claude-hooks/is-agent.cjs +64 -0
- package/claude-hooks/mega-test.cjs +213 -0
- package/claude-hooks/merge-dictionaries.mjs +207 -0
- package/claude-hooks/merged-codes.cjs +22675 -0
- package/claude-hooks/merged-codes.json +22676 -0
- package/claude-hooks/output-cleaner.cjs +388 -0
- package/claude-hooks/post-write-memory-hook.cjs +430 -0
- package/claude-hooks/quick-test.cjs +24 -0
- package/claude-hooks/quick-test2.cjs +24 -0
- package/claude-hooks/remove-bad-codes.cjs +23 -0
- package/claude-hooks/search-reminder-hook.js +90 -0
- package/claude-hooks/semantic-test.cjs +93 -0
- package/claude-hooks/settings.json +445 -0
- package/claude-hooks/smart-context-hook.cjs +547 -0
- package/claude-hooks/smart-context-hook.js +539 -0
- package/claude-hooks/smart-search-interceptor.js +364 -0
- package/claude-hooks/socket-connect-helper.cjs +235 -0
- package/claude-hooks/specmem/sockets/session-start.lock +1 -0
- package/claude-hooks/specmem-context-hook.cjs +357 -0
- package/claude-hooks/specmem-context-hook.js +357 -0
- package/claude-hooks/specmem-drilldown-hook.cjs +480 -0
- package/claude-hooks/specmem-drilldown-hook.js +480 -0
- package/claude-hooks/specmem-drilldown-setter.js +210 -0
- package/claude-hooks/specmem-paths.cjs +213 -0
- package/claude-hooks/specmem-precompact.js +183 -0
- package/claude-hooks/specmem-session-init.sh +33 -0
- package/claude-hooks/specmem-session-start.cjs +498 -0
- package/claude-hooks/specmem-stop-hook.cjs +73 -0
- package/claude-hooks/specmem-stop-hook.js +5 -0
- package/claude-hooks/specmem-team-comms.cjs +434 -0
- package/claude-hooks/specmem-team-member-inject.js +271 -0
- package/claude-hooks/specmem-unified-hook.py +670 -0
- package/claude-hooks/subagent-loading-hook.js +194 -0
- package/claude-hooks/sysprompt-squisher.cjs +167 -0
- package/claude-hooks/task-progress-hook.js +204 -0
- package/claude-hooks/team-comms-enforcer.cjs +585 -0
- package/claude-hooks/test-accuracy.cjs +27 -0
- package/claude-hooks/test-big.cjs +28 -0
- package/claude-hooks/test-inflectors.cjs +39 -0
- package/claude-hooks/test-pluralize.cjs +37 -0
- package/claude-hooks/test-quick.cjs +8 -0
- package/claude-hooks/test-wink.cjs +20 -0
- package/claude-hooks/token-compressor.cjs +940 -0
- package/claude-hooks/use-code-pointers.cjs +279 -0
- package/commands/COMMAND_TOOL_MAP.md +299 -0
- package/commands/specmem-agents.md +412 -0
- package/commands/specmem-autoclaude.md +295 -0
- package/commands/specmem-changes.md +247 -0
- package/commands/specmem-code.md +103 -0
- package/commands/specmem-configteammembercomms.md +322 -0
- package/commands/specmem-drilldown.md +208 -0
- package/commands/specmem-find.md +195 -0
- package/commands/specmem-getdashboard.md +243 -0
- package/commands/specmem-hooks.md +219 -0
- package/commands/specmem-pointers.md +149 -0
- package/commands/specmem-progress.md +287 -0
- package/commands/specmem-remember.md +123 -0
- package/commands/specmem-service.md +349 -0
- package/commands/specmem-stats.md +189 -0
- package/commands/specmem-team-member.md +409 -0
- package/commands/specmem-webdev.md +583 -0
- package/commands/specmem.md +363 -0
- package/dist/autoStart/index.d.ts +214 -0
- package/dist/autoStart/index.d.ts.map +1 -0
- package/dist/autoStart/index.js +883 -0
- package/dist/autoStart/index.js.map +1 -0
- package/dist/claude-sessions/contextRestorationParser.d.ts +74 -0
- package/dist/claude-sessions/contextRestorationParser.d.ts.map +1 -0
- package/dist/claude-sessions/contextRestorationParser.js +570 -0
- package/dist/claude-sessions/contextRestorationParser.js.map +1 -0
- package/dist/claude-sessions/index.d.ts +13 -0
- package/dist/claude-sessions/index.d.ts.map +1 -0
- package/dist/claude-sessions/index.js +11 -0
- package/dist/claude-sessions/index.js.map +1 -0
- package/dist/claude-sessions/sessionIntegration.d.ts +48 -0
- package/dist/claude-sessions/sessionIntegration.d.ts.map +1 -0
- package/dist/claude-sessions/sessionIntegration.js +146 -0
- package/dist/claude-sessions/sessionIntegration.js.map +1 -0
- package/dist/claude-sessions/sessionParser.d.ts +293 -0
- package/dist/claude-sessions/sessionParser.d.ts.map +1 -0
- package/dist/claude-sessions/sessionParser.js +1028 -0
- package/dist/claude-sessions/sessionParser.js.map +1 -0
- package/dist/claude-sessions/sessionWatcher.d.ts +139 -0
- package/dist/claude-sessions/sessionWatcher.d.ts.map +1 -0
- package/dist/claude-sessions/sessionWatcher.js +722 -0
- package/dist/claude-sessions/sessionWatcher.js.map +1 -0
- package/dist/cli/deploy-to-claude.d.ts +56 -0
- package/dist/cli/deploy-to-claude.d.ts.map +1 -0
- package/dist/cli/deploy-to-claude.js +576 -0
- package/dist/cli/deploy-to-claude.js.map +1 -0
- package/dist/code-explanations/explainCode.d.ts +86 -0
- package/dist/code-explanations/explainCode.d.ts.map +1 -0
- package/dist/code-explanations/explainCode.js +286 -0
- package/dist/code-explanations/explainCode.js.map +1 -0
- package/dist/code-explanations/feedback.d.ts +87 -0
- package/dist/code-explanations/feedback.d.ts.map +1 -0
- package/dist/code-explanations/feedback.js +212 -0
- package/dist/code-explanations/feedback.js.map +1 -0
- package/dist/code-explanations/getRelatedCode.d.ts +80 -0
- package/dist/code-explanations/getRelatedCode.d.ts.map +1 -0
- package/dist/code-explanations/getRelatedCode.js +262 -0
- package/dist/code-explanations/getRelatedCode.js.map +1 -0
- package/dist/code-explanations/index.d.ts +284 -0
- package/dist/code-explanations/index.d.ts.map +1 -0
- package/dist/code-explanations/index.js +249 -0
- package/dist/code-explanations/index.js.map +1 -0
- package/dist/code-explanations/linkCodeToPrompt.d.ts +79 -0
- package/dist/code-explanations/linkCodeToPrompt.d.ts.map +1 -0
- package/dist/code-explanations/linkCodeToPrompt.js +213 -0
- package/dist/code-explanations/linkCodeToPrompt.js.map +1 -0
- package/dist/code-explanations/recallExplanation.d.ts +88 -0
- package/dist/code-explanations/recallExplanation.d.ts.map +1 -0
- package/dist/code-explanations/recallExplanation.js +218 -0
- package/dist/code-explanations/recallExplanation.js.map +1 -0
- package/dist/code-explanations/schema.d.ts +32 -0
- package/dist/code-explanations/schema.d.ts.map +1 -0
- package/dist/code-explanations/schema.js +221 -0
- package/dist/code-explanations/schema.js.map +1 -0
- package/dist/code-explanations/semanticSearch.d.ts +75 -0
- package/dist/code-explanations/semanticSearch.d.ts.map +1 -0
- package/dist/code-explanations/semanticSearch.js +203 -0
- package/dist/code-explanations/semanticSearch.js.map +1 -0
- package/dist/code-explanations/types.d.ts +328 -0
- package/dist/code-explanations/types.d.ts.map +1 -0
- package/dist/code-explanations/types.js +122 -0
- package/dist/code-explanations/types.js.map +1 -0
- package/dist/codebase/codeAnalyzer.d.ts +272 -0
- package/dist/codebase/codeAnalyzer.d.ts.map +1 -0
- package/dist/codebase/codeAnalyzer.js +1353 -0
- package/dist/codebase/codeAnalyzer.js.map +1 -0
- package/dist/codebase/codebaseIndexer.d.ts +360 -0
- package/dist/codebase/codebaseIndexer.d.ts.map +1 -0
- package/dist/codebase/codebaseIndexer.js +1735 -0
- package/dist/codebase/codebaseIndexer.js.map +1 -0
- package/dist/codebase/codebaseTools.d.ts +853 -0
- package/dist/codebase/codebaseTools.d.ts.map +1 -0
- package/dist/codebase/codebaseTools.js +1279 -0
- package/dist/codebase/codebaseTools.js.map +1 -0
- package/dist/codebase/exclusions.d.ts +111 -0
- package/dist/codebase/exclusions.d.ts.map +1 -0
- package/dist/codebase/exclusions.js +771 -0
- package/dist/codebase/exclusions.js.map +1 -0
- package/dist/codebase/fileWatcher.d.ts +135 -0
- package/dist/codebase/fileWatcher.d.ts.map +1 -0
- package/dist/codebase/fileWatcher.js +309 -0
- package/dist/codebase/fileWatcher.js.map +1 -0
- package/dist/codebase/index.d.ts +33 -0
- package/dist/codebase/index.d.ts.map +1 -0
- package/dist/codebase/index.js +77 -0
- package/dist/codebase/index.js.map +1 -0
- package/dist/codebase/ingestion.d.ts +177 -0
- package/dist/codebase/ingestion.d.ts.map +1 -0
- package/dist/codebase/ingestion.js +690 -0
- package/dist/codebase/ingestion.js.map +1 -0
- package/dist/codebase/languageDetection.d.ts +75 -0
- package/dist/codebase/languageDetection.d.ts.map +1 -0
- package/dist/codebase/languageDetection.js +768 -0
- package/dist/codebase/languageDetection.js.map +1 -0
- package/dist/commands/codebaseCommands.d.ts +101 -0
- package/dist/commands/codebaseCommands.d.ts.map +1 -0
- package/dist/commands/codebaseCommands.js +911 -0
- package/dist/commands/codebaseCommands.js.map +1 -0
- package/dist/commands/commandHandler.d.ts +126 -0
- package/dist/commands/commandHandler.d.ts.map +1 -0
- package/dist/commands/commandHandler.js +296 -0
- package/dist/commands/commandHandler.js.map +1 -0
- package/dist/commands/commandLoader.d.ts +103 -0
- package/dist/commands/commandLoader.d.ts.map +1 -0
- package/dist/commands/commandLoader.js +223 -0
- package/dist/commands/commandLoader.js.map +1 -0
- package/dist/commands/contextCommands.d.ts +83 -0
- package/dist/commands/contextCommands.d.ts.map +1 -0
- package/dist/commands/contextCommands.js +512 -0
- package/dist/commands/contextCommands.js.map +1 -0
- package/dist/commands/index.d.ts +24 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +28 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/mcpResources.d.ts +50 -0
- package/dist/commands/mcpResources.d.ts.map +1 -0
- package/dist/commands/mcpResources.js +372 -0
- package/dist/commands/mcpResources.js.map +1 -0
- package/dist/commands/memoryCommands.d.ts +74 -0
- package/dist/commands/memoryCommands.d.ts.map +1 -0
- package/dist/commands/memoryCommands.js +609 -0
- package/dist/commands/memoryCommands.js.map +1 -0
- package/dist/commands/promptCommands.d.ts +91 -0
- package/dist/commands/promptCommands.d.ts.map +1 -0
- package/dist/commands/promptCommands.js +801 -0
- package/dist/commands/promptCommands.js.map +1 -0
- package/dist/commands/teamMemberCommands.d.ts +21 -0
- package/dist/commands/teamMemberCommands.d.ts.map +1 -0
- package/dist/commands/teamMemberCommands.js +137 -0
- package/dist/commands/teamMemberCommands.js.map +1 -0
- package/dist/comms/fileCommsTransport.d.ts +91 -0
- package/dist/comms/fileCommsTransport.d.ts.map +1 -0
- package/dist/comms/fileCommsTransport.js +244 -0
- package/dist/comms/fileCommsTransport.js.map +1 -0
- package/dist/comms/index.d.ts +7 -0
- package/dist/comms/index.d.ts.map +1 -0
- package/dist/comms/index.js +7 -0
- package/dist/comms/index.js.map +1 -0
- package/dist/config/apiKeyDetection.d.ts +41 -0
- package/dist/config/apiKeyDetection.d.ts.map +1 -0
- package/dist/config/apiKeyDetection.js +211 -0
- package/dist/config/apiKeyDetection.js.map +1 -0
- package/dist/config/autoConfig.d.ts +188 -0
- package/dist/config/autoConfig.d.ts.map +1 -0
- package/dist/config/autoConfig.js +850 -0
- package/dist/config/autoConfig.js.map +1 -0
- package/dist/config/configSync.d.ts +119 -0
- package/dist/config/configSync.d.ts.map +1 -0
- package/dist/config/configSync.js +878 -0
- package/dist/config/configSync.js.map +1 -0
- package/dist/config/embeddingTimeouts.d.ts +145 -0
- package/dist/config/embeddingTimeouts.d.ts.map +1 -0
- package/dist/config/embeddingTimeouts.js +255 -0
- package/dist/config/embeddingTimeouts.js.map +1 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +7 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/languageConfig.d.ts +68 -0
- package/dist/config/languageConfig.d.ts.map +1 -0
- package/dist/config/languageConfig.js +473 -0
- package/dist/config/languageConfig.js.map +1 -0
- package/dist/config/password.d.ts +145 -0
- package/dist/config/password.d.ts.map +1 -0
- package/dist/config/password.js +428 -0
- package/dist/config/password.js.map +1 -0
- package/dist/config.d.ts +338 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1177 -0
- package/dist/config.js.map +1 -0
- package/dist/consolidation.d.ts +44 -0
- package/dist/consolidation.d.ts.map +1 -0
- package/dist/consolidation.js +447 -0
- package/dist/consolidation.js.map +1 -0
- package/dist/constants.d.ts +371 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +552 -0
- package/dist/constants.js.map +1 -0
- package/dist/coordination/TeamMemberRegistry.d.ts +192 -0
- package/dist/coordination/TeamMemberRegistry.d.ts.map +1 -0
- package/dist/coordination/TeamMemberRegistry.js +415 -0
- package/dist/coordination/TeamMemberRegistry.js.map +1 -0
- package/dist/coordination/events.d.ts +369 -0
- package/dist/coordination/events.d.ts.map +1 -0
- package/dist/coordination/events.js +232 -0
- package/dist/coordination/events.js.map +1 -0
- package/dist/coordination/handlers.d.ts +116 -0
- package/dist/coordination/handlers.d.ts.map +1 -0
- package/dist/coordination/handlers.js +400 -0
- package/dist/coordination/handlers.js.map +1 -0
- package/dist/coordination/index.d.ts +14 -0
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +31 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/coordination/integration.d.ts +260 -0
- package/dist/coordination/integration.d.ts.map +1 -0
- package/dist/coordination/integration.js +472 -0
- package/dist/coordination/integration.js.map +1 -0
- package/dist/coordination/server.d.ts +266 -0
- package/dist/coordination/server.d.ts.map +1 -0
- package/dist/coordination/server.js +995 -0
- package/dist/coordination/server.js.map +1 -0
- package/dist/coordination/serviceProvider.d.ts +70 -0
- package/dist/coordination/serviceProvider.d.ts.map +1 -0
- package/dist/coordination/serviceProvider.js +273 -0
- package/dist/coordination/serviceProvider.js.map +1 -0
- package/dist/dashboard/api/claudeControl.d.ts +44 -0
- package/dist/dashboard/api/claudeControl.d.ts.map +1 -0
- package/dist/dashboard/api/claudeControl.js +650 -0
- package/dist/dashboard/api/claudeControl.js.map +1 -0
- package/dist/dashboard/api/claudeHistory.d.ts +4 -0
- package/dist/dashboard/api/claudeHistory.d.ts.map +1 -0
- package/dist/dashboard/api/claudeHistory.js +319 -0
- package/dist/dashboard/api/claudeHistory.js.map +1 -0
- package/dist/dashboard/api/dataExport.d.ts +23 -0
- package/dist/dashboard/api/dataExport.d.ts.map +1 -0
- package/dist/dashboard/api/dataExport.js +509 -0
- package/dist/dashboard/api/dataExport.js.map +1 -0
- package/dist/dashboard/api/fileManager.d.ts +39 -0
- package/dist/dashboard/api/fileManager.d.ts.map +1 -0
- package/dist/dashboard/api/fileManager.js +814 -0
- package/dist/dashboard/api/fileManager.js.map +1 -0
- package/dist/dashboard/api/hooks.d.ts +16 -0
- package/dist/dashboard/api/hooks.d.ts.map +1 -0
- package/dist/dashboard/api/hooks.js +342 -0
- package/dist/dashboard/api/hooks.js.map +1 -0
- package/dist/dashboard/api/hotReload.d.ts +14 -0
- package/dist/dashboard/api/hotReload.d.ts.map +1 -0
- package/dist/dashboard/api/hotReload.js +219 -0
- package/dist/dashboard/api/hotReload.js.map +1 -0
- package/dist/dashboard/api/liveSessionStream.d.ts +19 -0
- package/dist/dashboard/api/liveSessionStream.d.ts.map +1 -0
- package/dist/dashboard/api/liveSessionStream.js +430 -0
- package/dist/dashboard/api/liveSessionStream.js.map +1 -0
- package/dist/dashboard/api/memoryRecall.d.ts +20 -0
- package/dist/dashboard/api/memoryRecall.d.ts.map +1 -0
- package/dist/dashboard/api/memoryRecall.js +524 -0
- package/dist/dashboard/api/memoryRecall.js.map +1 -0
- package/dist/dashboard/api/promptSend.d.ts +33 -0
- package/dist/dashboard/api/promptSend.d.ts.map +1 -0
- package/dist/dashboard/api/promptSend.js +544 -0
- package/dist/dashboard/api/promptSend.js.map +1 -0
- package/dist/dashboard/api/settings.d.ts +10 -0
- package/dist/dashboard/api/settings.d.ts.map +1 -0
- package/dist/dashboard/api/settings.js +656 -0
- package/dist/dashboard/api/settings.js.map +1 -0
- package/dist/dashboard/api/setup.d.ts +21 -0
- package/dist/dashboard/api/setup.d.ts.map +1 -0
- package/dist/dashboard/api/setup.js +663 -0
- package/dist/dashboard/api/setup.js.map +1 -0
- package/dist/dashboard/api/specmemTools.d.ts +14 -0
- package/dist/dashboard/api/specmemTools.d.ts.map +1 -0
- package/dist/dashboard/api/specmemTools.js +1059 -0
- package/dist/dashboard/api/specmemTools.js.map +1 -0
- package/dist/dashboard/api/taskTeamMembers.d.ts +8 -0
- package/dist/dashboard/api/taskTeamMembers.d.ts.map +1 -0
- package/dist/dashboard/api/taskTeamMembers.js +136 -0
- package/dist/dashboard/api/taskTeamMembers.js.map +1 -0
- package/dist/dashboard/api/teamMemberDeploy.d.ts +15 -0
- package/dist/dashboard/api/teamMemberDeploy.d.ts.map +1 -0
- package/dist/dashboard/api/teamMemberDeploy.js +421 -0
- package/dist/dashboard/api/teamMemberDeploy.js.map +1 -0
- package/dist/dashboard/api/teamMemberHistory.d.ts +38 -0
- package/dist/dashboard/api/teamMemberHistory.d.ts.map +1 -0
- package/dist/dashboard/api/teamMemberHistory.js +583 -0
- package/dist/dashboard/api/teamMemberHistory.js.map +1 -0
- package/dist/dashboard/api/terminal.d.ts +12 -0
- package/dist/dashboard/api/terminal.d.ts.map +1 -0
- package/dist/dashboard/api/terminal.js +344 -0
- package/dist/dashboard/api/terminal.js.map +1 -0
- package/dist/dashboard/api/terminalInject.d.ts +17 -0
- package/dist/dashboard/api/terminalInject.d.ts.map +1 -0
- package/dist/dashboard/api/terminalInject.js +322 -0
- package/dist/dashboard/api/terminalInject.js.map +1 -0
- package/dist/dashboard/api/terminalStream.d.ts +12 -0
- package/dist/dashboard/api/terminalStream.d.ts.map +1 -0
- package/dist/dashboard/api/terminalStream.js +482 -0
- package/dist/dashboard/api/terminalStream.js.map +1 -0
- package/dist/dashboard/index.d.ts +7 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +7 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/dashboard/ptyStreamer.d.ts +173 -0
- package/dist/dashboard/ptyStreamer.d.ts.map +1 -0
- package/dist/dashboard/ptyStreamer.js +661 -0
- package/dist/dashboard/ptyStreamer.js.map +1 -0
- package/dist/dashboard/public/DASHBOARD-README.md +378 -0
- package/dist/dashboard/public/INTEGRATION-GUIDE.md +395 -0
- package/dist/dashboard/public/codebase-config.html +1247 -0
- package/dist/dashboard/public/dashboard-v2.html +1942 -0
- package/dist/dashboard/public/data-export.html +819 -0
- package/dist/dashboard/public/example-page.html +164 -0
- package/dist/dashboard/public/file-explorer.html +1023 -0
- package/dist/dashboard/public/hooks.html +1103 -0
- package/dist/dashboard/public/index-improvements.css +499 -0
- package/dist/dashboard/public/index.html +5534 -0
- package/dist/dashboard/public/memory-controls.html +1959 -0
- package/dist/dashboard/public/memory-recall.html +1495 -0
- package/dist/dashboard/public/previews/skeleton-memory-graph.html +361 -0
- package/dist/dashboard/public/previews/skeleton-memory-list.html +366 -0
- package/dist/dashboard/public/previews/skeleton-search-results.html +609 -0
- package/dist/dashboard/public/previews/skeleton-stats-dashboard.html +556 -0
- package/dist/dashboard/public/prompt-console.html +2763 -0
- package/dist/dashboard/public/react-dist/assets/index-CkjobT5B.js +871 -0
- package/dist/dashboard/public/react-dist/assets/index-iRclxMst.css +1 -0
- package/dist/dashboard/public/react-dist/index.html +16 -0
- package/dist/dashboard/public/shared-header.js +325 -0
- package/dist/dashboard/public/shared-language-selector.js +626 -0
- package/dist/dashboard/public/shared-logger.js +66 -0
- package/dist/dashboard/public/shared-nav.js +325 -0
- package/dist/dashboard/public/shared-theme-blue.css +331 -0
- package/dist/dashboard/public/shared-theme.css +813 -0
- package/dist/dashboard/public/shared-toast.js +415 -0
- package/dist/dashboard/public/team-member-history.html +1291 -0
- package/dist/dashboard/public/team-member-spy.html +1199 -0
- package/dist/dashboard/public/team-members.html +3756 -0
- package/dist/dashboard/public/terminal-output.html +1013 -0
- package/dist/dashboard/public/terminal.html +372 -0
- package/dist/dashboard/sessionStore.d.ts +86 -0
- package/dist/dashboard/sessionStore.d.ts.map +1 -0
- package/dist/dashboard/sessionStore.js +262 -0
- package/dist/dashboard/sessionStore.js.map +1 -0
- package/dist/dashboard/standalone.d.ts +27 -0
- package/dist/dashboard/standalone.d.ts.map +1 -0
- package/dist/dashboard/standalone.js +380 -0
- package/dist/dashboard/standalone.js.map +1 -0
- package/dist/dashboard/webServer.d.ts +390 -0
- package/dist/dashboard/webServer.d.ts.map +1 -0
- package/dist/dashboard/webServer.js +4297 -0
- package/dist/dashboard/webServer.js.map +1 -0
- package/dist/dashboard/websocket/teamMemberStream.d.ts +87 -0
- package/dist/dashboard/websocket/teamMemberStream.d.ts.map +1 -0
- package/dist/dashboard/websocket/teamMemberStream.js +366 -0
- package/dist/dashboard/websocket/teamMemberStream.js.map +1 -0
- package/dist/dashboard/websocket/terminalStream.d.ts +130 -0
- package/dist/dashboard/websocket/terminalStream.d.ts.map +1 -0
- package/dist/dashboard/websocket/terminalStream.js +456 -0
- package/dist/dashboard/websocket/terminalStream.js.map +1 -0
- package/dist/database/embeddedPostgres.d.ts +187 -0
- package/dist/database/embeddedPostgres.d.ts.map +1 -0
- package/dist/database/embeddedPostgres.js +763 -0
- package/dist/database/embeddedPostgres.js.map +1 -0
- package/dist/database/index.d.ts +12 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +20 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/initEmbeddedPostgres.d.ts +124 -0
- package/dist/database/initEmbeddedPostgres.d.ts.map +1 -0
- package/dist/database/initEmbeddedPostgres.js +855 -0
- package/dist/database/initEmbeddedPostgres.js.map +1 -0
- package/dist/database.d.ts +256 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +1209 -0
- package/dist/database.js.map +1 -0
- package/dist/db/apiDataManager.d.ts +334 -0
- package/dist/db/apiDataManager.d.ts.map +1 -0
- package/dist/db/apiDataManager.js +631 -0
- package/dist/db/apiDataManager.js.map +1 -0
- package/dist/db/batchOperations.d.ts +154 -0
- package/dist/db/batchOperations.d.ts.map +1 -0
- package/dist/db/batchOperations.js +564 -0
- package/dist/db/batchOperations.js.map +1 -0
- package/dist/db/bigBrainMigrations.d.ts +48 -0
- package/dist/db/bigBrainMigrations.d.ts.map +1 -0
- package/dist/db/bigBrainMigrations.js +4266 -0
- package/dist/db/bigBrainMigrations.js.map +1 -0
- package/dist/db/connectionPoolGoBrrr.d.ts +94 -0
- package/dist/db/connectionPoolGoBrrr.d.ts.map +1 -0
- package/dist/db/connectionPoolGoBrrr.js +548 -0
- package/dist/db/connectionPoolGoBrrr.js.map +1 -0
- package/dist/db/dashboardQueries.d.ts +182 -0
- package/dist/db/dashboardQueries.d.ts.map +1 -0
- package/dist/db/dashboardQueries.js +821 -0
- package/dist/db/dashboardQueries.js.map +1 -0
- package/dist/db/deploymentBootstrap.d.ts +43 -0
- package/dist/db/deploymentBootstrap.d.ts.map +1 -0
- package/dist/db/deploymentBootstrap.js +329 -0
- package/dist/db/deploymentBootstrap.js.map +1 -0
- package/dist/db/dimensionService.d.ts +140 -0
- package/dist/db/dimensionService.d.ts.map +1 -0
- package/dist/db/dimensionService.js +261 -0
- package/dist/db/dimensionService.js.map +1 -0
- package/dist/db/embeddingOverflow.d.ts +69 -0
- package/dist/db/embeddingOverflow.d.ts.map +1 -0
- package/dist/db/embeddingOverflow.js +332 -0
- package/dist/db/embeddingOverflow.js.map +1 -0
- package/dist/db/embeddingOverflow.sql +221 -0
- package/dist/db/findThatShit.d.ts +145 -0
- package/dist/db/findThatShit.d.ts.map +1 -0
- package/dist/db/findThatShit.js +782 -0
- package/dist/db/findThatShit.js.map +1 -0
- package/dist/db/hotPathManager.d.ts +187 -0
- package/dist/db/hotPathManager.d.ts.map +1 -0
- package/dist/db/hotPathManager.js +504 -0
- package/dist/db/hotPathManager.js.map +1 -0
- package/dist/db/index.d.ts +85 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +219 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/memoryDrilldown.sql +99 -0
- package/dist/db/migrate.d.ts +3 -0
- package/dist/db/migrate.d.ts.map +1 -0
- package/dist/db/migrate.js +97 -0
- package/dist/db/migrate.js.map +1 -0
- package/dist/db/migrateJsonToPostgres.d.ts +43 -0
- package/dist/db/migrateJsonToPostgres.d.ts.map +1 -0
- package/dist/db/migrateJsonToPostgres.js +465 -0
- package/dist/db/migrateJsonToPostgres.js.map +1 -0
- package/dist/db/nukeFromOrbit.d.ts +63 -0
- package/dist/db/nukeFromOrbit.d.ts.map +1 -0
- package/dist/db/nukeFromOrbit.js +499 -0
- package/dist/db/nukeFromOrbit.js.map +1 -0
- package/dist/db/processedTraining.sql +60 -0
- package/dist/db/projectNamespacing.d.ts +258 -0
- package/dist/db/projectNamespacing.d.ts.map +1 -0
- package/dist/db/projectNamespacing.js +920 -0
- package/dist/db/projectNamespacing.js.map +1 -0
- package/dist/db/projectNamespacing.sql +374 -0
- package/dist/db/projectSchemaInit.sql +271 -0
- package/dist/db/spatialMemory.d.ts +296 -0
- package/dist/db/spatialMemory.d.ts.map +1 -0
- package/dist/db/spatialMemory.js +818 -0
- package/dist/db/spatialMemory.js.map +1 -0
- package/dist/db/streamingQuery.d.ts +143 -0
- package/dist/db/streamingQuery.d.ts.map +1 -0
- package/dist/db/streamingQuery.js +350 -0
- package/dist/db/streamingQuery.js.map +1 -0
- package/dist/db/teamComms.sql +224 -0
- package/dist/db/yeetStuffInDb.d.ts +72 -0
- package/dist/db/yeetStuffInDb.d.ts.map +1 -0
- package/dist/db/yeetStuffInDb.js +473 -0
- package/dist/db/yeetStuffInDb.js.map +1 -0
- package/dist/embedding-providers/index.d.ts +10 -0
- package/dist/embedding-providers/index.d.ts.map +1 -0
- package/dist/embedding-providers/index.js +12 -0
- package/dist/embedding-providers/index.js.map +1 -0
- package/dist/embeddings/projectionLayer.d.ts +114 -0
- package/dist/embeddings/projectionLayer.d.ts.map +1 -0
- package/dist/embeddings/projectionLayer.js +345 -0
- package/dist/embeddings/projectionLayer.js.map +1 -0
- package/dist/events/Publisher.d.ts +193 -0
- package/dist/events/Publisher.d.ts.map +1 -0
- package/dist/events/Publisher.js +439 -0
- package/dist/events/Publisher.js.map +1 -0
- package/dist/events/config.d.ts +139 -0
- package/dist/events/config.d.ts.map +1 -0
- package/dist/events/config.js +266 -0
- package/dist/events/config.js.map +1 -0
- package/dist/events/index.d.ts +19 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +31 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/integration.d.ts +206 -0
- package/dist/events/integration.d.ts.map +1 -0
- package/dist/events/integration.js +348 -0
- package/dist/events/integration.js.map +1 -0
- package/dist/events/metrics.d.ts +147 -0
- package/dist/events/metrics.d.ts.map +1 -0
- package/dist/events/metrics.js +343 -0
- package/dist/events/metrics.js.map +1 -0
- package/dist/hooks/cli.d.ts +28 -0
- package/dist/hooks/cli.d.ts.map +1 -0
- package/dist/hooks/cli.js +118 -0
- package/dist/hooks/cli.js.map +1 -0
- package/dist/hooks/contextInjectionHook.d.ts +60 -0
- package/dist/hooks/contextInjectionHook.d.ts.map +1 -0
- package/dist/hooks/contextInjectionHook.js +294 -0
- package/dist/hooks/contextInjectionHook.js.map +1 -0
- package/dist/hooks/drilldownHook.d.ts +125 -0
- package/dist/hooks/drilldownHook.d.ts.map +1 -0
- package/dist/hooks/drilldownHook.js +181 -0
- package/dist/hooks/drilldownHook.js.map +1 -0
- package/dist/hooks/hookManager.d.ts +180 -0
- package/dist/hooks/hookManager.d.ts.map +1 -0
- package/dist/hooks/hookManager.js +782 -0
- package/dist/hooks/hookManager.js.map +1 -0
- package/dist/hooks/index.d.ts +62 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +66 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/lowContextHook.d.ts +71 -0
- package/dist/hooks/lowContextHook.d.ts.map +1 -0
- package/dist/hooks/lowContextHook.js +258 -0
- package/dist/hooks/lowContextHook.js.map +1 -0
- package/dist/hooks/simpleContextHook.d.ts +65 -0
- package/dist/hooks/simpleContextHook.d.ts.map +1 -0
- package/dist/hooks/simpleContextHook.js +194 -0
- package/dist/hooks/simpleContextHook.js.map +1 -0
- package/dist/hooks/teamFramingCli.d.ts +56 -0
- package/dist/hooks/teamFramingCli.d.ts.map +1 -0
- package/dist/hooks/teamFramingCli.js +264 -0
- package/dist/hooks/teamFramingCli.js.map +1 -0
- package/dist/hooks/teamMemberPrepromptHook.d.ts +150 -0
- package/dist/hooks/teamMemberPrepromptHook.d.ts.map +1 -0
- package/dist/hooks/teamMemberPrepromptHook.js +308 -0
- package/dist/hooks/teamMemberPrepromptHook.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4433 -0
- package/dist/index.js.map +1 -0
- package/dist/init/claudeConfigInjector.d.ts +116 -0
- package/dist/init/claudeConfigInjector.d.ts.map +1 -0
- package/dist/init/claudeConfigInjector.js +1154 -0
- package/dist/init/claudeConfigInjector.js.map +1 -0
- package/dist/installer/autoInstall.d.ts +72 -0
- package/dist/installer/autoInstall.d.ts.map +1 -0
- package/dist/installer/autoInstall.js +617 -0
- package/dist/installer/autoInstall.js.map +1 -0
- package/dist/installer/dbSetup.d.ts +84 -0
- package/dist/installer/dbSetup.d.ts.map +1 -0
- package/dist/installer/dbSetup.js +350 -0
- package/dist/installer/dbSetup.js.map +1 -0
- package/dist/installer/firstRun.d.ts +49 -0
- package/dist/installer/firstRun.d.ts.map +1 -0
- package/dist/installer/firstRun.js +207 -0
- package/dist/installer/firstRun.js.map +1 -0
- package/dist/installer/index.d.ts +10 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +10 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/silentAutoInstall.d.ts +99 -0
- package/dist/installer/silentAutoInstall.d.ts.map +1 -0
- package/dist/installer/silentAutoInstall.js +491 -0
- package/dist/installer/silentAutoInstall.js.map +1 -0
- package/dist/installer/systemDeps.d.ts +54 -0
- package/dist/installer/systemDeps.d.ts.map +1 -0
- package/dist/installer/systemDeps.js +322 -0
- package/dist/installer/systemDeps.js.map +1 -0
- package/dist/mcp/cliNotifications.d.ts +133 -0
- package/dist/mcp/cliNotifications.d.ts.map +1 -0
- package/dist/mcp/cliNotifications.js +289 -0
- package/dist/mcp/cliNotifications.js.map +1 -0
- package/dist/mcp/embeddingServerManager.d.ts +307 -0
- package/dist/mcp/embeddingServerManager.d.ts.map +1 -0
- package/dist/mcp/embeddingServerManager.js +2081 -0
- package/dist/mcp/embeddingServerManager.js.map +1 -0
- package/dist/mcp/healthMonitor.d.ts +196 -0
- package/dist/mcp/healthMonitor.d.ts.map +1 -0
- package/dist/mcp/healthMonitor.js +685 -0
- package/dist/mcp/healthMonitor.js.map +1 -0
- package/dist/mcp/hotReloadManager.d.ts +101 -0
- package/dist/mcp/hotReloadManager.d.ts.map +1 -0
- package/dist/mcp/hotReloadManager.js +251 -0
- package/dist/mcp/hotReloadManager.js.map +1 -0
- package/dist/mcp/index.d.ts +16 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +22 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcpProtocolHandler.d.ts +64 -0
- package/dist/mcp/mcpProtocolHandler.d.ts.map +1 -0
- package/dist/mcp/mcpProtocolHandler.js +253 -0
- package/dist/mcp/mcpProtocolHandler.js.map +1 -0
- package/dist/mcp/miniCOTServerManager.d.ts +336 -0
- package/dist/mcp/miniCOTServerManager.d.ts.map +1 -0
- package/dist/mcp/miniCOTServerManager.js +1384 -0
- package/dist/mcp/miniCOTServerManager.js.map +1 -0
- package/dist/mcp/promptExecutor.d.ts +188 -0
- package/dist/mcp/promptExecutor.d.ts.map +1 -0
- package/dist/mcp/promptExecutor.js +469 -0
- package/dist/mcp/promptExecutor.js.map +1 -0
- package/dist/mcp/reloadBroadcast.d.ts +127 -0
- package/dist/mcp/reloadBroadcast.d.ts.map +1 -0
- package/dist/mcp/reloadBroadcast.js +275 -0
- package/dist/mcp/reloadBroadcast.js.map +1 -0
- package/dist/mcp/resilientTransport.d.ts +249 -0
- package/dist/mcp/resilientTransport.d.ts.map +1 -0
- package/dist/mcp/resilientTransport.js +931 -0
- package/dist/mcp/resilientTransport.js.map +1 -0
- package/dist/mcp/samplingHandler.d.ts +129 -0
- package/dist/mcp/samplingHandler.d.ts.map +1 -0
- package/dist/mcp/samplingHandler.js +276 -0
- package/dist/mcp/samplingHandler.js.map +1 -0
- package/dist/mcp/specMemServer.d.ts +305 -0
- package/dist/mcp/specMemServer.d.ts.map +1 -0
- package/dist/mcp/specMemServer.js +2048 -0
- package/dist/mcp/specMemServer.js.map +1 -0
- package/dist/mcp/toolRegistry.d.ts +122 -0
- package/dist/mcp/toolRegistry.d.ts.map +1 -0
- package/dist/mcp/toolRegistry.js +609 -0
- package/dist/mcp/toolRegistry.js.map +1 -0
- package/dist/mcp/tools/embeddingControl.d.ts +114 -0
- package/dist/mcp/tools/embeddingControl.d.ts.map +1 -0
- package/dist/mcp/tools/embeddingControl.js +222 -0
- package/dist/mcp/tools/embeddingControl.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +10 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +17 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/teamComms.d.ts +444 -0
- package/dist/mcp/tools/teamComms.d.ts.map +1 -0
- package/dist/mcp/tools/teamComms.js +1953 -0
- package/dist/mcp/tools/teamComms.js.map +1 -0
- package/dist/mcp/triggerSystem.d.ts +129 -0
- package/dist/mcp/triggerSystem.d.ts.map +1 -0
- package/dist/mcp/triggerSystem.js +363 -0
- package/dist/mcp/triggerSystem.js.map +1 -0
- package/dist/mcp/watcherIntegration.d.ts +77 -0
- package/dist/mcp/watcherIntegration.d.ts.map +1 -0
- package/dist/mcp/watcherIntegration.js +428 -0
- package/dist/mcp/watcherIntegration.js.map +1 -0
- package/dist/mcp/watcherToolWrappers.d.ts +89 -0
- package/dist/mcp/watcherToolWrappers.d.ts.map +1 -0
- package/dist/mcp/watcherToolWrappers.js +91 -0
- package/dist/mcp/watcherToolWrappers.js.map +1 -0
- package/dist/memorization/claudeCodeMigration.d.ts +34 -0
- package/dist/memorization/claudeCodeMigration.d.ts.map +1 -0
- package/dist/memorization/claudeCodeMigration.js +210 -0
- package/dist/memorization/claudeCodeMigration.js.map +1 -0
- package/dist/memorization/claudeCodeTracker.d.ts +147 -0
- package/dist/memorization/claudeCodeTracker.d.ts.map +1 -0
- package/dist/memorization/claudeCodeTracker.js +424 -0
- package/dist/memorization/claudeCodeTracker.js.map +1 -0
- package/dist/memorization/codeMemorizer.d.ts +158 -0
- package/dist/memorization/codeMemorizer.d.ts.map +1 -0
- package/dist/memorization/codeMemorizer.js +357 -0
- package/dist/memorization/codeMemorizer.js.map +1 -0
- package/dist/memorization/codeRecall.d.ts +156 -0
- package/dist/memorization/codeRecall.d.ts.map +1 -0
- package/dist/memorization/codeRecall.js +499 -0
- package/dist/memorization/codeRecall.js.map +1 -0
- package/dist/memorization/index.d.ts +55 -0
- package/dist/memorization/index.d.ts.map +1 -0
- package/dist/memorization/index.js +64 -0
- package/dist/memorization/index.js.map +1 -0
- package/dist/memorization/memorizationTools.d.ts +413 -0
- package/dist/memorization/memorizationTools.d.ts.map +1 -0
- package/dist/memorization/memorizationTools.js +513 -0
- package/dist/memorization/memorizationTools.js.map +1 -0
- package/dist/memorization/watcherIntegration.d.ts +100 -0
- package/dist/memorization/watcherIntegration.d.ts.map +1 -0
- package/dist/memorization/watcherIntegration.js +196 -0
- package/dist/memorization/watcherIntegration.js.map +1 -0
- package/dist/memory/humanLikeMemory.d.ts +206 -0
- package/dist/memory/humanLikeMemory.d.ts.map +1 -0
- package/dist/memory/humanLikeMemory.js +603 -0
- package/dist/memory/humanLikeMemory.js.map +1 -0
- package/dist/memory/index.d.ts +22 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +24 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/memoryEvolutionMigration.d.ts +36 -0
- package/dist/memory/memoryEvolutionMigration.d.ts.map +1 -0
- package/dist/memory/memoryEvolutionMigration.js +371 -0
- package/dist/memory/memoryEvolutionMigration.js.map +1 -0
- package/dist/memory/quadrantSearch.d.ts +221 -0
- package/dist/memory/quadrantSearch.d.ts.map +1 -0
- package/dist/memory/quadrantSearch.js +897 -0
- package/dist/memory/quadrantSearch.js.map +1 -0
- package/dist/middleware/apiVersioning.d.ts +83 -0
- package/dist/middleware/apiVersioning.d.ts.map +1 -0
- package/dist/middleware/apiVersioning.js +152 -0
- package/dist/middleware/apiVersioning.js.map +1 -0
- package/dist/middleware/compression.d.ts +48 -0
- package/dist/middleware/compression.d.ts.map +1 -0
- package/dist/middleware/compression.js +240 -0
- package/dist/middleware/compression.js.map +1 -0
- package/dist/middleware/csrf.d.ts +118 -0
- package/dist/middleware/csrf.d.ts.map +1 -0
- package/dist/middleware/csrf.js +300 -0
- package/dist/middleware/csrf.js.map +1 -0
- package/dist/middleware/index.d.ts +13 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +17 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/wsRateLimiter.d.ts +129 -0
- package/dist/middleware/wsRateLimiter.d.ts.map +1 -0
- package/dist/middleware/wsRateLimiter.js +279 -0
- package/dist/middleware/wsRateLimiter.js.map +1 -0
- package/dist/migrations/run.d.ts +2 -0
- package/dist/migrations/run.d.ts.map +1 -0
- package/dist/migrations/run.js +25 -0
- package/dist/migrations/run.js.map +1 -0
- package/dist/migrations/syncDimensions.d.ts +24 -0
- package/dist/migrations/syncDimensions.d.ts.map +1 -0
- package/dist/migrations/syncDimensions.js +140 -0
- package/dist/migrations/syncDimensions.js.map +1 -0
- package/dist/migrations/teamComms.d.ts +16 -0
- package/dist/migrations/teamComms.d.ts.map +1 -0
- package/dist/migrations/teamComms.js +210 -0
- package/dist/migrations/teamComms.js.map +1 -0
- package/dist/openapi/index.d.ts +10 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js +10 -0
- package/dist/openapi/index.js.map +1 -0
- package/dist/openapi/spec.d.ts +902 -0
- package/dist/openapi/spec.d.ts.map +1 -0
- package/dist/openapi/spec.js +733 -0
- package/dist/openapi/spec.js.map +1 -0
- package/dist/packages/dependencyHistory.d.ts +113 -0
- package/dist/packages/dependencyHistory.d.ts.map +1 -0
- package/dist/packages/dependencyHistory.js +360 -0
- package/dist/packages/dependencyHistory.js.map +1 -0
- package/dist/packages/index.d.ts +30 -0
- package/dist/packages/index.d.ts.map +1 -0
- package/dist/packages/index.js +65 -0
- package/dist/packages/index.js.map +1 -0
- package/dist/packages/packageTools.d.ts +255 -0
- package/dist/packages/packageTools.d.ts.map +1 -0
- package/dist/packages/packageTools.js +242 -0
- package/dist/packages/packageTools.js.map +1 -0
- package/dist/packages/packageTracker.d.ts +98 -0
- package/dist/packages/packageTracker.d.ts.map +1 -0
- package/dist/packages/packageTracker.js +268 -0
- package/dist/packages/packageTracker.js.map +1 -0
- package/dist/packages/packageWatcher.d.ts +62 -0
- package/dist/packages/packageWatcher.d.ts.map +1 -0
- package/dist/packages/packageWatcher.js +146 -0
- package/dist/packages/packageWatcher.js.map +1 -0
- package/dist/providers/MiniCOTProvider.d.ts +48 -0
- package/dist/providers/MiniCOTProvider.d.ts.map +1 -0
- package/dist/providers/MiniCOTProvider.js +98 -0
- package/dist/providers/MiniCOTProvider.js.map +1 -0
- package/dist/reminders/index.d.ts +5 -0
- package/dist/reminders/index.d.ts.map +1 -0
- package/dist/reminders/index.js +5 -0
- package/dist/reminders/index.js.map +1 -0
- package/dist/reminders/skillReminder.d.ts +131 -0
- package/dist/reminders/skillReminder.d.ts.map +1 -0
- package/dist/reminders/skillReminder.js +386 -0
- package/dist/reminders/skillReminder.js.map +1 -0
- package/dist/search.d.ts +35 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +574 -0
- package/dist/search.js.map +1 -0
- package/dist/security/localhostOnly.d.ts +36 -0
- package/dist/security/localhostOnly.d.ts.map +1 -0
- package/dist/security/localhostOnly.js +101 -0
- package/dist/security/localhostOnly.js.map +1 -0
- package/dist/services/CameraZoomSearch.d.ts +206 -0
- package/dist/services/CameraZoomSearch.d.ts.map +1 -0
- package/dist/services/CameraZoomSearch.js +669 -0
- package/dist/services/CameraZoomSearch.js.map +1 -0
- package/dist/services/DataFlowPipeline.d.ts +111 -0
- package/dist/services/DataFlowPipeline.d.ts.map +1 -0
- package/dist/services/DataFlowPipeline.js +379 -0
- package/dist/services/DataFlowPipeline.js.map +1 -0
- package/dist/services/DimensionAdapter.d.ts +194 -0
- package/dist/services/DimensionAdapter.d.ts.map +1 -0
- package/dist/services/DimensionAdapter.js +566 -0
- package/dist/services/DimensionAdapter.js.map +1 -0
- package/dist/services/DimensionService.d.ts +252 -0
- package/dist/services/DimensionService.d.ts.map +1 -0
- package/dist/services/DimensionService.js +564 -0
- package/dist/services/DimensionService.js.map +1 -0
- package/dist/services/EmbeddingQueue.d.ts +71 -0
- package/dist/services/EmbeddingQueue.d.ts.map +1 -0
- package/dist/services/EmbeddingQueue.js +258 -0
- package/dist/services/EmbeddingQueue.js.map +1 -0
- package/dist/services/MemoryDrilldown.d.ts +226 -0
- package/dist/services/MemoryDrilldown.d.ts.map +1 -0
- package/dist/services/MemoryDrilldown.js +479 -0
- package/dist/services/MemoryDrilldown.js.map +1 -0
- package/dist/services/MiniCOTScorer.d.ts +140 -0
- package/dist/services/MiniCOTScorer.d.ts.map +1 -0
- package/dist/services/MiniCOTScorer.js +292 -0
- package/dist/services/MiniCOTScorer.js.map +1 -0
- package/dist/services/ProjectContext.d.ts +342 -0
- package/dist/services/ProjectContext.d.ts.map +1 -0
- package/dist/services/ProjectContext.js +667 -0
- package/dist/services/ProjectContext.js.map +1 -0
- package/dist/services/ResponseCompactor.d.ts +135 -0
- package/dist/services/ResponseCompactor.d.ts.map +1 -0
- package/dist/services/ResponseCompactor.js +501 -0
- package/dist/services/ResponseCompactor.js.map +1 -0
- package/dist/services/TeamCommsDbService.d.ts +202 -0
- package/dist/services/TeamCommsDbService.d.ts.map +1 -0
- package/dist/services/TeamCommsDbService.js +526 -0
- package/dist/services/TeamCommsDbService.js.map +1 -0
- package/dist/services/UnifiedPasswordService.d.ts +166 -0
- package/dist/services/UnifiedPasswordService.d.ts.map +1 -0
- package/dist/services/UnifiedPasswordService.js +587 -0
- package/dist/services/UnifiedPasswordService.js.map +1 -0
- package/dist/services/adaptiveSearchConfig.d.ts +64 -0
- package/dist/services/adaptiveSearchConfig.d.ts.map +1 -0
- package/dist/services/adaptiveSearchConfig.js +187 -0
- package/dist/services/adaptiveSearchConfig.js.map +1 -0
- package/dist/skills/index.d.ts +8 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +8 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/skillScanner.d.ts +203 -0
- package/dist/skills/skillScanner.d.ts.map +1 -0
- package/dist/skills/skillScanner.js +559 -0
- package/dist/skills/skillScanner.js.map +1 -0
- package/dist/skills/skillsResource.d.ts +69 -0
- package/dist/skills/skillsResource.d.ts.map +1 -0
- package/dist/skills/skillsResource.js +257 -0
- package/dist/skills/skillsResource.js.map +1 -0
- package/dist/startup/index.d.ts +9 -0
- package/dist/startup/index.d.ts.map +1 -0
- package/dist/startup/index.js +12 -0
- package/dist/startup/index.js.map +1 -0
- package/dist/startup/startupIndexing.d.ts +80 -0
- package/dist/startup/startupIndexing.d.ts.map +1 -0
- package/dist/startup/startupIndexing.js +463 -0
- package/dist/startup/startupIndexing.js.map +1 -0
- package/dist/startup/validation.d.ts +89 -0
- package/dist/startup/validation.d.ts.map +1 -0
- package/dist/startup/validation.js +590 -0
- package/dist/startup/validation.js.map +1 -0
- package/dist/storage/index.d.ts +4 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +4 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/overflowManager.d.ts +80 -0
- package/dist/storage/overflowManager.d.ts.map +1 -0
- package/dist/storage/overflowManager.js +317 -0
- package/dist/storage/overflowManager.js.map +1 -0
- package/dist/storage/overflowStorage.d.ts +69 -0
- package/dist/storage/overflowStorage.d.ts.map +1 -0
- package/dist/storage/overflowStorage.js +379 -0
- package/dist/storage/overflowStorage.js.map +1 -0
- package/dist/storage/toonFormat.d.ts +50 -0
- package/dist/storage/toonFormat.d.ts.map +1 -0
- package/dist/storage/toonFormat.js +224 -0
- package/dist/storage/toonFormat.js.map +1 -0
- package/dist/team-members/communication.d.ts +237 -0
- package/dist/team-members/communication.d.ts.map +1 -0
- package/dist/team-members/communication.js +650 -0
- package/dist/team-members/communication.js.map +1 -0
- package/dist/team-members/index.d.ts +14 -0
- package/dist/team-members/index.d.ts.map +1 -0
- package/dist/team-members/index.js +22 -0
- package/dist/team-members/index.js.map +1 -0
- package/dist/team-members/taskOrchestrator.d.ts +224 -0
- package/dist/team-members/taskOrchestrator.d.ts.map +1 -0
- package/dist/team-members/taskOrchestrator.js +574 -0
- package/dist/team-members/taskOrchestrator.js.map +1 -0
- package/dist/team-members/taskTeamMemberLogger.d.ts +157 -0
- package/dist/team-members/taskTeamMemberLogger.d.ts.map +1 -0
- package/dist/team-members/taskTeamMemberLogger.js +478 -0
- package/dist/team-members/taskTeamMemberLogger.js.map +1 -0
- package/dist/team-members/teamCommsService.d.ts +221 -0
- package/dist/team-members/teamCommsService.d.ts.map +1 -0
- package/dist/team-members/teamCommsService.js +628 -0
- package/dist/team-members/teamCommsService.js.map +1 -0
- package/dist/team-members/teamMemberChannels.d.ts +217 -0
- package/dist/team-members/teamMemberChannels.d.ts.map +1 -0
- package/dist/team-members/teamMemberChannels.js +687 -0
- package/dist/team-members/teamMemberChannels.js.map +1 -0
- package/dist/team-members/teamMemberDashboard.d.ts +222 -0
- package/dist/team-members/teamMemberDashboard.d.ts.map +1 -0
- package/dist/team-members/teamMemberDashboard.js +610 -0
- package/dist/team-members/teamMemberDashboard.js.map +1 -0
- package/dist/team-members/teamMemberDeployment.d.ts +60 -0
- package/dist/team-members/teamMemberDeployment.d.ts.map +1 -0
- package/dist/team-members/teamMemberDeployment.js +429 -0
- package/dist/team-members/teamMemberDeployment.js.map +1 -0
- package/dist/team-members/teamMemberDiscovery.d.ts +178 -0
- package/dist/team-members/teamMemberDiscovery.d.ts.map +1 -0
- package/dist/team-members/teamMemberDiscovery.js +446 -0
- package/dist/team-members/teamMemberDiscovery.js.map +1 -0
- package/dist/team-members/teamMemberHistory.d.ts +80 -0
- package/dist/team-members/teamMemberHistory.d.ts.map +1 -0
- package/dist/team-members/teamMemberHistory.js +426 -0
- package/dist/team-members/teamMemberHistory.js.map +1 -0
- package/dist/team-members/teamMemberLimits.d.ts +66 -0
- package/dist/team-members/teamMemberLimits.d.ts.map +1 -0
- package/dist/team-members/teamMemberLimits.js +259 -0
- package/dist/team-members/teamMemberLimits.js.map +1 -0
- package/dist/team-members/teamMemberRegistry.d.ts +199 -0
- package/dist/team-members/teamMemberRegistry.d.ts.map +1 -0
- package/dist/team-members/teamMemberRegistry.js +572 -0
- package/dist/team-members/teamMemberRegistry.js.map +1 -0
- package/dist/team-members/teamMemberTracker.d.ts +148 -0
- package/dist/team-members/teamMemberTracker.d.ts.map +1 -0
- package/dist/team-members/teamMemberTracker.js +828 -0
- package/dist/team-members/teamMemberTracker.js.map +1 -0
- package/dist/team-members/workers/aiWorker.d.ts +53 -0
- package/dist/team-members/workers/aiWorker.d.ts.map +1 -0
- package/dist/team-members/workers/aiWorker.js +322 -0
- package/dist/team-members/workers/aiWorker.js.map +1 -0
- package/dist/team-members/workers/baseWorker.d.ts +101 -0
- package/dist/team-members/workers/baseWorker.d.ts.map +1 -0
- package/dist/team-members/workers/baseWorker.js +179 -0
- package/dist/team-members/workers/baseWorker.js.map +1 -0
- package/dist/team-members/workers/codeReviewWorker.d.ts +3 -0
- package/dist/team-members/workers/codeReviewWorker.d.ts.map +1 -0
- package/dist/team-members/workers/codeReviewWorker.js +144 -0
- package/dist/team-members/workers/codeReviewWorker.js.map +1 -0
- package/dist/team-members/workers/index.d.ts +7 -0
- package/dist/team-members/workers/index.d.ts.map +1 -0
- package/dist/team-members/workers/index.js +7 -0
- package/dist/team-members/workers/index.js.map +1 -0
- package/dist/team-members/workers/repairWorker.d.ts +9 -0
- package/dist/team-members/workers/repairWorker.d.ts.map +1 -0
- package/dist/team-members/workers/repairWorker.js +102 -0
- package/dist/team-members/workers/repairWorker.js.map +1 -0
- package/dist/team-members/workers/sendToTeamMemberB.d.ts +9 -0
- package/dist/team-members/workers/sendToTeamMemberB.d.ts.map +1 -0
- package/dist/team-members/workers/sendToTeamMemberB.js +105 -0
- package/dist/team-members/workers/sendToTeamMemberB.js.map +1 -0
- package/dist/team-members/workers/specmemClient.d.ts +179 -0
- package/dist/team-members/workers/specmemClient.d.ts.map +1 -0
- package/dist/team-members/workers/specmemClient.js +421 -0
- package/dist/team-members/workers/specmemClient.js.map +1 -0
- package/dist/team-members/workers/testCommunication.d.ts +8 -0
- package/dist/team-members/workers/testCommunication.d.ts.map +1 -0
- package/dist/team-members/workers/testCommunication.js +136 -0
- package/dist/team-members/workers/testCommunication.js.map +1 -0
- package/dist/team-members/workers/testCommunicationSuite.d.ts +26 -0
- package/dist/team-members/workers/testCommunicationSuite.d.ts.map +1 -0
- package/dist/team-members/workers/testCommunicationSuite.js +415 -0
- package/dist/team-members/workers/testCommunicationSuite.js.map +1 -0
- package/dist/team-members/workers/testWorker.d.ts +9 -0
- package/dist/team-members/workers/testWorker.d.ts.map +1 -0
- package/dist/team-members/workers/testWorker.js +107 -0
- package/dist/team-members/workers/testWorker.js.map +1 -0
- package/dist/tools/agentDefinitions.d.ts +30 -0
- package/dist/tools/agentDefinitions.d.ts.map +1 -0
- package/dist/tools/agentDefinitions.js +166 -0
- package/dist/tools/agentDefinitions.js.map +1 -0
- package/dist/tools/goofy/checkSyncStatus.d.ts +68 -0
- package/dist/tools/goofy/checkSyncStatus.d.ts.map +1 -0
- package/dist/tools/goofy/checkSyncStatus.js +112 -0
- package/dist/tools/goofy/checkSyncStatus.js.map +1 -0
- package/dist/tools/goofy/codeMemoryLink.d.ts +82 -0
- package/dist/tools/goofy/codeMemoryLink.d.ts.map +1 -0
- package/dist/tools/goofy/codeMemoryLink.js +212 -0
- package/dist/tools/goofy/codeMemoryLink.js.map +1 -0
- package/dist/tools/goofy/compareInstanceMemory.d.ts +97 -0
- package/dist/tools/goofy/compareInstanceMemory.d.ts.map +1 -0
- package/dist/tools/goofy/compareInstanceMemory.js +218 -0
- package/dist/tools/goofy/compareInstanceMemory.js.map +1 -0
- package/dist/tools/goofy/createReasoningChain.d.ts +135 -0
- package/dist/tools/goofy/createReasoningChain.d.ts.map +1 -0
- package/dist/tools/goofy/createReasoningChain.js +257 -0
- package/dist/tools/goofy/createReasoningChain.js.map +1 -0
- package/dist/tools/goofy/deployTeamMember.d.ts +63 -0
- package/dist/tools/goofy/deployTeamMember.d.ts.map +1 -0
- package/dist/tools/goofy/deployTeamMember.js +103 -0
- package/dist/tools/goofy/deployTeamMember.js.map +1 -0
- package/dist/tools/goofy/drillDown.d.ts +143 -0
- package/dist/tools/goofy/drillDown.d.ts.map +1 -0
- package/dist/tools/goofy/drillDown.js +288 -0
- package/dist/tools/goofy/drillDown.js.map +1 -0
- package/dist/tools/goofy/extractClaudeSessions.d.ts +90 -0
- package/dist/tools/goofy/extractClaudeSessions.d.ts.map +1 -0
- package/dist/tools/goofy/extractClaudeSessions.js +277 -0
- package/dist/tools/goofy/extractClaudeSessions.js.map +1 -0
- package/dist/tools/goofy/extractContextRestorations.d.ts +70 -0
- package/dist/tools/goofy/extractContextRestorations.d.ts.map +1 -0
- package/dist/tools/goofy/extractContextRestorations.js +100 -0
- package/dist/tools/goofy/extractContextRestorations.js.map +1 -0
- package/dist/tools/goofy/findCodePointers.d.ts +364 -0
- package/dist/tools/goofy/findCodePointers.d.ts.map +1 -0
- package/dist/tools/goofy/findCodePointers.js +1764 -0
- package/dist/tools/goofy/findCodePointers.js.map +1 -0
- package/dist/tools/goofy/findMemoryGallery.d.ts +40 -0
- package/dist/tools/goofy/findMemoryGallery.d.ts.map +1 -0
- package/dist/tools/goofy/findMemoryGallery.js +66 -0
- package/dist/tools/goofy/findMemoryGallery.js.map +1 -0
- package/dist/tools/goofy/findWhatISaid.d.ts +300 -0
- package/dist/tools/goofy/findWhatISaid.d.ts.map +1 -0
- package/dist/tools/goofy/findWhatISaid.js +2547 -0
- package/dist/tools/goofy/findWhatISaid.js.map +1 -0
- package/dist/tools/goofy/forceResync.d.ts +57 -0
- package/dist/tools/goofy/forceResync.d.ts.map +1 -0
- package/dist/tools/goofy/forceResync.js +100 -0
- package/dist/tools/goofy/forceResync.js.map +1 -0
- package/dist/tools/goofy/getActiveTeamMembers.d.ts +48 -0
- package/dist/tools/goofy/getActiveTeamMembers.d.ts.map +1 -0
- package/dist/tools/goofy/getActiveTeamMembers.js +136 -0
- package/dist/tools/goofy/getActiveTeamMembers.js.map +1 -0
- package/dist/tools/goofy/getMemoryFull.d.ts +34 -0
- package/dist/tools/goofy/getMemoryFull.d.ts.map +1 -0
- package/dist/tools/goofy/getMemoryFull.js +58 -0
- package/dist/tools/goofy/getMemoryFull.js.map +1 -0
- package/dist/tools/goofy/getSessionWatcherStatus.d.ts +43 -0
- package/dist/tools/goofy/getSessionWatcherStatus.d.ts.map +1 -0
- package/dist/tools/goofy/getSessionWatcherStatus.js +92 -0
- package/dist/tools/goofy/getSessionWatcherStatus.js.map +1 -0
- package/dist/tools/goofy/getTeamMemberOutput.d.ts +35 -0
- package/dist/tools/goofy/getTeamMemberOutput.d.ts.map +1 -0
- package/dist/tools/goofy/getTeamMemberOutput.js +62 -0
- package/dist/tools/goofy/getTeamMemberOutput.js.map +1 -0
- package/dist/tools/goofy/getTeamMemberScreen.d.ts +28 -0
- package/dist/tools/goofy/getTeamMemberScreen.d.ts.map +1 -0
- package/dist/tools/goofy/getTeamMemberScreen.js +59 -0
- package/dist/tools/goofy/getTeamMemberScreen.js.map +1 -0
- package/dist/tools/goofy/getTeamMemberStatus.d.ts +33 -0
- package/dist/tools/goofy/getTeamMemberStatus.d.ts.map +1 -0
- package/dist/tools/goofy/getTeamMemberStatus.js +56 -0
- package/dist/tools/goofy/getTeamMemberStatus.js.map +1 -0
- package/dist/tools/goofy/index.d.ts +39 -0
- package/dist/tools/goofy/index.d.ts.map +1 -0
- package/dist/tools/goofy/index.js +51 -0
- package/dist/tools/goofy/index.js.map +1 -0
- package/dist/tools/goofy/interveneTeamMember.d.ts +33 -0
- package/dist/tools/goofy/interveneTeamMember.d.ts.map +1 -0
- package/dist/tools/goofy/interveneTeamMember.js +69 -0
- package/dist/tools/goofy/interveneTeamMember.js.map +1 -0
- package/dist/tools/goofy/killDeployedTeamMember.d.ts +29 -0
- package/dist/tools/goofy/killDeployedTeamMember.d.ts.map +1 -0
- package/dist/tools/goofy/killDeployedTeamMember.js +56 -0
- package/dist/tools/goofy/killDeployedTeamMember.js.map +1 -0
- package/dist/tools/goofy/linkTheVibes.d.ts +125 -0
- package/dist/tools/goofy/linkTheVibes.d.ts.map +1 -0
- package/dist/tools/goofy/linkTheVibes.js +354 -0
- package/dist/tools/goofy/linkTheVibes.js.map +1 -0
- package/dist/tools/goofy/listDeployedTeamMembers.d.ts +26 -0
- package/dist/tools/goofy/listDeployedTeamMembers.d.ts.map +1 -0
- package/dist/tools/goofy/listDeployedTeamMembers.js +52 -0
- package/dist/tools/goofy/listDeployedTeamMembers.js.map +1 -0
- package/dist/tools/goofy/listenForMessages.d.ts +56 -0
- package/dist/tools/goofy/listenForMessages.d.ts.map +1 -0
- package/dist/tools/goofy/listenForMessages.js +122 -0
- package/dist/tools/goofy/listenForMessages.js.map +1 -0
- package/dist/tools/goofy/memoryHealthCheck.d.ts +159 -0
- package/dist/tools/goofy/memoryHealthCheck.d.ts.map +1 -0
- package/dist/tools/goofy/memoryHealthCheck.js +443 -0
- package/dist/tools/goofy/memoryHealthCheck.js.map +1 -0
- package/dist/tools/goofy/rememberThisShit.d.ts +103 -0
- package/dist/tools/goofy/rememberThisShit.d.ts.map +1 -0
- package/dist/tools/goofy/rememberThisShit.js +291 -0
- package/dist/tools/goofy/rememberThisShit.js.map +1 -0
- package/dist/tools/goofy/sayToTeamMember.d.ts +55 -0
- package/dist/tools/goofy/sayToTeamMember.d.ts.map +1 -0
- package/dist/tools/goofy/sayToTeamMember.js +116 -0
- package/dist/tools/goofy/sayToTeamMember.js.map +1 -0
- package/dist/tools/goofy/selfMessage.d.ts +54 -0
- package/dist/tools/goofy/selfMessage.d.ts.map +1 -0
- package/dist/tools/goofy/selfMessage.js +111 -0
- package/dist/tools/goofy/selfMessage.js.map +1 -0
- package/dist/tools/goofy/sendHeartbeat.d.ts +53 -0
- package/dist/tools/goofy/sendHeartbeat.d.ts.map +1 -0
- package/dist/tools/goofy/sendHeartbeat.js +119 -0
- package/dist/tools/goofy/sendHeartbeat.js.map +1 -0
- package/dist/tools/goofy/showMeTheStats.d.ts +216 -0
- package/dist/tools/goofy/showMeTheStats.d.ts.map +1 -0
- package/dist/tools/goofy/showMeTheStats.js +535 -0
- package/dist/tools/goofy/showMeTheStats.js.map +1 -0
- package/dist/tools/goofy/smartRecall.d.ts +136 -0
- package/dist/tools/goofy/smartRecall.d.ts.map +1 -0
- package/dist/tools/goofy/smartRecall.js +286 -0
- package/dist/tools/goofy/smartRecall.js.map +1 -0
- package/dist/tools/goofy/smartSearch.d.ts +64 -0
- package/dist/tools/goofy/smartSearch.d.ts.map +1 -0
- package/dist/tools/goofy/smartSearch.js +89 -0
- package/dist/tools/goofy/smartSearch.js.map +1 -0
- package/dist/tools/goofy/smushMemoriesTogether.d.ts +128 -0
- package/dist/tools/goofy/smushMemoriesTogether.d.ts.map +1 -0
- package/dist/tools/goofy/smushMemoriesTogether.js +536 -0
- package/dist/tools/goofy/smushMemoriesTogether.js.map +1 -0
- package/dist/tools/goofy/spatialSearch.d.ts +198 -0
- package/dist/tools/goofy/spatialSearch.d.ts.map +1 -0
- package/dist/tools/goofy/spatialSearch.js +551 -0
- package/dist/tools/goofy/spatialSearch.js.map +1 -0
- package/dist/tools/goofy/spawnResearchTeamMember.d.ts +104 -0
- package/dist/tools/goofy/spawnResearchTeamMember.d.ts.map +1 -0
- package/dist/tools/goofy/spawnResearchTeamMember.js +290 -0
- package/dist/tools/goofy/spawnResearchTeamMember.js.map +1 -0
- package/dist/tools/goofy/spawnResearchTeamMemberTool.d.ts +121 -0
- package/dist/tools/goofy/spawnResearchTeamMemberTool.d.ts.map +1 -0
- package/dist/tools/goofy/spawnResearchTeamMemberTool.js +215 -0
- package/dist/tools/goofy/spawnResearchTeamMemberTool.js.map +1 -0
- package/dist/tools/goofy/startWatchingTheFiles.d.ts +81 -0
- package/dist/tools/goofy/startWatchingTheFiles.d.ts.map +1 -0
- package/dist/tools/goofy/startWatchingTheFiles.js +161 -0
- package/dist/tools/goofy/startWatchingTheFiles.js.map +1 -0
- package/dist/tools/goofy/stopWatchingTheFiles.d.ts +50 -0
- package/dist/tools/goofy/stopWatchingTheFiles.d.ts.map +1 -0
- package/dist/tools/goofy/stopWatchingTheFiles.js +81 -0
- package/dist/tools/goofy/stopWatchingTheFiles.js.map +1 -0
- package/dist/tools/goofy/whatDidIMean.d.ts +113 -0
- package/dist/tools/goofy/whatDidIMean.d.ts.map +1 -0
- package/dist/tools/goofy/whatDidIMean.js +401 -0
- package/dist/tools/goofy/whatDidIMean.js.map +1 -0
- package/dist/tools/goofy/yeahNahDeleteThat.d.ts +109 -0
- package/dist/tools/goofy/yeahNahDeleteThat.d.ts.map +1 -0
- package/dist/tools/goofy/yeahNahDeleteThat.js +319 -0
- package/dist/tools/goofy/yeahNahDeleteThat.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/teamMemberDeployer.d.ts +117 -0
- package/dist/tools/teamMemberDeployer.d.ts.map +1 -0
- package/dist/tools/teamMemberDeployer.js +613 -0
- package/dist/tools/teamMemberDeployer.js.map +1 -0
- package/dist/trace/index.d.ts +14 -0
- package/dist/trace/index.d.ts.map +1 -0
- package/dist/trace/index.js +16 -0
- package/dist/trace/index.js.map +1 -0
- package/dist/trace/tools/analyzeImpact.d.ts +90 -0
- package/dist/trace/tools/analyzeImpact.d.ts.map +1 -0
- package/dist/trace/tools/analyzeImpact.js +240 -0
- package/dist/trace/tools/analyzeImpact.js.map +1 -0
- package/dist/trace/tools/exploreDependencies.d.ts +81 -0
- package/dist/trace/tools/exploreDependencies.d.ts.map +1 -0
- package/dist/trace/tools/exploreDependencies.js +161 -0
- package/dist/trace/tools/exploreDependencies.js.map +1 -0
- package/dist/trace/tools/findSimilarBugs.d.ts +112 -0
- package/dist/trace/tools/findSimilarBugs.d.ts.map +1 -0
- package/dist/trace/tools/findSimilarBugs.js +216 -0
- package/dist/trace/tools/findSimilarBugs.js.map +1 -0
- package/dist/trace/tools/index.d.ts +22 -0
- package/dist/trace/tools/index.d.ts.map +1 -0
- package/dist/trace/tools/index.js +39 -0
- package/dist/trace/tools/index.js.map +1 -0
- package/dist/trace/tools/smartExplore.d.ts +126 -0
- package/dist/trace/tools/smartExplore.d.ts.map +1 -0
- package/dist/trace/tools/smartExplore.js +303 -0
- package/dist/trace/tools/smartExplore.js.map +1 -0
- package/dist/trace/tools/traceError.d.ts +101 -0
- package/dist/trace/tools/traceError.d.ts.map +1 -0
- package/dist/trace/tools/traceError.js +175 -0
- package/dist/trace/tools/traceError.js.map +1 -0
- package/dist/trace/traceExploreSystem.d.ts +271 -0
- package/dist/trace/traceExploreSystem.d.ts.map +1 -0
- package/dist/trace/traceExploreSystem.js +789 -0
- package/dist/trace/traceExploreSystem.js.map +1 -0
- package/dist/types/index.d.ts +421 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +118 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/circuitBreaker.d.ts +195 -0
- package/dist/utils/circuitBreaker.d.ts.map +1 -0
- package/dist/utils/circuitBreaker.js +374 -0
- package/dist/utils/circuitBreaker.js.map +1 -0
- package/dist/utils/cleanupHandler.d.ts +108 -0
- package/dist/utils/cleanupHandler.d.ts.map +1 -0
- package/dist/utils/cleanupHandler.js +203 -0
- package/dist/utils/cleanupHandler.js.map +1 -0
- package/dist/utils/compactXmlResponse.d.ts +60 -0
- package/dist/utils/compactXmlResponse.d.ts.map +1 -0
- package/dist/utils/compactXmlResponse.js +209 -0
- package/dist/utils/compactXmlResponse.js.map +1 -0
- package/dist/utils/cotBroadcast.d.ts +56 -0
- package/dist/utils/cotBroadcast.d.ts.map +1 -0
- package/dist/utils/cotBroadcast.js +157 -0
- package/dist/utils/cotBroadcast.js.map +1 -0
- package/dist/utils/debugLogger.d.ts +95 -0
- package/dist/utils/debugLogger.d.ts.map +1 -0
- package/dist/utils/debugLogger.js +610 -0
- package/dist/utils/debugLogger.js.map +1 -0
- package/dist/utils/fileProcessingQueue.d.ts +259 -0
- package/dist/utils/fileProcessingQueue.d.ts.map +1 -0
- package/dist/utils/fileProcessingQueue.js +714 -0
- package/dist/utils/fileProcessingQueue.js.map +1 -0
- package/dist/utils/humanReadableOutput.d.ts +124 -0
- package/dist/utils/humanReadableOutput.d.ts.map +1 -0
- package/dist/utils/humanReadableOutput.js +340 -0
- package/dist/utils/humanReadableOutput.js.map +1 -0
- package/dist/utils/index.d.ts +32 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +71 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/instanceManager.d.ts +530 -0
- package/dist/utils/instanceManager.d.ts.map +1 -0
- package/dist/utils/instanceManager.js +1784 -0
- package/dist/utils/instanceManager.js.map +1 -0
- package/dist/utils/logger.d.ts +6 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +49 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mapCleanup.d.ts +58 -0
- package/dist/utils/mapCleanup.d.ts.map +1 -0
- package/dist/utils/mapCleanup.js +150 -0
- package/dist/utils/mapCleanup.js.map +1 -0
- package/dist/utils/memoryManager.d.ts +349 -0
- package/dist/utils/memoryManager.d.ts.map +1 -0
- package/dist/utils/memoryManager.js +799 -0
- package/dist/utils/memoryManager.js.map +1 -0
- package/dist/utils/metrics.d.ts +160 -0
- package/dist/utils/metrics.d.ts.map +1 -0
- package/dist/utils/metrics.js +558 -0
- package/dist/utils/metrics.js.map +1 -0
- package/dist/utils/pathValidator.d.ts +96 -0
- package/dist/utils/pathValidator.d.ts.map +1 -0
- package/dist/utils/pathValidator.js +320 -0
- package/dist/utils/pathValidator.js.map +1 -0
- package/dist/utils/portAllocator.d.ts +296 -0
- package/dist/utils/portAllocator.d.ts.map +1 -0
- package/dist/utils/portAllocator.js +768 -0
- package/dist/utils/portAllocator.js.map +1 -0
- package/dist/utils/portUtils.d.ts +97 -0
- package/dist/utils/portUtils.d.ts.map +1 -0
- package/dist/utils/portUtils.js +285 -0
- package/dist/utils/portUtils.js.map +1 -0
- package/dist/utils/postgresAutoSetup.d.ts +55 -0
- package/dist/utils/postgresAutoSetup.d.ts.map +1 -0
- package/dist/utils/postgresAutoSetup.js +406 -0
- package/dist/utils/postgresAutoSetup.js.map +1 -0
- package/dist/utils/processHealthCheck.d.ts +61 -0
- package/dist/utils/processHealthCheck.d.ts.map +1 -0
- package/dist/utils/processHealthCheck.js +313 -0
- package/dist/utils/processHealthCheck.js.map +1 -0
- package/dist/utils/progressReporter.d.ts +151 -0
- package/dist/utils/progressReporter.d.ts.map +1 -0
- package/dist/utils/progressReporter.js +345 -0
- package/dist/utils/progressReporter.js.map +1 -0
- package/dist/utils/projectEnv.d.ts +73 -0
- package/dist/utils/projectEnv.d.ts.map +1 -0
- package/dist/utils/projectEnv.js +137 -0
- package/dist/utils/projectEnv.js.map +1 -0
- package/dist/utils/qoms.d.ts +122 -0
- package/dist/utils/qoms.d.ts.map +1 -0
- package/dist/utils/qoms.js +650 -0
- package/dist/utils/qoms.js.map +1 -0
- package/dist/utils/retryHelper.d.ts +122 -0
- package/dist/utils/retryHelper.d.ts.map +1 -0
- package/dist/utils/retryHelper.js +272 -0
- package/dist/utils/retryHelper.js.map +1 -0
- package/dist/utils/safeProcessTermination.d.ts +206 -0
- package/dist/utils/safeProcessTermination.d.ts.map +1 -0
- package/dist/utils/safeProcessTermination.js +552 -0
- package/dist/utils/safeProcessTermination.js.map +1 -0
- package/dist/utils/sessionInjector.d.ts +68 -0
- package/dist/utils/sessionInjector.d.ts.map +1 -0
- package/dist/utils/sessionInjector.js +189 -0
- package/dist/utils/sessionInjector.js.map +1 -0
- package/dist/utils/statsCache.d.ts +134 -0
- package/dist/utils/statsCache.d.ts.map +1 -0
- package/dist/utils/statsCache.js +285 -0
- package/dist/utils/statsCache.js.map +1 -0
- package/dist/utils/timeoutMiddleware.d.ts +81 -0
- package/dist/utils/timeoutMiddleware.d.ts.map +1 -0
- package/dist/utils/timeoutMiddleware.js +155 -0
- package/dist/utils/timeoutMiddleware.js.map +1 -0
- package/dist/utils/timerRegistry.d.ts +91 -0
- package/dist/utils/timerRegistry.d.ts.map +1 -0
- package/dist/utils/timerRegistry.js +187 -0
- package/dist/utils/timerRegistry.js.map +1 -0
- package/dist/utils/tokenCompressor.d.ts +332 -0
- package/dist/utils/tokenCompressor.d.ts.map +1 -0
- package/dist/utils/tokenCompressor.js +1306 -0
- package/dist/utils/tokenCompressor.js.map +1 -0
- package/dist/utils/tracing.d.ts +236 -0
- package/dist/utils/tracing.d.ts.map +1 -0
- package/dist/utils/tracing.js +378 -0
- package/dist/utils/tracing.js.map +1 -0
- package/dist/watcher/changeHandler.d.ts +123 -0
- package/dist/watcher/changeHandler.d.ts.map +1 -0
- package/dist/watcher/changeHandler.js +623 -0
- package/dist/watcher/changeHandler.js.map +1 -0
- package/dist/watcher/changeQueue.d.ts +133 -0
- package/dist/watcher/changeQueue.d.ts.map +1 -0
- package/dist/watcher/changeQueue.js +355 -0
- package/dist/watcher/changeQueue.js.map +1 -0
- package/dist/watcher/fileWatcher.d.ts +121 -0
- package/dist/watcher/fileWatcher.d.ts.map +1 -0
- package/dist/watcher/fileWatcher.js +531 -0
- package/dist/watcher/fileWatcher.js.map +1 -0
- package/dist/watcher/index.d.ts +94 -0
- package/dist/watcher/index.d.ts.map +1 -0
- package/dist/watcher/index.js +235 -0
- package/dist/watcher/index.js.map +1 -0
- package/dist/watcher/syncChecker.d.ts +93 -0
- package/dist/watcher/syncChecker.d.ts.map +1 -0
- package/dist/watcher/syncChecker.js +401 -0
- package/dist/watcher/syncChecker.js.map +1 -0
- package/dist/watcher/tsCompiler.d.ts +88 -0
- package/dist/watcher/tsCompiler.d.ts.map +1 -0
- package/dist/watcher/tsCompiler.js +212 -0
- package/dist/watcher/tsCompiler.js.map +1 -0
- package/embedding-sandbox/Dockerfile +77 -0
- package/embedding-sandbox/Dockerfile.frankenstein +91 -0
- package/embedding-sandbox/README.md +193 -0
- package/embedding-sandbox/__pycache__/frankenstein-embeddings.cpython-312.pyc +0 -0
- package/embedding-sandbox/__pycache__/frankenstein-embeddings.cpython-313.pyc +0 -0
- package/embedding-sandbox/__pycache__/qqms_v2.cpython-312.pyc +0 -0
- package/embedding-sandbox/__pycache__/qqms_v2.cpython-313.pyc +0 -0
- package/embedding-sandbox/add_js_docs.py +684 -0
- package/embedding-sandbox/build_docs_db.py +239 -0
- package/embedding-sandbox/client.cjs +376 -0
- package/embedding-sandbox/client.ts +913 -0
- package/embedding-sandbox/deploy-frankenstein.sh +240 -0
- package/embedding-sandbox/docker-compose.yml +60 -0
- package/embedding-sandbox/docker-manager.py +325 -0
- package/embedding-sandbox/docs/python_docs.db +0 -0
- package/embedding-sandbox/download-model.mjs +79 -0
- package/embedding-sandbox/download-model.py +28 -0
- package/embedding-sandbox/embedding-supervisor.sh +164 -0
- package/embedding-sandbox/frankenstein-embeddings.py +3940 -0
- package/embedding-sandbox/manage-services.sh +354 -0
- package/embedding-sandbox/overflow_queue.py +345 -0
- package/embedding-sandbox/package.json +17 -0
- package/embedding-sandbox/project_isolation.py +292 -0
- package/embedding-sandbox/qqms_v2.py +967 -0
- package/embedding-sandbox/ram-manager.sh +311 -0
- package/embedding-sandbox/requirements-frankenstein.txt +7 -0
- package/embedding-sandbox/run_js_docs.py +59 -0
- package/embedding-sandbox/seed_docs.py +885 -0
- package/embedding-sandbox/server-batch.mjs +228 -0
- package/embedding-sandbox/server.mjs +389 -0
- package/embedding-sandbox/specmem/sockets/claude-input-state.json +1 -0
- package/embedding-sandbox/specmem/sockets/embedding-death-reason.txt +3 -0
- package/embedding-sandbox/specmem/sockets/seen-sessions.json +1 -0
- package/embedding-sandbox/specmem/sockets/session-start.lock +1 -0
- package/embedding-sandbox/specmem/sockets/session-stops.log +7 -0
- package/embedding-sandbox/start-frankenstein-throttled.sh +98 -0
- package/embedding-sandbox/start-on-demand.sh +116 -0
- package/embedding-sandbox/start-sandbox.sh +237 -0
- package/embedding-sandbox/start-supervised.sh +11 -0
- package/embedding-sandbox/stop-sandbox.sh +51 -0
- package/embedding-sandbox/test-socket.mjs +61 -0
- package/embedding-sandbox/warm-start.sh +353 -0
- package/embedding-sandbox/warm_start_feeder.py +660 -0
- package/legal/README.md +31 -0
- package/legal/anthropic-privacy-center-screenshot-2026-01-30.png +0 -0
- package/legal/anthropic-tos-screenshot-2026-01-30.png +0 -0
- package/lib/codebase-bridge.cjs +308 -0
- package/package.json +136 -0
- package/plugins/specmem-agents/agents/bug-hunter.md +79 -0
- package/plugins/specmem-agents/agents/memory-explorer.md +57 -0
- package/plugins/specmem-agents/agents/team-coordinator.md +82 -0
- package/scripts/auto-updater.cjs +399 -0
- package/scripts/backfill-code-definition-embeddings.ts +440 -0
- package/scripts/backfill-code-embeddings.ts +206 -0
- package/scripts/capture-tos-screenshots.cjs +94 -0
- package/scripts/check-global-install.cjs +67 -0
- package/scripts/cleanup-embedding-servers.sh +25 -0
- package/scripts/dashboard-standalone.sh +369 -0
- package/scripts/deploy-hooks.cjs +1451 -0
- package/scripts/deploy.sh +106 -0
- package/scripts/docker-project-down.sh +83 -0
- package/scripts/docker-project-list.sh +40 -0
- package/scripts/docker-project-up.sh +79 -0
- package/scripts/fast-backfill-embeddings.ts +173 -0
- package/scripts/fast-batch-embedder.cjs +334 -0
- package/scripts/first-run-model-setup.cjs +849 -0
- package/scripts/global-postinstall.cjs +1957 -0
- package/scripts/index-codebase.js +72 -0
- package/scripts/migrate-fix-embeddings.py +110 -0
- package/scripts/migrate-to-project-schemas.ts +525 -0
- package/scripts/optimize-embedding-model.py +324 -0
- package/scripts/optimize-instructions.cjs +530 -0
- package/scripts/pack-docker-images.sh +68 -0
- package/scripts/pack-for-testing.sh +130 -0
- package/scripts/postinstall.cjs +54 -0
- package/scripts/project-env.sh +51 -0
- package/scripts/reset-db.sh +30 -0
- package/scripts/run-indexer.ts +69 -0
- package/scripts/run-migrations.js +47 -0
- package/scripts/setup-db.sh +34 -0
- package/scripts/setup-minimal-schema.sql +143 -0
- package/scripts/skills/code-review.md +44 -0
- package/scripts/skills/debugging.md +56 -0
- package/scripts/skills/specmem-deployteam.md +239 -0
- package/scripts/skills/teammemberskills/EFFICIENT_GREP.md +171 -0
- package/scripts/skills/teammemberskills/task-planning.md +67 -0
- package/scripts/specmem/sockets/session-start.lock +1 -0
- package/scripts/specmem/sockets/session-stops.log +1 -0
- package/scripts/specmem-health.sh +382 -0
- package/scripts/specmem-init.cjs +6935 -0
- package/scripts/strip-debug-logs.cjs +43 -0
- package/scripts/test-mcp-standalone.sh +365 -0
- package/scripts/test-optimized-models.py +166 -0
- package/scripts/verify-embedding-fix.sh +148 -0
- package/skills/code-review.md +44 -0
- package/skills/debugging.md +56 -0
- package/skills/specmem-deployteam.md +239 -0
- package/skills/teammemberskills/EFFICIENT_GREP.md +171 -0
- package/skills/teammemberskills/task-planning.md +67 -0
- package/specmem-health.cjs +522 -0
- package/specmem.env +216 -0
package/dist/database.js
ADDED
|
@@ -0,0 +1,1209 @@
|
|
|
1
|
+
// @ts-ignore - pg types not installed
|
|
2
|
+
import pg from 'pg';
|
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
+
import { logger } from './utils/logger.js';
|
|
5
|
+
import { getCoordinator } from './coordination/integration.js';
|
|
6
|
+
import { loadConfig } from './config.js';
|
|
7
|
+
import { getDebugLogger } from './utils/debugLogger.js';
|
|
8
|
+
import { getDimensionService } from './services/DimensionService.js';
|
|
9
|
+
import { getProjectContext, getProjectPathForInsert } from './services/ProjectContext.js';
|
|
10
|
+
import { getProjectSchema, createProjectSchema, setProjectSearchPath, initializeProjectSchema } from './db/projectNamespacing.js';
|
|
11
|
+
import { BigBrainMigrations } from './db/bigBrainMigrations.js';
|
|
12
|
+
const { Pool, types } = pg;
|
|
13
|
+
types.setTypeParser(1700, parseFloat);
|
|
14
|
+
types.setTypeParser(20, parseInt);
|
|
15
|
+
/**
|
|
16
|
+
* High-performance PostgreSQL connection manager with intelligent pooling,
|
|
17
|
+
* automatic reconnection, and health monitoring.
|
|
18
|
+
*
|
|
19
|
+
* Now integrated with LWJEB event bus for db:query:start, db:query:complete events
|
|
20
|
+
*/
|
|
21
|
+
export class DatabaseManager {
|
|
22
|
+
pool;
|
|
23
|
+
config;
|
|
24
|
+
isInitialized = false;
|
|
25
|
+
healthCheckInterval = null;
|
|
26
|
+
queryCounter = 0;
|
|
27
|
+
dimensionService = null;
|
|
28
|
+
currentSchema = null;
|
|
29
|
+
constructor(config) {
|
|
30
|
+
// TASK #21 FIX: Validate database credentials early - fail fast with clear error
|
|
31
|
+
this.validateCredentialsOrThrow(config);
|
|
32
|
+
this.config = config;
|
|
33
|
+
// DEBUG: Log EXACTLY what database we're connecting to (to stderr so it appears in logs)
|
|
34
|
+
const timestamp = new Date().toISOString();
|
|
35
|
+
process.stderr.write('[DB DEBUG ' + timestamp + '] DatabaseConfig: database="' + config.database + '" user="' + config.user + '" host="' + config.host + '" port=' + config.port + '\n');
|
|
36
|
+
process.stderr.write('[DB DEBUG ' + timestamp + '] ENV: SPECMEM_DB_NAME="' + process.env['SPECMEM_DB_NAME'] + '" SPECMEM_DB_USER="' + process.env['SPECMEM_DB_USER'] + '"\n');
|
|
37
|
+
this.pool = this.createPool();
|
|
38
|
+
this.setupPoolEvents();
|
|
39
|
+
// Log project-aware database connection info
|
|
40
|
+
const projectHash = process.env['SPECMEM_PROJECT_HASH'] || 'default';
|
|
41
|
+
logger.info({
|
|
42
|
+
database: config.database,
|
|
43
|
+
host: config.host,
|
|
44
|
+
port: config.port,
|
|
45
|
+
projectHash,
|
|
46
|
+
expectedFormat: 'specmem_' + projectHash
|
|
47
|
+
}, 'DatabaseManager initialized with project-scoped database');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* TASK #21 FIX: Validate database credentials before attempting connection.
|
|
51
|
+
* Fail fast with clear error message if credentials are invalid.
|
|
52
|
+
*/
|
|
53
|
+
validateCredentialsOrThrow(config) {
|
|
54
|
+
const errors = [];
|
|
55
|
+
// Validate host exists and is not empty
|
|
56
|
+
if (!config.host || config.host.trim().length === 0) {
|
|
57
|
+
errors.push('Database host is missing or empty');
|
|
58
|
+
}
|
|
59
|
+
// Validate port is valid number
|
|
60
|
+
if (!config.port || config.port < 1 || config.port > 65535) {
|
|
61
|
+
errors.push('Database port must be between 1 and 65535, got: ' + config.port);
|
|
62
|
+
}
|
|
63
|
+
// Validate database name exists and is valid format
|
|
64
|
+
if (!config.database || config.database.trim().length === 0) {
|
|
65
|
+
errors.push('Database name is missing or empty');
|
|
66
|
+
}
|
|
67
|
+
else if (config.database.length > 63) {
|
|
68
|
+
errors.push('Database name too long (max 63 chars): ' + config.database.length + ' chars');
|
|
69
|
+
}
|
|
70
|
+
// Validate user exists and is valid format
|
|
71
|
+
if (!config.user || config.user.trim().length === 0) {
|
|
72
|
+
errors.push('Database user is missing or empty');
|
|
73
|
+
}
|
|
74
|
+
else if (config.user.length > 63) {
|
|
75
|
+
errors.push('Database username too long (max 63 chars): ' + config.user.length + ' chars');
|
|
76
|
+
}
|
|
77
|
+
// Validate password exists (can be empty string but not undefined/null)
|
|
78
|
+
if (config.password === undefined || config.password === null) {
|
|
79
|
+
errors.push('Database password is undefined - check SPECMEM_PASSWORD env var');
|
|
80
|
+
}
|
|
81
|
+
else if (config.password.trim().length === 0) {
|
|
82
|
+
// Empty password is allowed but log warning
|
|
83
|
+
logger.warn('Database password is empty - this may cause authentication issues');
|
|
84
|
+
}
|
|
85
|
+
// Check for control characters in password
|
|
86
|
+
if (config.password && /[\x00-\x1f]/.test(config.password)) {
|
|
87
|
+
errors.push('Database password contains control characters (ASCII 0-31)');
|
|
88
|
+
}
|
|
89
|
+
// If any errors, throw with all error messages
|
|
90
|
+
if (errors.length > 0) {
|
|
91
|
+
const errorMsg = 'Database credential validation failed:\n - ' + errors.join('\n - ');
|
|
92
|
+
logger.error({ errors, config: { host: config.host, port: config.port, database: config.database, user: config.user } }, errorMsg);
|
|
93
|
+
throw new Error(errorMsg);
|
|
94
|
+
}
|
|
95
|
+
logger.debug({
|
|
96
|
+
host: config.host,
|
|
97
|
+
port: config.port,
|
|
98
|
+
database: config.database,
|
|
99
|
+
user: config.user,
|
|
100
|
+
passwordLength: config.password?.length || 0
|
|
101
|
+
}, 'Database credentials validated successfully');
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get the current project schema name.
|
|
105
|
+
* Returns null if schema isolation hasn't been initialized yet.
|
|
106
|
+
*/
|
|
107
|
+
getCurrentSchema() {
|
|
108
|
+
return this.currentSchema;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get the project schema name for the current project path.
|
|
112
|
+
* Uses SPECMEM_PROJECT_PATH env var or defaults to 'specmem_default'.
|
|
113
|
+
*/
|
|
114
|
+
getProjectSchemaName() {
|
|
115
|
+
return getProjectSchema();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get the DimensionService for this database manager.
|
|
119
|
+
* Lazily initializes the service on first access.
|
|
120
|
+
*/
|
|
121
|
+
getDimensionService() {
|
|
122
|
+
if (!this.dimensionService) {
|
|
123
|
+
this.dimensionService = getDimensionService(this);
|
|
124
|
+
}
|
|
125
|
+
return this.dimensionService;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get the underlying pg.Pool for direct access
|
|
129
|
+
* Used by team comms and other services that need raw pool access
|
|
130
|
+
*/
|
|
131
|
+
getPool() {
|
|
132
|
+
return this.pool;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Generate unique query ID for event tracking
|
|
136
|
+
*/
|
|
137
|
+
generateQueryId() {
|
|
138
|
+
return `q_${Date.now()}_${++this.queryCounter}`;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Detect query type from SQL text
|
|
142
|
+
*/
|
|
143
|
+
detectQueryType(sql) {
|
|
144
|
+
const trimmed = sql.trim().toUpperCase();
|
|
145
|
+
if (trimmed.startsWith('SELECT'))
|
|
146
|
+
return 'SELECT';
|
|
147
|
+
if (trimmed.startsWith('INSERT'))
|
|
148
|
+
return 'INSERT';
|
|
149
|
+
if (trimmed.startsWith('UPDATE'))
|
|
150
|
+
return 'UPDATE';
|
|
151
|
+
if (trimmed.startsWith('DELETE'))
|
|
152
|
+
return 'DELETE';
|
|
153
|
+
if (trimmed.startsWith('BEGIN') || trimmed.startsWith('COMMIT') || trimmed.startsWith('ROLLBACK'))
|
|
154
|
+
return 'TRANSACTION';
|
|
155
|
+
return 'OTHER';
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Extract table name from SQL (basic heuristic)
|
|
159
|
+
*/
|
|
160
|
+
extractTableName(sql) {
|
|
161
|
+
const patterns = [
|
|
162
|
+
/FROM\s+(\w+)/i,
|
|
163
|
+
/INTO\s+(\w+)/i,
|
|
164
|
+
/UPDATE\s+(\w+)/i,
|
|
165
|
+
/DELETE\s+FROM\s+(\w+)/i
|
|
166
|
+
];
|
|
167
|
+
for (const pattern of patterns) {
|
|
168
|
+
const match = sql.match(pattern);
|
|
169
|
+
if (match && match[1])
|
|
170
|
+
return match[1];
|
|
171
|
+
}
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
createPool() {
|
|
175
|
+
return new Pool({
|
|
176
|
+
host: this.config.host,
|
|
177
|
+
port: this.config.port,
|
|
178
|
+
database: this.config.database,
|
|
179
|
+
user: this.config.user,
|
|
180
|
+
password: this.config.password,
|
|
181
|
+
max: this.config.maxConnections,
|
|
182
|
+
idleTimeoutMillis: this.config.idleTimeout,
|
|
183
|
+
connectionTimeoutMillis: this.config.connectionTimeout,
|
|
184
|
+
ssl: this.config.ssl
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
setupPoolEvents() {
|
|
188
|
+
this.pool.on('error', (err) => {
|
|
189
|
+
logger.error({ err }, 'Unexpected pool error');
|
|
190
|
+
});
|
|
191
|
+
// SCHEMA ISOLATION FIX: pool.on('connect') doesn't wait for async callbacks!
|
|
192
|
+
// The client is returned to the caller before await completes.
|
|
193
|
+
// We still set search_path here for defense-in-depth, but critical paths
|
|
194
|
+
// must use ensureSearchPath() explicitly to guarantee isolation.
|
|
195
|
+
this.pool.on('connect', (client) => {
|
|
196
|
+
logger.debug('New client connected to pool');
|
|
197
|
+
// If we have a current schema, set search_path on this new connection
|
|
198
|
+
// NOTE: This is fire-and-forget because pg doesn't await connect handlers
|
|
199
|
+
// Critical code paths should call ensureSearchPath() explicitly
|
|
200
|
+
if (this.currentSchema) {
|
|
201
|
+
// Use quoted identifier format for safety - prevents SQL injection
|
|
202
|
+
client.query('SET search_path TO "' + this.currentSchema.replace(/"/g, '""') + '", public')
|
|
203
|
+
.then(() => {
|
|
204
|
+
logger.debug({ schema: this.currentSchema }, 'Set search_path on new pool connection');
|
|
205
|
+
})
|
|
206
|
+
.catch((error) => {
|
|
207
|
+
// CRITICAL: Log error but continue - the connection may still work for public schema
|
|
208
|
+
// Callers using ensureSearchPath() will set it correctly
|
|
209
|
+
logger.error({ error, schema: this.currentSchema }, 'RACE: Failed to set search_path on new connection - critical queries must use ensureSearchPath()');
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
this.pool.on('remove', () => {
|
|
214
|
+
logger.debug('Client removed from pool');
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
async initialize() {
|
|
218
|
+
if (this.isInitialized)
|
|
219
|
+
return;
|
|
220
|
+
let poolEnded = false; // HIGH-19 FIX: Track if pool was ended during error handling
|
|
221
|
+
// CRITICAL FIX: Initialize schema isolation FIRST before acquiring ANY client
|
|
222
|
+
// This ensures the pool's on('connect') hook has currentSchema set, so ALL
|
|
223
|
+
// connections (including the first one) get proper search_path
|
|
224
|
+
try {
|
|
225
|
+
await this.initializeProjectSchemaIsolation();
|
|
226
|
+
}
|
|
227
|
+
catch (schemaError) {
|
|
228
|
+
const errMsg = schemaError instanceof Error ? schemaError.message : String(schemaError);
|
|
229
|
+
// HIGH-19 FIX: Check if error message indicates pool was already ended
|
|
230
|
+
if (errMsg.includes('Pool ended') || errMsg.includes('Cannot use a pool after calling end')) {
|
|
231
|
+
poolEnded = true;
|
|
232
|
+
}
|
|
233
|
+
// Check if this is a permission error (including ownership issues)
|
|
234
|
+
if (errMsg.includes('permission denied') || errMsg.includes('CREATE') || errMsg.includes('must be owner')) {
|
|
235
|
+
logger.warn({ error: errMsg }, 'Permission/ownership error during schema init - attempting auto-fix...');
|
|
236
|
+
// HIGH-19 FIX: Recreate pool if it was ended
|
|
237
|
+
if (poolEnded) {
|
|
238
|
+
this.pool = this.createPool();
|
|
239
|
+
this.setupPoolEvents();
|
|
240
|
+
poolEnded = false;
|
|
241
|
+
}
|
|
242
|
+
// Try to fix permissions automatically
|
|
243
|
+
const fixed = await this.autoFixDatabasePermissions();
|
|
244
|
+
if (fixed) {
|
|
245
|
+
logger.info('Permissions fixed, retrying schema initialization...');
|
|
246
|
+
await this.initializeProjectSchemaIsolation();
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
throw schemaError; // Re-throw if we couldn't fix
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
throw schemaError; // Not a permission error, re-throw
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// NOW acquire client - it will have search_path set from on('connect') hook
|
|
257
|
+
const client = await this.pool.connect();
|
|
258
|
+
try {
|
|
259
|
+
await client.query('SELECT 1');
|
|
260
|
+
// Extensions must be in public schema
|
|
261
|
+
await this.ensureExtensions(client);
|
|
262
|
+
// Create tables in the project schema
|
|
263
|
+
try {
|
|
264
|
+
await this.ensureSchema(client);
|
|
265
|
+
}
|
|
266
|
+
catch (ensureError) {
|
|
267
|
+
const errMsg = ensureError instanceof Error ? ensureError.message : String(ensureError);
|
|
268
|
+
// Check if this is an ownership error
|
|
269
|
+
if (errMsg.includes('must be owner') || errMsg.includes('permission denied')) {
|
|
270
|
+
logger.warn({ error: errMsg }, 'Ownership/permission error during ensureSchema - attempting auto-fix...');
|
|
271
|
+
const fixed = await this.autoFixDatabasePermissions();
|
|
272
|
+
if (fixed) {
|
|
273
|
+
logger.info('Permissions/ownership fixed, retrying ensureSchema...');
|
|
274
|
+
await this.ensureSchema(client); // Retry after fix
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
throw ensureError; // Re-throw if we couldn't fix
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
throw ensureError; // Not a permission/ownership error, re-throw
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// CRITICAL: Run migrations to create code_definitions and other tables
|
|
285
|
+
// ensureSchema only creates basic tables - migrations add the rest
|
|
286
|
+
try {
|
|
287
|
+
logger.info('Running database migrations for code_definitions and other tables...');
|
|
288
|
+
// BigBrainMigrations needs pool-like object with queryWithSwag and transactionGang
|
|
289
|
+
const self = this;
|
|
290
|
+
const poolAdapter = {
|
|
291
|
+
queryWithSwag: async (sql, params) => self.query(sql, params),
|
|
292
|
+
transactionGang: async (callback) => {
|
|
293
|
+
// Run callback in a transaction
|
|
294
|
+
const poolClient = await self.pool.connect();
|
|
295
|
+
try {
|
|
296
|
+
await poolClient.query('BEGIN');
|
|
297
|
+
// Create a client-like wrapper for the callback
|
|
298
|
+
const clientWrapper = {
|
|
299
|
+
query: (sql, params) => poolClient.query(sql, params)
|
|
300
|
+
};
|
|
301
|
+
await callback(clientWrapper);
|
|
302
|
+
await poolClient.query('COMMIT');
|
|
303
|
+
}
|
|
304
|
+
catch (err) {
|
|
305
|
+
await poolClient.query('ROLLBACK');
|
|
306
|
+
throw err;
|
|
307
|
+
}
|
|
308
|
+
finally {
|
|
309
|
+
poolClient.release();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
const migrations = new BigBrainMigrations(poolAdapter);
|
|
314
|
+
await migrations.runAllMigrations();
|
|
315
|
+
logger.info('Migrations complete - code_definitions table should now exist');
|
|
316
|
+
}
|
|
317
|
+
catch (migrationError) {
|
|
318
|
+
const errMsg = migrationError instanceof Error ? migrationError.message : String(migrationError);
|
|
319
|
+
// Log ALL migration errors for debugging
|
|
320
|
+
logger.error({ error: errMsg, stack: migrationError?.stack }, 'Migration error');
|
|
321
|
+
}
|
|
322
|
+
this.isInitialized = true;
|
|
323
|
+
this.startHealthCheck();
|
|
324
|
+
logger.info({
|
|
325
|
+
schema: this.currentSchema,
|
|
326
|
+
projectPath: process.env['SPECMEM_PROJECT_PATH'] || 'default'
|
|
327
|
+
}, 'Database initialized successfully with project schema isolation');
|
|
328
|
+
}
|
|
329
|
+
finally {
|
|
330
|
+
// HIGH-19 FIX: Only release client if pool wasn't ended during error handling
|
|
331
|
+
if (!poolEnded) {
|
|
332
|
+
try {
|
|
333
|
+
client.release();
|
|
334
|
+
}
|
|
335
|
+
catch (releaseErr) {
|
|
336
|
+
// Pool might have been ended - this is expected in some error paths
|
|
337
|
+
logger.debug({ releaseErr }, 'client.release() failed - pool may have been ended');
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Attempt to automatically fix database permissions.
|
|
344
|
+
* Uses sudo to grant necessary privileges via postgres superuser.
|
|
345
|
+
*
|
|
346
|
+
* This handles the case where specmem was installed but permissions
|
|
347
|
+
* weren't properly set up, or when running multi-project isolation
|
|
348
|
+
* for the first time.
|
|
349
|
+
*/
|
|
350
|
+
async autoFixDatabasePermissions() {
|
|
351
|
+
const { execSync } = await import('child_process');
|
|
352
|
+
const dbName = this.config.database;
|
|
353
|
+
const userName = this.config.user;
|
|
354
|
+
logger.info({ dbName, userName }, 'Auto-fixing database permissions...');
|
|
355
|
+
try {
|
|
356
|
+
// Grant all privileges on the database
|
|
357
|
+
execSync(`sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE ${dbName} TO ${userName};" 2>/dev/null`, {
|
|
358
|
+
stdio: 'pipe',
|
|
359
|
+
timeout: 10000
|
|
360
|
+
});
|
|
361
|
+
// Grant CREATE permission (needed for schema creation)
|
|
362
|
+
execSync(`sudo -u postgres psql -d ${dbName} -c "GRANT CREATE ON DATABASE ${dbName} TO ${userName};" 2>/dev/null`, {
|
|
363
|
+
stdio: 'pipe',
|
|
364
|
+
timeout: 10000
|
|
365
|
+
});
|
|
366
|
+
// Grant schema privileges
|
|
367
|
+
execSync(`sudo -u postgres psql -d ${dbName} -c "GRANT ALL ON SCHEMA public TO ${userName};" 2>/dev/null`, {
|
|
368
|
+
stdio: 'pipe',
|
|
369
|
+
timeout: 10000
|
|
370
|
+
});
|
|
371
|
+
// Grant CREATEDB for multi-project isolation
|
|
372
|
+
execSync(`sudo -u postgres psql -c "ALTER USER ${userName} CREATEDB;" 2>/dev/null`, {
|
|
373
|
+
stdio: 'pipe',
|
|
374
|
+
timeout: 10000
|
|
375
|
+
});
|
|
376
|
+
// Grant ALL on ALL tables in public schema (for existing tables)
|
|
377
|
+
execSync(`sudo -u postgres psql -d ${dbName} -c "GRANT ALL ON ALL TABLES IN SCHEMA public TO ${userName};" 2>/dev/null`, {
|
|
378
|
+
stdio: 'pipe',
|
|
379
|
+
timeout: 10000
|
|
380
|
+
});
|
|
381
|
+
// Grant ALL on ALL sequences (needed for serial/identity columns)
|
|
382
|
+
execSync(`sudo -u postgres psql -d ${dbName} -c "GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO ${userName};" 2>/dev/null`, {
|
|
383
|
+
stdio: 'pipe',
|
|
384
|
+
timeout: 10000
|
|
385
|
+
});
|
|
386
|
+
// Set default privileges for future tables
|
|
387
|
+
execSync(`sudo -u postgres psql -d ${dbName} -c "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO ${userName};" 2>/dev/null`, {
|
|
388
|
+
stdio: 'pipe',
|
|
389
|
+
timeout: 10000
|
|
390
|
+
});
|
|
391
|
+
execSync(`sudo -u postgres psql -d ${dbName} -c "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO ${userName};" 2>/dev/null`, {
|
|
392
|
+
stdio: 'pipe',
|
|
393
|
+
timeout: 10000
|
|
394
|
+
});
|
|
395
|
+
// CRITICAL: Reassign ownership of ALL tables to specmem user
|
|
396
|
+
// This is required for DDL operations (ALTER TABLE) during schema migrations
|
|
397
|
+
execSync(`sudo -u postgres psql -d ${dbName} -c "DO \\$\\$ DECLARE r RECORD; BEGIN FOR r IN SELECT tablename FROM pg_tables WHERE schemaname = 'public' LOOP EXECUTE 'ALTER TABLE public.' || quote_ident(r.tablename) || ' OWNER TO ${userName}'; END LOOP; END \\$\\$;" 2>/dev/null`, {
|
|
398
|
+
stdio: 'pipe',
|
|
399
|
+
timeout: 30000
|
|
400
|
+
});
|
|
401
|
+
// Reassign ownership of ALL sequences to specmem user
|
|
402
|
+
execSync(`sudo -u postgres psql -d ${dbName} -c "DO \\$\\$ DECLARE r RECORD; BEGIN FOR r IN SELECT sequencename FROM pg_sequences WHERE schemaname = 'public' LOOP EXECUTE 'ALTER SEQUENCE public.' || quote_ident(r.sequencename) || ' OWNER TO ${userName}'; END LOOP; END \\$\\$;" 2>/dev/null`, {
|
|
403
|
+
stdio: 'pipe',
|
|
404
|
+
timeout: 30000
|
|
405
|
+
});
|
|
406
|
+
// Set default owner for future objects created by postgres
|
|
407
|
+
execSync(`sudo -u postgres psql -d ${dbName} -c "ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO ${userName};" 2>/dev/null`, {
|
|
408
|
+
stdio: 'pipe',
|
|
409
|
+
timeout: 10000
|
|
410
|
+
});
|
|
411
|
+
logger.info('Database permissions AND ownership fixed successfully');
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
catch (err) {
|
|
415
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
416
|
+
logger.warn({ error: errMsg }, 'Auto-fix failed - may need manual permission setup. Run: sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE specmem_westayunprofessional TO specmem_westayunprofessional; ALTER USER specmem_westayunprofessional CREATEDB;"');
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Initialize project schema isolation.
|
|
422
|
+
* Creates the project-specific schema and sets search_path.
|
|
423
|
+
*
|
|
424
|
+
* This enables multi-instance support where each project has its own
|
|
425
|
+
* isolated set of tables within a PostgreSQL schema.
|
|
426
|
+
*/
|
|
427
|
+
async initializeProjectSchemaIsolation() {
|
|
428
|
+
const projectPath = process.env['SPECMEM_PROJECT_PATH'];
|
|
429
|
+
const schemaName = getProjectSchema(projectPath);
|
|
430
|
+
logger.info({
|
|
431
|
+
schemaName,
|
|
432
|
+
projectPath: projectPath || 'default'
|
|
433
|
+
}, 'Initializing project schema isolation');
|
|
434
|
+
// Create schema if it doesn't exist
|
|
435
|
+
const created = await createProjectSchema(this, schemaName);
|
|
436
|
+
if (created) {
|
|
437
|
+
logger.info({ schemaName }, 'Created new project schema');
|
|
438
|
+
}
|
|
439
|
+
// Set currentSchema FIRST so on('connect') handler can use it for new connections
|
|
440
|
+
// This ensures ANY new connections created during initialization get correct search_path
|
|
441
|
+
this.currentSchema = schemaName;
|
|
442
|
+
// Set search_path to use the project schema first, then public
|
|
443
|
+
await setProjectSearchPath(this, schemaName);
|
|
444
|
+
// CRITICAL: Initialize tables in the schema
|
|
445
|
+
// This runs projectSchemaInit.sql to create memories, code_pointers, etc.
|
|
446
|
+
await initializeProjectSchema(this, projectPath);
|
|
447
|
+
logger.debug({ schemaName }, 'Project schema isolation configured with tables');
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Ensure search_path is set for a specific connection.
|
|
451
|
+
* CRITICAL: Call this when you need to GUARANTEE schema isolation for a query.
|
|
452
|
+
* The pool.on('connect') handler is fire-and-forget, so this must be called
|
|
453
|
+
* explicitly before any query that requires the correct schema.
|
|
454
|
+
*
|
|
455
|
+
* @param client - Optional pg.PoolClient to set path on, uses pool if not provided
|
|
456
|
+
*/
|
|
457
|
+
async ensureSearchPath(client) {
|
|
458
|
+
const schemaName = this.currentSchema || getProjectSchema();
|
|
459
|
+
// Use quoted identifier format for safety - prevents SQL injection
|
|
460
|
+
const safeSchema = '"' + schemaName.replace(/"/g, '""') + '"';
|
|
461
|
+
if (client) {
|
|
462
|
+
await client.query('SET search_path TO ' + safeSchema + ', public');
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
await this.query('SET search_path TO ' + safeSchema + ', public');
|
|
466
|
+
}
|
|
467
|
+
logger.trace({ schemaName }, 'search_path explicitly set');
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Check if database has been initialized
|
|
471
|
+
* Used by startup timing to avoid double-init
|
|
472
|
+
*/
|
|
473
|
+
isConnected() {
|
|
474
|
+
return this.isInitialized;
|
|
475
|
+
}
|
|
476
|
+
async ensureExtensions(client) {
|
|
477
|
+
await client.query('CREATE EXTENSION IF NOT EXISTS vector');
|
|
478
|
+
await client.query('CREATE EXTENSION IF NOT EXISTS pg_trgm');
|
|
479
|
+
await client.query('CREATE EXTENSION IF NOT EXISTS btree_gin');
|
|
480
|
+
}
|
|
481
|
+
async ensureSchema(client) {
|
|
482
|
+
// CRITICAL: Ensure search_path is set BEFORE any DDL operations
|
|
483
|
+
// The pool's on('connect') handler is async and may not complete before this runs
|
|
484
|
+
// Without this, tables may be created in 'public' schema instead of project schema
|
|
485
|
+
await this.ensureSearchPath(client);
|
|
486
|
+
await client.query(`
|
|
487
|
+
DO $$ BEGIN
|
|
488
|
+
CREATE TYPE memory_type AS ENUM ('episodic', 'semantic', 'procedural', 'working', 'consolidated');
|
|
489
|
+
EXCEPTION WHEN duplicate_object THEN NULL;
|
|
490
|
+
END $$
|
|
491
|
+
`);
|
|
492
|
+
await client.query(`
|
|
493
|
+
DO $$ BEGIN
|
|
494
|
+
CREATE TYPE importance_level AS ENUM ('critical', 'high', 'medium', 'low', 'trivial');
|
|
495
|
+
EXCEPTION WHEN duplicate_object THEN NULL;
|
|
496
|
+
END $$
|
|
497
|
+
`);
|
|
498
|
+
// Create immutable SHA256 helper function for GENERATED ALWAYS columns
|
|
499
|
+
// sha256() alone is not marked IMMUTABLE in PostgreSQL, so we wrap it
|
|
500
|
+
await client.query(`
|
|
501
|
+
CREATE OR REPLACE FUNCTION content_sha256(text) RETURNS varchar(64) AS $$
|
|
502
|
+
SELECT encode(sha256(convert_to($1, 'UTF8')), 'hex')
|
|
503
|
+
$$ LANGUAGE SQL IMMUTABLE STRICT
|
|
504
|
+
`);
|
|
505
|
+
// Check if memories table already exists and get its current dimension
|
|
506
|
+
const existingDim = await this.getTableDimension('memories');
|
|
507
|
+
if (existingDim !== null) {
|
|
508
|
+
// Table exists with a dimension - ensure all columns exist (schema migrations)
|
|
509
|
+
logger.debug({ existingDim }, 'memories table already exists with vector dimension');
|
|
510
|
+
// Auto-add missing columns that may have been added in newer versions
|
|
511
|
+
// Note: Cannot add NOT NULL columns without defaults via ALTER TABLE to existing data
|
|
512
|
+
// Note: Cannot add GENERATED ALWAYS columns via simple ALTER TABLE (would need complex migration)
|
|
513
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS memory_type memory_type DEFAULT 'semantic'`);
|
|
514
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS importance importance_level DEFAULT 'medium'`);
|
|
515
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS tags TEXT[] DEFAULT '{}'`);
|
|
516
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS metadata JSONB DEFAULT '{}'`);
|
|
517
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS embedding vector(384)`);
|
|
518
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS image_data BYTEA`);
|
|
519
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS image_mime_type VARCHAR(50)`);
|
|
520
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ DEFAULT NOW()`);
|
|
521
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ DEFAULT NOW()`);
|
|
522
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS access_count INTEGER DEFAULT 0`);
|
|
523
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS last_accessed_at TIMESTAMPTZ`);
|
|
524
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS expires_at TIMESTAMPTZ`);
|
|
525
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS consolidated_from UUID[] DEFAULT '{}'`);
|
|
526
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS role VARCHAR(20)`);
|
|
527
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS project_path TEXT`);
|
|
528
|
+
// Add content_hash GENERATED column if missing (required for dedup, inserts, and search)
|
|
529
|
+
// GENERATED ALWAYS columns can be added via ALTER TABLE in PostgreSQL 12+
|
|
530
|
+
try {
|
|
531
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS content_hash VARCHAR(64) GENERATED ALWAYS AS (content_sha256(content)) STORED`);
|
|
532
|
+
} catch (hashErr) {
|
|
533
|
+
// If GENERATED ALWAYS fails (e.g. column exists as non-generated), try plain column
|
|
534
|
+
if (!hashErr.message.includes('already exists')) {
|
|
535
|
+
logger.warn({ err: hashErr }, 'Could not add content_hash as GENERATED column, trying plain VARCHAR');
|
|
536
|
+
try {
|
|
537
|
+
await client.query(`ALTER TABLE memories ADD COLUMN IF NOT EXISTS content_hash VARCHAR(64)`);
|
|
538
|
+
} catch (e2) { /* column likely already exists */ }
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
logger.info('Ensured all required columns exist in memories table');
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
// Table doesn't exist - create with a placeholder dimension
|
|
545
|
+
// The actual dimension will be set on first embedding insert
|
|
546
|
+
// Using a function to defer dimension until first use
|
|
547
|
+
await client.query(`
|
|
548
|
+
CREATE TABLE IF NOT EXISTS memories (
|
|
549
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
550
|
+
content TEXT NOT NULL,
|
|
551
|
+
content_hash VARCHAR(64) GENERATED ALWAYS AS (content_sha256(content)) STORED,
|
|
552
|
+
content_tsv TSVECTOR GENERATED ALWAYS AS (to_tsvector('english', content)) STORED,
|
|
553
|
+
memory_type memory_type NOT NULL DEFAULT 'semantic',
|
|
554
|
+
importance importance_level NOT NULL DEFAULT 'medium',
|
|
555
|
+
tags TEXT[] NOT NULL DEFAULT '{}',
|
|
556
|
+
metadata JSONB DEFAULT '{}',
|
|
557
|
+
embedding vector(384),
|
|
558
|
+
image_data BYTEA,
|
|
559
|
+
image_mime_type VARCHAR(50),
|
|
560
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
561
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
562
|
+
access_count INTEGER NOT NULL DEFAULT 0,
|
|
563
|
+
last_accessed_at TIMESTAMPTZ,
|
|
564
|
+
expires_at TIMESTAMPTZ,
|
|
565
|
+
consolidated_from UUID[] DEFAULT '{}',
|
|
566
|
+
role VARCHAR(20),
|
|
567
|
+
project_path TEXT,
|
|
568
|
+
CONSTRAINT content_length CHECK (length(content) <= 1000000),
|
|
569
|
+
CONSTRAINT valid_image CHECK (
|
|
570
|
+
(image_data IS NULL AND image_mime_type IS NULL) OR
|
|
571
|
+
(image_data IS NOT NULL AND image_mime_type IS NOT NULL)
|
|
572
|
+
)
|
|
573
|
+
)
|
|
574
|
+
`);
|
|
575
|
+
logger.info('Created memories table with unbounded vector column (will be set on first insert)');
|
|
576
|
+
}
|
|
577
|
+
await client.query(`
|
|
578
|
+
CREATE TABLE IF NOT EXISTS memory_relations (
|
|
579
|
+
source_id UUID NOT NULL REFERENCES memories(id) ON DELETE CASCADE,
|
|
580
|
+
target_id UUID NOT NULL REFERENCES memories(id) ON DELETE CASCADE,
|
|
581
|
+
relation_type VARCHAR(50) DEFAULT 'related',
|
|
582
|
+
strength FLOAT DEFAULT 1.0,
|
|
583
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
584
|
+
PRIMARY KEY (source_id, target_id),
|
|
585
|
+
CONSTRAINT no_self_relation CHECK (source_id != target_id)
|
|
586
|
+
)
|
|
587
|
+
`);
|
|
588
|
+
// Auto-add missing columns to memory_relations table (schema migration support)
|
|
589
|
+
// Note: source_id and target_id are part of PRIMARY KEY, cannot be added via ALTER TABLE
|
|
590
|
+
await client.query(`ALTER TABLE memory_relations ADD COLUMN IF NOT EXISTS relation_type VARCHAR(50) DEFAULT 'related'`);
|
|
591
|
+
await client.query(`ALTER TABLE memory_relations ADD COLUMN IF NOT EXISTS strength FLOAT DEFAULT 1.0`);
|
|
592
|
+
await client.query(`ALTER TABLE memory_relations ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ DEFAULT NOW()`);
|
|
593
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_content_hash ON memories(content_hash)`);
|
|
594
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_embedding ON memories USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100)`);
|
|
595
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_content_tsv ON memories USING gin(content_tsv)`);
|
|
596
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_tags ON memories USING gin(tags)`);
|
|
597
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(memory_type)`);
|
|
598
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_importance ON memories(importance)`);
|
|
599
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_created ON memories(created_at DESC)`);
|
|
600
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_expires ON memories(expires_at) WHERE expires_at IS NOT NULL`);
|
|
601
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_access ON memories(last_accessed_at DESC NULLS LAST)`);
|
|
602
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memory_relations_target ON memory_relations(target_id)`);
|
|
603
|
+
// HIGH-09 FIX: Add missing project_path index - this column was added but never indexed
|
|
604
|
+
// Critical for cross-project queries and filtering by project
|
|
605
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_project_path ON memories(project_path)`);
|
|
606
|
+
// Composite indexes for common project_path query patterns
|
|
607
|
+
// These optimize the most frequent query combinations
|
|
608
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_project_path_created ON memories(project_path, created_at DESC)`);
|
|
609
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_project_path_importance ON memories(project_path, importance)`);
|
|
610
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_project_path_type ON memories(project_path, memory_type)`);
|
|
611
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_memories_project_path_hash ON memories(project_path, content_hash)`);
|
|
612
|
+
await client.query(`
|
|
613
|
+
CREATE OR REPLACE FUNCTION update_modified_column()
|
|
614
|
+
RETURNS TRIGGER AS $$
|
|
615
|
+
BEGIN
|
|
616
|
+
NEW.updated_at = NOW();
|
|
617
|
+
RETURN NEW;
|
|
618
|
+
END;
|
|
619
|
+
$$ LANGUAGE plpgsql
|
|
620
|
+
`);
|
|
621
|
+
await client.query(`
|
|
622
|
+
DO $$ BEGIN
|
|
623
|
+
CREATE TRIGGER memories_updated_at
|
|
624
|
+
BEFORE UPDATE ON memories
|
|
625
|
+
FOR EACH ROW
|
|
626
|
+
EXECUTE FUNCTION update_modified_column();
|
|
627
|
+
EXCEPTION WHEN duplicate_object THEN NULL;
|
|
628
|
+
END $$
|
|
629
|
+
`);
|
|
630
|
+
// AUTO-ADD project_path to codebase_files if table exists but column is missing
|
|
631
|
+
// This fixes find_code_pointers "column project_path does not exist" error
|
|
632
|
+
try {
|
|
633
|
+
const cbfExists = await client.query(`SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'codebase_files' AND table_schema = current_schema()) as exists`);
|
|
634
|
+
if (cbfExists.rows[0]?.exists) {
|
|
635
|
+
await client.query(`ALTER TABLE codebase_files ADD COLUMN IF NOT EXISTS project_path VARCHAR(500) DEFAULT '/'`);
|
|
636
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_codebase_files_project_path ON codebase_files(project_path)`);
|
|
637
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_codebase_files_project_path_file ON codebase_files(project_path, file_path)`);
|
|
638
|
+
}
|
|
639
|
+
} catch (cbfErr) {
|
|
640
|
+
// Ignore - table may not exist yet, migrations will create it
|
|
641
|
+
}
|
|
642
|
+
// AUTO-ADD project_path to code_dependencies if table exists but column is missing
|
|
643
|
+
try {
|
|
644
|
+
const cdExists = await client.query(`SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'code_dependencies' AND table_schema = current_schema()) as exists`);
|
|
645
|
+
if (cdExists.rows[0]?.exists) {
|
|
646
|
+
await client.query(`ALTER TABLE code_dependencies ADD COLUMN IF NOT EXISTS project_path VARCHAR(500) DEFAULT '/'`);
|
|
647
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_code_dependencies_project_path ON code_dependencies(project_path)`);
|
|
648
|
+
}
|
|
649
|
+
} catch (cdErr) {
|
|
650
|
+
// Ignore
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
startHealthCheck() {
|
|
654
|
+
this.healthCheckInterval = setInterval(async () => {
|
|
655
|
+
try {
|
|
656
|
+
await this.pool.query('SELECT 1');
|
|
657
|
+
}
|
|
658
|
+
catch (err) {
|
|
659
|
+
logger.error({ err }, 'Health check failed');
|
|
660
|
+
}
|
|
661
|
+
}, 30_000);
|
|
662
|
+
}
|
|
663
|
+
async query(text, params) {
|
|
664
|
+
const queryId = this.generateQueryId();
|
|
665
|
+
const queryType = this.detectQueryType(text);
|
|
666
|
+
const tableName = this.extractTableName(text);
|
|
667
|
+
// Get coordinator lazily to avoid circular dependency during initialization
|
|
668
|
+
let coordinator = null;
|
|
669
|
+
try {
|
|
670
|
+
coordinator = getCoordinator();
|
|
671
|
+
}
|
|
672
|
+
catch (e) {
|
|
673
|
+
// Coordinator not yet initialized - skip events, this is expected during startup
|
|
674
|
+
}
|
|
675
|
+
// Emit db:query:start event via LWJEB
|
|
676
|
+
coordinator?.emitDBQueryStart(queryId, queryType, tableName);
|
|
677
|
+
const start = Date.now();
|
|
678
|
+
let success = true;
|
|
679
|
+
let errorMsg;
|
|
680
|
+
let rowsAffected;
|
|
681
|
+
try {
|
|
682
|
+
const result = await this.pool.query(text, params);
|
|
683
|
+
rowsAffected = result.rowCount ?? undefined;
|
|
684
|
+
const duration = Date.now() - start;
|
|
685
|
+
// Emit db:query:complete event via LWJEB
|
|
686
|
+
coordinator?.emitDBQueryComplete(queryId, queryType, duration, true, rowsAffected);
|
|
687
|
+
// Slow query threshold configurable via SPECMEM_SLOW_QUERY_MS (default 500ms)
|
|
688
|
+
const slowQueryThreshold = parseInt(process.env['SPECMEM_SLOW_QUERY_MS'] || '500', 10);
|
|
689
|
+
if (duration > slowQueryThreshold) {
|
|
690
|
+
logger.warn({ duration, threshold: slowQueryThreshold, query: text.slice(0, 100) }, 'Slow query detected fr fr');
|
|
691
|
+
}
|
|
692
|
+
// Debug logging for all queries when enabled
|
|
693
|
+
getDebugLogger().dbQuery(text, duration, true);
|
|
694
|
+
return result;
|
|
695
|
+
}
|
|
696
|
+
catch (error) {
|
|
697
|
+
success = false;
|
|
698
|
+
errorMsg = error instanceof Error ? error.message : String(error);
|
|
699
|
+
const duration = Date.now() - start;
|
|
700
|
+
// Emit db:query:complete event with error via LWJEB
|
|
701
|
+
coordinator?.emitDBQueryComplete(queryId, queryType, duration, false, undefined, errorMsg);
|
|
702
|
+
throw error;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Execute query with GUARANTEED schema isolation.
|
|
707
|
+
* Use this for queries where schema isolation is critical and cannot risk the
|
|
708
|
+
* pool.on('connect') race condition.
|
|
709
|
+
*
|
|
710
|
+
* This acquires a dedicated client, sets search_path, runs the query, and releases.
|
|
711
|
+
* Slightly more expensive than query() but guarantees correct schema.
|
|
712
|
+
*/
|
|
713
|
+
async safeQuery(text, params) {
|
|
714
|
+
const client = await this.pool.connect();
|
|
715
|
+
try {
|
|
716
|
+
await this.ensureSearchPath(client);
|
|
717
|
+
return await client.query(text, params);
|
|
718
|
+
}
|
|
719
|
+
finally {
|
|
720
|
+
client.release();
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
async transaction(callback) {
|
|
724
|
+
const queryId = this.generateQueryId();
|
|
725
|
+
// Get coordinator lazily to avoid circular dependency during initialization
|
|
726
|
+
let coordinator = null;
|
|
727
|
+
try {
|
|
728
|
+
coordinator = getCoordinator();
|
|
729
|
+
}
|
|
730
|
+
catch (e) {
|
|
731
|
+
// Coordinator not yet initialized - skip events, this is expected during startup
|
|
732
|
+
}
|
|
733
|
+
// Emit db:query:start event for transaction via LWJEB
|
|
734
|
+
coordinator?.emitDBQueryStart(queryId, 'TRANSACTION', undefined);
|
|
735
|
+
const start = Date.now();
|
|
736
|
+
const client = await this.pool.connect();
|
|
737
|
+
try {
|
|
738
|
+
// SCHEMA ISOLATION FIX: Ensure search_path BEFORE BEGIN to guarantee correct schema
|
|
739
|
+
await this.ensureSearchPath(client);
|
|
740
|
+
await client.query('BEGIN');
|
|
741
|
+
const result = await callback(client);
|
|
742
|
+
await client.query('COMMIT');
|
|
743
|
+
const duration = Date.now() - start;
|
|
744
|
+
// Emit db:query:complete event for transaction via LWJEB
|
|
745
|
+
coordinator?.emitDBQueryComplete(queryId, 'TRANSACTION', duration, true);
|
|
746
|
+
return result;
|
|
747
|
+
}
|
|
748
|
+
catch (err) {
|
|
749
|
+
// HIGH-07 FIX: Wrap ROLLBACK in try-catch to preserve original error
|
|
750
|
+
// If ROLLBACK throws, we still want to surface the original error that caused it
|
|
751
|
+
try {
|
|
752
|
+
await client.query('ROLLBACK');
|
|
753
|
+
}
|
|
754
|
+
catch (rollbackErr) {
|
|
755
|
+
// Log rollback error separately but don't let it mask the original error
|
|
756
|
+
logger.error({ rollbackErr, originalErr: err instanceof Error ? err.message : String(err) }, 'ROLLBACK failed - original error preserved, this is double cooked fr');
|
|
757
|
+
}
|
|
758
|
+
const duration = Date.now() - start;
|
|
759
|
+
// Emit db:query:complete event for failed transaction via LWJEB
|
|
760
|
+
coordinator?.emitDBQueryComplete(queryId, 'TRANSACTION', duration, false, undefined, err instanceof Error ? err.message : String(err));
|
|
761
|
+
throw err;
|
|
762
|
+
}
|
|
763
|
+
finally {
|
|
764
|
+
client.release();
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
async batchInsert(memories) {
|
|
768
|
+
if (memories.length === 0)
|
|
769
|
+
return [];
|
|
770
|
+
// Get the current table dimension (may be null if unbounded or table doesn't exist)
|
|
771
|
+
const tableDim = await this.getTableDimension('memories');
|
|
772
|
+
const dimService = this.getDimensionService();
|
|
773
|
+
// Find the first memory with an embedding to determine expected dimension
|
|
774
|
+
const firstWithEmbedding = memories.find(m => m.embedding && m.embedding.length > 0);
|
|
775
|
+
const expectedDim = firstWithEmbedding?.embedding?.length;
|
|
776
|
+
// If table is unbounded and we have embeddings, set the dimension now
|
|
777
|
+
if (tableDim === null && expectedDim !== undefined) {
|
|
778
|
+
await this.alterVectorColumnDimension('memories', 'embedding', expectedDim);
|
|
779
|
+
logger.info({ dimension: expectedDim }, 'Set memories table vector dimension from first embedding');
|
|
780
|
+
}
|
|
781
|
+
const ids = [];
|
|
782
|
+
const batchSize = 500;
|
|
783
|
+
for (let i = 0; i < memories.length; i += batchSize) {
|
|
784
|
+
const batch = memories.slice(i, i + batchSize);
|
|
785
|
+
const batchIds = await this.transaction(async (client) => {
|
|
786
|
+
const insertedIds = [];
|
|
787
|
+
for (const memory of batch) {
|
|
788
|
+
// Prepare embedding with automatic dimension projection if needed
|
|
789
|
+
let embeddingStr = null;
|
|
790
|
+
if (memory.embedding && memory.embedding.length > 0) {
|
|
791
|
+
try {
|
|
792
|
+
const prepared = await dimService.validateAndPrepare('memories', memory.embedding, memory.content);
|
|
793
|
+
if (prepared.wasModified) {
|
|
794
|
+
logger.debug({
|
|
795
|
+
action: prepared.action,
|
|
796
|
+
originalDim: memory.embedding.length,
|
|
797
|
+
newDim: prepared.embedding.length
|
|
798
|
+
}, 'Projected memory embedding to target dimension');
|
|
799
|
+
}
|
|
800
|
+
embeddingStr = `[${prepared.embedding.join(',')}]`;
|
|
801
|
+
}
|
|
802
|
+
catch (error) {
|
|
803
|
+
// Fallback to original embedding if projection fails
|
|
804
|
+
logger.warn({ error }, 'Failed to prepare embedding, using original');
|
|
805
|
+
embeddingStr = `[${memory.embedding.join(',')}]`;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
const id = uuidv4();
|
|
809
|
+
// PROJECT ISOLATION: Get fresh project path at call time
|
|
810
|
+
const projectPath = getProjectPathForInsert();
|
|
811
|
+
await client.query(`INSERT INTO memories (id, content, memory_type, importance, tags, metadata, embedding, image_data, image_mime_type, expires_at, project_path)
|
|
812
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)`, [
|
|
813
|
+
id,
|
|
814
|
+
memory.content,
|
|
815
|
+
memory.memoryType,
|
|
816
|
+
memory.importance,
|
|
817
|
+
memory.tags,
|
|
818
|
+
memory.metadata ?? {},
|
|
819
|
+
embeddingStr,
|
|
820
|
+
memory.imageData ? Buffer.from(memory.imageData, 'base64') : null,
|
|
821
|
+
memory.imageMimeType ?? null,
|
|
822
|
+
memory.expiresAt ?? null,
|
|
823
|
+
projectPath
|
|
824
|
+
]);
|
|
825
|
+
insertedIds.push(id);
|
|
826
|
+
}
|
|
827
|
+
return insertedIds;
|
|
828
|
+
});
|
|
829
|
+
ids.push(...batchIds);
|
|
830
|
+
}
|
|
831
|
+
return ids;
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Alter a vector column's dimension dynamically.
|
|
835
|
+
* This will fail if there are existing embeddings with different dimensions.
|
|
836
|
+
*
|
|
837
|
+
* @param tableName - Table containing the vector column
|
|
838
|
+
* @param columnName - Name of the vector column
|
|
839
|
+
* @param dimension - New dimension to set
|
|
840
|
+
*/
|
|
841
|
+
async alterVectorColumnDimension(tableName, columnName, dimension) {
|
|
842
|
+
// Validate dimension is reasonable
|
|
843
|
+
if (dimension < 1 || dimension > 10000) {
|
|
844
|
+
throw new Error(`Invalid dimension ${dimension}: must be between 1 and 10000`);
|
|
845
|
+
}
|
|
846
|
+
try {
|
|
847
|
+
await this.query(`ALTER TABLE ${tableName} ALTER COLUMN ${columnName} TYPE vector(${dimension})`);
|
|
848
|
+
logger.info({ tableName, columnName, dimension }, 'Altered vector column dimension');
|
|
849
|
+
// Invalidate dimension cache
|
|
850
|
+
this.getDimensionService().invalidateTable(tableName);
|
|
851
|
+
}
|
|
852
|
+
catch (error) {
|
|
853
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
854
|
+
logger.error({ error: errMsg, tableName, columnName, dimension }, 'Failed to alter vector column dimension');
|
|
855
|
+
throw error;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
async getStats() {
|
|
859
|
+
return {
|
|
860
|
+
total: this.pool.totalCount,
|
|
861
|
+
idle: this.pool.idleCount,
|
|
862
|
+
waiting: this.pool.waitingCount
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Get detailed pool metrics for /api/metrics/database endpoint
|
|
867
|
+
*/
|
|
868
|
+
async getDetailedMetrics() {
|
|
869
|
+
return {
|
|
870
|
+
pool: await this.getStats(),
|
|
871
|
+
config: {
|
|
872
|
+
maxConnections: this.config.maxConnections,
|
|
873
|
+
idleTimeout: this.config.idleTimeout,
|
|
874
|
+
connectionTimeout: this.config.connectionTimeout
|
|
875
|
+
},
|
|
876
|
+
health: {
|
|
877
|
+
isInitialized: this.isInitialized,
|
|
878
|
+
queryCount: this.queryCounter
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Get the embedding vector dimension for a table.
|
|
884
|
+
* Returns the actual dimension from pg_attribute (atttypmod for pgvector).
|
|
885
|
+
* Returns null if table doesn't exist or doesn't have an embedding column.
|
|
886
|
+
*/
|
|
887
|
+
async getTableDimension(tableName) {
|
|
888
|
+
try {
|
|
889
|
+
const result = await this.query(`SELECT atttypmod FROM pg_attribute
|
|
890
|
+
WHERE attrelid = $1::regclass AND attname = 'embedding'`, [tableName]);
|
|
891
|
+
if (result.rows.length === 0) {
|
|
892
|
+
logger.warn({ tableName }, 'Table has no embedding column');
|
|
893
|
+
return null;
|
|
894
|
+
}
|
|
895
|
+
const dim = result.rows[0].atttypmod;
|
|
896
|
+
logger.debug({ tableName, dimension: dim }, 'Detected table embedding dimension');
|
|
897
|
+
return dim;
|
|
898
|
+
}
|
|
899
|
+
catch (error) {
|
|
900
|
+
logger.error({ error, tableName }, 'Failed to get table dimension');
|
|
901
|
+
return null;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
async close() {
|
|
905
|
+
if (this.healthCheckInterval) {
|
|
906
|
+
clearInterval(this.healthCheckInterval);
|
|
907
|
+
}
|
|
908
|
+
await this.pool.end();
|
|
909
|
+
this.isInitialized = false;
|
|
910
|
+
logger.info('Database connection closed');
|
|
911
|
+
}
|
|
912
|
+
// ============================================
|
|
913
|
+
// PROJECT NAMESPACING HELPERS
|
|
914
|
+
// ============================================
|
|
915
|
+
/**
|
|
916
|
+
* Get the ProjectContext singleton for this database manager.
|
|
917
|
+
* Initializes the connection on first access.
|
|
918
|
+
*/
|
|
919
|
+
getProjectContext() {
|
|
920
|
+
const ctx = getProjectContext();
|
|
921
|
+
ctx.setDatabase(this);
|
|
922
|
+
return ctx;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Execute a query with automatic project_id filtering.
|
|
926
|
+
*
|
|
927
|
+
* Automatically adds project_id filter to WHERE clause:
|
|
928
|
+
* - If SQL has WHERE, adds "AND project_id = $N"
|
|
929
|
+
* - If SQL has no WHERE, adds "WHERE project_id = $N"
|
|
930
|
+
*
|
|
931
|
+
* @param sql - The SQL query (SELECT, UPDATE, or DELETE)
|
|
932
|
+
* @param params - Query parameters (project_id will be appended)
|
|
933
|
+
* @returns Query result with rows filtered by current project
|
|
934
|
+
*
|
|
935
|
+
* @example
|
|
936
|
+
* // Instead of:
|
|
937
|
+
* db.query('SELECT * FROM memories WHERE tags @> $1', [['important']]);
|
|
938
|
+
* // Use:
|
|
939
|
+
* db.queryWithProject('SELECT * FROM memories WHERE tags @> $1', [['important']]);
|
|
940
|
+
* // Becomes: SELECT * FROM memories WHERE tags @> $1 AND project_id = $2
|
|
941
|
+
*/
|
|
942
|
+
async queryWithProject(sql, params = []) {
|
|
943
|
+
const projectCtx = this.getProjectContext();
|
|
944
|
+
const projectId = await projectCtx.getProjectId();
|
|
945
|
+
// Clone params to avoid mutating the original
|
|
946
|
+
const newParams = [...params];
|
|
947
|
+
const paramIndex = newParams.length + 1;
|
|
948
|
+
newParams.push(projectId);
|
|
949
|
+
// Determine where to insert the project_id filter
|
|
950
|
+
const modifiedSql = this.addProjectFilter(sql, paramIndex);
|
|
951
|
+
logger.debug({
|
|
952
|
+
originalSql: sql.slice(0, 100),
|
|
953
|
+
modifiedSql: modifiedSql.slice(0, 150),
|
|
954
|
+
projectId
|
|
955
|
+
}, 'queryWithProject');
|
|
956
|
+
return this.query(modifiedSql, newParams);
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Insert a record with automatic project_id inclusion.
|
|
960
|
+
*
|
|
961
|
+
* Automatically adds project_id to the insert data.
|
|
962
|
+
*
|
|
963
|
+
* @param table - Table name to insert into
|
|
964
|
+
* @param data - Record data (project_id will be added automatically)
|
|
965
|
+
* @returns The inserted record with generated fields (id, created_at, etc.)
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* // Instead of:
|
|
969
|
+
* db.query('INSERT INTO memories (content, tags, project_id) VALUES ($1, $2, $3)', [content, tags, projectId]);
|
|
970
|
+
* // Use:
|
|
971
|
+
* db.insertWithProject('memories', { content, tags });
|
|
972
|
+
*/
|
|
973
|
+
async insertWithProject(table, data) {
|
|
974
|
+
const projectCtx = this.getProjectContext();
|
|
975
|
+
const projectId = await projectCtx.getProjectId();
|
|
976
|
+
// Add project_id to the data
|
|
977
|
+
const dataWithProject = { ...data, project_id: projectId };
|
|
978
|
+
// Build column and value lists
|
|
979
|
+
const columns = Object.keys(dataWithProject);
|
|
980
|
+
const values = Object.values(dataWithProject);
|
|
981
|
+
const placeholders = columns.map((_, i) => `$${i + 1}`);
|
|
982
|
+
const sql = `INSERT INTO ${table} (${columns.join(', ')}) VALUES (${placeholders.join(', ')}) RETURNING *`;
|
|
983
|
+
logger.debug({
|
|
984
|
+
table,
|
|
985
|
+
columns,
|
|
986
|
+
projectId
|
|
987
|
+
}, 'insertWithProject');
|
|
988
|
+
const result = await this.query(sql, values);
|
|
989
|
+
return result.rows[0];
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Update records with automatic project_id filtering.
|
|
993
|
+
*
|
|
994
|
+
* Ensures updates only affect records in the current project.
|
|
995
|
+
*
|
|
996
|
+
* @param table - Table name to update
|
|
997
|
+
* @param data - Fields to update
|
|
998
|
+
* @param whereClause - Additional WHERE conditions (e.g., "id = $1")
|
|
999
|
+
* @param whereParams - Parameters for the WHERE clause
|
|
1000
|
+
* @returns Number of rows affected
|
|
1001
|
+
*
|
|
1002
|
+
* @example
|
|
1003
|
+
* db.updateWithProject('memories', { importance: 'high' }, 'id = $1', [memoryId]);
|
|
1004
|
+
*/
|
|
1005
|
+
async updateWithProject(table, data, whereClause, whereParams = []) {
|
|
1006
|
+
const projectCtx = this.getProjectContext();
|
|
1007
|
+
const projectId = await projectCtx.getProjectId();
|
|
1008
|
+
// Build SET clause
|
|
1009
|
+
const setEntries = Object.entries(data);
|
|
1010
|
+
const setClauses = setEntries.map((_, i) => {
|
|
1011
|
+
const colName = setEntries[i][0];
|
|
1012
|
+
return `${colName} = $${i + 1}`;
|
|
1013
|
+
});
|
|
1014
|
+
const setValues = setEntries.map(([_, v]) => v);
|
|
1015
|
+
// Calculate parameter offset for WHERE clause
|
|
1016
|
+
const whereOffset = setEntries.length;
|
|
1017
|
+
// Adjust WHERE clause parameter numbers
|
|
1018
|
+
const adjustedWhere = whereClause.replace(/\$(\d+)/g, (_, num) => {
|
|
1019
|
+
return `$${parseInt(num) + whereOffset}`;
|
|
1020
|
+
});
|
|
1021
|
+
// Add project_id filter
|
|
1022
|
+
const projectParamIndex = whereOffset + whereParams.length + 1;
|
|
1023
|
+
const finalWhere = `${adjustedWhere} AND project_id = $${projectParamIndex}`;
|
|
1024
|
+
const sql = `UPDATE ${table} SET ${setClauses.join(', ')} WHERE ${finalWhere}`;
|
|
1025
|
+
const allParams = [...setValues, ...whereParams, projectId];
|
|
1026
|
+
logger.debug({
|
|
1027
|
+
table,
|
|
1028
|
+
sql: sql.slice(0, 150),
|
|
1029
|
+
projectId
|
|
1030
|
+
}, 'updateWithProject');
|
|
1031
|
+
const result = await this.query(sql, allParams);
|
|
1032
|
+
return result.rowCount ?? 0;
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Delete records with automatic project_id filtering.
|
|
1036
|
+
*
|
|
1037
|
+
* Ensures deletes only affect records in the current project.
|
|
1038
|
+
*
|
|
1039
|
+
* @param table - Table name to delete from
|
|
1040
|
+
* @param whereClause - WHERE conditions (e.g., "id = $1")
|
|
1041
|
+
* @param whereParams - Parameters for the WHERE clause
|
|
1042
|
+
* @returns Number of rows deleted
|
|
1043
|
+
*
|
|
1044
|
+
* @example
|
|
1045
|
+
* db.deleteWithProject('memories', 'id = $1', [memoryId]);
|
|
1046
|
+
*/
|
|
1047
|
+
async deleteWithProject(table, whereClause, whereParams = []) {
|
|
1048
|
+
const projectCtx = this.getProjectContext();
|
|
1049
|
+
const projectId = await projectCtx.getProjectId();
|
|
1050
|
+
// Add project_id filter
|
|
1051
|
+
const projectParamIndex = whereParams.length + 1;
|
|
1052
|
+
const finalWhere = `${whereClause} AND project_id = $${projectParamIndex}`;
|
|
1053
|
+
const sql = `DELETE FROM ${table} WHERE ${finalWhere}`;
|
|
1054
|
+
const allParams = [...whereParams, projectId];
|
|
1055
|
+
logger.debug({
|
|
1056
|
+
table,
|
|
1057
|
+
sql,
|
|
1058
|
+
projectId
|
|
1059
|
+
}, 'deleteWithProject');
|
|
1060
|
+
const result = await this.query(sql, allParams);
|
|
1061
|
+
return result.rowCount ?? 0;
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Add project_id filter to a SQL query.
|
|
1065
|
+
* Handles both queries with and without existing WHERE clause.
|
|
1066
|
+
*
|
|
1067
|
+
* @param sql - Original SQL query
|
|
1068
|
+
* @param paramIndex - Parameter index to use for project_id
|
|
1069
|
+
* @returns Modified SQL with project_id filter
|
|
1070
|
+
*/
|
|
1071
|
+
addProjectFilter(sql, paramIndex) {
|
|
1072
|
+
const sqlUpper = sql.toUpperCase();
|
|
1073
|
+
const projectFilter = `project_id = $${paramIndex}`;
|
|
1074
|
+
// Find positions of key clauses
|
|
1075
|
+
const wherePos = sqlUpper.indexOf(' WHERE ');
|
|
1076
|
+
const groupByPos = sqlUpper.indexOf(' GROUP BY ');
|
|
1077
|
+
const orderByPos = sqlUpper.indexOf(' ORDER BY ');
|
|
1078
|
+
const limitPos = sqlUpper.indexOf(' LIMIT ');
|
|
1079
|
+
const havingPos = sqlUpper.indexOf(' HAVING ');
|
|
1080
|
+
// Find the first clause after WHERE (or end of query)
|
|
1081
|
+
const clausePositions = [groupByPos, orderByPos, limitPos, havingPos]
|
|
1082
|
+
.filter(pos => pos !== -1);
|
|
1083
|
+
const firstClauseAfterWhere = clausePositions.length > 0
|
|
1084
|
+
? Math.min(...clausePositions)
|
|
1085
|
+
: sql.length;
|
|
1086
|
+
if (wherePos !== -1) {
|
|
1087
|
+
// Has WHERE - insert AND before the first clause after WHERE
|
|
1088
|
+
if (clausePositions.length > 0 && firstClauseAfterWhere > wherePos) {
|
|
1089
|
+
// Insert before GROUP BY, ORDER BY, LIMIT, or HAVING
|
|
1090
|
+
return sql.slice(0, firstClauseAfterWhere) +
|
|
1091
|
+
` AND ${projectFilter}` +
|
|
1092
|
+
sql.slice(firstClauseAfterWhere);
|
|
1093
|
+
}
|
|
1094
|
+
else {
|
|
1095
|
+
// No clauses after WHERE - append to end
|
|
1096
|
+
return sql + ` AND ${projectFilter}`;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
1100
|
+
// No WHERE - need to insert WHERE clause
|
|
1101
|
+
// Insert before GROUP BY, ORDER BY, LIMIT, or HAVING
|
|
1102
|
+
if (clausePositions.length > 0) {
|
|
1103
|
+
const insertPos = Math.min(...clausePositions);
|
|
1104
|
+
return sql.slice(0, insertPos) +
|
|
1105
|
+
` WHERE ${projectFilter}` +
|
|
1106
|
+
sql.slice(insertPos);
|
|
1107
|
+
}
|
|
1108
|
+
else {
|
|
1109
|
+
// No clauses at all - append to end
|
|
1110
|
+
return sql + ` WHERE ${projectFilter}`;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
// nah fr we need per-project DB instances to prevent cross-project pollution
|
|
1116
|
+
// each project gets its own DatabaseManager keyed by project path
|
|
1117
|
+
const databaseManagers = new Map();
|
|
1118
|
+
/**
|
|
1119
|
+
* Get current project path for database isolation.
|
|
1120
|
+
* Uses SPECMEM_PROJECT_PATH env var (set at MCP server start by bootstrap.cjs).
|
|
1121
|
+
*/
|
|
1122
|
+
function getDbProjectPath() {
|
|
1123
|
+
return process.env['SPECMEM_PROJECT_PATH'] || process.cwd() || '/';
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Get the DatabaseManager for the current project.
|
|
1127
|
+
*
|
|
1128
|
+
* MULTI-PROJECT ISOLATION: Each project gets its own DatabaseManager instance.
|
|
1129
|
+
* This prevents cross-project data pollution and ensures proper schema isolation.
|
|
1130
|
+
*
|
|
1131
|
+
* @param config - DatabaseConfig, required on first call for a project
|
|
1132
|
+
* @param projectPath - Optional explicit project path override (mainly for testing)
|
|
1133
|
+
* @returns DatabaseManager instance for the current/specified project
|
|
1134
|
+
*/
|
|
1135
|
+
export function getDatabase(config, projectPath) {
|
|
1136
|
+
const key = projectPath || getDbProjectPath();
|
|
1137
|
+
// yooo check if we already have an instance for this project
|
|
1138
|
+
const existing = databaseManagers.get(key);
|
|
1139
|
+
if (existing) {
|
|
1140
|
+
return existing;
|
|
1141
|
+
}
|
|
1142
|
+
// TASK #23 FIX: Auto-load config from loadConfig() when not provided
|
|
1143
|
+
// This enables graceful degradation - callers dont need to pass config every time
|
|
1144
|
+
if (!config) {
|
|
1145
|
+
logger.info({ projectPath: key }, 'No config provided, auto-loading from loadConfig().database');
|
|
1146
|
+
try {
|
|
1147
|
+
config = loadConfig().database;
|
|
1148
|
+
}
|
|
1149
|
+
catch (e) {
|
|
1150
|
+
// loadConfig failed - use sensible defaults that should work for most setups
|
|
1151
|
+
logger.warn({ projectPath: key, error: String(e) }, 'loadConfig() failed, using fallback defaults');
|
|
1152
|
+
// Use unified credential pattern - matches config.ts
|
|
1153
|
+
const unifiedCred = process.env['SPECMEM_PASSWORD'] || 'specmem_westayunprofessional';
|
|
1154
|
+
config = {
|
|
1155
|
+
host: process.env['SPECMEM_DB_HOST'] || 'localhost',
|
|
1156
|
+
port: parseInt(process.env['SPECMEM_DB_PORT'] || '5432', 10),
|
|
1157
|
+
database: process.env['SPECMEM_DB_NAME'] || unifiedCred,
|
|
1158
|
+
user: process.env['SPECMEM_DB_USER'] || unifiedCred,
|
|
1159
|
+
password: process.env['SPECMEM_DB_PASSWORD'] || unifiedCred,
|
|
1160
|
+
maxConnections: 20,
|
|
1161
|
+
idleTimeout: 30000,
|
|
1162
|
+
connectionTimeout: 5000,
|
|
1163
|
+
ssl: undefined
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
// create new instance for this project
|
|
1168
|
+
logger.info({ projectPath: key, database: config.database }, 'Creating new DatabaseManager for project');
|
|
1169
|
+
const newInstance = new DatabaseManager(config);
|
|
1170
|
+
databaseManagers.set(key, newInstance);
|
|
1171
|
+
return newInstance;
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Reset database instance for the current project.
|
|
1175
|
+
* Use for testing or when project context changes.
|
|
1176
|
+
*
|
|
1177
|
+
* @param projectPath - Optional explicit project path, defaults to current project
|
|
1178
|
+
*/
|
|
1179
|
+
export function resetDatabase(projectPath) {
|
|
1180
|
+
const key = projectPath || getDbProjectPath();
|
|
1181
|
+
const existing = databaseManagers.get(key);
|
|
1182
|
+
if (existing) {
|
|
1183
|
+
logger.debug({ projectPath: key }, 'Resetting DatabaseManager for project');
|
|
1184
|
+
databaseManagers.delete(key);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Reset ALL database instances across all projects.
|
|
1189
|
+
* Use ONLY for testing or complete shutdown scenarios.
|
|
1190
|
+
*/
|
|
1191
|
+
export function resetAllDatabases() {
|
|
1192
|
+
logger.warn({ instanceCount: databaseManagers.size }, 'Resetting ALL DatabaseManager instances');
|
|
1193
|
+
databaseManagers.clear();
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Get count of active database instances.
|
|
1197
|
+
* Useful for debugging multi-project scenarios.
|
|
1198
|
+
*/
|
|
1199
|
+
export function getDatabaseInstanceCount() {
|
|
1200
|
+
return databaseManagers.size;
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Get all active project paths with database instances.
|
|
1204
|
+
* Useful for debugging and monitoring.
|
|
1205
|
+
*/
|
|
1206
|
+
export function getActiveDbProjectPaths() {
|
|
1207
|
+
return Array.from(databaseManagers.keys());
|
|
1208
|
+
}
|
|
1209
|
+
//# sourceMappingURL=database.js.map
|