@mycodemap/mycodemap 1.9.0 → 2.7.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 (527) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +63 -978
  3. package/README.zh-CN.md +1096 -0
  4. package/dist/cli/commands/agent-metrics/human.d.ts +4 -0
  5. package/dist/cli/commands/agent-metrics/human.d.ts.map +1 -0
  6. package/dist/cli/commands/agent-metrics/human.js +134 -0
  7. package/dist/cli/commands/agent-metrics/human.js.map +1 -0
  8. package/dist/cli/commands/agent-metrics/index.d.ts +15 -0
  9. package/dist/cli/commands/agent-metrics/index.d.ts.map +1 -0
  10. package/dist/cli/commands/agent-metrics/index.js +116 -0
  11. package/dist/cli/commands/agent-metrics/index.js.map +1 -0
  12. package/dist/cli/commands/analyze-options.d.ts.map +1 -1
  13. package/dist/cli/commands/analyze-options.js +8 -0
  14. package/dist/cli/commands/analyze-options.js.map +1 -1
  15. package/dist/cli/commands/analyze.d.ts +3 -196
  16. package/dist/cli/commands/analyze.d.ts.map +1 -1
  17. package/dist/cli/commands/analyze.js +27 -1162
  18. package/dist/cli/commands/analyze.js.map +1 -1
  19. package/dist/cli/commands/benchmark.d.ts +8 -0
  20. package/dist/cli/commands/benchmark.d.ts.map +1 -0
  21. package/dist/cli/commands/benchmark.js +153 -0
  22. package/dist/cli/commands/benchmark.js.map +1 -0
  23. package/dist/cli/commands/complexity.d.ts.map +1 -1
  24. package/dist/cli/commands/complexity.js +62 -95
  25. package/dist/cli/commands/complexity.js.map +1 -1
  26. package/dist/cli/commands/deps.d.ts +3 -59
  27. package/dist/cli/commands/deps.d.ts.map +1 -1
  28. package/dist/cli/commands/deps.js +25 -331
  29. package/dist/cli/commands/deps.js.map +1 -1
  30. package/dist/cli/commands/doctor.d.ts +3 -0
  31. package/dist/cli/commands/doctor.d.ts.map +1 -0
  32. package/dist/cli/commands/doctor.js +34 -0
  33. package/dist/cli/commands/doctor.js.map +1 -0
  34. package/dist/cli/commands/env-contract.d.ts +3 -0
  35. package/dist/cli/commands/env-contract.d.ts.map +1 -0
  36. package/dist/cli/commands/env-contract.js +221 -0
  37. package/dist/cli/commands/env-contract.js.map +1 -0
  38. package/dist/cli/commands/generate.d.ts +19 -1
  39. package/dist/cli/commands/generate.d.ts.map +1 -1
  40. package/dist/cli/commands/generate.js +735 -89
  41. package/dist/cli/commands/generate.js.map +1 -1
  42. package/dist/cli/commands/impact.d.ts +4 -38
  43. package/dist/cli/commands/impact.d.ts.map +1 -1
  44. package/dist/cli/commands/impact.js +133 -375
  45. package/dist/cli/commands/impact.js.map +1 -1
  46. package/dist/cli/commands/init.d.ts +1 -0
  47. package/dist/cli/commands/init.d.ts.map +1 -1
  48. package/dist/cli/commands/init.js +61 -2
  49. package/dist/cli/commands/init.js.map +1 -1
  50. package/dist/cli/commands/preview.d.ts +3 -0
  51. package/dist/cli/commands/preview.d.ts.map +1 -0
  52. package/dist/cli/commands/preview.js +216 -0
  53. package/dist/cli/commands/preview.js.map +1 -0
  54. package/dist/cli/commands/query.d.ts +2 -20
  55. package/dist/cli/commands/query.d.ts.map +1 -1
  56. package/dist/cli/commands/query.js +23 -708
  57. package/dist/cli/commands/query.js.map +1 -1
  58. package/dist/cli/commands/watch-foreground.d.ts.map +1 -1
  59. package/dist/cli/commands/watch-foreground.js +5 -1
  60. package/dist/cli/commands/watch-foreground.js.map +1 -1
  61. package/dist/cli/config-loader.d.ts.map +1 -1
  62. package/dist/cli/config-loader.js +51 -13
  63. package/dist/cli/config-loader.js.map +1 -1
  64. package/dist/cli/doctor/check-agent.d.ts +3 -0
  65. package/dist/cli/doctor/check-agent.d.ts.map +1 -0
  66. package/dist/cli/doctor/check-agent.js +60 -0
  67. package/dist/cli/doctor/check-agent.js.map +1 -0
  68. package/dist/cli/doctor/check-env-contract.d.ts +3 -0
  69. package/dist/cli/doctor/check-env-contract.d.ts.map +1 -0
  70. package/dist/cli/doctor/check-env-contract.js +96 -0
  71. package/dist/cli/doctor/check-env-contract.js.map +1 -0
  72. package/dist/cli/doctor/check-ghost-commands.d.ts +3 -0
  73. package/dist/cli/doctor/check-ghost-commands.d.ts.map +1 -0
  74. package/dist/cli/doctor/check-ghost-commands.js +86 -0
  75. package/dist/cli/doctor/check-ghost-commands.js.map +1 -0
  76. package/dist/cli/doctor/check-native-deps.d.ts +3 -0
  77. package/dist/cli/doctor/check-native-deps.d.ts.map +1 -0
  78. package/dist/cli/doctor/check-native-deps.js +70 -0
  79. package/dist/cli/doctor/check-native-deps.js.map +1 -0
  80. package/dist/cli/doctor/check-workspace-drift.d.ts +3 -0
  81. package/dist/cli/doctor/check-workspace-drift.d.ts.map +1 -0
  82. package/dist/cli/doctor/check-workspace-drift.js +83 -0
  83. package/dist/cli/doctor/check-workspace-drift.js.map +1 -0
  84. package/dist/cli/doctor/formatter.d.ts +20 -0
  85. package/dist/cli/doctor/formatter.d.ts.map +1 -0
  86. package/dist/cli/doctor/formatter.js +91 -0
  87. package/dist/cli/doctor/formatter.js.map +1 -0
  88. package/dist/cli/doctor/index.d.ts +8 -0
  89. package/dist/cli/doctor/index.d.ts.map +1 -0
  90. package/dist/cli/doctor/index.js +9 -0
  91. package/dist/cli/doctor/index.js.map +1 -0
  92. package/dist/cli/doctor/orchestrator.d.ts +3 -0
  93. package/dist/cli/doctor/orchestrator.d.ts.map +1 -0
  94. package/dist/cli/doctor/orchestrator.js +40 -0
  95. package/dist/cli/doctor/orchestrator.js.map +1 -0
  96. package/dist/cli/doctor/types.d.ts +19 -0
  97. package/dist/cli/doctor/types.d.ts.map +1 -0
  98. package/dist/cli/doctor/types.js +4 -0
  99. package/dist/cli/doctor/types.js.map +1 -0
  100. package/dist/cli/env-contract/check.d.ts +18 -0
  101. package/dist/cli/env-contract/check.d.ts.map +1 -0
  102. package/dist/cli/env-contract/check.js +118 -0
  103. package/dist/cli/env-contract/check.js.map +1 -0
  104. package/dist/cli/env-contract/discovery.d.ts +12 -0
  105. package/dist/cli/env-contract/discovery.d.ts.map +1 -0
  106. package/dist/cli/env-contract/discovery.js +249 -0
  107. package/dist/cli/env-contract/discovery.js.map +1 -0
  108. package/dist/cli/env-contract/filters.d.ts +10 -0
  109. package/dist/cli/env-contract/filters.d.ts.map +1 -0
  110. package/dist/cli/env-contract/filters.js +23 -0
  111. package/dist/cli/env-contract/filters.js.map +1 -0
  112. package/dist/cli/env-contract/index.d.ts +6 -0
  113. package/dist/cli/env-contract/index.d.ts.map +1 -0
  114. package/dist/cli/env-contract/index.js +8 -0
  115. package/dist/cli/env-contract/index.js.map +1 -0
  116. package/dist/cli/env-contract/reminder-engine.d.ts +34 -0
  117. package/dist/cli/env-contract/reminder-engine.d.ts.map +1 -0
  118. package/dist/cli/env-contract/reminder-engine.js +51 -0
  119. package/dist/cli/env-contract/reminder-engine.js.map +1 -0
  120. package/dist/cli/env-contract/reminder-hook-runner.d.ts +45 -0
  121. package/dist/cli/env-contract/reminder-hook-runner.d.ts.map +1 -0
  122. package/dist/cli/env-contract/reminder-hook-runner.js +273 -0
  123. package/dist/cli/env-contract/reminder-hook-runner.js.map +1 -0
  124. package/dist/cli/env-contract/reminder-ledger.d.ts +11 -0
  125. package/dist/cli/env-contract/reminder-ledger.d.ts.map +1 -0
  126. package/dist/cli/env-contract/reminder-ledger.js +37 -0
  127. package/dist/cli/env-contract/reminder-ledger.js.map +1 -0
  128. package/dist/cli/env-contract/types.d.ts +48 -0
  129. package/dist/cli/env-contract/types.d.ts.map +1 -0
  130. package/dist/cli/env-contract/types.js +22 -0
  131. package/dist/cli/env-contract/types.js.map +1 -0
  132. package/dist/cli/env-contract/validation.d.ts +10 -0
  133. package/dist/cli/env-contract/validation.d.ts.map +1 -0
  134. package/dist/cli/env-contract/validation.js +116 -0
  135. package/dist/cli/env-contract/validation.js.map +1 -0
  136. package/dist/cli/first-run-guide.d.ts.map +1 -1
  137. package/dist/cli/first-run-guide.js +8 -3
  138. package/dist/cli/first-run-guide.js.map +1 -1
  139. package/dist/cli/index.js +94 -22
  140. package/dist/cli/index.js.map +1 -1
  141. package/dist/cli/init/assistant-plan.d.ts +14 -0
  142. package/dist/cli/init/assistant-plan.d.ts.map +1 -0
  143. package/dist/cli/init/assistant-plan.js +208 -0
  144. package/dist/cli/init/assistant-plan.js.map +1 -0
  145. package/dist/cli/init/detect.d.ts +28 -0
  146. package/dist/cli/init/detect.d.ts.map +1 -0
  147. package/dist/cli/init/detect.js +63 -0
  148. package/dist/cli/init/detect.js.map +1 -0
  149. package/dist/cli/init/env-contract-plan.d.ts +28 -0
  150. package/dist/cli/init/env-contract-plan.d.ts.map +1 -0
  151. package/dist/cli/init/env-contract-plan.js +184 -0
  152. package/dist/cli/init/env-contract-plan.js.map +1 -0
  153. package/dist/cli/init/manifest-extractors.d.ts +22 -0
  154. package/dist/cli/init/manifest-extractors.d.ts.map +1 -0
  155. package/dist/cli/init/manifest-extractors.js +185 -0
  156. package/dist/cli/init/manifest-extractors.js.map +1 -0
  157. package/dist/cli/init/profile-loader.d.ts +49 -0
  158. package/dist/cli/init/profile-loader.d.ts.map +1 -0
  159. package/dist/cli/init/profile-loader.js +107 -0
  160. package/dist/cli/init/profile-loader.js.map +1 -0
  161. package/dist/cli/init/profile-plan.d.ts +38 -0
  162. package/dist/cli/init/profile-plan.d.ts.map +1 -0
  163. package/dist/cli/init/profile-plan.js +120 -0
  164. package/dist/cli/init/profile-plan.js.map +1 -0
  165. package/dist/cli/init/profiles/generic.json +16 -0
  166. package/dist/cli/init/profiles/go.json +12 -0
  167. package/dist/cli/init/profiles/nodejs.json +16 -0
  168. package/dist/cli/init/profiles/python.json +17 -0
  169. package/dist/cli/init/profiles/rust.json +12 -0
  170. package/dist/cli/init/receipt.d.ts.map +1 -1
  171. package/dist/cli/init/receipt.js +107 -7
  172. package/dist/cli/init/receipt.js.map +1 -1
  173. package/dist/cli/init/reconciler.d.ts +10 -1
  174. package/dist/cli/init/reconciler.d.ts.map +1 -1
  175. package/dist/cli/init/reconciler.js +85 -15
  176. package/dist/cli/init/reconciler.js.map +1 -1
  177. package/dist/cli/interface-contract/commands/agent-metrics.d.ts +3 -0
  178. package/dist/cli/interface-contract/commands/agent-metrics.d.ts.map +1 -0
  179. package/dist/cli/interface-contract/commands/agent-metrics.js +217 -0
  180. package/dist/cli/interface-contract/commands/agent-metrics.js.map +1 -0
  181. package/dist/cli/interface-contract/commands/analyze.d.ts +3 -0
  182. package/dist/cli/interface-contract/commands/analyze.d.ts.map +1 -0
  183. package/dist/cli/interface-contract/commands/analyze.js +139 -0
  184. package/dist/cli/interface-contract/commands/analyze.js.map +1 -0
  185. package/dist/cli/interface-contract/commands/benchmark.d.ts +3 -0
  186. package/dist/cli/interface-contract/commands/benchmark.d.ts.map +1 -0
  187. package/dist/cli/interface-contract/commands/benchmark.js +108 -0
  188. package/dist/cli/interface-contract/commands/benchmark.js.map +1 -0
  189. package/dist/cli/interface-contract/commands/deps.d.ts +3 -0
  190. package/dist/cli/interface-contract/commands/deps.d.ts.map +1 -0
  191. package/dist/cli/interface-contract/commands/deps.js +130 -0
  192. package/dist/cli/interface-contract/commands/deps.js.map +1 -0
  193. package/dist/cli/interface-contract/commands/doctor.d.ts +3 -0
  194. package/dist/cli/interface-contract/commands/doctor.d.ts.map +1 -0
  195. package/dist/cli/interface-contract/commands/doctor.js +60 -0
  196. package/dist/cli/interface-contract/commands/doctor.js.map +1 -0
  197. package/dist/cli/interface-contract/commands/env-contract.d.ts +3 -0
  198. package/dist/cli/interface-contract/commands/env-contract.d.ts.map +1 -0
  199. package/dist/cli/interface-contract/commands/env-contract.js +168 -0
  200. package/dist/cli/interface-contract/commands/env-contract.js.map +1 -0
  201. package/dist/cli/interface-contract/commands/index.d.ts +12 -0
  202. package/dist/cli/interface-contract/commands/index.d.ts.map +1 -0
  203. package/dist/cli/interface-contract/commands/index.js +24 -0
  204. package/dist/cli/interface-contract/commands/index.js.map +1 -0
  205. package/dist/cli/interface-contract/commands/init.d.ts +3 -0
  206. package/dist/cli/interface-contract/commands/init.d.ts.map +1 -0
  207. package/dist/cli/interface-contract/commands/init.js +96 -0
  208. package/dist/cli/interface-contract/commands/init.js.map +1 -0
  209. package/dist/cli/interface-contract/commands/preview.d.ts +3 -0
  210. package/dist/cli/interface-contract/commands/preview.d.ts.map +1 -0
  211. package/dist/cli/interface-contract/commands/preview.js +118 -0
  212. package/dist/cli/interface-contract/commands/preview.js.map +1 -0
  213. package/dist/cli/interface-contract/commands/query.d.ts +3 -0
  214. package/dist/cli/interface-contract/commands/query.d.ts.map +1 -0
  215. package/dist/cli/interface-contract/commands/query.js +186 -0
  216. package/dist/cli/interface-contract/commands/query.js.map +1 -0
  217. package/dist/cli/interface-contract/index.d.ts +22 -0
  218. package/dist/cli/interface-contract/index.d.ts.map +1 -0
  219. package/dist/cli/interface-contract/index.js +41 -0
  220. package/dist/cli/interface-contract/index.js.map +1 -0
  221. package/dist/cli/interface-contract/schema.d.ts +30 -0
  222. package/dist/cli/interface-contract/schema.d.ts.map +1 -0
  223. package/dist/cli/interface-contract/schema.js +73 -0
  224. package/dist/cli/interface-contract/schema.js.map +1 -0
  225. package/dist/cli/interface-contract/types.d.ts +77 -0
  226. package/dist/cli/interface-contract/types.d.ts.map +1 -0
  227. package/dist/cli/interface-contract/types.js +4 -0
  228. package/dist/cli/interface-contract/types.js.map +1 -0
  229. package/dist/cli/output/apply-suggestion.d.ts +12 -0
  230. package/dist/cli/output/apply-suggestion.d.ts.map +1 -0
  231. package/dist/cli/output/apply-suggestion.js +29 -0
  232. package/dist/cli/output/apply-suggestion.js.map +1 -0
  233. package/dist/cli/output/error-codes.d.ts +24 -0
  234. package/dist/cli/output/error-codes.d.ts.map +1 -0
  235. package/dist/cli/output/error-codes.js +94 -0
  236. package/dist/cli/output/error-codes.js.map +1 -0
  237. package/dist/cli/output/errors.d.ts +14 -0
  238. package/dist/cli/output/errors.d.ts.map +1 -0
  239. package/dist/cli/output/errors.js +182 -0
  240. package/dist/cli/output/errors.js.map +1 -0
  241. package/dist/cli/output/index.d.ts +13 -0
  242. package/dist/cli/output/index.d.ts.map +1 -0
  243. package/dist/cli/output/index.js +11 -0
  244. package/dist/cli/output/index.js.map +1 -0
  245. package/dist/cli/output/mode.d.ts +12 -0
  246. package/dist/cli/output/mode.d.ts.map +1 -0
  247. package/dist/cli/output/mode.js +23 -0
  248. package/dist/cli/output/mode.js.map +1 -0
  249. package/dist/cli/output/progress.d.ts +9 -0
  250. package/dist/cli/output/progress.d.ts.map +1 -0
  251. package/dist/cli/output/progress.js +65 -0
  252. package/dist/cli/output/progress.js.map +1 -0
  253. package/dist/cli/output/render.d.ts +11 -0
  254. package/dist/cli/output/render.d.ts.map +1 -0
  255. package/dist/cli/output/render.js +18 -0
  256. package/dist/cli/output/render.js.map +1 -0
  257. package/dist/cli/output/types.d.ts +53 -0
  258. package/dist/cli/output/types.d.ts.map +1 -0
  259. package/dist/cli/output/types.js +14 -0
  260. package/dist/cli/output/types.js.map +1 -0
  261. package/dist/cli/output/wasm-fallback.d.ts +14 -0
  262. package/dist/cli/output/wasm-fallback.d.ts.map +1 -0
  263. package/dist/cli/output/wasm-fallback.js +92 -0
  264. package/dist/cli/output/wasm-fallback.js.map +1 -0
  265. package/dist/cli/preview/complexity-scanner.d.ts +21 -0
  266. package/dist/cli/preview/complexity-scanner.d.ts.map +1 -0
  267. package/dist/cli/preview/complexity-scanner.js +52 -0
  268. package/dist/cli/preview/complexity-scanner.js.map +1 -0
  269. package/dist/cli/preview/dependency-extractor.d.ts +38 -0
  270. package/dist/cli/preview/dependency-extractor.d.ts.map +1 -0
  271. package/dist/cli/preview/dependency-extractor.js +140 -0
  272. package/dist/cli/preview/dependency-extractor.js.map +1 -0
  273. package/dist/cli/preview/preview-renderer.d.ts +32 -0
  274. package/dist/cli/preview/preview-renderer.d.ts.map +1 -0
  275. package/dist/cli/preview/preview-renderer.js +54 -0
  276. package/dist/cli/preview/preview-renderer.js.map +1 -0
  277. package/dist/cli/storage-runtime.d.ts +7 -0
  278. package/dist/cli/storage-runtime.d.ts.map +1 -1
  279. package/dist/cli/storage-runtime.js +22 -0
  280. package/dist/cli/storage-runtime.js.map +1 -1
  281. package/dist/cli/tree-sitter-check.d.ts +6 -1
  282. package/dist/cli/tree-sitter-check.d.ts.map +1 -1
  283. package/dist/cli/tree-sitter-check.js +23 -1
  284. package/dist/cli/tree-sitter-check.js.map +1 -1
  285. package/dist/cli-new/index.js +1 -1
  286. package/dist/cli-new/index.js.map +1 -1
  287. package/dist/composition/parser-composition.d.ts +7 -0
  288. package/dist/composition/parser-composition.d.ts.map +1 -0
  289. package/dist/composition/parser-composition.js +15 -0
  290. package/dist/composition/parser-composition.js.map +1 -0
  291. package/dist/core/analyzer.d.ts.map +1 -1
  292. package/dist/core/analyzer.js +83 -67
  293. package/dist/core/analyzer.js.map +1 -1
  294. package/dist/core/ast-complexity-analyzer.d.ts +12 -6
  295. package/dist/core/ast-complexity-analyzer.d.ts.map +1 -1
  296. package/dist/core/ast-complexity-analyzer.js +368 -209
  297. package/dist/core/ast-complexity-analyzer.js.map +1 -1
  298. package/dist/core/file-discovery.d.ts +1 -1
  299. package/dist/core/file-discovery.d.ts.map +1 -1
  300. package/dist/core/file-discovery.js +3 -0
  301. package/dist/core/file-discovery.js.map +1 -1
  302. package/dist/core/global-index.d.ts +3 -1
  303. package/dist/core/global-index.d.ts.map +1 -1
  304. package/dist/core/global-index.js +69 -4
  305. package/dist/core/global-index.js.map +1 -1
  306. package/dist/domain/entities/CodeGraph.d.ts +3 -0
  307. package/dist/domain/entities/CodeGraph.d.ts.map +1 -1
  308. package/dist/domain/entities/CodeGraph.js +19 -2
  309. package/dist/domain/entities/CodeGraph.js.map +1 -1
  310. package/dist/domain/entities/Dependency.d.ts +5 -2
  311. package/dist/domain/entities/Dependency.d.ts.map +1 -1
  312. package/dist/domain/entities/Dependency.js +49 -3
  313. package/dist/domain/entities/Dependency.js.map +1 -1
  314. package/dist/domain/repositories/CodeGraphRepository.d.ts +5 -0
  315. package/dist/domain/repositories/CodeGraphRepository.d.ts.map +1 -1
  316. package/dist/domain/repositories/CodeGraphRepository.js.map +1 -1
  317. package/dist/execution/contract-tools/analyze.d.ts +205 -0
  318. package/dist/execution/contract-tools/analyze.d.ts.map +1 -0
  319. package/dist/execution/contract-tools/analyze.js +1215 -0
  320. package/dist/execution/contract-tools/analyze.js.map +1 -0
  321. package/dist/execution/contract-tools/deps.d.ts +62 -0
  322. package/dist/execution/contract-tools/deps.d.ts.map +1 -0
  323. package/dist/execution/contract-tools/deps.js +234 -0
  324. package/dist/execution/contract-tools/deps.js.map +1 -0
  325. package/dist/execution/contract-tools/index.d.ts +5 -0
  326. package/dist/execution/contract-tools/index.d.ts.map +1 -0
  327. package/dist/execution/contract-tools/index.js +7 -0
  328. package/dist/execution/contract-tools/index.js.map +1 -0
  329. package/dist/execution/contract-tools/query.d.ts +60 -0
  330. package/dist/execution/contract-tools/query.d.ts.map +1 -0
  331. package/dist/execution/contract-tools/query.js +532 -0
  332. package/dist/execution/contract-tools/query.js.map +1 -0
  333. package/dist/execution/contract-tools/types.d.ts +26 -0
  334. package/dist/execution/contract-tools/types.d.ts.map +1 -0
  335. package/dist/execution/contract-tools/types.js +32 -0
  336. package/dist/execution/contract-tools/types.js.map +1 -0
  337. package/dist/generator/index.d.ts.map +1 -1
  338. package/dist/generator/index.js +0 -3
  339. package/dist/generator/index.js.map +1 -1
  340. package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.d.ts +12 -0
  341. package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.d.ts.map +1 -0
  342. package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.js +55 -0
  343. package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.js.map +1 -0
  344. package/dist/infrastructure/parser/implementations/GoParser.d.ts +2 -1
  345. package/dist/infrastructure/parser/implementations/GoParser.d.ts.map +1 -1
  346. package/dist/infrastructure/parser/implementations/GoParser.js +13 -1
  347. package/dist/infrastructure/parser/implementations/GoParser.js.map +1 -1
  348. package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.d.ts +114 -0
  349. package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.d.ts.map +1 -0
  350. package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.js +1022 -0
  351. package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.js.map +1 -0
  352. package/dist/infrastructure/parser/implementations/TreeSitterParser.d.ts +78 -0
  353. package/dist/infrastructure/parser/implementations/TreeSitterParser.d.ts.map +1 -0
  354. package/dist/infrastructure/parser/implementations/TreeSitterParser.js +648 -0
  355. package/dist/infrastructure/parser/implementations/TreeSitterParser.js.map +1 -0
  356. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts +3 -55
  357. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts.map +1 -1
  358. package/dist/infrastructure/parser/implementations/TypeScriptParser.js +4 -411
  359. package/dist/infrastructure/parser/implementations/TypeScriptParser.js.map +1 -1
  360. package/dist/infrastructure/parser/index.d.ts +2 -0
  361. package/dist/infrastructure/parser/index.d.ts.map +1 -1
  362. package/dist/infrastructure/parser/index.js +9 -6
  363. package/dist/infrastructure/parser/index.js.map +1 -1
  364. package/dist/infrastructure/parser/interfaces/ParserBase.d.ts.map +1 -1
  365. package/dist/infrastructure/parser/interfaces/ParserBase.js +1 -0
  366. package/dist/infrastructure/parser/interfaces/ParserBase.js.map +1 -1
  367. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts +2 -0
  368. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts.map +1 -1
  369. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js +4 -0
  370. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js.map +1 -1
  371. package/dist/infrastructure/storage/StorageFactory.d.ts +5 -18
  372. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -1
  373. package/dist/infrastructure/storage/StorageFactory.js +30 -98
  374. package/dist/infrastructure/storage/StorageFactory.js.map +1 -1
  375. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts +13 -1
  376. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts.map +1 -1
  377. package/dist/infrastructure/storage/adapters/SQLiteStorage.js +322 -76
  378. package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -1
  379. package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts +45 -0
  380. package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts.map +1 -0
  381. package/dist/infrastructure/storage/adapters/sqlite-loader.js +266 -0
  382. package/dist/infrastructure/storage/adapters/sqlite-loader.js.map +1 -0
  383. package/dist/infrastructure/storage/community-helpers.d.ts +4 -0
  384. package/dist/infrastructure/storage/community-helpers.d.ts.map +1 -0
  385. package/dist/infrastructure/storage/community-helpers.js +392 -0
  386. package/dist/infrastructure/storage/community-helpers.js.map +1 -0
  387. package/dist/infrastructure/storage/graph-helpers.d.ts +22 -5
  388. package/dist/infrastructure/storage/graph-helpers.d.ts.map +1 -1
  389. package/dist/infrastructure/storage/graph-helpers.js +496 -91
  390. package/dist/infrastructure/storage/graph-helpers.js.map +1 -1
  391. package/dist/infrastructure/storage/index.d.ts +1 -1
  392. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  393. package/dist/infrastructure/storage/index.js +1 -1
  394. package/dist/infrastructure/storage/index.js.map +1 -1
  395. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +2 -2
  396. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -1
  397. package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -1
  398. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts +2 -0
  399. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts.map +1 -1
  400. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js +52 -12
  401. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js.map +1 -1
  402. package/dist/infrastructure/storage/sqlite/schema.d.ts +2 -2
  403. package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -1
  404. package/dist/infrastructure/storage/sqlite/schema.js +49 -1
  405. package/dist/infrastructure/storage/sqlite/schema.js.map +1 -1
  406. package/dist/interface/config/index.d.ts +5 -3
  407. package/dist/interface/config/index.d.ts.map +1 -1
  408. package/dist/interface/types/index.d.ts +37 -6
  409. package/dist/interface/types/index.d.ts.map +1 -1
  410. package/dist/interface/types/parser.d.ts +85 -0
  411. package/dist/interface/types/parser.d.ts.map +1 -1
  412. package/dist/interface/types/storage.d.ts +227 -10
  413. package/dist/interface/types/storage.d.ts.map +1 -1
  414. package/dist/orchestrator/agent-metrics-service.d.ts +126 -0
  415. package/dist/orchestrator/agent-metrics-service.d.ts.map +1 -0
  416. package/dist/orchestrator/agent-metrics-service.js +444 -0
  417. package/dist/orchestrator/agent-metrics-service.js.map +1 -0
  418. package/dist/orchestrator/types.d.ts +2 -0
  419. package/dist/orchestrator/types.d.ts.map +1 -1
  420. package/dist/orchestrator/types.js.map +1 -1
  421. package/dist/parser/enhancers/PythonTypeEnhancer.d.ts +26 -0
  422. package/dist/parser/enhancers/PythonTypeEnhancer.d.ts.map +1 -0
  423. package/dist/parser/enhancers/PythonTypeEnhancer.js +440 -0
  424. package/dist/parser/enhancers/PythonTypeEnhancer.js.map +1 -0
  425. package/dist/parser/implementations/smart-parser.d.ts.map +1 -1
  426. package/dist/parser/implementations/smart-parser.js +7 -69
  427. package/dist/parser/implementations/smart-parser.js.map +1 -1
  428. package/dist/parser/implementations/tree-sitter-loader.d.ts +18 -0
  429. package/dist/parser/implementations/tree-sitter-loader.d.ts.map +1 -0
  430. package/dist/parser/implementations/tree-sitter-loader.js +136 -0
  431. package/dist/parser/implementations/tree-sitter-loader.js.map +1 -0
  432. package/dist/parser/index.d.ts +5 -3
  433. package/dist/parser/index.d.ts.map +1 -1
  434. package/dist/parser/index.js +68 -6
  435. package/dist/parser/index.js.map +1 -1
  436. package/dist/parser/interfaces/IParser.d.ts +19 -6
  437. package/dist/parser/interfaces/IParser.d.ts.map +1 -1
  438. package/dist/parser/interfaces/IParser.js +2 -3
  439. package/dist/parser/interfaces/IParser.js.map +1 -1
  440. package/dist/server/handlers/AnalysisHandler.d.ts +13 -2
  441. package/dist/server/handlers/AnalysisHandler.d.ts.map +1 -1
  442. package/dist/server/handlers/AnalysisHandler.js +24 -0
  443. package/dist/server/handlers/AnalysisHandler.js.map +1 -1
  444. package/dist/server/handlers/QueryHandler.d.ts.map +1 -1
  445. package/dist/server/handlers/QueryHandler.js +11 -30
  446. package/dist/server/handlers/QueryHandler.js.map +1 -1
  447. package/dist/server/mcp/context-tool.d.ts +9 -0
  448. package/dist/server/mcp/context-tool.d.ts.map +1 -0
  449. package/dist/server/mcp/context-tool.js +257 -0
  450. package/dist/server/mcp/context-tool.js.map +1 -0
  451. package/dist/server/mcp/schema-adapter.d.ts +55 -0
  452. package/dist/server/mcp/schema-adapter.d.ts.map +1 -0
  453. package/dist/server/mcp/schema-adapter.js +409 -0
  454. package/dist/server/mcp/schema-adapter.js.map +1 -0
  455. package/dist/server/mcp/server.d.ts +3 -3
  456. package/dist/server/mcp/server.d.ts.map +1 -1
  457. package/dist/server/mcp/server.js +134 -20
  458. package/dist/server/mcp/server.js.map +1 -1
  459. package/dist/server/mcp/service.d.ts +6 -2
  460. package/dist/server/mcp/service.d.ts.map +1 -1
  461. package/dist/server/mcp/service.js +138 -36
  462. package/dist/server/mcp/service.js.map +1 -1
  463. package/dist/server/mcp/stdio-transport.d.ts +23 -0
  464. package/dist/server/mcp/stdio-transport.d.ts.map +1 -0
  465. package/dist/server/mcp/stdio-transport.js +101 -0
  466. package/dist/server/mcp/stdio-transport.js.map +1 -0
  467. package/dist/server/mcp/types.d.ts +133 -8
  468. package/dist/server/mcp/types.d.ts.map +1 -1
  469. package/dist/server/routes/api.d.ts.map +1 -1
  470. package/dist/server/routes/api.js +11 -2
  471. package/dist/server/routes/api.js.map +1 -1
  472. package/docs/AI_ASSISTANT_SETUP.md +281 -12
  473. package/docs/API.md +170 -0
  474. package/docs/CONFIGURATION.md +141 -0
  475. package/docs/DEVELOPMENT.md +96 -0
  476. package/docs/GETTING-STARTED.md +114 -0
  477. package/docs/README.md +40 -1
  478. package/docs/SETUP_GUIDE.md +60 -14
  479. package/docs/TESTING.md +81 -0
  480. package/docs/ai-guide/COMMANDS.md +68 -10
  481. package/docs/ai-guide/INTEGRATION.md +77 -10
  482. package/docs/ai-guide/OUTPUT.md +345 -9
  483. package/docs/ai-guide/PROMPTS.md +2 -2
  484. package/docs/ai-guide/QUICKSTART.md +28 -1
  485. package/docs/ai-guide/README.md +2 -2
  486. package/docs/archive/ideation/2026-04-15-executable-architecture-constitution-ideation-archive.md +70 -0
  487. package/docs/archive/ideation/2026-04-20-mycodemap-init-enhancements-ideation-archive.md +109 -0
  488. package/docs/archive/ideation/2026-04-22-rules-entry-docs-optimization-consolidated-ideation-archive.md +54 -0
  489. package/docs/backlog.md +232 -144
  490. package/docs/brainstorms/2026-05-10-agent-effectiveness-validation-requirements.md +112 -0
  491. package/docs/generated/phase-58/subagent-evidence/claude-hook-example.json +15 -0
  492. package/docs/generated/phase-58/subagent-evidence/claude-session.md +146 -0
  493. package/docs/generated/phase-58/subagent-evidence/claude-subagent.json +28 -0
  494. package/docs/generated/phase-58/subagent-evidence/codex-agent-example.toml +19 -0
  495. package/docs/generated/phase-58/subagent-evidence/codex-session.md +150 -0
  496. package/docs/generated/phase-58/subagent-evidence/codex-subagent.json +20 -0
  497. package/docs/generated/phase-58/subagent-evidence/negative-no-retrieval.json +12 -0
  498. package/docs/generated/phase-58/subagent-evidence/verification-manifest.json +19 -0
  499. package/docs/ideation/2026-04-15-executable-architecture-constitution-ideation.md +10 -22
  500. package/docs/ideation/2026-04-20-mycodemap-init-enhancements-ideation.md +15 -60
  501. package/docs/ideation/2026-04-22-rules-entry-docs-optimization-consolidated-ideation.md +47 -52
  502. package/docs/ideation/2026-04-29-ux-install-agent-experience-ideation.md +256 -0
  503. package/docs/ideation/2026-05-02-subagent-environment-contract-injection-ideation.md +183 -0
  504. package/docs/ideation/2026-05-04-subagent-hooks-deep-dive-ideation.md +133 -0
  505. package/docs/ideation/2026-05-10-agent-effectiveness-validation-ideation.md +219 -0
  506. package/docs/plans/2026-04-30-install-guide-and-repo-analyzer-design.md +394 -0
  507. package/docs/rules/README.md +1 -0
  508. package/docs/rules/architecture-guardrails.md +2 -1
  509. package/docs/rules/engineering-with-codex-openai.md +1 -1
  510. package/docs/rules/harness.md +106 -0
  511. package/docs/rules/pre-release-checklist.md +28 -0
  512. package/docs/rules/testing.md +51 -0
  513. package/examples/claude/skills/mycodemap-repo-analyzer/SKILL.md +294 -0
  514. package/examples/claude/skills/mycodemap-repo-analyzer/references/analysis-guide.md +166 -0
  515. package/examples/claude/skills/mycodemap-repo-analyzer/references/module-analysis-guide.md +150 -0
  516. package/package.json +12 -4
  517. package/scripts/copy-build-assets.mjs +23 -0
  518. package/scripts/hooks/templates/pre-commit +33 -2
  519. package/scripts/sync-analyze-docs.js +2 -2
  520. package/scripts/tests/test_rule_control_workflow.py +15 -1
  521. package/scripts/validate-docs.js +113 -16
  522. package/scripts/verify-subagent-env-contract.mjs +279 -0
  523. package/dist/parser/implementations/tree-sitter-parser.d.ts +0 -57
  524. package/dist/parser/implementations/tree-sitter-parser.d.ts.map +0 -1
  525. package/dist/parser/implementations/tree-sitter-parser.js +0 -375
  526. package/dist/parser/implementations/tree-sitter-parser.js.map +0 -1
  527. package/docs/references/tmp.md +0 -527
