memor-code-cli 0.2.0

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 (418) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +109 -0
  3. package/dist/IntentionalStructure/index.d.ts +13 -0
  4. package/dist/IntentionalStructure/index.d.ts.map +1 -0
  5. package/dist/IntentionalStructure/index.js +46 -0
  6. package/dist/IntentionalStructure/index.js.map +1 -0
  7. package/dist/IntentionalStructure/parseCompose.d.ts +13 -0
  8. package/dist/IntentionalStructure/parseCompose.d.ts.map +1 -0
  9. package/dist/IntentionalStructure/parseCompose.js +234 -0
  10. package/dist/IntentionalStructure/parseCompose.js.map +1 -0
  11. package/dist/IntentionalStructure/parseDeployConfigs.d.ts +7 -0
  12. package/dist/IntentionalStructure/parseDeployConfigs.d.ts.map +1 -0
  13. package/dist/IntentionalStructure/parseDeployConfigs.js +168 -0
  14. package/dist/IntentionalStructure/parseDeployConfigs.js.map +1 -0
  15. package/dist/IntentionalStructure/parseEnvWiring.d.ts +7 -0
  16. package/dist/IntentionalStructure/parseEnvWiring.d.ts.map +1 -0
  17. package/dist/IntentionalStructure/parseEnvWiring.js +159 -0
  18. package/dist/IntentionalStructure/parseEnvWiring.js.map +1 -0
  19. package/dist/IntentionalStructure/parseWorkspaces.d.ts +8 -0
  20. package/dist/IntentionalStructure/parseWorkspaces.d.ts.map +1 -0
  21. package/dist/IntentionalStructure/parseWorkspaces.js +179 -0
  22. package/dist/IntentionalStructure/parseWorkspaces.js.map +1 -0
  23. package/dist/IntentionalStructure/types.d.ts +34 -0
  24. package/dist/IntentionalStructure/types.d.ts.map +1 -0
  25. package/dist/IntentionalStructure/types.js +8 -0
  26. package/dist/IntentionalStructure/types.js.map +1 -0
  27. package/dist/RepoTypeDetection/applyRepoModeConsistency.d.ts +11 -0
  28. package/dist/RepoTypeDetection/applyRepoModeConsistency.d.ts.map +1 -0
  29. package/dist/RepoTypeDetection/applyRepoModeConsistency.js +53 -0
  30. package/dist/RepoTypeDetection/applyRepoModeConsistency.js.map +1 -0
  31. package/dist/RepoTypeDetection/detectAppArchetype.d.ts +12 -0
  32. package/dist/RepoTypeDetection/detectAppArchetype.d.ts.map +1 -0
  33. package/dist/RepoTypeDetection/detectAppArchetype.js +162 -0
  34. package/dist/RepoTypeDetection/detectAppArchetype.js.map +1 -0
  35. package/dist/RepoTypeDetection/detectPackageArchetype.d.ts +10 -0
  36. package/dist/RepoTypeDetection/detectPackageArchetype.d.ts.map +1 -0
  37. package/dist/RepoTypeDetection/detectPackageArchetype.js +149 -0
  38. package/dist/RepoTypeDetection/detectPackageArchetype.js.map +1 -0
  39. package/dist/RepoTypeDetection/detectRepoCenterSystems.d.ts +11 -0
  40. package/dist/RepoTypeDetection/detectRepoCenterSystems.d.ts.map +1 -0
  41. package/dist/RepoTypeDetection/detectRepoCenterSystems.js +123 -0
  42. package/dist/RepoTypeDetection/detectRepoCenterSystems.js.map +1 -0
  43. package/dist/RepoTypeDetection/detectRepoMode.d.ts +16 -0
  44. package/dist/RepoTypeDetection/detectRepoMode.d.ts.map +1 -0
  45. package/dist/RepoTypeDetection/detectRepoMode.js +338 -0
  46. package/dist/RepoTypeDetection/detectRepoMode.js.map +1 -0
  47. package/dist/RepoTypeDetection/detectRepoSignals.d.ts +13 -0
  48. package/dist/RepoTypeDetection/detectRepoSignals.d.ts.map +1 -0
  49. package/dist/RepoTypeDetection/detectRepoSignals.js +451 -0
  50. package/dist/RepoTypeDetection/detectRepoSignals.js.map +1 -0
  51. package/dist/RepoTypeDetection/inferSupportRole.d.ts +8 -0
  52. package/dist/RepoTypeDetection/inferSupportRole.d.ts.map +1 -0
  53. package/dist/RepoTypeDetection/inferSupportRole.js +177 -0
  54. package/dist/RepoTypeDetection/inferSupportRole.js.map +1 -0
  55. package/dist/RuntimeInference/detectEnvConsumers.d.ts +7 -0
  56. package/dist/RuntimeInference/detectEnvConsumers.d.ts.map +1 -0
  57. package/dist/RuntimeInference/detectEnvConsumers.js +108 -0
  58. package/dist/RuntimeInference/detectEnvConsumers.js.map +1 -0
  59. package/dist/RuntimeInference/detectHttpEdges.d.ts +4 -0
  60. package/dist/RuntimeInference/detectHttpEdges.d.ts.map +1 -0
  61. package/dist/RuntimeInference/detectHttpEdges.js +146 -0
  62. package/dist/RuntimeInference/detectHttpEdges.js.map +1 -0
  63. package/dist/RuntimeInference/detectOrmConsumers.d.ts +5 -0
  64. package/dist/RuntimeInference/detectOrmConsumers.d.ts.map +1 -0
  65. package/dist/RuntimeInference/detectOrmConsumers.js +117 -0
  66. package/dist/RuntimeInference/detectOrmConsumers.js.map +1 -0
  67. package/dist/RuntimeInference/detectProxyRewrites.d.ts +5 -0
  68. package/dist/RuntimeInference/detectProxyRewrites.d.ts.map +1 -0
  69. package/dist/RuntimeInference/detectProxyRewrites.js +137 -0
  70. package/dist/RuntimeInference/detectProxyRewrites.js.map +1 -0
  71. package/dist/RuntimeInference/detectTrpcEdges.d.ts +4 -0
  72. package/dist/RuntimeInference/detectTrpcEdges.d.ts.map +1 -0
  73. package/dist/RuntimeInference/detectTrpcEdges.js +137 -0
  74. package/dist/RuntimeInference/detectTrpcEdges.js.map +1 -0
  75. package/dist/RuntimeInference/index.d.ts +17 -0
  76. package/dist/RuntimeInference/index.d.ts.map +1 -0
  77. package/dist/RuntimeInference/index.js +32 -0
  78. package/dist/RuntimeInference/index.js.map +1 -0
  79. package/dist/RuntimeInference/types.d.ts +8 -0
  80. package/dist/RuntimeInference/types.d.ts.map +1 -0
  81. package/dist/RuntimeInference/types.js +3 -0
  82. package/dist/RuntimeInference/types.js.map +1 -0
  83. package/dist/SystemSynthesis/index.d.ts +27 -0
  84. package/dist/SystemSynthesis/index.d.ts.map +1 -0
  85. package/dist/SystemSynthesis/index.js +31 -0
  86. package/dist/SystemSynthesis/index.js.map +1 -0
  87. package/dist/SystemSynthesis/mergeLayerOutputs.d.ts +13 -0
  88. package/dist/SystemSynthesis/mergeLayerOutputs.d.ts.map +1 -0
  89. package/dist/SystemSynthesis/mergeLayerOutputs.js +220 -0
  90. package/dist/SystemSynthesis/mergeLayerOutputs.js.map +1 -0
  91. package/dist/SystemSynthesis/stampDeterministic.d.ts +11 -0
  92. package/dist/SystemSynthesis/stampDeterministic.d.ts.map +1 -0
  93. package/dist/SystemSynthesis/stampDeterministic.js +177 -0
  94. package/dist/SystemSynthesis/stampDeterministic.js.map +1 -0
  95. package/dist/SystemSynthesis/synthesize.d.ts +15 -0
  96. package/dist/SystemSynthesis/synthesize.d.ts.map +1 -0
  97. package/dist/SystemSynthesis/synthesize.js +258 -0
  98. package/dist/SystemSynthesis/synthesize.js.map +1 -0
  99. package/dist/SystemSynthesis/types.d.ts +110 -0
  100. package/dist/SystemSynthesis/types.d.ts.map +1 -0
  101. package/dist/SystemSynthesis/types.js +12 -0
  102. package/dist/SystemSynthesis/types.js.map +1 -0
  103. package/dist/amGeneration/buildFlowGraph.d.ts +39 -0
  104. package/dist/amGeneration/buildFlowGraph.d.ts.map +1 -0
  105. package/dist/amGeneration/buildFlowGraph.js +643 -0
  106. package/dist/amGeneration/buildFlowGraph.js.map +1 -0
  107. package/dist/amGeneration/enrichAMEdges.d.ts +16 -0
  108. package/dist/amGeneration/enrichAMEdges.d.ts.map +1 -0
  109. package/dist/amGeneration/enrichAMEdges.js +291 -0
  110. package/dist/amGeneration/enrichAMEdges.js.map +1 -0
  111. package/dist/amGeneration/generateAM.d.ts +23 -0
  112. package/dist/amGeneration/generateAM.d.ts.map +1 -0
  113. package/dist/amGeneration/generateAM.js +131 -0
  114. package/dist/amGeneration/generateAM.js.map +1 -0
  115. package/dist/amGeneration/generateAMForRepo.d.ts +6 -0
  116. package/dist/amGeneration/generateAMForRepo.d.ts.map +1 -0
  117. package/dist/amGeneration/generateAMForRepo.js +130 -0
  118. package/dist/amGeneration/generateAMForRepo.js.map +1 -0
  119. package/dist/amGeneration/generateFlows.d.ts +27 -0
  120. package/dist/amGeneration/generateFlows.d.ts.map +1 -0
  121. package/dist/amGeneration/generateFlows.js +320 -0
  122. package/dist/amGeneration/generateFlows.js.map +1 -0
  123. package/dist/amGeneration/promptBuilder.d.ts +24 -0
  124. package/dist/amGeneration/promptBuilder.d.ts.map +1 -0
  125. package/dist/amGeneration/promptBuilder.js +299 -0
  126. package/dist/amGeneration/promptBuilder.js.map +1 -0
  127. package/dist/amGeneration/selectStrategicFiles.d.ts +42 -0
  128. package/dist/amGeneration/selectStrategicFiles.d.ts.map +1 -0
  129. package/dist/amGeneration/selectStrategicFiles.js +672 -0
  130. package/dist/amGeneration/selectStrategicFiles.js.map +1 -0
  131. package/dist/amGeneration/types.d.ts +83 -0
  132. package/dist/amGeneration/types.d.ts.map +1 -0
  133. package/dist/amGeneration/types.js +9 -0
  134. package/dist/amGeneration/types.js.map +1 -0
  135. package/dist/amSections.d.ts +29 -0
  136. package/dist/amSections.d.ts.map +1 -0
  137. package/dist/amSections.js +424 -0
  138. package/dist/amSections.js.map +1 -0
  139. package/dist/analysis/analysisCache.d.ts +4 -0
  140. package/dist/analysis/analysisCache.d.ts.map +1 -0
  141. package/dist/analysis/analysisCache.js +92 -0
  142. package/dist/analysis/analysisCache.js.map +1 -0
  143. package/dist/analysis/buildBranchStory.d.ts +95 -0
  144. package/dist/analysis/buildBranchStory.d.ts.map +1 -0
  145. package/dist/analysis/buildBranchStory.js +1264 -0
  146. package/dist/analysis/buildBranchStory.js.map +1 -0
  147. package/dist/analysis/buildDetailedFileXRay.d.ts +49 -0
  148. package/dist/analysis/buildDetailedFileXRay.d.ts.map +1 -0
  149. package/dist/analysis/buildDetailedFileXRay.js +607 -0
  150. package/dist/analysis/buildDetailedFileXRay.js.map +1 -0
  151. package/dist/analysis/buildFileXRay.d.ts +35 -0
  152. package/dist/analysis/buildFileXRay.d.ts.map +1 -0
  153. package/dist/analysis/buildFileXRay.js +305 -0
  154. package/dist/analysis/buildFileXRay.js.map +1 -0
  155. package/dist/analysis/classifySilentKiller.d.ts +14 -0
  156. package/dist/analysis/classifySilentKiller.d.ts.map +1 -0
  157. package/dist/analysis/classifySilentKiller.js +235 -0
  158. package/dist/analysis/classifySilentKiller.js.map +1 -0
  159. package/dist/analysis/diffChunks.d.ts +21 -0
  160. package/dist/analysis/diffChunks.d.ts.map +1 -0
  161. package/dist/analysis/diffChunks.js +302 -0
  162. package/dist/analysis/diffChunks.js.map +1 -0
  163. package/dist/analysis/extractRouteMap.d.ts +49 -0
  164. package/dist/analysis/extractRouteMap.d.ts.map +1 -0
  165. package/dist/analysis/extractRouteMap.js +354 -0
  166. package/dist/analysis/extractRouteMap.js.map +1 -0
  167. package/dist/analysis/generateFileInsight.d.ts +19 -0
  168. package/dist/analysis/generateFileInsight.d.ts.map +1 -0
  169. package/dist/analysis/generateFileInsight.js +103 -0
  170. package/dist/analysis/generateFileInsight.js.map +1 -0
  171. package/dist/analysis/llmXRay.d.ts +39 -0
  172. package/dist/analysis/llmXRay.d.ts.map +1 -0
  173. package/dist/analysis/llmXRay.js +208 -0
  174. package/dist/analysis/llmXRay.js.map +1 -0
  175. package/dist/analysis/simulateFailure.d.ts +44 -0
  176. package/dist/analysis/simulateFailure.d.ts.map +1 -0
  177. package/dist/analysis/simulateFailure.js +407 -0
  178. package/dist/analysis/simulateFailure.js.map +1 -0
  179. package/dist/anthropic.d.ts +3 -0
  180. package/dist/anthropic.d.ts.map +1 -0
  181. package/dist/anthropic.js +16 -0
  182. package/dist/anthropic.js.map +1 -0
  183. package/dist/app/buildAppPage.d.ts +34 -0
  184. package/dist/app/buildAppPage.d.ts.map +1 -0
  185. package/dist/app/buildAppPage.js +3085 -0
  186. package/dist/app/buildAppPage.js.map +1 -0
  187. package/dist/app-bundle.js +122 -0
  188. package/dist/buildAppData.d.ts +3 -0
  189. package/dist/buildAppData.d.ts.map +1 -0
  190. package/dist/buildAppData.js +207 -0
  191. package/dist/buildAppData.js.map +1 -0
  192. package/dist/builders/analyzeRepo.d.ts +25 -0
  193. package/dist/builders/analyzeRepo.d.ts.map +1 -0
  194. package/dist/builders/analyzeRepo.js +873 -0
  195. package/dist/builders/analyzeRepo.js.map +1 -0
  196. package/dist/builders/buildSystemConnections.d.ts +3 -0
  197. package/dist/builders/buildSystemConnections.d.ts.map +1 -0
  198. package/dist/builders/buildSystemConnections.js +388 -0
  199. package/dist/builders/buildSystemConnections.js.map +1 -0
  200. package/dist/builders/buildTextSummary.d.ts +61 -0
  201. package/dist/builders/buildTextSummary.d.ts.map +1 -0
  202. package/dist/builders/buildTextSummary.js +178 -0
  203. package/dist/builders/buildTextSummary.js.map +1 -0
  204. package/dist/builders/deriveRecommendedStartPath.d.ts +11 -0
  205. package/dist/builders/deriveRecommendedStartPath.d.ts.map +1 -0
  206. package/dist/builders/deriveRecommendedStartPath.js +140 -0
  207. package/dist/builders/deriveRecommendedStartPath.js.map +1 -0
  208. package/dist/builders/deriveRuntimeRole.d.ts +4 -0
  209. package/dist/builders/deriveRuntimeRole.d.ts.map +1 -0
  210. package/dist/builders/deriveRuntimeRole.js +30 -0
  211. package/dist/builders/deriveRuntimeRole.js.map +1 -0
  212. package/dist/builders/detectRunCommands.d.ts +16 -0
  213. package/dist/builders/detectRunCommands.d.ts.map +1 -0
  214. package/dist/builders/detectRunCommands.js +285 -0
  215. package/dist/builders/detectRunCommands.js.map +1 -0
  216. package/dist/builders/generateSystemNarrative.d.ts +12 -0
  217. package/dist/builders/generateSystemNarrative.d.ts.map +1 -0
  218. package/dist/builders/generateSystemNarrative.js +474 -0
  219. package/dist/builders/generateSystemNarrative.js.map +1 -0
  220. package/dist/builders/gitLogParser.d.ts +15 -0
  221. package/dist/builders/gitLogParser.d.ts.map +1 -0
  222. package/dist/builders/gitLogParser.js +116 -0
  223. package/dist/builders/gitLogParser.js.map +1 -0
  224. package/dist/builders/readRepoContext.d.ts +30 -0
  225. package/dist/builders/readRepoContext.d.ts.map +1 -0
  226. package/dist/builders/readRepoContext.js +323 -0
  227. package/dist/builders/readRepoContext.js.map +1 -0
  228. package/dist/builders/readSystemReadme.d.ts +39 -0
  229. package/dist/builders/readSystemReadme.d.ts.map +1 -0
  230. package/dist/builders/readSystemReadme.js +133 -0
  231. package/dist/builders/readSystemReadme.js.map +1 -0
  232. package/dist/builders/systemRanking.d.ts +24 -0
  233. package/dist/builders/systemRanking.d.ts.map +1 -0
  234. package/dist/builders/systemRanking.js +153 -0
  235. package/dist/builders/systemRanking.js.map +1 -0
  236. package/dist/cli.d.ts +3 -0
  237. package/dist/cli.d.ts.map +1 -0
  238. package/dist/cli.js +170 -0
  239. package/dist/cli.js.map +1 -0
  240. package/dist/detectors/applyRunnableConfidenceGate.d.ts +8 -0
  241. package/dist/detectors/applyRunnableConfidenceGate.d.ts.map +1 -0
  242. package/dist/detectors/applyRunnableConfidenceGate.js +166 -0
  243. package/dist/detectors/applyRunnableConfidenceGate.js.map +1 -0
  244. package/dist/detectors/classifySystemType.d.ts +17 -0
  245. package/dist/detectors/classifySystemType.d.ts.map +1 -0
  246. package/dist/detectors/classifySystemType.js +460 -0
  247. package/dist/detectors/classifySystemType.js.map +1 -0
  248. package/dist/detectors/detectAppInternalUnits.d.ts +20 -0
  249. package/dist/detectors/detectAppInternalUnits.d.ts.map +1 -0
  250. package/dist/detectors/detectAppInternalUnits.js +454 -0
  251. package/dist/detectors/detectAppInternalUnits.js.map +1 -0
  252. package/dist/detectors/detectBlocks.d.ts +6 -0
  253. package/dist/detectors/detectBlocks.d.ts.map +1 -0
  254. package/dist/detectors/detectBlocks.js +354 -0
  255. package/dist/detectors/detectBlocks.js.map +1 -0
  256. package/dist/detectors/detectComposeServices.d.ts +23 -0
  257. package/dist/detectors/detectComposeServices.d.ts.map +1 -0
  258. package/dist/detectors/detectComposeServices.js +255 -0
  259. package/dist/detectors/detectComposeServices.js.map +1 -0
  260. package/dist/detectors/detectEntryPoints.d.ts +6 -0
  261. package/dist/detectors/detectEntryPoints.d.ts.map +1 -0
  262. package/dist/detectors/detectEntryPoints.js +376 -0
  263. package/dist/detectors/detectEntryPoints.js.map +1 -0
  264. package/dist/detectors/detectSubsystems.d.ts +6 -0
  265. package/dist/detectors/detectSubsystems.d.ts.map +1 -0
  266. package/dist/detectors/detectSubsystems.js +376 -0
  267. package/dist/detectors/detectSubsystems.js.map +1 -0
  268. package/dist/detectors/detectSystemCandidates.d.ts +3 -0
  269. package/dist/detectors/detectSystemCandidates.d.ts.map +1 -0
  270. package/dist/detectors/detectSystemCandidates.js +577 -0
  271. package/dist/detectors/detectSystemCandidates.js.map +1 -0
  272. package/dist/devWatcher.d.ts +14 -0
  273. package/dist/devWatcher.d.ts.map +1 -0
  274. package/dist/devWatcher.js +96 -0
  275. package/dist/devWatcher.js.map +1 -0
  276. package/dist/graph/buildCodebaseGraph.d.ts +3 -0
  277. package/dist/graph/buildCodebaseGraph.d.ts.map +1 -0
  278. package/dist/graph/buildCodebaseGraph.js +602 -0
  279. package/dist/graph/buildCodebaseGraph.js.map +1 -0
  280. package/dist/graph/buildLLMPayload.d.ts +89 -0
  281. package/dist/graph/buildLLMPayload.d.ts.map +1 -0
  282. package/dist/graph/buildLLMPayload.js +715 -0
  283. package/dist/graph/buildLLMPayload.js.map +1 -0
  284. package/dist/graph/callLLM.d.ts +16 -0
  285. package/dist/graph/callLLM.d.ts.map +1 -0
  286. package/dist/graph/callLLM.js +274 -0
  287. package/dist/graph/callLLM.js.map +1 -0
  288. package/dist/graph/types.d.ts +76 -0
  289. package/dist/graph/types.d.ts.map +1 -0
  290. package/dist/graph/types.js +5 -0
  291. package/dist/graph/types.js.map +1 -0
  292. package/dist/graph/walkExports.d.ts +2 -0
  293. package/dist/graph/walkExports.d.ts.map +1 -0
  294. package/dist/graph/walkExports.js +172 -0
  295. package/dist/graph/walkExports.js.map +1 -0
  296. package/dist/heuristics/file-patterns.json +325 -0
  297. package/dist/heuristics/known-packages.json +1022 -0
  298. package/dist/heuristics/loader.d.ts +121 -0
  299. package/dist/heuristics/loader.d.ts.map +1 -0
  300. package/dist/heuristics/loader.js +196 -0
  301. package/dist/heuristics/loader.js.map +1 -0
  302. package/dist/heuristics/repo-mode-signals.json +248 -0
  303. package/dist/index.d.ts +3 -0
  304. package/dist/index.d.ts.map +1 -0
  305. package/dist/index.js +93 -0
  306. package/dist/index.js.map +1 -0
  307. package/dist/mcp.d.ts +3 -0
  308. package/dist/mcp.d.ts.map +1 -0
  309. package/dist/mcp.js +356 -0
  310. package/dist/mcp.js.map +1 -0
  311. package/dist/scanner/buildImportGraph.d.ts +23 -0
  312. package/dist/scanner/buildImportGraph.d.ts.map +1 -0
  313. package/dist/scanner/buildImportGraph.js +186 -0
  314. package/dist/scanner/buildImportGraph.js.map +1 -0
  315. package/dist/scanner/detectDBOps.d.ts +21 -0
  316. package/dist/scanner/detectDBOps.d.ts.map +1 -0
  317. package/dist/scanner/detectDBOps.js +346 -0
  318. package/dist/scanner/detectDBOps.js.map +1 -0
  319. package/dist/scanner/detectOutbound.d.ts +6 -0
  320. package/dist/scanner/detectOutbound.d.ts.map +1 -0
  321. package/dist/scanner/detectOutbound.js +101 -0
  322. package/dist/scanner/detectOutbound.js.map +1 -0
  323. package/dist/scanner/detectRepoPurpose.d.ts +19 -0
  324. package/dist/scanner/detectRepoPurpose.d.ts.map +1 -0
  325. package/dist/scanner/detectRepoPurpose.js +335 -0
  326. package/dist/scanner/detectRepoPurpose.js.map +1 -0
  327. package/dist/scanner/detectRoutes.d.ts +22 -0
  328. package/dist/scanner/detectRoutes.d.ts.map +1 -0
  329. package/dist/scanner/detectRoutes.js +406 -0
  330. package/dist/scanner/detectRoutes.js.map +1 -0
  331. package/dist/scanner/filterNoise.d.ts +4 -0
  332. package/dist/scanner/filterNoise.d.ts.map +1 -0
  333. package/dist/scanner/filterNoise.js +95 -0
  334. package/dist/scanner/filterNoise.js.map +1 -0
  335. package/dist/scanner/loadTsAliases.d.ts +20 -0
  336. package/dist/scanner/loadTsAliases.d.ts.map +1 -0
  337. package/dist/scanner/loadTsAliases.js +135 -0
  338. package/dist/scanner/loadTsAliases.js.map +1 -0
  339. package/dist/scanner/routeHandlers.d.ts +15 -0
  340. package/dist/scanner/routeHandlers.d.ts.map +1 -0
  341. package/dist/scanner/routeHandlers.js +154 -0
  342. package/dist/scanner/routeHandlers.js.map +1 -0
  343. package/dist/scanner/scanRepo.d.ts +10 -0
  344. package/dist/scanner/scanRepo.d.ts.map +1 -0
  345. package/dist/scanner/scanRepo.js +165 -0
  346. package/dist/scanner/scanRepo.js.map +1 -0
  347. package/dist/scanner/walkImports.d.ts +14 -0
  348. package/dist/scanner/walkImports.d.ts.map +1 -0
  349. package/dist/scanner/walkImports.js +162 -0
  350. package/dist/scanner/walkImports.js.map +1 -0
  351. package/dist/server.d.ts +2 -0
  352. package/dist/server.d.ts.map +1 -0
  353. package/dist/server.js +956 -0
  354. package/dist/server.js.map +1 -0
  355. package/dist/session/diff.d.ts +4 -0
  356. package/dist/session/diff.d.ts.map +1 -0
  357. package/dist/session/diff.js +150 -0
  358. package/dist/session/diff.js.map +1 -0
  359. package/dist/session/snapshot.d.ts +5 -0
  360. package/dist/session/snapshot.d.ts.map +1 -0
  361. package/dist/session/snapshot.js +114 -0
  362. package/dist/session/snapshot.js.map +1 -0
  363. package/dist/session/store.d.ts +8 -0
  364. package/dist/session/store.d.ts.map +1 -0
  365. package/dist/session/store.js +101 -0
  366. package/dist/session/store.js.map +1 -0
  367. package/dist/session/types.d.ts +46 -0
  368. package/dist/session/types.d.ts.map +1 -0
  369. package/dist/session/types.js +4 -0
  370. package/dist/session/types.js.map +1 -0
  371. package/dist/types.d.ts +350 -0
  372. package/dist/types.d.ts.map +1 -0
  373. package/dist/types.js +4 -0
  374. package/dist/types.js.map +1 -0
  375. package/dist/utils/file.d.ts +5 -0
  376. package/dist/utils/file.d.ts.map +1 -0
  377. package/dist/utils/file.js +76 -0
  378. package/dist/utils/file.js.map +1 -0
  379. package/dist/utils/path.d.ts +7 -0
  380. package/dist/utils/path.d.ts.map +1 -0
  381. package/dist/utils/path.js +62 -0
  382. package/dist/utils/path.js.map +1 -0
  383. package/dist/utils/text.d.ts +5 -0
  384. package/dist/utils/text.d.ts.map +1 -0
  385. package/dist/utils/text.js +29 -0
  386. package/dist/utils/text.js.map +1 -0
  387. package/dist/viewBuilders/buildSystemFolders.d.ts +39 -0
  388. package/dist/viewBuilders/buildSystemFolders.d.ts.map +1 -0
  389. package/dist/viewBuilders/buildSystemFolders.js +198 -0
  390. package/dist/viewBuilders/buildSystemFolders.js.map +1 -0
  391. package/dist/watcher/repoWatcher.d.ts +17 -0
  392. package/dist/watcher/repoWatcher.d.ts.map +1 -0
  393. package/dist/watcher/repoWatcher.js +87 -0
  394. package/dist/watcher/repoWatcher.js.map +1 -0
  395. package/package.json +102 -0
  396. package/public/memor_logo.svg +18 -0
  397. package/public/memor_transparent_logo.svg +25 -0
  398. package/public/tIcons/bun.svg +1 -0
  399. package/public/tIcons/css.svg +1 -0
  400. package/public/tIcons/docker.svg +3 -0
  401. package/public/tIcons/expressjs.svg +1 -0
  402. package/public/tIcons/html5.svg +6 -0
  403. package/public/tIcons/javascript.svg +1 -0
  404. package/public/tIcons/jest.svg +4 -0
  405. package/public/tIcons/json.svg +1 -0
  406. package/public/tIcons/markdown-light.svg +1 -0
  407. package/public/tIcons/nestjs.svg +1 -0
  408. package/public/tIcons/nextjs_icon_dark.svg +1 -0
  409. package/public/tIcons/npm.svg +1 -0
  410. package/public/tIcons/pnpm.svg +1 -0
  411. package/public/tIcons/prisma.svg +1 -0
  412. package/public/tIcons/react_dark.svg +11 -0
  413. package/public/tIcons/supabase.svg +15 -0
  414. package/public/tIcons/tailwindcss.svg +1 -0
  415. package/public/tIcons/turborepo-icon-light.svg +1 -0
  416. package/public/tIcons/typescript.svg +1 -0
  417. package/public/tIcons/vite.svg +1 -0
  418. package/public/tIcons/yarn.svg +1 -0
