@mycodemap/mycodemap 2.0.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 (424) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +59 -184
  3. package/dist/cli/commands/agent-metrics/human.d.ts +4 -0
  4. package/dist/cli/commands/agent-metrics/human.d.ts.map +1 -0
  5. package/dist/cli/commands/agent-metrics/human.js +134 -0
  6. package/dist/cli/commands/agent-metrics/human.js.map +1 -0
  7. package/dist/cli/commands/agent-metrics/index.d.ts +15 -0
  8. package/dist/cli/commands/agent-metrics/index.d.ts.map +1 -0
  9. package/dist/cli/commands/agent-metrics/index.js +116 -0
  10. package/dist/cli/commands/agent-metrics/index.js.map +1 -0
  11. package/dist/cli/commands/analyze.d.ts +3 -196
  12. package/dist/cli/commands/analyze.d.ts.map +1 -1
  13. package/dist/cli/commands/analyze.js +9 -1163
  14. package/dist/cli/commands/analyze.js.map +1 -1
  15. package/dist/cli/commands/benchmark.d.ts.map +1 -1
  16. package/dist/cli/commands/benchmark.js +5 -2
  17. package/dist/cli/commands/benchmark.js.map +1 -1
  18. package/dist/cli/commands/complexity.d.ts.map +1 -1
  19. package/dist/cli/commands/complexity.js +62 -95
  20. package/dist/cli/commands/complexity.js.map +1 -1
  21. package/dist/cli/commands/deps.d.ts +3 -60
  22. package/dist/cli/commands/deps.d.ts.map +1 -1
  23. package/dist/cli/commands/deps.js +16 -351
  24. package/dist/cli/commands/deps.js.map +1 -1
  25. package/dist/cli/commands/env-contract.d.ts +3 -0
  26. package/dist/cli/commands/env-contract.d.ts.map +1 -0
  27. package/dist/cli/commands/env-contract.js +221 -0
  28. package/dist/cli/commands/env-contract.js.map +1 -0
  29. package/dist/cli/commands/generate.d.ts +19 -1
  30. package/dist/cli/commands/generate.d.ts.map +1 -1
  31. package/dist/cli/commands/generate.js +735 -89
  32. package/dist/cli/commands/generate.js.map +1 -1
  33. package/dist/cli/commands/impact.d.ts +4 -38
  34. package/dist/cli/commands/impact.d.ts.map +1 -1
  35. package/dist/cli/commands/impact.js +133 -375
  36. package/dist/cli/commands/impact.js.map +1 -1
  37. package/dist/cli/commands/init.d.ts +1 -0
  38. package/dist/cli/commands/init.d.ts.map +1 -1
  39. package/dist/cli/commands/init.js +61 -2
  40. package/dist/cli/commands/init.js.map +1 -1
  41. package/dist/cli/commands/preview.d.ts +3 -0
  42. package/dist/cli/commands/preview.d.ts.map +1 -0
  43. package/dist/cli/commands/preview.js +216 -0
  44. package/dist/cli/commands/preview.js.map +1 -0
  45. package/dist/cli/commands/query.d.ts +2 -21
  46. package/dist/cli/commands/query.d.ts.map +1 -1
  47. package/dist/cli/commands/query.js +15 -683
  48. package/dist/cli/commands/query.js.map +1 -1
  49. package/dist/cli/commands/watch-foreground.d.ts.map +1 -1
  50. package/dist/cli/commands/watch-foreground.js +5 -1
  51. package/dist/cli/commands/watch-foreground.js.map +1 -1
  52. package/dist/cli/config-loader.d.ts.map +1 -1
  53. package/dist/cli/config-loader.js +51 -13
  54. package/dist/cli/config-loader.js.map +1 -1
  55. package/dist/cli/doctor/check-env-contract.d.ts +3 -0
  56. package/dist/cli/doctor/check-env-contract.d.ts.map +1 -0
  57. package/dist/cli/doctor/check-env-contract.js +96 -0
  58. package/dist/cli/doctor/check-env-contract.js.map +1 -0
  59. package/dist/cli/doctor/check-native-deps.d.ts.map +1 -1
  60. package/dist/cli/doctor/check-native-deps.js +20 -4
  61. package/dist/cli/doctor/check-native-deps.js.map +1 -1
  62. package/dist/cli/doctor/orchestrator.d.ts.map +1 -1
  63. package/dist/cli/doctor/orchestrator.js +5 -2
  64. package/dist/cli/doctor/orchestrator.js.map +1 -1
  65. package/dist/cli/env-contract/check.d.ts +18 -0
  66. package/dist/cli/env-contract/check.d.ts.map +1 -0
  67. package/dist/cli/env-contract/check.js +118 -0
  68. package/dist/cli/env-contract/check.js.map +1 -0
  69. package/dist/cli/env-contract/discovery.d.ts +12 -0
  70. package/dist/cli/env-contract/discovery.d.ts.map +1 -0
  71. package/dist/cli/env-contract/discovery.js +249 -0
  72. package/dist/cli/env-contract/discovery.js.map +1 -0
  73. package/dist/cli/env-contract/filters.d.ts +10 -0
  74. package/dist/cli/env-contract/filters.d.ts.map +1 -0
  75. package/dist/cli/env-contract/filters.js +23 -0
  76. package/dist/cli/env-contract/filters.js.map +1 -0
  77. package/dist/cli/env-contract/index.d.ts +6 -0
  78. package/dist/cli/env-contract/index.d.ts.map +1 -0
  79. package/dist/cli/env-contract/index.js +8 -0
  80. package/dist/cli/env-contract/index.js.map +1 -0
  81. package/dist/cli/env-contract/reminder-engine.d.ts +34 -0
  82. package/dist/cli/env-contract/reminder-engine.d.ts.map +1 -0
  83. package/dist/cli/env-contract/reminder-engine.js +51 -0
  84. package/dist/cli/env-contract/reminder-engine.js.map +1 -0
  85. package/dist/cli/env-contract/reminder-hook-runner.d.ts +45 -0
  86. package/dist/cli/env-contract/reminder-hook-runner.d.ts.map +1 -0
  87. package/dist/cli/env-contract/reminder-hook-runner.js +273 -0
  88. package/dist/cli/env-contract/reminder-hook-runner.js.map +1 -0
  89. package/dist/cli/env-contract/reminder-ledger.d.ts +11 -0
  90. package/dist/cli/env-contract/reminder-ledger.d.ts.map +1 -0
  91. package/dist/cli/env-contract/reminder-ledger.js +37 -0
  92. package/dist/cli/env-contract/reminder-ledger.js.map +1 -0
  93. package/dist/cli/env-contract/types.d.ts +48 -0
  94. package/dist/cli/env-contract/types.d.ts.map +1 -0
  95. package/dist/cli/env-contract/types.js +22 -0
  96. package/dist/cli/env-contract/types.js.map +1 -0
  97. package/dist/cli/env-contract/validation.d.ts +10 -0
  98. package/dist/cli/env-contract/validation.d.ts.map +1 -0
  99. package/dist/cli/env-contract/validation.js +116 -0
  100. package/dist/cli/env-contract/validation.js.map +1 -0
  101. package/dist/cli/first-run-guide.d.ts.map +1 -1
  102. package/dist/cli/first-run-guide.js +8 -3
  103. package/dist/cli/first-run-guide.js.map +1 -1
  104. package/dist/cli/index.js +23 -3
  105. package/dist/cli/index.js.map +1 -1
  106. package/dist/cli/init/assistant-plan.d.ts +14 -0
  107. package/dist/cli/init/assistant-plan.d.ts.map +1 -0
  108. package/dist/cli/init/assistant-plan.js +208 -0
  109. package/dist/cli/init/assistant-plan.js.map +1 -0
  110. package/dist/cli/init/detect.d.ts +28 -0
  111. package/dist/cli/init/detect.d.ts.map +1 -0
  112. package/dist/cli/init/detect.js +63 -0
  113. package/dist/cli/init/detect.js.map +1 -0
  114. package/dist/cli/init/env-contract-plan.d.ts +28 -0
  115. package/dist/cli/init/env-contract-plan.d.ts.map +1 -0
  116. package/dist/cli/init/env-contract-plan.js +184 -0
  117. package/dist/cli/init/env-contract-plan.js.map +1 -0
  118. package/dist/cli/init/manifest-extractors.d.ts +22 -0
  119. package/dist/cli/init/manifest-extractors.d.ts.map +1 -0
  120. package/dist/cli/init/manifest-extractors.js +185 -0
  121. package/dist/cli/init/manifest-extractors.js.map +1 -0
  122. package/dist/cli/init/profile-loader.d.ts +49 -0
  123. package/dist/cli/init/profile-loader.d.ts.map +1 -0
  124. package/dist/cli/init/profile-loader.js +107 -0
  125. package/dist/cli/init/profile-loader.js.map +1 -0
  126. package/dist/cli/init/profile-plan.d.ts +38 -0
  127. package/dist/cli/init/profile-plan.d.ts.map +1 -0
  128. package/dist/cli/init/profile-plan.js +120 -0
  129. package/dist/cli/init/profile-plan.js.map +1 -0
  130. package/dist/cli/init/profiles/generic.json +16 -0
  131. package/dist/cli/init/profiles/go.json +12 -0
  132. package/dist/cli/init/profiles/nodejs.json +16 -0
  133. package/dist/cli/init/profiles/python.json +17 -0
  134. package/dist/cli/init/profiles/rust.json +12 -0
  135. package/dist/cli/init/receipt.d.ts.map +1 -1
  136. package/dist/cli/init/receipt.js +107 -7
  137. package/dist/cli/init/receipt.js.map +1 -1
  138. package/dist/cli/init/reconciler.d.ts +10 -1
  139. package/dist/cli/init/reconciler.d.ts.map +1 -1
  140. package/dist/cli/init/reconciler.js +85 -15
  141. package/dist/cli/init/reconciler.js.map +1 -1
  142. package/dist/cli/interface-contract/commands/agent-metrics.d.ts +3 -0
  143. package/dist/cli/interface-contract/commands/agent-metrics.d.ts.map +1 -0
  144. package/dist/cli/interface-contract/commands/agent-metrics.js +217 -0
  145. package/dist/cli/interface-contract/commands/agent-metrics.js.map +1 -0
  146. package/dist/cli/interface-contract/commands/analyze.d.ts.map +1 -1
  147. package/dist/cli/interface-contract/commands/analyze.js +1 -0
  148. package/dist/cli/interface-contract/commands/analyze.js.map +1 -1
  149. package/dist/cli/interface-contract/commands/benchmark.d.ts.map +1 -1
  150. package/dist/cli/interface-contract/commands/benchmark.js +1 -0
  151. package/dist/cli/interface-contract/commands/benchmark.js.map +1 -1
  152. package/dist/cli/interface-contract/commands/deps.d.ts.map +1 -1
  153. package/dist/cli/interface-contract/commands/deps.js +1 -0
  154. package/dist/cli/interface-contract/commands/deps.js.map +1 -1
  155. package/dist/cli/interface-contract/commands/doctor.d.ts.map +1 -1
  156. package/dist/cli/interface-contract/commands/doctor.js +1 -0
  157. package/dist/cli/interface-contract/commands/doctor.js.map +1 -1
  158. package/dist/cli/interface-contract/commands/env-contract.d.ts +3 -0
  159. package/dist/cli/interface-contract/commands/env-contract.d.ts.map +1 -0
  160. package/dist/cli/interface-contract/commands/env-contract.js +168 -0
  161. package/dist/cli/interface-contract/commands/env-contract.js.map +1 -0
  162. package/dist/cli/interface-contract/commands/index.d.ts +5 -2
  163. package/dist/cli/interface-contract/commands/index.d.ts.map +1 -1
  164. package/dist/cli/interface-contract/commands/index.js +7 -1
  165. package/dist/cli/interface-contract/commands/index.js.map +1 -1
  166. package/dist/cli/interface-contract/commands/init.d.ts.map +1 -1
  167. package/dist/cli/interface-contract/commands/init.js +9 -0
  168. package/dist/cli/interface-contract/commands/init.js.map +1 -1
  169. package/dist/cli/interface-contract/commands/preview.d.ts +3 -0
  170. package/dist/cli/interface-contract/commands/preview.d.ts.map +1 -0
  171. package/dist/cli/interface-contract/commands/preview.js +118 -0
  172. package/dist/cli/interface-contract/commands/preview.js.map +1 -0
  173. package/dist/cli/interface-contract/commands/query.d.ts.map +1 -1
  174. package/dist/cli/interface-contract/commands/query.js +1 -0
  175. package/dist/cli/interface-contract/commands/query.js.map +1 -1
  176. package/dist/cli/interface-contract/index.d.ts +1 -1
  177. package/dist/cli/interface-contract/index.d.ts.map +1 -1
  178. package/dist/cli/interface-contract/index.js +2 -2
  179. package/dist/cli/interface-contract/index.js.map +1 -1
  180. package/dist/cli/interface-contract/schema.d.ts.map +1 -1
  181. package/dist/cli/interface-contract/schema.js +1 -0
  182. package/dist/cli/interface-contract/schema.js.map +1 -1
  183. package/dist/cli/interface-contract/types.d.ts +1 -0
  184. package/dist/cli/interface-contract/types.d.ts.map +1 -1
  185. package/dist/cli/output/error-codes.d.ts +2 -0
  186. package/dist/cli/output/error-codes.d.ts.map +1 -1
  187. package/dist/cli/output/error-codes.js +12 -0
  188. package/dist/cli/output/error-codes.js.map +1 -1
  189. package/dist/cli/output/errors.d.ts.map +1 -1
  190. package/dist/cli/output/errors.js +12 -0
  191. package/dist/cli/output/errors.js.map +1 -1
  192. package/dist/cli/output/wasm-fallback.d.ts +1 -0
  193. package/dist/cli/output/wasm-fallback.d.ts.map +1 -1
  194. package/dist/cli/output/wasm-fallback.js.map +1 -1
  195. package/dist/cli/preview/complexity-scanner.d.ts +21 -0
  196. package/dist/cli/preview/complexity-scanner.d.ts.map +1 -0
  197. package/dist/cli/preview/complexity-scanner.js +52 -0
  198. package/dist/cli/preview/complexity-scanner.js.map +1 -0
  199. package/dist/cli/preview/dependency-extractor.d.ts +38 -0
  200. package/dist/cli/preview/dependency-extractor.d.ts.map +1 -0
  201. package/dist/cli/preview/dependency-extractor.js +140 -0
  202. package/dist/cli/preview/dependency-extractor.js.map +1 -0
  203. package/dist/cli/preview/preview-renderer.d.ts +32 -0
  204. package/dist/cli/preview/preview-renderer.d.ts.map +1 -0
  205. package/dist/cli/preview/preview-renderer.js +54 -0
  206. package/dist/cli/preview/preview-renderer.js.map +1 -0
  207. package/dist/cli/storage-runtime.d.ts +7 -0
  208. package/dist/cli/storage-runtime.d.ts.map +1 -1
  209. package/dist/cli/storage-runtime.js +22 -0
  210. package/dist/cli/storage-runtime.js.map +1 -1
  211. package/dist/cli-new/index.js +1 -1
  212. package/dist/cli-new/index.js.map +1 -1
  213. package/dist/composition/parser-composition.d.ts +7 -0
  214. package/dist/composition/parser-composition.d.ts.map +1 -0
  215. package/dist/composition/parser-composition.js +15 -0
  216. package/dist/composition/parser-composition.js.map +1 -0
  217. package/dist/core/analyzer.d.ts.map +1 -1
  218. package/dist/core/analyzer.js +83 -67
  219. package/dist/core/analyzer.js.map +1 -1
  220. package/dist/core/ast-complexity-analyzer.d.ts +12 -6
  221. package/dist/core/ast-complexity-analyzer.d.ts.map +1 -1
  222. package/dist/core/ast-complexity-analyzer.js +368 -209
  223. package/dist/core/ast-complexity-analyzer.js.map +1 -1
  224. package/dist/core/file-discovery.d.ts +1 -1
  225. package/dist/core/file-discovery.d.ts.map +1 -1
  226. package/dist/core/file-discovery.js +3 -0
  227. package/dist/core/file-discovery.js.map +1 -1
  228. package/dist/core/global-index.d.ts +3 -1
  229. package/dist/core/global-index.d.ts.map +1 -1
  230. package/dist/core/global-index.js +69 -4
  231. package/dist/core/global-index.js.map +1 -1
  232. package/dist/domain/entities/CodeGraph.d.ts +3 -0
  233. package/dist/domain/entities/CodeGraph.d.ts.map +1 -1
  234. package/dist/domain/entities/CodeGraph.js +19 -2
  235. package/dist/domain/entities/CodeGraph.js.map +1 -1
  236. package/dist/domain/entities/Dependency.d.ts +5 -2
  237. package/dist/domain/entities/Dependency.d.ts.map +1 -1
  238. package/dist/domain/entities/Dependency.js +49 -3
  239. package/dist/domain/entities/Dependency.js.map +1 -1
  240. package/dist/domain/repositories/CodeGraphRepository.d.ts +5 -0
  241. package/dist/domain/repositories/CodeGraphRepository.d.ts.map +1 -1
  242. package/dist/domain/repositories/CodeGraphRepository.js.map +1 -1
  243. package/dist/execution/contract-tools/analyze.d.ts +205 -0
  244. package/dist/execution/contract-tools/analyze.d.ts.map +1 -0
  245. package/dist/execution/contract-tools/analyze.js +1215 -0
  246. package/dist/execution/contract-tools/analyze.js.map +1 -0
  247. package/dist/execution/contract-tools/deps.d.ts +62 -0
  248. package/dist/execution/contract-tools/deps.d.ts.map +1 -0
  249. package/dist/execution/contract-tools/deps.js +234 -0
  250. package/dist/execution/contract-tools/deps.js.map +1 -0
  251. package/dist/execution/contract-tools/index.d.ts +5 -0
  252. package/dist/execution/contract-tools/index.d.ts.map +1 -0
  253. package/dist/execution/contract-tools/index.js +7 -0
  254. package/dist/execution/contract-tools/index.js.map +1 -0
  255. package/dist/execution/contract-tools/query.d.ts +60 -0
  256. package/dist/execution/contract-tools/query.d.ts.map +1 -0
  257. package/dist/execution/contract-tools/query.js +532 -0
  258. package/dist/execution/contract-tools/query.js.map +1 -0
  259. package/dist/execution/contract-tools/types.d.ts +26 -0
  260. package/dist/execution/contract-tools/types.d.ts.map +1 -0
  261. package/dist/execution/contract-tools/types.js +32 -0
  262. package/dist/execution/contract-tools/types.js.map +1 -0
  263. package/dist/generator/index.d.ts.map +1 -1
  264. package/dist/generator/index.js +0 -3
  265. package/dist/generator/index.js.map +1 -1
  266. package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.d.ts +12 -0
  267. package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.d.ts.map +1 -0
  268. package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.js +55 -0
  269. package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.js.map +1 -0
  270. package/dist/infrastructure/parser/implementations/GoParser.d.ts +2 -1
  271. package/dist/infrastructure/parser/implementations/GoParser.d.ts.map +1 -1
  272. package/dist/infrastructure/parser/implementations/GoParser.js +13 -1
  273. package/dist/infrastructure/parser/implementations/GoParser.js.map +1 -1
  274. package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.d.ts +114 -0
  275. package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.d.ts.map +1 -0
  276. package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.js +1022 -0
  277. package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.js.map +1 -0
  278. package/dist/infrastructure/parser/implementations/TreeSitterParser.d.ts +78 -0
  279. package/dist/infrastructure/parser/implementations/TreeSitterParser.d.ts.map +1 -0
  280. package/dist/infrastructure/parser/implementations/TreeSitterParser.js +648 -0
  281. package/dist/infrastructure/parser/implementations/TreeSitterParser.js.map +1 -0
  282. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts +3 -55
  283. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts.map +1 -1
  284. package/dist/infrastructure/parser/implementations/TypeScriptParser.js +4 -411
  285. package/dist/infrastructure/parser/implementations/TypeScriptParser.js.map +1 -1
  286. package/dist/infrastructure/parser/index.d.ts +2 -0
  287. package/dist/infrastructure/parser/index.d.ts.map +1 -1
  288. package/dist/infrastructure/parser/index.js +9 -6
  289. package/dist/infrastructure/parser/index.js.map +1 -1
  290. package/dist/infrastructure/parser/interfaces/ParserBase.d.ts.map +1 -1
  291. package/dist/infrastructure/parser/interfaces/ParserBase.js +1 -0
  292. package/dist/infrastructure/parser/interfaces/ParserBase.js.map +1 -1
  293. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts +2 -0
  294. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts.map +1 -1
  295. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js +4 -0
  296. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js.map +1 -1
  297. package/dist/infrastructure/storage/StorageFactory.d.ts +5 -18
  298. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -1
  299. package/dist/infrastructure/storage/StorageFactory.js +30 -98
  300. package/dist/infrastructure/storage/StorageFactory.js.map +1 -1
  301. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts +13 -1
  302. package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts.map +1 -1
  303. package/dist/infrastructure/storage/adapters/SQLiteStorage.js +321 -75
  304. package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -1
  305. package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts +22 -0
  306. package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts.map +1 -1
  307. package/dist/infrastructure/storage/adapters/sqlite-loader.js +78 -22
  308. package/dist/infrastructure/storage/adapters/sqlite-loader.js.map +1 -1
  309. package/dist/infrastructure/storage/community-helpers.d.ts +4 -0
  310. package/dist/infrastructure/storage/community-helpers.d.ts.map +1 -0
  311. package/dist/infrastructure/storage/community-helpers.js +392 -0
  312. package/dist/infrastructure/storage/community-helpers.js.map +1 -0
  313. package/dist/infrastructure/storage/graph-helpers.d.ts +22 -5
  314. package/dist/infrastructure/storage/graph-helpers.d.ts.map +1 -1
  315. package/dist/infrastructure/storage/graph-helpers.js +496 -91
  316. package/dist/infrastructure/storage/graph-helpers.js.map +1 -1
  317. package/dist/infrastructure/storage/index.d.ts +1 -1
  318. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  319. package/dist/infrastructure/storage/index.js +1 -1
  320. package/dist/infrastructure/storage/index.js.map +1 -1
  321. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +2 -2
  322. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -1
  323. package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -1
  324. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts +2 -0
  325. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts.map +1 -1
  326. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js +52 -12
  327. package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js.map +1 -1
  328. package/dist/infrastructure/storage/sqlite/schema.d.ts +2 -2
  329. package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -1
  330. package/dist/infrastructure/storage/sqlite/schema.js +49 -1
  331. package/dist/infrastructure/storage/sqlite/schema.js.map +1 -1
  332. package/dist/interface/config/index.d.ts +5 -3
  333. package/dist/interface/config/index.d.ts.map +1 -1
  334. package/dist/interface/types/index.d.ts +37 -6
  335. package/dist/interface/types/index.d.ts.map +1 -1
  336. package/dist/interface/types/parser.d.ts +85 -0
  337. package/dist/interface/types/parser.d.ts.map +1 -1
  338. package/dist/interface/types/storage.d.ts +227 -10
  339. package/dist/interface/types/storage.d.ts.map +1 -1
  340. package/dist/orchestrator/agent-metrics-service.d.ts +126 -0
  341. package/dist/orchestrator/agent-metrics-service.d.ts.map +1 -0
  342. package/dist/orchestrator/agent-metrics-service.js +444 -0
  343. package/dist/orchestrator/agent-metrics-service.js.map +1 -0
  344. package/dist/parser/enhancers/PythonTypeEnhancer.d.ts +26 -0
  345. package/dist/parser/enhancers/PythonTypeEnhancer.d.ts.map +1 -0
  346. package/dist/parser/enhancers/PythonTypeEnhancer.js +440 -0
  347. package/dist/parser/enhancers/PythonTypeEnhancer.js.map +1 -0
  348. package/dist/parser/implementations/smart-parser.d.ts.map +1 -1
  349. package/dist/parser/implementations/smart-parser.js +7 -69
  350. package/dist/parser/implementations/smart-parser.js.map +1 -1
  351. package/dist/parser/implementations/tree-sitter-loader.d.ts +2 -0
  352. package/dist/parser/implementations/tree-sitter-loader.d.ts.map +1 -1
  353. package/dist/parser/implementations/tree-sitter-loader.js +46 -15
  354. package/dist/parser/implementations/tree-sitter-loader.js.map +1 -1
  355. package/dist/parser/index.d.ts +5 -3
  356. package/dist/parser/index.d.ts.map +1 -1
  357. package/dist/parser/index.js +68 -6
  358. package/dist/parser/index.js.map +1 -1
  359. package/dist/parser/interfaces/IParser.d.ts +19 -6
  360. package/dist/parser/interfaces/IParser.d.ts.map +1 -1
  361. package/dist/parser/interfaces/IParser.js +2 -3
  362. package/dist/parser/interfaces/IParser.js.map +1 -1
  363. package/dist/server/handlers/AnalysisHandler.d.ts +13 -2
  364. package/dist/server/handlers/AnalysisHandler.d.ts.map +1 -1
  365. package/dist/server/handlers/AnalysisHandler.js +24 -0
  366. package/dist/server/handlers/AnalysisHandler.js.map +1 -1
  367. package/dist/server/handlers/QueryHandler.d.ts.map +1 -1
  368. package/dist/server/handlers/QueryHandler.js +11 -30
  369. package/dist/server/handlers/QueryHandler.js.map +1 -1
  370. package/dist/server/mcp/context-tool.d.ts +9 -0
  371. package/dist/server/mcp/context-tool.d.ts.map +1 -0
  372. package/dist/server/mcp/context-tool.js +257 -0
  373. package/dist/server/mcp/context-tool.js.map +1 -0
  374. package/dist/server/mcp/schema-adapter.d.ts +11 -1
  375. package/dist/server/mcp/schema-adapter.d.ts.map +1 -1
  376. package/dist/server/mcp/schema-adapter.js +126 -7
  377. package/dist/server/mcp/schema-adapter.js.map +1 -1
  378. package/dist/server/mcp/server.d.ts +3 -3
  379. package/dist/server/mcp/server.d.ts.map +1 -1
  380. package/dist/server/mcp/server.js +114 -30
  381. package/dist/server/mcp/server.js.map +1 -1
  382. package/dist/server/mcp/service.d.ts +6 -2
  383. package/dist/server/mcp/service.d.ts.map +1 -1
  384. package/dist/server/mcp/service.js +138 -36
  385. package/dist/server/mcp/service.js.map +1 -1
  386. package/dist/server/mcp/stdio-transport.d.ts +23 -0
  387. package/dist/server/mcp/stdio-transport.d.ts.map +1 -0
  388. package/dist/server/mcp/stdio-transport.js +101 -0
  389. package/dist/server/mcp/stdio-transport.js.map +1 -0
  390. package/dist/server/mcp/types.d.ts +133 -8
  391. package/dist/server/mcp/types.d.ts.map +1 -1
  392. package/dist/server/routes/api.d.ts.map +1 -1
  393. package/dist/server/routes/api.js +11 -2
  394. package/dist/server/routes/api.js.map +1 -1
  395. package/docs/AI_ASSISTANT_SETUP.md +112 -0
  396. package/docs/API.md +170 -0
  397. package/docs/CONFIGURATION.md +141 -0
  398. package/docs/DEVELOPMENT.md +96 -0
  399. package/docs/GETTING-STARTED.md +114 -0
  400. package/docs/SETUP_GUIDE.md +49 -0
  401. package/docs/TESTING.md +81 -0
  402. package/docs/ai-guide/OUTPUT.md +51 -8
  403. package/docs/backlog.md +232 -144
  404. package/docs/brainstorms/2026-05-10-agent-effectiveness-validation-requirements.md +112 -0
  405. package/docs/generated/phase-58/subagent-evidence/claude-hook-example.json +15 -0
  406. package/docs/generated/phase-58/subagent-evidence/claude-session.md +146 -0
  407. package/docs/generated/phase-58/subagent-evidence/claude-subagent.json +28 -0
  408. package/docs/generated/phase-58/subagent-evidence/codex-agent-example.toml +19 -0
  409. package/docs/generated/phase-58/subagent-evidence/codex-session.md +150 -0
  410. package/docs/generated/phase-58/subagent-evidence/codex-subagent.json +20 -0
  411. package/docs/generated/phase-58/subagent-evidence/negative-no-retrieval.json +12 -0
  412. package/docs/generated/phase-58/subagent-evidence/verification-manifest.json +19 -0
  413. package/docs/ideation/2026-05-02-subagent-environment-contract-injection-ideation.md +183 -0
  414. package/docs/ideation/2026-05-04-subagent-hooks-deep-dive-ideation.md +133 -0
  415. package/docs/ideation/2026-05-10-agent-effectiveness-validation-ideation.md +219 -0
  416. package/package.json +8 -3
  417. package/scripts/copy-build-assets.mjs +23 -0
  418. package/scripts/hooks/templates/pre-commit +33 -2
  419. package/scripts/tests/test_rule_control_workflow.py +15 -1
  420. package/scripts/verify-subagent-env-contract.mjs +279 -0
  421. package/dist/parser/implementations/tree-sitter-parser.d.ts +0 -60
  422. package/dist/parser/implementations/tree-sitter-parser.d.ts.map +0 -1
  423. package/dist/parser/implementations/tree-sitter-parser.js +0 -380
  424. package/dist/parser/implementations/tree-sitter-parser.js.map +0 -1
