@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
package/dist/cli/index.js CHANGED
@@ -1,7 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  // [META] since:2026-03-03 | owner:orchestrator-team | stable:true
3
3
  // [WHY] CLI 入口点,注册命令并初始化运行日志
4
+ import { createRequire } from 'module';
4
5
  import { Command } from 'commander';
6
+ const require = createRequire(import.meta.url);
7
+ const pkg = require('../../package.json');
5
8
  import { generateCommand } from './commands/generate.js';
6
9
  import { initCommand } from './commands/init.js';
7
10
  import { queryCommand } from './commands/query.js';
@@ -18,6 +21,11 @@ import { historyCommand } from './commands/history.js';
18
21
  import { publishStatusCommand } from './commands/publish-status.js';
19
22
  import { readinessGateCommand } from './commands/readiness-gate.js';
20
23
  import { mcpCommand, isMcpStartInvocation } from './commands/mcp.js';
24
+ import { doctorCommand } from './commands/doctor.js';
25
+ import { benchmarkCommand } from './commands/benchmark.js';
26
+ import { previewCommand } from './commands/preview.js';
27
+ import { envContractCommand } from './commands/env-contract.js';
28
+ import { agentMetricsCommand } from './commands/agent-metrics/index.js';
21
29
  import { shipCommand } from './commands/ship/index.js';
22
30
  import { ANALYZE_COMMAND_DESCRIPTION, configureAnalyzeCommand } from './commands/analyze-options.js';
23
31
  import { setupRuntimeLogging } from './runtime-logger.js';
@@ -25,9 +33,21 @@ import { runFirstRunGuide } from './first-run-guide.js';
25
33
  import { printMigrationWarning } from './paths.js';
26
34
  import { validatePlatform } from './platform-check.js';
27
35
  import { formatRemovedCommandMessage, getRemovedTopLevelCommand } from './removed-commands.js';
28
- import { commandRequiresTreeSitter, validateTreeSitter } from './tree-sitter-check.js';
36
+ import { commandRequiresTreeSitter, validateTreeSitterAsync } from './tree-sitter-check.js';
37
+ import { getFullContract } from './interface-contract/index.js';
38
+ import { tryApplySuggestion } from './output/apply-suggestion.js';
39
+ import { resolveOutputMode, formatError } from './output/index.js';
29
40
  const program = new Command();
30
41
  const cliArgs = process.argv.slice(2);
42
+ // --schema must bypass all startup side effects to keep stdout machine-parseable
43
+ // Only intercept at root level (no subcommand present) so valid subcommand args
44
+ // that happen to be exactly --schema are not hijacked.
45
+ const firstArg = cliArgs[0];
46
+ const isRootLevel = !firstArg || firstArg.startsWith('-');
47
+ if (isRootLevel && cliArgs.includes('--schema')) {
48
+ console.log(JSON.stringify(getFullContract(), null, 2));
49
+ process.exit(0);
50
+ }
31
51
  const shouldBypassHumanStartupSideEffects = isMcpStartInvocation(cliArgs);
32
52
  const removedCommand = getRemovedTopLevelCommand(cliArgs);