@@ -0,0 +1,648 @@
1
+ // [META] since:2026-05 | owner:parser-team | stable:false
2
+ // [WHY] Shared Tree-sitter parser now lives in Infrastructure and provides TS/JS active parsing plus shared AST helpers for Python
3
+ import path from 'path';
4
+ import { randomUUID } from 'crypto';
5
+ import { analyzeComplexityFromContent } from '../../../core/ast-complexity-analyzer.js';
6
+ import { loadTreeSitter } from '../../../parser/implementations/tree-sitter-loader.js';
7
+ import { ParserBase } from '../interfaces/ParserBase.js';
8
+ const EXTENSION_LANGUAGE_MAP = {
9
+ ts: { grammar: 'typescript', language: 'typescript' },
10
+ tsx: { grammar: 'tsx', language: 'typescript' },
11
+ js: { grammar: 'tsx', language: 'javascript' },
12
+ jsx: { grammar: 'tsx', language: 'javascript' },
13
+ mjs: { grammar: 'tsx', language: 'javascript' },
14
+ cjs: { grammar: 'tsx', language: 'javascript' },
15
+ py: { grammar: 'python', language: 'python' },
16
+ };
17
+ export class TreeSitterParser extends ParserBase {
18
+ languageId = 'typescript';
19
+ fileExtensions = ['ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs'];
20
+ name = 'TreeSitterParser';
21
+ supportedFeatures = new Set([
22
+ 'type-inference',
23
+ 'generic-types',
24
+ 'decorators',
25
+ 'call-graph',
26
+ 'cross-file-analysis',
27
+ 'complexity-metrics',
28
+ ]);
29
+ parser;
30
+ grammars = null;
31
+ parserPromise = null;
32
+ constructor(_options) {
33
+ super();
34
+ }
35
+ async doInitialize() {
36
+ await this.getParserPromise();
37
+ }
38
+ async doDispose() { }
39
+ async initializeParser() {
40
+ const { Parser, TypeScript, Python } = await loadTreeSitter();
41
+ this.parser = new Parser();
42
+ this.grammars = {
43
+ typescript: TypeScript.typescript,
44
+ tsx: TypeScript.tsx ?? TypeScript.typescript,
45
+ python: Python,
46
+ };
47
+ }
48
+ async parseFile(filePath, content, options) {
49
+ this.ensureInitialized();
50
+ const startTime = Date.now();
51
+ const parsed = await this.parseContent(filePath, content);
52
+ const module = {
53
+ id: `mod_${randomUUID().replace(/-/g, '').slice(0, 16)}`,
54
+ projectId: '',
55
+ path: filePath,
56
+ language: parsed.language,
57
+ stats: parsed.stats,
58
+ };
59
+ return {
60
+ filePath,
61
+ language: parsed.language,
62
+ module,
63
+ symbols: parsed.symbols,
64
+ imports: parsed.imports,
65
+ exports: parsed.exports,
66
+ dependencies: this.buildDependencies(parsed.imports),
67
+ callGraph: options?.includeCallGraph ? await this.buildCallGraph(content) : undefined,
68
+ complexity: options?.includeComplexity ? await this.calculateComplexity(content, filePath) : undefined,
69
+ parseTime: Date.now() - startTime,
70
+ parserUsed: parsed.parserUsed,
71
+ };
72
+ }
73
+ async parseContent(filePath, content) {
74
+ const syntaxTree = await this.parseSyntaxTree(filePath, content);
75
+ const { rootNode, language } = syntaxTree;
76
+ if (language === 'python') {
77
+ return {
78
+ filePath,
79
+ language,
80
+ parserUsed: 'TreeSitterParser',
81
+ imports: this.extractPythonImports(rootNode),
82
+ exports: this.extractPythonExports(rootNode),
83
+ symbols: this.extractPythonSymbols(rootNode, filePath),
84
+ dependencies: this.extractDependencies(this.extractPythonImports(rootNode)),
85
+ type: this.detectModuleType(filePath),
86
+ stats: this.calculateStats(content, rootNode),
87
+ };
88
+ }
89
+ const imports = this.extractTypeScriptImports(rootNode);
90
+ return {
91
+ filePath,
92
+ language,
93
+ parserUsed: 'TreeSitterParser',
94
+ imports,
95
+ exports: this.extractTypeScriptExports(rootNode),
96
+ symbols: this.extractTypeScriptSymbols(rootNode, filePath),
97
+ dependencies: this.extractDependencies(imports),
98
+ type: this.detectModuleType(filePath),
99
+ stats: this.calculateStats(content, rootNode),
100
+ };
101
+ }
102
+ async parseSyntaxTree(filePath, content) {
103
+ await this.getParserPromise();
104
+ const selection = this.selectLanguage(filePath);
105
+ this.parser.setLanguage(selection.grammar);
106
+ const tree = this.parser.parse(content);
107
+ return {
108
+ filePath,
109
+ content,
110
+ language: selection.language,
111
+ parserUsed: 'TreeSitterParser',
112
+ tree,
113
+ rootNode: tree.rootNode,
114
+ };
115
+ }
116
+ getParserPromise() {
117
+ if (!this.parserPromise) {
118
+ this.parserPromise = this.initializeParser();
119
+ }
120
+ return this.parserPromise;
121
+ }
122
+ async extractImports(content) {
123
+ this.ensureInitialized();
124
+ const shared = await this.parseContent('/virtual.ts', content);
125
+ return shared.imports;
126
+ }
127
+ async extractExports(content) {
128
+ this.ensureInitialized();
129
+ const shared = await this.parseContent('/virtual.ts', content);
130
+ return shared.exports;
131
+ }
132
+ async extractSymbols(content) {
133
+ this.ensureInitialized();
134
+ const shared = await this.parseContent('/virtual.ts', content);
135
+ return shared.symbols;
136
+ }
137
+ async buildCallGraph(content) {
138
+ const calls = [];
139
+ const calledFunctions = new Set();
140
+ const callRegex = /(\w+)\s*\(/g;
141
+ let match;
142
+ while ((match = callRegex.exec(content)) !== null) {
143
+ const callee = match[1];
144
+ if (callee && !this.isKeyword(callee)) {
145
+ calledFunctions.add(callee);
146
+ calls.push({
147
+ caller: '<anonymous>',
148
+ callee,
149
+ line: this.getLineNumber(content, match.index),
150
+ });
151
+ }
152
+ }
153
+ const recursive = [];
154
+ const functionRegex = /(?:async\s+)?function\s+(\w+)/g;
155
+ while ((match = functionRegex.exec(content)) !== null) {
156
+ const funcName = match[1];
157
+ if (!funcName || !calledFunctions.has(funcName)) {
158
+ continue;
159
+ }
160
+ const funcBody = content.slice(match.index, this.findFunctionEnd(content, match.index));
161
+ if (new RegExp(`\\b${funcName}\\s*\\(`, 'g').test(funcBody)) {
162
+ recursive.push(funcName);
163
+ }
164
+ }
165
+ return { calls, recursive, issues: [] };
166
+ }
167
+ async calculateComplexity(content, filePath = '/virtual.ts') {
168
+ const language = this.selectLanguage(filePath).language;
169
+ return analyzeComplexityFromContent({
170
+ filePath,
171
+ content,
172
+ language,
173
+ });
174
+ }
175
+ selectLanguage(filePath) {
176
+ const extension = path.extname(filePath).slice(1).toLowerCase();
177
+ const selection = EXTENSION_LANGUAGE_MAP[extension];
178
+ if (!selection || !this.grammars) {
179
+ throw new Error(`Unsupported tree-sitter language for file: ${filePath}`);
180
+ }
181
+ const grammar = this.grammars[selection.grammar];
182
+ if (!grammar) {
183
+ throw new Error(`Tree-sitter grammar not available for .${extension}`);
184
+ }
185
+ return { grammar, language: selection.language };
186
+ }
187
+ extractTypeScriptImports(root) {
188
+ const imports = [];
189
+ const importNodes = root.namedChildren.filter((node) => node.type === 'import_statement');
190
+ for (const importNode of importNodes) {
191
+ const stringLiteral = importNode.namedChildren.find((node) => node.type === 'string');
192
+ const source = stringLiteral?.text.replace(/['"]/g, '') || '';
193
+ const importClause = importNode.namedChildren.find((node) => node.type === 'import_clause');
194
+ const specifiers = [];
195
+ if (importClause) {
196
+ const namedImports = importClause.namedChildren.filter((node) => node.type === 'named_imports');
197
+ for (const named of namedImports) {
198
+ const specifierList = named.namedChildren.filter((node) => node.type === 'import_specifier');
199
+ for (const spec of specifierList) {
200
+ const name = spec.namedChildren[0];
201
+ specifiers.push({
202
+ name: name?.text || '',
203
+ alias: spec.namedChildren[1]?.text,
204
+ isTypeOnly: false,
205
+ });
206
+ }
207
+ }
208
+ const defaultImport = importClause.namedChildren.find((node) => node.type === 'identifier');
209
+ if (defaultImport) {
210
+ specifiers.push({
211
+ name: defaultImport.text,
212
+ isTypeOnly: false,
213
+ });
214
+ }
215
+ const namespaceImport = importClause.namedChildren.find((node) => node.type === 'namespace_import');
216
+ if (namespaceImport) {
217
+ const alias = namespaceImport.namedChildren[0];
218
+ specifiers.push({
219
+ name: alias?.text || '*',
220
+ isTypeOnly: false,
221
+ });
222
+ }
223
+ }
224
+ if (specifiers.length > 0 || source) {
225
+ imports.push({
226
+ source,
227
+ sourceType: this.classifyImportSource(source),
228
+ specifiers,
229
+ isTypeOnly: false,
230
+ });
231
+ }
232
+ }
233
+ return imports;
234
+ }
235
+ extractTypeScriptExports(root) {
236
+ const exports = [];
237
+ const exportNodes = root.namedChildren.filter((node) => node.type === 'export_statement');
238
+ for (const exportNode of exportNodes) {
239
+ for (const child of exportNode.namedChildren) {
240
+ switch (child.type) {
241
+ case 'named_exports': {
242
+ const specifiers = child.namedChildren.filter((node) => node.type === 'export_specifier');
243
+ for (const spec of specifiers) {
244
+ const name = spec.namedChildren[0];
245
+ exports.push({
246
+ name: name?.text || '',
247
+ kind: 'function',
248
+ isDefault: false,
249
+ isTypeOnly: false,
250
+ origin: spec.namedChildren[1]?.text,
251
+ });
252
+ }
253
+ break;
254
+ }
255
+ case 'class_declaration': {
256
+ const className = child.namedChildren.find((node) => node.type === 'type_identifier');
257
+ if (className) {
258
+ exports.push({ name: className.text, kind: 'class', isDefault: false, isTypeOnly: false });
259
+ }
260
+ break;
261
+ }
262
+ case 'function_declaration': {
263
+ const funcName = child.namedChildren.find((node) => node.type === 'identifier');
264
+ if (funcName) {
265
+ exports.push({ name: funcName.text, kind: 'function', isDefault: false, isTypeOnly: false });
266
+ }
267
+ break;
268
+ }
269
+ case 'variable_declaration': {
270
+ const variables = child.namedChildren.filter((node) => node.type === 'variable_declarator');
271
+ for (const variable of variables) {
272
+ const varName = variable.namedChildren[0];
273
+ exports.push({
274
+ name: varName?.text || '',
275
+ kind: 'type',
276
+ isDefault: false,
277
+ isTypeOnly: false,
278
+ });
279
+ }
280
+ break;
281
+ }
282
+ case 'interface_declaration': {
283
+ const ifaceName = child.namedChildren.find((node) => node.type === 'type_identifier');
284
+ if (ifaceName) {
285
+ exports.push({ name: ifaceName.text, kind: 'interface', isDefault: false, isTypeOnly: false });
286
+ }
287
+ break;
288
+ }
289
+ case 'type_alias_declaration': {
290
+ const typeName = child.namedChildren.find((node) => node.type === 'type_identifier');
291
+ if (typeName) {
292
+ exports.push({ name: typeName.text, kind: 'type', isDefault: false, isTypeOnly: false });
293
+ }
294
+ break;
295
+ }
296
+ case 'enum_declaration': {
297
+ const enumName = child.namedChildren.find((node) => node.type === 'identifier');
298
+ if (enumName) {
299
+ exports.push({ name: enumName.text, kind: 'enum', isDefault: false, isTypeOnly: false });
300
+ }
301
+ break;
302
+ }
303
+ }
304
+ }
305
+ const defaultExport = exportNode.namedChildren.find((node) => node.type === 'default');
306
+ if (defaultExport) {
307
+ exports.push({
308
+ name: 'default',
309
+ kind: 'function',
310
+ isDefault: true,
311
+ isTypeOnly: false,
312
+ });
313
+ }
314
+ }
315
+ return exports;
316
+ }
317
+ extractTypeScriptSymbols(root, filePath) {
318
+ const symbols = [];
319
+ const declarations = this.findTypeScriptDeclarations(root);
320
+ for (const decl of declarations) {
321
+ symbols.push({
322
+ id: `${decl.name}-${decl.node.startPosition.row}`,
323
+ name: decl.name,
324
+ kind: decl.kind,
325
+ location: {
326
+ file: filePath,
327
+ line: decl.node.startPosition.row + 1,
328
+ column: decl.node.startPosition.column,
329
+ },
330
+ visibility: 'public',
331
+ relatedSymbols: [],
332
+ });
333
+ }
334
+ return symbols;
335
+ }
336
+ findTypeScriptDeclarations(node) {
337
+ const declarations = [];
338
+ if (node.type === 'class_declaration') {
339
+ const name = node.namedChildren.find((child) => child.type === 'type_identifier');
340
+ if (name)
341
+ declarations.push({ name: name.text, kind: 'class', node });
342
+ }
343
+ if (node.type === 'function_declaration') {
344
+ const name = node.namedChildren.find((child) => child.type === 'identifier');
345
+ if (name)
346
+ declarations.push({ name: name.text, kind: 'function', node });
347
+ }
348
+ if (node.type === 'interface_declaration') {
349
+ const name = node.namedChildren.find((child) => child.type === 'type_identifier');
350
+ if (name)
351
+ declarations.push({ name: name.text, kind: 'interface', node });
352
+ }
353
+ if (node.type === 'type_alias_declaration') {
354
+ const name = node.namedChildren.find((child) => child.type === 'type_identifier');
355
+ if (name)
356
+ declarations.push({ name: name.text, kind: 'type', node });
357
+ }
358
+ if (node.type === 'enum_declaration') {
359
+ const name = node.namedChildren.find((child) => child.type === 'identifier');
360
+ if (name)
361
+ declarations.push({ name: name.text, kind: 'enum', node });
362
+ }
363
+ if (node.type === 'variable_declarator') {
364
+ const name = node.namedChildren[0];
365
+ if (name && name.type === 'identifier') {
366
+ declarations.push({ name: name.text, kind: 'variable', node });
367
+ }
368
+ }
369
+ for (const child of node.namedChildren) {
370
+ declarations.push(...this.findTypeScriptDeclarations(child));
371
+ }
372
+ return declarations;
373
+ }
374
+ extractPythonImports(root) {
375
+ const imports = [];
376
+ for (const child of root.namedChildren) {
377
+ if (child.type === 'import_statement') {
378
+ imports.push(...this.parsePythonImportStatement(child));
379
+ }
380
+ else if (child.type === 'import_from_statement') {
381
+ imports.push(...this.parsePythonImportFromStatement(child));
382
+ }
383
+ else if (child.type === 'future_import_statement') {
384
+ imports.push(...this.parsePythonFutureImportStatement(child));
385
+ }
386
+ }
387
+ return imports;
388
+ }
389
+ parsePythonImportStatement(node) {
390
+ const nameField = node.childForFieldName('name');
391
+ if (!nameField)
392
+ return [];
393
+ const specifiers = this.extractPythonImportSpecifiers(nameField);
394
+ if (specifiers.length === 0)
395
+ return [];
396
+ return [{
397
+ source: specifiers[0].name,
398
+ sourceType: specifiers[0].name.startsWith('.') ? 'relative' : 'absolute',
399
+ specifiers,
400
+ isTypeOnly: false,
401
+ }];
402
+ }
403
+ parsePythonImportFromStatement(node) {
404
+ const moduleName = node.childForFieldName('module_name');
405
+ let source = '';
406
+ let sourceType = 'absolute';
407
+ if (moduleName) {
408
+ source = moduleName.text;
409
+ sourceType = source.startsWith('.') ? 'relative' : 'absolute';
410
+ }
411
+ const specifiers = [];
412
+ for (let i = 1; i < node.namedChildren.length; i++) {
413
+ const child = node.namedChildren[i];
414
+ if (child.type === 'dotted_name' || child.type === 'identifier') {
415
+ specifiers.push({ name: child.text, isTypeOnly: false });
416
+ }
417
+ else if (child.type === 'aliased_import') {
418
+ specifiers.push({
419
+ name: child.childForFieldName('name')?.text || '',
420
+ alias: child.childForFieldName('alias')?.text,
421
+ isTypeOnly: false,
422
+ });
423
+ }
424
+ else if (child.type === 'wildcard_import') {
425
+ specifiers.push({ name: '*', isTypeOnly: false });
426
+ }
427
+ }
428
+ if (specifiers.length === 0 && !source)
429
+ return [];
430
+ return [{ source, sourceType, specifiers, isTypeOnly: false }];
431
+ }
432
+ parsePythonFutureImportStatement(node) {
433
+ const specifiers = node.namedChildren
434
+ .filter((child) => child.type === 'identifier')
435
+ .map((child) => ({ name: child.text, isTypeOnly: false }));
436
+ return [{
437
+ source: '__future__',
438
+ sourceType: 'absolute',
439
+ specifiers,
440
+ isTypeOnly: false,
441
+ }];
442
+ }
443
+ extractPythonImportSpecifiers(nameNode) {
444
+ if (nameNode.type === 'dotted_name' || nameNode.type === 'identifier') {
445
+ return [{ name: nameNode.text, isTypeOnly: false }];
446
+ }
447
+ if (nameNode.type === 'aliased_import') {
448
+ return [{
449
+ name: nameNode.childForFieldName('name')?.text || '',
450
+ alias: nameNode.childForFieldName('alias')?.text,
451
+ isTypeOnly: false,
452
+ }];
453
+ }
454
+ return nameNode.namedChildren.flatMap((child) => this.extractPythonImportSpecifiers(child));
455
+ }
456
+ extractPythonExports(root) {
457
+ const explicitExports = this.extractPythonAllExports(root);
458
+ if (explicitExports.length > 0) {
459
+ return explicitExports.map((name) => ({
460
+ name,
461
+ kind: 'variable',
462
+ isDefault: false,
463
+ isTypeOnly: false,
464
+ }));
465
+ }
466
+ const exports = [];
467
+ for (const child of root.namedChildren) {
468
+ if (child.type === 'class_definition' || child.type === 'function_definition') {
469
+ const nameNode = child.childForFieldName('name');
470
+ if (nameNode && !nameNode.text.startsWith('_')) {
471
+ exports.push({
472
+ name: nameNode.text,
473
+ kind: child.type === 'class_definition' ? 'class' : 'function',
474
+ isDefault: false,
475
+ isTypeOnly: false,
476
+ });
477
+ }
478
+ }
479
+ else if (child.type === 'decorated_definition') {
480
+ const definition = child.namedChildren.find((node) => node.type === 'class_definition' || node.type === 'function_definition');
481
+ const nameNode = definition?.childForFieldName('name');
482
+ if (definition && nameNode && !nameNode.text.startsWith('_')) {
483
+ exports.push({
484
+ name: nameNode.text,
485
+ kind: definition.type === 'class_definition' ? 'class' : 'function',
486
+ isDefault: false,
487
+ isTypeOnly: false,
488
+ });
489
+ }
490
+ }
491
+ }
492
+ return exports;
493
+ }
494
+ extractPythonAllExports(root) {
495
+ const assignment = root.namedChildren.find((child) => child.type === 'expression_statement' && child.text.includes('__all__'));
496
+ if (!assignment)
497
+ return [];
498
+ return Array.from(assignment.text.matchAll(/['"]([^'"]+)['"]/g)).map((match) => match[1] || '');
499
+ }
500
+ extractPythonSymbols(root, filePath) {
501
+ const symbols = [];
502
+ const visit = (node, decorators = []) => {
503
+ if (node.type === 'decorated_definition') {
504
+ const decoratorNodes = node.namedChildren.filter((child) => child.type === 'decorator');
505
+ const nextDecorators = decoratorNodes.map((child) => ({
506
+ name: child.text.replace(/^@/, '').split('(')[0] || child.text,
507
+ target: 'class',
508
+ }));
509
+ const definition = node.namedChildren.find((child) => child.type === 'class_definition' || child.type === 'function_definition');
510
+ if (definition)
511
+ visit(definition, nextDecorators);
512
+ return;
513
+ }
514
+ if (node.type === 'class_definition' || node.type === 'function_definition') {
515
+ const nameNode = node.childForFieldName('name');
516
+ if (nameNode) {
517
+ const kind = node.type === 'class_definition' ? 'class' : 'function';
518
+ const signature = kind === 'function'
519
+ ? {
520
+ parameters: [],
521
+ returnType: 'Any',
522
+ async: node.text.startsWith('async def '),
523
+ }
524
+ : undefined;
525
+ symbols.push({
526
+ id: `${nameNode.text}-${node.startPosition.row}`,
527
+ name: nameNode.text,
528
+ kind,
529
+ location: {
530
+ file: filePath,
531
+ line: node.startPosition.row + 1,
532
+ column: node.startPosition.column,
533
+ },
534
+ visibility: nameNode.text.startsWith('_') ? 'internal' : 'public',
535
+ relatedSymbols: [],
536
+ decorators: decorators.length > 0 ? decorators : undefined,
537
+ signature,
538
+ ...(kind === 'class' ? { extends: this.extractPythonClassBases(node) } : {}),
539
+ });
540
+ }
541
+ }
542
+ for (const child of node.namedChildren ?? []) {
543
+ visit(child, []);
544
+ }
545
+ };
546
+ for (const child of root.namedChildren) {
547
+ visit(child);
548
+ }
549
+ return symbols;
550
+ }
551
+ extractPythonClassBases(node) {
552
+ const superclasses = node.childForFieldName('superclasses');
553
+ if (!superclasses)
554
+ return [];
555
+ return superclasses.namedChildren
556
+ .filter((child) => child.type === 'identifier' || child.type === 'attribute')
557
+ .map((child) => child.text);
558
+ }
559
+ extractDependencies(imports) {
560
+ const deps = new Set();
561
+ for (const imp of imports) {
562
+ if (!imp.source.startsWith('.')) {
563
+ deps.add(imp.source);
564
+ }
565
+ }
566
+ return Array.from(deps);
567
+ }
568
+ detectModuleType(filePath) {
569
+ const basename = path.basename(filePath);
570
+ if (basename.includes('.test.') || basename.includes('.spec.'))
571
+ return 'test';
572
+ if (basename.startsWith('.') || basename.endsWith('.config.') || basename.endsWith('.config.ts'))
573
+ return 'config';
574
+ if (basename.includes('.d.ts') || basename.includes('.types.'))
575
+ return 'type';
576
+ return 'source';
577
+ }
578
+ calculateStats(content, root) {
579
+ const lines = content.split('\n');
580
+ const commentLines = new Set();
581
+ for (const comment of this.findCommentNodes(root)) {
582
+ for (let i = comment.startPosition.row; i <= comment.endPosition.row; i++) {
583
+ commentLines.add(i);
584
+ }
585
+ }
586
+ const blankLines = lines.filter((line) => line.trim() === '').length;
587
+ return {
588
+ lines: lines.length,
589
+ codeLines: lines.length - commentLines.size - blankLines,
590
+ commentLines: commentLines.size,
591
+ blankLines,
592
+ };
593
+ }
594
+ findCommentNodes(node) {
595
+ const comments = [];
596
+ if (node.type === 'comment')
597
+ comments.push(node);
598
+ for (const child of node.children) {
599
+ comments.push(...this.findCommentNodes(child));
600
+ }
601
+ return comments;
602
+ }
603
+ classifyImportSource(source) {
604
+ if (source.startsWith('.'))
605
+ return 'relative';
606
+ if (source.startsWith('@'))
607
+ return 'alias';
608
+ return 'node_module';
609
+ }
610
+ buildDependencies(imports) {
611
+ return imports.map((imp) => ({
612
+ id: `dep_${randomUUID().replace(/-/g, '').slice(0, 16)}`,
613
+ sourceId: '',
614
+ targetId: '',
615
+ type: 'import',
616
+ filePath: imp.source,
617
+ }));
618
+ }
619
+ getLineNumber(content, index) {
620
+ return content.slice(0, index).split('\n').length;
621
+ }
622
+ isKeyword(word) {
623
+ return [
624
+ 'if', 'else', 'while', 'for', 'switch', 'case', 'break', 'continue',
625
+ 'return', 'throw', 'try', 'catch', 'finally', 'new', 'typeof', 'instanceof',
626
+ 'await', 'yield', 'void', 'delete', 'in', 'of',
627
+ ].includes(word);
628
+ }
629
+ findFunctionEnd(content, startIndex) {
630
+ let braceCount = 0;
631
+ let inFunction = false;
632
+ for (let i = startIndex; i < content.length; i++) {
633
+ const char = content[i];
634
+ if (char === '{') {
635
+ braceCount++;
636
+ inFunction = true;
637
+ }
638
+ else if (char === '}') {
639
+ braceCount--;
640
+ if (inFunction && braceCount === 0) {
641
+ return i + 1;
642
+ }
643
+ }
644
+ }
645
+ return content.length;
646
+ }
647
+ }
648
+ //# sourceMappingURL=TreeSitterParser.js.map