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.
Files changed (1473) hide show
  1. package/CHANGELOG.md +299 -0
  2. package/LICENSE.md +6406 -0
  3. package/README.md +539 -0
  4. package/bin/AegisTheme.cjs +1022 -0
  5. package/bin/AnsiRenderer.cjs +1055 -0
  6. package/bin/BoxRenderer.cjs +605 -0
  7. package/bin/ClaudeLiveScreen.cjs +1299 -0
  8. package/bin/DashboardModules.cjs +733 -0
  9. package/bin/LiveScreenCapture.cjs +1012 -0
  10. package/bin/MemoryBrowserScreen.cjs +1595 -0
  11. package/bin/TabManager.cjs +1414 -0
  12. package/bin/checkAgentStatus-fix.patch +30 -0
  13. package/bin/mcp-socket-client.cjs +462 -0
  14. package/bin/screen-utils.cjs +106 -0
  15. package/bin/specmem-autoclaude.cjs +663 -0
  16. package/bin/specmem-cleanup.cjs +421 -0
  17. package/bin/specmem-cli.cjs +794 -0
  18. package/bin/specmem-console-teamcomms-class.cjs +428 -0
  19. package/bin/specmem-console.cjs +8104 -0
  20. package/bin/specmem-statusbar.cjs +530 -0
  21. package/bootstrap.cjs +5065 -0
  22. package/claude-hooks/agent-chooser-hook.js +179 -0
  23. package/claude-hooks/agent-chooser-inject.js +121 -0
  24. package/claude-hooks/agent-loading-hook.js +990 -0
  25. package/claude-hooks/agent-output-fader.cjs +542 -0
  26. package/claude-hooks/agent-output-interceptor.js +193 -0
  27. package/claude-hooks/agent-type-matcher.js +419 -0
  28. package/claude-hooks/auto-bypass.py +74 -0
  29. package/claude-hooks/background-completion-silencer.js +134 -0
  30. package/claude-hooks/bash-auto-background.js +182 -0
  31. package/claude-hooks/build-cedict-dictionary.mjs +167 -0
  32. package/claude-hooks/bullshit-radar.cjs +323 -0
  33. package/claude-hooks/cedict-codes.json +270 -0
  34. package/claude-hooks/cedict-extracted.json +22632 -0
  35. package/claude-hooks/claude-watchdog.sh +401 -0
  36. package/claude-hooks/context-dedup.cjs +144 -0
  37. package/claude-hooks/context-yeeter.cjs +244 -0
  38. package/claude-hooks/debug-suffix.cjs +15 -0
  39. package/claude-hooks/debug2.cjs +7 -0
  40. package/claude-hooks/drilldown-enforcer.js +242 -0
  41. package/claude-hooks/english-morphology-standalone.cjs +149 -0
  42. package/claude-hooks/english-morphology.cjs +152 -0
  43. package/claude-hooks/extract-translations.mjs +193 -0
  44. package/claude-hooks/file-claim-enforcer.cjs +293 -0
  45. package/claude-hooks/file-claim-enforcer.js +293 -0
  46. package/claude-hooks/find-collisions.cjs +39 -0
  47. package/claude-hooks/fix-abbreviations.cjs +60 -0
  48. package/claude-hooks/fix-collisions.cjs +60 -0
  49. package/claude-hooks/fix-decompressor.cjs +79 -0
  50. package/claude-hooks/fix-suffixes.cjs +66 -0
  51. package/claude-hooks/grammar-engine.cjs +159 -0
  52. package/claude-hooks/input-aware-improver.js +231 -0
  53. package/claude-hooks/is-agent.cjs +64 -0
  54. package/claude-hooks/mega-test.cjs +213 -0
  55. package/claude-hooks/merge-dictionaries.mjs +207 -0
  56. package/claude-hooks/merged-codes.cjs +22675 -0
  57. package/claude-hooks/merged-codes.json +22676 -0
  58. package/claude-hooks/output-cleaner.cjs +388 -0
  59. package/claude-hooks/post-write-memory-hook.cjs +430 -0
  60. package/claude-hooks/quick-test.cjs +24 -0
  61. package/claude-hooks/quick-test2.cjs +24 -0
  62. package/claude-hooks/remove-bad-codes.cjs +23 -0
  63. package/claude-hooks/search-reminder-hook.js +90 -0
  64. package/claude-hooks/semantic-test.cjs +93 -0
  65. package/claude-hooks/settings.json +445 -0
  66. package/claude-hooks/smart-context-hook.cjs +547 -0
  67. package/claude-hooks/smart-context-hook.js +539 -0
  68. package/claude-hooks/smart-search-interceptor.js +364 -0
  69. package/claude-hooks/socket-connect-helper.cjs +235 -0
  70. package/claude-hooks/specmem/sockets/session-start.lock +1 -0
  71. package/claude-hooks/specmem-context-hook.cjs +357 -0
  72. package/claude-hooks/specmem-context-hook.js +357 -0
  73. package/claude-hooks/specmem-drilldown-hook.cjs +480 -0
  74. package/claude-hooks/specmem-drilldown-hook.js +480 -0
  75. package/claude-hooks/specmem-drilldown-setter.js +210 -0
  76. package/claude-hooks/specmem-paths.cjs +213 -0
  77. package/claude-hooks/specmem-precompact.js +183 -0
  78. package/claude-hooks/specmem-session-init.sh +33 -0
  79. package/claude-hooks/specmem-session-start.cjs +498 -0
  80. package/claude-hooks/specmem-stop-hook.cjs +73 -0
  81. package/claude-hooks/specmem-stop-hook.js +5 -0
  82. package/claude-hooks/specmem-team-comms.cjs +434 -0
  83. package/claude-hooks/specmem-team-member-inject.js +271 -0
  84. package/claude-hooks/specmem-unified-hook.py +670 -0
  85. package/claude-hooks/subagent-loading-hook.js +194 -0
  86. package/claude-hooks/sysprompt-squisher.cjs +167 -0
  87. package/claude-hooks/task-progress-hook.js +204 -0
  88. package/claude-hooks/team-comms-enforcer.cjs +585 -0
  89. package/claude-hooks/test-accuracy.cjs +27 -0
  90. package/claude-hooks/test-big.cjs +28 -0
  91. package/claude-hooks/test-inflectors.cjs +39 -0
  92. package/claude-hooks/test-pluralize.cjs +37 -0
  93. package/claude-hooks/test-quick.cjs +8 -0
  94. package/claude-hooks/test-wink.cjs +20 -0
  95. package/claude-hooks/token-compressor.cjs +940 -0
  96. package/claude-hooks/use-code-pointers.cjs +279 -0
  97. package/commands/COMMAND_TOOL_MAP.md +299 -0
  98. package/commands/specmem-agents.md +412 -0
  99. package/commands/specmem-autoclaude.md +295 -0
  100. package/commands/specmem-changes.md +247 -0
  101. package/commands/specmem-code.md +103 -0
  102. package/commands/specmem-configteammembercomms.md +322 -0
  103. package/commands/specmem-drilldown.md +208 -0
  104. package/commands/specmem-find.md +195 -0
  105. package/commands/specmem-getdashboard.md +243 -0
  106. package/commands/specmem-hooks.md +219 -0
  107. package/commands/specmem-pointers.md +149 -0
  108. package/commands/specmem-progress.md +287 -0
  109. package/commands/specmem-remember.md +123 -0
  110. package/commands/specmem-service.md +349 -0
  111. package/commands/specmem-stats.md +189 -0
  112. package/commands/specmem-team-member.md +409 -0
  113. package/commands/specmem-webdev.md +583 -0
  114. package/commands/specmem.md +363 -0
  115. package/dist/autoStart/index.d.ts +214 -0
  116. package/dist/autoStart/index.d.ts.map +1 -0
  117. package/dist/autoStart/index.js +883 -0
  118. package/dist/autoStart/index.js.map +1 -0
  119. package/dist/claude-sessions/contextRestorationParser.d.ts +74 -0
  120. package/dist/claude-sessions/contextRestorationParser.d.ts.map +1 -0
  121. package/dist/claude-sessions/contextRestorationParser.js +570 -0
  122. package/dist/claude-sessions/contextRestorationParser.js.map +1 -0
  123. package/dist/claude-sessions/index.d.ts +13 -0
  124. package/dist/claude-sessions/index.d.ts.map +1 -0
  125. package/dist/claude-sessions/index.js +11 -0
  126. package/dist/claude-sessions/index.js.map +1 -0
  127. package/dist/claude-sessions/sessionIntegration.d.ts +48 -0
  128. package/dist/claude-sessions/sessionIntegration.d.ts.map +1 -0
  129. package/dist/claude-sessions/sessionIntegration.js +146 -0
  130. package/dist/claude-sessions/sessionIntegration.js.map +1 -0
  131. package/dist/claude-sessions/sessionParser.d.ts +293 -0
  132. package/dist/claude-sessions/sessionParser.d.ts.map +1 -0
  133. package/dist/claude-sessions/sessionParser.js +1028 -0
  134. package/dist/claude-sessions/sessionParser.js.map +1 -0
  135. package/dist/claude-sessions/sessionWatcher.d.ts +139 -0
  136. package/dist/claude-sessions/sessionWatcher.d.ts.map +1 -0
  137. package/dist/claude-sessions/sessionWatcher.js +722 -0
  138. package/dist/claude-sessions/sessionWatcher.js.map +1 -0
  139. package/dist/cli/deploy-to-claude.d.ts +56 -0
  140. package/dist/cli/deploy-to-claude.d.ts.map +1 -0
  141. package/dist/cli/deploy-to-claude.js +576 -0
  142. package/dist/cli/deploy-to-claude.js.map +1 -0
  143. package/dist/code-explanations/explainCode.d.ts +86 -0
  144. package/dist/code-explanations/explainCode.d.ts.map +1 -0
  145. package/dist/code-explanations/explainCode.js +286 -0
  146. package/dist/code-explanations/explainCode.js.map +1 -0
  147. package/dist/code-explanations/feedback.d.ts +87 -0
  148. package/dist/code-explanations/feedback.d.ts.map +1 -0
  149. package/dist/code-explanations/feedback.js +212 -0
  150. package/dist/code-explanations/feedback.js.map +1 -0
  151. package/dist/code-explanations/getRelatedCode.d.ts +80 -0
  152. package/dist/code-explanations/getRelatedCode.d.ts.map +1 -0
  153. package/dist/code-explanations/getRelatedCode.js +262 -0
  154. package/dist/code-explanations/getRelatedCode.js.map +1 -0
  155. package/dist/code-explanations/index.d.ts +284 -0
  156. package/dist/code-explanations/index.d.ts.map +1 -0
  157. package/dist/code-explanations/index.js +249 -0
  158. package/dist/code-explanations/index.js.map +1 -0
  159. package/dist/code-explanations/linkCodeToPrompt.d.ts +79 -0
  160. package/dist/code-explanations/linkCodeToPrompt.d.ts.map +1 -0
  161. package/dist/code-explanations/linkCodeToPrompt.js +213 -0
  162. package/dist/code-explanations/linkCodeToPrompt.js.map +1 -0
  163. package/dist/code-explanations/recallExplanation.d.ts +88 -0
  164. package/dist/code-explanations/recallExplanation.d.ts.map +1 -0
  165. package/dist/code-explanations/recallExplanation.js +218 -0
  166. package/dist/code-explanations/recallExplanation.js.map +1 -0
  167. package/dist/code-explanations/schema.d.ts +32 -0
  168. package/dist/code-explanations/schema.d.ts.map +1 -0
  169. package/dist/code-explanations/schema.js +221 -0
  170. package/dist/code-explanations/schema.js.map +1 -0
  171. package/dist/code-explanations/semanticSearch.d.ts +75 -0
  172. package/dist/code-explanations/semanticSearch.d.ts.map +1 -0
  173. package/dist/code-explanations/semanticSearch.js +203 -0
  174. package/dist/code-explanations/semanticSearch.js.map +1 -0
  175. package/dist/code-explanations/types.d.ts +328 -0
  176. package/dist/code-explanations/types.d.ts.map +1 -0
  177. package/dist/code-explanations/types.js +122 -0
  178. package/dist/code-explanations/types.js.map +1 -0
  179. package/dist/codebase/codeAnalyzer.d.ts +272 -0
  180. package/dist/codebase/codeAnalyzer.d.ts.map +1 -0
  181. package/dist/codebase/codeAnalyzer.js +1353 -0
  182. package/dist/codebase/codeAnalyzer.js.map +1 -0
  183. package/dist/codebase/codebaseIndexer.d.ts +360 -0
  184. package/dist/codebase/codebaseIndexer.d.ts.map +1 -0
  185. package/dist/codebase/codebaseIndexer.js +1735 -0
  186. package/dist/codebase/codebaseIndexer.js.map +1 -0
  187. package/dist/codebase/codebaseTools.d.ts +853 -0
  188. package/dist/codebase/codebaseTools.d.ts.map +1 -0
  189. package/dist/codebase/codebaseTools.js +1279 -0
  190. package/dist/codebase/codebaseTools.js.map +1 -0
  191. package/dist/codebase/exclusions.d.ts +111 -0
  192. package/dist/codebase/exclusions.d.ts.map +1 -0
  193. package/dist/codebase/exclusions.js +771 -0
  194. package/dist/codebase/exclusions.js.map +1 -0
  195. package/dist/codebase/fileWatcher.d.ts +135 -0
  196. package/dist/codebase/fileWatcher.d.ts.map +1 -0
  197. package/dist/codebase/fileWatcher.js +309 -0
  198. package/dist/codebase/fileWatcher.js.map +1 -0
  199. package/dist/codebase/index.d.ts +33 -0
  200. package/dist/codebase/index.d.ts.map +1 -0
  201. package/dist/codebase/index.js +77 -0
  202. package/dist/codebase/index.js.map +1 -0
  203. package/dist/codebase/ingestion.d.ts +177 -0
  204. package/dist/codebase/ingestion.d.ts.map +1 -0
  205. package/dist/codebase/ingestion.js +690 -0
  206. package/dist/codebase/ingestion.js.map +1 -0
  207. package/dist/codebase/languageDetection.d.ts +75 -0
  208. package/dist/codebase/languageDetection.d.ts.map +1 -0
  209. package/dist/codebase/languageDetection.js +768 -0
  210. package/dist/codebase/languageDetection.js.map +1 -0
  211. package/dist/commands/codebaseCommands.d.ts +101 -0
  212. package/dist/commands/codebaseCommands.d.ts.map +1 -0
  213. package/dist/commands/codebaseCommands.js +911 -0
  214. package/dist/commands/codebaseCommands.js.map +1 -0
  215. package/dist/commands/commandHandler.d.ts +126 -0
  216. package/dist/commands/commandHandler.d.ts.map +1 -0
  217. package/dist/commands/commandHandler.js +296 -0
  218. package/dist/commands/commandHandler.js.map +1 -0
  219. package/dist/commands/commandLoader.d.ts +103 -0
  220. package/dist/commands/commandLoader.d.ts.map +1 -0
  221. package/dist/commands/commandLoader.js +223 -0
  222. package/dist/commands/commandLoader.js.map +1 -0
  223. package/dist/commands/contextCommands.d.ts +83 -0
  224. package/dist/commands/contextCommands.d.ts.map +1 -0
  225. package/dist/commands/contextCommands.js +512 -0
  226. package/dist/commands/contextCommands.js.map +1 -0
  227. package/dist/commands/index.d.ts +24 -0
  228. package/dist/commands/index.d.ts.map +1 -0
  229. package/dist/commands/index.js +28 -0
  230. package/dist/commands/index.js.map +1 -0
  231. package/dist/commands/mcpResources.d.ts +50 -0
  232. package/dist/commands/mcpResources.d.ts.map +1 -0
  233. package/dist/commands/mcpResources.js +372 -0
  234. package/dist/commands/mcpResources.js.map +1 -0
  235. package/dist/commands/memoryCommands.d.ts +74 -0
  236. package/dist/commands/memoryCommands.d.ts.map +1 -0
  237. package/dist/commands/memoryCommands.js +609 -0
  238. package/dist/commands/memoryCommands.js.map +1 -0
  239. package/dist/commands/promptCommands.d.ts +91 -0
  240. package/dist/commands/promptCommands.d.ts.map +1 -0
  241. package/dist/commands/promptCommands.js +801 -0
  242. package/dist/commands/promptCommands.js.map +1 -0
  243. package/dist/commands/teamMemberCommands.d.ts +21 -0
  244. package/dist/commands/teamMemberCommands.d.ts.map +1 -0
  245. package/dist/commands/teamMemberCommands.js +137 -0
  246. package/dist/commands/teamMemberCommands.js.map +1 -0
  247. package/dist/comms/fileCommsTransport.d.ts +91 -0
  248. package/dist/comms/fileCommsTransport.d.ts.map +1 -0
  249. package/dist/comms/fileCommsTransport.js +244 -0
  250. package/dist/comms/fileCommsTransport.js.map +1 -0
  251. package/dist/comms/index.d.ts +7 -0
  252. package/dist/comms/index.d.ts.map +1 -0
  253. package/dist/comms/index.js +7 -0
  254. package/dist/comms/index.js.map +1 -0
  255. package/dist/config/apiKeyDetection.d.ts +41 -0
  256. package/dist/config/apiKeyDetection.d.ts.map +1 -0
  257. package/dist/config/apiKeyDetection.js +211 -0
  258. package/dist/config/apiKeyDetection.js.map +1 -0
  259. package/dist/config/autoConfig.d.ts +188 -0
  260. package/dist/config/autoConfig.d.ts.map +1 -0
  261. package/dist/config/autoConfig.js +850 -0
  262. package/dist/config/autoConfig.js.map +1 -0
  263. package/dist/config/configSync.d.ts +119 -0
  264. package/dist/config/configSync.d.ts.map +1 -0
  265. package/dist/config/configSync.js +878 -0
  266. package/dist/config/configSync.js.map +1 -0
  267. package/dist/config/embeddingTimeouts.d.ts +145 -0
  268. package/dist/config/embeddingTimeouts.d.ts.map +1 -0
  269. package/dist/config/embeddingTimeouts.js +255 -0
  270. package/dist/config/embeddingTimeouts.js.map +1 -0
  271. package/dist/config/index.d.ts +5 -0
  272. package/dist/config/index.d.ts.map +1 -0
  273. package/dist/config/index.js +7 -0
  274. package/dist/config/index.js.map +1 -0
  275. package/dist/config/languageConfig.d.ts +68 -0
  276. package/dist/config/languageConfig.d.ts.map +1 -0
  277. package/dist/config/languageConfig.js +473 -0
  278. package/dist/config/languageConfig.js.map +1 -0
  279. package/dist/config/password.d.ts +145 -0
  280. package/dist/config/password.d.ts.map +1 -0
  281. package/dist/config/password.js +428 -0
  282. package/dist/config/password.js.map +1 -0
  283. package/dist/config.d.ts +338 -0
  284. package/dist/config.d.ts.map +1 -0
  285. package/dist/config.js +1177 -0
  286. package/dist/config.js.map +1 -0
  287. package/dist/consolidation.d.ts +44 -0
  288. package/dist/consolidation.d.ts.map +1 -0
  289. package/dist/consolidation.js +447 -0
  290. package/dist/consolidation.js.map +1 -0
  291. package/dist/constants.d.ts +371 -0
  292. package/dist/constants.d.ts.map +1 -0
  293. package/dist/constants.js +552 -0
  294. package/dist/constants.js.map +1 -0
  295. package/dist/coordination/TeamMemberRegistry.d.ts +192 -0
  296. package/dist/coordination/TeamMemberRegistry.d.ts.map +1 -0
  297. package/dist/coordination/TeamMemberRegistry.js +415 -0
  298. package/dist/coordination/TeamMemberRegistry.js.map +1 -0
  299. package/dist/coordination/events.d.ts +369 -0
  300. package/dist/coordination/events.d.ts.map +1 -0
  301. package/dist/coordination/events.js +232 -0
  302. package/dist/coordination/events.js.map +1 -0
  303. package/dist/coordination/handlers.d.ts +116 -0
  304. package/dist/coordination/handlers.d.ts.map +1 -0
  305. package/dist/coordination/handlers.js +400 -0
  306. package/dist/coordination/handlers.js.map +1 -0
  307. package/dist/coordination/index.d.ts +14 -0
  308. package/dist/coordination/index.d.ts.map +1 -0
  309. package/dist/coordination/index.js +31 -0
  310. package/dist/coordination/index.js.map +1 -0
  311. package/dist/coordination/integration.d.ts +260 -0
  312. package/dist/coordination/integration.d.ts.map +1 -0
  313. package/dist/coordination/integration.js +472 -0
  314. package/dist/coordination/integration.js.map +1 -0
  315. package/dist/coordination/server.d.ts +266 -0
  316. package/dist/coordination/server.d.ts.map +1 -0
  317. package/dist/coordination/server.js +995 -0
  318. package/dist/coordination/server.js.map +1 -0
  319. package/dist/coordination/serviceProvider.d.ts +70 -0
  320. package/dist/coordination/serviceProvider.d.ts.map +1 -0
  321. package/dist/coordination/serviceProvider.js +273 -0
  322. package/dist/coordination/serviceProvider.js.map +1 -0
  323. package/dist/dashboard/api/claudeControl.d.ts +44 -0
  324. package/dist/dashboard/api/claudeControl.d.ts.map +1 -0
  325. package/dist/dashboard/api/claudeControl.js +650 -0
  326. package/dist/dashboard/api/claudeControl.js.map +1 -0
  327. package/dist/dashboard/api/claudeHistory.d.ts +4 -0
  328. package/dist/dashboard/api/claudeHistory.d.ts.map +1 -0
  329. package/dist/dashboard/api/claudeHistory.js +319 -0
  330. package/dist/dashboard/api/claudeHistory.js.map +1 -0
  331. package/dist/dashboard/api/dataExport.d.ts +23 -0
  332. package/dist/dashboard/api/dataExport.d.ts.map +1 -0
  333. package/dist/dashboard/api/dataExport.js +509 -0
  334. package/dist/dashboard/api/dataExport.js.map +1 -0
  335. package/dist/dashboard/api/fileManager.d.ts +39 -0
  336. package/dist/dashboard/api/fileManager.d.ts.map +1 -0
  337. package/dist/dashboard/api/fileManager.js +814 -0
  338. package/dist/dashboard/api/fileManager.js.map +1 -0
  339. package/dist/dashboard/api/hooks.d.ts +16 -0
  340. package/dist/dashboard/api/hooks.d.ts.map +1 -0
  341. package/dist/dashboard/api/hooks.js +342 -0
  342. package/dist/dashboard/api/hooks.js.map +1 -0
  343. package/dist/dashboard/api/hotReload.d.ts +14 -0
  344. package/dist/dashboard/api/hotReload.d.ts.map +1 -0
  345. package/dist/dashboard/api/hotReload.js +219 -0
  346. package/dist/dashboard/api/hotReload.js.map +1 -0
  347. package/dist/dashboard/api/liveSessionStream.d.ts +19 -0
  348. package/dist/dashboard/api/liveSessionStream.d.ts.map +1 -0
  349. package/dist/dashboard/api/liveSessionStream.js +430 -0
  350. package/dist/dashboard/api/liveSessionStream.js.map +1 -0
  351. package/dist/dashboard/api/memoryRecall.d.ts +20 -0
  352. package/dist/dashboard/api/memoryRecall.d.ts.map +1 -0
  353. package/dist/dashboard/api/memoryRecall.js +524 -0
  354. package/dist/dashboard/api/memoryRecall.js.map +1 -0
  355. package/dist/dashboard/api/promptSend.d.ts +33 -0
  356. package/dist/dashboard/api/promptSend.d.ts.map +1 -0
  357. package/dist/dashboard/api/promptSend.js +544 -0
  358. package/dist/dashboard/api/promptSend.js.map +1 -0
  359. package/dist/dashboard/api/settings.d.ts +10 -0
  360. package/dist/dashboard/api/settings.d.ts.map +1 -0
  361. package/dist/dashboard/api/settings.js +656 -0
  362. package/dist/dashboard/api/settings.js.map +1 -0
  363. package/dist/dashboard/api/setup.d.ts +21 -0
  364. package/dist/dashboard/api/setup.d.ts.map +1 -0
  365. package/dist/dashboard/api/setup.js +663 -0
  366. package/dist/dashboard/api/setup.js.map +1 -0
  367. package/dist/dashboard/api/specmemTools.d.ts +14 -0
  368. package/dist/dashboard/api/specmemTools.d.ts.map +1 -0
  369. package/dist/dashboard/api/specmemTools.js +1059 -0
  370. package/dist/dashboard/api/specmemTools.js.map +1 -0
  371. package/dist/dashboard/api/taskTeamMembers.d.ts +8 -0
  372. package/dist/dashboard/api/taskTeamMembers.d.ts.map +1 -0
  373. package/dist/dashboard/api/taskTeamMembers.js +136 -0
  374. package/dist/dashboard/api/taskTeamMembers.js.map +1 -0
  375. package/dist/dashboard/api/teamMemberDeploy.d.ts +15 -0
  376. package/dist/dashboard/api/teamMemberDeploy.d.ts.map +1 -0
  377. package/dist/dashboard/api/teamMemberDeploy.js +421 -0
  378. package/dist/dashboard/api/teamMemberDeploy.js.map +1 -0
  379. package/dist/dashboard/api/teamMemberHistory.d.ts +38 -0
  380. package/dist/dashboard/api/teamMemberHistory.d.ts.map +1 -0
  381. package/dist/dashboard/api/teamMemberHistory.js +583 -0
  382. package/dist/dashboard/api/teamMemberHistory.js.map +1 -0
  383. package/dist/dashboard/api/terminal.d.ts +12 -0
  384. package/dist/dashboard/api/terminal.d.ts.map +1 -0
  385. package/dist/dashboard/api/terminal.js +344 -0
  386. package/dist/dashboard/api/terminal.js.map +1 -0
  387. package/dist/dashboard/api/terminalInject.d.ts +17 -0
  388. package/dist/dashboard/api/terminalInject.d.ts.map +1 -0
  389. package/dist/dashboard/api/terminalInject.js +322 -0
  390. package/dist/dashboard/api/terminalInject.js.map +1 -0
  391. package/dist/dashboard/api/terminalStream.d.ts +12 -0
  392. package/dist/dashboard/api/terminalStream.d.ts.map +1 -0
  393. package/dist/dashboard/api/terminalStream.js +482 -0
  394. package/dist/dashboard/api/terminalStream.js.map +1 -0
  395. package/dist/dashboard/index.d.ts +7 -0
  396. package/dist/dashboard/index.d.ts.map +1 -0
  397. package/dist/dashboard/index.js +7 -0
  398. package/dist/dashboard/index.js.map +1 -0
  399. package/dist/dashboard/ptyStreamer.d.ts +173 -0
  400. package/dist/dashboard/ptyStreamer.d.ts.map +1 -0
  401. package/dist/dashboard/ptyStreamer.js +661 -0
  402. package/dist/dashboard/ptyStreamer.js.map +1 -0
  403. package/dist/dashboard/public/DASHBOARD-README.md +378 -0
  404. package/dist/dashboard/public/INTEGRATION-GUIDE.md +395 -0
  405. package/dist/dashboard/public/codebase-config.html +1247 -0
  406. package/dist/dashboard/public/dashboard-v2.html +1942 -0
  407. package/dist/dashboard/public/data-export.html +819 -0
  408. package/dist/dashboard/public/example-page.html +164 -0
  409. package/dist/dashboard/public/file-explorer.html +1023 -0
  410. package/dist/dashboard/public/hooks.html +1103 -0
  411. package/dist/dashboard/public/index-improvements.css +499 -0
  412. package/dist/dashboard/public/index.html +5534 -0
  413. package/dist/dashboard/public/memory-controls.html +1959 -0
  414. package/dist/dashboard/public/memory-recall.html +1495 -0
  415. package/dist/dashboard/public/previews/skeleton-memory-graph.html +361 -0
  416. package/dist/dashboard/public/previews/skeleton-memory-list.html +366 -0
  417. package/dist/dashboard/public/previews/skeleton-search-results.html +609 -0
  418. package/dist/dashboard/public/previews/skeleton-stats-dashboard.html +556 -0
  419. package/dist/dashboard/public/prompt-console.html +2763 -0
  420. package/dist/dashboard/public/react-dist/assets/index-CkjobT5B.js +871 -0
  421. package/dist/dashboard/public/react-dist/assets/index-iRclxMst.css +1 -0
  422. package/dist/dashboard/public/react-dist/index.html +16 -0
  423. package/dist/dashboard/public/shared-header.js +325 -0
  424. package/dist/dashboard/public/shared-language-selector.js +626 -0
  425. package/dist/dashboard/public/shared-logger.js +66 -0
  426. package/dist/dashboard/public/shared-nav.js +325 -0
  427. package/dist/dashboard/public/shared-theme-blue.css +331 -0
  428. package/dist/dashboard/public/shared-theme.css +813 -0
  429. package/dist/dashboard/public/shared-toast.js +415 -0
  430. package/dist/dashboard/public/team-member-history.html +1291 -0
  431. package/dist/dashboard/public/team-member-spy.html +1199 -0
  432. package/dist/dashboard/public/team-members.html +3756 -0
  433. package/dist/dashboard/public/terminal-output.html +1013 -0
  434. package/dist/dashboard/public/terminal.html +372 -0
  435. package/dist/dashboard/sessionStore.d.ts +86 -0
  436. package/dist/dashboard/sessionStore.d.ts.map +1 -0
  437. package/dist/dashboard/sessionStore.js +262 -0
  438. package/dist/dashboard/sessionStore.js.map +1 -0
  439. package/dist/dashboard/standalone.d.ts +27 -0
  440. package/dist/dashboard/standalone.d.ts.map +1 -0
  441. package/dist/dashboard/standalone.js +380 -0
  442. package/dist/dashboard/standalone.js.map +1 -0
  443. package/dist/dashboard/webServer.d.ts +390 -0
  444. package/dist/dashboard/webServer.d.ts.map +1 -0
  445. package/dist/dashboard/webServer.js +4297 -0
  446. package/dist/dashboard/webServer.js.map +1 -0
  447. package/dist/dashboard/websocket/teamMemberStream.d.ts +87 -0
  448. package/dist/dashboard/websocket/teamMemberStream.d.ts.map +1 -0
  449. package/dist/dashboard/websocket/teamMemberStream.js +366 -0
  450. package/dist/dashboard/websocket/teamMemberStream.js.map +1 -0
  451. package/dist/dashboard/websocket/terminalStream.d.ts +130 -0
  452. package/dist/dashboard/websocket/terminalStream.d.ts.map +1 -0
  453. package/dist/dashboard/websocket/terminalStream.js +456 -0
  454. package/dist/dashboard/websocket/terminalStream.js.map +1 -0
  455. package/dist/database/embeddedPostgres.d.ts +187 -0
  456. package/dist/database/embeddedPostgres.d.ts.map +1 -0
  457. package/dist/database/embeddedPostgres.js +763 -0
  458. package/dist/database/embeddedPostgres.js.map +1 -0
  459. package/dist/database/index.d.ts +12 -0
  460. package/dist/database/index.d.ts.map +1 -0
  461. package/dist/database/index.js +20 -0
  462. package/dist/database/index.js.map +1 -0
  463. package/dist/database/initEmbeddedPostgres.d.ts +124 -0
  464. package/dist/database/initEmbeddedPostgres.d.ts.map +1 -0
  465. package/dist/database/initEmbeddedPostgres.js +855 -0
  466. package/dist/database/initEmbeddedPostgres.js.map +1 -0
  467. package/dist/database.d.ts +256 -0
  468. package/dist/database.d.ts.map +1 -0
  469. package/dist/database.js +1209 -0
  470. package/dist/database.js.map +1 -0
  471. package/dist/db/apiDataManager.d.ts +334 -0
  472. package/dist/db/apiDataManager.d.ts.map +1 -0
  473. package/dist/db/apiDataManager.js +631 -0
  474. package/dist/db/apiDataManager.js.map +1 -0
  475. package/dist/db/batchOperations.d.ts +154 -0
  476. package/dist/db/batchOperations.d.ts.map +1 -0
  477. package/dist/db/batchOperations.js +564 -0
  478. package/dist/db/batchOperations.js.map +1 -0
  479. package/dist/db/bigBrainMigrations.d.ts +48 -0
  480. package/dist/db/bigBrainMigrations.d.ts.map +1 -0
  481. package/dist/db/bigBrainMigrations.js +4266 -0
  482. package/dist/db/bigBrainMigrations.js.map +1 -0
  483. package/dist/db/connectionPoolGoBrrr.d.ts +94 -0
  484. package/dist/db/connectionPoolGoBrrr.d.ts.map +1 -0
  485. package/dist/db/connectionPoolGoBrrr.js +548 -0
  486. package/dist/db/connectionPoolGoBrrr.js.map +1 -0
  487. package/dist/db/dashboardQueries.d.ts +182 -0
  488. package/dist/db/dashboardQueries.d.ts.map +1 -0
  489. package/dist/db/dashboardQueries.js +821 -0
  490. package/dist/db/dashboardQueries.js.map +1 -0
  491. package/dist/db/deploymentBootstrap.d.ts +43 -0
  492. package/dist/db/deploymentBootstrap.d.ts.map +1 -0
  493. package/dist/db/deploymentBootstrap.js +329 -0
  494. package/dist/db/deploymentBootstrap.js.map +1 -0
  495. package/dist/db/dimensionService.d.ts +140 -0
  496. package/dist/db/dimensionService.d.ts.map +1 -0
  497. package/dist/db/dimensionService.js +261 -0
  498. package/dist/db/dimensionService.js.map +1 -0
  499. package/dist/db/embeddingOverflow.d.ts +69 -0
  500. package/dist/db/embeddingOverflow.d.ts.map +1 -0
  501. package/dist/db/embeddingOverflow.js +332 -0
  502. package/dist/db/embeddingOverflow.js.map +1 -0
  503. package/dist/db/embeddingOverflow.sql +221 -0
  504. package/dist/db/findThatShit.d.ts +145 -0
  505. package/dist/db/findThatShit.d.ts.map +1 -0
  506. package/dist/db/findThatShit.js +782 -0
  507. package/dist/db/findThatShit.js.map +1 -0
  508. package/dist/db/hotPathManager.d.ts +187 -0
  509. package/dist/db/hotPathManager.d.ts.map +1 -0
  510. package/dist/db/hotPathManager.js +504 -0
  511. package/dist/db/hotPathManager.js.map +1 -0
  512. package/dist/db/index.d.ts +85 -0
  513. package/dist/db/index.d.ts.map +1 -0
  514. package/dist/db/index.js +219 -0
  515. package/dist/db/index.js.map +1 -0
  516. package/dist/db/memoryDrilldown.sql +99 -0
  517. package/dist/db/migrate.d.ts +3 -0
  518. package/dist/db/migrate.d.ts.map +1 -0
  519. package/dist/db/migrate.js +97 -0
  520. package/dist/db/migrate.js.map +1 -0
  521. package/dist/db/migrateJsonToPostgres.d.ts +43 -0
  522. package/dist/db/migrateJsonToPostgres.d.ts.map +1 -0
  523. package/dist/db/migrateJsonToPostgres.js +465 -0
  524. package/dist/db/migrateJsonToPostgres.js.map +1 -0
  525. package/dist/db/nukeFromOrbit.d.ts +63 -0
  526. package/dist/db/nukeFromOrbit.d.ts.map +1 -0
  527. package/dist/db/nukeFromOrbit.js +499 -0
  528. package/dist/db/nukeFromOrbit.js.map +1 -0
  529. package/dist/db/processedTraining.sql +60 -0
  530. package/dist/db/projectNamespacing.d.ts +258 -0
  531. package/dist/db/projectNamespacing.d.ts.map +1 -0
  532. package/dist/db/projectNamespacing.js +920 -0
  533. package/dist/db/projectNamespacing.js.map +1 -0
  534. package/dist/db/projectNamespacing.sql +374 -0
  535. package/dist/db/projectSchemaInit.sql +271 -0
  536. package/dist/db/spatialMemory.d.ts +296 -0
  537. package/dist/db/spatialMemory.d.ts.map +1 -0
  538. package/dist/db/spatialMemory.js +818 -0
  539. package/dist/db/spatialMemory.js.map +1 -0
  540. package/dist/db/streamingQuery.d.ts +143 -0
  541. package/dist/db/streamingQuery.d.ts.map +1 -0
  542. package/dist/db/streamingQuery.js +350 -0
  543. package/dist/db/streamingQuery.js.map +1 -0
  544. package/dist/db/teamComms.sql +224 -0
  545. package/dist/db/yeetStuffInDb.d.ts +72 -0
  546. package/dist/db/yeetStuffInDb.d.ts.map +1 -0
  547. package/dist/db/yeetStuffInDb.js +473 -0
  548. package/dist/db/yeetStuffInDb.js.map +1 -0
  549. package/dist/embedding-providers/index.d.ts +10 -0
  550. package/dist/embedding-providers/index.d.ts.map +1 -0
  551. package/dist/embedding-providers/index.js +12 -0
  552. package/dist/embedding-providers/index.js.map +1 -0
  553. package/dist/embeddings/projectionLayer.d.ts +114 -0
  554. package/dist/embeddings/projectionLayer.d.ts.map +1 -0
  555. package/dist/embeddings/projectionLayer.js +345 -0
  556. package/dist/embeddings/projectionLayer.js.map +1 -0
  557. package/dist/events/Publisher.d.ts +193 -0
  558. package/dist/events/Publisher.d.ts.map +1 -0
  559. package/dist/events/Publisher.js +439 -0
  560. package/dist/events/Publisher.js.map +1 -0
  561. package/dist/events/config.d.ts +139 -0
  562. package/dist/events/config.d.ts.map +1 -0
  563. package/dist/events/config.js +266 -0
  564. package/dist/events/config.js.map +1 -0
  565. package/dist/events/index.d.ts +19 -0
  566. package/dist/events/index.d.ts.map +1 -0
  567. package/dist/events/index.js +31 -0
  568. package/dist/events/index.js.map +1 -0
  569. package/dist/events/integration.d.ts +206 -0
  570. package/dist/events/integration.d.ts.map +1 -0
  571. package/dist/events/integration.js +348 -0
  572. package/dist/events/integration.js.map +1 -0
  573. package/dist/events/metrics.d.ts +147 -0
  574. package/dist/events/metrics.d.ts.map +1 -0
  575. package/dist/events/metrics.js +343 -0
  576. package/dist/events/metrics.js.map +1 -0
  577. package/dist/hooks/cli.d.ts +28 -0
  578. package/dist/hooks/cli.d.ts.map +1 -0
  579. package/dist/hooks/cli.js +118 -0
  580. package/dist/hooks/cli.js.map +1 -0
  581. package/dist/hooks/contextInjectionHook.d.ts +60 -0
  582. package/dist/hooks/contextInjectionHook.d.ts.map +1 -0
  583. package/dist/hooks/contextInjectionHook.js +294 -0
  584. package/dist/hooks/contextInjectionHook.js.map +1 -0
  585. package/dist/hooks/drilldownHook.d.ts +125 -0
  586. package/dist/hooks/drilldownHook.d.ts.map +1 -0
  587. package/dist/hooks/drilldownHook.js +181 -0
  588. package/dist/hooks/drilldownHook.js.map +1 -0
  589. package/dist/hooks/hookManager.d.ts +180 -0
  590. package/dist/hooks/hookManager.d.ts.map +1 -0
  591. package/dist/hooks/hookManager.js +782 -0
  592. package/dist/hooks/hookManager.js.map +1 -0
  593. package/dist/hooks/index.d.ts +62 -0
  594. package/dist/hooks/index.d.ts.map +1 -0
  595. package/dist/hooks/index.js +66 -0
  596. package/dist/hooks/index.js.map +1 -0
  597. package/dist/hooks/lowContextHook.d.ts +71 -0
  598. package/dist/hooks/lowContextHook.d.ts.map +1 -0
  599. package/dist/hooks/lowContextHook.js +258 -0
  600. package/dist/hooks/lowContextHook.js.map +1 -0
  601. package/dist/hooks/simpleContextHook.d.ts +65 -0
  602. package/dist/hooks/simpleContextHook.d.ts.map +1 -0
  603. package/dist/hooks/simpleContextHook.js +194 -0
  604. package/dist/hooks/simpleContextHook.js.map +1 -0
  605. package/dist/hooks/teamFramingCli.d.ts +56 -0
  606. package/dist/hooks/teamFramingCli.d.ts.map +1 -0
  607. package/dist/hooks/teamFramingCli.js +264 -0
  608. package/dist/hooks/teamFramingCli.js.map +1 -0
  609. package/dist/hooks/teamMemberPrepromptHook.d.ts +150 -0
  610. package/dist/hooks/teamMemberPrepromptHook.d.ts.map +1 -0
  611. package/dist/hooks/teamMemberPrepromptHook.js +308 -0
  612. package/dist/hooks/teamMemberPrepromptHook.js.map +1 -0
  613. package/dist/index.d.ts +42 -0
  614. package/dist/index.d.ts.map +1 -0
  615. package/dist/index.js +4433 -0
  616. package/dist/index.js.map +1 -0
  617. package/dist/init/claudeConfigInjector.d.ts +116 -0
  618. package/dist/init/claudeConfigInjector.d.ts.map +1 -0
  619. package/dist/init/claudeConfigInjector.js +1154 -0
  620. package/dist/init/claudeConfigInjector.js.map +1 -0
  621. package/dist/installer/autoInstall.d.ts +72 -0
  622. package/dist/installer/autoInstall.d.ts.map +1 -0
  623. package/dist/installer/autoInstall.js +617 -0
  624. package/dist/installer/autoInstall.js.map +1 -0
  625. package/dist/installer/dbSetup.d.ts +84 -0
  626. package/dist/installer/dbSetup.d.ts.map +1 -0
  627. package/dist/installer/dbSetup.js +350 -0
  628. package/dist/installer/dbSetup.js.map +1 -0
  629. package/dist/installer/firstRun.d.ts +49 -0
  630. package/dist/installer/firstRun.d.ts.map +1 -0
  631. package/dist/installer/firstRun.js +207 -0
  632. package/dist/installer/firstRun.js.map +1 -0
  633. package/dist/installer/index.d.ts +10 -0
  634. package/dist/installer/index.d.ts.map +1 -0
  635. package/dist/installer/index.js +10 -0
  636. package/dist/installer/index.js.map +1 -0
  637. package/dist/installer/silentAutoInstall.d.ts +99 -0
  638. package/dist/installer/silentAutoInstall.d.ts.map +1 -0
  639. package/dist/installer/silentAutoInstall.js +491 -0
  640. package/dist/installer/silentAutoInstall.js.map +1 -0
  641. package/dist/installer/systemDeps.d.ts +54 -0
  642. package/dist/installer/systemDeps.d.ts.map +1 -0
  643. package/dist/installer/systemDeps.js +322 -0
  644. package/dist/installer/systemDeps.js.map +1 -0
  645. package/dist/mcp/cliNotifications.d.ts +133 -0
  646. package/dist/mcp/cliNotifications.d.ts.map +1 -0
  647. package/dist/mcp/cliNotifications.js +289 -0
  648. package/dist/mcp/cliNotifications.js.map +1 -0
  649. package/dist/mcp/embeddingServerManager.d.ts +307 -0
  650. package/dist/mcp/embeddingServerManager.d.ts.map +1 -0
  651. package/dist/mcp/embeddingServerManager.js +2081 -0
  652. package/dist/mcp/embeddingServerManager.js.map +1 -0
  653. package/dist/mcp/healthMonitor.d.ts +196 -0
  654. package/dist/mcp/healthMonitor.d.ts.map +1 -0
  655. package/dist/mcp/healthMonitor.js +685 -0
  656. package/dist/mcp/healthMonitor.js.map +1 -0
  657. package/dist/mcp/hotReloadManager.d.ts +101 -0
  658. package/dist/mcp/hotReloadManager.d.ts.map +1 -0
  659. package/dist/mcp/hotReloadManager.js +251 -0
  660. package/dist/mcp/hotReloadManager.js.map +1 -0
  661. package/dist/mcp/index.d.ts +16 -0
  662. package/dist/mcp/index.d.ts.map +1 -0
  663. package/dist/mcp/index.js +22 -0
  664. package/dist/mcp/index.js.map +1 -0
  665. package/dist/mcp/mcpProtocolHandler.d.ts +64 -0
  666. package/dist/mcp/mcpProtocolHandler.d.ts.map +1 -0
  667. package/dist/mcp/mcpProtocolHandler.js +253 -0
  668. package/dist/mcp/mcpProtocolHandler.js.map +1 -0
  669. package/dist/mcp/miniCOTServerManager.d.ts +336 -0
  670. package/dist/mcp/miniCOTServerManager.d.ts.map +1 -0
  671. package/dist/mcp/miniCOTServerManager.js +1384 -0
  672. package/dist/mcp/miniCOTServerManager.js.map +1 -0
  673. package/dist/mcp/promptExecutor.d.ts +188 -0
  674. package/dist/mcp/promptExecutor.d.ts.map +1 -0
  675. package/dist/mcp/promptExecutor.js +469 -0
  676. package/dist/mcp/promptExecutor.js.map +1 -0
  677. package/dist/mcp/reloadBroadcast.d.ts +127 -0
  678. package/dist/mcp/reloadBroadcast.d.ts.map +1 -0
  679. package/dist/mcp/reloadBroadcast.js +275 -0
  680. package/dist/mcp/reloadBroadcast.js.map +1 -0
  681. package/dist/mcp/resilientTransport.d.ts +249 -0
  682. package/dist/mcp/resilientTransport.d.ts.map +1 -0
  683. package/dist/mcp/resilientTransport.js +931 -0
  684. package/dist/mcp/resilientTransport.js.map +1 -0
  685. package/dist/mcp/samplingHandler.d.ts +129 -0
  686. package/dist/mcp/samplingHandler.d.ts.map +1 -0
  687. package/dist/mcp/samplingHandler.js +276 -0
  688. package/dist/mcp/samplingHandler.js.map +1 -0
  689. package/dist/mcp/specMemServer.d.ts +305 -0
  690. package/dist/mcp/specMemServer.d.ts.map +1 -0
  691. package/dist/mcp/specMemServer.js +2048 -0
  692. package/dist/mcp/specMemServer.js.map +1 -0
  693. package/dist/mcp/toolRegistry.d.ts +122 -0
  694. package/dist/mcp/toolRegistry.d.ts.map +1 -0
  695. package/dist/mcp/toolRegistry.js +609 -0
  696. package/dist/mcp/toolRegistry.js.map +1 -0
  697. package/dist/mcp/tools/embeddingControl.d.ts +114 -0
  698. package/dist/mcp/tools/embeddingControl.d.ts.map +1 -0
  699. package/dist/mcp/tools/embeddingControl.js +222 -0
  700. package/dist/mcp/tools/embeddingControl.js.map +1 -0
  701. package/dist/mcp/tools/index.d.ts +10 -0
  702. package/dist/mcp/tools/index.d.ts.map +1 -0
  703. package/dist/mcp/tools/index.js +17 -0
  704. package/dist/mcp/tools/index.js.map +1 -0
  705. package/dist/mcp/tools/teamComms.d.ts +444 -0
  706. package/dist/mcp/tools/teamComms.d.ts.map +1 -0
  707. package/dist/mcp/tools/teamComms.js +1953 -0
  708. package/dist/mcp/tools/teamComms.js.map +1 -0
  709. package/dist/mcp/triggerSystem.d.ts +129 -0
  710. package/dist/mcp/triggerSystem.d.ts.map +1 -0
  711. package/dist/mcp/triggerSystem.js +363 -0
  712. package/dist/mcp/triggerSystem.js.map +1 -0
  713. package/dist/mcp/watcherIntegration.d.ts +77 -0
  714. package/dist/mcp/watcherIntegration.d.ts.map +1 -0
  715. package/dist/mcp/watcherIntegration.js +428 -0
  716. package/dist/mcp/watcherIntegration.js.map +1 -0
  717. package/dist/mcp/watcherToolWrappers.d.ts +89 -0
  718. package/dist/mcp/watcherToolWrappers.d.ts.map +1 -0
  719. package/dist/mcp/watcherToolWrappers.js +91 -0
  720. package/dist/mcp/watcherToolWrappers.js.map +1 -0
  721. package/dist/memorization/claudeCodeMigration.d.ts +34 -0
  722. package/dist/memorization/claudeCodeMigration.d.ts.map +1 -0
  723. package/dist/memorization/claudeCodeMigration.js +210 -0
  724. package/dist/memorization/claudeCodeMigration.js.map +1 -0
  725. package/dist/memorization/claudeCodeTracker.d.ts +147 -0
  726. package/dist/memorization/claudeCodeTracker.d.ts.map +1 -0
  727. package/dist/memorization/claudeCodeTracker.js +424 -0
  728. package/dist/memorization/claudeCodeTracker.js.map +1 -0
  729. package/dist/memorization/codeMemorizer.d.ts +158 -0
  730. package/dist/memorization/codeMemorizer.d.ts.map +1 -0
  731. package/dist/memorization/codeMemorizer.js +357 -0
  732. package/dist/memorization/codeMemorizer.js.map +1 -0
  733. package/dist/memorization/codeRecall.d.ts +156 -0
  734. package/dist/memorization/codeRecall.d.ts.map +1 -0
  735. package/dist/memorization/codeRecall.js +499 -0
  736. package/dist/memorization/codeRecall.js.map +1 -0
  737. package/dist/memorization/index.d.ts +55 -0
  738. package/dist/memorization/index.d.ts.map +1 -0
  739. package/dist/memorization/index.js +64 -0
  740. package/dist/memorization/index.js.map +1 -0
  741. package/dist/memorization/memorizationTools.d.ts +413 -0
  742. package/dist/memorization/memorizationTools.d.ts.map +1 -0
  743. package/dist/memorization/memorizationTools.js +513 -0
  744. package/dist/memorization/memorizationTools.js.map +1 -0
  745. package/dist/memorization/watcherIntegration.d.ts +100 -0
  746. package/dist/memorization/watcherIntegration.d.ts.map +1 -0
  747. package/dist/memorization/watcherIntegration.js +196 -0
  748. package/dist/memorization/watcherIntegration.js.map +1 -0
  749. package/dist/memory/humanLikeMemory.d.ts +206 -0
  750. package/dist/memory/humanLikeMemory.d.ts.map +1 -0
  751. package/dist/memory/humanLikeMemory.js +603 -0
  752. package/dist/memory/humanLikeMemory.js.map +1 -0
  753. package/dist/memory/index.d.ts +22 -0
  754. package/dist/memory/index.d.ts.map +1 -0
  755. package/dist/memory/index.js +24 -0
  756. package/dist/memory/index.js.map +1 -0
  757. package/dist/memory/memoryEvolutionMigration.d.ts +36 -0
  758. package/dist/memory/memoryEvolutionMigration.d.ts.map +1 -0
  759. package/dist/memory/memoryEvolutionMigration.js +371 -0
  760. package/dist/memory/memoryEvolutionMigration.js.map +1 -0
  761. package/dist/memory/quadrantSearch.d.ts +221 -0
  762. package/dist/memory/quadrantSearch.d.ts.map +1 -0
  763. package/dist/memory/quadrantSearch.js +897 -0
  764. package/dist/memory/quadrantSearch.js.map +1 -0
  765. package/dist/middleware/apiVersioning.d.ts +83 -0
  766. package/dist/middleware/apiVersioning.d.ts.map +1 -0
  767. package/dist/middleware/apiVersioning.js +152 -0
  768. package/dist/middleware/apiVersioning.js.map +1 -0
  769. package/dist/middleware/compression.d.ts +48 -0
  770. package/dist/middleware/compression.d.ts.map +1 -0
  771. package/dist/middleware/compression.js +240 -0
  772. package/dist/middleware/compression.js.map +1 -0
  773. package/dist/middleware/csrf.d.ts +118 -0
  774. package/dist/middleware/csrf.d.ts.map +1 -0
  775. package/dist/middleware/csrf.js +300 -0
  776. package/dist/middleware/csrf.js.map +1 -0
  777. package/dist/middleware/index.d.ts +13 -0
  778. package/dist/middleware/index.d.ts.map +1 -0
  779. package/dist/middleware/index.js +17 -0
  780. package/dist/middleware/index.js.map +1 -0
  781. package/dist/middleware/wsRateLimiter.d.ts +129 -0
  782. package/dist/middleware/wsRateLimiter.d.ts.map +1 -0
  783. package/dist/middleware/wsRateLimiter.js +279 -0
  784. package/dist/middleware/wsRateLimiter.js.map +1 -0
  785. package/dist/migrations/run.d.ts +2 -0
  786. package/dist/migrations/run.d.ts.map +1 -0
  787. package/dist/migrations/run.js +25 -0
  788. package/dist/migrations/run.js.map +1 -0
  789. package/dist/migrations/syncDimensions.d.ts +24 -0
  790. package/dist/migrations/syncDimensions.d.ts.map +1 -0
  791. package/dist/migrations/syncDimensions.js +140 -0
  792. package/dist/migrations/syncDimensions.js.map +1 -0
  793. package/dist/migrations/teamComms.d.ts +16 -0
  794. package/dist/migrations/teamComms.d.ts.map +1 -0
  795. package/dist/migrations/teamComms.js +210 -0
  796. package/dist/migrations/teamComms.js.map +1 -0
  797. package/dist/openapi/index.d.ts +10 -0
  798. package/dist/openapi/index.d.ts.map +1 -0
  799. package/dist/openapi/index.js +10 -0
  800. package/dist/openapi/index.js.map +1 -0
  801. package/dist/openapi/spec.d.ts +902 -0
  802. package/dist/openapi/spec.d.ts.map +1 -0
  803. package/dist/openapi/spec.js +733 -0
  804. package/dist/openapi/spec.js.map +1 -0
  805. package/dist/packages/dependencyHistory.d.ts +113 -0
  806. package/dist/packages/dependencyHistory.d.ts.map +1 -0
  807. package/dist/packages/dependencyHistory.js +360 -0
  808. package/dist/packages/dependencyHistory.js.map +1 -0
  809. package/dist/packages/index.d.ts +30 -0
  810. package/dist/packages/index.d.ts.map +1 -0
  811. package/dist/packages/index.js +65 -0
  812. package/dist/packages/index.js.map +1 -0
  813. package/dist/packages/packageTools.d.ts +255 -0
  814. package/dist/packages/packageTools.d.ts.map +1 -0
  815. package/dist/packages/packageTools.js +242 -0
  816. package/dist/packages/packageTools.js.map +1 -0
  817. package/dist/packages/packageTracker.d.ts +98 -0
  818. package/dist/packages/packageTracker.d.ts.map +1 -0
  819. package/dist/packages/packageTracker.js +268 -0
  820. package/dist/packages/packageTracker.js.map +1 -0
  821. package/dist/packages/packageWatcher.d.ts +62 -0
  822. package/dist/packages/packageWatcher.d.ts.map +1 -0
  823. package/dist/packages/packageWatcher.js +146 -0
  824. package/dist/packages/packageWatcher.js.map +1 -0
  825. package/dist/providers/MiniCOTProvider.d.ts +48 -0
  826. package/dist/providers/MiniCOTProvider.d.ts.map +1 -0
  827. package/dist/providers/MiniCOTProvider.js +98 -0
  828. package/dist/providers/MiniCOTProvider.js.map +1 -0
  829. package/dist/reminders/index.d.ts +5 -0
  830. package/dist/reminders/index.d.ts.map +1 -0
  831. package/dist/reminders/index.js +5 -0
  832. package/dist/reminders/index.js.map +1 -0
  833. package/dist/reminders/skillReminder.d.ts +131 -0
  834. package/dist/reminders/skillReminder.d.ts.map +1 -0
  835. package/dist/reminders/skillReminder.js +386 -0
  836. package/dist/reminders/skillReminder.js.map +1 -0
  837. package/dist/search.d.ts +35 -0
  838. package/dist/search.d.ts.map +1 -0
  839. package/dist/search.js +574 -0
  840. package/dist/search.js.map +1 -0
  841. package/dist/security/localhostOnly.d.ts +36 -0
  842. package/dist/security/localhostOnly.d.ts.map +1 -0
  843. package/dist/security/localhostOnly.js +101 -0
  844. package/dist/security/localhostOnly.js.map +1 -0
  845. package/dist/services/CameraZoomSearch.d.ts +206 -0
  846. package/dist/services/CameraZoomSearch.d.ts.map +1 -0
  847. package/dist/services/CameraZoomSearch.js +669 -0
  848. package/dist/services/CameraZoomSearch.js.map +1 -0
  849. package/dist/services/DataFlowPipeline.d.ts +111 -0
  850. package/dist/services/DataFlowPipeline.d.ts.map +1 -0
  851. package/dist/services/DataFlowPipeline.js +379 -0
  852. package/dist/services/DataFlowPipeline.js.map +1 -0
  853. package/dist/services/DimensionAdapter.d.ts +194 -0
  854. package/dist/services/DimensionAdapter.d.ts.map +1 -0
  855. package/dist/services/DimensionAdapter.js +566 -0
  856. package/dist/services/DimensionAdapter.js.map +1 -0
  857. package/dist/services/DimensionService.d.ts +252 -0
  858. package/dist/services/DimensionService.d.ts.map +1 -0
  859. package/dist/services/DimensionService.js +564 -0
  860. package/dist/services/DimensionService.js.map +1 -0
  861. package/dist/services/EmbeddingQueue.d.ts +71 -0
  862. package/dist/services/EmbeddingQueue.d.ts.map +1 -0
  863. package/dist/services/EmbeddingQueue.js +258 -0
  864. package/dist/services/EmbeddingQueue.js.map +1 -0
  865. package/dist/services/MemoryDrilldown.d.ts +226 -0
  866. package/dist/services/MemoryDrilldown.d.ts.map +1 -0
  867. package/dist/services/MemoryDrilldown.js +479 -0
  868. package/dist/services/MemoryDrilldown.js.map +1 -0
  869. package/dist/services/MiniCOTScorer.d.ts +140 -0
  870. package/dist/services/MiniCOTScorer.d.ts.map +1 -0
  871. package/dist/services/MiniCOTScorer.js +292 -0
  872. package/dist/services/MiniCOTScorer.js.map +1 -0
  873. package/dist/services/ProjectContext.d.ts +342 -0
  874. package/dist/services/ProjectContext.d.ts.map +1 -0
  875. package/dist/services/ProjectContext.js +667 -0
  876. package/dist/services/ProjectContext.js.map +1 -0
  877. package/dist/services/ResponseCompactor.d.ts +135 -0
  878. package/dist/services/ResponseCompactor.d.ts.map +1 -0
  879. package/dist/services/ResponseCompactor.js +501 -0
  880. package/dist/services/ResponseCompactor.js.map +1 -0
  881. package/dist/services/TeamCommsDbService.d.ts +202 -0
  882. package/dist/services/TeamCommsDbService.d.ts.map +1 -0
  883. package/dist/services/TeamCommsDbService.js +526 -0
  884. package/dist/services/TeamCommsDbService.js.map +1 -0
  885. package/dist/services/UnifiedPasswordService.d.ts +166 -0
  886. package/dist/services/UnifiedPasswordService.d.ts.map +1 -0
  887. package/dist/services/UnifiedPasswordService.js +587 -0
  888. package/dist/services/UnifiedPasswordService.js.map +1 -0
  889. package/dist/services/adaptiveSearchConfig.d.ts +64 -0
  890. package/dist/services/adaptiveSearchConfig.d.ts.map +1 -0
  891. package/dist/services/adaptiveSearchConfig.js +187 -0
  892. package/dist/services/adaptiveSearchConfig.js.map +1 -0
  893. package/dist/skills/index.d.ts +8 -0
  894. package/dist/skills/index.d.ts.map +1 -0
  895. package/dist/skills/index.js +8 -0
  896. package/dist/skills/index.js.map +1 -0
  897. package/dist/skills/skillScanner.d.ts +203 -0
  898. package/dist/skills/skillScanner.d.ts.map +1 -0
  899. package/dist/skills/skillScanner.js +559 -0
  900. package/dist/skills/skillScanner.js.map +1 -0
  901. package/dist/skills/skillsResource.d.ts +69 -0
  902. package/dist/skills/skillsResource.d.ts.map +1 -0
  903. package/dist/skills/skillsResource.js +257 -0
  904. package/dist/skills/skillsResource.js.map +1 -0
  905. package/dist/startup/index.d.ts +9 -0
  906. package/dist/startup/index.d.ts.map +1 -0
  907. package/dist/startup/index.js +12 -0
  908. package/dist/startup/index.js.map +1 -0
  909. package/dist/startup/startupIndexing.d.ts +80 -0
  910. package/dist/startup/startupIndexing.d.ts.map +1 -0
  911. package/dist/startup/startupIndexing.js +463 -0
  912. package/dist/startup/startupIndexing.js.map +1 -0
  913. package/dist/startup/validation.d.ts +89 -0
  914. package/dist/startup/validation.d.ts.map +1 -0
  915. package/dist/startup/validation.js +590 -0
  916. package/dist/startup/validation.js.map +1 -0
  917. package/dist/storage/index.d.ts +4 -0
  918. package/dist/storage/index.d.ts.map +1 -0
  919. package/dist/storage/index.js +4 -0
  920. package/dist/storage/index.js.map +1 -0
  921. package/dist/storage/overflowManager.d.ts +80 -0
  922. package/dist/storage/overflowManager.d.ts.map +1 -0
  923. package/dist/storage/overflowManager.js +317 -0
  924. package/dist/storage/overflowManager.js.map +1 -0
  925. package/dist/storage/overflowStorage.d.ts +69 -0
  926. package/dist/storage/overflowStorage.d.ts.map +1 -0
  927. package/dist/storage/overflowStorage.js +379 -0
  928. package/dist/storage/overflowStorage.js.map +1 -0
  929. package/dist/storage/toonFormat.d.ts +50 -0
  930. package/dist/storage/toonFormat.d.ts.map +1 -0
  931. package/dist/storage/toonFormat.js +224 -0
  932. package/dist/storage/toonFormat.js.map +1 -0
  933. package/dist/team-members/communication.d.ts +237 -0
  934. package/dist/team-members/communication.d.ts.map +1 -0
  935. package/dist/team-members/communication.js +650 -0
  936. package/dist/team-members/communication.js.map +1 -0
  937. package/dist/team-members/index.d.ts +14 -0
  938. package/dist/team-members/index.d.ts.map +1 -0
  939. package/dist/team-members/index.js +22 -0
  940. package/dist/team-members/index.js.map +1 -0
  941. package/dist/team-members/taskOrchestrator.d.ts +224 -0
  942. package/dist/team-members/taskOrchestrator.d.ts.map +1 -0
  943. package/dist/team-members/taskOrchestrator.js +574 -0
  944. package/dist/team-members/taskOrchestrator.js.map +1 -0
  945. package/dist/team-members/taskTeamMemberLogger.d.ts +157 -0
  946. package/dist/team-members/taskTeamMemberLogger.d.ts.map +1 -0
  947. package/dist/team-members/taskTeamMemberLogger.js +478 -0
  948. package/dist/team-members/taskTeamMemberLogger.js.map +1 -0
  949. package/dist/team-members/teamCommsService.d.ts +221 -0
  950. package/dist/team-members/teamCommsService.d.ts.map +1 -0
  951. package/dist/team-members/teamCommsService.js +628 -0
  952. package/dist/team-members/teamCommsService.js.map +1 -0
  953. package/dist/team-members/teamMemberChannels.d.ts +217 -0
  954. package/dist/team-members/teamMemberChannels.d.ts.map +1 -0
  955. package/dist/team-members/teamMemberChannels.js +687 -0
  956. package/dist/team-members/teamMemberChannels.js.map +1 -0
  957. package/dist/team-members/teamMemberDashboard.d.ts +222 -0
  958. package/dist/team-members/teamMemberDashboard.d.ts.map +1 -0
  959. package/dist/team-members/teamMemberDashboard.js +610 -0
  960. package/dist/team-members/teamMemberDashboard.js.map +1 -0
  961. package/dist/team-members/teamMemberDeployment.d.ts +60 -0
  962. package/dist/team-members/teamMemberDeployment.d.ts.map +1 -0
  963. package/dist/team-members/teamMemberDeployment.js +429 -0
  964. package/dist/team-members/teamMemberDeployment.js.map +1 -0
  965. package/dist/team-members/teamMemberDiscovery.d.ts +178 -0
  966. package/dist/team-members/teamMemberDiscovery.d.ts.map +1 -0
  967. package/dist/team-members/teamMemberDiscovery.js +446 -0
  968. package/dist/team-members/teamMemberDiscovery.js.map +1 -0
  969. package/dist/team-members/teamMemberHistory.d.ts +80 -0
  970. package/dist/team-members/teamMemberHistory.d.ts.map +1 -0
  971. package/dist/team-members/teamMemberHistory.js +426 -0
  972. package/dist/team-members/teamMemberHistory.js.map +1 -0
  973. package/dist/team-members/teamMemberLimits.d.ts +66 -0
  974. package/dist/team-members/teamMemberLimits.d.ts.map +1 -0
  975. package/dist/team-members/teamMemberLimits.js +259 -0
  976. package/dist/team-members/teamMemberLimits.js.map +1 -0
  977. package/dist/team-members/teamMemberRegistry.d.ts +199 -0
  978. package/dist/team-members/teamMemberRegistry.d.ts.map +1 -0
  979. package/dist/team-members/teamMemberRegistry.js +572 -0
  980. package/dist/team-members/teamMemberRegistry.js.map +1 -0
  981. package/dist/team-members/teamMemberTracker.d.ts +148 -0
  982. package/dist/team-members/teamMemberTracker.d.ts.map +1 -0
  983. package/dist/team-members/teamMemberTracker.js +828 -0
  984. package/dist/team-members/teamMemberTracker.js.map +1 -0
  985. package/dist/team-members/workers/aiWorker.d.ts +53 -0
  986. package/dist/team-members/workers/aiWorker.d.ts.map +1 -0
  987. package/dist/team-members/workers/aiWorker.js +322 -0
  988. package/dist/team-members/workers/aiWorker.js.map +1 -0
  989. package/dist/team-members/workers/baseWorker.d.ts +101 -0
  990. package/dist/team-members/workers/baseWorker.d.ts.map +1 -0
  991. package/dist/team-members/workers/baseWorker.js +179 -0
  992. package/dist/team-members/workers/baseWorker.js.map +1 -0
  993. package/dist/team-members/workers/codeReviewWorker.d.ts +3 -0
  994. package/dist/team-members/workers/codeReviewWorker.d.ts.map +1 -0
  995. package/dist/team-members/workers/codeReviewWorker.js +144 -0
  996. package/dist/team-members/workers/codeReviewWorker.js.map +1 -0
  997. package/dist/team-members/workers/index.d.ts +7 -0
  998. package/dist/team-members/workers/index.d.ts.map +1 -0
  999. package/dist/team-members/workers/index.js +7 -0
  1000. package/dist/team-members/workers/index.js.map +1 -0
  1001. package/dist/team-members/workers/repairWorker.d.ts +9 -0
  1002. package/dist/team-members/workers/repairWorker.d.ts.map +1 -0
  1003. package/dist/team-members/workers/repairWorker.js +102 -0
  1004. package/dist/team-members/workers/repairWorker.js.map +1 -0
  1005. package/dist/team-members/workers/sendToTeamMemberB.d.ts +9 -0
  1006. package/dist/team-members/workers/sendToTeamMemberB.d.ts.map +1 -0
  1007. package/dist/team-members/workers/sendToTeamMemberB.js +105 -0
  1008. package/dist/team-members/workers/sendToTeamMemberB.js.map +1 -0
  1009. package/dist/team-members/workers/specmemClient.d.ts +179 -0
  1010. package/dist/team-members/workers/specmemClient.d.ts.map +1 -0
  1011. package/dist/team-members/workers/specmemClient.js +421 -0
  1012. package/dist/team-members/workers/specmemClient.js.map +1 -0
  1013. package/dist/team-members/workers/testCommunication.d.ts +8 -0
  1014. package/dist/team-members/workers/testCommunication.d.ts.map +1 -0
  1015. package/dist/team-members/workers/testCommunication.js +136 -0
  1016. package/dist/team-members/workers/testCommunication.js.map +1 -0
  1017. package/dist/team-members/workers/testCommunicationSuite.d.ts +26 -0
  1018. package/dist/team-members/workers/testCommunicationSuite.d.ts.map +1 -0
  1019. package/dist/team-members/workers/testCommunicationSuite.js +415 -0
  1020. package/dist/team-members/workers/testCommunicationSuite.js.map +1 -0
  1021. package/dist/team-members/workers/testWorker.d.ts +9 -0
  1022. package/dist/team-members/workers/testWorker.d.ts.map +1 -0
  1023. package/dist/team-members/workers/testWorker.js +107 -0
  1024. package/dist/team-members/workers/testWorker.js.map +1 -0
  1025. package/dist/tools/agentDefinitions.d.ts +30 -0
  1026. package/dist/tools/agentDefinitions.d.ts.map +1 -0
  1027. package/dist/tools/agentDefinitions.js +166 -0
  1028. package/dist/tools/agentDefinitions.js.map +1 -0
  1029. package/dist/tools/goofy/checkSyncStatus.d.ts +68 -0
  1030. package/dist/tools/goofy/checkSyncStatus.d.ts.map +1 -0
  1031. package/dist/tools/goofy/checkSyncStatus.js +112 -0
  1032. package/dist/tools/goofy/checkSyncStatus.js.map +1 -0
  1033. package/dist/tools/goofy/codeMemoryLink.d.ts +82 -0
  1034. package/dist/tools/goofy/codeMemoryLink.d.ts.map +1 -0
  1035. package/dist/tools/goofy/codeMemoryLink.js +212 -0
  1036. package/dist/tools/goofy/codeMemoryLink.js.map +1 -0
  1037. package/dist/tools/goofy/compareInstanceMemory.d.ts +97 -0
  1038. package/dist/tools/goofy/compareInstanceMemory.d.ts.map +1 -0
  1039. package/dist/tools/goofy/compareInstanceMemory.js +218 -0
  1040. package/dist/tools/goofy/compareInstanceMemory.js.map +1 -0
  1041. package/dist/tools/goofy/createReasoningChain.d.ts +135 -0
  1042. package/dist/tools/goofy/createReasoningChain.d.ts.map +1 -0
  1043. package/dist/tools/goofy/createReasoningChain.js +257 -0
  1044. package/dist/tools/goofy/createReasoningChain.js.map +1 -0
  1045. package/dist/tools/goofy/deployTeamMember.d.ts +63 -0
  1046. package/dist/tools/goofy/deployTeamMember.d.ts.map +1 -0
  1047. package/dist/tools/goofy/deployTeamMember.js +103 -0
  1048. package/dist/tools/goofy/deployTeamMember.js.map +1 -0
  1049. package/dist/tools/goofy/drillDown.d.ts +143 -0
  1050. package/dist/tools/goofy/drillDown.d.ts.map +1 -0
  1051. package/dist/tools/goofy/drillDown.js +288 -0
  1052. package/dist/tools/goofy/drillDown.js.map +1 -0
  1053. package/dist/tools/goofy/extractClaudeSessions.d.ts +90 -0
  1054. package/dist/tools/goofy/extractClaudeSessions.d.ts.map +1 -0
  1055. package/dist/tools/goofy/extractClaudeSessions.js +277 -0
  1056. package/dist/tools/goofy/extractClaudeSessions.js.map +1 -0
  1057. package/dist/tools/goofy/extractContextRestorations.d.ts +70 -0
  1058. package/dist/tools/goofy/extractContextRestorations.d.ts.map +1 -0
  1059. package/dist/tools/goofy/extractContextRestorations.js +100 -0
  1060. package/dist/tools/goofy/extractContextRestorations.js.map +1 -0
  1061. package/dist/tools/goofy/findCodePointers.d.ts +364 -0
  1062. package/dist/tools/goofy/findCodePointers.d.ts.map +1 -0
  1063. package/dist/tools/goofy/findCodePointers.js +1764 -0
  1064. package/dist/tools/goofy/findCodePointers.js.map +1 -0
  1065. package/dist/tools/goofy/findMemoryGallery.d.ts +40 -0
  1066. package/dist/tools/goofy/findMemoryGallery.d.ts.map +1 -0
  1067. package/dist/tools/goofy/findMemoryGallery.js +66 -0
  1068. package/dist/tools/goofy/findMemoryGallery.js.map +1 -0
  1069. package/dist/tools/goofy/findWhatISaid.d.ts +300 -0
  1070. package/dist/tools/goofy/findWhatISaid.d.ts.map +1 -0
  1071. package/dist/tools/goofy/findWhatISaid.js +2547 -0
  1072. package/dist/tools/goofy/findWhatISaid.js.map +1 -0
  1073. package/dist/tools/goofy/forceResync.d.ts +57 -0
  1074. package/dist/tools/goofy/forceResync.d.ts.map +1 -0
  1075. package/dist/tools/goofy/forceResync.js +100 -0
  1076. package/dist/tools/goofy/forceResync.js.map +1 -0
  1077. package/dist/tools/goofy/getActiveTeamMembers.d.ts +48 -0
  1078. package/dist/tools/goofy/getActiveTeamMembers.d.ts.map +1 -0
  1079. package/dist/tools/goofy/getActiveTeamMembers.js +136 -0
  1080. package/dist/tools/goofy/getActiveTeamMembers.js.map +1 -0
  1081. package/dist/tools/goofy/getMemoryFull.d.ts +34 -0
  1082. package/dist/tools/goofy/getMemoryFull.d.ts.map +1 -0
  1083. package/dist/tools/goofy/getMemoryFull.js +58 -0
  1084. package/dist/tools/goofy/getMemoryFull.js.map +1 -0
  1085. package/dist/tools/goofy/getSessionWatcherStatus.d.ts +43 -0
  1086. package/dist/tools/goofy/getSessionWatcherStatus.d.ts.map +1 -0
  1087. package/dist/tools/goofy/getSessionWatcherStatus.js +92 -0
  1088. package/dist/tools/goofy/getSessionWatcherStatus.js.map +1 -0
  1089. package/dist/tools/goofy/getTeamMemberOutput.d.ts +35 -0
  1090. package/dist/tools/goofy/getTeamMemberOutput.d.ts.map +1 -0
  1091. package/dist/tools/goofy/getTeamMemberOutput.js +62 -0
  1092. package/dist/tools/goofy/getTeamMemberOutput.js.map +1 -0
  1093. package/dist/tools/goofy/getTeamMemberScreen.d.ts +28 -0
  1094. package/dist/tools/goofy/getTeamMemberScreen.d.ts.map +1 -0
  1095. package/dist/tools/goofy/getTeamMemberScreen.js +59 -0
  1096. package/dist/tools/goofy/getTeamMemberScreen.js.map +1 -0
  1097. package/dist/tools/goofy/getTeamMemberStatus.d.ts +33 -0
  1098. package/dist/tools/goofy/getTeamMemberStatus.d.ts.map +1 -0
  1099. package/dist/tools/goofy/getTeamMemberStatus.js +56 -0
  1100. package/dist/tools/goofy/getTeamMemberStatus.js.map +1 -0
  1101. package/dist/tools/goofy/index.d.ts +39 -0
  1102. package/dist/tools/goofy/index.d.ts.map +1 -0
  1103. package/dist/tools/goofy/index.js +51 -0
  1104. package/dist/tools/goofy/index.js.map +1 -0
  1105. package/dist/tools/goofy/interveneTeamMember.d.ts +33 -0
  1106. package/dist/tools/goofy/interveneTeamMember.d.ts.map +1 -0
  1107. package/dist/tools/goofy/interveneTeamMember.js +69 -0
  1108. package/dist/tools/goofy/interveneTeamMember.js.map +1 -0
  1109. package/dist/tools/goofy/killDeployedTeamMember.d.ts +29 -0
  1110. package/dist/tools/goofy/killDeployedTeamMember.d.ts.map +1 -0
  1111. package/dist/tools/goofy/killDeployedTeamMember.js +56 -0
  1112. package/dist/tools/goofy/killDeployedTeamMember.js.map +1 -0
  1113. package/dist/tools/goofy/linkTheVibes.d.ts +125 -0
  1114. package/dist/tools/goofy/linkTheVibes.d.ts.map +1 -0
  1115. package/dist/tools/goofy/linkTheVibes.js +354 -0
  1116. package/dist/tools/goofy/linkTheVibes.js.map +1 -0
  1117. package/dist/tools/goofy/listDeployedTeamMembers.d.ts +26 -0
  1118. package/dist/tools/goofy/listDeployedTeamMembers.d.ts.map +1 -0
  1119. package/dist/tools/goofy/listDeployedTeamMembers.js +52 -0
  1120. package/dist/tools/goofy/listDeployedTeamMembers.js.map +1 -0
  1121. package/dist/tools/goofy/listenForMessages.d.ts +56 -0
  1122. package/dist/tools/goofy/listenForMessages.d.ts.map +1 -0
  1123. package/dist/tools/goofy/listenForMessages.js +122 -0
  1124. package/dist/tools/goofy/listenForMessages.js.map +1 -0
  1125. package/dist/tools/goofy/memoryHealthCheck.d.ts +159 -0
  1126. package/dist/tools/goofy/memoryHealthCheck.d.ts.map +1 -0
  1127. package/dist/tools/goofy/memoryHealthCheck.js +443 -0
  1128. package/dist/tools/goofy/memoryHealthCheck.js.map +1 -0
  1129. package/dist/tools/goofy/rememberThisShit.d.ts +103 -0
  1130. package/dist/tools/goofy/rememberThisShit.d.ts.map +1 -0
  1131. package/dist/tools/goofy/rememberThisShit.js +291 -0
  1132. package/dist/tools/goofy/rememberThisShit.js.map +1 -0
  1133. package/dist/tools/goofy/sayToTeamMember.d.ts +55 -0
  1134. package/dist/tools/goofy/sayToTeamMember.d.ts.map +1 -0
  1135. package/dist/tools/goofy/sayToTeamMember.js +116 -0
  1136. package/dist/tools/goofy/sayToTeamMember.js.map +1 -0
  1137. package/dist/tools/goofy/selfMessage.d.ts +54 -0
  1138. package/dist/tools/goofy/selfMessage.d.ts.map +1 -0
  1139. package/dist/tools/goofy/selfMessage.js +111 -0
  1140. package/dist/tools/goofy/selfMessage.js.map +1 -0
  1141. package/dist/tools/goofy/sendHeartbeat.d.ts +53 -0
  1142. package/dist/tools/goofy/sendHeartbeat.d.ts.map +1 -0
  1143. package/dist/tools/goofy/sendHeartbeat.js +119 -0
  1144. package/dist/tools/goofy/sendHeartbeat.js.map +1 -0
  1145. package/dist/tools/goofy/showMeTheStats.d.ts +216 -0
  1146. package/dist/tools/goofy/showMeTheStats.d.ts.map +1 -0
  1147. package/dist/tools/goofy/showMeTheStats.js +535 -0
  1148. package/dist/tools/goofy/showMeTheStats.js.map +1 -0
  1149. package/dist/tools/goofy/smartRecall.d.ts +136 -0
  1150. package/dist/tools/goofy/smartRecall.d.ts.map +1 -0
  1151. package/dist/tools/goofy/smartRecall.js +286 -0
  1152. package/dist/tools/goofy/smartRecall.js.map +1 -0
  1153. package/dist/tools/goofy/smartSearch.d.ts +64 -0
  1154. package/dist/tools/goofy/smartSearch.d.ts.map +1 -0
  1155. package/dist/tools/goofy/smartSearch.js +89 -0
  1156. package/dist/tools/goofy/smartSearch.js.map +1 -0
  1157. package/dist/tools/goofy/smushMemoriesTogether.d.ts +128 -0
  1158. package/dist/tools/goofy/smushMemoriesTogether.d.ts.map +1 -0
  1159. package/dist/tools/goofy/smushMemoriesTogether.js +536 -0
  1160. package/dist/tools/goofy/smushMemoriesTogether.js.map +1 -0
  1161. package/dist/tools/goofy/spatialSearch.d.ts +198 -0
  1162. package/dist/tools/goofy/spatialSearch.d.ts.map +1 -0
  1163. package/dist/tools/goofy/spatialSearch.js +551 -0
  1164. package/dist/tools/goofy/spatialSearch.js.map +1 -0
  1165. package/dist/tools/goofy/spawnResearchTeamMember.d.ts +104 -0
  1166. package/dist/tools/goofy/spawnResearchTeamMember.d.ts.map +1 -0
  1167. package/dist/tools/goofy/spawnResearchTeamMember.js +290 -0
  1168. package/dist/tools/goofy/spawnResearchTeamMember.js.map +1 -0
  1169. package/dist/tools/goofy/spawnResearchTeamMemberTool.d.ts +121 -0
  1170. package/dist/tools/goofy/spawnResearchTeamMemberTool.d.ts.map +1 -0
  1171. package/dist/tools/goofy/spawnResearchTeamMemberTool.js +215 -0
  1172. package/dist/tools/goofy/spawnResearchTeamMemberTool.js.map +1 -0
  1173. package/dist/tools/goofy/startWatchingTheFiles.d.ts +81 -0
  1174. package/dist/tools/goofy/startWatchingTheFiles.d.ts.map +1 -0
  1175. package/dist/tools/goofy/startWatchingTheFiles.js +161 -0
  1176. package/dist/tools/goofy/startWatchingTheFiles.js.map +1 -0
  1177. package/dist/tools/goofy/stopWatchingTheFiles.d.ts +50 -0
  1178. package/dist/tools/goofy/stopWatchingTheFiles.d.ts.map +1 -0
  1179. package/dist/tools/goofy/stopWatchingTheFiles.js +81 -0
  1180. package/dist/tools/goofy/stopWatchingTheFiles.js.map +1 -0
  1181. package/dist/tools/goofy/whatDidIMean.d.ts +113 -0
  1182. package/dist/tools/goofy/whatDidIMean.d.ts.map +1 -0
  1183. package/dist/tools/goofy/whatDidIMean.js +401 -0
  1184. package/dist/tools/goofy/whatDidIMean.js.map +1 -0
  1185. package/dist/tools/goofy/yeahNahDeleteThat.d.ts +109 -0
  1186. package/dist/tools/goofy/yeahNahDeleteThat.d.ts.map +1 -0
  1187. package/dist/tools/goofy/yeahNahDeleteThat.js +319 -0
  1188. package/dist/tools/goofy/yeahNahDeleteThat.js.map +1 -0
  1189. package/dist/tools/index.d.ts +9 -0
  1190. package/dist/tools/index.d.ts.map +1 -0
  1191. package/dist/tools/index.js +9 -0
  1192. package/dist/tools/index.js.map +1 -0
  1193. package/dist/tools/teamMemberDeployer.d.ts +117 -0
  1194. package/dist/tools/teamMemberDeployer.d.ts.map +1 -0
  1195. package/dist/tools/teamMemberDeployer.js +613 -0
  1196. package/dist/tools/teamMemberDeployer.js.map +1 -0
  1197. package/dist/trace/index.d.ts +14 -0
  1198. package/dist/trace/index.d.ts.map +1 -0
  1199. package/dist/trace/index.js +16 -0
  1200. package/dist/trace/index.js.map +1 -0
  1201. package/dist/trace/tools/analyzeImpact.d.ts +90 -0
  1202. package/dist/trace/tools/analyzeImpact.d.ts.map +1 -0
  1203. package/dist/trace/tools/analyzeImpact.js +240 -0
  1204. package/dist/trace/tools/analyzeImpact.js.map +1 -0
  1205. package/dist/trace/tools/exploreDependencies.d.ts +81 -0
  1206. package/dist/trace/tools/exploreDependencies.d.ts.map +1 -0
  1207. package/dist/trace/tools/exploreDependencies.js +161 -0
  1208. package/dist/trace/tools/exploreDependencies.js.map +1 -0
  1209. package/dist/trace/tools/findSimilarBugs.d.ts +112 -0
  1210. package/dist/trace/tools/findSimilarBugs.d.ts.map +1 -0
  1211. package/dist/trace/tools/findSimilarBugs.js +216 -0
  1212. package/dist/trace/tools/findSimilarBugs.js.map +1 -0
  1213. package/dist/trace/tools/index.d.ts +22 -0
  1214. package/dist/trace/tools/index.d.ts.map +1 -0
  1215. package/dist/trace/tools/index.js +39 -0
  1216. package/dist/trace/tools/index.js.map +1 -0
  1217. package/dist/trace/tools/smartExplore.d.ts +126 -0
  1218. package/dist/trace/tools/smartExplore.d.ts.map +1 -0
  1219. package/dist/trace/tools/smartExplore.js +303 -0
  1220. package/dist/trace/tools/smartExplore.js.map +1 -0
  1221. package/dist/trace/tools/traceError.d.ts +101 -0
  1222. package/dist/trace/tools/traceError.d.ts.map +1 -0
  1223. package/dist/trace/tools/traceError.js +175 -0
  1224. package/dist/trace/tools/traceError.js.map +1 -0
  1225. package/dist/trace/traceExploreSystem.d.ts +271 -0
  1226. package/dist/trace/traceExploreSystem.d.ts.map +1 -0
  1227. package/dist/trace/traceExploreSystem.js +789 -0
  1228. package/dist/trace/traceExploreSystem.js.map +1 -0
  1229. package/dist/types/index.d.ts +421 -0
  1230. package/dist/types/index.d.ts.map +1 -0
  1231. package/dist/types/index.js +118 -0
  1232. package/dist/types/index.js.map +1 -0
  1233. package/dist/utils/circuitBreaker.d.ts +195 -0
  1234. package/dist/utils/circuitBreaker.d.ts.map +1 -0
  1235. package/dist/utils/circuitBreaker.js +374 -0
  1236. package/dist/utils/circuitBreaker.js.map +1 -0
  1237. package/dist/utils/cleanupHandler.d.ts +108 -0
  1238. package/dist/utils/cleanupHandler.d.ts.map +1 -0
  1239. package/dist/utils/cleanupHandler.js +203 -0
  1240. package/dist/utils/cleanupHandler.js.map +1 -0
  1241. package/dist/utils/compactXmlResponse.d.ts +60 -0
  1242. package/dist/utils/compactXmlResponse.d.ts.map +1 -0
  1243. package/dist/utils/compactXmlResponse.js +209 -0
  1244. package/dist/utils/compactXmlResponse.js.map +1 -0
  1245. package/dist/utils/cotBroadcast.d.ts +56 -0
  1246. package/dist/utils/cotBroadcast.d.ts.map +1 -0
  1247. package/dist/utils/cotBroadcast.js +157 -0
  1248. package/dist/utils/cotBroadcast.js.map +1 -0
  1249. package/dist/utils/debugLogger.d.ts +95 -0
  1250. package/dist/utils/debugLogger.d.ts.map +1 -0
  1251. package/dist/utils/debugLogger.js +610 -0
  1252. package/dist/utils/debugLogger.js.map +1 -0
  1253. package/dist/utils/fileProcessingQueue.d.ts +259 -0
  1254. package/dist/utils/fileProcessingQueue.d.ts.map +1 -0
  1255. package/dist/utils/fileProcessingQueue.js +714 -0
  1256. package/dist/utils/fileProcessingQueue.js.map +1 -0
  1257. package/dist/utils/humanReadableOutput.d.ts +124 -0
  1258. package/dist/utils/humanReadableOutput.d.ts.map +1 -0
  1259. package/dist/utils/humanReadableOutput.js +340 -0
  1260. package/dist/utils/humanReadableOutput.js.map +1 -0
  1261. package/dist/utils/index.d.ts +32 -0
  1262. package/dist/utils/index.d.ts.map +1 -0
  1263. package/dist/utils/index.js +71 -0
  1264. package/dist/utils/index.js.map +1 -0
  1265. package/dist/utils/instanceManager.d.ts +530 -0
  1266. package/dist/utils/instanceManager.d.ts.map +1 -0
  1267. package/dist/utils/instanceManager.js +1784 -0
  1268. package/dist/utils/instanceManager.js.map +1 -0
  1269. package/dist/utils/logger.d.ts +6 -0
  1270. package/dist/utils/logger.d.ts.map +1 -0
  1271. package/dist/utils/logger.js +49 -0
  1272. package/dist/utils/logger.js.map +1 -0
  1273. package/dist/utils/mapCleanup.d.ts +58 -0
  1274. package/dist/utils/mapCleanup.d.ts.map +1 -0
  1275. package/dist/utils/mapCleanup.js +150 -0
  1276. package/dist/utils/mapCleanup.js.map +1 -0
  1277. package/dist/utils/memoryManager.d.ts +349 -0
  1278. package/dist/utils/memoryManager.d.ts.map +1 -0
  1279. package/dist/utils/memoryManager.js +799 -0
  1280. package/dist/utils/memoryManager.js.map +1 -0
  1281. package/dist/utils/metrics.d.ts +160 -0
  1282. package/dist/utils/metrics.d.ts.map +1 -0
  1283. package/dist/utils/metrics.js +558 -0
  1284. package/dist/utils/metrics.js.map +1 -0
  1285. package/dist/utils/pathValidator.d.ts +96 -0
  1286. package/dist/utils/pathValidator.d.ts.map +1 -0
  1287. package/dist/utils/pathValidator.js +320 -0
  1288. package/dist/utils/pathValidator.js.map +1 -0
  1289. package/dist/utils/portAllocator.d.ts +296 -0
  1290. package/dist/utils/portAllocator.d.ts.map +1 -0
  1291. package/dist/utils/portAllocator.js +768 -0
  1292. package/dist/utils/portAllocator.js.map +1 -0
  1293. package/dist/utils/portUtils.d.ts +97 -0
  1294. package/dist/utils/portUtils.d.ts.map +1 -0
  1295. package/dist/utils/portUtils.js +285 -0
  1296. package/dist/utils/portUtils.js.map +1 -0
  1297. package/dist/utils/postgresAutoSetup.d.ts +55 -0
  1298. package/dist/utils/postgresAutoSetup.d.ts.map +1 -0
  1299. package/dist/utils/postgresAutoSetup.js +406 -0
  1300. package/dist/utils/postgresAutoSetup.js.map +1 -0
  1301. package/dist/utils/processHealthCheck.d.ts +61 -0
  1302. package/dist/utils/processHealthCheck.d.ts.map +1 -0
  1303. package/dist/utils/processHealthCheck.js +313 -0
  1304. package/dist/utils/processHealthCheck.js.map +1 -0
  1305. package/dist/utils/progressReporter.d.ts +151 -0
  1306. package/dist/utils/progressReporter.d.ts.map +1 -0
  1307. package/dist/utils/progressReporter.js +345 -0
  1308. package/dist/utils/progressReporter.js.map +1 -0
  1309. package/dist/utils/projectEnv.d.ts +73 -0
  1310. package/dist/utils/projectEnv.d.ts.map +1 -0
  1311. package/dist/utils/projectEnv.js +137 -0
  1312. package/dist/utils/projectEnv.js.map +1 -0
  1313. package/dist/utils/qoms.d.ts +122 -0
  1314. package/dist/utils/qoms.d.ts.map +1 -0
  1315. package/dist/utils/qoms.js +650 -0
  1316. package/dist/utils/qoms.js.map +1 -0
  1317. package/dist/utils/retryHelper.d.ts +122 -0
  1318. package/dist/utils/retryHelper.d.ts.map +1 -0
  1319. package/dist/utils/retryHelper.js +272 -0
  1320. package/dist/utils/retryHelper.js.map +1 -0
  1321. package/dist/utils/safeProcessTermination.d.ts +206 -0
  1322. package/dist/utils/safeProcessTermination.d.ts.map +1 -0
  1323. package/dist/utils/safeProcessTermination.js +552 -0
  1324. package/dist/utils/safeProcessTermination.js.map +1 -0
  1325. package/dist/utils/sessionInjector.d.ts +68 -0
  1326. package/dist/utils/sessionInjector.d.ts.map +1 -0
  1327. package/dist/utils/sessionInjector.js +189 -0
  1328. package/dist/utils/sessionInjector.js.map +1 -0
  1329. package/dist/utils/statsCache.d.ts +134 -0
  1330. package/dist/utils/statsCache.d.ts.map +1 -0
  1331. package/dist/utils/statsCache.js +285 -0
  1332. package/dist/utils/statsCache.js.map +1 -0
  1333. package/dist/utils/timeoutMiddleware.d.ts +81 -0
  1334. package/dist/utils/timeoutMiddleware.d.ts.map +1 -0
  1335. package/dist/utils/timeoutMiddleware.js +155 -0
  1336. package/dist/utils/timeoutMiddleware.js.map +1 -0
  1337. package/dist/utils/timerRegistry.d.ts +91 -0
  1338. package/dist/utils/timerRegistry.d.ts.map +1 -0
  1339. package/dist/utils/timerRegistry.js +187 -0
  1340. package/dist/utils/timerRegistry.js.map +1 -0
  1341. package/dist/utils/tokenCompressor.d.ts +332 -0
  1342. package/dist/utils/tokenCompressor.d.ts.map +1 -0
  1343. package/dist/utils/tokenCompressor.js +1306 -0
  1344. package/dist/utils/tokenCompressor.js.map +1 -0
  1345. package/dist/utils/tracing.d.ts +236 -0
  1346. package/dist/utils/tracing.d.ts.map +1 -0
  1347. package/dist/utils/tracing.js +378 -0
  1348. package/dist/utils/tracing.js.map +1 -0
  1349. package/dist/watcher/changeHandler.d.ts +123 -0
  1350. package/dist/watcher/changeHandler.d.ts.map +1 -0
  1351. package/dist/watcher/changeHandler.js +623 -0
  1352. package/dist/watcher/changeHandler.js.map +1 -0
  1353. package/dist/watcher/changeQueue.d.ts +133 -0
  1354. package/dist/watcher/changeQueue.d.ts.map +1 -0
  1355. package/dist/watcher/changeQueue.js +355 -0
  1356. package/dist/watcher/changeQueue.js.map +1 -0
  1357. package/dist/watcher/fileWatcher.d.ts +121 -0
  1358. package/dist/watcher/fileWatcher.d.ts.map +1 -0
  1359. package/dist/watcher/fileWatcher.js +531 -0
  1360. package/dist/watcher/fileWatcher.js.map +1 -0
  1361. package/dist/watcher/index.d.ts +94 -0
  1362. package/dist/watcher/index.d.ts.map +1 -0
  1363. package/dist/watcher/index.js +235 -0
  1364. package/dist/watcher/index.js.map +1 -0
  1365. package/dist/watcher/syncChecker.d.ts +93 -0
  1366. package/dist/watcher/syncChecker.d.ts.map +1 -0
  1367. package/dist/watcher/syncChecker.js +401 -0
  1368. package/dist/watcher/syncChecker.js.map +1 -0
  1369. package/dist/watcher/tsCompiler.d.ts +88 -0
  1370. package/dist/watcher/tsCompiler.d.ts.map +1 -0
  1371. package/dist/watcher/tsCompiler.js +212 -0
  1372. package/dist/watcher/tsCompiler.js.map +1 -0
  1373. package/embedding-sandbox/Dockerfile +77 -0
  1374. package/embedding-sandbox/Dockerfile.frankenstein +91 -0
  1375. package/embedding-sandbox/README.md +193 -0
  1376. package/embedding-sandbox/__pycache__/frankenstein-embeddings.cpython-312.pyc +0 -0
  1377. package/embedding-sandbox/__pycache__/frankenstein-embeddings.cpython-313.pyc +0 -0
  1378. package/embedding-sandbox/__pycache__/qqms_v2.cpython-312.pyc +0 -0
  1379. package/embedding-sandbox/__pycache__/qqms_v2.cpython-313.pyc +0 -0
  1380. package/embedding-sandbox/add_js_docs.py +684 -0
  1381. package/embedding-sandbox/build_docs_db.py +239 -0
  1382. package/embedding-sandbox/client.cjs +376 -0
  1383. package/embedding-sandbox/client.ts +913 -0
  1384. package/embedding-sandbox/deploy-frankenstein.sh +240 -0
  1385. package/embedding-sandbox/docker-compose.yml +60 -0
  1386. package/embedding-sandbox/docker-manager.py +325 -0
  1387. package/embedding-sandbox/docs/python_docs.db +0 -0
  1388. package/embedding-sandbox/download-model.mjs +79 -0
  1389. package/embedding-sandbox/download-model.py +28 -0
  1390. package/embedding-sandbox/embedding-supervisor.sh +164 -0
  1391. package/embedding-sandbox/frankenstein-embeddings.py +3940 -0
  1392. package/embedding-sandbox/manage-services.sh +354 -0
  1393. package/embedding-sandbox/overflow_queue.py +345 -0
  1394. package/embedding-sandbox/package.json +17 -0
  1395. package/embedding-sandbox/project_isolation.py +292 -0
  1396. package/embedding-sandbox/qqms_v2.py +967 -0
  1397. package/embedding-sandbox/ram-manager.sh +311 -0
  1398. package/embedding-sandbox/requirements-frankenstein.txt +7 -0
  1399. package/embedding-sandbox/run_js_docs.py +59 -0
  1400. package/embedding-sandbox/seed_docs.py +885 -0
  1401. package/embedding-sandbox/server-batch.mjs +228 -0
  1402. package/embedding-sandbox/server.mjs +389 -0
  1403. package/embedding-sandbox/specmem/sockets/claude-input-state.json +1 -0
  1404. package/embedding-sandbox/specmem/sockets/embedding-death-reason.txt +3 -0
  1405. package/embedding-sandbox/specmem/sockets/seen-sessions.json +1 -0
  1406. package/embedding-sandbox/specmem/sockets/session-start.lock +1 -0
  1407. package/embedding-sandbox/specmem/sockets/session-stops.log +7 -0
  1408. package/embedding-sandbox/start-frankenstein-throttled.sh +98 -0
  1409. package/embedding-sandbox/start-on-demand.sh +116 -0
  1410. package/embedding-sandbox/start-sandbox.sh +237 -0
  1411. package/embedding-sandbox/start-supervised.sh +11 -0
  1412. package/embedding-sandbox/stop-sandbox.sh +51 -0
  1413. package/embedding-sandbox/test-socket.mjs +61 -0
  1414. package/embedding-sandbox/warm-start.sh +353 -0
  1415. package/embedding-sandbox/warm_start_feeder.py +660 -0
  1416. package/legal/README.md +31 -0
  1417. package/legal/anthropic-privacy-center-screenshot-2026-01-30.png +0 -0
  1418. package/legal/anthropic-tos-screenshot-2026-01-30.png +0 -0
  1419. package/lib/codebase-bridge.cjs +308 -0
  1420. package/package.json +136 -0
  1421. package/plugins/specmem-agents/agents/bug-hunter.md +79 -0
  1422. package/plugins/specmem-agents/agents/memory-explorer.md +57 -0
  1423. package/plugins/specmem-agents/agents/team-coordinator.md +82 -0
  1424. package/scripts/auto-updater.cjs +399 -0
  1425. package/scripts/backfill-code-definition-embeddings.ts +440 -0
  1426. package/scripts/backfill-code-embeddings.ts +206 -0
  1427. package/scripts/capture-tos-screenshots.cjs +94 -0
  1428. package/scripts/check-global-install.cjs +67 -0
  1429. package/scripts/cleanup-embedding-servers.sh +25 -0
  1430. package/scripts/dashboard-standalone.sh +369 -0
  1431. package/scripts/deploy-hooks.cjs +1451 -0
  1432. package/scripts/deploy.sh +106 -0
  1433. package/scripts/docker-project-down.sh +83 -0
  1434. package/scripts/docker-project-list.sh +40 -0
  1435. package/scripts/docker-project-up.sh +79 -0
  1436. package/scripts/fast-backfill-embeddings.ts +173 -0
  1437. package/scripts/fast-batch-embedder.cjs +334 -0
  1438. package/scripts/first-run-model-setup.cjs +849 -0
  1439. package/scripts/global-postinstall.cjs +1957 -0
  1440. package/scripts/index-codebase.js +72 -0
  1441. package/scripts/migrate-fix-embeddings.py +110 -0
  1442. package/scripts/migrate-to-project-schemas.ts +525 -0
  1443. package/scripts/optimize-embedding-model.py +324 -0
  1444. package/scripts/optimize-instructions.cjs +530 -0
  1445. package/scripts/pack-docker-images.sh +68 -0
  1446. package/scripts/pack-for-testing.sh +130 -0
  1447. package/scripts/postinstall.cjs +54 -0
  1448. package/scripts/project-env.sh +51 -0
  1449. package/scripts/reset-db.sh +30 -0
  1450. package/scripts/run-indexer.ts +69 -0
  1451. package/scripts/run-migrations.js +47 -0
  1452. package/scripts/setup-db.sh +34 -0
  1453. package/scripts/setup-minimal-schema.sql +143 -0
  1454. package/scripts/skills/code-review.md +44 -0
  1455. package/scripts/skills/debugging.md +56 -0
  1456. package/scripts/skills/specmem-deployteam.md +239 -0
  1457. package/scripts/skills/teammemberskills/EFFICIENT_GREP.md +171 -0
  1458. package/scripts/skills/teammemberskills/task-planning.md +67 -0
  1459. package/scripts/specmem/sockets/session-start.lock +1 -0
  1460. package/scripts/specmem/sockets/session-stops.log +1 -0
  1461. package/scripts/specmem-health.sh +382 -0
  1462. package/scripts/specmem-init.cjs +6935 -0
  1463. package/scripts/strip-debug-logs.cjs +43 -0
  1464. package/scripts/test-mcp-standalone.sh +365 -0
  1465. package/scripts/test-optimized-models.py +166 -0
  1466. package/scripts/verify-embedding-fix.sh +148 -0
  1467. package/skills/code-review.md +44 -0
  1468. package/skills/debugging.md +56 -0
  1469. package/skills/specmem-deployteam.md +239 -0
  1470. package/skills/teammemberskills/EFFICIENT_GREP.md +171 -0
  1471. package/skills/teammemberskills/task-planning.md +67 -0
  1472. package/specmem-health.cjs +522 -0
  1473. package/specmem.env +216 -0