33
53
  if (removedCommand) {
@@ -52,41 +72,63 @@ catch (error) {
52
72
  process.exit(1);
53
73
  }
54
74
  /**
55
- * 包装命令 action,按需检测 tree-sitter
75
+ * 统一命令 action 包装器:tree-sitter 检查 + 集中式错误处理 + suggestion 自动修复
56
76
  */
57
- function wrapWithTreeSitterCheck(commandName, action) {
58
- return async (options) => {
59
- if (commandRequiresTreeSitter(commandName)) {
60
- try {
61
- validateTreeSitter();
77
+ async function createActionHandler(commandName, action) {
78
+ return async (...args) => {
79
+ try {
80
+ if (commandRequiresTreeSitter(commandName)) {
81
+ await validateTreeSitterAsync();
62
82
  }
63
- catch (error) {
64
- console.error(error instanceof Error ? error.message : String(error));
65
- process.exit(1);
83
+ await action(...args);
84
+ }
85
+ catch (error) {
86
+ const mode = resolveOutputMode({});
87
+ const formatted = formatError(error, mode, commandName);
88
+ process.stdout.write(formatted + '\n');
89
+ // 尝试自动修复(如果 --apply-suggestion 已设置且错误是 ActionableError)
90
+ const cliOpts = program.opts();
91
+ if (cliOpts.applySuggestion && error && typeof error === 'object' && 'nextCommand' in error) {
92
+ const suggestionResult = await tryApplySuggestion(error, { applySuggestion: cliOpts.applySuggestion, wasmFallback: cliOpts.wasmFallback }, mode);
93
+ if (suggestionResult.success) {
94
+ process.exitCode = 0;
95
+ return;
96
+ }
66
97
  }
98
+ process.exitCode = 1;
67
99
  }
68
- return action(options);
69
100
  };
70
101
  }
71
102
  program
72
103
  .name('mycodemap')
73
104
  .alias('codemap') // 兼容旧命令名
74
- .description('TypeScript 代码地图工具 - 为 AI 辅助开发提供结构化上下文')
75
- .version('0.1.0');
105
+ .description(`TypeScript 代码地图工具 v${pkg.version} - 为 AI 辅助开发提供结构化上下文`)
106
+ .version(pkg.version)
107
+ .option('--apply-suggestion', 'Allow automatic execution of high-confidence remediation suggestions (confidence >= 0.8)')
108
+ .option('--wasm-fallback', 'Automatically use WASM fallback when native dependencies fail to compile')
109
+ .option('--native', 'Force native binary usage for tree-sitter and better-sqlite3 (disables WASM fallback)');
76
110
  program
77
111
  .command('init')
78
112
  .description('初始化并收敛 CodeMap 项目状态')
79
113
  .option('-y, --yes', '使用默认配置')
80
114
  .option('--interactive', '仅显示 reconciliation preview,不写入文件')
115
+ .option('--profile <name>', '指定 bootstrap profile(nodejs|python|go|rust|generic),跳过自动检测')
81
116
  .action(initCommand);
82
117
  program
83
118
  .command('generate')
84
119
  .description('生成代码地图')
85
- .option('-m, --mode <mode>', '分析模式 (fast|smart|hybrid)', 'hybrid')
120
+ .option('-m, --mode <mode>', 'Parser 兼容输入;默认使用单一路径 parser,fast/smart/hybrid 将返回废弃错误', 'tree-sitter')
86
121
  .option('-o, --output <dir>', '输出目录', '.mycodemap')
87
122
  .option('--symbol-level', '额外 materialize symbol-level 调用依赖到代码图存储', false)
123
+ .option('--incremental', '基于 persisted graph truth 执行 scoped incremental refresh', false)
124
+ .option('--changed-files <paths...>', '显式指定 changed files,启用 incremental refresh')
125
+ .option('--base <rev>', '增量刷新时用于 git diff 的 base revision')
126
+ .option('--against <rev>', '增量刷新时用于 git diff 的 against revision')
88
127
  .option('--ai-context', '为每个文件生成 AI 描述(需要 AI Provider)', false)
89
- .action(async (options, command) => {
128
+ .option('-j, --json', 'JSON 格式输出')
129
+ .option('--human', '强制人类可读输出')
130
+ .option('--structured', '输出完全结构化的 JSON(不包含自然语言字符串,需要配合 --json 使用)')
131
+ .action(await createActionHandler('generate', async (options, command) => {
90
132
  await generateCommand({
91
133
  ...options,
92
134
  __optionSources: {
@@ -94,7 +136,7 @@ program
94
136
  output: command.getOptionValueSource('output'),
95
137
  },
96
138
  });
97
- });
139
+ }));
98
140
  program.addCommand(designCommand);
99
141
  program
100
142
  .command('query')
@@ -105,6 +147,7 @@ program
105
147
  .option('-S, --search <word>', '模糊搜索')
106
148
  .option('-l, --limit <number>', '限制结果数量', '50')
107
149
  .option('-j, --json', 'JSON 格式输出')
150
+ .option('--human', '强制人类可读输出')
108
151
  .option('--structured', '输出完全结构化的 JSON(不包含自然语言字符串,需要配合 --json 使用)')
109
152
  .option('-v, --verbose', '显示性能指标')
110
153
  .option('-r, --regex', '使用正则表达式搜索(仅适用于 -S/--search)')
@@ -119,15 +162,16 @@ program
119
162
  .description('分析项目模块依赖关系')
120
163
  .option('-m, --module <path>', '查看指定模块的依赖')
121
164
  .option('-j, --json', 'JSON 格式输出')
165
+ .option('--human', '强制人类可读输出')
122
166
  .option('--structured', '输出完全结构化的 JSON(不包含自然语言字符串,需要配合 --json 使用)')
123
- .action(depsCommand);
167
+ .action(await createActionHandler('deps', depsCommand));
124
168
  program
125
169
  .command('cycles')
126
170
  .description('检测项目中的循环依赖')
127
171
  .option('-d, --depth <number>', '检测深度', '5')
128
172
  .option('-j, --json', 'JSON 格式输出')
129
173
  .option('--structured', '输出完全结构化的 JSON(不包含自然语言字符串,需要配合 --json 使用)')
130
- .action(cyclesCommand);
174
+ .action(await createActionHandler('cycles', cyclesCommand));
131
175
  program
132
176
  .command('complexity')
133
177
  .description('分析代码复杂度(圈复杂度、认知复杂度、可维护性)')
@@ -135,7 +179,7 @@ program
135
179
  .option('-d, --detail', '显示函数级复杂度详情(使用 AST 精确分析)')
136
180
  .option('-j, --json', 'JSON 格式输出')
137
181
  .option('--structured', '输出完全结构化的 JSON(不包含自然语言字符串,需要配合 --json 使用)')
138
- .action(complexityCommand);
182
+ .action(await createActionHandler('complexity', complexityCommand));
139
183
  program
140
184
  .command('impact')
141
185
  .description('分析文件变更的影响范围')
@@ -143,14 +187,14 @@ program
143
187
  .option('-t, --transitive', '包含传递依赖')
144
188
  .option('-j, --json', 'JSON 格式输出')
145
189
  .option('--structured', '输出完全结构化的 JSON(不包含自然语言字符串,需要配合 --json 使用)')
146
- .action(impactCommand);
190
+ .action(await createActionHandler('impact', impactCommand));
147
191
  configureAnalyzeCommand(program
148
192
  .command('analyze')
149
- .description(ANALYZE_COMMAND_DESCRIPTION)).action(async () => {
193
+ .description(ANALYZE_COMMAND_DESCRIPTION)).action(await createActionHandler('analyze', async () => {
150
194
  const { analyzeCommand } = await import('./commands/analyze.js');
151
195
  // 跳过 program name 和 command name
152
196
  await analyzeCommand(process.argv.slice(2));
153
- });
197
+ }));
154
198
  // CI Gateway 命令
155
199
  program.addCommand(ciCommand);
156
200
  // Contract gate 命令
@@ -163,6 +207,23 @@ program.addCommand(publishStatusCommand);
163
207
  program.addCommand(readinessGateCommand);
164
208
  // Experimental MCP 命令
165
209
  program.addCommand(mcpCommand);
210
+ // Doctor command
211
+ program.addCommand(doctorCommand);
212
+ // Preview command
213
+ program.addCommand(previewCommand);
214
+ // Env-contract command
215
+ program.addCommand(envContractCommand);
216
+ // Agent-metrics command
217
+ program.addCommand(agentMetricsCommand);
218
+ // Benchmark command
219
+ program
220
+ .command('benchmark')
221
+ .description('Compare WASM vs Native performance')
222
+ .option('-t, --target <path>', 'Target repository', '.')
223
+ .option('-m, --mode <mode>', 'Benchmark mode: native, wasm, both', 'both')
224
+ .option('-i, --iterations <n>', 'Number of iterations', '3')
225
+ .option('-j, --json', 'JSON output')
226
+ .action(benchmarkCommand);
166
227
  // Workflow 命令
167
228
  program.addCommand(workflowCommand);
168
229
  // Export 命令
@@ -180,5 +241,16 @@ program
180
241
  .option('--verbose', '显示详细输出')
181
242
  .option('--yes, -y', '置信度 60-75 时自动确认(不询问)')
182
243
  .action(shipCommand);
244
+ // Handle --native flag: disable WASM fallback before any command runs
245
+ const cliOpts = program.opts();
246
+ if (cliOpts.native) {
247
+ process.env.CODEMAP_USE_WASM_TREE_SITTER = '0';
248
+ process.env.CODEMAP_USE_WASM_BETTER_SQLITE3 = '0';
249
+ }
250
+ // Handle --wasm-fallback flag: activate WASM fallback before any command runs
251
+ if (cliOpts.wasmFallback) {
252
+ process.env.CODEMAP_USE_WASM_TREE_SITTER = '1';
253
+ process.env.CODEMAP_USE_WASM_BETTER_SQLITE3 = '1';
254
+ }
183
255
  program.parse();
184
256
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,kEA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AC9B,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC;KAC7B,MAAM,CAAC,WAAW,EAAE,sBAAsB,CAAC;KAC3C,MAAM,CAAC,WAAW,CAAC,CAAC;AAEvB,sEAAsE;AACtE,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAC/B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,GAAG,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,+BAA+B,GAAG,GAAG,CAAC;AACpD,CAAC;AAED,8EAA8E;AAC9E,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IACzB,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,GAAG,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,+BAA+B,GAAG,GAAG,CAAC;AACpD,CAAC;AAED,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { InitAsset } from './reconciler.js';
2
+ export type AssistantProfile = 'claude' | 'codex' | 'generic';
3
+ interface FileWriteAction {
4
+ targetPath: string;
5
+ content: string;
6
+ }
7
+ export interface AssistantPlan {
8
+ assets: InitAsset[];
9
+ writes: FileWriteAction[];
10
+ }
11
+ export declare function createAssistantPlan(rootDir: string, assistantProfile?: AssistantProfile, profileName?: string): AssistantPlan;
12
+ export declare function applyAssistantPlan(plan: AssistantPlan): Promise<void>;
13
+ export {};
14
+ //# sourceMappingURL=assistant-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assistant-plan.d.ts","sourceRoot":"","sources":["../../../src/cli/init/assistant-plan.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAE9D,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAiKD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,CAAC,EAAE,MAAM,GACnB,aAAa,CA4Df;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAK3E"}
@@ -0,0 +1,208 @@
1
+ // [META] since:2026-05-02 | owner:cli-team | stable:false
2
+ // [WHY] 为 init 提供 per-runtime assistant bootstrap 资产生成,让 Claude/Codex/generic 助手快速连接项目上下文
3
+ import { createHash } from 'node:crypto';
4
+ import { existsSync, readFileSync } from 'node:fs';
5
+ import { mkdir, writeFile } from 'node:fs/promises';
6
+ import path from 'node:path';
7
+ function hashText(text) {
8
+ return createHash('sha256').update(text).digest('hex').slice(0, 12);
9
+ }
10
+ function safeReadText(filePath) {
11
+ if (!existsSync(filePath)) {
12
+ return undefined;
13
+ }
14
+ return readFileSync(filePath, 'utf8');
15
+ }
16
+ function generateClaudeContext(_rootDir, profileName) {
17
+ return `# CodeMap - Claude Context
18
+
19
+ > Auto-generated by \`mycodemap init\`. Review and copy relevant sections into your project CLAUDE.md.
20
+
21
+ ## Project Setup
22
+
23
+ - **Profile:** ${profileName ?? 'generic'}
24
+ - **Env Contract:** \`.mycodemap/env-contract.json\`
25
+ - **Rules:** \`.mycodemap/rules/\`
26
+ - **Init Receipt:** \`.mycodemap/status/init-last.json\`
27
+
28
+ ## Quick Commands
29
+
30
+ \`\`\`bash
31
+ mycodemap doctor # Diagnose project health
32
+ mycodemap generate # Generate code map
33
+ mycodemap preview # Preview without config
34
+ \`\`\`
35
+
36
+ ## Subagent Retrieval
37
+
38
+ For delegated-start reminders, enable the runtime hook adapter:
39
+
40
+ mycodemap env-contract --run-reminder-hook claude
41
+
42
+ When you need the Project Environment Contract directly, query:
43
+
44
+ mycodemap env-contract --for default --json
45
+
46
+ Use --for explore, --for plan, --for worker, or --for verify when the delegated role is known.
47
+
48
+ > This file is a copy-paste suggestion. Do NOT auto-rewrite your CLAUDE.md.
49
+ `;
50
+ }
51
+ function generateAgentsContext(_rootDir, profileName) {
52
+ return `# CodeMap - Agents Context
53
+
54
+ > Auto-generated by \`mycodemap init\`. Review and copy relevant sections into your project AGENTS.md.
55
+
56
+ ## Project Setup
57
+
58
+ - **Profile:** ${profileName ?? 'generic'}
59
+ - **Env Contract:** \`.mycodemap/env-contract.json\`
60
+ - **Rules:** \`.mycodemap/rules/\`
61
+ - **Init Receipt:** \`.mycodemap/status/init-last.json\`
62
+
63
+ ## Quick Commands
64
+
65
+ \`\`\`bash
66
+ mycodemap doctor # Diagnose project health
67
+ mycodemap generate # Generate code map
68
+ mycodemap preview # Preview without config
69
+ \`\`\`
70
+
71
+ ## Subagent Retrieval
72
+
73
+ For delegated-start reminders, enable the runtime hook adapter:
74
+
75
+ mycodemap env-contract --run-reminder-hook codex
76
+
77
+ When you need the Project Environment Contract directly, query:
78
+
79
+ mycodemap env-contract --for default --json
80
+
81
+ Use --for explore, --for plan, --for worker, or --for verify when the delegated role is known.
82
+
83
+ > This file is a copy-paste suggestion. Do NOT auto-rewrite your AGENTS.md.
84
+ `;
85
+ }
86
+ function generateClaudeHookExample() {
87
+ return JSON.stringify({
88
+ _comment: 'Example Claude Code SubagentStart hook — NOT active by default. Copy to .claude/settings.json to enable.',
89
+ hooks: {
90
+ SubagentStart: [
91
+ {
92
+ matcher: '',
93
+ hooks: [
94
+ {
95
+ type: 'command',
96
+ command: 'mycodemap env-contract --run-reminder-hook claude',
97
+ },
98
+ ],
99
+ },
100
+ ],
101
+ },
102
+ }, null, 2);
103
+ }
104
+ function generateCodexAgentExample() {
105
+ return `# Example Codex agent developer_instructions — NOT active by default.
106
+ # Copy to .codex/agents/ to enable subagent contract retrieval.
107
+
108
+ [developer_instructions]
109
+ description = "Retrieve project environment contract for delegated agents"
110
+
111
+ developer_instructions = """
112
+ Enable the delegated-start reminder hook:
113
+ - mycodemap env-contract --run-reminder-hook codex
114
+
115
+ When you need the project environment contract:
116
+ - CLI: mycodemap env-contract --for worker --json
117
+ - MCP: codemap_env_contract(agentType="worker")
118
+ """
119
+ `;
120
+ }
121
+ const ASSISTANT_ASSETS = [
122
+ {
123
+ runtime: 'claude',
124
+ fileName: 'claude-context.md',
125
+ generate: (rootDir, profileName) => generateClaudeContext(rootDir, profileName),
126
+ },
127
+ {
128
+ runtime: 'codex',
129
+ fileName: 'agents-context.md',
130
+ generate: (rootDir, profileName) => generateAgentsContext(rootDir, profileName),
131
+ },
132
+ {
133
+ runtime: 'claude',
134
+ fileName: 'claude-hook-example.json',
135
+ generate: () => generateClaudeHookExample(),
136
+ },
137
+ {
138
+ runtime: 'codex',
139
+ fileName: 'codex-agent-example.toml',
140
+ generate: () => generateCodexAgentExample(),
141
+ },
142
+ ];
143
+ function assetKey(fileName) {
144
+ const base = fileName.replace(/\.[^.]+$/, '');
145
+ return `assistant:${base}`;
146
+ }
147
+ export function createAssistantPlan(rootDir, assistantProfile, profileName) {
148
+ const assets = [];
149
+ const writes = [];
150
+ for (const def of ASSISTANT_ASSETS) {
151
+ if (assistantProfile && def.runtime !== assistantProfile) {
152
+ continue;
153
+ }
154
+ const targetPath = path.join(rootDir, '.mycodemap', 'assistants', def.fileName);
155
+ const content = def.generate(rootDir, profileName);
156
+ const key = assetKey(def.fileName);
157
+ const currentText = safeReadText(targetPath);
158
+ if (currentText === content) {
159
+ assets.push({
160
+ key,
161
+ label: def.fileName,
162
+ status: 'already-synced',
163
+ ownership: 'tool-owned',
164
+ origin: 'assistant-bootstrap',
165
+ path: targetPath,
166
+ details: [`${def.fileName} 已同步,无需更新`],
167
+ hash: hashText(content),
168
+ });
169
+ continue;
170
+ }
171
+ if (currentText !== undefined) {
172
+ assets.push({
173
+ key,
174
+ label: def.fileName,
175
+ status: 'conflict',
176
+ ownership: 'tool-owned',
177
+ origin: 'assistant-bootstrap',
178
+ path: targetPath,
179
+ details: [
180
+ `检测到 .mycodemap/assistants/${def.fileName} 与预期内容存在差异;本次不会自动覆盖`,
181
+ ],
182
+ hash: hashText(content),
183
+ manualAction: `手动审阅 .mycodemap/assistants/${def.fileName} 的内容,确认后可删除该文件再重跑 init`,
184
+ });
185
+ continue;
186
+ }
187
+ writes.push({ targetPath, content });
188
+ assets.push({
189
+ key,
190
+ label: def.fileName,
191
+ status: 'installed',
192
+ ownership: 'tool-owned',
193
+ origin: 'assistant-bootstrap',
194
+ path: targetPath,
195
+ details: [`将生成 .mycodemap/assistants/${def.fileName}`],
196
+ hash: hashText(content),
197
+ rollbackHint: `如需回退,可删除 .mycodemap/assistants/${def.fileName}`,
198
+ });
199
+ }
200
+ return { assets, writes };
201
+ }
202
+ export async function applyAssistantPlan(plan) {
203
+ for (const writeAction of plan.writes) {
204
+ await mkdir(path.dirname(writeAction.targetPath), { recursive: true });
205
+ await writeFile(writeAction.targetPath, writeAction.content, 'utf8');
206
+ }
207
+ }
208
+ //# sourceMappingURL=assistant-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assistant-plan.js","sourceRoot":"","sources":["../../../src/cli/init/assistant-plan.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,0FAA0F;AAE1F,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAqB7B,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CA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WAAW,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,MAAM,SAAS,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ export type ProjectType = 'nodejs' | 'python' | 'go' | 'rust' | 'generic';
2
+ export interface DetectionCandidate {
3
+ type: ProjectType;
4
+ markerFile: string;
5
+ confidence: 'high' | 'low';
6
+ }
7
+ export interface DetectionResult {
8
+ candidates: DetectionCandidate[];
9
+ recommended: ProjectType | null;
10
+ }
11
+ /**
12
+ * Detect dominant project type by marker files only.
13
+ *
14
+ * - 0 markers → `{ candidates: [], recommended: null }` (caller must refuse per D-04).
15
+ * - 1 marker → `{ candidates: [...], recommended: <type> }`.
16
+ * - 2+ markers → `{ candidates: [...], recommended: null }` forces disambiguation per D-02.
17
+ *
18
+ * Pure function: synchronous existsSync; no content reads; no process.exit.
19
+ */
20
+ export declare function detectProjectType(rootDir: string): DetectionResult;
21
+ /**
22
+ * Interactive numeric-choice prompt for multi-marker disambiguation.
23
+ *
24
+ * Caller must verify TTY availability (D-12) before invoking this; non-TTY
25
+ * callers should require `--profile <name>` instead.
26
+ */
27
+ export declare function promptForProfileSelection(candidates: DetectionCandidate[]): Promise<ProjectType>;
28
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../src/cli/init/detect.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;AAE1E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;CACjC;AASD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAiBlE;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,kBAAkB,EAAE,GAC/B,OAAO,CAAC,WAAW,CAAC,CAiBtB"}
@@ -0,0 +1,63 @@
1
+ // [META] since:2026-05-01 | owner:cli-team | stable:false
2
+ // [WHY] Phase 53 marker-only project type detection for `mycodemap init`.
3
+ // Detects nodejs/python/go/rust by marker files (no content sniffing); supports
4
+ // interactive disambiguation when multiple markers coexist.
5
+ import { existsSync } from 'node:fs';
6
+ import path from 'node:path';
7
+ import { createInterface } from 'node:readline/promises';
8
+ import { stdin as input, stdout as output } from 'node:process';
9
+ const MARKER_MAP = Object.freeze({
10
+ 'package.json': 'nodejs',
11
+ 'pyproject.toml': 'python',
12
+ 'go.mod': 'go',
13
+ 'Cargo.toml': 'rust',
14
+ });
15
+ /**
16
+ * Detect dominant project type by marker files only.
17
+ *
18
+ * - 0 markers → `{ candidates: [], recommended: null }` (caller must refuse per D-04).
19
+ * - 1 marker → `{ candidates: [...], recommended: <type> }`.
20
+ * - 2+ markers → `{ candidates: [...], recommended: null }` forces disambiguation per D-02.
21
+ *
22
+ * Pure function: synchronous existsSync; no content reads; no process.exit.
23
+ */
24
+ export function detectProjectType(rootDir) {
25
+ const candidates = [];
26
+ for (const [file, type] of Object.entries(MARKER_MAP)) {
27
+ if (existsSync(path.join(rootDir, file))) {
28
+ candidates.push({ type, markerFile: file, confidence: 'high' });
29
+ }
30
+ }
31
+ if (candidates.length === 0) {
32
+ return { candidates: [], recommended: null };
33
+ }
34
+ if (candidates.length === 1) {
35
+ return { candidates, recommended: candidates[0].type };
36
+ }
37
+ return { candidates, recommended: null };
38
+ }
39
+ /**
40
+ * Interactive numeric-choice prompt for multi-marker disambiguation.
41
+ *
42
+ * Caller must verify TTY availability (D-12) before invoking this; non-TTY
43
+ * callers should require `--profile <name>` instead.
44
+ */
45
+ export async function promptForProfileSelection(candidates) {
46
+ console.log('检测到多个项目类型标记:');
47
+ candidates.forEach((c, i) => {
48
+ console.log(` ${i + 1}) ${c.type} (${c.markerFile})`);
49
+ });
50
+ const readline = createInterface({ input, output });
51
+ try {
52
+ const answer = await readline.question('请选择 (输入编号): ');
53
+ const index = parseInt(answer.trim(), 10) - 1;
54
+ if (Number.isInteger(index) && index >= 0 && index < candidates.length) {
55
+ return candidates[index].type;
56
+ }
57
+ throw new Error('无效选择');
58
+ }
59
+ finally {
60
+ readline.close();
61
+ }
62
+ }
63
+ //# sourceMappingURL=detect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.js","sourceRoot":"","sources":["../../../src/cli/init/detect.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,0EAA0E;AAC1E,gFAAgF;AAChF,4DAA4D;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,cAAc,CAAC;AAehE,MAAM,UAAU,GAAgC,MAAM,CAAC,MAAM,CAAC;IAC5D,cAAc,EAAE,QAAQ;IACxB,gBAAgB,EAAE,QAAQ;IAC1B,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,MAAM;CACrB,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,MAAM,UAAU,GAAyB,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACtD,IAAI,UAAU,CAAC,IA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C,IAAI,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;YACvE,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;QAChC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;YAAS,CAAC;QACT,QAAQ,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { InitAsset } from './reconciler.js';
2
+ interface FileWriteAction {
3
+ targetPath: string;
4
+ content: string;
5
+ }
6
+ export interface EnvContractPlan {
7
+ assets: InitAsset[];
8
+ writes: FileWriteAction[];
9
+ }
10
+ /**
11
+ * Build an EnvContractPlan describing the env-contract.json decision.
12
+ *
13
+ * States:
14
+ * - file exists + same content → already-synced
15
+ * - file exists + seed v1 → migrate + installed (deterministic)
16
+ * - file exists + different + not seed → conflict (manual review)
17
+ * - file missing + preview mode → skipped
18
+ * - file missing + apply mode → installed + write action
19
+ */
20
+ export declare function createEnvContractPlan(rootDir: string, profileName?: string, mode?: 'preview' | 'apply', options?: {
21
+ generatedAt?: string;
22
+ }): EnvContractPlan;
23
+ /**
24
+ * Apply the env-contract plan: write the JSON file to disk.
25
+ */
26
+ export declare function applyEnvContractPlan(plan: EnvContractPlan): Promise<void>;
27
+ export {};
28
+ //# sourceMappingURL=env-contract-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-contract-plan.d.ts","sourceRoot":"","sources":["../../../src/cli/init/env-contract-plan.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAKjD,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAiDD;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,EACpB,IAAI,GAAE,SAAS,GAAG,OAAiB,EACnC,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACjC,eAAe,CAqIjB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAK/E"}