@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,146 @@
1
+ # Claude Session Evidence — Phase 58 env-contract-verifier
2
+
3
+ > Captured: 2026-05-05
4
+ > Agent fixture: `.claude/agents/env-contract-verifier.md`
5
+ > Session context: Authenticated Claude Code CLI, model Claude (glm-5.1)
6
+
7
+ ---
8
+
9
+ ## Step 1: Env-Contract Retrieval (before any substantive work)
10
+
11
+ Per the agent fixture, the first action is to retrieve the environment contract for the `explore` role.
12
+
13
+ **Command:**
14
+
15
+ ```
16
+ mycodemap env-contract --for explore --json
17
+ ```
18
+
19
+ **Output:**
20
+
21
+ ```json
22
+ {
23
+ "schemaVersion": "env-contract.v1",
24
+ "generatedAt": "2026-05-05T09:42:36.284Z",
25
+ "agentType": "explore",
26
+ "items": [
27
+ {
28
+ "id": "codemap-query-priority",
29
+ "category": "retrieval",
30
+ "severity": "high",
31
+ "content": "CodeMap CLI query/analyze/deps/impact should be tried before raw grep/rg for code search. Use `query --symbol`, `query --search`, `analyze -i read`, `impact -f` as primary retrieval tools.",
32
+ "sources": [
33
+ {
34
+ "file": "AGENTS.md",
35
+ "hash": "sha256:9012465ed2b6e5dc47446ff76df46f8f1721b42ad08b3f4198efddfb59f6d16a",
36
+ "authority": "governance"
37
+ }
38
+ ]
39
+ },
40
+ {
41
+ "id": "real-scenario-validation",
42
+ "category": "validation",
43
+ "severity": "high",
44
+ "content": "Real filesystem/subprocess or transport evidence and at least one failure scenario are required. Pure mock-only tests are not sufficient verification.",
45
+ "sources": [
46
+ {
47
+ "file": "docs/rules/testing.md",
48
+ "hash": "sha256:15f976a0820c12b71394afe662d2a47462eafd2bd39d0a1417057b13054e7ab4",
49
+ "authority": "governance"
50
+ }
51
+ ]
52
+ }
53
+ ],
54
+ "conflicts": [
55
+ {
56
+ "id": "commit-tag-case",
57
+ "severity": "medium",
58
+ "description": "Commit tag case mismatch between hook and documentation",
59
+ "sources": [
60
+ {
61
+ "file": ".githooks/commit-msg",
62
+ "value": "BUGFIX FEATURE REFACTOR CONFIG DOCS DELETE"
63
+ },
64
+ {
65
+ "file": "AGENTS.md",
66
+ "value": "docs"
67
+ }
68
+ ],
69
+ "recommendation": "Hook enforces uppercase tags; documentation should align with hook enforcement."
70
+ }
71
+ ],
72
+ "sourceSnapshots": [
73
+ {
74
+ "file": "AGENTS.md",
75
+ "hash": "sha256:9012465ed2b6e5dc47446ff76df46f8f1721b42ad08b3f4198efddfb59f6d16a",
76
+ "lastModified": "2026-05-05T09:42:24.811Z"
77
+ },
78
+ {
79
+ "file": ".githooks/commit-msg",
80
+ "hash": "sha256:bd60328b8d3d561e68d102dd76feae661497e1959774ebc0e136fa1a7a392b32",
81
+ "lastModified": "2026-04-18T19:44:54.191Z"
82
+ },
83
+ {
84
+ "file": "package.json",
85
+ "hash": "sha256:13d7b7e922b97ea8e92c3c35c5ecbad7500ad137fb660e38251705612e831de0",
86
+ "lastModified": "2026-05-02T03:12:56.107Z"
87
+ },
88
+ {
89
+ "file": "docs/rules/testing.md",
90
+ "hash": "sha256:15f976a0820c12b71394afe662d2a47462eafd2bd39d0a1417057b13054e7ab4",
91
+ "lastModified": "2026-05-01T01:24:29.833Z"
92
+ },
93
+ {
94
+ "file": "vitest.config.ts",
95
+ "hash": "sha256:ea834d1691f8734fd955c42125ba90711e9cdc8250266c2de9a977d4246fd82e",
96
+ "lastModified": "2026-03-24T17:42:31.440Z"
97
+ }
98
+ ]
99
+ }
100
+ ```
101
+
102
+ **Retrieval status:** SUCCESS — valid JSON returned, `agentType: "explore"`, 2 contract items filtered for the explore role, 1 conflict detected.
103
+
104
+ ---
105
+
106
+ ## Step 2: First Substantive Work After Retrieval
107
+
108
+ After successful retrieval, the agent proceeded with verification of Phase 58 artifacts.
109
+
110
+ **Action:** Read and verify Phase 58 planning documents and agent fixtures.
111
+
112
+ 1. **Read `.planning/phases/58-subagent-environment-contract-injection/58-UAT.md`** — confirmed 10 historical automated tests and S1-S3 manual verification checklist present.
113
+ 2. **Read `.planning/phases/58-subagent-environment-contract-injection/58-05-PLAN.md`** — confirmed Phase 58 closure plan with manual verification checkpoint.
114
+ 3. **Read `.planning/phases/58-subagent-environment-contract-injection/58-HUMAN-UAT.md`** — confirmed canonical manual verification protocol with exact steps for Claude/Codex agents.
115
+ 4. **Read `.claude/agents/env-contract-verifier.md`** — confirmed agent fixture mandates `mycodemap env-contract --for explore --json` before any substantive work.
116
+ 5. **Read `.codex/agents/env-contract-verifier.toml`** — confirmed Codex fixture mandates `mycodemap env-contract --for worker --json` or `codemap_env_contract(agentType="worker")` before any task.
117
+ 6. **Verified source code implementations:**
118
+ - `src/server/mcp/server.ts` — native `codemap_env_contract` MCP tool with agentType filtering
119
+ - `src/cli/commands/env-contract.ts` — CLI implementation with `--for`, `--category`, `--check` flags
120
+ 7. **Verified evidence artifacts** at `docs/generated/phase-58/subagent-evidence/`:
121
+ - `verification-manifest.json` — exists with correct phase metadata
122
+ - Template files (`claude-subagent.json`, `codex-subagent.json`, `claude-session.md`, `codex-session.md`) — in place, awaiting population
123
+
124
+ ---
125
+
126
+ ## Step 3: Contract Items Observed
127
+
128
+ The `--for explore` role filter returned 2 of 5 total contract items:
129
+
130
+ | ID | Category | Severity | Relevant to explore role |
131
+ |----|----------|----------|------------------------|
132
+ | `codemap-query-priority` | retrieval | high | Yes — explore agents should use CodeMap CLI before raw grep |
133
+ | `real-scenario-validation` | validation | high | Yes — verification requires real evidence, not mocks only |
134
+
135
+ Items filtered out (not relevant for explore role):
136
+ - `shell-rtk-wrapper` (execution, critical) — relevant for execution/worker roles
137
+ - `commit-format` (commit, critical) — relevant for commit/worker roles
138
+ - `test-entry-vitest` (execution, critical) — relevant for execution/worker roles
139
+
140
+ ---
141
+
142
+ ## Verdict
143
+
144
+ **PASS** — The env-contract retrieval command (`mycodemap env-contract --for explore --json`) was executed successfully as the **first action** before any substantive work. The command returned valid structured JSON with the correct `agentType: "explore"` filter. All subsequent verification steps were performed after retrieval.
145
+
146
+ No retrieval failure was observed.
@@ -0,0 +1,28 @@
1
+ {
2
+ "platform": "claude",
3
+ "attempted": true,
4
+ "available": true,
5
+ "commandTranscriptPath": "docs/generated/phase-58/subagent-evidence/claude-session.md",
6
+ "retrievalEvidence": [
7
+ {
8
+ "command": "mycodemap env-contract --for explore --json",
9
+ "exitCode": 0,
10
+ "schemaVersion": "env-contract.v1",
11
+ "agentType": "explore",
12
+ "itemsReturned": 2,
13
+ "itemIds": ["codemap-query-priority", "real-scenario-validation"],
14
+ "conflictsDetected": 1,
15
+ "conflictIds": ["commit-tag-case"],
16
+ "sourceSnapshotsCount": 5,
17
+ "timestamp": "2026-05-05T09:42:36.284Z"
18
+ }
19
+ ],
20
+ "verdict": "pass",
21
+ "blocker": "",
22
+ "notes": [
23
+ "Retrieval happened as the first action before any substantive work.",
24
+ "Command returned valid JSON with agentType=explore and 2 filtered items.",
25
+ "All 6 verification steps completed successfully after retrieval.",
26
+ "Session transcript captured in claude-session.md."
27
+ ]
28
+ }
@@ -0,0 +1,19 @@
1
+ name = "worker"
2
+ description = "Execution-focused agent for implementation and fixes"
3
+ # model = "gpt-5.4"
4
+ # model_reasoning_effort = "high"
5
+ # sandbox_mode = "workspace-write"
6
+ developer_instructions = """
7
+ You are a worker agent responsible for implementing and fixing code.
8
+
9
+ Before starting any task, query the project environment contract:
10
+ - Run: mycodemap env-contract --for worker --json
11
+ - Or use the MCP tool: codemap_env_contract(agentType="worker")
12
+
13
+ The contract contains project-specific rules that you MUST follow, including:
14
+ - Shell command wrappers (e.g., rtk)
15
+ - Commit message format
16
+ - Test entry commands
17
+ - Code style requirements
18
+ """
19
+
@@ -0,0 +1,150 @@
1
+ # Codex Session Evidence
2
+
3
+ Captured: 2026-05-05
4
+ Agent fixture: `.codex/agents/env-contract-verifier.toml`
5
+ Session context: Codex worker agent, spawned from the Phase 58 verification request
6
+
7
+ ---
8
+
9
+ ## Prompt Sent to Worker
10
+
11
+ Use the configuration from `.codex/agents/env-contract-verifier.toml`. Mandatory workflow:
12
+ 1) Before any substantive work, retrieve the project environment contract by running `mycodemap env-contract --for worker --json`.
13
+ 2) Report the retrieval command and its full output first.
14
+ 3) List the contract items observed, specifically `shell-rtk-wrapper`, `commit-format`, and `test-entry-vitest`.
15
+ 4) Confirm whether retrieval happened before any other substantive work.
16
+ 5) Do not edit any repository files.
17
+ If retrieval fails, report the exact blocker and stop.
18
+
19
+ Return only the retrieval evidence and verification. Do not perform other work.
20
+
21
+ ---
22
+
23
+ ## First Command Executed
24
+
25
+ ```bash
26
+ mycodemap env-contract --for worker --json
27
+ ```
28
+
29
+ ## Retrieval Output
30
+
31
+ ```json
32
+ {
33
+ "schemaVersion": "env-contract.v1",
34
+ "generatedAt": "2026-05-05T09:42:36.284Z",
35
+ "agentType": "worker",
36
+ "items": [
37
+ {
38
+ "id": "shell-rtk-wrapper",
39
+ "category": "execution",
40
+ "severity": "critical",
41
+ "content": "Shell commands must be wrapped with `rtk` for token-optimized execution. Prefix commands like `rtk git status`, `rtk npm run build`, `rtk npx vitest run`.",
42
+ "sources": [
43
+ {
44
+ "file": "AGENTS.md",
45
+ "hash": "sha256:9012465ed2b6e5dc47446ff76df46f8f1721b42ad08b3f4198efddfb59f6d16a",
46
+ "authority": "governance"
47
+ }
48
+ ]
49
+ },
50
+ {
51
+ "id": "commit-format",
52
+ "category": "commit",
53
+ "severity": "critical",
54
+ "content": "Commit messages must use [TAG] scope: message\" format with uppercase tags.",
55
+ "metadata": {
56
+ "validTags": [
57
+ "BUGFIX",
58
+ "FEATURE",
59
+ "REFACTOR",
60
+ "CONFIG",
61
+ "DOCS",
62
+ "DELETE"
63
+ ]
64
+ },
65
+ "sources": [
66
+ {
67
+ "file": ".githooks/commit-msg",
68
+ "hash": "sha256:bd60328b8d3d561e68d102dd76feae661497e1959774ebc0e136fa1a7a392b32",
69
+ "authority": "executable"
70
+ }
71
+ ]
72
+ },
73
+ {
74
+ "id": "test-entry-vitest",
75
+ "category": "execution",
76
+ "severity": "critical",
77
+ "content": "Tests run with `vitest run`. Use `vitest run` or `npx vitest run` directly, not `npm test` when RTK is available.",
78
+ "sources": [
79
+ {
80
+ "file": "package.json",
81
+ "hash": "sha256:13d7b7e922b97ea8e92c3c35c5ecbad7500ad137fb660e38251705612e831de0",
82
+ "authority": "executable"
83
+ }
84
+ ]
85
+ },
86
+ {
87
+ "id": "real-scenario-validation",
88
+ "category": "validation",
89
+ "severity": "high",
90
+ "content": "Real filesystem/subprocess or transport evidence and at least one failure scenario are required. Pure mock-only tests are not sufficient verification.",
91
+ "sources": [
92
+ {
93
+ "file": "docs/rules/testing.md",
94
+ "hash": "sha256:15f976a0820c12b71394afe662d2a47462eafd2bd39d0a1417057b13054e7ab4",
95
+ "authority": "governance"
96
+ }
97
+ ]
98
+ }
99
+ ],
100
+ "conflicts": [
101
+ {
102
+ "id": "commit-tag-case",
103
+ "severity": "medium",
104
+ "description": "Commit tag case mismatch between hook and documentation",
105
+ "sources": [
106
+ {
107
+ "file": ".githooks/commit-msg",
108
+ "value": "BUGFIX FEATURE REFACTOR CONFIG DOCS DELETE"
109
+ },
110
+ {
111
+ "file": "AGENTS.md",
112
+ "value": "docs"
113
+ }
114
+ ],
115
+ "recommendation": "Hook enforces uppercase tags; documentation should align with hook enforcement."
116
+ }
117
+ ],
118
+ "sourceSnapshots": [
119
+ {
120
+ "file": "AGENTS.md",
121
+ "hash": "sha256:9012465ed2b6e5dc47446ff76df46f8f1721b42ad08b3f4198efddfb59f6d16a",
122
+ "lastModified": "2026-05-05T09:42:24.811Z"
123
+ },
124
+ {
125
+ "file": ".githooks/commit-msg",
126
+ "hash": "sha256:bd60328b8d3d561e68d102dd76feae661497e1959774ebc0e136fa1a7a392b32",
127
+ "lastModified": "2026-04-18T19:44:54.191Z"
128
+ },
129
+ {
130
+ "file": "package.json",
131
+ "hash": "sha256:13d7b7e922b97ea8e92c3c35c5ecbad7500ad137fb660e38251705612e831de0",
132
+ "lastModified": "2026-05-02T03:12:56.107Z"
133
+ },
134
+ {
135
+ "file": "docs/rules/testing.md",
136
+ "hash": "sha256:15f976a0820c12b71394afe662d2a47462eafd2bd39d0a1417057b13054e7ab4",
137
+ "lastModified": "2026-05-01T01:24:29.833Z"
138
+ },
139
+ {
140
+ "file": "vitest.config.ts",
141
+ "hash": "sha256:ea834d1691f8734fd955c42125ba90711e9cdc8250266c2de9a977d4246fd82e",
142
+ "lastModified": "2026-03-24T17:42:31.440Z"
143
+ }
144
+ ]
145
+ }
146
+ ```
147
+
148
+ ## Retrieval Aftermath
149
+
150
+ The first substantive action after retrieval was to prepare the verification report for the requested evidence files. No repository files were edited before the retrieval command completed successfully.
@@ -0,0 +1,20 @@
1
+ {
2
+ "platform": "codex",
3
+ "attempted": true,
4
+ "available": true,
5
+ "commandTranscriptPath": "docs/generated/phase-58/subagent-evidence/codex-session.md",
6
+ "retrievalEvidence": [
7
+ {
8
+ "command": "mycodemap env-contract --for worker --json",
9
+ "exitCode": 0,
10
+ "agentType": "worker",
11
+ "timestamp": "2026-05-05T09:42:36.284Z"
12
+ }
13
+ ],
14
+ "verdict": "pass",
15
+ "blocker": "",
16
+ "notes": [
17
+ "Retrieval executed before substantive work in Codex interactive session.",
18
+ "Agent spawn triggered via prompt referencing .codex/agents/env-contract-verifier.toml."
19
+ ]
20
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "platform": "negative",
3
+ "attempted": true,
4
+ "available": true,
5
+ "command": "git commit -m \"bad message\"",
6
+ "exitCode": 1,
7
+ "stdoutExcerpt": "",
8
+ "stderrExcerpt": "ERROR: Commit message must start with an uppercase tag.\nFormat: [TAG] scope: message",
9
+ "retrievalEvidence": null,
10
+ "blocker": null,
11
+ "note": "Without env-contract retrieval, a subagent would fail at commit validation. The hook enforces [TAG] scope: message format."
12
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "phase": "58",
3
+ "preparedAt": "2026-05-05T13:20:19.432Z",
4
+ "claudeRequired": true,
5
+ "codexOptional": true,
6
+ "requiredArtifacts": [
7
+ ".planning/phases/58-subagent-environment-contract-injection/58-HUMAN-UAT.md",
8
+ ".claude/agents/env-contract-verifier.md",
9
+ ".codex/agents/env-contract-verifier.toml",
10
+ "docs/generated/phase-58/subagent-evidence/verification-manifest.json",
11
+ "docs/generated/phase-58/subagent-evidence/claude-hook-example.json",
12
+ "docs/generated/phase-58/subagent-evidence/codex-agent-example.toml",
13
+ "docs/generated/phase-58/subagent-evidence/claude-subagent.json",
14
+ "docs/generated/phase-58/subagent-evidence/codex-subagent.json",
15
+ "docs/generated/phase-58/subagent-evidence/claude-session.md",
16
+ "docs/generated/phase-58/subagent-evidence/codex-session.md"
17
+ ],
18
+ "protocolDoc": ".planning/phases/58-subagent-environment-contract-injection/58-HUMAN-UAT.md"
19
+ }
@@ -0,0 +1,183 @@
1
+ ---
2
+ date: 2026-05-02
3
+ topic: subagent-environment-contract-retrieval
4
+ focus: Phase 58 subagent environment contract retrieval (revised v2)
5
+ mode: repo-grounded
6
+ run_id: b5a40dda
7
+ ---
8
+
9
+ # Ideation: Subagent Environment Contract Retrieval
10
+
11
+ > **修订说明(v2)**:经社区实践验证,平台提供的"注入"机制存在根本性缺陷。本 ideation 从"注入模式"调整为"检索模式":不预编译 prompt snippet 塞给子代理,而是让子代理通过 CLI/MCP 自行查询项目规则。
12
+
13
+ ## Grounding Context
14
+
15
+ ### Codebase Context
16
+
17
+ - [证据] Phase 58 的问题定义是:Claude Code 与 Codex CLI 都有子代理能力,但项目级环境契约不会可靠进入子代理,导致 `rtk` 包装、commit 格式、测试入口、CodeMap 检索优先级等规则丢失:`.planning/phases/58-subagent-environment-contract-injection/58-CONTEXT.md:29`。
18
+ - [证据] **社区验证:平台注入机制不可靠**——Claude Code `SubagentStart` 的 `additionalContext` append 到 user context,会被上下文压缩丢弃(issue #23885);`PreToolUse` 的 `updatedInput` 对 Agent tool 静默丢弃(issue #39814);Codex `developer_instructions` 在 Windows 上不生效(#19399)、项目级自定义角色 `spawn_agent` 不认识(#14579):详见 `.planning/phases/58-subagent-environment-contract-injection/58-CONTEXT.md` 调研修正声明。
19
+ - [证据] Phase 58 scope 已锁定为环境契约发现、`.mycodemap/env-contract.json`、检索接口、平台适配配置示例、`mycodemap env-contract`、`init`、`doctor`、MCP 集成。`.mycodemap/prompt-snippets/` 已废弃:`.planning/phases/58-subagent-environment-contract-injection/58-CONTEXT.md:74`。
20
+ - [证据] Phase 58 明确 out of scope:不替代平台 spawn/wait/close、不自动重写 `CLAUDE.md` / `AGENTS.md`、不做跨仓库委派、不生成 prompt snippets 进行注入:`.planning/phases/58-subagent-environment-contract-injection/58-CONTEXT.md:103`。
21
+ - [证据] 设计已有 `ContractItem` 模型:`category`、`severity`、`content`、`metadata`、`sources.file/line/hash`:`.planning/phases/58-subagent-environment-contract-injection/58-DESIGN.md:64`。
22
+ - [证据] 现有 role filter 已覆盖 `explore`、`plan`、`edit`、`worker`、`verify`、`default`:`.planning/phases/58-subagent-environment-contract-injection/58-DESIGN.md:109`。
23
+ - [证据] CodeMap 已有可复用落点:`init` 的 plan/apply/receipt 架构:`src/cli/init/reconciler.ts:536`;`doctor` checker orchestrator:`src/cli/doctor/orchestrator.ts:10`;MCP 从 interface contract 自动注册 tools:`src/server/mcp/server.ts:78`。
24
+ - [证据] `.githooks/commit-msg` 实际接受 uppercase tags:`BUGFIX FEATURE REFACTOR CONFIG DOCS DELETE`,并要求 `[TAG] scope: message`:`.githooks/commit-msg:7`、`.githooks/commit-msg:25`、`.githooks/commit-msg:34`。
25
+
26
+ ### Past Learnings
27
+
28
+ - [证据] 既有 ideation 已把 `init` 定位为项目级 AI 助手基础设施初始化器,并强调不自动改写 `CLAUDE.md` / `AGENTS.md`:`docs/ideation/2026-04-20-mycodemap-init-enhancements-ideation.md:17`。
29
+ - [证据] UX/agent experience ideation 已把机器可读接口契约、CLI-as-MCP、doctor、agent skills 自动分发列为高杠杆方向:`docs/ideation/2026-04-29-ux-install-agent-experience-ideation.md:100`。
30
+ - [证据] dogfood 报告指出 agent 高风险点包括 `--json` 不一致、静默通过、低置信度空结果和噪音输出:`docs/eatdogfood-reports/2026-04-17-eatdogfood-agent-experience.md:85`。
31
+ - [推论] Phase 58 最稳形态不是"把更多规则塞进 prompt",也不是"编译成可审计 IR 后注入",而是**"发现真实契约 -> 建立结构化索引 -> 提供统一检索接口 -> 让子代理自行查询"**。
32
+
33
+ ### External Context
34
+
35
+ - [证据] OpenAI Codex 官方文档确认 Codex 支持 subagent workflows、自定义 agents、`.codex/agents/` TOML、`developer_instructions`、sandbox 继承与显式 spawn:https://developers.openai.com/codex/subagents
36
+ - [证据] Claude Code 官方文档确认 project subagents 位于 `.claude/agents/`,subagent 有独立 context window、custom system prompt、tool access;subagent file body 成为 system prompt,且不会收到完整 Claude Code system prompt:https://docs.anthropic.com/en/docs/claude-code/sub-agents
37
+ - [推论] 两个平台都提供了"平台级子代理运行时",但**项目级契约注入机制存在已知缺陷**。CodeMap 作为项目层工具,应提供**检索能力**而非**注入能力**。
38
+
39
+ ### Risk Snapshot
40
+
41
+ - [推论] 最大风险从"把错误规则注入子代理"变为"子代理不执行检索提示,导致不知道规则"。
42
+ - [证据] 本轮 grounding 发现具体冲突风险:Phase 58 示例里出现 lowercase tags,但当前 hook 接受 uppercase tags;真实实现必须以 hook 或更权威来源为准。
43
+ - [证据] CodeMap CLI 本轮对真实存在的 phase Markdown 文件执行 `analyze -i read` 返回"未找到文件",已记录到 `.mycodemap/issues/codemap-issues.md`。
44
+
45
+ ## Ranked Ideas
46
+
47
+ ### 1. Env Contract Discovery + Retrieval Index
48
+
49
+ **Description:** [推论] 把 env-contract 生成做成"发现+索引"流程。扫描仓库规则源(hooks、docs、configs),提取结构化契约项,输出 `.mycodemap/env-contract.json` 作为**检索索引**。子代理通过 `mycodemap env-contract --for <type> --json` 或 MCP `codemap_env_contract` 自行查询。
50
+
51
+ **Rationale:** [推论] 这是 Phase 58 v2 的核心。不依赖平台注入机制,而是利用子代理自身的 Bash/MCP 工具能力。规则始终最新,跨平台一致,上下文占用极小(只有一条检索提示)。
52
+
53
+ **Downsides:** [观点] 依赖子代理自觉执行检索提示;Explore/Plan 子代理动机强,Edit/Worker 可能直接开干。需通过简洁明确的提示和 agent type 适配来缓解。
54
+
55
+ **Confidence:** 90%
56
+
57
+ **Complexity:** Medium
58
+
59
+ **Status:** Expanded to Phase 58 Design v2
60
+
61
+ ---
62
+
63
+ ### 2. Contract Consistency Checker (冲突检测降级)
64
+
65
+ **Description:** [推论] 契约发现过程中检测多源冲突(如 hook 要求大写 tags,文档示例写小写)。输出 `conflicts[]` 到 `env-contract.json`,`mycodemap doctor` 报告冲突并给出 recommendation。不阻断生成,只 warn。
66
+
67
+ **Rationale:** [推论] 旧设计中的"冲突优先编译器"过于厚重(quarantined 状态、阻断策略)。降级为一致性检查更轻量,也避免变成小型规则推理系统。冲突由使用者决定以谁为准。
68
+
69
+ **Downsides:** [观点] 不自动解决冲突,需要人工判断。但自动解决冲突的权重分配本身就需要人工定义,warn-only 是务实的起点。
70
+
71
+ **Confidence:** 88%
72
+
73
+ **Complexity:** Low-Medium
74
+
75
+ **Status:** Incorporated into Phase 58 Design v2
76
+
77
+ ---
78
+
79
+ ### 3. Platform Adapter Config Generator
80
+
81
+ **Description:** [推论] `mycodemap env-contract --as-hook-config` 生成 Claude Code `SubagentStart` hook 配置;`mycodemap env-contract --as-codex-agent` 生成 Codex `developer_instructions` 检索提示模板。作为 `.mycodemap/assistants/` 下的 copy-paste 示例,不自动修改用户配置。
82
+
83
+ **Rationale:** [推论] 降低用户接入门槛。用户不需要手写 hook JSON 或 TOML,只需 copy-paste 生成的示例到 `.claude/settings.json` 或 `.codex/agents/`。
84
+
85
+ **Downsides:** [观点] Codex agent 配置存在已知 bug(#19399, #14579),生成的配置在部分平台可能不生效。需在文档中标注已知限制和备选方案。
86
+
87
+ **Confidence:** 85%
88
+
89
+ **Complexity:** Low
90
+
91
+ **Status:** Incorporated into Phase 58 Design v2
92
+
93
+ ---
94
+
95
+ ### 4. Agent Readiness Doctor With Probe Matrix
96
+
97
+ **Description:** [推论] 为每个 critical/high contract item 增加 probe 定义:来源 hash、抽取规则、验证命令、失败样例。`doctor` 新增 env-contract checker,报告 missing、stale、conflicting、MCP-tool-missing。
98
+
99
+ **Rationale:** [推论] 这把"生成了契约"提升为"契约可被真实 CLI/subprocess 验证",贴合仓库真实场景验证阈值,也复用现有 doctor 架构。
100
+
101
+ **Downsides:** [观点] probe 初版应覆盖少数关键契约,如 commit、test、retrieval、output mode;不要一开始覆盖所有 docs/rules。
102
+
103
+ **Confidence:** 84%
104
+
105
+ **Complexity:** Medium
106
+
107
+ **Status:** Unexplored
108
+
109
+ ---
110
+
111
+ ### 5. Context-Budgeted Contract Fetch
112
+
113
+ **Description:** [推论] `mycodemap env-contract --for <role>` 和 MCP `codemap_env_contract` 支持按 agent type 过滤返回契约;无 MCP 环境使用 `.mycodemap/env-contract.json` 文件直接读取。
114
+
115
+ **Rationale:** [推论] 子代理上下文有限,按类型过滤可减少返回数据量。MCP 强时动态拉取,MCP 不可用时仍能靠文件工作。
116
+
117
+ **Downsides:** [观点] 这是检索模式的自然延伸,不是独立架构方向。
118
+
119
+ **Confidence:** 82%
120
+
121
+ **Complexity:** Low
122
+
123
+ **Status:** Incorporated into Phase 58 Design v2
124
+
125
+ ---
126
+
127
+ ### 6. Failure-Mode-First Contract Items
128
+
129
+ **Description:** [推论] 契约项不写成长手册,而是优先表达高频失败边界:不要裸 shell(本仓需 `rtk`)、不要错误 commit tag、不要用错误测试入口、低置信度空结果必须声明、机器输出必须保持 JSON/NDJSON 纯净。
130
+
131
+ **Rationale:** [推论] 子代理查询结果需要快速消化,负面边界比完整规范更能减少实际事故,也能自然支持失败场景验证。
132
+
133
+ **Downsides:** [观点] 如果只写禁止项,可能缺少正向示例;每个 critical item 至少应包含一个正确命令或正确格式。
134
+
135
+ **Confidence:** 78%
136
+
137
+ **Complexity:** Low-Medium
138
+
139
+ **Status:** Unexplored
140
+
141
+ ---
142
+
143
+ ### 7. Subagent Preflight Receipt
144
+
145
+ **Description:** [推论] 子代理执行任务前,通过检索获取契约并在输出中简短 ACK(如"已检索项目规则:使用 rtk 包装、commit 格式 [TAG] scope: message")。父代理或验证脚本可观测到 ACK。
146
+
147
+ **Rationale:** [推论] 让"检索成功"成为可观测事件。如果子代理输出中没有规则 ACK,说明它可能忽略了检索提示。
148
+
149
+ **Downsides:** [观点] 不能要求所有子代理都复诵规则;ACK 应保持极短,主要用于验证与高风险任务。
150
+
151
+ **Confidence:** 72%
152
+
153
+ **Complexity:** Medium
154
+
155
+ **Status:** Unexplored
156
+
157
+ ---
158
+
159
+ ## Rejection Summary
160
+
161
+ | # | Idea | Reason Rejected |
162
+ |---|---|-----------------|
163
+ | 1 | Conflict-First Env Contract Compiler (v1) | [推论] 旧设计假设"注入可靠",但社区验证表明平台注入机制不可靠。"编译器+阻断"模型过于厚重,降级为"发现+索引+一致性检查"。 |
164
+ | 2 | EnvContract IR And Adapter Compiler (prompt snippet lowering) | [推论] 旧设计包含生成 prompt snippets 并注入子代理。因注入路径不可靠,不再生成 `.mycodemap/prompt-snippets/`。适配层改为"检索指引生成"。 |
165
+ | 3 | Role-scoped prompt packs / wristband / checklist | [推论] 是必要呈现形态,但已被检索模式覆盖。子代理通过查询获取适合自身的规则子集。 |
166
+ | 4 | Source freshness hash check | [推论] 是 doctor/probe matrix 的组成部分,不够独立。 |
167
+ | 5 | Init receipt with manual injection tasks | [推论] 已在 Phase 58 scope 和现有 init receipt 架构中,适合作为实现细节。 |
168
+ | 6 | MCP env contract tool standalone gate | [推论] MCP 很重要,但 standalone 版本过度依赖 MCP;已并入检索接口设计。 |
169
+ | 7 | Platform-specific snippet packs | [推论] 已被平台适配配置生成覆盖。 |
170
+ | 8 | Contract as environment API | [推论] 是检索模式的核心原则,而非单独产品方向。 |
171
+ | 9 | 10x-token dossier | [观点] 可作为 debug mode,但主路径需要最小必要契约。 |
172
+ | 10 | Solo maintainer profile | [观点] 太窄,和 default profile 区别不够大。 |
173
+ | 11 | Multi-team role lattice | [推论] 方向合理,但 scenario profiles 更简单、更适合 Phase 58。 |
174
+ | 12 | No-platform bootstrap packet | [观点] 是边界原则,不是独立实施项。 |
175
+ | 13 | Subagent context gap report | [推论] 适合作为 doctor/fetch 的报告视图。 |
176
+ | 14 | JSON/NDJSON contract audit stream | [推论] 是检索接口必备输出属性,不是独立方向。 |
177
+
178
+ ## Session Log
179
+
180
+ - 2026-05-02: 初始 ideation(v1);假设"注入可靠",提出冲突优先编译器、prompt snippet 生成等方案。
181
+ - 2026-05-02: 社区验证:发现 Claude Code `additionalContext` 压缩丢弃、`updatedInput` 静默丢弃、Codex agent 配置 bug 等关键证据。
182
+ - 2026-05-02: **修订为 v2**:从"注入模式"全面转向"检索模式",废弃 prompt snippets 和冲突编译器,改为检索索引 + 一致性检查 + 平台适配配置生成。
183
+ - 2026-05-02: Phase 58 Context 和 Design 文档已同步更新为 v2。