@@ -0,0 +1,1735 @@
1
+ /**
2
+ * codebaseIndexer.ts - Intelligent Codebase Indexing System
3
+ *
4
+ * yo this indexer is the BRAINS of the operation fr fr
5
+ * scans the codebase (configurable via SPECMEM_CODEBASE_PATH), stores it with embeddings
6
+ * and keeps it updated automatically when files change
7
+ *
8
+ * Features:
9
+ * - Full recursive codebase scanning
10
+ * - Smart exclusions (node_modules, .git, dist, etc.)
11
+ * - File type detection and language awareness
12
+ * - Embedding generation for semantic search
13
+ * - Auto-update via file watching
14
+ * - Incremental updates (only changed files)
15
+ * - Code definition extraction (functions, classes, etc.)
16
+ * - Dependency/import tracking
17
+ * - Code complexity metrics
18
+ * - Semantic code chunking for better search
19
+ *
20
+ * Now integrated with LWJEB event bus for codebase:scan events
21
+ * and enhanced with CodeAnalyzer for semantic code understanding
22
+ */
23
+ import * as fs from 'fs/promises';
24
+ import * as path from 'path';
25
+ import * as crypto from 'crypto';
26
+ import { v4 as uuidv4 } from 'uuid';
27
+ import chokidar from 'chokidar';
28
+ import { logger } from '../utils/logger.js';
29
+ import { getProjectPath } from '../config.js';
30
+ import { getCoordinator } from '../coordination/integration.js';
31
+ import { getDimensionService } from '../services/DimensionService.js';
32
+ import { getProjectContext } from '../services/ProjectContext.js';
33
+ import { getCodeAnalyzer } from './codeAnalyzer.js';
34
+ import { TEXT_LIMITS } from '../constants.js';
35
+ /**
36
+ * Default configuration that slaps
37
+ * Uses environment variable or current working directory for codebase path
38
+ */
39
+ const DEFAULT_CONFIG = {
40
+ codebasePath: process.env['SPECMEM_CODEBASE_PATH'] || process.cwd(),
41
+ excludePatterns: [
42
+ 'node_modules',
43
+ '.git',
44
+ 'dist',
45
+ 'build',
46
+ '.next',
47
+ 'coverage',
48
+ '.cache',
49
+ '__pycache__',
50
+ '.pytest_cache',
51
+ '.mypy_cache',
52
+ 'venv',
53
+ '.venv',
54
+ 'env',
55
+ '.env',
56
+ '*.pyc',
57
+ '*.pyo',
58
+ '*.so',
59
+ '*.dylib',
60
+ '*.dll',
61
+ '*.exe',
62
+ '*.bin',
63
+ '*.log',
64
+ '*.lock',
65
+ 'package-lock.json',
66
+ 'yarn.lock',
67
+ 'pnpm-lock.yaml',
68
+ '.DS_Store',
69
+ 'Thumbs.db'
70
+ ],
71
+ includeExtensions: [
72
+ '.js', '.ts', '.jsx', '.tsx', '.mjs', '.cjs',
73
+ '.py', '.pyi',
74
+ '.json',
75
+ '.md', '.markdown', '.rst', '.txt',
76
+ '.yaml', '.yml',
77
+ '.toml', '.ini', '.cfg',
78
+ '.sh', '.bash', '.zsh',
79
+ '.css', '.scss', '.sass', '.less',
80
+ '.html', '.htm', '.xml',
81
+ '.sql',
82
+ '.go',
83
+ '.rs',
84
+ '.java', '.kt', '.scala',
85
+ '.rb',
86
+ '.php',
87
+ '.c', '.cpp', '.h', '.hpp',
88
+ '.swift',
89
+ '.dockerfile', 'Dockerfile',
90
+ '.env.example', '.env.template'
91
+ ],
92
+ maxFileSizeBytes: 1024 * 1024, // 1MB
93
+ generateEmbeddings: true,
94
+ watchForChanges: true,
95
+ debounceMs: 1000,
96
+ batchSize: 50,
97
+ maxDepth: 30,
98
+ // Enhanced analysis options - semantic search goes CRAZY with these
99
+ extractDefinitions: true,
100
+ trackDependencies: true,
101
+ calculateComplexity: true,
102
+ chunkCode: true,
103
+ chunkSize: 50,
104
+ chunkOverlap: 10,
105
+ generateChunkEmbeddings: true
106
+ };
107
+ /**
108
+ * Language detection mapping
109
+ */
110
+ const LANGUAGE_MAP = {
111
+ '.js': 'javascript',
112
+ '.mjs': 'javascript',
113
+ '.cjs': 'javascript',
114
+ '.ts': 'typescript',
115
+ '.jsx': 'javascript-react',
116
+ '.tsx': 'typescript-react',
117
+ '.py': 'python',
118
+ '.pyi': 'python',
119
+ '.json': 'json',
120
+ '.md': 'markdown',
121
+ '.markdown': 'markdown',
122
+ '.yaml': 'yaml',
123
+ '.yml': 'yaml',
124
+ '.toml': 'toml',
125
+ '.sh': 'bash',
126
+ '.bash': 'bash',
127
+ '.zsh': 'zsh',
128
+ '.css': 'css',
129
+ '.scss': 'scss',
130
+ '.sass': 'sass',
131
+ '.html': 'html',
132
+ '.xml': 'xml',
133
+ '.sql': 'sql',
134
+ '.go': 'go',
135
+ '.rs': 'rust',
136
+ '.java': 'java',
137
+ '.kt': 'kotlin',
138
+ '.rb': 'ruby',
139
+ '.php': 'php',
140
+ '.c': 'c',
141
+ '.cpp': 'cpp',
142
+ '.h': 'c-header',
143
+ '.hpp': 'cpp-header',
144
+ '.swift': 'swift'
145
+ };
146
+ /**
147
+ * CodebaseIndexer - the main indexing engine
148
+ *
149
+ * scans your entire codebase and makes it searchable
150
+ * uses embeddings for semantic search no cap
151
+ *
152
+ * Emits LWJEB events: codebase:scan:start, codebase:scan:complete, codebase:scan:progress, codebase:file:indexed
153
+ *
154
+ * Now enhanced with:
155
+ * - Code definition extraction (functions, classes, etc.)
156
+ * - Dependency/import tracking
157
+ * - Code complexity metrics
158
+ * - Semantic code chunking
159
+ */
160
+ export class CodebaseIndexer {
161
+ config;
162
+ index = new Map();
163
+ embeddingProvider;
164
+ db;
165
+ watcher = null;
166
+ isWatching = false;
167
+ lastFullScan = null;
168
+ lastUpdate = null;
169
+ pendingUpdates = new Map();
170
+ updateTimer = null;
171
+ isProcessing = false;
172
+ // Enhanced analysis
173
+ codeAnalyzer;
174
+ definitionsIndex = new Map();
175
+ dependenciesIndex = new Map();
176
+ chunksIndex = new Map();
177
+ complexityIndex = new Map();
178
+ // Dimension service for dynamic embedding handling
179
+ dimensionService = null;
180
+ constructor(config = {}, embeddingProvider = null, db = null) {
181
+ this.config = { ...DEFAULT_CONFIG, ...config };
182
+ this.embeddingProvider = embeddingProvider;
183
+ this.db = db;
184
+ this.codeAnalyzer = getCodeAnalyzer({
185
+ chunkSize: this.config.chunkSize,
186
+ chunkOverlap: this.config.chunkOverlap
187
+ });
188
+ // Initialize dimension service if db is available
189
+ if (db) {
190
+ try {
191
+ this.dimensionService = getDimensionService(db, embeddingProvider || undefined);
192
+ }
193
+ catch (err) {
194
+ // dimension service unavailable at init - will retry on first use
195
+ logger.debug({ error: String(err) }, 'DimensionService init deferred - will retry lazily');
196
+ }
197
+ }
198
+ }
199
+ /**
200
+ * Get the DimensionService (lazy initialization)
201
+ */
202
+ getDimService() {
203
+ if (!this.dimensionService && this.db) {
204
+ try {
205
+ this.dimensionService = getDimensionService(this.db, this.embeddingProvider || undefined);
206
+ }
207
+ catch (err) {
208
+ // dimension service still not available - embeddings will use raw dimensions
209
+ logger.debug({ error: String(err) }, 'DimensionService unavailable - using raw embedding dimensions');
210
+ }
211
+ }
212
+ return this.dimensionService;
213
+ }
214
+ /**
215
+ * Prepare embedding for database storage - projects to target dimension if needed.
216
+ * Uses DimensionService to handle dimension mismatches.
217
+ *
218
+ * @param embedding - The raw embedding from the embedding provider
219
+ * @param tableName - Target table for dimension lookup
220
+ * @param originalText - Original text for re-embedding if needed
221
+ * @returns Formatted embedding string for PostgreSQL, or null if no embedding
222
+ */
223
+ async prepareEmbeddingForStorage(embedding, tableName, originalText) {
224
+ if (!embedding || embedding.length === 0)
225
+ return null;
226
+ const dimService = this.getDimService();
227
+ if (!dimService) {
228
+ // No dimension service available - return embedding as-is
229
+ return `[${embedding.join(',')}]`;
230
+ }
231
+ try {
232
+ const prepared = await dimService.validateAndPrepare(tableName, embedding, originalText);
233
+ if (prepared.wasModified) {
234
+ logger.debug({
235
+ action: prepared.action,
236
+ tableName,
237
+ originalDim: embedding.length,
238
+ newDim: prepared.embedding.length
239
+ }, 'Projected embedding to target dimension for storage');
240
+ }
241
+ return `[${prepared.embedding.join(',')}]`;
242
+ }
243
+ catch (error) {
244
+ logger.warn({ error, tableName }, 'Failed to prepare embedding, using original');
245
+ return `[${embedding.join(',')}]`;
246
+ }
247
+ }
248
+ /**
249
+ * Get coordinator lazily to avoid circular dependency during initialization
250
+ */
251
+ getCoordinatorSafe() {
252
+ try {
253
+ return getCoordinator();
254
+ }
255
+ catch (e) {
256
+ // Coordinator not initialized yet - this is expected during startup
257
+ return null;
258
+ }
259
+ }
260
+ /**
261
+ * initialize - starts the indexer with initial scan
262
+ */
263
+ async initialize() {
264
+ logger.info({ codebasePath: this.config.codebasePath }, 'initializing codebase indexer...');
265
+ // perform initial full scan with PARALLEL batch embedding for speed
266
+ await this.fullScanParallel();
267
+ // start file watcher if enabled
268
+ if (this.config.watchForChanges) {
269
+ await this.startWatching();
270
+ }
271
+ const stats = this.getStats();
272
+ logger.info({
273
+ totalFiles: stats.totalFiles,
274
+ totalLines: stats.totalLines,
275
+ watching: stats.isWatching
276
+ }, 'codebase indexer initialized - we ready to search fr fr');
277
+ return stats;
278
+ }
279
+ /**
280
+ * fullScan - performs a complete scan of the codebase
281
+ * OPTIMIZED: Skips unchanged files using hash comparison against DB
282
+ * Emits LWJEB events: codebase:scan:start, codebase:scan:progress, codebase:scan:complete
283
+ */
284
+ async fullScan() {
285
+ const coordinator = this.getCoordinatorSafe();
286
+ logger.info({ path: this.config.codebasePath }, 'starting full codebase scan...');
287
+ const startTime = Date.now();
288
+ // Emit codebase:scan:start event via LWJEB
289
+ coordinator?.emitCodebaseScanStart(this.config.codebasePath, 'full');
290
+ // Load existing file hashes from DB to skip unchanged files - filtered by project
291
+ const existingHashes = new Map();
292
+ const projectPath = getProjectContext().getProjectPath();
293
+ if (this.db) {
294
+ try {
295
+ const result = await this.db.query(`SELECT file_path, content_hash FROM codebase_files WHERE content_hash IS NOT NULL AND project_path = $1`, [projectPath]);
296
+ for (const row of result.rows) {
297
+ existingHashes.set(row.file_path, row.content_hash);
298
+ }
299
+ logger.info({ cachedFiles: existingHashes.size, projectPath }, 'loaded existing file hashes for skip check');
300
+ }
301
+ catch (error) {
302
+ logger.warn({ error }, 'failed to load existing hashes, will reindex all');
303
+ }
304
+ }
305
+ // clear existing in-memory index
306
+ this.index.clear();
307
+ // find all files
308
+ const files = await this.findFiles(this.config.codebasePath, 0);
309
+ logger.info({ fileCount: files.length }, 'found files to index');
310
+ let skipped = 0;
311
+ let indexed = 0;
312
+ const changedFiles = [];
313
+ // process files in batches
314
+ for (let i = 0; i < files.length; i += this.config.batchSize) {
315
+ const batch = files.slice(i, i + this.config.batchSize);
316
+ await Promise.all(batch.map(async (filePath) => {
317
+ try {
318
+ const relativePath = path.relative(this.config.codebasePath, filePath);
319
+ // Quick hash check - read file and compute hash first
320
+ const stats = await fs.stat(filePath);
321
+ if (stats.size > this.config.maxFileSizeBytes)
322
+ return;
323
+ if (await this.isBinaryFile(filePath))
324
+ return;
325
+ const content = await fs.readFile(filePath, 'utf-8');
326
+ const contentHash = this.hashContent(content);
327
+ // Check if file unchanged
328
+ const existingHash = existingHashes.get(relativePath);
329
+ if (existingHash === contentHash) {
330
+ skipped++;
331
+ return; // Skip - file hasn't changed
332
+ }
333
+ // File is new or changed - full index
334
+ const indexedFile = await this.indexFile(filePath);
335
+ if (indexedFile) {
336
+ this.index.set(indexedFile.filePath, indexedFile);
337
+ changedFiles.push(indexedFile);
338
+ indexed++;
339
+ // Emit codebase:file:indexed event via LWJEB
340
+ coordinator?.emitCodebaseFileIndexed(indexedFile.filePath, indexedFile.language, indexedFile.lineCount, !!indexedFile.embedding);
341
+ }
342
+ }
343
+ catch (error) {
344
+ logger.warn({ error, filePath }, 'failed to index file');
345
+ }
346
+ }));
347
+ // progress update
348
+ const processed = Math.min(i + this.config.batchSize, files.length);
349
+ logger.debug({ processed, total: files.length, skipped, indexed }, 'indexing progress');
350
+ // Emit codebase:scan:progress event via LWJEB
351
+ coordinator?.emitCodebaseScanProgress(processed, files.length);
352
+ }
353
+ this.lastFullScan = new Date();
354
+ this.lastUpdate = new Date();
355
+ // persist ONLY changed files to database
356
+ if (this.db && changedFiles.length > 0) {
357
+ await this.persistToDatabase(changedFiles);
358
+ }
359
+ const duration = Date.now() - startTime;
360
+ const totalLines = Array.from(this.index.values()).reduce((sum, f) => sum + f.lineCount, 0);
361
+ // Emit codebase:scan:complete event via LWJEB
362
+ coordinator?.emitCodebaseScanComplete(this.config.codebasePath, this.index.size, totalLines, duration, true);
363
+ logger.info({
364
+ filesIndexed: indexed,
365
+ filesSkipped: skipped,
366
+ duration,
367
+ linesIndexed: totalLines
368
+ }, 'full codebase scan complete (hash-optimized)');
369
+ }
370
+ /**
371
+ * fullScanParallel - OPTIMIZED scan with parallel batch embedding
372
+ * Uses session watcher pattern: collect → parallel embed → batch insert with ACK
373
+ *
374
+ * Key optimizations:
375
+ * 1. Two-pass scan: metadata first, then batch embeddings
376
+ * 2. Dynamic batch sizing based on file count
377
+ * 3. Parallel embedding generation with Promise.all()
378
+ * 4. ACK verification with RETURNING clause
379
+ * 5. Progress streaming with rate limiting
380
+ * 6. Memory-efficient: don't store full content in memory
381
+ * 7. Concurrency limits to prevent OOM crashes
382
+ */
383
+ async fullScanParallel() {
384
+ const coordinator = this.getCoordinatorSafe();
385
+ const projectPath = getProjectContext().getProjectPath();
386
+ const startTime = Date.now();
387
+ logger.info({ path: this.config.codebasePath }, '🚀 starting PARALLEL codebase scan...');
388
+ coordinator?.emitCodebaseScanStart(this.config.codebasePath, 'full');
389
+ // Load existing hashes AND mtimes for fast deduplication
390
+ // OPTIMIZATION: mtime check is ~100x faster than reading file to compute hash
391
+ const existingFiles = new Map(); // file_path -> { hash, mtime }
392
+ if (this.db) {
393
+ try {
394
+ const result = await this.db.query(
395
+ `SELECT file_path, content_hash, last_modified FROM codebase_files WHERE content_hash IS NOT NULL AND project_path = $1`,
396
+ [projectPath]
397
+ );
398
+ for (const row of result.rows) {
399
+ existingFiles.set(row.file_path, {
400
+ hash: row.content_hash,
401
+ mtime: row.last_modified ? new Date(row.last_modified).getTime() : 0
402
+ });
403
+ }
404
+ logger.info({ existingCount: existingFiles.size }, 'loaded existing files (hash+mtime) for fast deduplication');
405
+ }
406
+ catch (error) {
407
+ logger.warn({ error }, 'failed to load existing file data');
408
+ }
409
+ }
410
+ // Clear in-memory index - MEMORY FIX: Only store metadata, not full content
411
+ this.index.clear();
412
+ this.definitionsIndex.clear();
413
+ this.chunksIndex.clear();
414
+ // PHASE 1: Find all files
415
+ const files = await this.findFiles(this.config.codebasePath, 0);
416
+ logger.info({ fileCount: files.length }, 'found files to scan');
417
+ // MEMORY FIX: Smaller batches to prevent OOM at 70%
418
+ // Dynamic batch sizing: reduced from 200 max to 50 max for stability
419
+ // Larger batches caused memory pressure and crashes
420
+ const dynamicBatchSize = Math.min(Math.max(25, Math.ceil(files.length / 2000)), 50);
421
+ logger.info({ dynamicBatchSize, totalFiles: files.length }, 'using dynamic batch size (memory-optimized)');
422
+ // Stats tracking with ACK counts
423
+ let totalProcessed = 0;
424
+ let totalSkipped = 0;
425
+ let totalMtimeSkipped = 0; // Fast path: skipped via mtime (no file read)
426
+ let totalHashSkipped = 0; // Slow path: skipped via hash (file read required)
427
+ let totalIndexed = 0;
428
+ let totalAckSuccess = 0;
429
+ let totalAckFailed = 0;
430
+ let totalEmbeddings = 0;
431
+ // PHASE 2: Process files in batches with parallel embedding
432
+ for (let i = 0; i < files.length; i += dynamicBatchSize) {
433
+ const batchFiles = files.slice(i, i + dynamicBatchSize);
434
+ const batchStartTime = Date.now();
435
+ // 2a: Read and filter files (parallel)
436
+ const fileDataPromises = batchFiles.map(async (filePath) => {
437
+ try {
438
+ const relativePath = path.relative(this.config.codebasePath, filePath);
439
+ const stats = await fs.stat(filePath);
440
+ if (stats.size > this.config.maxFileSizeBytes)
441
+ return null;
442
+ // MTIME-FIRST OPTIMIZATION: Skip file read if mtime unchanged
443
+ // stat() is ~100x faster than read(), saves massive I/O on unchanged files
444
+ const existing = existingFiles.get(relativePath);
445
+ if (existing && existing.mtime && stats.mtime.getTime() <= existing.mtime) {
446
+ // mtime unchanged = file unchanged, skip without reading
447
+ return { skipped: true, relativePath, mtimeSkip: true };
448
+ }
449
+ if (await this.isBinaryFile(filePath))
450
+ return null;
451
+ const content = await fs.readFile(filePath, 'utf-8');
452
+ const contentHash = this.hashContent(content);
453
+ // Fallback: hash check for files with changed mtime but same content
454
+ if (existing && existing.hash === contentHash) {
455
+ return { skipped: true, relativePath, hashSkip: true };
456
+ }
457
+ const fileName = path.basename(filePath);
458
+ const extension = path.extname(filePath).toLowerCase();
459
+ const language = this.detectLanguage(fileName, extension);
460
+ return {
461
+ skipped: false,
462
+ id: uuidv4(),
463
+ filePath: relativePath,
464
+ absolutePath: filePath,
465
+ fileName,
466
+ extension,
467
+ language,
468
+ content,
469
+ contentHash,
470
+ sizeBytes: stats.size,
471
+ lineCount: content.split('\n').length,
472
+ lastModified: stats.mtime,
473
+ lastIndexed: new Date()
474
+ };
475
+ }
476
+ catch (err) {
477
+ // file read/hash failed - log with path context for debugging
478
+ logger.debug({ filePath, error: String(err) }, 'failed to read file during parallel scan');
479
+ return null;
480
+ }
481
+ });
482
+ const fileDataResults = await Promise.all(fileDataPromises);
483
+ // Filter out nulls and skipped
484
+ const filesToEmbed = [];
485
+ for (const result of fileDataResults) {
486
+ if (!result)
487
+ continue;
488
+ if (result.skipped) {
489
+ totalSkipped++;
490
+ if (result.mtimeSkip) totalMtimeSkipped++;
491
+ if (result.hashSkip) totalHashSkipped++;
492
+ continue;
493
+ }
494
+ filesToEmbed.push(result);
495
+ }
496
+ // 2b: Generate embeddings using BATCH API (single socket request for all texts!)
497
+ // This is 5-10x faster than individual Promise.all calls
498
+ // STABILITY FIX: Add timeout and graceful degradation to prevent system crashes
499
+ if (this.embeddingProvider && filesToEmbed.length > 0) {
500
+ const embeddingTexts = filesToEmbed.map(f => this.createEmbeddingText(f));
501
+ const EMBEDDING_BATCH_TIMEOUT_MS = 60000; // 60 second timeout per batch
502
+ try {
503
+ // Use batch method if available (single socket request!)
504
+ let embeddings;
505
+ // Wrap in timeout to prevent hanging if embedding server is overwhelmed
506
+ const embeddingPromise = this.embeddingProvider.generateEmbeddingsBatch
507
+ ? this.embeddingProvider.generateEmbeddingsBatch(embeddingTexts)
508
+ : Promise.all(embeddingTexts.map(text => this.embeddingProvider.generateEmbedding(text)));
509
+ embeddings = await Promise.race([
510
+ embeddingPromise,
511
+ new Promise((_, reject) => setTimeout(() => reject(new Error(`Embedding timeout after ${EMBEDDING_BATCH_TIMEOUT_MS}ms`)), EMBEDDING_BATCH_TIMEOUT_MS))
512
+ ]);
513
+ // Attach embeddings to files
514
+ for (let j = 0; j < filesToEmbed.length; j++) {
515
+ filesToEmbed[j].embedding = embeddings[j];
516
+ totalEmbeddings++;
517
+ }
518
+ }
519
+ catch (error) {
520
+ // Log but continue - don't crash the entire scan
521
+ const errorMsg = error instanceof Error ? error.message : String(error);
522
+ const isTimeout = errorMsg.includes('timeout');
523
+ logger.warn({
524
+ error: errorMsg,
525
+ batchIndex: Math.floor(i / dynamicBatchSize),
526
+ batchSize: filesToEmbed.length,
527
+ isTimeout
528
+ }, isTimeout ? 'embedding timeout - server may be overloaded' : 'batch embedding failed, continuing without embeddings');
529
+ // STABILITY FIX: If embedding is timing out, skip definition embeddings too
530
+ // to prevent cascade failures
531
+ if (isTimeout) {
532
+ logger.info('Skipping definition embeddings due to server overload');
533
+ }
534
+ }
535
+ }
536
+ // 2c: Enhanced analysis for each file (definitions, chunks, etc.)
537
+ for (const file of filesToEmbed) {
538
+ if (this.shouldAnalyze(file.language)) {
539
+ try {
540
+ const analysis = await this.codeAnalyzer.analyzeFile(file.id, file.filePath, file.content, file.language);
541
+ file.analysis = analysis;
542
+ this.definitionsIndex.set(file.filePath, analysis.definitions);
543
+ this.chunksIndex.set(file.filePath, analysis.chunks);
544
+ }
545
+ catch (err) {
546
+ // code analysis failed - log with file context for debugging
547
+ logger.debug({ filePath: file.filePath, language: file.language, error: String(err) }, 'code analysis failed - indexing without definitions/chunks');
548
+ }
549
+ }
550
+ totalIndexed++;
551
+ }
552
+ // 2d: Persist batch to DB with ACK verification (needs full content)
553
+ if (this.db && filesToEmbed.length > 0) {
554
+ const ackResult = await this.persistBatchWithAck(filesToEmbed, projectPath);
555
+ totalAckSuccess += ackResult.success;
556
+ totalAckFailed += ackResult.failed;
557
+ }
558
+ // 2e: MEMORY FIX - Now that content is persisted to DB, create lightweight index entries
559
+ // This prevents OOM at 70% on large codebases
560
+ for (const file of filesToEmbed) {
561
+ const lightFile = {
562
+ ...file,
563
+ content: '', // Clear content to free memory - it's in DB now
564
+ analysis: undefined // Analysis data is indexed separately
565
+ };
566
+ this.index.set(file.filePath, lightFile);
567
+ }
568
+ // MEMORY FIX: Help garbage collector by clearing references
569
+ // and hinting that we're done with this batch
570
+ filesToEmbed.length = 0; // Clear array
571
+ totalProcessed += batchFiles.length;
572
+ const batchDuration = Date.now() - batchStartTime;
573
+ // STABILITY FIX: Check memory usage and log warning if high
574
+ const memUsage = process.memoryUsage();
575
+ const heapUsedMB = Math.round(memUsage.heapUsed / 1024 / 1024);
576
+ const heapTotalMB = Math.round(memUsage.heapTotal / 1024 / 1024);
577
+ const usagePercent = Math.round((memUsage.heapUsed / memUsage.heapTotal) * 100);
578
+ if (usagePercent > 85) {
579
+ logger.warn({
580
+ heapUsedMB,
581
+ heapTotalMB,
582
+ usagePercent,
583
+ processed: totalProcessed,
584
+ total: files.length
585
+ }, '⚠️ HIGH MEMORY USAGE - may need to reduce batch size');
586
+ // Force garbage collection if available (run node with --expose-gc)
587
+ if (global.gc) {
588
+ global.gc();
589
+ logger.info('Forced garbage collection due to high memory');
590
+ }
591
+ }
592
+ // Progress logging every 10 batches
593
+ if ((i / dynamicBatchSize) % 10 === 0) {
594
+ const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
595
+ const rate = Math.round(totalProcessed / parseFloat(elapsed));
596
+ logger.info({
597
+ processed: totalProcessed,
598
+ indexed: totalIndexed,
599
+ skipped: totalSkipped,
600
+ mtimeSkip: totalMtimeSkipped,
601
+ hashSkip: totalHashSkipped,
602
+ embeddings: totalEmbeddings,
603
+ ackSuccess: totalAckSuccess,
604
+ ackFailed: totalAckFailed,
605
+ elapsedSec: elapsed,
606
+ filesPerSec: rate,
607
+ batchMs: batchDuration
608
+ }, '📊 parallel scan progress');
609
+ }
610
+ // Emit progress event
611
+ coordinator?.emitCodebaseScanProgress(totalProcessed, files.length);
612
+ }
613
+ this.lastFullScan = new Date();
614
+ this.lastUpdate = new Date();
615
+ const duration = Date.now() - startTime;
616
+ const totalLines = Array.from(this.index.values()).reduce((sum, f) => sum + f.lineCount, 0);
617
+ coordinator?.emitCodebaseScanComplete(this.config.codebasePath, this.index.size, totalLines, duration, true);
618
+ logger.info({
619
+ filesProcessed: totalProcessed,
620
+ filesIndexed: totalIndexed,
621
+ filesSkipped: totalSkipped,
622
+ mtimeSkipped: totalMtimeSkipped, // Fast path - no file read needed
623
+ hashSkipped: totalHashSkipped, // Slow path - file read required
624
+ embeddingsGenerated: totalEmbeddings,
625
+ ackSuccess: totalAckSuccess,
626
+ ackFailed: totalAckFailed,
627
+ durationMs: duration,
628
+ durationSec: (duration / 1000).toFixed(1),
629
+ filesPerSec: Math.round(totalProcessed / (duration / 1000)),
630
+ linesIndexed: totalLines
631
+ }, `✅ PARALLEL codebase scan complete! (${totalMtimeSkipped} mtime-skipped, ${totalHashSkipped} hash-skipped)`);
632
+ }
633
+ /**
634
+ * persistBatchWithAck - persist files with ACK verification using RETURNING
635
+ */
636
+ async persistBatchWithAck(files, projectPath) {
637
+ let success = 0;
638
+ let failed = 0;
639
+ if (!this.db)
640
+ return { success, failed };
641
+ for (const file of files) {
642
+ try {
643
+ const embeddingStr = await this.prepareEmbeddingForStorage(file.embedding, 'codebase_files', this.createEmbeddingText(file));
644
+ // ACK verification: RETURNING id confirms the write
645
+ const result = await this.db.query(`INSERT INTO codebase_files (
646
+ id, file_path, absolute_path, file_name, extension,
647
+ language_id, language_name, content, content_hash,
648
+ size_bytes, line_count, embedding, project_path
649
+ ) VALUES (
650
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13
651
+ )
652
+ ON CONFLICT (file_path, project_path) DO UPDATE SET
653
+ content = EXCLUDED.content,
654
+ content_hash = EXCLUDED.content_hash,
655
+ size_bytes = EXCLUDED.size_bytes,
656
+ line_count = EXCLUDED.line_count,
657
+ embedding = COALESCE(EXCLUDED.embedding, codebase_files.embedding),
658
+ updated_at = NOW()
659
+ RETURNING id`, [
660
+ file.id,
661
+ file.filePath,
662
+ file.absolutePath,
663
+ file.fileName,
664
+ file.extension,
665
+ file.language.toLowerCase(),
666
+ file.language,
667
+ file.content,
668
+ file.contentHash,
669
+ file.sizeBytes,
670
+ file.lineCount,
671
+ embeddingStr,
672
+ projectPath
673
+ ]);
674
+ if (result.rows.length > 0) {
675
+ success++;
676
+ // Also persist definitions with embeddings if available
677
+ if (file.analysis?.definitions) {
678
+ await this.persistDefinitionsWithAck(file.id, file.analysis.definitions, projectPath);
679
+ }
680
+ }
681
+ else {
682
+ failed++;
683
+ }
684
+ }
685
+ catch (error) {
686
+ failed++;
687
+ logger.debug({ error, filePath: file.filePath }, 'ACK failed for file');
688
+ }
689
+ }
690
+ return { success, failed };
691
+ }
692
+ /**
693
+ * persistDefinitionsWithAck - persist code definitions with embeddings and ACK
694
+ */
695
+ async persistDefinitionsWithAck(fileId, definitions, projectPath) {
696
+ if (!this.db || !this.embeddingProvider)
697
+ return;
698
+ // Filter garbage entries
699
+ const GARBAGE_NAMES = new Set([
700
+ 'SELECT', 'FROM', 'WHERE', 'AND', 'OR', 'NULL', 'TRUE', 'FALSE',
701
+ 'INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'ALTER', 'TABLE',
702
+ 'JOIN', 'LEFT', 'RIGHT', 'INNER', 'OUTER', 'ON', 'AS', 'IN',
703
+ 'ORDER', 'BY', 'GROUP', 'HAVING', 'LIMIT', 'OFFSET', 'UNION',
704
+ 'function', 'class', 'const', 'let', 'var', 'if', 'else', 'return',
705
+ 'for', 'while', 'do', 'switch', 'case', 'break', 'continue', 'try', 'catch'
706
+ ]);
707
+ const validDefs = definitions.filter(def => def.name.length >= 2 &&
708
+ !GARBAGE_NAMES.has(def.name) &&
709
+ !GARBAGE_NAMES.has(def.name.toUpperCase()));
710
+ if (validDefs.length === 0)
711
+ return;
712
+ // Generate embeddings for definitions in parallel
713
+ const defTexts = validDefs.map(def => [
714
+ `${def.definitionType} ${def.name}`,
715
+ def.signature || '',
716
+ def.docstring || ''
717
+ ].filter(Boolean).join('\n'));
718
+ try {
719
+ // Use batch embedding for definitions (single socket request!)
720
+ let defEmbeddings;
721
+ if (this.embeddingProvider.generateEmbeddingsBatch) {
722
+ defEmbeddings = await this.embeddingProvider.generateEmbeddingsBatch(defTexts);
723
+ }
724
+ else {
725
+ defEmbeddings = await Promise.all(defTexts.map(text => this.embeddingProvider.generateEmbedding(text)));
726
+ }
727
+ // Insert definitions with ACK
728
+ for (let i = 0; i < validDefs.length; i++) {
729
+ const def = validDefs[i];
730
+ const embeddingStr = await this.prepareEmbeddingForStorage(defEmbeddings[i], 'code_definitions', defTexts[i]);
731
+ await this.db.query(`INSERT INTO code_definitions (
732
+ id, file_id, file_path, name, qualified_name, definition_type,
733
+ start_line, end_line, signature, docstring, visibility,
734
+ is_exported, is_async, is_static, project_path, embedding
735
+ ) VALUES (
736
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16
737
+ )
738
+ ON CONFLICT (id) DO UPDATE SET
739
+ embedding = COALESCE(EXCLUDED.embedding, code_definitions.embedding),
740
+ updated_at = NOW()
741
+ RETURNING id`, [
742
+ def.id, fileId, def.filePath, def.name, def.qualifiedName, def.definitionType,
743
+ def.startLine, def.endLine, def.signature, def.docstring, def.visibility,
744
+ def.isExported, def.isAsync, def.isStatic, projectPath, embeddingStr
745
+ ]);
746
+ }
747
+ }
748
+ catch (error) {
749
+ // definition embedding/persistence failed - log with file context
750
+ logger.warn({ error: String(error), fileId, defCount: validDefs.length }, 'failed to persist code definitions with embeddings');
751
+ }
752
+ }
753
+ /**
754
+ * findFiles - recursively finds all indexable files
755
+ */
756
+ async findFiles(dirPath, depth) {
757
+ if (depth > this.config.maxDepth) {
758
+ return [];
759
+ }
760
+ const files = [];
761
+ try {
762
+ const entries = await fs.readdir(dirPath, { withFileTypes: true });
763
+ for (const entry of entries) {
764
+ const fullPath = path.join(dirPath, entry.name);
765
+ // check exclusions
766
+ if (this.shouldExclude(entry.name, fullPath)) {
767
+ continue;
768
+ }
769
+ if (entry.isDirectory()) {
770
+ const subFiles = await this.findFiles(fullPath, depth + 1);
771
+ files.push(...subFiles);
772
+ }
773
+ else if (entry.isFile()) {
774
+ if (this.shouldInclude(entry.name)) {
775
+ files.push(fullPath);
776
+ }
777
+ }
778
+ }
779
+ }
780
+ catch (error) {
781
+ logger.warn({ dirPath, error }, 'failed to read directory');
782
+ }
783
+ return files;
784
+ }
785
+ /**
786
+ * shouldExclude - checks if path should be excluded
787
+ */
788
+ shouldExclude(name, fullPath) {
789
+ // skip hidden files/directories
790
+ if (name.startsWith('.') && name !== '.env.example' && name !== '.env.template') {
791
+ return true;
792
+ }
793
+ // check exclude patterns
794
+ for (const pattern of this.config.excludePatterns) {
795
+ if (name === pattern || name.endsWith(pattern)) {
796
+ return true;
797
+ }
798
+ // check if path contains excluded directory
799
+ if (fullPath.includes(`/${pattern}/`) || fullPath.includes(`\\${pattern}\\`)) {
800
+ return true;
801
+ }
802
+ }
803
+ return false;
804
+ }
805
+ /**
806
+ * shouldInclude - checks if file should be included
807
+ */
808
+ shouldInclude(name) {
809
+ const ext = path.extname(name).toLowerCase();
810
+ // check Dockerfile special case
811
+ if (name.toLowerCase() === 'dockerfile') {
812
+ return true;
813
+ }
814
+ return this.config.includeExtensions.includes(ext);
815
+ }
816
+ /**
817
+ * indexFile - reads and indexes a single file with enhanced analysis
818
+ */
819
+ async indexFile(absolutePath) {
820
+ try {
821
+ const stats = await fs.stat(absolutePath);
822
+ // skip if too large
823
+ if (stats.size > this.config.maxFileSizeBytes) {
824
+ logger.debug({ path: absolutePath, size: stats.size }, 'skipping large file');
825
+ return null;
826
+ }
827
+ // skip if binary
828
+ if (await this.isBinaryFile(absolutePath)) {
829
+ return null;
830
+ }
831
+ const content = await fs.readFile(absolutePath, 'utf-8');
832
+ const relativePath = path.relative(this.config.codebasePath, absolutePath);
833
+ const fileName = path.basename(absolutePath);
834
+ const extension = path.extname(absolutePath).toLowerCase();
835
+ const language = this.detectLanguage(fileName, extension);
836
+ const contentHash = this.hashContent(content);
837
+ const lineCount = content.split('\n').length;
838
+ const indexed = {
839
+ id: uuidv4(),
840
+ filePath: relativePath,
841
+ absolutePath,
842
+ fileName,
843
+ extension,
844
+ language,
845
+ content,
846
+ contentHash,
847
+ sizeBytes: stats.size,
848
+ lineCount,
849
+ lastModified: stats.mtime,
850
+ lastIndexed: new Date()
851
+ };
852
+ // generate embedding if enabled
853
+ if (this.config.generateEmbeddings && this.embeddingProvider) {
854
+ try {
855
+ const textForEmbedding = this.createEmbeddingText(indexed);
856
+ indexed.embedding = await this.embeddingProvider.generateEmbedding(textForEmbedding);
857
+ }
858
+ catch (error) {
859
+ logger.warn({ error, path: relativePath }, 'failed to generate embedding');
860
+ }
861
+ }
862
+ // Enhanced analysis - extract definitions, dependencies, chunks, complexity
863
+ if (this.shouldAnalyze(language)) {
864
+ try {
865
+ const analysis = await this.codeAnalyzer.analyzeFile(indexed.id, relativePath, content, language);
866
+ indexed.analysis = analysis;
867
+ // Store in indexes
868
+ this.definitionsIndex.set(relativePath, analysis.definitions);
869
+ this.dependenciesIndex.set(relativePath, analysis.dependencies);
870
+ this.chunksIndex.set(relativePath, analysis.chunks);
871
+ this.complexityIndex.set(relativePath, analysis.complexity);
872
+ // Generate embeddings for chunks if enabled
873
+ if (this.config.generateChunkEmbeddings && this.embeddingProvider) {
874
+ await this.generateChunkEmbeddings(analysis.chunks);
875
+ }
876
+ logger.debug({
877
+ path: relativePath,
878
+ definitions: analysis.definitions.length,
879
+ dependencies: analysis.dependencies.length,
880
+ chunks: analysis.chunks.length,
881
+ complexity: analysis.complexity.cyclomaticComplexity
882
+ }, 'file analysis complete');
883
+ }
884
+ catch (error) {
885
+ logger.warn({ error, path: relativePath }, 'failed to analyze file');
886
+ }
887
+ }
888
+ return indexed;
889
+ }
890
+ catch (error) {
891
+ logger.warn({ error, path: absolutePath }, 'failed to index file');
892
+ return null;
893
+ }
894
+ }
895
+ /**
896
+ * shouldAnalyze - determines if a file should get enhanced analysis
897
+ */
898
+ shouldAnalyze(language) {
899
+ // Only analyze programming languages, not config or data files
900
+ const analyzableLanguages = [
901
+ 'typescript', 'typescript-react', 'javascript', 'javascript-react',
902
+ 'python', 'go', 'rust', 'java', 'kotlin', 'scala',
903
+ 'ruby', 'php', 'c', 'cpp', 'swift'
904
+ ];
905
+ return analyzableLanguages.includes(language);
906
+ }
907
+ /**
908
+ * generateChunkEmbeddings - generates embeddings for code chunks
909
+ */
910
+ async generateChunkEmbeddings(chunks) {
911
+ if (!this.embeddingProvider)
912
+ return;
913
+ for (const chunk of chunks) {
914
+ try {
915
+ const text = `File: ${chunk.filePath}\nLanguage: ${chunk.language}\nLines ${chunk.startLine}-${chunk.endLine}\n\n${chunk.content}`;
916
+ chunk.embedding = await this.embeddingProvider.generateEmbedding(text);
917
+ }
918
+ catch (error) {
919
+ logger.warn({ error, chunkId: chunk.id }, 'failed to generate chunk embedding');
920
+ }
921
+ }
922
+ }
923
+ /**
924
+ * isBinaryFile - checks if file is binary
925
+ */
926
+ async isBinaryFile(filePath) {
927
+ try {
928
+ const buffer = Buffer.alloc(512);
929
+ const fd = await fs.open(filePath, 'r');
930
+ try {
931
+ await fd.read(buffer, 0, 512, 0);
932
+ }
933
+ finally {
934
+ await fd.close();
935
+ }
936
+ // check for null bytes (common in binary files)
937
+ for (let i = 0; i < 512; i++) {
938
+ if (buffer[i] === 0) {
939
+ return true;
940
+ }
941
+ }
942
+ return false;
943
+ }
944
+ catch (e) {
945
+ // binary detection failed - log with file context, assume text for safety
946
+ logger.debug({ filePath, error: String(e) }, 'binary detection failed - assuming text file');
947
+ return false;
948
+ }
949
+ }
950
+ /**
951
+ * detectLanguage - determines file language
952
+ */
953
+ detectLanguage(fileName, extension) {
954
+ // check special filenames
955
+ if (fileName.toLowerCase() === 'dockerfile') {
956
+ return 'dockerfile';
957
+ }
958
+ if (fileName.toLowerCase() === 'makefile') {
959
+ return 'makefile';
960
+ }
961
+ return LANGUAGE_MAP[extension] || 'unknown';
962
+ }
963
+ /**
964
+ * hashContent - generates SHA256 hash of content
965
+ */
966
+ hashContent(content) {
967
+ return crypto.createHash('sha256').update(content, 'utf-8').digest('hex');
968
+ }
969
+ /**
970
+ * createEmbeddingText - creates optimal text for embedding
971
+ */
972
+ createEmbeddingText(file) {
973
+ const header = `File: ${file.filePath}\nLanguage: ${file.language}\n\n`;
974
+ // truncate content if needed - use standardized limit from constants
975
+ let content = file.content;
976
+ if (content.length > TEXT_LIMITS.EMBEDDING_CONTENT_MAX) {
977
+ content = content.slice(0, TEXT_LIMITS.EMBEDDING_CONTENT_MAX) + '\n...[truncated]';
978
+ }
979
+ return header + content;
980
+ }
981
+ /**
982
+ * startWatching - begins watching for file changes
983
+ */
984
+ async startWatching() {
985
+ if (this.isWatching) {
986
+ return;
987
+ }
988
+ logger.info({ path: this.config.codebasePath }, 'starting codebase file watcher...');
989
+ // build ignore patterns for chokidar
990
+ const ignored = [
991
+ ...this.config.excludePatterns.map(p => `**/${p}/**`),
992
+ '**/.*' // hidden files
993
+ ];
994
+ this.watcher = chokidar.watch(this.config.codebasePath, {
995
+ ignored,
996
+ ignoreInitial: true,
997
+ persistent: true,
998
+ depth: this.config.maxDepth,
999
+ awaitWriteFinish: {
1000
+ stabilityThreshold: this.config.debounceMs,
1001
+ pollInterval: 100
1002
+ }
1003
+ });
1004
+ this.watcher.on('add', (filePath) => this.queueUpdate(filePath, 'add'));
1005
+ this.watcher.on('change', (filePath) => this.queueUpdate(filePath, 'change'));
1006
+ this.watcher.on('unlink', (filePath) => this.queueUpdate(filePath, 'unlink'));
1007
+ this.watcher.on('error', (error) => {
1008
+ logger.error({ error }, 'codebase watcher error');
1009
+ });
1010
+ this.isWatching = true;
1011
+ logger.info('codebase watcher started');
1012
+ }
1013
+ /**
1014
+ * queueUpdate - queues a file update for batch processing
1015
+ */
1016
+ queueUpdate(filePath, type) {
1017
+ // check if file should be included
1018
+ const fileName = path.basename(filePath);
1019
+ if (!this.shouldInclude(fileName)) {
1020
+ return;
1021
+ }
1022
+ this.pendingUpdates.set(filePath, type);
1023
+ // reset timer
1024
+ if (this.updateTimer) {
1025
+ clearTimeout(this.updateTimer);
1026
+ }
1027
+ // process after debounce period
1028
+ this.updateTimer = setTimeout(() => {
1029
+ this.processPendingUpdates();
1030
+ }, this.config.debounceMs);
1031
+ }
1032
+ /**
1033
+ * processPendingUpdates - processes all queued updates
1034
+ * Emits incremental scan events via LWJEB
1035
+ */
1036
+ async processPendingUpdates() {
1037
+ if (this.isProcessing || this.pendingUpdates.size === 0) {
1038
+ return;
1039
+ }
1040
+ this.isProcessing = true;
1041
+ const coordinator = this.getCoordinatorSafe();
1042
+ const startTime = Date.now();
1043
+ // Emit codebase:scan:start for incremental scan via LWJEB
1044
+ coordinator?.emitCodebaseScanStart(this.config.codebasePath, 'incremental');
1045
+ try {
1046
+ const updates = new Map(this.pendingUpdates);
1047
+ this.pendingUpdates.clear();
1048
+ logger.debug({ count: updates.size }, 'processing codebase updates');
1049
+ let filesIndexed = 0;
1050
+ let totalLines = 0;
1051
+ for (const [filePath, type] of updates) {
1052
+ try {
1053
+ if (type === 'unlink') {
1054
+ const relativePath = path.relative(this.config.codebasePath, filePath);
1055
+ this.index.delete(relativePath);
1056
+ logger.debug({ path: relativePath }, 'removed file from index');
1057
+ }
1058
+ else {
1059
+ const indexed = await this.indexFile(filePath);
1060
+ if (indexed) {
1061
+ this.index.set(indexed.filePath, indexed);
1062
+ filesIndexed++;
1063
+ totalLines += indexed.lineCount;
1064
+ // Emit codebase:file:indexed event via LWJEB
1065
+ coordinator?.emitCodebaseFileIndexed(indexed.filePath, indexed.language, indexed.lineCount, !!indexed.embedding);
1066
+ logger.debug({ path: indexed.filePath }, 'updated file in index');
1067
+ }
1068
+ }
1069
+ }
1070
+ catch (error) {
1071
+ logger.warn({ error, filePath }, 'failed to process update');
1072
+ }
1073
+ }
1074
+ const duration = Date.now() - startTime;
1075
+ // Emit codebase:scan:complete for incremental scan via LWJEB
1076
+ coordinator?.emitCodebaseScanComplete(this.config.codebasePath, filesIndexed, totalLines, duration, true);
1077
+ this.lastUpdate = new Date();
1078
+ }
1079
+ finally {
1080
+ this.isProcessing = false;
1081
+ }
1082
+ }
1083
+ /**
1084
+ * persistToDatabase - stores files and enhanced analysis in the database
1085
+ * Uses RETURNING to get the actual file ID (handles ON CONFLICT cases)
1086
+ * to prevent foreign key violations when inserting code_chunks
1087
+ */
1088
+ async persistToDatabase(files) {
1089
+ if (!this.db || files.length === 0)
1090
+ return 0;
1091
+ logger.info({ fileCount: files.length }, 'persisting files to database...');
1092
+ let storedCount = 0;
1093
+ const batchSize = 100;
1094
+ const projectPath = getProjectContext().getProjectPath();
1095
+ for (let i = 0; i < files.length; i += batchSize) {
1096
+ const batch = files.slice(i, i + batchSize);
1097
+ try {
1098
+ for (const file of batch) {
1099
+ // Use dimension service to prepare embedding for correct dimension
1100
+ const embeddingText = this.createEmbeddingText(file);
1101
+ const embeddingStr = await this.prepareEmbeddingForStorage(file.embedding, 'codebase_files', embeddingText);
1102
+ // Map simple language string to database structure
1103
+ // The database expects language_id, language_name, language_type
1104
+ const languageId = file.language.toLowerCase();
1105
+ const languageName = file.language.charAt(0).toUpperCase() + file.language.slice(1);
1106
+ const languageType = this.getLanguageType(file.language);
1107
+ // Use RETURNING id to get the actual file ID that was inserted or updated
1108
+ // This prevents foreign key violations when the file already exists
1109
+ // (ON CONFLICT would update existing row but file.id would be a new UUID)
1110
+ // First try to update existing file - filtered by project_path
1111
+ // Update existing file with content_hash
1112
+ const updateResult = await this.db.query(`UPDATE codebase_files SET
1113
+ absolute_path = $2,
1114
+ file_name = $3,
1115
+ extension = $4,
1116
+ language_id = $5,
1117
+ language_name = $6,
1118
+ language_type = $7,
1119
+ content = $8,
1120
+ size_bytes = $9,
1121
+ line_count = $10,
1122
+ char_count = $11,
1123
+ last_modified = $12,
1124
+ embedding = COALESCE($13, embedding),
1125
+ content_hash = $14
1126
+ WHERE file_path = $1 AND project_path = $15
1127
+ RETURNING id`, [
1128
+ file.filePath,
1129
+ file.absolutePath,
1130
+ file.fileName,
1131
+ file.extension,
1132
+ languageId,
1133
+ languageName,
1134
+ languageType,
1135
+ file.content,
1136
+ file.sizeBytes,
1137
+ file.lineCount,
1138
+ file.content.length,
1139
+ file.lastModified,
1140
+ embeddingStr,
1141
+ file.contentHash,
1142
+ projectPath
1143
+ ]);
1144
+ let result;
1145
+ if (updateResult.rows.length === 0) {
1146
+ // File doesn't exist, insert it with project_path and content_hash
1147
+ result = await this.db.query(`INSERT INTO codebase_files (
1148
+ id, file_path, absolute_path, file_name, extension,
1149
+ language_id, language_name, language_type,
1150
+ content, size_bytes, line_count, char_count,
1151
+ last_modified, embedding, content_hash, project_path
1152
+ ) VALUES (
1153
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16
1154
+ )
1155
+ RETURNING id`, [
1156
+ file.id,
1157
+ file.filePath,
1158
+ file.absolutePath,
1159
+ file.fileName,
1160
+ file.extension,
1161
+ languageId,
1162
+ languageName,
1163
+ languageType,
1164
+ file.content,
1165
+ file.sizeBytes,
1166
+ file.lineCount,
1167
+ file.content.length,
1168
+ file.lastModified,
1169
+ embeddingStr,
1170
+ file.contentHash,
1171
+ projectPath
1172
+ ]);
1173
+ }
1174
+ else {
1175
+ result = updateResult;
1176
+ }
1177
+ // Use the actual database ID (could be different from file.id on conflict)
1178
+ const actualFileId = result.rows[0]?.id || file.id;
1179
+ // Store enhanced analysis if available using the actual file ID
1180
+ if (file.analysis) {
1181
+ await this.persistAnalysis(actualFileId, file.analysis);
1182
+ }
1183
+ storedCount++;
1184
+ }
1185
+ logger.debug({
1186
+ batch: Math.floor(i / batchSize) + 1,
1187
+ storedInBatch: batch.length
1188
+ }, 'stored batch of files');
1189
+ }
1190
+ catch (error) {
1191
+ logger.error({ error, batchIndex: Math.floor(i / batchSize) }, 'failed to store batch');
1192
+ }
1193
+ }
1194
+ logger.info({ storedCount }, 'database persistence complete');
1195
+ return storedCount;
1196
+ }
1197
+ /**
1198
+ * persistAnalysis - stores enhanced analysis data in the database
1199
+ * All tables are scoped by project_path for data isolation
1200
+ */
1201
+ async persistAnalysis(fileId, analysis) {
1202
+ if (!this.db)
1203
+ return;
1204
+ const projectPath = getProjectContext().getProjectPath();
1205
+ try {
1206
+ // Store code chunks with project_path
1207
+ for (const chunk of analysis.chunks) {
1208
+ // Skip empty chunks - no point storing whitespace fr fr
1209
+ if (!chunk.content.trim())
1210
+ continue;
1211
+ // Use dimension service to prepare chunk embedding
1212
+ const chunkText = `File: ${chunk.filePath}\nLanguage: ${chunk.language}\nLines ${chunk.startLine}-${chunk.endLine}\n\n${chunk.content}`;
1213
+ const embeddingStr = await this.prepareEmbeddingForStorage(chunk.embedding, 'code_chunks', chunkText);
1214
+ await this.db.query(`INSERT INTO code_chunks (
1215
+ id, file_id, file_path, chunk_index, start_line, end_line,
1216
+ start_char, end_char, content, language, chunk_type,
1217
+ context_before, context_after, embedding, metadata, project_path
1218
+ ) VALUES (
1219
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16
1220
+ )
1221
+ ON CONFLICT (id) DO UPDATE SET
1222
+ content = EXCLUDED.content,
1223
+ embedding = COALESCE(EXCLUDED.embedding, code_chunks.embedding),
1224
+ updated_at = NOW()`, [
1225
+ chunk.id, fileId, chunk.filePath, chunk.chunkIndex,
1226
+ chunk.startLine, chunk.endLine, chunk.startChar, chunk.endChar,
1227
+ chunk.content, chunk.language, chunk.chunkType,
1228
+ chunk.contextBefore, chunk.contextAfter,
1229
+ embeddingStr, JSON.stringify(chunk.metadata), projectPath
1230
+ ]);
1231
+ }
1232
+ // Store code definitions with project_path AND embeddings
1233
+ // FIX: Previously embeddings were missing, causing low relevance in find_code_pointers
1234
+ // ACK VERIFICATION: Skip garbage entries (SQL keywords, common noise)
1235
+ const GARBAGE_NAMES = new Set([
1236
+ // SQL keywords
1237
+ 'SELECT', 'FROM', 'WHERE', 'AND', 'OR', 'NOT', 'NULL', 'TRUE', 'FALSE',
1238
+ 'INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'ALTER', 'TABLE', 'INDEX',
1239
+ 'JOIN', 'LEFT', 'RIGHT', 'INNER', 'OUTER', 'ON', 'AS', 'IN', 'LIKE',
1240
+ 'BETWEEN', 'IS', 'GROUP', 'BY', 'HAVING', 'ORDER', 'LIMIT', 'OFFSET',
1241
+ 'DISTINCT', 'UNION', 'ALL', 'ANY', 'EXISTS', 'CASE', 'WHEN', 'THEN', 'ELSE', 'END',
1242
+ 'COUNT', 'SUM', 'AVG', 'MIN', 'MAX', 'COALESCE', 'NULLIF', 'CAST',
1243
+ 'VALUES', 'RETURNING', 'INTO', 'SET', 'DEFAULT', 'PRIMARY', 'KEY', 'FOREIGN',
1244
+ 'REFERENCES', 'UNIQUE', 'CHECK', 'CONSTRAINT', 'CASCADE', 'RESTRICT',
1245
+ 'ROUND', 'LOWER', 'UPPER', 'TRIM', 'LENGTH', 'SUBSTRING', 'REPLACE', 'CONCAT',
1246
+ 'EXTRACT', 'DATE', 'TIME', 'TIMESTAMP', 'INTERVAL', 'NOW', 'CURRENT_DATE',
1247
+ // JS noise
1248
+ 'switch', 'super', 'clearInterval', 'clearTimeout', 'setTimeout', 'callback',
1249
+ // Common false positives
1250
+ 'undefined', 'null', 'true', 'false', 'NaN', 'Infinity'
1251
+ ]);
1252
+ const isValidDefinition = (def) => {
1253
+ // Name must exist and be reasonable
1254
+ if (!def.name || def.name.length < 2 || def.name.length > 100)
1255
+ return false;
1256
+ // Name must not be a garbage keyword
1257
+ if (GARBAGE_NAMES.has(def.name.toUpperCase()))
1258
+ return false;
1259
+ // Name should start with letter or underscore
1260
+ if (!/^[a-zA-Z_$]/.test(def.name))
1261
+ return false;
1262
+ // Signature shouldn't be SQL (indicates parser confusion)
1263
+ if (def.signature && /^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE)\s/i.test(def.signature))
1264
+ return false;
1265
+ return true;
1266
+ };
1267
+ for (const def of analysis.definitions) {
1268
+ // ACK: Verify this is a real code definition, not garbage
1269
+ if (!isValidDefinition(def)) {
1270
+ logger.debug({ name: def.name, filePath: def.filePath }, 'Skipping invalid definition (ACK failed)');
1271
+ continue;
1272
+ }
1273
+ // Generate embedding for definition based on name + signature + docstring
1274
+ // This enables semantic search to find definitions by meaning
1275
+ const defText = [
1276
+ `${def.definitionType} ${def.name}`,
1277
+ def.signature || '',
1278
+ def.docstring || '',
1279
+ `File: ${def.filePath}`,
1280
+ `Language: ${def.language}`
1281
+ ].filter(Boolean).join('\n');
1282
+ // Generate embedding for the definition text
1283
+ let defEmbeddingStr = null;
1284
+ if (this.embeddingProvider) {
1285
+ try {
1286
+ const defEmbedding = await this.embeddingProvider.generateEmbedding(defText);
1287
+ defEmbeddingStr = await this.prepareEmbeddingForStorage(defEmbedding, 'code_definitions', defText);
1288
+ }
1289
+ catch (err) {
1290
+ logger.warn({ error: err, defName: def.name }, 'Failed to generate definition embedding');
1291
+ }
1292
+ }
1293
+ await this.db.query(`INSERT INTO code_definitions (
1294
+ id, file_id, file_path, name, qualified_name, definition_type,
1295
+ start_line, end_line, start_column, end_column,
1296
+ signature, docstring, return_type, visibility,
1297
+ is_exported, is_async, is_static, is_abstract,
1298
+ parent_definition_id, parameters, language, decorators, metadata, project_path, embedding
1299
+ ) VALUES (
1300
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10,
1301
+ $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25
1302
+ )
1303
+ ON CONFLICT (id) DO UPDATE SET
1304
+ signature = EXCLUDED.signature,
1305
+ embedding = COALESCE(EXCLUDED.embedding, code_definitions.embedding),
1306
+ updated_at = NOW()`, [
1307
+ def.id, fileId, def.filePath, def.name, def.qualifiedName, def.definitionType,
1308
+ def.startLine, def.endLine, def.startColumn, def.endColumn,
1309
+ def.signature, def.docstring, def.returnType, def.visibility,
1310
+ def.isExported, def.isAsync, def.isStatic, def.isAbstract,
1311
+ def.parentDefinitionId, JSON.stringify(def.parameters),
1312
+ def.language, def.decorators, JSON.stringify(def.metadata), projectPath, defEmbeddingStr
1313
+ ]);
1314
+ }
1315
+ // Store code dependencies with project_path
1316
+ for (const dep of analysis.dependencies) {
1317
+ await this.db.query(`INSERT INTO code_dependencies (
1318
+ id, source_file_id, source_file_path, target_path, resolved_path,
1319
+ import_type, import_statement, imported_names, imported_as,
1320
+ is_default_import, is_namespace_import, is_type_import, is_side_effect_import,
1321
+ line_number, column_number, is_external, is_builtin, is_relative,
1322
+ is_absolute, is_dynamic, package_name, package_version, language, metadata, project_path
1323
+ ) VALUES (
1324
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10,
1325
+ $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25
1326
+ )
1327
+ ON CONFLICT (id) DO UPDATE SET
1328
+ resolved_path = EXCLUDED.resolved_path,
1329
+ updated_at = NOW()`, [
1330
+ dep.id, fileId, dep.sourceFilePath, dep.targetPath, dep.resolvedPath,
1331
+ dep.importType, dep.importStatement, dep.importedNames, dep.importedAs,
1332
+ dep.isDefaultImport, dep.isNamespaceImport, dep.isTypeImport, dep.isSideEffectImport,
1333
+ dep.lineNumber, dep.columnNumber, dep.isExternal, dep.isBuiltin, dep.isRelative,
1334
+ dep.isAbsolute, dep.isDynamic, dep.packageName, dep.packageVersion,
1335
+ dep.language, JSON.stringify(dep.metadata), projectPath
1336
+ ]);
1337
+ }
1338
+ // Store code complexity with project_path
1339
+ const comp = analysis.complexity;
1340
+ await this.db.query(`INSERT INTO code_complexity (
1341
+ id, file_id, file_path, definition_id, definition_name, scope_type,
1342
+ lines_of_code, logical_lines, comment_lines, blank_lines,
1343
+ cyclomatic_complexity, cognitive_complexity, halstead_difficulty,
1344
+ halstead_effort, halstead_volume, maintainability_index,
1345
+ parameter_count, return_statement_count, nesting_depth, coupling_score,
1346
+ issues_count, issues, duplicate_blocks, duplicate_lines,
1347
+ language, metadata, analyzed_at, analyzer_version, project_path
1348
+ ) VALUES (
1349
+ $1, $2, $3, $4, $5, $6, $7, $8, $9, $10,
1350
+ $11, $12, $13, $14, $15, $16, $17, $18, $19, $20,
1351
+ $21, $22, $23, $24, $25, $26, $27, $28, $29
1352
+ )
1353
+ ON CONFLICT (id) DO UPDATE SET
1354
+ cyclomatic_complexity = EXCLUDED.cyclomatic_complexity,
1355
+ maintainability_index = EXCLUDED.maintainability_index,
1356
+ analyzed_at = EXCLUDED.analyzed_at,
1357
+ updated_at = NOW()`, [
1358
+ comp.id, fileId, comp.filePath, comp.definitionId, comp.definitionName, comp.scopeType,
1359
+ comp.linesOfCode, comp.logicalLines, comp.commentLines, comp.blankLines,
1360
+ comp.cyclomaticComplexity, comp.cognitiveComplexity, comp.halsteadDifficulty,
1361
+ comp.halsteadEffort, comp.halsteadVolume, comp.maintainabilityIndex,
1362
+ comp.parameterCount, comp.returnStatementCount, comp.nestingDepth, comp.couplingScore,
1363
+ comp.issuesCount, JSON.stringify(comp.issues), comp.duplicateBlocks, comp.duplicateLines,
1364
+ comp.language, JSON.stringify(comp.metadata), comp.analyzedAt, comp.analyzerVersion, projectPath
1365
+ ]);
1366
+ }
1367
+ catch (error) {
1368
+ logger.error({ error, fileId }, 'failed to persist analysis');
1369
+ }
1370
+ }
1371
+ /**
1372
+ * getLanguageType - determines language type category
1373
+ */
1374
+ getLanguageType(language) {
1375
+ const programmingLangs = [
1376
+ 'javascript', 'typescript', 'python', 'java', 'go', 'rust',
1377
+ 'c', 'cpp', 'swift', 'kotlin', 'ruby', 'php', 'scala'
1378
+ ];
1379
+ const markupLangs = ['html', 'xml', 'markdown'];
1380
+ const dataLangs = ['json', 'yaml', 'toml'];
1381
+ const configLangs = ['ini', 'cfg', 'bash', 'zsh', 'dockerfile'];
1382
+ const lower = language.toLowerCase();
1383
+ if (programmingLangs.some(l => lower.includes(l)))
1384
+ return 'programming';
1385
+ if (markupLangs.some(l => lower.includes(l)))
1386
+ return 'markup';
1387
+ if (dataLangs.some(l => lower.includes(l)))
1388
+ return 'data';
1389
+ if (configLangs.some(l => lower.includes(l)))
1390
+ return 'config';
1391
+ return 'data';
1392
+ }
1393
+ /**
1394
+ * stopWatching - stops the file watcher
1395
+ */
1396
+ async stopWatching() {
1397
+ if (this.updateTimer) {
1398
+ clearTimeout(this.updateTimer);
1399
+ this.updateTimer = null;
1400
+ }
1401
+ if (this.watcher) {
1402
+ await this.watcher.close();
1403
+ this.watcher = null;
1404
+ }
1405
+ this.isWatching = false;
1406
+ logger.info('codebase watcher stopped');
1407
+ }
1408
+ // === PUBLIC API ===
1409
+ /**
1410
+ * getFile - retrieves a file by relative path
1411
+ */
1412
+ getFile(relativePath) {
1413
+ return this.index.get(relativePath);
1414
+ }
1415
+ /**
1416
+ * getAllFiles - returns all indexed files
1417
+ */
1418
+ getAllFiles() {
1419
+ return Array.from(this.index.values());
1420
+ }
1421
+ /**
1422
+ * searchByPath - searches files by path pattern
1423
+ */
1424
+ searchByPath(pattern) {
1425
+ const normalizedPattern = pattern.toLowerCase();
1426
+ return Array.from(this.index.values()).filter(file => file.filePath.toLowerCase().includes(normalizedPattern) ||
1427
+ file.fileName.toLowerCase().includes(normalizedPattern));
1428
+ }
1429
+ /**
1430
+ * searchByContent - searches files by content
1431
+ */
1432
+ searchByContent(query) {
1433
+ const normalizedQuery = query.toLowerCase();
1434
+ return Array.from(this.index.values()).filter(file => file.content.toLowerCase().includes(normalizedQuery));
1435
+ }
1436
+ /**
1437
+ * searchByLanguage - returns all files of a language
1438
+ */
1439
+ searchByLanguage(language) {
1440
+ return Array.from(this.index.values()).filter(file => file.language === language);
1441
+ }
1442
+ /**
1443
+ * getCodebaseOverview - returns a summary of the codebase
1444
+ */
1445
+ getCodebaseOverview() {
1446
+ const stats = this.getStats();
1447
+ const files = this.getAllFiles();
1448
+ let overview = `# Codebase Overview\n\n`;
1449
+ overview += `**Root Path**: ${this.config.codebasePath}\n`;
1450
+ overview += `**Total Files**: ${stats.totalFiles}\n`;
1451
+ overview += `**Total Lines**: ${stats.totalLines}\n`;
1452
+ overview += `**Total Size**: ${(stats.totalBytes / 1024 / 1024).toFixed(2)} MB\n\n`;
1453
+ overview += `## Language Breakdown\n\n`;
1454
+ for (const [language, count] of Object.entries(stats.languageBreakdown)) {
1455
+ overview += `- **${language}**: ${count} files\n`;
1456
+ }
1457
+ overview += '\n';
1458
+ overview += `## Directory Structure\n\n`;
1459
+ // group files by top-level directory
1460
+ const directories = new Map();
1461
+ for (const file of files) {
1462
+ const parts = file.filePath.split(path.sep);
1463
+ const topDir = parts[0] || 'root';
1464
+ directories.set(topDir, (directories.get(topDir) || 0) + 1);
1465
+ }
1466
+ for (const [dir, count] of Array.from(directories.entries()).sort((a, b) => b[1] - a[1])) {
1467
+ overview += `- \`${dir}/\`: ${count} files\n`;
1468
+ }
1469
+ return overview;
1470
+ }
1471
+ /**
1472
+ * getStats - returns indexer statistics including enhanced analysis metrics
1473
+ */
1474
+ getStats() {
1475
+ const files = Array.from(this.index.values());
1476
+ const languageBreakdown = {};
1477
+ const definitionBreakdown = {};
1478
+ let totalBytes = 0;
1479
+ let totalLines = 0;
1480
+ let filesWithEmbeddings = 0;
1481
+ let totalDefinitions = 0;
1482
+ let totalDependencies = 0;
1483
+ let totalChunks = 0;
1484
+ let chunksWithEmbeddings = 0;
1485
+ let totalComplexity = 0;
1486
+ let complexityCount = 0;
1487
+ for (const file of files) {
1488
+ languageBreakdown[file.language] = (languageBreakdown[file.language] || 0) + 1;
1489
+ totalBytes += file.sizeBytes;
1490
+ totalLines += file.lineCount;
1491
+ if (file.embedding) {
1492
+ filesWithEmbeddings++;
1493
+ }
1494
+ }
1495
+ // Count definitions
1496
+ for (const defs of this.definitionsIndex.values()) {
1497
+ totalDefinitions += defs.length;
1498
+ for (const def of defs) {
1499
+ definitionBreakdown[def.definitionType] = (definitionBreakdown[def.definitionType] || 0) + 1;
1500
+ }
1501
+ }
1502
+ // Count dependencies
1503
+ for (const deps of this.dependenciesIndex.values()) {
1504
+ totalDependencies += deps.length;
1505
+ }
1506
+ // Count chunks
1507
+ for (const chunks of this.chunksIndex.values()) {
1508
+ totalChunks += chunks.length;
1509
+ for (const chunk of chunks) {
1510
+ if (chunk.embedding) {
1511
+ chunksWithEmbeddings++;
1512
+ }
1513
+ }
1514
+ }
1515
+ // Calculate average complexity
1516
+ for (const complexity of this.complexityIndex.values()) {
1517
+ if (complexity.cyclomaticComplexity !== undefined) {
1518
+ totalComplexity += complexity.cyclomaticComplexity;
1519
+ complexityCount++;
1520
+ }
1521
+ }
1522
+ return {
1523
+ totalFiles: files.length,
1524
+ totalBytes,
1525
+ totalLines,
1526
+ filesWithEmbeddings,
1527
+ languageBreakdown,
1528
+ lastFullScan: this.lastFullScan,
1529
+ lastUpdate: this.lastUpdate,
1530
+ isWatching: this.isWatching,
1531
+ // Enhanced statistics
1532
+ totalDefinitions,
1533
+ totalDependencies,
1534
+ totalChunks,
1535
+ chunksWithEmbeddings,
1536
+ avgComplexity: complexityCount > 0 ? totalComplexity / complexityCount : 0,
1537
+ definitionBreakdown
1538
+ };
1539
+ }
1540
+ /**
1541
+ * shutdown - cleanup resources
1542
+ */
1543
+ async shutdown() {
1544
+ await this.stopWatching();
1545
+ this.index.clear();
1546
+ this.definitionsIndex.clear();
1547
+ this.dependenciesIndex.clear();
1548
+ this.chunksIndex.clear();
1549
+ this.complexityIndex.clear();
1550
+ logger.info('codebase indexer shut down');
1551
+ }
1552
+ // === ENHANCED PUBLIC API ===
1553
+ /**
1554
+ * getDefinitions - returns all definitions for a file
1555
+ */
1556
+ getDefinitions(filePath) {
1557
+ return this.definitionsIndex.get(filePath) || [];
1558
+ }
1559
+ /**
1560
+ * getAllDefinitions - returns all definitions across all files
1561
+ */
1562
+ getAllDefinitions() {
1563
+ return Array.from(this.definitionsIndex.values()).flat();
1564
+ }
1565
+ /**
1566
+ * searchDefinitions - searches for definitions by name
1567
+ */
1568
+ searchDefinitions(query) {
1569
+ const normalizedQuery = query.toLowerCase();
1570
+ return this.getAllDefinitions().filter(def => def.name.toLowerCase().includes(normalizedQuery) ||
1571
+ (def.qualifiedName?.toLowerCase().includes(normalizedQuery)));
1572
+ }
1573
+ /**
1574
+ * getDefinitionsByType - returns all definitions of a specific type
1575
+ */
1576
+ getDefinitionsByType(type) {
1577
+ return this.getAllDefinitions().filter(def => def.definitionType === type);
1578
+ }
1579
+ /**
1580
+ * getDependencies - returns all dependencies for a file
1581
+ */
1582
+ getDependencies(filePath) {
1583
+ return this.dependenciesIndex.get(filePath) || [];
1584
+ }
1585
+ /**
1586
+ * getAllDependencies - returns all dependencies across all files
1587
+ */
1588
+ getAllDependencies() {
1589
+ return Array.from(this.dependenciesIndex.values()).flat();
1590
+ }
1591
+ /**
1592
+ * getDependentsOf - returns files that import the given path
1593
+ */
1594
+ getDependentsOf(targetPath) {
1595
+ return this.getAllDependencies().filter(dep => dep.targetPath === targetPath ||
1596
+ dep.resolvedPath === targetPath);
1597
+ }
1598
+ /**
1599
+ * getExternalDependencies - returns all external (npm) dependencies
1600
+ */
1601
+ getExternalDependencies() {
1602
+ return this.getAllDependencies().filter(dep => dep.isExternal);
1603
+ }
1604
+ /**
1605
+ * getChunks - returns all chunks for a file
1606
+ */
1607
+ getChunks(filePath) {
1608
+ return this.chunksIndex.get(filePath) || [];
1609
+ }
1610
+ /**
1611
+ * getAllChunks - returns all chunks across all files
1612
+ */
1613
+ getAllChunks() {
1614
+ return Array.from(this.chunksIndex.values()).flat();
1615
+ }
1616
+ /**
1617
+ * getComplexity - returns complexity metrics for a file
1618
+ */
1619
+ getComplexity(filePath) {
1620
+ return this.complexityIndex.get(filePath);
1621
+ }
1622
+ /**
1623
+ * getHighComplexityFiles - returns files with high cyclomatic complexity
1624
+ */
1625
+ getHighComplexityFiles(threshold = 10) {
1626
+ return Array.from(this.complexityIndex.values())
1627
+ .filter(comp => (comp.cyclomaticComplexity || 0) > threshold)
1628
+ .sort((a, b) => (b.cyclomaticComplexity || 0) - (a.cyclomaticComplexity || 0));
1629
+ }
1630
+ /**
1631
+ * getLowMaintainabilityFiles - returns files with low maintainability index
1632
+ */
1633
+ getLowMaintainabilityFiles(threshold = 50) {
1634
+ return Array.from(this.complexityIndex.values())
1635
+ .filter(comp => (comp.maintainabilityIndex || 100) < threshold)
1636
+ .sort((a, b) => (a.maintainabilityIndex || 0) - (b.maintainabilityIndex || 0));
1637
+ }
1638
+ /**
1639
+ * findSimilarChunks - finds chunks similar to the query using embeddings
1640
+ * Returns chunks with similarity scores
1641
+ */
1642
+ async findSimilarChunks(query, limit = 10) {
1643
+ if (!this.embeddingProvider) {
1644
+ logger.warn('no embedding provider for similarity search');
1645
+ return [];
1646
+ }
1647
+ try {
1648
+ const queryEmbedding = await this.embeddingProvider.generateEmbedding(query);
1649
+ const allChunks = this.getAllChunks().filter(c => c.embedding);
1650
+ const results = allChunks.map(chunk => ({
1651
+ chunk,
1652
+ similarity: this.cosineSimilarity(queryEmbedding, chunk.embedding)
1653
+ }));
1654
+ return results
1655
+ .sort((a, b) => b.similarity - a.similarity)
1656
+ .slice(0, limit);
1657
+ }
1658
+ catch (error) {
1659
+ logger.warn({ error }, 'failed to find similar chunks');
1660
+ return [];
1661
+ }
1662
+ }
1663
+ /**
1664
+ * cosineSimilarity - calculates cosine similarity between two vectors
1665
+ */
1666
+ cosineSimilarity(a, b) {
1667
+ if (a.length !== b.length)
1668
+ return 0;
1669
+ let dotProduct = 0;
1670
+ let normA = 0;
1671
+ let normB = 0;
1672
+ for (let i = 0; i < a.length; i++) {
1673
+ dotProduct += a[i] * b[i];
1674
+ normA += a[i] * a[i];
1675
+ normB += b[i] * b[i];
1676
+ }
1677
+ if (normA === 0 || normB === 0)
1678
+ return 0;
1679
+ return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
1680
+ }
1681
+ /**
1682
+ * getDependencyGraph - returns a dependency graph for visualization
1683
+ */
1684
+ getDependencyGraph() {
1685
+ const nodes = new Set();
1686
+ const edges = [];
1687
+ for (const [filePath, deps] of this.dependenciesIndex) {
1688
+ nodes.add(filePath);
1689
+ for (const dep of deps) {
1690
+ if (dep.resolvedPath && !dep.isExternal) {
1691
+ nodes.add(dep.resolvedPath);
1692
+ edges.push({ from: filePath, to: dep.resolvedPath });
1693
+ }
1694
+ }
1695
+ }
1696
+ return {
1697
+ nodes: Array.from(nodes),
1698
+ edges
1699
+ };
1700
+ }
1701
+ }
1702
+ // Per-project indexer instances
1703
+ const indexersByProject = new Map();
1704
+ /**
1705
+ * getCodebaseIndexer - returns indexer instance for current project
1706
+ * uses Map pattern to isolate instances per project
1707
+ */
1708
+ export function getCodebaseIndexer(config, embeddingProvider, db, projectPath) {
1709
+ const targetProject = projectPath || getProjectPath();
1710
+ if (!indexersByProject.has(targetProject)) {
1711
+ indexersByProject.set(targetProject, new CodebaseIndexer(config, embeddingProvider || null, db || null));
1712
+ }
1713
+ return indexersByProject.get(targetProject);
1714
+ }
1715
+ /**
1716
+ * resetCodebaseIndexer - resets the indexer for a project (for testing)
1717
+ */
1718
+ export function resetCodebaseIndexer(projectPath) {
1719
+ const targetProject = projectPath || getProjectPath();
1720
+ const indexer = indexersByProject.get(targetProject);
1721
+ if (indexer) {
1722
+ indexer.shutdown();
1723
+ indexersByProject.delete(targetProject);
1724
+ }
1725
+ }
1726
+ /**
1727
+ * resetAllCodebaseIndexers - resets all indexer instances (for testing)
1728
+ */
1729
+ export function resetAllCodebaseIndexers() {
1730
+ for (const [project, indexer] of indexersByProject) {
1731
+ indexer.shutdown();
1732
+ }
1733
+ indexersByProject.clear();
1734
+ }
1735
+ //# sourceMappingURL=codebaseIndexer.js.map