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,873 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.analyzeRepo = analyzeRepo;
37
+ const path = __importStar(require("path"));
38
+ const scanRepo_1 = require("../scanner/scanRepo");
39
+ const buildCodebaseGraph_1 = require("../graph/buildCodebaseGraph");
40
+ const SystemSynthesis_1 = require("../SystemSynthesis");
41
+ const detectRepoSignals_1 = require("../RepoTypeDetection/detectRepoSignals");
42
+ const detectSystemCandidates_1 = require("../detectors/detectSystemCandidates");
43
+ const classifySystemType_1 = require("../detectors/classifySystemType");
44
+ const applyRunnableConfidenceGate_1 = require("../detectors/applyRunnableConfidenceGate");
45
+ const detectEntryPoints_1 = require("../detectors/detectEntryPoints");
46
+ const detectBlocks_1 = require("../detectors/detectBlocks");
47
+ const detectAppArchetype_1 = require("../RepoTypeDetection/detectAppArchetype");
48
+ const detectPackageArchetype_1 = require("../RepoTypeDetection/detectPackageArchetype");
49
+ const detectRepoMode_1 = require("../RepoTypeDetection/detectRepoMode");
50
+ const applyRepoModeConsistency_1 = require("../RepoTypeDetection/applyRepoModeConsistency");
51
+ const detectRepoCenterSystems_1 = require("../RepoTypeDetection/detectRepoCenterSystems");
52
+ const inferSupportRole_1 = require("../RepoTypeDetection/inferSupportRole");
53
+ const detectSubsystems_1 = require("../detectors/detectSubsystems");
54
+ const deriveRecommendedStartPath_1 = require("./deriveRecommendedStartPath");
55
+ const deriveRuntimeRole_1 = require("./deriveRuntimeRole");
56
+ const systemRanking_1 = require("./systemRanking");
57
+ const buildSystemConnections_1 = require("./buildSystemConnections");
58
+ const text_1 = require("../utils/text");
59
+ const path_1 = require("../utils/path");
60
+ const file_1 = require("../utils/file");
61
+ const IntentionalStructure_1 = require("../IntentionalStructure");
62
+ const RuntimeInference_1 = require("../RuntimeInference");
63
+ const SystemSynthesis_2 = require("../SystemSynthesis");
64
+ const detectAppInternalUnits_1 = require("../detectors/detectAppInternalUnits");
65
+ const detectRoutes_1 = require("../scanner/detectRoutes");
66
+ const detectDBOps_1 = require("../scanner/detectDBOps");
67
+ const detectRepoPurpose_1 = require("../scanner/detectRepoPurpose");
68
+ const loader_1 = require("../heuristics/loader");
69
+ const detectRunCommands_1 = require("./detectRunCommands");
70
+ // ── Per-system tech detection ─────────────────────────────────────────
71
+ // Framework labels are now sourced from src/heuristics/known-packages.json.
72
+ // To add a new framework or fix a label, edit that file — not this one.
73
+ function detectTechFromPkg(pkg, rootPath, flat) {
74
+ const tech = [];
75
+ const seen = new Set();
76
+ // Language detection from file extensions within this system
77
+ const norm = path.normalize(rootPath);
78
+ const sysFiles = flat.filter((e) => !e.isDirectory && path.normalize(e.fullPath).startsWith(norm + path.sep));
79
+ let tsCount = 0, jsCount = 0, pyCount = 0, goCount = 0, rsCount = 0;
80
+ for (const f of sysFiles.slice(0, 200)) {
81
+ const ext = f.extension;
82
+ if (ext === "ts" || ext === "tsx")
83
+ tsCount++;
84
+ else if (ext === "js" || ext === "jsx")
85
+ jsCount++;
86
+ else if (ext === "py")
87
+ pyCount++;
88
+ else if (ext === "go")
89
+ goCount++;
90
+ else if (ext === "rs")
91
+ rsCount++;
92
+ }
93
+ if (tsCount > jsCount && tsCount > 0) {
94
+ tech.push("TypeScript");
95
+ seen.add("TypeScript");
96
+ }
97
+ else if (jsCount > 0) {
98
+ tech.push("JavaScript");
99
+ seen.add("JavaScript");
100
+ }
101
+ if (pyCount > 3) {
102
+ tech.push("Python");
103
+ seen.add("Python");
104
+ }
105
+ if (goCount > 3) {
106
+ tech.push("Go");
107
+ seen.add("Go");
108
+ }
109
+ if (rsCount > 3) {
110
+ tech.push("Rust");
111
+ seen.add("Rust");
112
+ }
113
+ if (!pkg)
114
+ return tech;
115
+ const runtimeDeps = Object.keys(pkg.dependencies || {});
116
+ const devDeps = Object.keys(pkg.devDependencies || {});
117
+ const peerDeps = Object.keys(pkg.peerDependencies || {});
118
+ // resolveFrameworkLabels reads known-packages.json — covers 100+ JS/TS frameworks.
119
+ // Deduplicates by framework name, respects depKind rules (runtime vs dev).
120
+ const frameworkLabels = (0, loader_1.resolveFrameworkLabels)(runtimeDeps, devDeps, peerDeps);
121
+ for (const label of frameworkLabels) {
122
+ if (!seen.has(label)) {
123
+ tech.push(label);
124
+ seen.add(label);
125
+ }
126
+ }
127
+ return tech.slice(0, 6);
128
+ }
129
+ function countFilesAndDirs(flat) {
130
+ let files = 0;
131
+ let dirs = 0;
132
+ for (const e of flat) {
133
+ if (e.isDirectory)
134
+ dirs += 1;
135
+ else
136
+ files += 1;
137
+ }
138
+ return { files, dirs };
139
+ }
140
+ function rankingContext(c) {
141
+ const rr = c.relativeRoot === "." ? "" : c.relativeRoot;
142
+ const parts = rr.split("/").filter(Boolean);
143
+ return {
144
+ candidateName: c.name,
145
+ underApps: parts[0] === "apps",
146
+ underPackages: parts[0] === "packages",
147
+ };
148
+ }
149
+ /**
150
+ * Full pipeline: scan → classify → entry points → runnable gate → blocks → tier/score/start → runtime role → flows → tier-group sort → summary.
151
+ */
152
+ async function analyzeRepo(repoPath) {
153
+ const rootPath = (0, path_1.normalizeRepoRoot)(repoPath);
154
+ const repoName = path.basename(rootPath);
155
+ const scan = await (0, scanRepo_1.scanRepo)(rootPath);
156
+ const flat = (0, scanRepo_1.flattenScanTree)(scan.root);
157
+ const { files: totalFiles, dirs: totalDirectories } = countFilesAndDirs(flat);
158
+ const signals = await (0, detectRepoSignals_1.detectRepoSignals)(rootPath);
159
+ const candidates = await (0, detectSystemCandidates_1.detectSystemCandidates)(rootPath, scan.root, signals);
160
+ const systems = [];
161
+ for (let i = 0; i < candidates.length; i++) {
162
+ const c = candidates[i];
163
+ const sysId = `sys-${(0, text_1.slugify)(c.name)}-${i}`;
164
+ const rctx = rankingContext(c);
165
+ // Non-package systems (compiler/, scripts/, examples/, etc.)
166
+ if (c.isNonPackage) {
167
+ systems.push({
168
+ id: sysId,
169
+ name: c.name,
170
+ type: "support-system",
171
+ systemTier: "support",
172
+ runtimeRole: "consumable",
173
+ importanceScore: 0.3,
174
+ rootPath: c.relativeRoot,
175
+ confidence: 0.7,
176
+ description: c.reason,
177
+ entryPoints: [],
178
+ blocks: [],
179
+ flows: [],
180
+ tags: [],
181
+ });
182
+ continue;
183
+ }
184
+ const classifyCtx = {
185
+ candidateFolderName: c.name,
186
+ relativeRoot: c.relativeRoot,
187
+ };
188
+ let classification = await (0, classifySystemType_1.classifySystemType)(c.rootPath, rootPath, flat, classifyCtx);
189
+ const relRoot = c.relativeRoot;
190
+ const rootPathOut = relRoot === "." ? "." : relRoot;
191
+ let entryPoints = await (0, detectEntryPoints_1.detectEntryPoints)(c.rootPath, relRoot, flat, classification.type);
192
+ const gated = (0, applyRunnableConfidenceGate_1.applyRunnableConfidenceGate)(classification, c.rootPath, flat, classifyCtx, entryPoints);
193
+ if (gated.type !== classification.type) {
194
+ entryPoints = await (0, detectEntryPoints_1.detectEntryPoints)(c.rootPath, relRoot, flat, gated.type);
195
+ }
196
+ classification = gated;
197
+ const blocks = (0, detectBlocks_1.detectBlocks)(c.rootPath, relRoot, flat, sysId);
198
+ const baseDescription = `${classification.description} Candidate: ${c.reason}`;
199
+ // Read package.json description + deps for enrichment
200
+ const pkgJsonRaw = await (0, file_1.readTextSafe)(path.join(c.rootPath, "package.json"));
201
+ const pkgJson = pkgJsonRaw ? (0, text_1.parseJsonLoose)(pkgJsonRaw) : null;
202
+ const pkgDesc = pkgJson && typeof pkgJson.description === "string" && pkgJson.description.length > 5
203
+ ? pkgJson.description
204
+ : undefined;
205
+ const detectedTech = detectTechFromPkg(pkgJson, c.rootPath, flat);
206
+ // Tags are derived from the system's own detectedTech, not from repo-root signals.
207
+ // signals.frameworks are repo-wide (e.g., React detected somewhere in the monorepo)
208
+ // and would stamp the same tags on every system — Prisma packages getting React tags, etc.
209
+ const tagsOut = [...new Set(detectedTech)].slice(0, 8);
210
+ const draft = {
211
+ id: sysId,
212
+ name: c.name,
213
+ type: classification.type,
214
+ systemTier: "secondary",
215
+ runtimeRole: "consumable",
216
+ importanceScore: 0,
217
+ packageDescription: pkgDesc,
218
+ detectedTech: detectedTech.length > 0 ? detectedTech : undefined,
219
+ rootPath: rootPathOut,
220
+ confidence: classification.confidence,
221
+ description: baseDescription,
222
+ entryPoints,
223
+ blocks,
224
+ flows: [],
225
+ tags: tagsOut,
226
+ };
227
+ draft.systemTier = (0, systemRanking_1.assignSystemTier)(draft, rctx);
228
+ draft.importanceScore = (0, systemRanking_1.computeImportanceScore)(draft, rctx);
229
+ const startResult = (0, deriveRecommendedStartPath_1.deriveRecommendedStartPath)(draft);
230
+ draft.recommendedStartPath = startResult.path;
231
+ draft.startPathReason = startResult.reason;
232
+ draft.startPathConfidence = startResult.confidence;
233
+ draft.runtimeRole = (0, deriveRuntimeRole_1.deriveRuntimeRole)(draft, rctx);
234
+ draft.appArchetype = (0, detectAppArchetype_1.detectAppArchetype)(draft, { candidateName: c.name, relativeRoot: relRoot }, flat, c.rootPath);
235
+ draft.subsystems = (0, detectSubsystems_1.detectSubsystems)(draft, c.rootPath, relRoot, flat);
236
+ draft.packageArchetype = (0, detectPackageArchetype_1.detectPackageArchetype)(draft, rctx);
237
+ systems.push(draft);
238
+ }
239
+ // Read README excerpt for each system (used to enrich descriptions)
240
+ for (const s of systems) {
241
+ if (s.type === "support-system")
242
+ continue;
243
+ const sysAbs = s.rootPath === "." ? rootPath : path.resolve(rootPath, s.rootPath);
244
+ const readmeNames = ["README.md", "readme.md", "Readme.md", "README.MD"];
245
+ for (const name of readmeNames) {
246
+ const raw = await (0, file_1.readTextSafe)(path.join(sysAbs, name), 4000);
247
+ if (!raw)
248
+ continue;
249
+ const excerpt = extractReadmeExcerpt(raw);
250
+ if (excerpt) {
251
+ s.readmeExcerpt = excerpt;
252
+ }
253
+ break;
254
+ }
255
+ }
256
+ // Deduplicate: if two systems share the same name, keep the one with higher confidence
257
+ // (this can happen when a package appears in multiple locations, e.g. nested examples/)
258
+ const seenNames = new Map();
259
+ for (const s of systems) {
260
+ const key = s.name.toLowerCase();
261
+ const prev = seenNames.get(key);
262
+ if (!prev) {
263
+ seenNames.set(key, s);
264
+ }
265
+ else {
266
+ // Keep the one with higher confidence, or more blocks, or shorter rootPath (closer to root)
267
+ const prevDepth = prev.rootPath.split("/").length;
268
+ const curDepth = s.rootPath.split("/").length;
269
+ const betterConfidence = s.confidence > prev.confidence;
270
+ const moreBlocks = s.blocks.length > prev.blocks.length && s.confidence >= prev.confidence - 0.1;
271
+ const shallower = curDepth < prevDepth;
272
+ if (betterConfidence || moreBlocks || shallower) {
273
+ seenNames.set(key, s);
274
+ }
275
+ }
276
+ }
277
+ const dedupedSystems = [...seenNames.values()];
278
+ const sortedSystems = (0, systemRanking_1.sortSystemsGroupedByTier)(dedupedSystems);
279
+ const detectedRepoStyle = signals.isMonorepoLayout ? "monorepo"
280
+ : sortedSystems.length > 3 ? "multi-system"
281
+ : sortedSystems.length > 0 ? "single-app"
282
+ : "unknown";
283
+ const summary = {
284
+ totalFiles,
285
+ totalDirectories,
286
+ detectedFrameworks: signals.frameworks,
287
+ detectedRepoStyle,
288
+ totalSystems: sortedSystems.length,
289
+ };
290
+ const { mode: repoMode } = (0, detectRepoMode_1.detectRepoMode)(signals, repoName); // structure/type/techStack flow to RepoAnalysis via signals
291
+ // Phase 1: normalise types that contradict repo mode
292
+ (0, applyRepoModeConsistency_1.applyRepoModeConsistency)(sortedSystems, repoMode);
293
+ // Phase 2: promote core systems and assign role hints
294
+ promoteForRepoMode(sortedSystems, repoMode, repoName);
295
+ (0, detectRepoCenterSystems_1.detectRepoCenterSystems)(sortedSystems, repoMode, repoName);
296
+ // Ensure at least one primary: if nothing was promoted (e.g., single infra/docs repo),
297
+ // promote the highest-scoring non-support system so the repo is never all-secondary.
298
+ const primaryCount = sortedSystems.filter((s) => s.systemTier === "primary").length;
299
+ if (primaryCount === 0) {
300
+ const candidate = sortedSystems.find((s) => s.type !== "support-system");
301
+ if (candidate) {
302
+ candidate.systemTier = "primary";
303
+ candidate.importanceScore = Math.max(candidate.importanceScore, 0.7);
304
+ }
305
+ }
306
+ // Phase 3: infer support roles for non-center systems
307
+ for (const s of sortedSystems) {
308
+ s.inferredSupportRole = (0, inferSupportRole_1.inferSupportRole)(s, repoMode);
309
+ }
310
+ // Phase 4: re-detect archetypes for systems whose role was updated
311
+ for (const s of sortedSystems) {
312
+ if (s.systemRoleHint || s.isRepoCenter || s.inferredSupportRole) {
313
+ s.packageArchetype = (0, detectPackageArchetype_1.detectPackageArchetype)(s, { candidateName: s.name });
314
+ }
315
+ }
316
+ // Phase 5: build system-level connections
317
+ await (0, buildSystemConnections_1.buildSystemConnections)(sortedSystems, rootPath, flat, repoMode);
318
+ // Phase 5b: connection-aware hub promotion
319
+ promoteConnectionHub(sortedSystems, repoName);
320
+ // Phase 6: route + DB detection for API-surface and runnable systems
321
+ // Only run on systems that could plausibly have routes or DB calls.
322
+ // These are best-effort and never block analysis on failure.
323
+ for (const s of sortedSystems) {
324
+ if (s.type === "support-system")
325
+ continue;
326
+ const sysAbs = s.rootPath === "." ? rootPath : path.resolve(rootPath, s.rootPath);
327
+ const looksLikeRoute = s.type === "api-service" || s.type === "web-app" || s.type === "worker";
328
+ if (looksLikeRoute) {
329
+ try {
330
+ s.detectedRoutes = await (0, detectRoutes_1.detectRoutes)(sysAbs);
331
+ }
332
+ catch { /* best-effort */ }
333
+ }
334
+ try {
335
+ s.detectedDBOps = await (0, detectDBOps_1.detectDBOperations)(sysAbs);
336
+ }
337
+ catch { /* best-effort */ }
338
+ }
339
+ // Phase 7: for product-web-app repos, decompose internal architecture
340
+ if (repoMode === "product-web-app" && sortedSystems.length <= 3) {
341
+ const mainSystem = sortedSystems.find((s) => s.type !== "support-system") ?? sortedSystems[0];
342
+ if (mainSystem) {
343
+ const appUnits = (0, detectAppInternalUnits_1.detectAppInternalUnits)(mainSystem, rootPath, flat);
344
+ if (appUnits.length >= 2) {
345
+ sortedSystems.push(...appUnits);
346
+ }
347
+ }
348
+ }
349
+ const finalSystems = (0, systemRanking_1.sortSystemsGroupedByTier)(sortedSystems);
350
+ const repoCenter = (0, detectRepoMode_1.deriveRepoCenter)(repoMode);
351
+ const repoNarrative = (0, detectRepoMode_1.buildRepoNarrative)({ repoName, systems: finalSystems, summary }, repoMode);
352
+ // Phase 8: deterministic repo purpose detection
353
+ // Runs at repo root — uses file density, config files, package.json signals only.
354
+ let inferredRepoPurpose;
355
+ try {
356
+ const purpose = await (0, detectRepoPurpose_1.detectRepoPurpose)(rootPath);
357
+ if (purpose.kind !== "unknown")
358
+ inferredRepoPurpose = purpose;
359
+ }
360
+ catch { /* best-effort */ }
361
+ // Phase 9: run command extraction — zero LLM, pure file reading
362
+ let runCommands;
363
+ try {
364
+ const cmds = await (0, detectRunCommands_1.detectRunCommands)(rootPath);
365
+ if (cmds.length > 0)
366
+ runCommands = cmds;
367
+ }
368
+ catch { /* best-effort */ }
369
+ // ── Layer 1: Intentional Structure ────────────────────────────────────
370
+ // Run before the graph phase so Layer 1 package boundaries inform cluster building.
371
+ const intentional = await (0, IntentionalStructure_1.detectIntentionalStructure)(rootPath);
372
+ // Phase 10: always build the import graph (no API key needed) for blast radius data.
373
+ // LLM system naming only runs when an API key is available.
374
+ // Without an API key, systems fall back to the filesystem-scan path (finalSystems).
375
+ let graphSystems = [];
376
+ let graphResult;
377
+ let synthesisResultOut;
378
+ try {
379
+ const r = await runGraphPhase(rootPath, signals.frameworks, signals, intentional);
380
+ // Always use graph systems — even without LLM, cluster-based detection (real import
381
+ // edges, centrality ranking) is more accurate than filesystem-scan package detection
382
+ // for understanding code architecture.
383
+ graphSystems = r.systems;
384
+ graphResult = r.graph;
385
+ synthesisResultOut = r.synthesisResult;
386
+ }
387
+ catch {
388
+ // best-effort, never block analysis
389
+ }
390
+ const allSystems = graphSystems.length > 0
391
+ ? (0, systemRanking_1.sortSystemsGroupedByTier)([...graphSystems])
392
+ : finalSystems;
393
+ // Wire Layer 1 edges into system connections
394
+ await applyIntentionalStructure(allSystems, intentional, rootPath);
395
+ const analysis = {
396
+ repoName,
397
+ rootPath,
398
+ repoMode,
399
+ repoCenter,
400
+ repoNarrative,
401
+ systems: allSystems,
402
+ ignoredPaths: scan.ignoredPaths,
403
+ summary: { ...summary, totalSystems: allSystems.length },
404
+ inferredRepoPurpose,
405
+ runCommands,
406
+ };
407
+ return {
408
+ analysis,
409
+ deprioritizedPaths: scan.deprioritizedPaths,
410
+ scanMeta: scan.meta,
411
+ flat,
412
+ graph: graphResult,
413
+ synthesisResult: synthesisResultOut,
414
+ };
415
+ }
416
+ // ── Layer 1: Intentional Structure wiring ────────────────────────────────
417
+ async function applyIntentionalStructure(systems, intentional, repoRoot) {
418
+ if (intentional.systems.length === 0 && intentional.edges.length === 0)
419
+ return;
420
+ // Map Layer 1 system name → AM system, matched by abs path overlap or name
421
+ const nameToSystem = new Map();
422
+ for (const iSys of intentional.systems) {
423
+ if (!iSys.path)
424
+ continue;
425
+ // Path match: find the AM system whose rootPath is the closest ancestor
426
+ let best = null;
427
+ let bestDepth = -1;
428
+ for (const sys of systems) {
429
+ const sysAbs = sys.rootPath === "." ? repoRoot : path.resolve(repoRoot, sys.rootPath);
430
+ if (iSys.path.startsWith(sysAbs)) {
431
+ const depth = sysAbs.split(path.sep).length;
432
+ if (depth > bestDepth) {
433
+ best = sys;
434
+ bestDepth = depth;
435
+ }
436
+ }
437
+ }
438
+ if (best) {
439
+ nameToSystem.set(iSys.name, best);
440
+ continue;
441
+ }
442
+ // Name match fallback
443
+ const byName = systems.find((s) => s.name.toLowerCase() === iSys.name.toLowerCase());
444
+ if (byName)
445
+ nameToSystem.set(iSys.name, byName);
446
+ }
447
+ // Wire edges from Layer 1
448
+ for (const edge of intentional.edges) {
449
+ const fromSys = nameToSystem.get(edge.from);
450
+ const toSys = nameToSystem.get(edge.to);
451
+ // Resolve or create the target system
452
+ let toId;
453
+ let toName;
454
+ if (toSys) {
455
+ toId = toSys.id;
456
+ toName = toSys.name;
457
+ }
458
+ else {
459
+ // Create a synthetic infra system for unmatched targets (postgres, redis, etc.)
460
+ const syntheticId = `intentional-${edge.to}`;
461
+ const existing = systems.find((s) => s.id === syntheticId);
462
+ if (existing) {
463
+ toId = existing.id;
464
+ toName = existing.name;
465
+ }
466
+ else {
467
+ const iSysDef = intentional.systems.find((s) => s.name === edge.to);
468
+ const inferredName = capitalize(edge.to);
469
+ const infraSys = {
470
+ id: syntheticId,
471
+ name: inferredName,
472
+ systemTier: "support",
473
+ type: "infra",
474
+ runtimeRole: "support",
475
+ importanceScore: 0.1,
476
+ confidence: 1.0,
477
+ description: iSysDef
478
+ ? `${inferredName} — declared in ${iSysDef.source}`
479
+ : `${inferredName} — declared in intentional structure`,
480
+ rootPath: edge.to,
481
+ connections: { outgoing: [], incoming: [] },
482
+ blocks: [],
483
+ entryPoints: [],
484
+ flows: [],
485
+ tags: ["intentional"],
486
+ };
487
+ systems.push(infraSys);
488
+ nameToSystem.set(edge.to, infraSys);
489
+ toId = infraSys.id;
490
+ toName = infraSys.name;
491
+ }
492
+ }
493
+ if (!fromSys)
494
+ continue;
495
+ if (!fromSys.connections)
496
+ fromSys.connections = { outgoing: [], incoming: [] };
497
+ const alreadyOut = fromSys.connections.outgoing.some((c) => c.targetSystemId === toId);
498
+ if (!alreadyOut) {
499
+ fromSys.connections.outgoing.push({
500
+ targetSystemId: toId,
501
+ targetSystemName: toName,
502
+ relation: "uses",
503
+ confidence: 1.0,
504
+ reason: edge.evidence,
505
+ });
506
+ }
507
+ const targetSys = toSys ?? systems.find((s) => s.id === toId);
508
+ if (targetSys) {
509
+ if (!targetSys.connections)
510
+ targetSys.connections = { outgoing: [], incoming: [] };
511
+ const alreadyIn = targetSys.connections.incoming.some((c) => c.targetSystemId === fromSys.id);
512
+ if (!alreadyIn) {
513
+ targetSys.connections.incoming.push({
514
+ targetSystemId: fromSys.id,
515
+ targetSystemName: fromSys.name,
516
+ relation: "used-by",
517
+ confidence: 1.0,
518
+ reason: edge.evidence,
519
+ });
520
+ }
521
+ }
522
+ }
523
+ }
524
+ function capitalize(s) {
525
+ return s.charAt(0).toUpperCase() + s.slice(1);
526
+ }
527
+ // ── Graph-based system detection (Phase 10) ───────────────────────────────
528
+ const LLM_TYPE_MAP = {
529
+ "web-app": "web-app",
530
+ "api-service": "api-service",
531
+ "ui-library": "ui-library",
532
+ "docs-site": "docs-site",
533
+ "shared-library": "shared-package",
534
+ "shared-package": "shared-package",
535
+ "data-layer": "shared-package",
536
+ "infra": "infra",
537
+ "worker": "worker",
538
+ "cli": "worker",
539
+ "config": "support-system",
540
+ "core-engine": "unknown",
541
+ };
542
+ function synthesisToMemorSystems(result, graph) {
543
+ // Build id lookup so ConnectionRef.target (name) can resolve to id
544
+ const nameToId = new Map();
545
+ for (const s of result.systems)
546
+ nameToId.set(s.name, s.id);
547
+ return result.systems.map((s) => {
548
+ const sysType = LLM_TYPE_MAP[s.type] ?? "unknown";
549
+ const outgoing = s.connects_to.map((ref) => ({
550
+ targetSystemId: nameToId.get(ref.target) ?? `synth-ref-${ref.target}`,
551
+ targetSystemName: ref.target,
552
+ relation: "uses",
553
+ confidence: ref.confidence,
554
+ reason: ref.source,
555
+ }));
556
+ const incoming = s.called_by.map((ref) => ({
557
+ targetSystemId: nameToId.get(ref.target) ?? `synth-ref-${ref.target}`,
558
+ targetSystemName: ref.target,
559
+ relation: "used-by",
560
+ confidence: ref.confidence,
561
+ reason: ref.source,
562
+ }));
563
+ let files = graph.clusterFiles[s.cluster_id] ?? [];
564
+ // If the cluster has no direct files (e.g. app/api/admin/blocks whose files live
565
+ // in app/api/admin/blocks/create/, .../delete/, etc.), gather from child clusters.
566
+ if (files.length === 0) {
567
+ const prefix = s.cluster_id + "/";
568
+ for (const [cid, cfiles] of Object.entries(graph.clusterFiles)) {
569
+ if (cid.startsWith(prefix))
570
+ files = files.concat(cfiles);
571
+ }
572
+ }
573
+ // Detect duplicate basenames — use parent/filename when ambiguous
574
+ const basenames = files.map((fp) => fp.split("/").pop() ?? fp);
575
+ const baseCount = new Map();
576
+ for (const b of basenames)
577
+ baseCount.set(b, (baseCount.get(b) ?? 0) + 1);
578
+ const blocks = files.map((filePath, i) => {
579
+ const base = basenames[i];
580
+ const parts = filePath.split("/");
581
+ const name = (baseCount.get(base) ?? 0) > 1 && parts.length >= 2
582
+ ? `${parts[parts.length - 2]}/${base}`
583
+ : base;
584
+ return {
585
+ id: `${s.id}-file-${i}`,
586
+ name,
587
+ type: "source-tree",
588
+ path: filePath,
589
+ };
590
+ });
591
+ const mem = {
592
+ id: s.id,
593
+ name: s.name,
594
+ type: sysType,
595
+ systemTier: s.tier,
596
+ runtimeRole: s.tier === "support" ? "support" : "consumable",
597
+ importanceScore: s.tier === "primary" ? 0.9 : s.tier === "secondary" ? 0.6 : 0.3,
598
+ rootPath: s.cluster_id,
599
+ confidence: 0.8,
600
+ description: s.description,
601
+ connections: { outgoing, incoming },
602
+ entryPoints: [],
603
+ blocks,
604
+ flows: [],
605
+ tags: [],
606
+ };
607
+ // owns_routes are path strings from L4; detectedRoutes is populated separately by detectRoutes()
608
+ if (s.package_id)
609
+ mem.packageDescription = s.package_id;
610
+ // Wire Phase 3 archetype label so Layer 5 UI can show it without re-classifying
611
+ if (s.archetype)
612
+ mem.graphArchetype = s.archetype;
613
+ return mem;
614
+ });
615
+ }
616
+ /**
617
+ * Run graph-based internal system detection for any repo.
618
+ * Builds an import/export graph across all source files, compresses it to
619
+ * ~3k tokens, and asks the LLM to name domain systems from real exported symbols.
620
+ * Falls back to raw cluster names if LLM is unavailable.
621
+ */
622
+ async function runGraphPhase(rootPath, frameworks, signals, intentional) {
623
+ const layer1Paths = (intentional?.systems ?? [])
624
+ .filter((s) => s.path !== null)
625
+ .map((s) => s.path);
626
+ const graph = await (0, buildCodebaseGraph_1.buildCodebaseGraph)(rootPath, frameworks, layer1Paths);
627
+ if (graph.clusters.length === 0)
628
+ return { systems: [], graph, synthesisResult: undefined };
629
+ const meaningfulClusters = graph.clusters.filter((c) => !c.signals.hasTests && c.fileCount >= 1);
630
+ if (meaningfulClusters.length <= 1)
631
+ return { systems: [], graph, synthesisResult: undefined };
632
+ // Read root README and derive repo type — needed before merging layers
633
+ const repoName = rootPath.split("/").pop() ?? "repo";
634
+ const readmeNames = ["README.md", "readme.md", "Readme.md", "README.MD"];
635
+ let readmeSummary;
636
+ for (const name of readmeNames) {
637
+ const raw = await (0, file_1.readTextSafe)(path.join(rootPath, name), 4000);
638
+ if (raw) {
639
+ readmeSummary = extractReadmeExcerpt(raw) ?? undefined;
640
+ break;
641
+ }
642
+ }
643
+ let repoStructure;
644
+ let repoType;
645
+ let techStack;
646
+ if (signals) {
647
+ const { detectRepoMode } = await Promise.resolve().then(() => __importStar(require("../RepoTypeDetection/detectRepoMode")));
648
+ const result = detectRepoMode(signals, repoName);
649
+ repoStructure = result.structure;
650
+ repoType = result.type;
651
+ techStack = result.techStack;
652
+ }
653
+ // Layer 3: Runtime Inference
654
+ let runtimeInference = { edges: [], sources: [] };
655
+ if (intentional) {
656
+ try {
657
+ runtimeInference = await (0, RuntimeInference_1.detectRuntimeInference)(rootPath, graph, intentional);
658
+ }
659
+ catch { /* best-effort */ }
660
+ }
661
+ // Merge L1 + L2 + L3 into a single EnrichedGraph
662
+ const enriched = (0, SystemSynthesis_2.mergeLayerOutputs)(intentional ?? { systems: [], edges: [], envWiring: [], sources: [] }, graph, runtimeInference, { repoName, readmeSummary, repoStructure, repoType, techStack });
663
+ // Layer 4: Synthesize — handles cache / LLM / deterministic fallback + stampDeterministic
664
+ const synthesisResult = await (0, SystemSynthesis_1.synthesize)(enriched);
665
+ const systems = synthesisToMemorSystems(synthesisResult, graph);
666
+ return { systems, graph, synthesisResult };
667
+ }
668
+ /**
669
+ * Extract a 1–2 sentence description from a README file.
670
+ * Skips headings, badges, install instructions, and code blocks.
671
+ */
672
+ function extractReadmeExcerpt(raw) {
673
+ const lines = raw.split("\n");
674
+ let inCodeBlock = false;
675
+ const candidates = [];
676
+ let h1Title = null;
677
+ for (const line of lines) {
678
+ const trimmed = line.trim();
679
+ if (trimmed.startsWith("```") || trimmed.startsWith("~~~")) {
680
+ inCodeBlock = !inCodeBlock;
681
+ continue;
682
+ }
683
+ if (inCodeBlock)
684
+ continue;
685
+ // Capture first H1 as fallback domain label
686
+ if (!h1Title && /^#\s+\S/.test(trimmed)) {
687
+ h1Title = trimmed.replace(/^#+\s*/, "").trim();
688
+ }
689
+ // Skip headings, badges, empty lines, HTML tags, install/usage sections
690
+ if (!trimmed)
691
+ continue;
692
+ if (trimmed.startsWith("#"))
693
+ continue;
694
+ if (trimmed.startsWith("![") || trimmed.startsWith("[!["))
695
+ continue;
696
+ if (trimmed.startsWith("<"))
697
+ continue;
698
+ if (trimmed.startsWith("|"))
699
+ continue; // tables
700
+ if (/^(npm install|yarn add|pnpm add|npx |bun add)/i.test(trimmed))
701
+ continue;
702
+ if (/^(install|usage|getting started|quick start|table of contents|license)/i.test(trimmed))
703
+ continue;
704
+ // Require at least 30 chars and a letter, skip lines that look like code
705
+ if (trimmed.length < 30)
706
+ continue;
707
+ if (/^[`$>]/.test(trimmed))
708
+ continue;
709
+ if (/^\s*(import|require|const |let |var |export )/i.test(trimmed))
710
+ continue;
711
+ candidates.push(trimmed);
712
+ if (candidates.length >= 3)
713
+ break;
714
+ }
715
+ // Fall back to the H1 title if no prose was found
716
+ if (candidates.length === 0)
717
+ return h1Title;
718
+ // Take first 1-2 candidates, join, and truncate to 200 chars
719
+ let result = candidates.slice(0, 2).join(" ").trim();
720
+ // Clean up markdown links [text](url) → text
721
+ result = result.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1");
722
+ // Clean up bold/italic
723
+ result = result.replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1");
724
+ // Truncate
725
+ if (result.length > 220) {
726
+ result = result.slice(0, 217) + "...";
727
+ }
728
+ return result.length >= 30 ? result : null;
729
+ }
730
+ /**
731
+ * After connections are built, promote the system with the most incoming
732
+ * connections to primary/center if it clearly dominates the graph.
733
+ * Uses a composite score: incoming weight + outgoing weight + extends-target bonus.
734
+ */
735
+ function promoteConnectionHub(systems, repoName) {
736
+ if (systems.length < 3)
737
+ return;
738
+ const hasCenter = systems.some((s) => s.isRepoCenter);
739
+ if (hasCenter)
740
+ return;
741
+ function hubScore(s) {
742
+ const inc = s.connections?.incoming ?? [];
743
+ const out = s.connections?.outgoing ?? [];
744
+ let score = inc.length * 2 + out.length;
745
+ // Systems that others extend are more architecturally central
746
+ const extendsCount = inc.filter((c) => c.relation === "used-by" &&
747
+ systems.find((x) => x.id === c.targetSystemId)?.connections?.outgoing
748
+ ?.some((o) => o.targetSystemId === s.id && o.relation === "extends")).length;
749
+ score += extendsCount * 3;
750
+ return score;
751
+ }
752
+ const scored = systems.map((s) => ({ sys: s, score: hubScore(s) }));
753
+ scored.sort((a, b) => b.score - a.score);
754
+ const best = scored[0];
755
+ const second = scored[1];
756
+ if (best.score >= 8 && best.score > second.score * 1.3) {
757
+ best.sys.isRepoCenter = true;
758
+ best.sys.systemTier = "primary";
759
+ best.sys.importanceScore = Math.max(best.sys.importanceScore, 0.9);
760
+ if (!best.sys.systemRoleHint || best.sys.systemRoleHint === "unknown") {
761
+ const rnFlat = repoName.toLowerCase().replace(/[^a-z0-9]/g, "");
762
+ const nFlat = best.sys.name.toLowerCase().replace(/[^a-z0-9]/g, "");
763
+ if (nFlat === rnFlat || nFlat.includes(rnFlat) || rnFlat.includes(nFlat)) {
764
+ best.sys.systemRoleHint = "framework-core-package";
765
+ }
766
+ }
767
+ }
768
+ }
769
+ /**
770
+ * After repo-level mode detection, selectively promote the most important
771
+ * packages to primary tier for framework-core and library-tooling repos.
772
+ * Also enriches descriptions for promoted packages. Mutates in place.
773
+ */
774
+ function promoteForRepoMode(systems, repoMode, repoName) {
775
+ const rnLower = repoName.toLowerCase().replace(/[^a-z0-9]/g, "");
776
+ const FRAMEWORK_CORE_NAMES = /^(core|common|runtime|scheduler|compiler|reconciler|server|dom)$/i;
777
+ if (repoMode === "framework-core") {
778
+ let promoted = false;
779
+ for (const s of systems) {
780
+ if (s.type === "support-system")
781
+ continue;
782
+ const n = s.name.toLowerCase();
783
+ const nFlat = n.replace(/[^a-z0-9]/g, "");
784
+ if (FRAMEWORK_CORE_NAMES.test(n) ||
785
+ nFlat === rnLower ||
786
+ nFlat === `${rnLower}dom` ||
787
+ nFlat === `${rnLower}server` ||
788
+ nFlat === `${rnLower}reconciler`) {
789
+ s.systemTier = "primary";
790
+ s.importanceScore = Math.max(s.importanceScore, 0.86);
791
+ promoted = true;
792
+ }
793
+ }
794
+ // Single-package framework: promote the one real package
795
+ if (!promoted) {
796
+ const realPkgs = systems.filter((s) => s.type !== "support-system");
797
+ if (realPkgs.length === 1) {
798
+ realPkgs[0].systemTier = "primary";
799
+ realPkgs[0].importanceScore = Math.max(realPkgs[0].importanceScore, 0.9);
800
+ realPkgs[0].isRepoCenter = true;
801
+ }
802
+ }
803
+ }
804
+ if (repoMode === "library-tooling") {
805
+ let best = null;
806
+ for (const s of systems) {
807
+ const nFlat = s.name.toLowerCase().replace(/[^a-z0-9]/g, "");
808
+ if (nFlat === rnLower || nFlat.includes(rnLower) || rnLower.includes(nFlat)) {
809
+ if (!best || s.blocks.length > best.blocks.length)
810
+ best = s;
811
+ }
812
+ }
813
+ if (!best && systems.length) {
814
+ best = systems.reduce((a, b) => b.blocks.length > a.blocks.length ? b : a);
815
+ }
816
+ if (best) {
817
+ best.systemTier = "primary";
818
+ best.importanceScore = Math.max(best.importanceScore, 0.9);
819
+ best.description = `This is the primary library package in this repository. It is consumed by applications and other packages rather than run directly.`;
820
+ }
821
+ }
822
+ if (repoMode === "product-web-app") {
823
+ // For single-app web repos, promote the main app as the center
824
+ const mainApp = systems.find((s) => s.type === "web-app");
825
+ if (mainApp) {
826
+ mainApp.systemTier = "primary";
827
+ mainApp.importanceScore = Math.max(mainApp.importanceScore, 0.9);
828
+ mainApp.isRepoCenter = true;
829
+ }
830
+ }
831
+ if (repoMode === "product-domain-machine") {
832
+ // Systems under packages/ can't get primary tier from assignSystemTier, but in a
833
+ // product-domain-machine monorepo they absolutely should be primary if they're runnable apps.
834
+ const primaries = systems.filter((s) => s.systemTier === "primary");
835
+ if (primaries.length === 0) {
836
+ const RUNNABLE_TYPES = new Set(["web-app", "api-service", "worker", "docs-site"]);
837
+ let promoted = false;
838
+ for (const s of systems) {
839
+ if (s.type === "support-system")
840
+ continue;
841
+ if (RUNNABLE_TYPES.has(s.type)) {
842
+ s.systemTier = "primary";
843
+ s.importanceScore = Math.max(s.importanceScore, 0.88);
844
+ promoted = true;
845
+ }
846
+ }
847
+ // If nothing runnable found, promote highest-importance systems
848
+ if (!promoted) {
849
+ const top = [...systems]
850
+ .filter((s) => s.type !== "support-system")
851
+ .sort((a, b) => b.importanceScore - a.importanceScore)
852
+ .slice(0, 2);
853
+ for (const s of top) {
854
+ s.systemTier = "primary";
855
+ s.importanceScore = Math.max(s.importanceScore, 0.85);
856
+ }
857
+ }
858
+ }
859
+ }
860
+ if (repoMode === "workflow-platform") {
861
+ for (const s of systems) {
862
+ const n = s.name.toLowerCase();
863
+ if (/-(core|server|scheduler|executor)$/.test(n) ||
864
+ n === "core" ||
865
+ n === rnLower) {
866
+ s.systemTier = "primary";
867
+ s.importanceScore = Math.max(s.importanceScore, 0.88);
868
+ s.description = `Core platform module \`${s.name}\` — a foundational component of this workflow or orchestration system.`;
869
+ }
870
+ }
871
+ }
872
+ }
873
+ //# sourceMappingURL=analyzeRepo.js.map