@yalehwang/archguard 0.1.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 (427) hide show
  1. package/README.md +537 -0
  2. package/dist/cli/cache/arch-json-disk-cache.d.ts +12 -0
  3. package/dist/cli/cache/arch-json-disk-cache.d.ts.map +1 -0
  4. package/dist/cli/cache/arch-json-disk-cache.js +51 -0
  5. package/dist/cli/cache/arch-json-disk-cache.js.map +1 -0
  6. package/dist/cli/cache-manager.d.ts +28 -0
  7. package/dist/cli/cache-manager.d.ts.map +1 -0
  8. package/dist/cli/cache-manager.js +126 -0
  9. package/dist/cli/cache-manager.js.map +1 -0
  10. package/dist/cli/commands/analyze.d.ts +7 -0
  11. package/dist/cli/commands/analyze.d.ts.map +1 -0
  12. package/dist/cli/commands/analyze.js +212 -0
  13. package/dist/cli/commands/analyze.js.map +1 -0
  14. package/dist/cli/commands/cache.d.ts +3 -0
  15. package/dist/cli/commands/cache.d.ts.map +1 -0
  16. package/dist/cli/commands/cache.js +56 -0
  17. package/dist/cli/commands/cache.js.map +1 -0
  18. package/dist/cli/commands/init.d.ts +3 -0
  19. package/dist/cli/commands/init.d.ts.map +1 -0
  20. package/dist/cli/commands/init.js +34 -0
  21. package/dist/cli/commands/init.js.map +1 -0
  22. package/dist/cli/config-loader.d.ts +701 -0
  23. package/dist/cli/config-loader.d.ts.map +1 -0
  24. package/dist/cli/config-loader.js +259 -0
  25. package/dist/cli/config-loader.js.map +1 -0
  26. package/dist/cli/error-handler.d.ts +15 -0
  27. package/dist/cli/error-handler.d.ts.map +1 -0
  28. package/dist/cli/error-handler.js +127 -0
  29. package/dist/cli/error-handler.js.map +1 -0
  30. package/dist/cli/errors.d.ts +15 -0
  31. package/dist/cli/errors.d.ts.map +1 -0
  32. package/dist/cli/errors.js +31 -0
  33. package/dist/cli/errors.js.map +1 -0
  34. package/dist/cli/index.d.ts +4 -0
  35. package/dist/cli/index.d.ts.map +1 -0
  36. package/dist/cli/index.js +27 -0
  37. package/dist/cli/index.js.map +1 -0
  38. package/dist/cli/processors/diagram-processor.d.ts +61 -0
  39. package/dist/cli/processors/diagram-processor.d.ts.map +1 -0
  40. package/dist/cli/processors/diagram-processor.js +610 -0
  41. package/dist/cli/processors/diagram-processor.js.map +1 -0
  42. package/dist/cli/progress/parallel-progress.d.ts +16 -0
  43. package/dist/cli/progress/parallel-progress.d.ts.map +1 -0
  44. package/dist/cli/progress/parallel-progress.js +49 -0
  45. package/dist/cli/progress/parallel-progress.js.map +1 -0
  46. package/dist/cli/progress.d.ts +36 -0
  47. package/dist/cli/progress.d.ts.map +1 -0
  48. package/dist/cli/progress.js +127 -0
  49. package/dist/cli/progress.js.map +1 -0
  50. package/dist/cli/types.d.ts +37 -0
  51. package/dist/cli/types.d.ts.map +1 -0
  52. package/dist/cli/types.js +2 -0
  53. package/dist/cli/types.js.map +1 -0
  54. package/dist/cli/utils/cpp-project-structure-detector.d.ts +10 -0
  55. package/dist/cli/utils/cpp-project-structure-detector.d.ts.map +1 -0
  56. package/dist/cli/utils/cpp-project-structure-detector.js +99 -0
  57. package/dist/cli/utils/cpp-project-structure-detector.js.map +1 -0
  58. package/dist/cli/utils/diagram-index-generator.d.ts +12 -0
  59. package/dist/cli/utils/diagram-index-generator.d.ts.map +1 -0
  60. package/dist/cli/utils/diagram-index-generator.js +94 -0
  61. package/dist/cli/utils/diagram-index-generator.js.map +1 -0
  62. package/dist/cli/utils/file-discovery-service.d.ts +10 -0
  63. package/dist/cli/utils/file-discovery-service.d.ts.map +1 -0
  64. package/dist/cli/utils/file-discovery-service.js +56 -0
  65. package/dist/cli/utils/file-discovery-service.js.map +1 -0
  66. package/dist/cli/utils/output-path-resolver.d.ts +34 -0
  67. package/dist/cli/utils/output-path-resolver.d.ts.map +1 -0
  68. package/dist/cli/utils/output-path-resolver.js +91 -0
  69. package/dist/cli/utils/output-path-resolver.js.map +1 -0
  70. package/dist/cli/utils/project-structure-detector.d.ts +6 -0
  71. package/dist/cli/utils/project-structure-detector.d.ts.map +1 -0
  72. package/dist/cli/utils/project-structure-detector.js +159 -0
  73. package/dist/cli/utils/project-structure-detector.js.map +1 -0
  74. package/dist/core/interfaces/dependency.d.ts +14 -0
  75. package/dist/core/interfaces/dependency.d.ts.map +1 -0
  76. package/dist/core/interfaces/dependency.js +2 -0
  77. package/dist/core/interfaces/dependency.js.map +1 -0
  78. package/dist/core/interfaces/errors.d.ts +29 -0
  79. package/dist/core/interfaces/errors.d.ts.map +1 -0
  80. package/dist/core/interfaces/errors.js +59 -0
  81. package/dist/core/interfaces/errors.js.map +1 -0
  82. package/dist/core/interfaces/index.d.ts +6 -0
  83. package/dist/core/interfaces/index.d.ts.map +1 -0
  84. package/dist/core/interfaces/index.js +2 -0
  85. package/dist/core/interfaces/index.js.map +1 -0
  86. package/dist/core/interfaces/language-plugin.d.ts +34 -0
  87. package/dist/core/interfaces/language-plugin.d.ts.map +1 -0
  88. package/dist/core/interfaces/language-plugin.js +2 -0
  89. package/dist/core/interfaces/language-plugin.js.map +1 -0
  90. package/dist/core/interfaces/parser.d.ts +15 -0
  91. package/dist/core/interfaces/parser.d.ts.map +1 -0
  92. package/dist/core/interfaces/parser.js +2 -0
  93. package/dist/core/interfaces/parser.js.map +1 -0
  94. package/dist/core/interfaces/validation.d.ts +24 -0
  95. package/dist/core/interfaces/validation.d.ts.map +1 -0
  96. package/dist/core/interfaces/validation.js +2 -0
  97. package/dist/core/interfaces/validation.js.map +1 -0
  98. package/dist/core/plugin-registry.d.ts +19 -0
  99. package/dist/core/plugin-registry.d.ts.map +1 -0
  100. package/dist/core/plugin-registry.js +137 -0
  101. package/dist/core/plugin-registry.js.map +1 -0
  102. package/dist/index.d.ts +4 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/index.js +4 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/mermaid/auto-repair.d.ts +23 -0
  107. package/dist/mermaid/auto-repair.d.ts.map +1 -0
  108. package/dist/mermaid/auto-repair.js +197 -0
  109. package/dist/mermaid/auto-repair.js.map +1 -0
  110. package/dist/mermaid/comment-generator.d.ts +10 -0
  111. package/dist/mermaid/comment-generator.d.ts.map +1 -0
  112. package/dist/mermaid/comment-generator.js +213 -0
  113. package/dist/mermaid/comment-generator.js.map +1 -0
  114. package/dist/mermaid/cpp-package-flowchart-generator.d.ts +5 -0
  115. package/dist/mermaid/cpp-package-flowchart-generator.d.ts.map +1 -0
  116. package/dist/mermaid/cpp-package-flowchart-generator.js +33 -0
  117. package/dist/mermaid/cpp-package-flowchart-generator.js.map +1 -0
  118. package/dist/mermaid/diagram-generator.d.ts +31 -0
  119. package/dist/mermaid/diagram-generator.d.ts.map +1 -0
  120. package/dist/mermaid/diagram-generator.js +194 -0
  121. package/dist/mermaid/diagram-generator.js.map +1 -0
  122. package/dist/mermaid/external-dependencies.d.ts +3 -0
  123. package/dist/mermaid/external-dependencies.d.ts.map +1 -0
  124. package/dist/mermaid/external-dependencies.js +38 -0
  125. package/dist/mermaid/external-dependencies.js.map +1 -0
  126. package/dist/mermaid/generator.d.ts +44 -0
  127. package/dist/mermaid/generator.d.ts.map +1 -0
  128. package/dist/mermaid/generator.js +511 -0
  129. package/dist/mermaid/generator.js.map +1 -0
  130. package/dist/mermaid/grouper.d.ts +15 -0
  131. package/dist/mermaid/grouper.d.ts.map +1 -0
  132. package/dist/mermaid/grouper.js +194 -0
  133. package/dist/mermaid/grouper.js.map +1 -0
  134. package/dist/mermaid/index.d.ts +14 -0
  135. package/dist/mermaid/index.d.ts.map +1 -0
  136. package/dist/mermaid/index.js +13 -0
  137. package/dist/mermaid/index.js.map +1 -0
  138. package/dist/mermaid/progress.d.ts +15 -0
  139. package/dist/mermaid/progress.d.ts.map +1 -0
  140. package/dist/mermaid/progress.js +8 -0
  141. package/dist/mermaid/progress.js.map +1 -0
  142. package/dist/mermaid/render-worker-pool.d.ts +29 -0
  143. package/dist/mermaid/render-worker-pool.d.ts.map +1 -0
  144. package/dist/mermaid/render-worker-pool.js +73 -0
  145. package/dist/mermaid/render-worker-pool.js.map +1 -0
  146. package/dist/mermaid/render-worker.d.ts +2 -0
  147. package/dist/mermaid/render-worker.d.ts.map +1 -0
  148. package/dist/mermaid/render-worker.js +22 -0
  149. package/dist/mermaid/render-worker.js.map +1 -0
  150. package/dist/mermaid/renderer.d.ts +17 -0
  151. package/dist/mermaid/renderer.d.ts.map +1 -0
  152. package/dist/mermaid/renderer.js +204 -0
  153. package/dist/mermaid/renderer.js.map +1 -0
  154. package/dist/mermaid/ts-module-graph-renderer.d.ts +3 -0
  155. package/dist/mermaid/ts-module-graph-renderer.d.ts.map +1 -0
  156. package/dist/mermaid/ts-module-graph-renderer.js +180 -0
  157. package/dist/mermaid/ts-module-graph-renderer.js.map +1 -0
  158. package/dist/mermaid/types.d.ts +122 -0
  159. package/dist/mermaid/types.d.ts.map +1 -0
  160. package/dist/mermaid/types.js +2 -0
  161. package/dist/mermaid/types.js.map +1 -0
  162. package/dist/mermaid/validation-pipeline.d.ts +29 -0
  163. package/dist/mermaid/validation-pipeline.d.ts.map +1 -0
  164. package/dist/mermaid/validation-pipeline.js +163 -0
  165. package/dist/mermaid/validation-pipeline.js.map +1 -0
  166. package/dist/mermaid/validator-parse.d.ts +11 -0
  167. package/dist/mermaid/validator-parse.d.ts.map +1 -0
  168. package/dist/mermaid/validator-parse.js +130 -0
  169. package/dist/mermaid/validator-parse.js.map +1 -0
  170. package/dist/mermaid/validator-quality.d.ts +17 -0
  171. package/dist/mermaid/validator-quality.d.ts.map +1 -0
  172. package/dist/mermaid/validator-quality.js +187 -0
  173. package/dist/mermaid/validator-quality.js.map +1 -0
  174. package/dist/mermaid/validator-render.d.ts +12 -0
  175. package/dist/mermaid/validator-render.d.ts.map +1 -0
  176. package/dist/mermaid/validator-render.js +98 -0
  177. package/dist/mermaid/validator-render.js.map +1 -0
  178. package/dist/mermaid/validator-structural.d.ts +11 -0
  179. package/dist/mermaid/validator-structural.d.ts.map +1 -0
  180. package/dist/mermaid/validator-structural.js +116 -0
  181. package/dist/mermaid/validator-structural.js.map +1 -0
  182. package/dist/parser/archjson-aggregator.d.ts +11 -0
  183. package/dist/parser/archjson-aggregator.d.ts.map +1 -0
  184. package/dist/parser/archjson-aggregator.js +113 -0
  185. package/dist/parser/archjson-aggregator.js.map +1 -0
  186. package/dist/parser/base-extractor.d.ts +6 -0
  187. package/dist/parser/base-extractor.d.ts.map +1 -0
  188. package/dist/parser/base-extractor.js +13 -0
  189. package/dist/parser/base-extractor.js.map +1 -0
  190. package/dist/parser/class-extractor.d.ts +17 -0
  191. package/dist/parser/class-extractor.d.ts.map +1 -0
  192. package/dist/parser/class-extractor.js +144 -0
  193. package/dist/parser/class-extractor.js.map +1 -0
  194. package/dist/parser/enum-extractor.d.ts +9 -0
  195. package/dist/parser/enum-extractor.d.ts.map +1 -0
  196. package/dist/parser/enum-extractor.js +45 -0
  197. package/dist/parser/enum-extractor.js.map +1 -0
  198. package/dist/parser/errors.d.ts +7 -0
  199. package/dist/parser/errors.d.ts.map +1 -0
  200. package/dist/parser/errors.js +14 -0
  201. package/dist/parser/errors.js.map +1 -0
  202. package/dist/parser/function-extractor.d.ts +7 -0
  203. package/dist/parser/function-extractor.d.ts.map +1 -0
  204. package/dist/parser/function-extractor.js +59 -0
  205. package/dist/parser/function-extractor.js.map +1 -0
  206. package/dist/parser/index.d.ts +10 -0
  207. package/dist/parser/index.d.ts.map +1 -0
  208. package/dist/parser/index.js +9 -0
  209. package/dist/parser/index.js.map +1 -0
  210. package/dist/parser/interface-extractor.d.ts +14 -0
  211. package/dist/parser/interface-extractor.d.ts.map +1 -0
  212. package/dist/parser/interface-extractor.js +90 -0
  213. package/dist/parser/interface-extractor.js.map +1 -0
  214. package/dist/parser/metrics-calculator.d.ts +9 -0
  215. package/dist/parser/metrics-calculator.d.ts.map +1 -0
  216. package/dist/parser/metrics-calculator.js +84 -0
  217. package/dist/parser/metrics-calculator.js.map +1 -0
  218. package/dist/parser/parallel-parser.d.ts +38 -0
  219. package/dist/parser/parallel-parser.d.ts.map +1 -0
  220. package/dist/parser/parallel-parser.js +170 -0
  221. package/dist/parser/parallel-parser.js.map +1 -0
  222. package/dist/parser/parse-cache.d.ts +8 -0
  223. package/dist/parser/parse-cache.d.ts.map +1 -0
  224. package/dist/parser/parse-cache.js +25 -0
  225. package/dist/parser/parse-cache.js.map +1 -0
  226. package/dist/parser/relation-extractor.d.ts +14 -0
  227. package/dist/parser/relation-extractor.d.ts.map +1 -0
  228. package/dist/parser/relation-extractor.js +203 -0
  229. package/dist/parser/relation-extractor.js.map +1 -0
  230. package/dist/parser/typescript-parser.d.ts +19 -0
  231. package/dist/parser/typescript-parser.d.ts.map +1 -0
  232. package/dist/parser/typescript-parser.js +182 -0
  233. package/dist/parser/typescript-parser.js.map +1 -0
  234. package/dist/plugins/cpp/archjson-mapper.d.ts +13 -0
  235. package/dist/plugins/cpp/archjson-mapper.d.ts.map +1 -0
  236. package/dist/plugins/cpp/archjson-mapper.js +180 -0
  237. package/dist/plugins/cpp/archjson-mapper.js.map +1 -0
  238. package/dist/plugins/cpp/builders/class-builder.d.ts +15 -0
  239. package/dist/plugins/cpp/builders/class-builder.d.ts.map +1 -0
  240. package/dist/plugins/cpp/builders/class-builder.js +102 -0
  241. package/dist/plugins/cpp/builders/class-builder.js.map +1 -0
  242. package/dist/plugins/cpp/builders/header-merger.d.ts +8 -0
  243. package/dist/plugins/cpp/builders/header-merger.d.ts.map +1 -0
  244. package/dist/plugins/cpp/builders/header-merger.js +65 -0
  245. package/dist/plugins/cpp/builders/header-merger.js.map +1 -0
  246. package/dist/plugins/cpp/cpp-type-extractor.d.ts +13 -0
  247. package/dist/plugins/cpp/cpp-type-extractor.d.ts.map +1 -0
  248. package/dist/plugins/cpp/cpp-type-extractor.js +153 -0
  249. package/dist/plugins/cpp/cpp-type-extractor.js.map +1 -0
  250. package/dist/plugins/cpp/dependency-extractor.d.ts +5 -0
  251. package/dist/plugins/cpp/dependency-extractor.d.ts.map +1 -0
  252. package/dist/plugins/cpp/dependency-extractor.js +28 -0
  253. package/dist/plugins/cpp/dependency-extractor.js.map +1 -0
  254. package/dist/plugins/cpp/index.d.ts +21 -0
  255. package/dist/plugins/cpp/index.d.ts.map +1 -0
  256. package/dist/plugins/cpp/index.js +113 -0
  257. package/dist/plugins/cpp/index.js.map +1 -0
  258. package/dist/plugins/cpp/tree-sitter-bridge.d.ts +20 -0
  259. package/dist/plugins/cpp/tree-sitter-bridge.d.ts.map +1 -0
  260. package/dist/plugins/cpp/tree-sitter-bridge.js +258 -0
  261. package/dist/plugins/cpp/tree-sitter-bridge.js.map +1 -0
  262. package/dist/plugins/cpp/types.d.ts +75 -0
  263. package/dist/plugins/cpp/types.d.ts.map +1 -0
  264. package/dist/plugins/cpp/types.js +2 -0
  265. package/dist/plugins/cpp/types.js.map +1 -0
  266. package/dist/plugins/golang/archjson-mapper.d.ts +10 -0
  267. package/dist/plugins/golang/archjson-mapper.d.ts.map +1 -0
  268. package/dist/plugins/golang/archjson-mapper.js +121 -0
  269. package/dist/plugins/golang/archjson-mapper.js.map +1 -0
  270. package/dist/plugins/golang/atlas/behavior-analyzer.d.ts +16 -0
  271. package/dist/plugins/golang/atlas/behavior-analyzer.d.ts.map +1 -0
  272. package/dist/plugins/golang/atlas/behavior-analyzer.js +32 -0
  273. package/dist/plugins/golang/atlas/behavior-analyzer.js.map +1 -0
  274. package/dist/plugins/golang/atlas/builders/capability-graph-builder.d.ts +12 -0
  275. package/dist/plugins/golang/atlas/builders/capability-graph-builder.d.ts.map +1 -0
  276. package/dist/plugins/golang/atlas/builders/capability-graph-builder.js +219 -0
  277. package/dist/plugins/golang/atlas/builders/capability-graph-builder.js.map +1 -0
  278. package/dist/plugins/golang/atlas/builders/flow-graph-builder.d.ts +18 -0
  279. package/dist/plugins/golang/atlas/builders/flow-graph-builder.d.ts.map +1 -0
  280. package/dist/plugins/golang/atlas/builders/flow-graph-builder.js +300 -0
  281. package/dist/plugins/golang/atlas/builders/flow-graph-builder.js.map +1 -0
  282. package/dist/plugins/golang/atlas/builders/goroutine-topology-builder.d.ts +15 -0
  283. package/dist/plugins/golang/atlas/builders/goroutine-topology-builder.d.ts.map +1 -0
  284. package/dist/plugins/golang/atlas/builders/goroutine-topology-builder.js +254 -0
  285. package/dist/plugins/golang/atlas/builders/goroutine-topology-builder.js.map +1 -0
  286. package/dist/plugins/golang/atlas/builders/i-atlas-builder.d.ts +5 -0
  287. package/dist/plugins/golang/atlas/builders/i-atlas-builder.d.ts.map +1 -0
  288. package/dist/plugins/golang/atlas/builders/i-atlas-builder.js +2 -0
  289. package/dist/plugins/golang/atlas/builders/i-atlas-builder.js.map +1 -0
  290. package/dist/plugins/golang/atlas/builders/index.d.ts +6 -0
  291. package/dist/plugins/golang/atlas/builders/index.d.ts.map +1 -0
  292. package/dist/plugins/golang/atlas/builders/index.js +5 -0
  293. package/dist/plugins/golang/atlas/builders/index.js.map +1 -0
  294. package/dist/plugins/golang/atlas/builders/package-graph-builder.d.ts +14 -0
  295. package/dist/plugins/golang/atlas/builders/package-graph-builder.d.ts.map +1 -0
  296. package/dist/plugins/golang/atlas/builders/package-graph-builder.js +115 -0
  297. package/dist/plugins/golang/atlas/builders/package-graph-builder.js.map +1 -0
  298. package/dist/plugins/golang/atlas/framework-detector.d.ts +11 -0
  299. package/dist/plugins/golang/atlas/framework-detector.d.ts.map +1 -0
  300. package/dist/plugins/golang/atlas/framework-detector.js +82 -0
  301. package/dist/plugins/golang/atlas/framework-detector.js.map +1 -0
  302. package/dist/plugins/golang/atlas/go-mod-resolver.d.ts +21 -0
  303. package/dist/plugins/golang/atlas/go-mod-resolver.d.ts.map +1 -0
  304. package/dist/plugins/golang/atlas/go-mod-resolver.js +90 -0
  305. package/dist/plugins/golang/atlas/go-mod-resolver.js.map +1 -0
  306. package/dist/plugins/golang/atlas/index.d.ts +28 -0
  307. package/dist/plugins/golang/atlas/index.d.ts.map +1 -0
  308. package/dist/plugins/golang/atlas/index.js +166 -0
  309. package/dist/plugins/golang/atlas/index.js.map +1 -0
  310. package/dist/plugins/golang/atlas/renderers/atlas-renderer.d.ts +7 -0
  311. package/dist/plugins/golang/atlas/renderers/atlas-renderer.d.ts.map +1 -0
  312. package/dist/plugins/golang/atlas/renderers/atlas-renderer.js +62 -0
  313. package/dist/plugins/golang/atlas/renderers/atlas-renderer.js.map +1 -0
  314. package/dist/plugins/golang/atlas/renderers/mermaid-templates.d.ts +24 -0
  315. package/dist/plugins/golang/atlas/renderers/mermaid-templates.d.ts.map +1 -0
  316. package/dist/plugins/golang/atlas/renderers/mermaid-templates.js +688 -0
  317. package/dist/plugins/golang/atlas/renderers/mermaid-templates.js.map +1 -0
  318. package/dist/plugins/golang/atlas/types.d.ts +63 -0
  319. package/dist/plugins/golang/atlas/types.d.ts.map +1 -0
  320. package/dist/plugins/golang/atlas/types.js +2 -0
  321. package/dist/plugins/golang/atlas/types.js.map +1 -0
  322. package/dist/plugins/golang/dependency-extractor.d.ts +7 -0
  323. package/dist/plugins/golang/dependency-extractor.d.ts.map +1 -0
  324. package/dist/plugins/golang/dependency-extractor.js +100 -0
  325. package/dist/plugins/golang/dependency-extractor.js.map +1 -0
  326. package/dist/plugins/golang/gopls-client.d.ts +38 -0
  327. package/dist/plugins/golang/gopls-client.d.ts.map +1 -0
  328. package/dist/plugins/golang/gopls-client.js +354 -0
  329. package/dist/plugins/golang/gopls-client.js.map +1 -0
  330. package/dist/plugins/golang/index.d.ts +29 -0
  331. package/dist/plugins/golang/index.d.ts.map +1 -0
  332. package/dist/plugins/golang/index.js +242 -0
  333. package/dist/plugins/golang/index.js.map +1 -0
  334. package/dist/plugins/golang/interface-matcher.d.ts +14 -0
  335. package/dist/plugins/golang/interface-matcher.d.ts.map +1 -0
  336. package/dist/plugins/golang/interface-matcher.js +235 -0
  337. package/dist/plugins/golang/interface-matcher.js.map +1 -0
  338. package/dist/plugins/golang/tree-sitter-bridge.d.ts +32 -0
  339. package/dist/plugins/golang/tree-sitter-bridge.d.ts.map +1 -0
  340. package/dist/plugins/golang/tree-sitter-bridge.js +579 -0
  341. package/dist/plugins/golang/tree-sitter-bridge.js.map +1 -0
  342. package/dist/plugins/golang/types.d.ts +119 -0
  343. package/dist/plugins/golang/types.d.ts.map +1 -0
  344. package/dist/plugins/golang/types.js +2 -0
  345. package/dist/plugins/golang/types.js.map +1 -0
  346. package/dist/plugins/java/archjson-mapper.d.ts +15 -0
  347. package/dist/plugins/java/archjson-mapper.d.ts.map +1 -0
  348. package/dist/plugins/java/archjson-mapper.js +273 -0
  349. package/dist/plugins/java/archjson-mapper.js.map +1 -0
  350. package/dist/plugins/java/dependency-extractor.d.ts +9 -0
  351. package/dist/plugins/java/dependency-extractor.d.ts.map +1 -0
  352. package/dist/plugins/java/dependency-extractor.js +99 -0
  353. package/dist/plugins/java/dependency-extractor.js.map +1 -0
  354. package/dist/plugins/java/index.d.ts +21 -0
  355. package/dist/plugins/java/index.d.ts.map +1 -0
  356. package/dist/plugins/java/index.js +167 -0
  357. package/dist/plugins/java/index.js.map +1 -0
  358. package/dist/plugins/java/tree-sitter-bridge.d.ts +19 -0
  359. package/dist/plugins/java/tree-sitter-bridge.d.ts.map +1 -0
  360. package/dist/plugins/java/tree-sitter-bridge.js +334 -0
  361. package/dist/plugins/java/tree-sitter-bridge.js.map +1 -0
  362. package/dist/plugins/java/types.d.ts +81 -0
  363. package/dist/plugins/java/types.d.ts.map +1 -0
  364. package/dist/plugins/java/types.js +2 -0
  365. package/dist/plugins/java/types.js.map +1 -0
  366. package/dist/plugins/python/archjson-mapper.d.ts +19 -0
  367. package/dist/plugins/python/archjson-mapper.d.ts.map +1 -0
  368. package/dist/plugins/python/archjson-mapper.js +170 -0
  369. package/dist/plugins/python/archjson-mapper.js.map +1 -0
  370. package/dist/plugins/python/dependency-extractor.d.ts +11 -0
  371. package/dist/plugins/python/dependency-extractor.d.ts.map +1 -0
  372. package/dist/plugins/python/dependency-extractor.js +186 -0
  373. package/dist/plugins/python/dependency-extractor.js.map +1 -0
  374. package/dist/plugins/python/index.d.ts +21 -0
  375. package/dist/plugins/python/index.d.ts.map +1 -0
  376. package/dist/plugins/python/index.js +142 -0
  377. package/dist/plugins/python/index.js.map +1 -0
  378. package/dist/plugins/python/tree-sitter-bridge.d.ts +16 -0
  379. package/dist/plugins/python/tree-sitter-bridge.d.ts.map +1 -0
  380. package/dist/plugins/python/tree-sitter-bridge.js +352 -0
  381. package/dist/plugins/python/tree-sitter-bridge.js.map +1 -0
  382. package/dist/plugins/python/types.d.ts +86 -0
  383. package/dist/plugins/python/types.d.ts.map +1 -0
  384. package/dist/plugins/python/types.js +2 -0
  385. package/dist/plugins/python/types.js.map +1 -0
  386. package/dist/plugins/shared/mapper-utils.d.ts +4 -0
  387. package/dist/plugins/shared/mapper-utils.d.ts.map +1 -0
  388. package/dist/plugins/shared/mapper-utils.js +12 -0
  389. package/dist/plugins/shared/mapper-utils.js.map +1 -0
  390. package/dist/plugins/typescript/builders/module-graph-builder.d.ts +8 -0
  391. package/dist/plugins/typescript/builders/module-graph-builder.d.ts.map +1 -0
  392. package/dist/plugins/typescript/builders/module-graph-builder.js +175 -0
  393. package/dist/plugins/typescript/builders/module-graph-builder.js.map +1 -0
  394. package/dist/plugins/typescript/index.d.ts +26 -0
  395. package/dist/plugins/typescript/index.d.ts.map +1 -0
  396. package/dist/plugins/typescript/index.js +232 -0
  397. package/dist/plugins/typescript/index.js.map +1 -0
  398. package/dist/plugins/typescript/typescript-analyzer.d.ts +8 -0
  399. package/dist/plugins/typescript/typescript-analyzer.d.ts.map +1 -0
  400. package/dist/plugins/typescript/typescript-analyzer.js +13 -0
  401. package/dist/plugins/typescript/typescript-analyzer.js.map +1 -0
  402. package/dist/scripts/migrate-to-mermaid.js +214 -0
  403. package/dist/types/config.d.ts +140 -0
  404. package/dist/types/config.d.ts.map +1 -0
  405. package/dist/types/config.js +6 -0
  406. package/dist/types/config.js.map +1 -0
  407. package/dist/types/extensions.d.ts +224 -0
  408. package/dist/types/extensions.d.ts.map +1 -0
  409. package/dist/types/extensions.js +3 -0
  410. package/dist/types/extensions.js.map +1 -0
  411. package/dist/types/index.d.ts +89 -0
  412. package/dist/types/index.d.ts.map +1 -0
  413. package/dist/types/index.js +3 -0
  414. package/dist/types/index.js.map +1 -0
  415. package/dist/utils/cli-detector.d.ts +8 -0
  416. package/dist/utils/cli-detector.d.ts.map +1 -0
  417. package/dist/utils/cli-detector.js +38 -0
  418. package/dist/utils/cli-detector.js.map +1 -0
  419. package/dist/utils/index.d.ts +4 -0
  420. package/dist/utils/index.d.ts.map +1 -0
  421. package/dist/utils/index.js +3 -0
  422. package/dist/utils/index.js.map +1 -0
  423. package/dist/utils/tsconfig-finder.d.ts +7 -0
  424. package/dist/utils/tsconfig-finder.d.ts.map +1 -0
  425. package/dist/utils/tsconfig-finder.js +31 -0
  426. package/dist/utils/tsconfig-finder.js.map +1 -0
  427. package/package.json +95 -0
