@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,610 @@
1
+ import { FileDiscoveryService } from '../utils/file-discovery-service.js';
2
+ import { ParallelParser } from '../../parser/parallel-parser.js';
3
+ import { ArchJSONAggregator } from '../../parser/archjson-aggregator.js';
4
+ import { MetricsCalculator } from '../../parser/metrics-calculator.js';
5
+ import { OutputPathResolver } from '../utils/output-path-resolver.js';
6
+ import { MermaidDiagramGenerator } from '../../mermaid/diagram-generator.js';
7
+ import { ParallelProgressReporter } from '../progress/parallel-progress.js';
8
+ import { MermaidRenderWorkerPool } from '../../mermaid/render-worker-pool.js';
9
+ import { ArchJsonDiskCache } from '../cache/arch-json-disk-cache.js';
10
+ import fs from 'fs-extra';
11
+ import pMap from 'p-map';
12
+ import os from 'os';
13
+ import { createHash } from 'crypto';
14
+ import path from 'path';
15
+ export function deriveSubModuleArchJSON(parent, subPath, workspaceRoot) {
16
+ const normSub = subPath.replace(/\\/g, '/').replace(/\/$/, '');
17
+ let relSub = null;
18
+ if (workspaceRoot) {
19
+ const normRoot = workspaceRoot.replace(/\\/g, '/').replace(/\/$/, '');
20
+ if (normSub.startsWith(normRoot + '/')) {
21
+ relSub = normSub.slice(normRoot.length + 1);
22
+ }
23
+ else if (normSub === normRoot) {
24
+ relSub = '';
25
+ }
26
+ }
27
+ const entities = parent.entities.filter((e) => {
28
+ let fp = (e.filePath ?? '').replace(/\\/g, '/');
29
+ if (!fp && e.name && e.id.endsWith('.' + e.name)) {
30
+ fp = e.id.slice(0, e.id.length - e.name.length - 1).replace(/\\/g, '/');
31
+ }
32
+ if (e.sourceLocation?.file && (!fp || (!fp.includes('/') && !fp.includes('.')))) {
33
+ fp = e.sourceLocation.file.replace(/\\/g, '/');
34
+ }
35
+ if (!fp)
36
+ return false;
37
+ if (fp.startsWith(normSub + '/') || fp === normSub)
38
+ return true;
39
+ if (relSub !== null) {
40
+ if (relSub === '')
41
+ return true;
42
+ if (fp.startsWith(relSub + '/') || fp === relSub)
43
+ return true;
44
+ }
45
+ return false;
46
+ });
47
+ const ids = new Set(entities.map((e) => e.id));
48
+ const outgoingRelations = (parent.relations ?? []).filter((r) => ids.has(r.source));
49
+ const crossModuleTargetIds = new Set(outgoingRelations
50
+ .filter((r) => !ids.has(r.target))
51
+ .map((r) => r.target));
52
+ const stubEntities = parent.entities
53
+ .filter((e) => crossModuleTargetIds.has(e.id))
54
+ .map((e) => ({ ...e, members: [] }));
55
+ const allModuleEntities = [...entities, ...stubEntities];
56
+ const relations = outgoingRelations;
57
+ let extensions = parent.extensions;
58
+ const mg = parent.extensions?.tsAnalysis?.moduleGraph;
59
+ if (mg) {
60
+ const parts = normSub.split('/').filter(Boolean);
61
+ const relPrefix = parts.length >= 2 ? parts.slice(-2).join('/') : parts[parts.length - 1] ?? normSub;
62
+ const filteredNodes = mg.nodes.filter((n) => n.id === relPrefix || n.id.startsWith(relPrefix + '/'));
63
+ const filteredNodeIds = new Set(filteredNodes.map((n) => n.id));
64
+ const filteredEdges = mg.edges.filter((e) => filteredNodeIds.has(e.from) && filteredNodeIds.has(e.to));
65
+ const filteredCycles = (mg.cycles ?? []).filter((c) => c.modules.every((m) => filteredNodeIds.has(m)));
66
+ extensions = {
67
+ ...parent.extensions,
68
+ tsAnalysis: {
69
+ ...parent.extensions.tsAnalysis,
70
+ moduleGraph: {
71
+ nodes: filteredNodes,
72
+ edges: filteredEdges,
73
+ cycles: filteredCycles,
74
+ },
75
+ },
76
+ };
77
+ }
78
+ return { ...parent, entities: allModuleEntities, relations, extensions };
79
+ }
80
+ export class DiagramProcessor {
81
+ diagrams;
82
+ globalConfig;
83
+ progress;
84
+ fileDiscovery;
85
+ aggregator;
86
+ metricsCalculator;
87
+ parallelProgress;
88
+ parseCache;
89
+ registry;
90
+ archJsonDiskCache;
91
+ constructor(options) {
92
+ if (options.diagrams.length === 0) {
93
+ throw new Error('At least one diagram configuration is required');
94
+ }
95
+ this.diagrams = options.diagrams;
96
+ this.globalConfig = options.globalConfig;
97
+ this.progress = options.progress;
98
+ this.fileDiscovery = new FileDiscoveryService();
99
+ this.aggregator = new ArchJSONAggregator();
100
+ this.metricsCalculator = new MetricsCalculator();
101
+ this.parseCache = options.parseCache;
102
+ this.registry = options.registry;
103
+ const diskCacheDir = path.join(os.homedir(), '.archguard', 'cache', 'archjson');
104
+ this.archJsonDiskCache = new ArchJsonDiskCache(diskCacheDir);
105
+ }
106
+ async processAll() {
107
+ const concurrency = this.globalConfig.concurrency || os.cpus().length;
108
+ if (this.diagrams.length > 1) {
109
+ const diagramNames = this.diagrams.map((d) => d.name);
110
+ this.parallelProgress = new ParallelProgressReporter(diagramNames);
111
+ }
112
+ const diagramCount = this.diagrams.length;
113
+ const isGoAtlas = diagramCount === 1 && this.diagrams[0].language === 'go';
114
+ const atlasLayerCount = isGoAtlas
115
+ ? (this.diagrams[0].languageSpecific?.atlas
116
+ ?.layers?.length ?? 4)
117
+ : 0;
118
+ const effectiveDiagramCount = Math.max(diagramCount, atlasLayerCount);
119
+ const poolSize = effectiveDiagramCount >= 2 ? Math.min(os.cpus().length, effectiveDiagramCount, 4) : 0;
120
+ const poolTheme = typeof this.globalConfig.mermaid?.theme === 'string'
121
+ ? this.globalConfig.mermaid.theme
122
+ : this.globalConfig.mermaid?.theme?.name ?? 'default';
123
+ const pool = poolSize > 0
124
+ ? new MermaidRenderWorkerPool(poolSize, {
125
+ theme: poolTheme,
126
+ backgroundColor: this.globalConfig.mermaid?.transparentBackground ? 'transparent' : 'white',
127
+ })
128
+ : null;
129
+ if (pool)
130
+ await pool.start();
131
+ try {
132
+ const sourceGroups = this.groupDiagramsBySource();
133
+ const groupResults = await pMap(Array.from(sourceGroups.entries()), async ([sourceKey, diagrams]) => {
134
+ return await this.processSourceGroup(sourceKey, diagrams, pool);
135
+ }, { concurrency: Math.min(concurrency, sourceGroups.size) });
136
+ const results = groupResults.flat();
137
+ if (process.env.ArchGuardDebug === 'true') {
138
+ console.debug(`πŸ“Š Cache stats: ${this.archJsonCache.size} entries`);
139
+ }
140
+ return results;
141
+ }
142
+ finally {
143
+ await pool?.terminate();
144
+ if (this.parallelProgress) {
145
+ this.parallelProgress.stop();
146
+ }
147
+ }
148
+ }
149
+ groupDiagramsBySource() {
150
+ const sourceGroups = new Map();
151
+ for (const diagram of this.diagrams) {
152
+ const key = this.hashSources(diagram.sources);
153
+ if (!sourceGroups.has(key)) {
154
+ sourceGroups.set(key, []);
155
+ }
156
+ sourceGroups.get(key).push(diagram);
157
+ }
158
+ return sourceGroups;
159
+ }
160
+ hashSources(sources) {
161
+ const normalized = sources
162
+ .map((s) => s.replace(/\\/g, '/'))
163
+ .sort()
164
+ .join('|');
165
+ return createHash('sha256').update(normalized).digest('hex').slice(0, 8);
166
+ }
167
+ cacheArchJson(sources, archJson) {
168
+ const key = this.hashSources(sources);
169
+ this.archJsonCache.set(key, archJson);
170
+ for (const s of sources) {
171
+ this.archJsonPathIndex.set(s.replace(/\\/g, '/'), key);
172
+ }
173
+ }
174
+ registerDeferred(sources, parsePromise) {
175
+ const key = this.hashSources(sources);
176
+ const withCaching = parsePromise.then((result) => {
177
+ this.cacheArchJson(sources, result);
178
+ this.archJsonDeferred.delete(key);
179
+ return result;
180
+ });
181
+ this.archJsonDeferred.set(key, { promise: withCaching, sources });
182
+ return withCaching;
183
+ }
184
+ findParentCoverage(sources) {
185
+ const normSources = sources.map((s) => s.replace(/\\/g, '/'));
186
+ for (const [indexedPath] of this.archJsonPathIndex) {
187
+ if (normSources.every((s) => s.startsWith(indexedPath + '/') || s === indexedPath)) {
188
+ return { deferred: null, normParentPath: indexedPath };
189
+ }
190
+ }
191
+ for (const [, { promise, sources: parentSources }] of this.archJsonDeferred) {
192
+ const normParentSources = parentSources.map((ps) => ps.replace(/\\/g, '/'));
193
+ const matchedParent = normParentSources.find((ps) => normSources.every((s) => s.startsWith(ps + '/') || s === ps));
194
+ if (matchedParent) {
195
+ return { deferred: promise, normParentPath: matchedParent };
196
+ }
197
+ }
198
+ return { deferred: null, normParentPath: null };
199
+ }
200
+ archJsonCache = new Map();
201
+ archJsonPathIndex = new Map();
202
+ archJsonDeferred = new Map();
203
+ async processSourceGroup(sourceKey, diagrams, pool = null) {
204
+ if (!this.parallelProgress && diagrams.length === 1) {
205
+ this.progress.start(`Processing diagram: ${diagrams[0].name}`);
206
+ }
207
+ try {
208
+ const firstDiagram = diagrams[0];
209
+ if (firstDiagram.language === 'go') {
210
+ const rawArchJSON = await this.registerDeferred(firstDiagram.sources, this.parseGoProject(firstDiagram));
211
+ const results = await pMap(diagrams, async (diagram) => this.processDiagramWithArchJSON(diagram, rawArchJSON, pool), { concurrency: this.globalConfig.concurrency || os.cpus().length });
212
+ return results;
213
+ }
214
+ if (firstDiagram.language === 'cpp') {
215
+ const { deferred, normParentPath } = this.findParentCoverage(firstDiagram.sources);
216
+ let rawArchJSON;
217
+ if (deferred) {
218
+ const parentArchJSON = await deferred;
219
+ rawArchJSON = deriveSubModuleArchJSON(parentArchJSON, firstDiagram.sources[0], normParentPath ?? undefined);
220
+ }
221
+ else if (normParentPath) {
222
+ const parentCacheKey = this.archJsonPathIndex.get(normParentPath);
223
+ const parentArchJSON = this.archJsonCache.get(parentCacheKey);
224
+ rawArchJSON = deriveSubModuleArchJSON(parentArchJSON, firstDiagram.sources[0], normParentPath);
225
+ }
226
+ else {
227
+ rawArchJSON = await this.registerDeferred(firstDiagram.sources, this.parseCppProject(firstDiagram));
228
+ }
229
+ const results = await pMap(diagrams, async (diagram) => this.processDiagramWithArchJSON(diagram, rawArchJSON, pool), { concurrency: this.globalConfig.concurrency || os.cpus().length });
230
+ return results;
231
+ }
232
+ const needsModuleGraph = diagrams.some((d) => d.level === 'package');
233
+ if (needsModuleGraph && (!firstDiagram.language || firstDiagram.language === 'typescript')) {
234
+ const tsFiles = await this.fileDiscovery.discoverFiles({
235
+ sources: firstDiagram.sources,
236
+ exclude: firstDiagram.exclude || this.globalConfig.exclude,
237
+ skipMissing: false,
238
+ });
239
+ const diskCacheEnabled = this.globalConfig.cache?.enabled !== false;
240
+ const diskKey = diskCacheEnabled && tsFiles.length > 0 ? await this.archJsonDiskCache.computeKey(tsFiles) : null;
241
+ let cachedArchJSON = null;
242
+ if (diskKey) {
243
+ cachedArchJSON = await this.archJsonDiskCache.get(diskKey);
244
+ if (cachedArchJSON && process.env.ArchGuardDebug === 'true') {
245
+ console.debug(`πŸ’Ύ Disk cache hit for ts-morph path: ${firstDiagram.sources.join(', ')}`);
246
+ }
247
+ }
248
+ const rawArchJSON = cachedArchJSON
249
+ ? cachedArchJSON
250
+ : await this.registerDeferred(firstDiagram.sources, this.parseTsProject(firstDiagram).then(async (result) => {
251
+ if (diskKey)
252
+ await this.archJsonDiskCache.set(diskKey, result);
253
+ return result;
254
+ }));
255
+ const results = await pMap(diagrams, async (diagram) => this.processDiagramWithArchJSON(diagram, rawArchJSON, pool), { concurrency: this.globalConfig.concurrency || os.cpus().length });
256
+ return results;
257
+ }
258
+ const files = await this.fileDiscovery.discoverFiles({
259
+ sources: diagrams[0].sources,
260
+ exclude: diagrams[0].exclude || this.globalConfig.exclude,
261
+ skipMissing: false,
262
+ });
263
+ if (files.length === 0) {
264
+ throw new Error(`No TypeScript files found in sources: ${diagrams[0].sources.join(', ')}`);
265
+ }
266
+ let rawArchJSON = this.archJsonCache.get(sourceKey);
267
+ if (!rawArchJSON) {
268
+ const { deferred, normParentPath } = this.findParentCoverage(diagrams[0].sources);
269
+ if (deferred) {
270
+ const parentArchJSON = await deferred;
271
+ rawArchJSON = deriveSubModuleArchJSON(parentArchJSON, diagrams[0].sources[0], normParentPath ?? undefined);
272
+ if (process.env.ArchGuardDebug === 'true') {
273
+ console.debug(`πŸ”— Awaited parent and derived ArchJSON for ${diagrams[0].sources.join(', ')} from ${normParentPath}`);
274
+ }
275
+ }
276
+ else if (normParentPath) {
277
+ const parentCacheKey = this.archJsonPathIndex.get(normParentPath);
278
+ const parentArchJSON = this.archJsonCache.get(parentCacheKey);
279
+ rawArchJSON = deriveSubModuleArchJSON(parentArchJSON, diagrams[0].sources[0], normParentPath);
280
+ if (process.env.ArchGuardDebug === 'true') {
281
+ console.debug(`πŸ”— Derived ArchJSON for ${diagrams[0].sources.join(', ')} from ${normParentPath}`);
282
+ }
283
+ }
284
+ else {
285
+ if (process.env.ArchGuardDebug === 'true') {
286
+ console.debug(`πŸ” Cache miss for ${sourceKey}: ${diagrams[0].sources.join(', ')}`);
287
+ }
288
+ const diskCacheEnabled2 = this.globalConfig.cache?.enabled !== false;
289
+ const diskKey = diskCacheEnabled2 ? await this.archJsonDiskCache.computeKey(files) : null;
290
+ const diskCached = diskKey ? await this.archJsonDiskCache.get(diskKey) : null;
291
+ if (diskCached) {
292
+ rawArchJSON = diskCached;
293
+ if (process.env.ArchGuardDebug === 'true') {
294
+ console.debug(`πŸ’Ύ Disk cache hit for ParallelParser path: ${diagrams[0].sources.join(', ')}`);
295
+ }
296
+ }
297
+ else {
298
+ const parser = new ParallelParser({
299
+ concurrency: this.globalConfig.concurrency,
300
+ continueOnError: true,
301
+ parseCache: this.parseCache,
302
+ });
303
+ rawArchJSON = await parser.parseFiles(files);
304
+ if (diskKey)
305
+ await this.archJsonDiskCache.set(diskKey, rawArchJSON);
306
+ }
307
+ this.cacheArchJson(diagrams[0].sources, rawArchJSON);
308
+ }
309
+ }
310
+ else if (process.env.ArchGuardDebug === 'true') {
311
+ console.debug(`πŸ“¦ Cache hit for ${sourceKey}: ${diagrams[0].sources.join(', ')}`);
312
+ }
313
+ const results = await pMap(diagrams, async (diagram) => {
314
+ return await this.processDiagramWithArchJSON(diagram, rawArchJSON, pool);
315
+ }, { concurrency: this.globalConfig.concurrency || os.cpus().length });
316
+ return results;
317
+ }
318
+ catch (error) {
319
+ const errorMessage = error instanceof Error ? error.message : String(error);
320
+ return diagrams.map((diagram) => ({
321
+ name: diagram.name,
322
+ success: false,
323
+ error: errorMessage,
324
+ }));
325
+ }
326
+ }
327
+ async processDiagramWithArchJSON(diagram, rawArchJSON, pool = null) {
328
+ const startTime = Date.now();
329
+ try {
330
+ if (!this.parallelProgress) {
331
+ this.progress.start(`Processing diagram: ${diagram.name}`);
332
+ }
333
+ if (this.parallelProgress) {
334
+ this.parallelProgress.update(diagram.name, 50, 'Aggregating');
335
+ }
336
+ const aggregatedJSON = this.aggregator.aggregate(rawArchJSON, diagram.level);
337
+ if (this.parallelProgress) {
338
+ this.parallelProgress.update(diagram.name, 60, 'Preparing output');
339
+ }
340
+ const pathResolver = new OutputPathResolver({
341
+ outputDir: this.globalConfig.outputDir,
342
+ output: undefined,
343
+ });
344
+ const paths = pathResolver.resolve({ name: diagram.name });
345
+ await pathResolver.ensureDirectory({ name: diagram.name });
346
+ if (this.parallelProgress) {
347
+ this.parallelProgress.update(diagram.name, 70, 'Generating output');
348
+ }
349
+ const format = diagram.format || this.globalConfig.format;
350
+ const outputJSON = format === 'json'
351
+ ? { ...aggregatedJSON, metrics: this.metricsCalculator.calculate(aggregatedJSON, diagram.level) }
352
+ : aggregatedJSON;
353
+ await this.generateOutput(outputJSON, paths, format, diagram.level, diagram, pool);
354
+ if (this.parallelProgress) {
355
+ this.parallelProgress.update(diagram.name, 90, 'Finalizing');
356
+ }
357
+ const parseTime = Date.now() - startTime;
358
+ if (this.parallelProgress) {
359
+ this.parallelProgress.complete(diagram.name);
360
+ }
361
+ else {
362
+ this.progress.succeed(`Diagram ${diagram.name} completed`);
363
+ }
364
+ const resultPaths = {};
365
+ if (format === 'json') {
366
+ resultPaths.json = paths.paths.json;
367
+ }
368
+ else if (format === 'mermaid') {
369
+ resultPaths.mmd = paths.paths.mmd;
370
+ resultPaths.svg = paths.paths.svg;
371
+ resultPaths.png = paths.paths.png;
372
+ }
373
+ const moduleGraph = aggregatedJSON.extensions?.tsAnalysis?.moduleGraph;
374
+ const usesModuleGraph = diagram.level === 'package' && !!moduleGraph;
375
+ return {
376
+ name: diagram.name,
377
+ success: true,
378
+ paths: resultPaths,
379
+ stats: {
380
+ entities: usesModuleGraph ? moduleGraph.nodes.length : aggregatedJSON.entities.length,
381
+ relations: usesModuleGraph ? moduleGraph.edges.length : aggregatedJSON.relations.length,
382
+ parseTime,
383
+ },
384
+ };
385
+ }
386
+ catch (error) {
387
+ const errorMessage = error instanceof Error ? error.message : String(error);
388
+ if (this.parallelProgress) {
389
+ this.parallelProgress.fail(diagram.name);
390
+ }
391
+ else {
392
+ this.progress.fail(`Diagram ${diagram.name} failed: ${errorMessage}`);
393
+ }
394
+ return {
395
+ name: diagram.name,
396
+ success: false,
397
+ error: errorMessage,
398
+ };
399
+ }
400
+ }
401
+ async parseGoProject(diagram) {
402
+ const workspaceRoot = path.resolve(diagram.sources[0]);
403
+ const registryPlugin = this.registry?.getByName('golang');
404
+ const plugin = registryPlugin ?? await (async () => {
405
+ const { GoAtlasPlugin } = await import('../../plugins/golang/atlas/index.js');
406
+ return new GoAtlasPlugin();
407
+ })();
408
+ await plugin.initialize({ workspaceRoot });
409
+ return plugin.parseProject(workspaceRoot, {
410
+ workspaceRoot,
411
+ excludePatterns: diagram.exclude ?? this.globalConfig.exclude ?? [],
412
+ languageSpecific: diagram.languageSpecific,
413
+ });
414
+ }
415
+ async parseCppProject(diagram) {
416
+ const workspaceRoot = path.resolve(diagram.sources[0]);
417
+ const registryPlugin = this.registry?.getByName('cpp');
418
+ const plugin = registryPlugin ?? await (async () => {
419
+ const { CppPlugin } = await import('../../plugins/cpp/index.js');
420
+ return new CppPlugin();
421
+ })();
422
+ await plugin.initialize({ workspaceRoot });
423
+ return plugin.parseProject(workspaceRoot, {
424
+ workspaceRoot,
425
+ excludePatterns: diagram.exclude ?? this.globalConfig.exclude ?? [],
426
+ });
427
+ }
428
+ async parseTsProject(diagram) {
429
+ const workspaceRoot = path.resolve(diagram.sources[0]);
430
+ const registryPlugin = this.registry?.getByName('typescript');
431
+ const plugin = registryPlugin ?? await (async () => {
432
+ const { TypeScriptPlugin } = await import('../../plugins/typescript/index.js');
433
+ return new TypeScriptPlugin();
434
+ })();
435
+ await plugin.initialize({ workspaceRoot });
436
+ return plugin.parseProject(workspaceRoot, {
437
+ workspaceRoot,
438
+ excludePatterns: diagram.exclude ?? this.globalConfig.exclude ?? [],
439
+ });
440
+ }
441
+ async generateOutput(archJSON, paths, format, level, diagram, pool = null) {
442
+ switch (format) {
443
+ case 'json':
444
+ await fs.writeJson(paths.paths.json, archJSON, { spaces: 2 });
445
+ break;
446
+ case 'mermaid':
447
+ if (archJSON.extensions?.goAtlas) {
448
+ await this.generateAtlasOutput(archJSON, paths, diagram, pool);
449
+ }
450
+ else if (level === 'package' && archJSON.extensions?.tsAnalysis?.moduleGraph) {
451
+ await this.generateTsModuleGraphOutput(archJSON, paths, diagram, pool);
452
+ }
453
+ else if (level === 'package' && archJSON.language === 'cpp') {
454
+ await this.generateCppPackageOutput(archJSON, paths, pool);
455
+ }
456
+ else {
457
+ const mermaidGenerator = new MermaidDiagramGenerator(this.globalConfig, this.progress);
458
+ await mermaidGenerator.generateAndRender(archJSON, {
459
+ outputDir: paths.paths.mmd.replace(/\/[^/]+$/, ''),
460
+ baseName: paths.paths.mmd.replace(/^.*\/([^/]+)\.mmd$/, '$1'),
461
+ paths: paths.paths,
462
+ }, level, diagram);
463
+ }
464
+ break;
465
+ default:
466
+ const exhaustiveCheck = format;
467
+ throw new Error(`Unsupported format: ${exhaustiveCheck}`);
468
+ }
469
+ }
470
+ async generateAtlasOutput(archJSON, paths, diagram, pool = null) {
471
+ const { AtlasRenderer } = await import('../../plugins/golang/atlas/renderers/atlas-renderer.js');
472
+ const { IsomorphicMermaidRenderer } = await import('../../mermaid/renderer.js');
473
+ const atlas = archJSON.extensions.goAtlas;
474
+ const renderer = new AtlasRenderer();
475
+ const requestedLayers = diagram.languageSpecific?.atlas?.layers ?? ['package', 'capability', 'goroutine', 'flow'];
476
+ const availableLayers = requestedLayers.filter((layer) => atlas.layers[layer]);
477
+ const basePath = paths.paths.mmd.replace(/\.mmd$/, '');
478
+ const rendererOptions = {};
479
+ if (this.globalConfig.mermaid?.theme) {
480
+ rendererOptions.theme =
481
+ typeof this.globalConfig.mermaid.theme === 'string'
482
+ ? { name: this.globalConfig.mermaid.theme }
483
+ : this.globalConfig.mermaid.theme;
484
+ }
485
+ if (this.globalConfig.mermaid?.transparentBackground) {
486
+ rendererOptions.backgroundColor = 'transparent';
487
+ }
488
+ const mermaidRenderer = new IsomorphicMermaidRenderer(rendererOptions);
489
+ console.log('\nπŸ—ΊοΈ Generating Go Architecture Atlas...');
490
+ await Promise.all(availableLayers.map(async (layer) => {
491
+ const result = await renderer.render(atlas, layer, 'mermaid');
492
+ const layerPaths = {
493
+ mmd: `${basePath}-${layer}.mmd`,
494
+ svg: `${basePath}-${layer}.svg`,
495
+ png: `${basePath}-${layer}.png`,
496
+ };
497
+ await fs.ensureDir(path.dirname(layerPaths.mmd));
498
+ await fs.writeFile(layerPaths.mmd, result.content, 'utf-8');
499
+ let svg;
500
+ if (pool) {
501
+ const poolResult = await pool.render({ mermaidCode: result.content });
502
+ if (!poolResult.success) {
503
+ console.warn(` Worker render failed: ${poolResult.error} β€” falling back to main thread`);
504
+ svg = await mermaidRenderer.renderSVG(result.content);
505
+ }
506
+ else {
507
+ svg = poolResult.svg;
508
+ }
509
+ }
510
+ else {
511
+ svg = await mermaidRenderer.renderSVG(result.content);
512
+ }
513
+ let pngFailed = false;
514
+ await Promise.all([
515
+ fs.writeFile(layerPaths.svg, svg, 'utf-8'),
516
+ mermaidRenderer.convertSVGToPNG(svg, layerPaths.png).catch((err) => {
517
+ const msg = err instanceof Error ? err.message : String(err);
518
+ console.warn(` ⚠️ ${layer} PNG skipped (${msg}) β€” MMD + SVG saved`);
519
+ pngFailed = true;
520
+ }),
521
+ ]);
522
+ console.log(` βœ… ${layer}: ${layerPaths.mmd}${pngFailed ? ' (no PNG)' : ''}`);
523
+ }));
524
+ const atlasJsonPath = `${basePath}-atlas.json`;
525
+ await fs.writeJson(atlasJsonPath, atlas, { spaces: 2 });
526
+ console.log(` πŸ“Š Atlas JSON: ${atlasJsonPath}`);
527
+ console.log(`\n✨ Atlas layers: ${availableLayers.join(', ')}`);
528
+ }
529
+ async generateTsModuleGraphOutput(archJSON, paths, _diagram, pool = null) {
530
+ const { renderTsModuleGraph } = await import('../../mermaid/ts-module-graph-renderer.js');
531
+ const { IsomorphicMermaidRenderer } = await import('../../mermaid/renderer.js');
532
+ const moduleGraph = archJSON.extensions.tsAnalysis.moduleGraph;
533
+ const mmdContent = renderTsModuleGraph(moduleGraph);
534
+ const rendererOptions = {};
535
+ if (this.globalConfig.mermaid?.theme) {
536
+ rendererOptions.theme =
537
+ typeof this.globalConfig.mermaid.theme === 'string'
538
+ ? { name: this.globalConfig.mermaid.theme }
539
+ : this.globalConfig.mermaid.theme;
540
+ }
541
+ if (this.globalConfig.mermaid?.transparentBackground) {
542
+ rendererOptions.backgroundColor = 'transparent';
543
+ }
544
+ const mermaidRenderer = new IsomorphicMermaidRenderer(rendererOptions);
545
+ await fs.ensureDir(path.dirname(paths.paths.mmd));
546
+ await fs.writeFile(paths.paths.mmd, mmdContent, 'utf-8');
547
+ let svg;
548
+ if (pool) {
549
+ const poolResult = await pool.render({ mermaidCode: mmdContent });
550
+ if (!poolResult.success) {
551
+ console.warn(` Worker render failed: ${poolResult.error} β€” falling back to main thread`);
552
+ svg = await mermaidRenderer.renderSVG(mmdContent);
553
+ }
554
+ else {
555
+ svg = poolResult.svg;
556
+ }
557
+ }
558
+ else {
559
+ svg = await mermaidRenderer.renderSVG(mmdContent);
560
+ }
561
+ await Promise.all([
562
+ fs.writeFile(paths.paths.svg, svg, 'utf-8'),
563
+ mermaidRenderer.convertSVGToPNG(svg, paths.paths.png).catch((err) => {
564
+ const msg = err instanceof Error ? err.message : String(err);
565
+ console.warn(` TS module graph PNG skipped (${msg}) β€” MMD + SVG saved`);
566
+ }),
567
+ ]);
568
+ }
569
+ async generateCppPackageOutput(archJSON, paths, pool = null) {
570
+ const { CppPackageFlowchartGenerator } = await import('../../mermaid/cpp-package-flowchart-generator.js');
571
+ const { IsomorphicMermaidRenderer } = await import('../../mermaid/renderer.js');
572
+ const generator = new CppPackageFlowchartGenerator();
573
+ const mmdContent = generator.generate(archJSON);
574
+ const rendererOptions = {};
575
+ if (this.globalConfig.mermaid?.theme) {
576
+ rendererOptions.theme =
577
+ typeof this.globalConfig.mermaid.theme === 'string'
578
+ ? { name: this.globalConfig.mermaid.theme }
579
+ : this.globalConfig.mermaid.theme;
580
+ }
581
+ if (this.globalConfig.mermaid?.transparentBackground) {
582
+ rendererOptions.backgroundColor = 'transparent';
583
+ }
584
+ const mermaidRenderer = new IsomorphicMermaidRenderer(rendererOptions);
585
+ await fs.ensureDir(path.dirname(paths.paths.mmd));
586
+ await fs.writeFile(paths.paths.mmd, mmdContent, 'utf-8');
587
+ let svg;
588
+ if (pool) {
589
+ const poolResult = await pool.render({ mermaidCode: mmdContent });
590
+ if (!poolResult.success) {
591
+ console.warn(` Worker render failed: ${poolResult.error} β€” falling back to main thread`);
592
+ svg = await mermaidRenderer.renderSVG(mmdContent);
593
+ }
594
+ else {
595
+ svg = poolResult.svg;
596
+ }
597
+ }
598
+ else {
599
+ svg = await mermaidRenderer.renderSVG(mmdContent);
600
+ }
601
+ await Promise.all([
602
+ fs.writeFile(paths.paths.svg, svg, 'utf-8'),
603
+ mermaidRenderer.convertSVGToPNG(svg, paths.paths.png).catch((err) => {
604
+ const msg = err instanceof Error ? err.message : String(err);
605
+ console.warn(` C++ package graph PNG skipped (${msg}) β€” MMD + SVG saved`);
606
+ }),
607
+ ]);
608
+ }
609
+ }
610
+ //# sourceMappingURL=diagram-processor.js.map