@@ -0,0 +1,184 @@
1
+ // [META] since:2026-05-02 | owner:cli-team | stable:false
2
+ // [WHY] Phase 55/58 — generate .mycodemap/env-contract.json from discovery engine.
3
+ // Phase 55 produced env-contract.seed.v1; Phase 58 upgrades to env-contract.v1.
4
+ import { existsSync, readFileSync } from 'node:fs';
5
+ import { mkdir, writeFile } from 'node:fs/promises';
6
+ import path from 'node:path';
7
+ import { discoverProjectEnvironmentContract } from '../env-contract/discovery.js';
8
+ const ASSET_KEY = 'env-contract';
9
+ const ASSET_LABEL = 'env-contract';
10
+ const ASSET_ORIGIN = 'discovery-engine';
11
+ function makeAsset(status, details, options = {}) {
12
+ return {
13
+ key: ASSET_KEY,
14
+ label: ASSET_LABEL,
15
+ status,
16
+ ownership: 'tool-owned',
17
+ origin: ASSET_ORIGIN,
18
+ path: options.path,
19
+ details,
20
+ hash: options.hash,
21
+ rollbackHint: options.rollbackHint,
22
+ manualAction: options.manualAction,
23
+ };
24
+ }
25
+ function normalizeContractForComparison(contract) {
26
+ const normalized = JSON.parse(JSON.stringify(contract));
27
+ delete normalized.generatedAt;
28
+ return JSON.stringify(normalized);
29
+ }
30
+ /**
31
+ * Check if existing content is a Phase 55 seed contract (env-contract.seed.v1).
32
+ */
33
+ function isSeedContract(parsed) {
34
+ return (typeof parsed === 'object' &&
35
+ parsed !== null &&
36
+ parsed.schemaVersion === 'env-contract.seed.v1');
37
+ }
38
+ /**
39
+ * Build an EnvContractPlan describing the env-contract.json decision.
40
+ *
41
+ * States:
42
+ * - file exists + same content → already-synced
43
+ * - file exists + seed v1 → migrate + installed (deterministic)
44
+ * - file exists + different + not seed → conflict (manual review)
45
+ * - file missing + preview mode → skipped
46
+ * - file missing + apply mode → installed + write action
47
+ */
48
+ export function createEnvContractPlan(rootDir, profileName, mode = 'apply', options) {
49
+ const targetPath = path.join(rootDir, '.mycodemap', 'env-contract.json');
50
+ const contract = discoverProjectEnvironmentContract(rootDir, {
51
+ profileName,
52
+ generatedAt: options?.generatedAt ?? new Date().toISOString(),
53
+ });
54
+ const contractJson = JSON.stringify(contract, null, 2);
55
+ // File already exists — check if content matches
56
+ if (existsSync(targetPath)) {
57
+ try {
58
+ const currentContent = readFileSync(targetPath, 'utf8');
59
+ // Try to parse existing content
60
+ let parsed;
61
+ try {
62
+ parsed = JSON.parse(currentContent);
63
+ }
64
+ catch {
65
+ // Unparseable — conflict
66
+ return {
67
+ assets: [
68
+ makeAsset('conflict', [
69
+ '无法解析 .mycodemap/env-contract.json,需手动确认',
70
+ ], {
71
+ path: targetPath,
72
+ manualAction: '手动审阅 .mycodemap/env-contract.json 的内容,确认后可删除该文件再重跑 init',
73
+ }),
74
+ ],
75
+ writes: [],
76
+ };
77
+ }
78
+ if (typeof parsed === 'object' &&
79
+ parsed !== null &&
80
+ normalizeContractForComparison(parsed) ===
81
+ normalizeContractForComparison(contract)) {
82
+ return {
83
+ assets: [
84
+ makeAsset('already-synced', [
85
+ 'env-contract.json 内容已同步,无需更新',
86
+ ], { path: targetPath }),
87
+ ],
88
+ writes: [],
89
+ };
90
+ }
91
+ // Seed v1 migration — deterministic upgrade
92
+ if (isSeedContract(parsed)) {
93
+ return {
94
+ assets: [
95
+ makeAsset('installed', [
96
+ '从 env-contract.seed.v1 迁移至 env-contract.v1',
97
+ `发现 ${contract.items.length} 项契约`,
98
+ `发现 ${contract.sourceSnapshots.length} 个源快照`,
99
+ ], {
100
+ path: targetPath,
101
+ rollbackHint: '如需回退,可删除 `.mycodemap/env-contract.json`',
102
+ }),
103
+ ],
104
+ writes: [
105
+ {
106
+ targetPath,
107
+ content: contractJson,
108
+ },
109
+ ],
110
+ };
111
+ }
112
+ // Content differs and is not a recognized seed — conflict
113
+ return {
114
+ assets: [
115
+ makeAsset('conflict', [
116
+ '检测到 .mycodemap/env-contract.json 与当前提取结果不同,本次不会自动覆盖',
117
+ ], {
118
+ path: targetPath,
119
+ manualAction: '手动审阅 .mycodemap/env-contract.json 的内容,确认后可删除该文件再重跑 init',
120
+ }),
121
+ ],
122
+ writes: [],
123
+ };
124
+ }
125
+ catch {
126
+ // Read error — treat as conflict
127
+ return {
128
+ assets: [
129
+ makeAsset('conflict', [
130
+ '无法读取 .mycodemap/env-contract.json,需手动确认',
131
+ ], {
132
+ path: targetPath,
133
+ manualAction: '手动审阅 .mycodemap/env-contract.json 的内容,确认后可删除该文件再重跑 init',
134
+ }),
135
+ ],
136
+ writes: [],
137
+ };
138
+ }
139
+ }
140
+ // Preview mode — don't write
141
+ if (mode === 'preview') {
142
+ return {
143
+ assets: [
144
+ makeAsset('skipped', [
145
+ `schemaVersion: ${contract.schemaVersion}`,
146
+ `projectProfile: ${contract.projectProfile.name}`,
147
+ `items: ${contract.items.length} 项`,
148
+ `sourceSnapshots: ${contract.sourceSnapshots.length} 个`,
149
+ '预览模式不会写入 .mycodemap/env-contract.json;使用 --yes 应用',
150
+ ]),
151
+ ],
152
+ writes: [],
153
+ };
154
+ }
155
+ // Apply mode — write the file
156
+ return {
157
+ assets: [
158
+ makeAsset('installed', [
159
+ '将生成 .mycodemap/env-contract.json',
160
+ `发现 ${contract.items.length} 项契约`,
161
+ `发现 ${contract.sourceSnapshots.length} 个源快照`,
162
+ ], {
163
+ path: targetPath,
164
+ rollbackHint: '如需回退,可删除 `.mycodemap/env-contract.json`',
165
+ }),
166
+ ],
167
+ writes: [
168
+ {
169
+ targetPath,
170
+ content: contractJson,
171
+ },
172
+ ],
173
+ };
174
+ }
175
+ /**
176
+ * Apply the env-contract plan: write the JSON file to disk.
177
+ */
178
+ export async function applyEnvContractPlan(plan) {
179
+ for (const write of plan.writes) {
180
+ await mkdir(path.dirname(write.targetPath), { recursive: true });
181
+ await writeFile(write.targetPath, write.content, 'utf8');
182
+ }
183
+ }
184
+ //# sourceMappingURL=env-contract-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-contract-plan.js","sourceRoot":"","sources":["../../../src/cli/init/env-contract-plan.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,mFAAmF;AACnF,gFAAgF;AAEhF,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;AAE7B,OAAO,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAclF,MAAM,SAAS,GAAG,cAAc,CAAC;AACjC,MAAM,WAAW,GAAG,cAAc,CAA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U;gBACV,OAAO,EAAE,YAAY;aACtB;SACF;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAqB;IAC9D,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,MAAM,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ export interface ManifestItem {
2
+ category: 'execution' | 'commit' | 'retrieval' | 'validation' | 'style';
3
+ key: string;
4
+ value?: string;
5
+ status?: 'unknown';
6
+ source: string;
7
+ confidence: 'high' | 'medium' | 'low' | 'none';
8
+ }
9
+ export interface ManifestFacts {
10
+ projectType: string;
11
+ projectSource: string;
12
+ items: ManifestItem[];
13
+ }
14
+ /**
15
+ * Extract obvious project facts from manifest files in `rootDir`.
16
+ *
17
+ * Reads package.json, pyproject.toml, go.mod, Cargo.toml for basic
18
+ * project metadata. Returns typed ManifestFacts with items[].
19
+ * Missing items are represented as status: 'unknown' with source: 'not-detected'.
20
+ */
21
+ export declare function extractManifestFacts(rootDir: string, profileName?: string): ManifestFacts;
22
+ //# sourceMappingURL=manifest-extractors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-extractors.d.ts","sourceRoot":"","sources":["../../../src/cli/init/manifest-extractors.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC;IACxE,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;CAChD;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAqKD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,GACnB,aAAa,CAoBf"}
@@ -0,0 +1,185 @@
1
+ // [META] since:2026-05-02 | owner:cli-team | stable:false
2
+ // [WHY] Phase 55 — extract obvious project facts from package.json, pyproject.toml,
3
+ // go.mod, Cargo.toml for env-contract seed generation.
4
+ import { existsSync, readFileSync } from 'node:fs';
5
+ import path from 'node:path';
6
+ import { parse as parseToml } from 'smol-toml';
7
+ function safeReadFile(filePath) {
8
+ if (!existsSync(filePath)) {
9
+ return undefined;
10
+ }
11
+ try {
12
+ return readFileSync(filePath, 'utf8');
13
+ }
14
+ catch {
15
+ return undefined;
16
+ }
17
+ }
18
+ function extractPackageJson(rootDir, items) {
19
+ const text = safeReadFile(path.join(rootDir, 'package.json'));
20
+ if (!text)
21
+ return;
22
+ try {
23
+ const pkg = JSON.parse(text);
24
+ const scripts = pkg.scripts;
25
+ if (scripts?.test) {
26
+ items.push({
27
+ category: 'execution',
28
+ key: 'testCommand',
29
+ value: scripts.test,
30
+ source: 'package.json:scripts.test',
31
+ confidence: 'high',
32
+ });
33
+ }
34
+ if (scripts?.build) {
35
+ items.push({
36
+ category: 'execution',
37
+ key: 'buildCommand',
38
+ value: scripts.build,
39
+ source: 'package.json:scripts.build',
40
+ confidence: 'high',
41
+ });
42
+ }
43
+ if (scripts?.lint) {
44
+ items.push({
45
+ category: 'execution',
46
+ key: 'lintCommand',
47
+ value: scripts.lint,
48
+ source: 'package.json:scripts.lint',
49
+ confidence: 'high',
50
+ });
51
+ }
52
+ if (typeof pkg.main === 'string') {
53
+ items.push({
54
+ category: 'execution',
55
+ key: 'entryPoint',
56
+ value: pkg.main,
57
+ source: 'package.json:main',
58
+ confidence: 'medium',
59
+ });
60
+ }
61
+ }
62
+ catch {
63
+ // skip malformed package.json
64
+ }
65
+ }
66
+ function extractPyprojectToml(rootDir, items) {
67
+ const text = safeReadFile(path.join(rootDir, 'pyproject.toml'));
68
+ if (!text)
69
+ return;
70
+ try {
71
+ const parsed = parseToml(text);
72
+ const project = parsed.project;
73
+ if (project?.name) {
74
+ items.push({
75
+ category: 'execution',
76
+ key: 'projectName',
77
+ value: String(project.name),
78
+ source: 'pyproject.toml:project.name',
79
+ confidence: 'high',
80
+ });
81
+ }
82
+ const tool = parsed.tool;
83
+ const pytest = tool?.pytest;
84
+ if (pytest?.ini_options) {
85
+ items.push({
86
+ category: 'execution',
87
+ key: 'testCommand',
88
+ value: 'pytest',
89
+ source: 'pyproject.toml:tool.pytest',
90
+ confidence: 'medium',
91
+ });
92
+ }
93
+ }
94
+ catch {
95
+ // skip malformed pyproject.toml
96
+ }
97
+ }
98
+ function extractGoMod(rootDir, items) {
99
+ const text = safeReadFile(path.join(rootDir, 'go.mod'));
100
+ if (!text)
101
+ return;
102
+ try {
103
+ const match = text.match(/^module\s+(.+)$/m);
104
+ if (match) {
105
+ items.push({
106
+ category: 'execution',
107
+ key: 'moduleName',
108
+ value: match[1].trim(),
109
+ source: 'go.mod:module',
110
+ confidence: 'high',
111
+ });
112
+ }
113
+ }
114
+ catch {
115
+ // skip malformed go.mod
116
+ }
117
+ }
118
+ function extractCargoToml(rootDir, items) {
119
+ const text = safeReadFile(path.join(rootDir, 'Cargo.toml'));
120
+ if (!text)
121
+ return;
122
+ try {
123
+ const parsed = parseToml(text);
124
+ const pkg = parsed.package;
125
+ if (pkg?.name) {
126
+ items.push({
127
+ category: 'execution',
128
+ key: 'packageName',
129
+ value: String(pkg.name),
130
+ source: 'Cargo.toml:package.name',
131
+ confidence: 'high',
132
+ });
133
+ }
134
+ }
135
+ catch {
136
+ // skip malformed Cargo.toml
137
+ }
138
+ }
139
+ function addMissingDefaults(items) {
140
+ const keys = new Set(items.map((item) => item.key));
141
+ if (!keys.has('testCommand')) {
142
+ items.push({
143
+ category: 'execution',
144
+ key: 'testCommand',
145
+ status: 'unknown',
146
+ source: 'not-detected',
147
+ confidence: 'none',
148
+ });
149
+ }
150
+ if (!keys.has('buildCommand')) {
151
+ items.push({
152
+ category: 'execution',
153
+ key: 'buildCommand',
154
+ status: 'unknown',
155
+ source: 'not-detected',
156
+ confidence: 'none',
157
+ });
158
+ }
159
+ }
160
+ /**
161
+ * Extract obvious project facts from manifest files in `rootDir`.
162
+ *
163
+ * Reads package.json, pyproject.toml, go.mod, Cargo.toml for basic
164
+ * project metadata. Returns typed ManifestFacts with items[].
165
+ * Missing items are represented as status: 'unknown' with source: 'not-detected'.
166
+ */
167
+ export function extractManifestFacts(rootDir, profileName) {
168
+ const items = [];
169
+ extractPackageJson(rootDir, items);
170
+ extractPyprojectToml(rootDir, items);
171
+ extractGoMod(rootDir, items);
172
+ extractCargoToml(rootDir, items);
173
+ addMissingDefaults(items);
174
+ // Determine project source from whichever manifest was detected
175
+ const sourceMap = {
176
+ nodejs: 'package.json',
177
+ python: 'pyproject.toml',
178
+ go: 'go.mod',
179
+ rust: 'Cargo.toml',
180
+ };
181
+ const projectType = profileName ?? 'generic';
182
+ const projectSource = sourceMap[projectType] ?? 'not-detected';
183
+ return { projectType, projectSource, items };
184
+ }
185
+ //# sourceMappingURL=manifest-extractors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-extractors.js","sourceRoot":"","sources":["../../../src/cli/init/manifest-extractors.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,oFAAoF;AACpF,uDAAuD;AAEvD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAA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,EAAE,gBAAgB;QACxB,EAAE,EAAE,QAAQ;QACZ,IAAI,EAAE,YAAY;KACnB,CAAC;IACF,MAAM,WAAW,GAAG,WAAW,IAAI,SAAS,CAAC;IAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,cAAc,CAAC;IAE/D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { z } from 'zod';
2
+ export declare const bootstrapProfileSchema: z.ZodObject<{
3
+ parser: z.ZodObject<{
4
+ include: z.ZodArray<z.ZodString>;
5
+ extensions: z.ZodArray<z.ZodString>;
6
+ }, z.core.$strip>;
7
+ ignore: z.ZodArray<z.ZodString>;
8
+ analysis_depth: z.ZodEnum<{
9
+ deep: "deep";
10
+ shallow: "shallow";
11
+ standard: "standard";
12
+ }>;
13
+ }, z.core.$strip>;
14
+ export type BootstrapProfile = z.infer<typeof bootstrapProfileSchema>;
15
+ /**
16
+ * Map `analysis_depth` profile values to the canonical config `mode` field.
17
+ *
18
+ * Documented mapping (per RESOLVED open question 2 in 53-RESEARCH.md):
19
+ * shallow -> fast
20
+ * standard -> hybrid
21
+ * deep -> smart
22
+ *
23
+ * Consumed by `profile-plan.ts` in plan 53-02 when merging profile defaults
24
+ * into `.mycodemap/config.json`. Kept here so the mapping lives next to the
25
+ * schema that defines the source enum.
26
+ */
27
+ export declare const ANALYSIS_DEPTH_TO_MODE: Record<BootstrapProfile['analysis_depth'], 'fast' | 'hybrid' | 'smart'>;
28
+ /**
29
+ * Resolve the absolute filesystem path for a built-in profile JSON file.
30
+ *
31
+ * Throws on unknown names or any name containing path separators / parent-dir
32
+ * tokens (mitigation for T-53-01 path traversal).
33
+ */
34
+ export declare function resolveProfilePath(profileName: string): string;
35
+ /**
36
+ * Load and validate a built-in bootstrap profile by name.
37
+ *
38
+ * Errors:
39
+ * - Unknown / illegal name → from `resolveProfilePath`
40
+ * - File missing on disk → "Profile 文件未找到" (does NOT include full path
41
+ * in the message body to mitigate T-53-04 info leak;
42
+ * the path is appended only in the trailing detail)
43
+ * - JSON parse failure → re-thrown with profile name context
44
+ * - Schema validation fail → flattened ZodError → "Profile 验证失败 [name]: ..."
45
+ *
46
+ * Pure: no `process.exit`; callers handle exit codes at CLI entry.
47
+ */
48
+ export declare function loadProfile(profileName: string): BootstrapProfile;
49
+ //# sourceMappingURL=profile-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-loader.d.ts","sourceRoot":"","sources":["../../../src/cli/init/profile-loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,sBAAsB;;;;;;;;;;;iBAOjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAQtE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAI1G,CAAC;AAUF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQ9D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,gBAAgB,CAgCjE"}
@@ -0,0 +1,107 @@
1
+ // [META] since:2026-05-01 | owner:cli-team | stable:false
2
+ // [WHY] Phase 53 profile JSON loader with strict zod validation. Reads built-in
3
+ // bootstrap profiles from the package's `src/cli/init/profiles/` directory and
4
+ // validates them against `bootstrapProfileSchema` before returning a typed result.
5
+ import { z } from 'zod';
6
+ import { readFileSync } from 'node:fs';
7
+ import path from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ export const bootstrapProfileSchema = z.object({
10
+ parser: z.object({
11
+ include: z.array(z.string()).min(1),
12
+ extensions: z.array(z.string()).min(1),
13
+ }),
14
+ ignore: z.array(z.string()),
15
+ analysis_depth: z.enum(['shallow', 'standard', 'deep']),
16
+ });
17
+ /**
18
+ * Allow-list of built-in profile names (security: prevents arbitrary file reads
19
+ * via `--profile ../../../etc/passwd`-style inputs; threat T-53-01).
20
+ */
21
+ const ALLOWED_PROFILE_NAMES = new Set(['nodejs', 'python', 'go', 'rust', 'generic']);
22
+ /**
23
+ * Map `analysis_depth` profile values to the canonical config `mode` field.
24
+ *
25
+ * Documented mapping (per RESOLVED open question 2 in 53-RESEARCH.md):
26
+ * shallow -> fast
27
+ * standard -> hybrid
28
+ * deep -> smart
29
+ *
30
+ * Consumed by `profile-plan.ts` in plan 53-02 when merging profile defaults
31
+ * into `.mycodemap/config.json`. Kept here so the mapping lives next to the
32
+ * schema that defines the source enum.
33
+ */
34
+ export const ANALYSIS_DEPTH_TO_MODE = {
35
+ shallow: 'fast',
36
+ standard: 'hybrid',
37
+ deep: 'smart',
38
+ };
39
+ function resolveProfilesDir() {
40
+ // Profile JSONs ship next to this loader (in src/ during dev, in dist/ after
41
+ // build). Resolving relative to `import.meta.url` keeps both layouts in sync
42
+ // without depending on the package layout above this directory, which is
43
+ // important because npm `files` only ships `dist/`, not `src/`.
44
+ return fileURLToPath(new URL('./profiles/', import.meta.url));
45
+ }
46
+ /**
47
+ * Resolve the absolute filesystem path for a built-in profile JSON file.
48
+ *
49
+ * Throws on unknown names or any name containing path separators / parent-dir
50
+ * tokens (mitigation for T-53-01 path traversal).
51
+ */
52
+ export function resolveProfilePath(profileName) {
53
+ if (!ALLOWED_PROFILE_NAMES.has(profileName)) {
54
+ throw new Error(`未知 profile: ${profileName}`);
55
+ }
56
+ if (profileName.includes('/') || profileName.includes('\\') || profileName.includes('..')) {
57
+ throw new Error(`非法 profile 名称: ${profileName}`);
58
+ }
59
+ return path.join(resolveProfilesDir(), `${profileName}.json`);
60
+ }
61
+ /**
62
+ * Load and validate a built-in bootstrap profile by name.
63
+ *
64
+ * Errors:
65
+ * - Unknown / illegal name → from `resolveProfilePath`
66
+ * - File missing on disk → "Profile 文件未找到" (does NOT include full path
67
+ * in the message body to mitigate T-53-04 info leak;
68
+ * the path is appended only in the trailing detail)
69
+ * - JSON parse failure → re-thrown with profile name context
70
+ * - Schema validation fail → flattened ZodError → "Profile 验证失败 [name]: ..."
71
+ *
72
+ * Pure: no `process.exit`; callers handle exit codes at CLI entry.
73
+ */
74
+ export function loadProfile(profileName) {
75
+ const filePath = resolveProfilePath(profileName);
76
+ let text;
77
+ try {
78
+ text = readFileSync(filePath, 'utf8');
79
+ }
80
+ catch (error) {
81
+ const code = error?.code;
82
+ if (code === 'ENOENT') {
83
+ throw new Error(`Profile 文件未找到 [${profileName}]: ${filePath}`);
84
+ }
85
+ throw new Error(`无法读取 profile [${profileName}]: ${error.message}`);
86
+ }
87
+ let parsed;
88
+ try {
89
+ parsed = JSON.parse(text);
90
+ }
91
+ catch (error) {
92
+ throw new Error(`Profile JSON 解析失败 [${profileName}]: ${error.message}`);
93
+ }
94
+ try {
95
+ return bootstrapProfileSchema.parse(parsed);
96
+ }
97
+ catch (error) {
98
+ if (error instanceof z.ZodError) {
99
+ const issues = error.issues
100
+ .map((issue) => `${issue.path.join('.')}: ${issue.message}`)
101
+ .join('; ');
102
+ throw new Error(`Profile 验证失败 [${profileName}]: ${issues}`);
103
+ }
104
+ throw error;
105
+ }
106
+ }
107
+ //# sourceMappingURL=profile-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-loader.js","sourceRoot":"","sources":["../../../src/cli/init/profile-loader.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,gFAAgF;AAChF,+EAA+E;AAC/E,mFAAmF;AAEnF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAA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AM,MAAM,GAAG,KAAK,CAAC,MAAM;iBACxB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;iBAC3D,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,iBAAiB,WAAW,MAAM,MAAM,EAAE,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { BootstrapProfile } from './profile-loader.js';
2
+ import type { InitAsset } from './reconciler.js';
3
+ interface FileWriteAction {
4
+ targetPath: string;
5
+ content: string;
6
+ }
7
+ /**
8
+ * Minimal scan shape consumed by createProfilePlan.
9
+ *
10
+ * Defined locally (not imported from reconciler.ts) to avoid a circular
11
+ * type import; reconciler.ts's full InitScan structurally satisfies this.
12
+ */
13
+ export interface ProfilePlanScan {
14
+ hasCanonicalConfig: boolean;
15
+ paths: {
16
+ canonicalConfigPath: string;
17
+ };
18
+ }
19
+ export interface ProfilePlan {
20
+ assets: InitAsset[];
21
+ writes: FileWriteAction[];
22
+ /** Serialized merged config for preview rendering. */
23
+ mergedConfigText?: string;
24
+ /** Profile name for display, when one was selected. */
25
+ profileName?: string;
26
+ }
27
+ /**
28
+ * Build a ProfilePlan describing the bootstrap profile decision.
29
+ *
30
+ * - profile === null → skipped (no marker detected, or detection bypassed)
31
+ * - scan.hasCanonicalConfig → already-synced (D-16: respect existing config)
32
+ * - mode === 'preview' → skipped with merged-config preview text
33
+ * - mode === 'apply' → installed; queues canonical config write
34
+ */
35
+ export declare function createProfilePlan(_rootDir: string, profile: BootstrapProfile | null, scan: ProfilePlanScan, mode: 'preview' | 'apply', profileName?: string): ProfilePlan;
36
+ export declare function applyProfilePlan(plan: ProfilePlan): Promise<void>;
37
+ export {};
38
+ //# sourceMappingURL=profile-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-plan.d.ts","sourceRoot":"","sources":["../../../src/cli/init/profile-plan.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,KAAK,EAAE;QACL,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA0DD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,GAAG,IAAI,EAChC,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,SAAS,GAAG,OAAO,EACzB,WAAW,CAAC,EAAE,MAAM,GACnB,WAAW,CAqEb;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAKvE"}