@@ -0,0 +1,672 @@
1
+ "use strict";
2
+ /**
3
+ * selectStrategicFiles — picks files the LLM should read + builds a file tree.
4
+ *
5
+ * Three-phase selection:
6
+ * Phase 0 — Workspace-aware: For monorepos (pnpm/yarn/npm workspaces), pick 1
7
+ * representative file per workspace package. Ensures every package is
8
+ * represented, not just the first N files found.
9
+ * Phase 1 — Targeted reads: API route handlers, lib/service files, schema files,
10
+ * external clients. Per-pattern caps prevent any one category from
11
+ * consuming all slots.
12
+ * Phase 2 — Graph-signal reads: entry points, route owners, high inDegree.
13
+ * Fill remaining slots up to MAX_FILES.
14
+ *
15
+ * Also exports buildFileTree() — a compact directory listing used in the prompt
16
+ * so the LLM sees every path even if it can't read every file.
17
+ */
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.buildFileTree = buildFileTree;
23
+ exports.readWorkspaceManifests = readWorkspaceManifests;
24
+ exports.selectStrategicFiles = selectStrategicFiles;
25
+ const promises_1 = __importDefault(require("fs/promises"));
26
+ const path_1 = __importDefault(require("path"));
27
+ const MAX_FILES = 30;
28
+ const MAX_FILE_SIZE_BYTES = 8000;
29
+ // For monorepos: max packages to represent before targeted/graph phases fill the rest
30
+ const MAX_WORKSPACE_PACKAGE_SLOTS = 30;
31
+ // ── File tree builder ─────────────────────────────────────────────────────────
32
+ const TREE_IGNORE = new Set([
33
+ "node_modules", ".next", ".git", "dist", "build", "out",
34
+ ".cache", "coverage", "__pycache__", ".turbo", ".vercel",
35
+ ]);
36
+ const SOURCE_EXTS = new Set([".ts", ".tsx", ".js", ".jsx", ".py", ".go", ".rs", ".prisma"]);
37
+ async function walkDir(dir, repoRoot, depth) {
38
+ if (depth > 6)
39
+ return [];
40
+ let entries;
41
+ try {
42
+ entries = await promises_1.default.readdir(dir, { withFileTypes: true });
43
+ }
44
+ catch {
45
+ return [];
46
+ }
47
+ const lines = [];
48
+ const indent = " ".repeat(depth);
49
+ const sorted = entries.sort((a, b) => {
50
+ // dirs first, then files
51
+ if (a.isDirectory() && !b.isDirectory())
52
+ return -1;
53
+ if (!a.isDirectory() && b.isDirectory())
54
+ return 1;
55
+ return a.name.localeCompare(b.name);
56
+ });
57
+ for (const e of sorted) {
58
+ if (e.name.startsWith(".") && e.name !== ".env.example")
59
+ continue;
60
+ if (TREE_IGNORE.has(e.name))
61
+ continue;
62
+ if (e.isDirectory()) {
63
+ lines.push(`${indent}${e.name}/`);
64
+ const sub = await walkDir(path_1.default.join(dir, e.name), repoRoot, depth + 1);
65
+ lines.push(...sub);
66
+ }
67
+ else if (e.isFile()) {
68
+ const ext = path_1.default.extname(e.name);
69
+ if (SOURCE_EXTS.has(ext) || e.name === "package.json" || e.name === "schema.prisma") {
70
+ lines.push(`${indent}${e.name}`);
71
+ }
72
+ }
73
+ }
74
+ return lines;
75
+ }
76
+ async function buildFileTree(repoRoot, workspaceDirs) {
77
+ // For large monorepos: show workspace packages as flat list + top-level files only.
78
+ // Descending into every package at depth-6 produces tens of thousands of lines; the
79
+ // 300-line cap then truncates to ~2% of the structure — useless. Better to show all
80
+ // package names clearly and let workspace manifests provide the detail.
81
+ if (workspaceDirs && workspaceDirs.size >= 10) {
82
+ const rootEntries = await promises_1.default.readdir(repoRoot, { withFileTypes: true }).catch(() => []);
83
+ const lines = [];
84
+ // Top-level source files
85
+ for (const e of rootEntries) {
86
+ if (e.isFile()) {
87
+ const ext = path_1.default.extname(e.name);
88
+ if (SOURCE_EXTS.has(ext) || e.name === "package.json")
89
+ lines.push(e.name);
90
+ }
91
+ }
92
+ // Workspace directories — show one level deep (subdirs only, not every file)
93
+ const workspaceDirsSorted = [...workspaceDirs].sort();
94
+ for (const absDir of workspaceDirsSorted) {
95
+ const rel = path_1.default.relative(repoRoot, absDir);
96
+ lines.push(`${rel}/`);
97
+ // Show src/ or top-level source structure — one level only
98
+ const subEntries = await promises_1.default.readdir(absDir, { withFileTypes: true }).catch(() => []);
99
+ for (const e of subEntries) {
100
+ if (e.name.startsWith(".") || TREE_IGNORE.has(e.name))
101
+ continue;
102
+ if (e.isDirectory()) {
103
+ lines.push(` ${e.name}/`);
104
+ }
105
+ else if (e.isFile()) {
106
+ const ext = path_1.default.extname(e.name);
107
+ if (SOURCE_EXTS.has(ext) || e.name === "package.json")
108
+ lines.push(` ${e.name}`);
109
+ }
110
+ }
111
+ }
112
+ return lines.join("\n");
113
+ }
114
+ const lines = await walkDir(repoRoot, repoRoot, 0);
115
+ // Cap at 400 lines to avoid bloating the prompt
116
+ if (lines.length > 400) {
117
+ return lines.slice(0, 400).join("\n") + `\n... (${lines.length - 400} more files)`;
118
+ }
119
+ return lines.join("\n");
120
+ }
121
+ /**
122
+ * Parse glob patterns from pnpm-workspace.yaml, package.json#workspaces, or
123
+ * lerna.json#packages. Expands `dir/*` patterns into real subdirectories.
124
+ * Returns directories that actually contain a package.json.
125
+ */
126
+ async function detectWorkspacePackages(repoRoot) {
127
+ const packages = [];
128
+ const seen = new Set();
129
+ async function tryAddDir(dir) {
130
+ const abs = path_1.default.isAbsolute(dir) ? dir : path_1.default.join(repoRoot, dir);
131
+ if (seen.has(abs))
132
+ return;
133
+ seen.add(abs);
134
+ try {
135
+ const raw = await promises_1.default.readFile(path_1.default.join(abs, "package.json"), "utf8");
136
+ const pkg = JSON.parse(raw);
137
+ packages.push({ dir: abs, name: pkg.name ?? path_1.default.basename(abs) });
138
+ }
139
+ catch { }
140
+ }
141
+ async function expandGlob(pattern) {
142
+ // Only handle the common `dir/*` pattern — deeper globs are rare in practice
143
+ if (pattern.endsWith("/*")) {
144
+ const parent = path_1.default.join(repoRoot, pattern.slice(0, -2));
145
+ try {
146
+ const entries = await promises_1.default.readdir(parent, { withFileTypes: true });
147
+ for (const e of entries) {
148
+ if (e.isDirectory() && !e.name.startsWith(".") && !TREE_IGNORE.has(e.name)) {
149
+ await tryAddDir(path_1.default.join(parent, e.name));
150
+ }
151
+ }
152
+ }
153
+ catch { }
154
+ }
155
+ else {
156
+ await tryAddDir(path_1.default.join(repoRoot, pattern));
157
+ }
158
+ }
159
+ // pnpm-workspace.yaml
160
+ try {
161
+ const raw = await promises_1.default.readFile(path_1.default.join(repoRoot, "pnpm-workspace.yaml"), "utf8");
162
+ // Extract lines like ` - 'packages/*'` or ` - packages/*`
163
+ const lines = raw.split("\n");
164
+ let inPackages = false;
165
+ for (const line of lines) {
166
+ const trimmed = line.trim();
167
+ if (trimmed === "packages:") {
168
+ inPackages = true;
169
+ continue;
170
+ }
171
+ if (inPackages) {
172
+ if (trimmed.startsWith("-")) {
173
+ const glob = trimmed.slice(1).trim().replace(/^['"]|['"]$/g, "");
174
+ await expandGlob(glob);
175
+ }
176
+ else if (trimmed && !trimmed.startsWith("#")) {
177
+ inPackages = false; // new top-level key
178
+ }
179
+ }
180
+ }
181
+ }
182
+ catch { }
183
+ // root package.json#workspaces (yarn / npm workspaces)
184
+ if (packages.length === 0) {
185
+ try {
186
+ const root = JSON.parse(await promises_1.default.readFile(path_1.default.join(repoRoot, "package.json"), "utf8"));
187
+ const globs = Array.isArray(root.workspaces)
188
+ ? root.workspaces
189
+ : (root.workspaces?.packages ?? []);
190
+ for (const glob of globs)
191
+ await expandGlob(glob);
192
+ }
193
+ catch { }
194
+ }
195
+ // lerna.json
196
+ if (packages.length === 0) {
197
+ try {
198
+ const lerna = JSON.parse(await promises_1.default.readFile(path_1.default.join(repoRoot, "lerna.json"), "utf8"));
199
+ const globs = lerna.packages ?? ["packages/*"];
200
+ for (const glob of globs)
201
+ await expandGlob(glob);
202
+ }
203
+ catch { }
204
+ }
205
+ return packages;
206
+ }
207
+ /**
208
+ * Read package.json manifests for ALL workspace packages.
209
+ * Returns lightweight summaries used to build the WORKSPACE PACKAGES prompt section.
210
+ * This is the reliable alternative to heuristic source-file selection — package.json
211
+ * always exists and contains names, descriptions, and inter-package dependencies.
212
+ */
213
+ async function readWorkspaceManifests(repoRoot) {
214
+ const packages = await detectWorkspacePackages(repoRoot);
215
+ if (packages.length < 3)
216
+ return []; // not a monorepo
217
+ // Build a set of all workspace package names for internal dep detection
218
+ const workspaceNames = new Set(packages.map((p) => p.name));
219
+ const manifests = [];
220
+ await Promise.all(packages.map(async ({ dir, name }) => {
221
+ try {
222
+ const raw = await promises_1.default.readFile(path_1.default.join(dir, "package.json"), "utf8");
223
+ const pkg = JSON.parse(raw);
224
+ const allDeps = {
225
+ ...(pkg.dependencies ?? {}),
226
+ ...(pkg.peerDependencies ?? {}),
227
+ };
228
+ const internalDeps = Object.keys(allDeps)
229
+ .filter((d) => workspaceNames.has(d))
230
+ .sort();
231
+ const externalDeps = Object.keys(allDeps)
232
+ .filter((d) => !workspaceNames.has(d) && !d.startsWith("@types/"))
233
+ .slice(0, 5)
234
+ .sort();
235
+ // Simplified exports: just the subpath keys (e.g. ".", "./client", "./server")
236
+ const exportsField = pkg.exports;
237
+ let exports = [];
238
+ if (typeof exportsField === "string") {
239
+ exports = ["."];
240
+ }
241
+ else if (typeof exportsField === "object" && exportsField !== null) {
242
+ exports = Object.keys(exportsField).slice(0, 8);
243
+ }
244
+ else if (pkg.main || pkg.module) {
245
+ exports = ["."];
246
+ }
247
+ manifests.push({
248
+ relDir: path_1.default.relative(repoRoot, dir),
249
+ name: pkg.name ?? name,
250
+ description: pkg.description,
251
+ internalDeps,
252
+ externalDeps,
253
+ exports,
254
+ isPrivate: !!pkg.private,
255
+ });
256
+ }
257
+ catch { /* skip unreadable */ }
258
+ }));
259
+ // Sort: fewest deps first (foundation packages first), then alphabetically
260
+ manifests.sort((a, b) => a.internalDeps.length - b.internalDeps.length ||
261
+ a.name.localeCompare(b.name));
262
+ return manifests;
263
+ }
264
+ /**
265
+ * For a workspace package directory, find the single most representative source
266
+ * file: prefers the main/module entry from package.json, then index.ts/js, then
267
+ * any top-level source file.
268
+ */
269
+ async function findPackageEntryFile(pkgDir) {
270
+ // Try package.json#main / #module / #exports
271
+ try {
272
+ const raw = await promises_1.default.readFile(path_1.default.join(pkgDir, "package.json"), "utf8");
273
+ const pkg = JSON.parse(raw);
274
+ const candidates = [pkg.main, pkg.module, pkg.source, pkg.exports]
275
+ .flat()
276
+ .filter(Boolean)
277
+ .map((s) => (typeof s === "string" ? s : null))
278
+ .filter(Boolean);
279
+ for (const c of candidates) {
280
+ // Resolve src variant (package.json often points to compiled dist, but src is better)
281
+ const srcVariant = c.replace(/^(dist|lib|build)\//, "src/").replace(/\.(js|cjs|mjs)$/, ".ts");
282
+ for (const candidate of [srcVariant, c]) {
283
+ const abs = path_1.default.resolve(pkgDir, candidate);
284
+ try {
285
+ await promises_1.default.access(abs);
286
+ return abs;
287
+ }
288
+ catch { }
289
+ }
290
+ }
291
+ }
292
+ catch { }
293
+ // Fallback: standard entry file names in pkg root, src/, or lib/
294
+ const ENTRY_NAMES = ["index.ts", "index.tsx", "index.js", "index.jsx",
295
+ "main.ts", "main.tsx", "main.js", "app.ts", "app.tsx", "app.js"];
296
+ const searchDirs = [pkgDir, path_1.default.join(pkgDir, "src"), path_1.default.join(pkgDir, "lib")];
297
+ for (const dir of searchDirs) {
298
+ for (const name of ENTRY_NAMES) {
299
+ const abs = path_1.default.join(dir, name);
300
+ try {
301
+ await promises_1.default.access(abs);
302
+ return abs;
303
+ }
304
+ catch { }
305
+ }
306
+ }
307
+ const isSourceFile = (name) => /\.(ts|tsx|js|jsx)$/.test(name) &&
308
+ !name.endsWith(".test.ts") && !name.endsWith(".spec.ts") &&
309
+ !name.endsWith(".test.js") && !name.endsWith(".spec.js") &&
310
+ !name.endsWith(".stories.tsx") && !name.endsWith(".d.ts");
311
+ // Score filenames: prefer "main module" signals over utility files.
312
+ // Lower = more representative.
313
+ const fileScore = (name) => {
314
+ const stem = name.replace(/\.(ts|tsx|js|jsx)$/, "").toLowerCase();
315
+ if (/^(index|main|app|server|client|core|plugin|registry|manager|symbols|config|types|constants)$/i.test(stem))
316
+ return 0;
317
+ if (/hostconfig|symbols|registry|plugin|manager|internals|public/i.test(stem))
318
+ return 1;
319
+ if (/^react/i.test(stem))
320
+ return 2;
321
+ return 3;
322
+ };
323
+ const bestFile = (files, dir) => {
324
+ const src = files.filter((e) => e.isFile() && isSourceFile(e.name));
325
+ if (!src.length)
326
+ return null;
327
+ src.sort((a, b) => fileScore(a.name) - fileScore(b.name) || a.name.localeCompare(b.name));
328
+ return path_1.default.join(dir, src[0].name);
329
+ };
330
+ // Files directly in src/
331
+ const srcDir = path_1.default.join(pkgDir, "src");
332
+ try {
333
+ const entries = await promises_1.default.readdir(srcDir, { withFileTypes: true });
334
+ const f = bestFile(entries, srcDir);
335
+ if (f)
336
+ return f;
337
+ }
338
+ catch { }
339
+ // Files at package root — covers packages like shared/ that put .js at root
340
+ try {
341
+ const entries = await promises_1.default.readdir(pkgDir, { withFileTypes: true });
342
+ const f = bestFile(entries, pkgDir);
343
+ if (f)
344
+ return f;
345
+ }
346
+ catch { }
347
+ // One level deeper into src/ subdirs — covers packages like react-dom-bindings
348
+ // where src/ has only subdirs (client/, events/, server/)
349
+ const SUBDIR_PRIORITY = ["client", "server", "shared", "lib", "core"];
350
+ try {
351
+ const srcEntries = await promises_1.default.readdir(srcDir, { withFileTypes: true });
352
+ const subdirs = srcEntries
353
+ .filter((e) => e.isDirectory() && !TREE_IGNORE.has(e.name))
354
+ .sort((a, b) => {
355
+ const ai = SUBDIR_PRIORITY.indexOf(a.name);
356
+ const bi = SUBDIR_PRIORITY.indexOf(b.name);
357
+ return (ai === -1 ? 99 : ai) - (bi === -1 ? 99 : bi);
358
+ });
359
+ for (const subdir of subdirs) {
360
+ const subPath = path_1.default.join(srcDir, subdir.name);
361
+ const subEntries = await promises_1.default.readdir(subPath, { withFileTypes: true });
362
+ const f = bestFile(subEntries, subPath);
363
+ if (f)
364
+ return f;
365
+ }
366
+ }
367
+ catch { }
368
+ return null;
369
+ }
370
+ // ── Targeted file reader ──────────────────────────────────────────────────────
371
+ // Paths that look like API routes but are actually type/DTO/schema definitions — skip them.
372
+ const TARGETED_EXCLUDE = /\/(dto|types?|interfaces?|schemas?|models?|constants?|enums?)\//i;
373
+ const TARGETED_PATTERNS = [
374
+ // External service clients (Jira, Stripe, AWS, third-party HTTP clients) — read all, usually few
375
+ { glob: /\/(external|clients?|integrations?|providers?)\/.+\.(ts|js)$/i, reason: "external client", priority: 1 },
376
+ // Next.js / Express API route handlers — cap at 8 to avoid every snowflake route consuming slots
377
+ { glob: /\/(api|routes?|controllers?)\/.+\.(ts|js)$/, reason: "API route handler", priority: 2, cap: 8 },
378
+ // Command/operation handlers (handler classes, use-cases, commands) — cap at 6
379
+ { glob: /\/(handlers?|use.?cases?|commands?|actions?)\/.+\.(ts|js)$/i, reason: "handler", priority: 2, cap: 6 },
380
+ // Service / library functions — cap at 6
381
+ { glob: /\/(lib|services?|helpers?|utils?)\/[^/]+\.(ts|js)$/, reason: "service layer", priority: 3, cap: 6 },
382
+ // React data hooks (use*.js/ts files — custom hooks for data fetching) — cap at 4
383
+ { glob: /\/use[A-Z][^/]+\.(ts|tsx|js|jsx)$/, reason: "data hook", priority: 3, cap: 4 },
384
+ // Page / component files — ensures user-facing systems get at least one .tsx in key_files
385
+ // so the LLM and import scanner can trace UI library consumption (e.g. @calcom/ui, @mui/material)
386
+ // Matches Next.js pages/, App Router app/, generic components/, Vue views/, RN screens/
387
+ { glob: /\/(pages?|components?|views?|screens?)\/.+\.tsx$/, reason: "page/component", priority: 3, cap: 5 },
388
+ // DB clients and config
389
+ { glob: /(supabase|prisma|drizzle|mongoose|knex|sequelize|database|db)\.(ts|js)$/i, reason: "data client", priority: 4 },
390
+ // Prisma schema
391
+ { glob: /schema\.prisma$/, reason: "ORM schema", priority: 4 },
392
+ // Auth / middleware
393
+ { glob: /(auth|middleware|guard|session)\.(ts|js)$/, reason: "auth/middleware", priority: 5 },
394
+ // Transformers / mappers
395
+ { glob: /\/(transformers?|mappers?|serializers?|adapters?)\/.+\.(ts|js)$/i, reason: "transformer", priority: 5, cap: 3 },
396
+ ];
397
+ async function findTargetedFiles(repoRoot) {
398
+ const results = [];
399
+ const seen = new Set();
400
+ // Track per-pattern counts for cap enforcement
401
+ const patternCounts = new Map();
402
+ async function walk(dir) {
403
+ let entries;
404
+ try {
405
+ entries = await promises_1.default.readdir(dir, { withFileTypes: true });
406
+ }
407
+ catch {
408
+ return;
409
+ }
410
+ for (const e of entries) {
411
+ if (e.name.startsWith("."))
412
+ continue;
413
+ if (TREE_IGNORE.has(e.name))
414
+ continue;
415
+ const full = path_1.default.join(dir, e.name);
416
+ if (e.isDirectory()) {
417
+ await walk(full);
418
+ }
419
+ else if (e.isFile()) {
420
+ const rel = path_1.default.relative(repoRoot, full);
421
+ if (seen.has(rel))
422
+ continue;
423
+ const ext = path_1.default.extname(e.name);
424
+ if (!SOURCE_EXTS.has(ext) && e.name !== "schema.prisma")
425
+ continue;
426
+ // Skip pure type/DTO files — they don't define systems, they waste slots
427
+ if (TARGETED_EXCLUDE.test(rel))
428
+ continue;
429
+ for (let pi = 0; pi < TARGETED_PATTERNS.length; pi++) {
430
+ const pat = TARGETED_PATTERNS[pi];
431
+ if (pat.glob.test(rel)) {
432
+ const count = patternCounts.get(pi) ?? 0;
433
+ if (pat.cap !== undefined && count >= pat.cap)
434
+ break;
435
+ patternCounts.set(pi, count + 1);
436
+ seen.add(rel);
437
+ results.push({ filePath: full, relPath: rel, reason: pat.reason, priority: pat.priority });
438
+ break;
439
+ }
440
+ }
441
+ }
442
+ }
443
+ }
444
+ await walk(repoRoot);
445
+ return results.sort((a, b) => a.priority - b.priority || a.relPath.localeCompare(b.relPath));
446
+ }
447
+ // ── Graph-signal file finder (unchanged from original) ────────────────────────
448
+ async function findRepresentativeFile(clusterId, repoRoot) {
449
+ const clusterPath = path_1.default.join(repoRoot, clusterId);
450
+ const candidates = [
451
+ "index.ts", "index.tsx", "index.js", "index.jsx",
452
+ "router.ts", "router.js", "main.ts", "main.js",
453
+ "server.ts", "server.js", "app.ts", "app.js", "app.tsx",
454
+ ];
455
+ const searchDirs = [clusterPath, path_1.default.join(clusterPath, "src"), path_1.default.join(clusterPath, "lib")];
456
+ for (const dir of searchDirs) {
457
+ for (const candidate of candidates) {
458
+ const full = path_1.default.join(dir, candidate);
459
+ try {
460
+ await promises_1.default.access(full);
461
+ return full;
462
+ }
463
+ catch { }
464
+ }
465
+ }
466
+ for (const dir of searchDirs) {
467
+ try {
468
+ const entries = await promises_1.default.readdir(dir, { withFileTypes: true });
469
+ const srcFile = entries.find((e) => e.isFile()
470
+ && (e.name.endsWith(".ts") || e.name.endsWith(".tsx") || e.name.endsWith(".js") || e.name.endsWith(".jsx"))
471
+ && !e.name.endsWith(".test.ts") && !e.name.endsWith(".spec.ts")
472
+ && !e.name.endsWith(".test.js") && !e.name.endsWith(".spec.js")
473
+ && !e.name.endsWith(".stories.tsx") && !e.name.endsWith(".stories.jsx"));
474
+ if (srcFile)
475
+ return path_1.default.join(dir, srcFile.name);
476
+ }
477
+ catch { }
478
+ }
479
+ for (const ext of [".ts", ".tsx", ".js", ".jsx"]) {
480
+ const full = path_1.default.join(repoRoot, clusterId + ext);
481
+ try {
482
+ await promises_1.default.access(full);
483
+ return full;
484
+ }
485
+ catch { }
486
+ }
487
+ return null;
488
+ }
489
+ async function readTruncated(filePath) {
490
+ try {
491
+ const content = await promises_1.default.readFile(filePath, "utf8");
492
+ if (Buffer.byteLength(content) <= MAX_FILE_SIZE_BYTES)
493
+ return content;
494
+ return content.slice(0, MAX_FILE_SIZE_BYTES) + "\n\n// ... (truncated)";
495
+ }
496
+ catch {
497
+ return "";
498
+ }
499
+ }
500
+ // ── Must-include: data-client and external service files ─────────────────────
501
+ // These reveal the data-client swimlane layer. They bypass MAX_FILES so the LLM
502
+ // always sees DB connections and external service clients regardless of repo size.
503
+ const MUST_INCLUDE_PATTERNS = [
504
+ { glob: /(supabase|prisma|drizzle|mongoose|knex|sequelize|typeorm)\.(ts|js)$/i, reason: "DB client" },
505
+ { glob: /(snowflake|redshift|bigquery|databricks)\.(ts|js)$/i, reason: "data warehouse client" },
506
+ { glob: /(redis|elasticache|memcache)\.(ts|js)$/i, reason: "cache client" },
507
+ { glob: /(stripe|braintree|paypal|square)\.(ts|js)$/i, reason: "payment client" },
508
+ { glob: /(jira|github|gitlab|slack|twilio|sendgrid|mailgun|postmark)\.(ts|js)$/i, reason: "external service client" },
509
+ { glob: /(aws|gcp|azure).*(client|sdk|secret|credentials?)\.(ts|js)$/i, reason: "cloud client" },
510
+ { glob: /(connection.?manager|db.?pool|database.?pool|pg.?pool|connection.?pool)\.(ts|js)$/i, reason: "connection pool" },
511
+ { glob: /\/(secrets?|credentials?|vault)\.(ts|js)$/i, reason: "secrets client" },
512
+ ];
513
+ const MUST_INCLUDE_BONUS = 3; // files we'll add beyond MAX_FILES
514
+ async function findMustIncludeFiles(repoRoot) {
515
+ const results = [];
516
+ const walk = async (dir) => {
517
+ let entries;
518
+ try {
519
+ entries = await promises_1.default.readdir(dir, { withFileTypes: true });
520
+ }
521
+ catch {
522
+ return;
523
+ }
524
+ for (const e of entries) {
525
+ if (e.name.startsWith(".") || TREE_IGNORE.has(e.name))
526
+ continue;
527
+ const full = path_1.default.join(dir, e.name);
528
+ if (e.isDirectory()) {
529
+ await walk(full);
530
+ }
531
+ else if (e.isFile()) {
532
+ const rel = path_1.default.relative(repoRoot, full);
533
+ for (const pat of MUST_INCLUDE_PATTERNS) {
534
+ if (pat.glob.test(rel)) {
535
+ results.push({ filePath: full, relPath: rel, reason: pat.reason });
536
+ break;
537
+ }
538
+ }
539
+ }
540
+ }
541
+ };
542
+ await walk(repoRoot);
543
+ return results;
544
+ }
545
+ // ── Main export ───────────────────────────────────────────────────────────────
546
+ async function selectStrategicFiles(enriched, repoRoot) {
547
+ const results = [];
548
+ const seenPaths = new Set();
549
+ // ── Phase 0: Workspace-aware package representation (monorepos) ──────────
550
+ const workspacePackages = await detectWorkspacePackages(repoRoot);
551
+ const isMonorepo = workspacePackages.length >= 3;
552
+ if (isMonorepo) {
553
+ // Score each package: packages with "api", "auth", "store", "router" in name
554
+ // get priority; the rest are sorted by name for stability.
555
+ // Prefer packages whose names signal runtime importance over test/devtools/tooling.
556
+ // Among equals, shorter names float up first (react < react-dom < react-devtools-extensions).
557
+ const LOW_VALUE = /\b(test|tests|spec|mock|devtools|storybook|eslint|jest|fixture|bench|example|demo|playground|docs|internal)\b/i;
558
+ const sorted = [...workspacePackages].sort((a, b) => {
559
+ const aLow = LOW_VALUE.test(a.name) ? 1 : 0;
560
+ const bLow = LOW_VALUE.test(b.name) ? 1 : 0;
561
+ if (aLow !== bLow)
562
+ return aLow - bLow;
563
+ // shorter names are more fundamental (react < react-reconciler < react-devtools-shared)
564
+ return a.name.length - b.name.length || a.name.localeCompare(b.name);
565
+ });
566
+ const pkgSlots = Math.min(sorted.length, MAX_WORKSPACE_PACKAGE_SLOTS);
567
+ await Promise.all(sorted.slice(0, pkgSlots).map(async ({ dir, name }) => {
568
+ const filePath = await findPackageEntryFile(dir);
569
+ if (!filePath)
570
+ return;
571
+ const relPath = path_1.default.relative(repoRoot, filePath);
572
+ if (seenPaths.has(relPath))
573
+ return;
574
+ const content = await readTruncated(filePath);
575
+ if (!content)
576
+ return;
577
+ seenPaths.add(relPath);
578
+ results.push({ path: filePath, relPath, reason: `workspace package: ${name}`, content });
579
+ }));
580
+ }
581
+ // ── Phase 1: Targeted reads (API routes, lib, data clients) ──────────────
582
+ const targeted = await findTargetedFiles(repoRoot);
583
+ for (const { filePath, relPath, reason } of targeted) {
584
+ if (results.length >= MAX_FILES)
585
+ break;
586
+ if (seenPaths.has(relPath))
587
+ continue;
588
+ const content = await readTruncated(filePath);
589
+ if (!content)
590
+ continue;
591
+ seenPaths.add(relPath);
592
+ results.push({ path: filePath, relPath, reason, content });
593
+ }
594
+ // ── Phase 2: Graph-signal reads (fill remaining slots) ────────────────────
595
+ const remaining = MAX_FILES - results.length;
596
+ if (remaining <= 0)
597
+ return results;
598
+ const nodes = enriched.nodes.filter((n) => n.kind === "cluster" || n.kind === "package");
599
+ const TEST_SEGS = new Set(["__tests__", "__test__", "__mocks__", "__mock__", "test", "tests", "spec", "specs", "fixtures", "mocks"]);
600
+ const isTestNode = (n) => n.id.split("/").some((seg) => TEST_SEGS.has(seg.toLowerCase()));
601
+ const ENTRY_NAMES = new Set(["index", "main", "app", "server", "cli", "entry", "bootstrap", "start"]);
602
+ const isRealEntryPoint = (n) => n.isEntryPoint && !isTestNode(n) &&
603
+ ENTRY_NAMES.has(n.name.toLowerCase().replace(/\.(ts|tsx|js|jsx)$/, ""));
604
+ const graphSelected = new Map();
605
+ let entryCount = 0;
606
+ for (const n of nodes) {
607
+ if (entryCount >= 3)
608
+ break;
609
+ if (isRealEntryPoint(n)) {
610
+ graphSelected.set(n.id, { node: n, reason: "entry point", priority: 1 });
611
+ entryCount++;
612
+ }
613
+ }
614
+ let routeCount = 0;
615
+ for (const n of nodes) {
616
+ if (routeCount >= 3)
617
+ break;
618
+ if (n.routes.length > 0 && !graphSelected.has(n.id)) {
619
+ graphSelected.set(n.id, { node: n, reason: `owns routes: ${n.routes.slice(0, 3).join(", ")}`, priority: 2 });
620
+ routeCount++;
621
+ }
622
+ }
623
+ let ormCount = 0;
624
+ for (const n of nodes) {
625
+ if (ormCount >= 2)
626
+ break;
627
+ if (n.ormUses.length > 0 && !graphSelected.has(n.id)) {
628
+ graphSelected.set(n.id, { node: n, reason: `uses ORM: ${n.ormUses.slice(0, 2).join(", ")}`, priority: 3 });
629
+ ormCount++;
630
+ }
631
+ }
632
+ const byInDegree = [...nodes]
633
+ .filter((n) => !graphSelected.has(n.id) && !isTestNode(n))
634
+ .sort((a, b) => b.inDegree - a.inDegree)
635
+ .slice(0, 4);
636
+ for (const n of byInDegree) {
637
+ graphSelected.set(n.id, { node: n, reason: `high inDegree (${n.inDegree})`, priority: 4 });
638
+ }
639
+ const sorted = [...graphSelected.values()]
640
+ .sort((a, b) => a.priority - b.priority)
641
+ .slice(0, remaining);
642
+ await Promise.all(sorted.map(async ({ node, reason }) => {
643
+ const filePath = await findRepresentativeFile(node.id, repoRoot);
644
+ if (!filePath)
645
+ return;
646
+ const relPath = path_1.default.relative(repoRoot, filePath);
647
+ if (seenPaths.has(relPath))
648
+ return;
649
+ const content = await readTruncated(filePath);
650
+ if (!content)
651
+ return;
652
+ seenPaths.add(relPath);
653
+ results.push({ path: filePath, relPath, reason, content });
654
+ }));
655
+ // ── Phase 3: Must-include infra (data-client + external service files) ────
656
+ // These bypass MAX_FILES — up to MUST_INCLUDE_BONUS extra slots.
657
+ const mustInclude = await findMustIncludeFiles(repoRoot);
658
+ const bonusCap = MAX_FILES + MUST_INCLUDE_BONUS;
659
+ for (const { filePath, relPath, reason } of mustInclude) {
660
+ if (results.length >= bonusCap)
661
+ break;
662
+ if (seenPaths.has(relPath))
663
+ continue;
664
+ const content = await readTruncated(filePath);
665
+ if (!content)
666
+ continue;
667
+ seenPaths.add(relPath);
668
+ results.push({ path: filePath, relPath, reason, content });
669
+ }
670
+ return results;
671
+ }
672
+ //# sourceMappingURL=selectStrategicFiles.js.map