@@ -0,0 +1,688 @@
1
+ import path from 'path';
2
+ export class MermaidTemplates {
3
+ static SUBGRAPH_DEPTH_STYLES = [
4
+ 'fill:#ffffff,stroke:#d0d7de,stroke-width:1px',
5
+ 'fill:#f6f8fa,stroke:#d0d7de,stroke-width:1px',
6
+ 'fill:#eaeef2,stroke:#8b949e,stroke-width:1px',
7
+ 'fill:#d0d7de,stroke:#57606a,stroke-width:1px',
8
+ ];
9
+ static FLOWCHART_INIT = "%%{init: {'flowchart': {'nodeSpacing': 50, 'rankSpacing': 80, 'curve': 'basis'}}}%%\n";
10
+ static SEQUENCE_INIT = "%%{init: {'sequence': {'actorMargin': 50}}}%%\n";
11
+ static buildPackageTree(packages) {
12
+ const pkgSet = new Set(packages);
13
+ const prefixCount = new Map();
14
+ for (const pkg of packages) {
15
+ const segs = pkg.split('/');
16
+ for (let d = 1; d < segs.length; d++) {
17
+ const prefix = segs.slice(0, d).join('/');
18
+ prefixCount.set(prefix, (prefixCount.get(prefix) ?? 0) + 1);
19
+ }
20
+ }
21
+ const virtualGroups = new Set();
22
+ for (const [prefix, count] of prefixCount) {
23
+ if (count >= 2 && !pkgSet.has(prefix)) {
24
+ virtualGroups.add(prefix);
25
+ }
26
+ }
27
+ const allPrefixes = new Set([...packages, ...virtualGroups]);
28
+ const nodeMap = new Map();
29
+ for (const p of allPrefixes) {
30
+ nodeMap.set(p, { pkg: p, isVirtual: !pkgSet.has(p), children: [] });
31
+ }
32
+ const parentOf = (pkg) => {
33
+ const segs = pkg.split('/');
34
+ for (let d = segs.length - 1; d >= 1; d--) {
35
+ const prefix = segs.slice(0, d).join('/');
36
+ if (allPrefixes.has(prefix))
37
+ return prefix;
38
+ }
39
+ return null;
40
+ };
41
+ const roots = [];
42
+ for (const p of allPrefixes) {
43
+ const parent = parentOf(p);
44
+ if (parent && nodeMap.has(parent)) {
45
+ nodeMap.get(parent).children.push(nodeMap.get(p));
46
+ }
47
+ else {
48
+ roots.push(nodeMap.get(p));
49
+ }
50
+ }
51
+ return roots;
52
+ }
53
+ static buildGroupTree(nodes) {
54
+ const prefixMembers = new Map();
55
+ for (const node of nodes) {
56
+ const segs = node.name.split('/');
57
+ for (let d = 1; d <= segs.length; d++) {
58
+ const prefix = segs.slice(0, d).join('/');
59
+ const arr = prefixMembers.get(prefix) ?? [];
60
+ arr.push(node.id);
61
+ prefixMembers.set(prefix, arr);
62
+ }
63
+ }
64
+ const validPrefixes = new Set();
65
+ for (const [prefix, ids] of prefixMembers) {
66
+ if (ids.length >= 2)
67
+ validPrefixes.add(prefix);
68
+ }
69
+ const deepestGroupFor = (name) => {
70
+ const segs = name.split('/');
71
+ for (let d = segs.length; d >= 1; d--) {
72
+ const prefix = segs.slice(0, d).join('/');
73
+ if (validPrefixes.has(prefix))
74
+ return prefix;
75
+ }
76
+ return null;
77
+ };
78
+ const parentGroupFor = (prefix) => {
79
+ const segs = prefix.split('/');
80
+ for (let d = segs.length - 1; d >= 1; d--) {
81
+ const p = segs.slice(0, d).join('/');
82
+ if (validPrefixes.has(p))
83
+ return p;
84
+ }
85
+ return null;
86
+ };
87
+ const nodeObjects = new Map();
88
+ for (const prefix of validPrefixes) {
89
+ nodeObjects.set(prefix, { prefix, children: [], nodeIds: [] });
90
+ }
91
+ const roots = [];
92
+ for (const prefix of validPrefixes) {
93
+ const parent = parentGroupFor(prefix);
94
+ if (parent && nodeObjects.has(parent)) {
95
+ nodeObjects.get(parent).children.push(nodeObjects.get(prefix));
96
+ }
97
+ else {
98
+ roots.push(nodeObjects.get(prefix));
99
+ }
100
+ }
101
+ const grouped = new Set();
102
+ for (const node of nodes) {
103
+ const group = deepestGroupFor(node.name);
104
+ if (group && nodeObjects.has(group)) {
105
+ nodeObjects.get(group).nodeIds.push(node.id);
106
+ grouped.add(node.id);
107
+ }
108
+ }
109
+ return { roots, grouped };
110
+ }
111
+ static renderGroupNodes(groups, nodeMap, cycleNodeIds, indent, inDegree, depthMap, depth) {
112
+ const currentDepth = depth ?? 0;
113
+ let out = '';
114
+ for (const group of groups) {
115
+ const sgId = 'grp_' + MermaidTemplates.sanitizeId(group.prefix);
116
+ if (depthMap)
117
+ depthMap.set(sgId, currentDepth);
118
+ out += `\n${indent}subgraph ${sgId}["${group.prefix}"]\n`;
119
+ out += MermaidTemplates.renderGroupNodes(group.children, nodeMap, cycleNodeIds, indent + ' ', inDegree, depthMap, currentDepth + 1);
120
+ const sortedIds = inDegree
121
+ ? [...group.nodeIds].sort((a, b) => {
122
+ const diff = (inDegree.get(b) ?? 0) - (inDegree.get(a) ?? 0);
123
+ return diff !== 0 ? diff : a.localeCompare(b);
124
+ })
125
+ : group.nodeIds;
126
+ for (const nodeId of sortedIds) {
127
+ const node = nodeMap.get(nodeId);
128
+ const style = cycleNodeIds.has(node.id) ? ':::cycle' : `:::${node.type}`;
129
+ out += `${indent} ${MermaidTemplates.sanitizeId(node.id)}["${node.name}"]${style}\n`;
130
+ }
131
+ out += `${indent}end\n`;
132
+ }
133
+ return out;
134
+ }
135
+ static renderLegend(activeTypes) {
136
+ const LEGEND_LABELS = {
137
+ cmd: 'cmd (entry point)',
138
+ tests: 'tests',
139
+ examples: 'examples',
140
+ testutil: 'testutil',
141
+ internal: 'internal',
142
+ vendor: 'vendor',
143
+ external: 'external (module boundary)',
144
+ cycle: 'cycle (circular dep)',
145
+ };
146
+ let out = ' subgraph legend["Legend"]\n';
147
+ out += ' direction LR\n';
148
+ for (const type of Object.keys(LEGEND_LABELS)) {
149
+ if (activeTypes.has(type)) {
150
+ out += ` legend_${type}["${LEGEND_LABELS[type]}"]:::${type}\n`;
151
+ }
152
+ }
153
+ out += ' legend_edge["--> depends on (bolder = more imports)"]\n';
154
+ out += ' end\n';
155
+ out += ' style legend fill:#fff8c5,stroke:#d4a72c,stroke-dasharray:5 5,color:#633c01\n\n';
156
+ return out;
157
+ }
158
+ static renderPackageGraph(graph) {
159
+ let output = MermaidTemplates.FLOWCHART_INIT + 'flowchart TB\n';
160
+ const cycleNodeIds = new Set(graph.cycles.filter((c) => c.packages.length > 1).flatMap((c) => c.packages));
161
+ const activeTypes = new Set(graph.nodes.map((n) => n.type));
162
+ if (cycleNodeIds.size > 0)
163
+ activeTypes.add('cycle');
164
+ const nodeMap = new Map(graph.nodes.map((n) => [n.id, n]));
165
+ const { roots, grouped } = MermaidTemplates.buildGroupTree(graph.nodes);
166
+ const inDegree = new Map();
167
+ for (const node of graph.nodes)
168
+ inDegree.set(node.id, 0);
169
+ for (const edge of graph.edges) {
170
+ if (edge.from !== edge.to) {
171
+ inDegree.set(edge.to, (inDegree.get(edge.to) ?? 0) + 1);
172
+ }
173
+ }
174
+ const sortedNodes = [...graph.nodes].sort((a, b) => {
175
+ const diff = (inDegree.get(b.id) ?? 0) - (inDegree.get(a.id) ?? 0);
176
+ return diff !== 0 ? diff : a.id.localeCompare(b.id);
177
+ });
178
+ for (const node of sortedNodes) {
179
+ if (!grouped.has(node.id)) {
180
+ const style = cycleNodeIds.has(node.id) ? ':::cycle' : `:::${node.type}`;
181
+ output += ` ${MermaidTemplates.sanitizeId(node.id)}["${node.name}"]${style}\n`;
182
+ }
183
+ }
184
+ const subgraphDepthMap = new Map();
185
+ output += MermaidTemplates.renderGroupNodes(roots, nodeMap, cycleNodeIds, ' ', inDegree, subgraphDepthMap, 0);
186
+ output += MermaidTemplates.renderLegend(activeTypes);
187
+ for (const [sgId, sgDepth] of subgraphDepthMap) {
188
+ const styleStr = MermaidTemplates.SUBGRAPH_DEPTH_STYLES[Math.min(sgDepth, MermaidTemplates.SUBGRAPH_DEPTH_STYLES.length - 1)];
189
+ output += ` style ${sgId} ${styleStr}\n`;
190
+ }
191
+ output += '\n';
192
+ output += ' classDef cmd fill:#ffebe9,stroke:#cf222e,color:#82071e\n';
193
+ output += ' classDef tests fill:#f6f8fa,stroke:#d0d7de,color:#57606a\n';
194
+ output += ' classDef examples fill:#ddf4ff,stroke:#54aeff,color:#0550ae\n';
195
+ output += ' classDef testutil fill:#f6f8fa,stroke:#d0d7de,color:#57606a\n';
196
+ output += ' classDef internal fill:#dafbe1,stroke:#2da44e,color:#116329\n';
197
+ output += ' classDef vendor fill:#fdf4ff,stroke:#d2a8ff,color:#6e40c9\n';
198
+ output += ' classDef external fill:#fff8c5,stroke:#d4a72c,color:#633c01\n';
199
+ output += ' classDef cycle fill:#ffebe9,stroke:#cf222e,stroke-width:3px,color:#82071e,font-weight:bold\n';
200
+ const edgeThicknesses = [];
201
+ let edgeIndex = 0;
202
+ output += '\n';
203
+ for (const edge of graph.edges) {
204
+ const fromId = MermaidTemplates.sanitizeId(edge.from);
205
+ const toId = MermaidTemplates.sanitizeId(edge.to);
206
+ if (edge.from === edge.to) {
207
+ output += ` ${fromId} -.->|"⚠ self"| ${toId}\n`;
208
+ edgeIndex++;
209
+ continue;
210
+ }
211
+ const label = edge.strength > 1 ? `|"${edge.strength} refs"|` : '';
212
+ output += ` ${fromId} -->${label} ${toId}\n`;
213
+ edgeThicknesses.push({ index: edgeIndex, strength: edge.strength });
214
+ edgeIndex++;
215
+ }
216
+ if (edgeThicknesses.length > 0) {
217
+ const tiers = MermaidTemplates.computePackageEdgeTiers(edgeThicknesses.map((e) => e.strength));
218
+ if (tiers.size > 0) {
219
+ output += '\n';
220
+ for (const { index, strength } of edgeThicknesses) {
221
+ const width = tiers.get(strength);
222
+ if (width !== undefined) {
223
+ output += ` linkStyle ${index} stroke-width:${width}px\n`;
224
+ }
225
+ }
226
+ }
227
+ }
228
+ if (graph.cycles.length > 0) {
229
+ output += '\n %% Cycles detected:\n';
230
+ for (const cycle of graph.cycles) {
231
+ output += ` %% ${cycle.severity}: ${cycle.packages.join(' → ')}\n`;
232
+ }
233
+ }
234
+ return output;
235
+ }
236
+ static renderCapabilityGraph(graph) {
237
+ if (graph.nodes.length === 0) {
238
+ return MermaidTemplates.FLOWCHART_INIT + 'flowchart LR';
239
+ }
240
+ let output = MermaidTemplates.FLOWCHART_INIT + 'flowchart LR\n';
241
+ const nodesByPkg = new Map();
242
+ for (const node of graph.nodes) {
243
+ if (!nodesByPkg.has(node.package))
244
+ nodesByPkg.set(node.package, []);
245
+ nodesByPkg.get(node.package).push(node);
246
+ }
247
+ const pkgList = Array.from(nodesByPkg.keys());
248
+ const pkgRoots = MermaidTemplates.buildPackageTree(pkgList);
249
+ let hasHotspot = false;
250
+ const capDepthMap = new Map();
251
+ const renderCapNode = (treeNode, indent, depth) => {
252
+ const sgId = 'grp_' + MermaidTemplates.sanitizeId(treeNode.pkg);
253
+ capDepthMap.set(sgId, depth);
254
+ output += `${indent}subgraph ${sgId}["${treeNode.pkg}"]\n`;
255
+ for (const child of treeNode.children) {
256
+ renderCapNode(child, indent + ' ', depth + 1);
257
+ }
258
+ if (!treeNode.isVirtual) {
259
+ for (const node of nodesByPkg.get(treeNode.pkg) ?? []) {
260
+ const mId = MermaidTemplates.sanitizeId(node.id);
261
+ const label = MermaidTemplates.formatCapabilityLabel(node);
262
+ const isHot = MermaidTemplates.isHotspot(node);
263
+ if (isHot)
264
+ hasHotspot = true;
265
+ const classSuffix = isHot
266
+ ? ':::hotspot'
267
+ : node.type === 'interface'
268
+ ? ':::interface'
269
+ : ':::concrete';
270
+ if (node.type === 'interface') {
271
+ output += `${indent} ${mId}{{"${label}"}}${classSuffix}\n`;
272
+ }
273
+ else {
274
+ output += `${indent} ${mId}["${label}"]${classSuffix}\n`;
275
+ }
276
+ }
277
+ }
278
+ output += `${indent}end\n`;
279
+ };
280
+ for (const root of pkgRoots) {
281
+ renderCapNode(root, '', 0);
282
+ }
283
+ for (const [sgId, sgDepth] of capDepthMap) {
284
+ const styleStr = MermaidTemplates.SUBGRAPH_DEPTH_STYLES[Math.min(sgDepth, MermaidTemplates.SUBGRAPH_DEPTH_STYLES.length - 1)];
285
+ output += ` style ${sgId} ${styleStr}\n`;
286
+ }
287
+ const hasConcreteEdge = graph.edges.some((e) => e.concreteUsage === true);
288
+ output += ' subgraph legend["Legend"]\n';
289
+ output += ' direction LR\n';
290
+ output += ' legend_interface{{"interface"}}:::interface\n';
291
+ output += ' legend_concrete["concrete"]:::concrete\n';
292
+ if (hasHotspot) {
293
+ output += ' legend_hotspot["hotspot (≥11m or fi>5)"]:::hotspot\n';
294
+ }
295
+ output += ' legend_impl["-.-> implements"]\n';
296
+ output += ' legend_uses["--> uses"]\n';
297
+ if (hasConcreteEdge) {
298
+ output += ' legend_conc["==> concrete usage"]\n';
299
+ }
300
+ output += ' end\n';
301
+ output += ' style legend fill:#fff8c5,stroke:#d4a72c,stroke-dasharray:5 5,color:#633c01\n';
302
+ output += ' classDef interface fill:#ddf4ff,stroke:#54aeff,color:#0550ae\n';
303
+ output += ' classDef concrete fill:#dafbe1,stroke:#2da44e,color:#116329\n';
304
+ if (hasHotspot) {
305
+ output += ' classDef hotspot fill:#ffebe9,stroke:#cf222e,stroke-width:2px,color:#82071e\n';
306
+ }
307
+ for (const edge of graph.edges) {
308
+ const src = MermaidTemplates.sanitizeId(edge.source);
309
+ const tgt = MermaidTemplates.sanitizeId(edge.target);
310
+ if (edge.type === 'implements') {
311
+ output += ` ${src} -.->|impl| ${tgt}\n`;
312
+ }
313
+ else if (edge.concreteUsage === true) {
314
+ output += ` ${src} ==>|conc| ${tgt}\n`;
315
+ }
316
+ else {
317
+ output += ` ${src} -->|uses| ${tgt}\n`;
318
+ }
319
+ }
320
+ return output;
321
+ }
322
+ static formatCapabilityLabel(node) {
323
+ const sizeParts = [];
324
+ if ((node.fieldCount ?? 0) > 0)
325
+ sizeParts.push(`${node.fieldCount}f`);
326
+ if ((node.methodCount ?? 0) > 0)
327
+ sizeParts.push(`${node.methodCount}m`);
328
+ const couplingParts = [];
329
+ if ((node.fanIn ?? 0) > 0)
330
+ couplingParts.push(`fi:${node.fanIn}`);
331
+ if ((node.fanOut ?? 0) > 0)
332
+ couplingParts.push(`fo:${node.fanOut}`);
333
+ if (sizeParts.length === 0 && couplingParts.length === 0) {
334
+ return node.name;
335
+ }
336
+ const sections = [];
337
+ if (sizeParts.length > 0)
338
+ sections.push(sizeParts.join(' '));
339
+ if (couplingParts.length > 0)
340
+ sections.push(couplingParts.join(' '));
341
+ return `${node.name} [${sections.join(' | ')}]`;
342
+ }
343
+ static isHotspot(node) {
344
+ return (node.methodCount ?? 0) > 10 || (node.fanIn ?? 0) > 5;
345
+ }
346
+ static computePackageEdgeTiers(strengths) {
347
+ if (strengths.length === 0)
348
+ return new Map();
349
+ const sorted = [...strengths].sort((a, b) => a - b);
350
+ const min = sorted[0];
351
+ const max = sorted[sorted.length - 1];
352
+ if (max === min)
353
+ return new Map();
354
+ const n = sorted.length;
355
+ let thMedium = sorted[Math.min(Math.floor(n * 0.5), n - 1)];
356
+ let thHeavy = sorted[Math.min(Math.floor(n * 0.85), n - 1)];
357
+ if (thMedium >= max) {
358
+ thMedium = min;
359
+ thHeavy = max;
360
+ }
361
+ const result = new Map();
362
+ for (const s of new Set(strengths)) {
363
+ if (s >= thHeavy) {
364
+ result.set(s, 5.0);
365
+ }
366
+ else if (s > thMedium) {
367
+ result.set(s, 3.0);
368
+ }
369
+ }
370
+ return result;
371
+ }
372
+ static renderGoroutineTopology(topology) {
373
+ let output = MermaidTemplates.FLOWCHART_INIT + 'flowchart TB\n';
374
+ const packageGroups = new Map();
375
+ const ungrouped = [];
376
+ const declaredIds = new Set();
377
+ const addDecl = (pkg, decl) => {
378
+ if (pkg) {
379
+ if (!packageGroups.has(pkg))
380
+ packageGroups.set(pkg, []);
381
+ packageGroups.get(pkg).push(decl);
382
+ }
383
+ else {
384
+ ungrouped.push(decl);
385
+ }
386
+ declaredIds.add(decl.rawId);
387
+ };
388
+ const nodeIdToPackage = new Map();
389
+ for (const node of topology.nodes) {
390
+ if (node.package)
391
+ nodeIdToPackage.set(node.id, node.package);
392
+ }
393
+ for (const node of topology.nodes) {
394
+ const patternLabel = node.pattern ? ` (${node.pattern})` : '';
395
+ const displayName = MermaidTemplates.formatGoroutineName(node);
396
+ const lifecycleTag = node.type === 'spawned'
397
+ ? MermaidTemplates.getLifecycleTag(node.id, topology.lifecycle)
398
+ : '';
399
+ const label = `${displayName}${patternLabel}${lifecycleTag}`;
400
+ const style = node.type === 'main'
401
+ ? ':::main'
402
+ : label.includes('\u26a0 no exit')
403
+ ? ':::spawned_noexit'
404
+ : ':::spawned';
405
+ addDecl(node.package || undefined, {
406
+ rawId: node.id,
407
+ label,
408
+ style,
409
+ });
410
+ }
411
+ for (const edge of topology.edges) {
412
+ if (!declaredIds.has(edge.from)) {
413
+ const label = MermaidTemplates.formatSpawnerLabel(edge.from);
414
+ const pkg = nodeIdToPackage.get(edge.to);
415
+ addDecl(pkg, { rawId: edge.from, label, style: ':::spawner' });
416
+ }
417
+ }
418
+ for (const edge of topology.channelEdges) {
419
+ if (!edge.from.startsWith('chan-') && !declaredIds.has(edge.from)) {
420
+ const label = MermaidTemplates.formatSpawnerLabel(edge.from);
421
+ const pkg = nodeIdToPackage.get(edge.to);
422
+ addDecl(pkg, { rawId: edge.from, label, style: ':::spawner' });
423
+ }
424
+ }
425
+ const pkgList = Array.from(packageGroups.keys());
426
+ const pkgRoots = MermaidTemplates.buildPackageTree(pkgList);
427
+ const goroutineDepthMap = new Map();
428
+ const renderGoroutineNode = (treeNode, indent, depth) => {
429
+ const sgId = 'grp_' + MermaidTemplates.sanitizeId(treeNode.pkg);
430
+ goroutineDepthMap.set(sgId, depth);
431
+ output += `\n${indent}subgraph ${sgId}["${treeNode.pkg}"]\n`;
432
+ for (const child of treeNode.children) {
433
+ renderGoroutineNode(child, indent + ' ', depth + 1);
434
+ }
435
+ if (!treeNode.isVirtual) {
436
+ for (const decl of packageGroups.get(treeNode.pkg) ?? []) {
437
+ output += `${indent} ${this.sanitizeId(decl.rawId)}["${decl.label}"]${decl.style}\n`;
438
+ }
439
+ }
440
+ output += `${indent}end\n`;
441
+ };
442
+ for (const root of pkgRoots) {
443
+ renderGoroutineNode(root, ' ', 0);
444
+ }
445
+ for (const decl of ungrouped) {
446
+ output += ` ${this.sanitizeId(decl.rawId)}["${decl.label}"]${decl.style}\n`;
447
+ }
448
+ output += '\n';
449
+ for (const [sgId, sgDepth] of goroutineDepthMap) {
450
+ const styleStr = MermaidTemplates.SUBGRAPH_DEPTH_STYLES[Math.min(sgDepth, MermaidTemplates.SUBGRAPH_DEPTH_STYLES.length - 1)];
451
+ output += ` style ${sgId} ${styleStr}\n`;
452
+ }
453
+ for (const edge of topology.edges) {
454
+ output += ` ${this.sanitizeId(edge.from)} -->|go| ${this.sanitizeId(edge.to)}\n`;
455
+ }
456
+ if (topology.channels.length > 0) {
457
+ output += '\n subgraph channels\n';
458
+ for (const ch of topology.channels) {
459
+ const label = ch.type !== 'chan' ? ch.type : MermaidTemplates.formatChannelLabel(ch.id);
460
+ output += ` ${this.sanitizeId(ch.id)}[("${label}")]:::channel\n`;
461
+ }
462
+ output += ' end\n';
463
+ output += ' style channels fill:#ffffff,stroke:#d0d7de,stroke-width:1px\n';
464
+ }
465
+ for (const edge of topology.channelEdges) {
466
+ output += ` ${this.sanitizeId(edge.from)} -->|${edge.edgeType}| ${this.sanitizeId(edge.to)}\n`;
467
+ }
468
+ const hasNormalSpawned = [...packageGroups.values()].flat().concat(ungrouped)
469
+ .some((d) => d.style === ':::spawned');
470
+ output += '\n subgraph legend["Legend"]\n';
471
+ output += ' direction LR\n';
472
+ output += ' legend_main["main"]:::main\n';
473
+ output += ' legend_spawner["spawner"]:::spawner\n';
474
+ if (hasNormalSpawned) {
475
+ output += ' legend_spawned["spawned \u2713"]:::spawned\n';
476
+ }
477
+ output += ' legend_spawned_noexit["spawned \u26a0 no exit"]:::spawned_noexit\n';
478
+ output += ' legend_channel["channel"]:::channel\n';
479
+ output += ' legend_go["--> go (goroutine launch)"]\n';
480
+ if (topology.channels.length > 0) {
481
+ output += ' legend_make["--> make/send/recv"]\n';
482
+ }
483
+ output += ' end\n';
484
+ output += ' style legend fill:#fff8c5,stroke:#d4a72c,stroke-dasharray:5 5,color:#633c01\n';
485
+ output += '\n classDef main fill:#ffebe9,stroke:#cf222e,stroke-width:2px,color:#82071e\n';
486
+ output += ' classDef spawned fill:#dafbe1,stroke:#2da44e,color:#116329\n';
487
+ output += ' classDef spawner fill:#ddf4ff,stroke:#54aeff,color:#0550ae\n';
488
+ output += ' classDef spawned_noexit fill:#fff3cd,stroke:#d4a72c,stroke-width:2px,color:#633c01\n';
489
+ output += ' classDef channel fill:#fff8c5,stroke:#d4a72c,color:#633c01\n';
490
+ return output;
491
+ }
492
+ static renderFlowGraph(graph, format = 'flowchart') {
493
+ if (format === 'sequence') {
494
+ let output = MermaidTemplates.SEQUENCE_INIT + 'sequenceDiagram\n';
495
+ for (const chain of graph.callChains) {
496
+ const entry = graph.entryPoints.find((e) => e.id === chain.entryPoint);
497
+ if (!entry)
498
+ continue;
499
+ const handlerId = this.sanitizeId(entry.handler);
500
+ if (handlerId) {
501
+ const entryLabel = MermaidTemplates.formatEntryLabel(entry);
502
+ output += `\n Note over ${handlerId}: ${entryLabel}\n`;
503
+ }
504
+ for (const call of chain.calls) {
505
+ const fromId = this.sanitizeId(call.from);
506
+ const toId = this.sanitizeId(call.to);
507
+ if (!fromId || !toId)
508
+ continue;
509
+ output += ` ${fromId}->>+${toId}: call\n`;
510
+ output += ` ${toId}-->>-${fromId}: return\n`;
511
+ }
512
+ }
513
+ return output;
514
+ }
515
+ let output = MermaidTemplates.FLOWCHART_INIT + 'flowchart LR\n';
516
+ const pkgGroups = new Map();
517
+ for (const entry of graph.entryPoints) {
518
+ const pkg = entry.package ?? path.dirname(entry.location.file);
519
+ if (!pkgGroups.has(pkg))
520
+ pkgGroups.set(pkg, []);
521
+ pkgGroups.get(pkg).push(entry);
522
+ }
523
+ const pkgPaths = Array.from(pkgGroups.keys());
524
+ const pkgTree = MermaidTemplates.buildPackageTree(pkgPaths);
525
+ const flowDepthMap = new Map();
526
+ const renderEntryPkg = (node, indent, depth) => {
527
+ const sgId = 'grp_' + MermaidTemplates.sanitizeId(node.pkg);
528
+ flowDepthMap.set(sgId, depth);
529
+ output += `${indent}subgraph ${sgId}["${node.pkg}"]\n`;
530
+ for (const child of node.children) {
531
+ renderEntryPkg(child, indent + ' ', depth + 1);
532
+ }
533
+ if (!node.isVirtual) {
534
+ for (const entry of pkgGroups.get(node.pkg) ?? []) {
535
+ const nodeId = MermaidTemplates.sanitizeId(entry.id);
536
+ const label = MermaidTemplates.formatEntryLabel(entry);
537
+ output += `${indent} ${nodeId}["${label}"]:::entry\n`;
538
+ }
539
+ }
540
+ output += `${indent}end\n`;
541
+ };
542
+ for (const root of pkgTree) {
543
+ renderEntryPkg(root, ' ', 0);
544
+ }
545
+ for (const [sgId, sgDepth] of flowDepthMap) {
546
+ const styleStr = MermaidTemplates.SUBGRAPH_DEPTH_STYLES[Math.min(sgDepth, MermaidTemplates.SUBGRAPH_DEPTH_STYLES.length - 1)];
547
+ output += ` style ${sgId} ${styleStr}\n`;
548
+ }
549
+ const handlerNodeIds = new Set(graph.entryPoints.map((e) => this.sanitizeId(e.handler)));
550
+ const declaredNodeIds = new Set(graph.entryPoints.map((e) => this.sanitizeId(e.id)));
551
+ let hasIfaceEdge = false;
552
+ let hasIndirEdge = false;
553
+ const emittedEdges = new Set();
554
+ const addEdge = (from, to, label, callEdge) => {
555
+ const key = `${from}\x00${to}`;
556
+ if (emittedEdges.has(key))
557
+ return;
558
+ emittedEdges.add(key);
559
+ if (callEdge) {
560
+ if (callEdge.type === 'interface') {
561
+ hasIfaceEdge = true;
562
+ output += ` ${from} -.->|iface| ${to}\n`;
563
+ }
564
+ else if (callEdge.type === 'indirect') {
565
+ hasIndirEdge = true;
566
+ output += ` ${from} -.->|indir| ${to}\n`;
567
+ }
568
+ else {
569
+ output += ` ${from} --> ${to}\n`;
570
+ }
571
+ }
572
+ else if (label) {
573
+ output += ` ${from} -->|${label}| ${to}\n`;
574
+ }
575
+ else {
576
+ output += ` ${from} --> ${to}\n`;
577
+ }
578
+ };
579
+ const declareNode = (id, originalName) => {
580
+ if (declaredNodeIds.has(id))
581
+ return;
582
+ declaredNodeIds.add(id);
583
+ const classSuffix = handlerNodeIds.has(id) ? ':::handler' : ':::util';
584
+ output += ` ${id}["${originalName}"]${classSuffix}\n`;
585
+ };
586
+ for (const chain of graph.callChains) {
587
+ const entry = graph.entryPoints.find((e) => e.id === chain.entryPoint);
588
+ if (!entry || chain.calls.length === 0)
589
+ continue;
590
+ const entryNodeId = this.sanitizeId(entry.id);
591
+ const handlerNodeId = this.sanitizeId(entry.handler);
592
+ declareNode(handlerNodeId, entry.handler);
593
+ const entryLabel = `"${chain.calls.length} calls"`;
594
+ addEdge(entryNodeId, handlerNodeId, entryLabel);
595
+ for (const call of chain.calls) {
596
+ const fromId = this.sanitizeId(call.from);
597
+ const toId = this.sanitizeId(call.to);
598
+ if (!fromId || !toId)
599
+ continue;
600
+ declareNode(fromId, call.from);
601
+ declareNode(toId, call.to);
602
+ addEdge(fromId, toId, undefined, call);
603
+ }
604
+ }
605
+ output += '\n subgraph legend["Legend"]\n';
606
+ output += ' direction LR\n';
607
+ output += ' legend_entry["entry point"]:::entry\n';
608
+ output += ' legend_handler["handler"]:::handler\n';
609
+ output += ' legend_util["utility"]:::util\n';
610
+ output += ' legend_edge_calls["\u2192|N calls| entry \u2192 handler"]\n';
611
+ output += ' legend_edge_direct["\u2192 direct call"]\n';
612
+ if (hasIfaceEdge) {
613
+ output += ' legend_edge_iface["-\u00b7\u2192|iface| interface dispatch"]\n';
614
+ }
615
+ if (hasIndirEdge) {
616
+ output += ' legend_edge_indir["-\u00b7\u2192|indir| indirect call"]\n';
617
+ }
618
+ output += ' end\n';
619
+ output += ' style legend fill:#fff8c5,stroke:#d4a72c,stroke-dasharray:5 5,color:#633c01\n';
620
+ output += '\n classDef entry fill:#ffebe9,stroke:#cf222e,color:#82071e\n';
621
+ output += ' classDef handler fill:#ddf4ff,stroke:#54aeff,color:#0550ae\n';
622
+ output += ' classDef util fill:#f6f8fa,stroke:#d0d7de,color:#57606a\n';
623
+ return output;
624
+ }
625
+ static formatEntryLabel(entry) {
626
+ if (entry.protocol === 'http') {
627
+ const m = entry.method ?? 'HTTP';
628
+ return `${m} ${entry.path}`;
629
+ }
630
+ if (entry.protocol === 'grpc')
631
+ return `gRPC ${entry.path}`;
632
+ if (entry.protocol === 'cli')
633
+ return `CMD ${entry.path || entry.handler}`;
634
+ if (entry.protocol === 'message')
635
+ return `MSG ${entry.path}`;
636
+ if (entry.protocol === 'scheduler')
637
+ return `CRON ${entry.path}`;
638
+ return entry.path || entry.id;
639
+ }
640
+ static formatSpawnerLabel(nodeId) {
641
+ const slashIdx = nodeId.lastIndexOf('/');
642
+ const afterSlash = slashIdx >= 0 ? nodeId.slice(slashIdx + 1) : nodeId;
643
+ const parts = afterSlash.split('.');
644
+ return parts.length > 2 ? parts.slice(-2).join('.') : afterSlash;
645
+ }
646
+ static formatChannelLabel(channelId) {
647
+ const withoutPrefix = channelId.startsWith('chan-') ? channelId.slice(5) : channelId;
648
+ const withoutSuffix = withoutPrefix.replace(/-\d+$/, '');
649
+ const slashIdx = withoutSuffix.lastIndexOf('/');
650
+ return slashIdx >= 0 ? withoutSuffix.slice(slashIdx + 1) : withoutSuffix;
651
+ }
652
+ static formatGoroutineName(node) {
653
+ if (node.name) {
654
+ const slashIdx = node.name.lastIndexOf('/');
655
+ const afterSlash = slashIdx >= 0 ? node.name.slice(slashIdx + 1) : node.name;
656
+ const dotIdx = afterSlash.indexOf('.');
657
+ if (dotIdx > 0 && afterSlash.slice(0, dotIdx).includes('-')) {
658
+ const symbol = afterSlash.slice(dotIdx + 1);
659
+ if (symbol.length > 0 &&
660
+ symbol[0] === symbol[0].toUpperCase() &&
661
+ symbol[0] !== symbol[0].toLowerCase()) {
662
+ return symbol;
663
+ }
664
+ }
665
+ return afterSlash;
666
+ }
667
+ const stripped = node.id.replace(/\.spawn-\d+$/, '');
668
+ const afterSlash = stripped.slice(stripped.lastIndexOf('/') + 1);
669
+ const parts = afterSlash.split('.');
670
+ return parts.slice(-2).join('.');
671
+ }
672
+ static getLifecycleTag(nodeId, lifecycle) {
673
+ const entry = lifecycle?.find((l) => l.nodeId === nodeId);
674
+ if (!entry)
675
+ return '';
676
+ if (entry.receivesContext && entry.hasCancellationCheck)
677
+ return ' \u2713ctx';
678
+ if (entry.receivesContext && !entry.cancellationCheckAvailable)
679
+ return ' ctx?';
680
+ if (entry.orphan)
681
+ return ' \u26a0 no exit';
682
+ return '';
683
+ }
684
+ static sanitizeId(id) {
685
+ return id.replace(/[^a-zA-Z0-9_]/g, '_');
686
+ }
687
+ }
688
+ //# sourceMappingURL=mermaid-templates.js.map