mewkit 1.14.0 → 1.15.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 (392) hide show
  1. package/README.md +7 -0
  2. package/dist/commands/capabilities.d.ts +13 -0
  3. package/dist/commands/capabilities.d.ts.map +1 -0
  4. package/dist/commands/capabilities.js +230 -0
  5. package/dist/commands/capabilities.js.map +1 -0
  6. package/dist/commands/context.d.ts +10 -0
  7. package/dist/commands/context.d.ts.map +1 -0
  8. package/dist/commands/context.js +125 -0
  9. package/dist/commands/context.js.map +1 -0
  10. package/dist/commands/doctor.d.ts +27 -0
  11. package/dist/commands/doctor.d.ts.map +1 -1
  12. package/dist/commands/doctor.js +123 -0
  13. package/dist/commands/doctor.js.map +1 -1
  14. package/dist/commands/providers.d.ts +2 -0
  15. package/dist/commands/providers.d.ts.map +1 -1
  16. package/dist/commands/providers.js +77 -0
  17. package/dist/commands/providers.js.map +1 -1
  18. package/dist/commands/task-state.d.ts +13 -0
  19. package/dist/commands/task-state.d.ts.map +1 -0
  20. package/dist/commands/task-state.js +106 -0
  21. package/dist/commands/task-state.js.map +1 -0
  22. package/dist/commands/validate.d.ts +48 -1
  23. package/dist/commands/validate.d.ts.map +1 -1
  24. package/dist/commands/validate.js +97 -24
  25. package/dist/commands/validate.js.map +1 -1
  26. package/dist/core/availability.d.ts +40 -0
  27. package/dist/core/availability.d.ts.map +1 -0
  28. package/dist/core/availability.js +47 -0
  29. package/dist/core/availability.js.map +1 -0
  30. package/dist/core/bootstrap.d.ts +19 -0
  31. package/dist/core/bootstrap.d.ts.map +1 -0
  32. package/dist/core/bootstrap.js +42 -0
  33. package/dist/core/bootstrap.js.map +1 -0
  34. package/dist/core/build-capabilities.d.ts +9 -0
  35. package/dist/core/build-capabilities.d.ts.map +1 -0
  36. package/dist/core/build-capabilities.js +123 -0
  37. package/dist/core/build-capabilities.js.map +1 -0
  38. package/dist/core/build-inventory.d.ts +2 -0
  39. package/dist/core/build-inventory.d.ts.map +1 -1
  40. package/dist/core/build-inventory.js +1 -1
  41. package/dist/core/build-inventory.js.map +1 -1
  42. package/dist/core/capability-authored.d.ts +26 -0
  43. package/dist/core/capability-authored.d.ts.map +1 -0
  44. package/dist/core/capability-authored.js +117 -0
  45. package/dist/core/capability-authored.js.map +1 -0
  46. package/dist/core/capability-snapshot.d.ts +13 -0
  47. package/dist/core/capability-snapshot.d.ts.map +1 -0
  48. package/dist/core/capability-snapshot.js +53 -0
  49. package/dist/core/capability-snapshot.js.map +1 -0
  50. package/dist/core/capability.d.ts +519 -0
  51. package/dist/core/capability.d.ts.map +1 -0
  52. package/dist/core/capability.js +114 -0
  53. package/dist/core/capability.js.map +1 -0
  54. package/dist/core/compute-checksums.d.ts.map +1 -1
  55. package/dist/core/compute-checksums.js +8 -2
  56. package/dist/core/compute-checksums.js.map +1 -1
  57. package/dist/core/consolidation-ledger.d.ts +30 -0
  58. package/dist/core/consolidation-ledger.d.ts.map +1 -0
  59. package/dist/core/consolidation-ledger.js +145 -0
  60. package/dist/core/consolidation-ledger.js.map +1 -0
  61. package/dist/core/generate-capability-view.d.ts +21 -0
  62. package/dist/core/generate-capability-view.d.ts.map +1 -0
  63. package/dist/core/generate-capability-view.js +48 -0
  64. package/dist/core/generate-capability-view.js.map +1 -0
  65. package/dist/core/install-metadata.d.ts +47 -30
  66. package/dist/core/install-metadata.d.ts.map +1 -1
  67. package/dist/core/install-metadata.js +49 -9
  68. package/dist/core/install-metadata.js.map +1 -1
  69. package/dist/core/plugin-manifest.d.ts +16 -16
  70. package/dist/core/provider-adapter.d.ts +28 -0
  71. package/dist/core/provider-adapter.d.ts.map +1 -0
  72. package/dist/core/provider-adapter.js +31 -0
  73. package/dist/core/provider-adapter.js.map +1 -0
  74. package/dist/core/provider-invocation.d.ts +14 -0
  75. package/dist/core/provider-invocation.d.ts.map +1 -0
  76. package/dist/core/provider-invocation.js +56 -0
  77. package/dist/core/provider-invocation.js.map +1 -0
  78. package/dist/core/provider-lifecycle.d.ts +35 -0
  79. package/dist/core/provider-lifecycle.d.ts.map +1 -0
  80. package/dist/core/provider-lifecycle.js +101 -0
  81. package/dist/core/provider-lifecycle.js.map +1 -0
  82. package/dist/core/provider-projection.d.ts +29 -0
  83. package/dist/core/provider-projection.d.ts.map +1 -0
  84. package/dist/core/provider-projection.js +47 -0
  85. package/dist/core/provider-projection.js.map +1 -0
  86. package/dist/core/release-metadata.d.ts +9 -2
  87. package/dist/core/release-metadata.d.ts.map +1 -1
  88. package/dist/core/release-metadata.js +13 -0
  89. package/dist/core/release-metadata.js.map +1 -1
  90. package/dist/core/repo-context-adapter.d.ts +23 -0
  91. package/dist/core/repo-context-adapter.d.ts.map +1 -0
  92. package/dist/core/repo-context-adapter.js +44 -0
  93. package/dist/core/repo-context-adapter.js.map +1 -0
  94. package/dist/core/repo-context.d.ts +147 -0
  95. package/dist/core/repo-context.d.ts.map +1 -0
  96. package/dist/core/repo-context.js +204 -0
  97. package/dist/core/repo-context.js.map +1 -0
  98. package/dist/core/resolve-capabilities.d.ts +70 -0
  99. package/dist/core/resolve-capabilities.d.ts.map +1 -0
  100. package/dist/core/resolve-capabilities.js +124 -0
  101. package/dist/core/resolve-capabilities.js.map +1 -0
  102. package/dist/core/smart-update.d.ts.map +1 -1
  103. package/dist/core/smart-update.js +13 -12
  104. package/dist/core/smart-update.js.map +1 -1
  105. package/dist/core/task-record.d.ts +252 -0
  106. package/dist/core/task-record.d.ts.map +1 -0
  107. package/dist/core/task-record.js +252 -0
  108. package/dist/core/task-record.js.map +1 -0
  109. package/dist/core/validate-capabilities.d.ts +12 -0
  110. package/dist/core/validate-capabilities.d.ts.map +1 -0
  111. package/dist/core/validate-capabilities.js +138 -0
  112. package/dist/core/validate-capabilities.js.map +1 -0
  113. package/dist/index.js +66 -4
  114. package/dist/index.js.map +1 -1
  115. package/dist/migrate/apply-env-var-rewrites.d.ts +15 -0
  116. package/dist/migrate/apply-env-var-rewrites.d.ts.map +1 -0
  117. package/dist/migrate/apply-env-var-rewrites.js +26 -0
  118. package/dist/migrate/apply-env-var-rewrites.js.map +1 -0
  119. package/dist/migrate/capability-bootstrap-projection.d.ts +11 -0
  120. package/dist/migrate/capability-bootstrap-projection.d.ts.map +1 -0
  121. package/dist/migrate/capability-bootstrap-projection.js +48 -0
  122. package/dist/migrate/capability-bootstrap-projection.js.map +1 -0
  123. package/dist/migrate/converters/command-to-codex-skill.d.ts.map +1 -1
  124. package/dist/migrate/converters/command-to-codex-skill.js +15 -5
  125. package/dist/migrate/converters/command-to-codex-skill.js.map +1 -1
  126. package/dist/migrate/converters/fm-to-codex-toml.d.ts +4 -1
  127. package/dist/migrate/converters/fm-to-codex-toml.d.ts.map +1 -1
  128. package/dist/migrate/converters/fm-to-codex-toml.js +7 -2
  129. package/dist/migrate/converters/fm-to-codex-toml.js.map +1 -1
  130. package/dist/migrate/converters/index.js +1 -1
  131. package/dist/migrate/converters/index.js.map +1 -1
  132. package/dist/migrate/discovery/config-discovery.d.ts +29 -0
  133. package/dist/migrate/discovery/config-discovery.d.ts.map +1 -1
  134. package/dist/migrate/discovery/config-discovery.js +45 -0
  135. package/dist/migrate/discovery/config-discovery.js.map +1 -1
  136. package/dist/migrate/discovery/handlers-json-filter.d.ts.map +1 -1
  137. package/dist/migrate/discovery/handlers-json-filter.js +4 -2
  138. package/dist/migrate/discovery/handlers-json-filter.js.map +1 -1
  139. package/dist/migrate/discovery/hooks-discovery.d.ts +5 -0
  140. package/dist/migrate/discovery/hooks-discovery.d.ts.map +1 -1
  141. package/dist/migrate/discovery/hooks-discovery.js +21 -5
  142. package/dist/migrate/discovery/hooks-discovery.js.map +1 -1
  143. package/dist/migrate/hooks/codex-hook-wrapper.d.ts +15 -1
  144. package/dist/migrate/hooks/codex-hook-wrapper.d.ts.map +1 -1
  145. package/dist/migrate/hooks/codex-hook-wrapper.js +78 -7
  146. package/dist/migrate/hooks/codex-hook-wrapper.js.map +1 -1
  147. package/dist/migrate/hooks/codex-path-safety.d.ts +29 -0
  148. package/dist/migrate/hooks/codex-path-safety.d.ts.map +1 -1
  149. package/dist/migrate/hooks/codex-path-safety.js +36 -1
  150. package/dist/migrate/hooks/codex-path-safety.js.map +1 -1
  151. package/dist/migrate/hooks/codex-sh-wrapper-script.d.ts +8 -0
  152. package/dist/migrate/hooks/codex-sh-wrapper-script.d.ts.map +1 -0
  153. package/dist/migrate/hooks/codex-sh-wrapper-script.js +118 -0
  154. package/dist/migrate/hooks/codex-sh-wrapper-script.js.map +1 -0
  155. package/dist/migrate/hooks/codex-shell-env-installer.d.ts +14 -0
  156. package/dist/migrate/hooks/codex-shell-env-installer.d.ts.map +1 -0
  157. package/dist/migrate/hooks/codex-shell-env-installer.js +82 -0
  158. package/dist/migrate/hooks/codex-shell-env-installer.js.map +1 -0
  159. package/dist/migrate/hooks/codex-toml-installer.d.ts +2 -0
  160. package/dist/migrate/hooks/codex-toml-installer.d.ts.map +1 -1
  161. package/dist/migrate/hooks/codex-toml-installer.js +3 -1
  162. package/dist/migrate/hooks/codex-toml-installer.js.map +1 -1
  163. package/dist/migrate/hooks/hooks-settings-merger.d.ts +3 -0
  164. package/dist/migrate/hooks/hooks-settings-merger.d.ts.map +1 -1
  165. package/dist/migrate/hooks/hooks-settings-merger.js +152 -20
  166. package/dist/migrate/hooks/hooks-settings-merger.js.map +1 -1
  167. package/dist/migrate/migrate-orchestrator.d.ts +19 -0
  168. package/dist/migrate/migrate-orchestrator.d.ts.map +1 -1
  169. package/dist/migrate/migrate-orchestrator.js +176 -24
  170. package/dist/migrate/migrate-orchestrator.js.map +1 -1
  171. package/dist/migrate/migrate-ui-summary.d.ts +23 -0
  172. package/dist/migrate/migrate-ui-summary.d.ts.map +1 -1
  173. package/dist/migrate/migrate-ui-summary.js +24 -0
  174. package/dist/migrate/migrate-ui-summary.js.map +1 -1
  175. package/dist/migrate/model-routing-config.d.ts +3 -1
  176. package/dist/migrate/model-routing-config.d.ts.map +1 -1
  177. package/dist/migrate/model-routing-config.js +28 -0
  178. package/dist/migrate/model-routing-config.js.map +1 -1
  179. package/dist/migrate/portable-installer.d.ts +14 -1
  180. package/dist/migrate/portable-installer.d.ts.map +1 -1
  181. package/dist/migrate/portable-installer.js +110 -9
  182. package/dist/migrate/portable-installer.js.map +1 -1
  183. package/dist/migrate/providers/codex/capabilities.d.ts +5 -0
  184. package/dist/migrate/providers/codex/capabilities.d.ts.map +1 -1
  185. package/dist/migrate/providers/codex/capabilities.js +31 -0
  186. package/dist/migrate/providers/codex/capabilities.js.map +1 -1
  187. package/dist/migrate/providers/codex/config.d.ts.map +1 -1
  188. package/dist/migrate/providers/codex/config.js +8 -2
  189. package/dist/migrate/providers/codex/config.js.map +1 -1
  190. package/dist/migrate/providers/codex/shell-env-policy-emitter.d.ts +27 -0
  191. package/dist/migrate/providers/codex/shell-env-policy-emitter.d.ts.map +1 -0
  192. package/dist/migrate/providers/codex/shell-env-policy-emitter.js +86 -0
  193. package/dist/migrate/providers/codex/shell-env-policy-emitter.js.map +1 -0
  194. package/dist/migrate/reconcile/index.d.ts +1 -1
  195. package/dist/migrate/reconcile/index.d.ts.map +1 -1
  196. package/dist/migrate/reconcile/index.js +1 -1
  197. package/dist/migrate/reconcile/index.js.map +1 -1
  198. package/dist/migrate/reconcile/portable-manifest.d.ts +6 -0
  199. package/dist/migrate/reconcile/portable-manifest.d.ts.map +1 -1
  200. package/dist/migrate/reconcile/portable-manifest.js +23 -0
  201. package/dist/migrate/reconcile/portable-manifest.js.map +1 -1
  202. package/dist/migrate/reconcile/reconcile-state-builders.d.ts +12 -5
  203. package/dist/migrate/reconcile/reconcile-state-builders.d.ts.map +1 -1
  204. package/dist/migrate/reconcile/reconcile-state-builders.js +2 -2
  205. package/dist/migrate/reconcile/reconcile-state-builders.js.map +1 -1
  206. package/dist/migrate/references/env-var-rewrite-table.d.ts +36 -0
  207. package/dist/migrate/references/env-var-rewrite-table.d.ts.map +1 -0
  208. package/dist/migrate/references/env-var-rewrite-table.js +97 -0
  209. package/dist/migrate/references/env-var-rewrite-table.js.map +1 -0
  210. package/dist/migrate/references/reference-classifier.d.ts +15 -0
  211. package/dist/migrate/references/reference-classifier.d.ts.map +1 -1
  212. package/dist/migrate/references/reference-classifier.js +33 -0
  213. package/dist/migrate/references/reference-classifier.js.map +1 -1
  214. package/dist/migrate/runtime-compat-audit.d.ts +1 -0
  215. package/dist/migrate/runtime-compat-audit.d.ts.map +1 -1
  216. package/dist/migrate/runtime-compat-audit.js +8 -3
  217. package/dist/migrate/runtime-compat-audit.js.map +1 -1
  218. package/dist/migrate/runtime-coupling-patterns.d.ts +30 -2
  219. package/dist/migrate/runtime-coupling-patterns.d.ts.map +1 -1
  220. package/dist/migrate/runtime-coupling-patterns.js +36 -8
  221. package/dist/migrate/runtime-coupling-patterns.js.map +1 -1
  222. package/dist/migrate/skill-directory-audit.d.ts +14 -0
  223. package/dist/migrate/skill-directory-audit.d.ts.map +1 -1
  224. package/dist/migrate/skill-directory-audit.js +68 -10
  225. package/dist/migrate/skill-directory-audit.js.map +1 -1
  226. package/dist/migrate/skill-directory-installer.d.ts +3 -0
  227. package/dist/migrate/skill-directory-installer.d.ts.map +1 -1
  228. package/dist/migrate/skill-directory-installer.js +98 -1
  229. package/dist/migrate/skill-directory-installer.js.map +1 -1
  230. package/dist/migrate/state-changing-script-detector.d.ts +16 -0
  231. package/dist/migrate/state-changing-script-detector.d.ts.map +1 -0
  232. package/dist/migrate/state-changing-script-detector.js +144 -0
  233. package/dist/migrate/state-changing-script-detector.js.map +1 -0
  234. package/dist/migrate/validation/migrate-conversion-report.d.ts +28 -0
  235. package/dist/migrate/validation/migrate-conversion-report.d.ts.map +1 -1
  236. package/dist/migrate/validation/migrate-conversion-report.js +48 -7
  237. package/dist/migrate/validation/migrate-conversion-report.js.map +1 -1
  238. package/dist/migrate/validation/migration-ledger-inputs.d.ts +56 -0
  239. package/dist/migrate/validation/migration-ledger-inputs.d.ts.map +1 -0
  240. package/dist/migrate/validation/migration-ledger-inputs.js +160 -0
  241. package/dist/migrate/validation/migration-ledger-inputs.js.map +1 -0
  242. package/dist/migrate/validation/migration-record-types.d.ts +38 -0
  243. package/dist/migrate/validation/migration-record-types.d.ts.map +1 -0
  244. package/dist/migrate/validation/migration-record-types.js +12 -0
  245. package/dist/migrate/validation/migration-record-types.js.map +1 -0
  246. package/dist/migrate/validation/migration-report-writer.d.ts +98 -0
  247. package/dist/migrate/validation/migration-report-writer.d.ts.map +1 -0
  248. package/dist/migrate/validation/migration-report-writer.js +0 -0
  249. package/dist/migrate/validation/migration-report-writer.js.map +1 -0
  250. package/dist/orchviz-web/index.js +3 -3
  251. package/package.json +1 -1
  252. package/portable-manifest.json +10 -2
  253. package/dist/commands/evolve.d.ts +0 -11
  254. package/dist/commands/evolve.d.ts.map +0 -1
  255. package/dist/commands/evolve.js +0 -63
  256. package/dist/commands/evolve.js.map +0 -1
  257. package/dist/commands/health.d.ts +0 -14
  258. package/dist/commands/health.d.ts.map +0 -1
  259. package/dist/commands/health.js +0 -193
  260. package/dist/commands/health.js.map +0 -1
  261. package/dist/commands/policy.d.ts +0 -8
  262. package/dist/commands/policy.d.ts.map +0 -1
  263. package/dist/commands/policy.js +0 -65
  264. package/dist/commands/policy.js.map +0 -1
  265. package/dist/commands/portability.d.ts +0 -7
  266. package/dist/commands/portability.d.ts.map +0 -1
  267. package/dist/commands/portability.js +0 -50
  268. package/dist/commands/portability.js.map +0 -1
  269. package/dist/commands/reflect.d.ts +0 -14
  270. package/dist/commands/reflect.d.ts.map +0 -1
  271. package/dist/commands/reflect.js +0 -135
  272. package/dist/commands/reflect.js.map +0 -1
  273. package/dist/commands/simulate.d.ts +0 -14
  274. package/dist/commands/simulate.d.ts.map +0 -1
  275. package/dist/commands/simulate.js +0 -86
  276. package/dist/commands/simulate.js.map +0 -1
  277. package/dist/core/event-log.d.ts +0 -44
  278. package/dist/core/event-log.d.ts.map +0 -1
  279. package/dist/core/event-log.js +0 -169
  280. package/dist/core/event-log.js.map +0 -1
  281. package/dist/core/evolution/event-clusters.d.ts +0 -4
  282. package/dist/core/evolution/event-clusters.d.ts.map +0 -1
  283. package/dist/core/evolution/event-clusters.js +0 -82
  284. package/dist/core/evolution/event-clusters.js.map +0 -1
  285. package/dist/core/evolution/recommendation-renderer.d.ts +0 -3
  286. package/dist/core/evolution/recommendation-renderer.d.ts.map +0 -1
  287. package/dist/core/evolution/recommendation-renderer.js +0 -24
  288. package/dist/core/evolution/recommendation-renderer.js.map +0 -1
  289. package/dist/core/evolution/review-failure-clusters.d.ts +0 -10
  290. package/dist/core/evolution/review-failure-clusters.d.ts.map +0 -1
  291. package/dist/core/evolution/review-failure-clusters.js +0 -30
  292. package/dist/core/evolution/review-failure-clusters.js.map +0 -1
  293. package/dist/core/evolution/suggestions.d.ts +0 -24
  294. package/dist/core/evolution/suggestions.d.ts.map +0 -1
  295. package/dist/core/evolution/suggestions.js +0 -11
  296. package/dist/core/evolution/suggestions.js.map +0 -1
  297. package/dist/core/gate-policy.d.ts +0 -20
  298. package/dist/core/gate-policy.d.ts.map +0 -1
  299. package/dist/core/gate-policy.js +0 -64
  300. package/dist/core/gate-policy.js.map +0 -1
  301. package/dist/core/portability-matrix.d.ts +0 -17
  302. package/dist/core/portability-matrix.d.ts.map +0 -1
  303. package/dist/core/portability-matrix.js +0 -31
  304. package/dist/core/portability-matrix.js.map +0 -1
  305. package/dist/core/simulation-runner.d.ts +0 -93
  306. package/dist/core/simulation-runner.d.ts.map +0 -1
  307. package/dist/core/simulation-runner.js +0 -161
  308. package/dist/core/simulation-runner.js.map +0 -1
  309. package/dist/core/usage/usage-analyzer.d.ts +0 -18
  310. package/dist/core/usage/usage-analyzer.d.ts.map +0 -1
  311. package/dist/core/usage/usage-analyzer.js +0 -41
  312. package/dist/core/usage/usage-analyzer.js.map +0 -1
  313. package/dist/memory/archive.d.ts +0 -9
  314. package/dist/memory/archive.d.ts.map +0 -1
  315. package/dist/memory/archive.js +0 -42
  316. package/dist/memory/archive.js.map +0 -1
  317. package/dist/memory/compact.d.ts +0 -9
  318. package/dist/memory/compact.d.ts.map +0 -1
  319. package/dist/memory/compact.js +0 -33
  320. package/dist/memory/compact.js.map +0 -1
  321. package/dist/memory/conflicts.d.ts +0 -8
  322. package/dist/memory/conflicts.d.ts.map +0 -1
  323. package/dist/memory/conflicts.js +0 -28
  324. package/dist/memory/conflicts.js.map +0 -1
  325. package/dist/memory/promote.d.ts +0 -8
  326. package/dist/memory/promote.d.ts.map +0 -1
  327. package/dist/memory/promote.js +0 -10
  328. package/dist/memory/promote.js.map +0 -1
  329. package/dist/memory/store-utils.d.ts +0 -14
  330. package/dist/memory/store-utils.d.ts.map +0 -1
  331. package/dist/memory/store-utils.js +0 -44
  332. package/dist/memory/store-utils.js.map +0 -1
  333. package/dist/migrate/__tests__/frontmatter-parser.test.d.ts +0 -2
  334. package/dist/migrate/__tests__/frontmatter-parser.test.d.ts.map +0 -1
  335. package/dist/migrate/__tests__/frontmatter-parser.test.js +0 -73
  336. package/dist/migrate/__tests__/frontmatter-parser.test.js.map +0 -1
  337. package/dist/migrate/__tests__/md-strip-mewkit.test.d.ts +0 -2
  338. package/dist/migrate/__tests__/md-strip-mewkit.test.d.ts.map +0 -1
  339. package/dist/migrate/__tests__/md-strip-mewkit.test.js +0 -55
  340. package/dist/migrate/__tests__/md-strip-mewkit.test.js.map +0 -1
  341. package/dist/migrate/__tests__/migrate-scope-resolver.test.d.ts +0 -2
  342. package/dist/migrate/__tests__/migrate-scope-resolver.test.d.ts.map +0 -1
  343. package/dist/migrate/__tests__/migrate-scope-resolver.test.js +0 -53
  344. package/dist/migrate/__tests__/migrate-scope-resolver.test.js.map +0 -1
  345. package/dist/migrate/__tests__/process-lock.test.d.ts +0 -2
  346. package/dist/migrate/__tests__/process-lock.test.d.ts.map +0 -1
  347. package/dist/migrate/__tests__/process-lock.test.js +0 -63
  348. package/dist/migrate/__tests__/process-lock.test.js.map +0 -1
  349. package/dist/migrate/__tests__/provider-registry.test.d.ts +0 -2
  350. package/dist/migrate/__tests__/provider-registry.test.d.ts.map +0 -1
  351. package/dist/migrate/__tests__/provider-registry.test.js +0 -53
  352. package/dist/migrate/__tests__/provider-registry.test.js.map +0 -1
  353. package/dist/migrate/__tests__/reconciler.test.d.ts +0 -2
  354. package/dist/migrate/__tests__/reconciler.test.d.ts.map +0 -1
  355. package/dist/migrate/__tests__/reconciler.test.js +0 -180
  356. package/dist/migrate/__tests__/reconciler.test.js.map +0 -1
  357. package/dist/migrate/__tests__/skill-id-utils.test.d.ts +0 -2
  358. package/dist/migrate/__tests__/skill-id-utils.test.d.ts.map +0 -1
  359. package/dist/migrate/__tests__/skill-id-utils.test.js +0 -78
  360. package/dist/migrate/__tests__/skill-id-utils.test.js.map +0 -1
  361. package/dist/orchviz/plan/__tests__/apply-todo-toggle.test.d.ts +0 -15
  362. package/dist/orchviz/plan/__tests__/apply-todo-toggle.test.d.ts.map +0 -1
  363. package/dist/orchviz/plan/__tests__/apply-todo-toggle.test.js +0 -165
  364. package/dist/orchviz/plan/__tests__/apply-todo-toggle.test.js.map +0 -1
  365. package/dist/orchviz/plan/__tests__/atomic-write.test.d.ts +0 -11
  366. package/dist/orchviz/plan/__tests__/atomic-write.test.d.ts.map +0 -1
  367. package/dist/orchviz/plan/__tests__/atomic-write.test.js +0 -89
  368. package/dist/orchviz/plan/__tests__/atomic-write.test.js.map +0 -1
  369. package/dist/orchviz/plan/__tests__/end-to-end.test.d.ts +0 -10
  370. package/dist/orchviz/plan/__tests__/end-to-end.test.d.ts.map +0 -1
  371. package/dist/orchviz/plan/__tests__/end-to-end.test.js +0 -132
  372. package/dist/orchviz/plan/__tests__/end-to-end.test.js.map +0 -1
  373. package/dist/orchviz/plan/__tests__/etag.test.d.ts +0 -11
  374. package/dist/orchviz/plan/__tests__/etag.test.d.ts.map +0 -1
  375. package/dist/orchviz/plan/__tests__/etag.test.js +0 -92
  376. package/dist/orchviz/plan/__tests__/etag.test.js.map +0 -1
  377. package/dist/orchviz/plan/__tests__/list-plans.test.d.ts +0 -14
  378. package/dist/orchviz/plan/__tests__/list-plans.test.d.ts.map +0 -1
  379. package/dist/orchviz/plan/__tests__/list-plans.test.js +0 -154
  380. package/dist/orchviz/plan/__tests__/list-plans.test.js.map +0 -1
  381. package/dist/orchviz/server/__tests__/security-smoke.test.d.ts +0 -13
  382. package/dist/orchviz/server/__tests__/security-smoke.test.d.ts.map +0 -1
  383. package/dist/orchviz/server/__tests__/security-smoke.test.js +0 -207
  384. package/dist/orchviz/server/__tests__/security-smoke.test.js.map +0 -1
  385. package/dist/orchviz/server/__tests__/write-handlers.test.d.ts +0 -24
  386. package/dist/orchviz/server/__tests__/write-handlers.test.d.ts.map +0 -1
  387. package/dist/orchviz/server/__tests__/write-handlers.test.js +0 -347
  388. package/dist/orchviz/server/__tests__/write-handlers.test.js.map +0 -1
  389. package/dist/orchviz/test-server-boot.d.ts +0 -28
  390. package/dist/orchviz/test-server-boot.d.ts.map +0 -1
  391. package/dist/orchviz/test-server-boot.js +0 -64
  392. package/dist/orchviz/test-server-boot.js.map +0 -1
@@ -0,0 +1,23 @@
1
+ /** A host-native tool the agent invokes to acquire evidence (MeowKit only names it). */
2
+ export interface AcquisitionTool {
3
+ /** Host-native/logical tool identifier — e.g. "Read", "Grep+Glob", "shell:ripgrep". */
4
+ tool: string;
5
+ /** Plain-language note on what the tool does / any advisory caveat. */
6
+ note: string;
7
+ }
8
+ export interface AcquisitionDescriptor {
9
+ provider: string;
10
+ /** `supported` = typed host tools; `partial` = shell-mediated (advisory); `report-only` = none. */
11
+ status: "supported" | "partial" | "report-only";
12
+ /** How the host reads a file's content. null ⇒ no read surface (report-only). */
13
+ read: AcquisitionTool | null;
14
+ /** How the host searches for task-relevant paths/symbols. null ⇒ no search surface. */
15
+ search: AcquisitionTool | null;
16
+ /** Plain-language basis for the claim — what makes the status what it is. */
17
+ evidence: string;
18
+ }
19
+ /** Providers whose acquisition surface is authored + evidenced. Others are report-only. */
20
+ export declare const ACQUISITION_DESCRIPTORS: Record<string, AcquisitionDescriptor>;
21
+ /** The acquisition descriptor for a provider, or a report-only fallback that claims nothing. */
22
+ export declare function getAcquisitionDescriptor(provider: string): AcquisitionDescriptor;
23
+ //# sourceMappingURL=repo-context-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-context-adapter.d.ts","sourceRoot":"","sources":["../../src/core/repo-context-adapter.ts"],"names":[],"mappings":"AAQA,wFAAwF;AACxF,MAAM,WAAW,eAAe;IAC/B,uFAAuF;IACvF,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,mGAAmG;IACnG,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,aAAa,CAAC;IAChD,iFAAiF;IACjF,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IAC7B,uFAAuF;IACvF,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/B,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,2FAA2F;AAC3F,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAwBzE,CAAC;AAEF,gGAAgG;AAChG,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CAUhF"}
@@ -0,0 +1,44 @@
1
+ // Per-provider repo-context ACQUISITION descriptors (Phase 5 slice 3). Given a provider, this
2
+ // names the host-native read + search tools the AGENT uses to acquire task-scoped evidence.
3
+ // MeowKit NEVER executes these tools — it is the outer harness: it selects the contract and
4
+ // records the resulting envelope (`context record`), while the inner runtime does the reading.
5
+ // This mirrors provider-projection.ts: a trusted constant that must not over-claim. A provider
6
+ // with no tested acquisition surface is `report-only` with null read/search — no capability to
7
+ // acquire is asserted, so the orchestrator falls back to host-provided paths only.
8
+ /** Providers whose acquisition surface is authored + evidenced. Others are report-only. */
9
+ export const ACQUISITION_DESCRIPTORS = {
10
+ "claude-code": {
11
+ provider: "claude-code",
12
+ status: "supported",
13
+ read: { tool: "Read", note: "typed host-native file read" },
14
+ search: { tool: "Grep+Glob", note: "typed content search (Grep) + filename search (Glob)" },
15
+ evidence: "Claude Code exposes typed Read/Grep/Glob tools the agent invokes to acquire evidence; MeowKit records the resulting envelope.",
16
+ },
17
+ "claude-plugin": {
18
+ provider: "claude-plugin",
19
+ status: "supported",
20
+ read: { tool: "Read", note: "typed host-native file read (same Claude Code host)" },
21
+ search: { tool: "Grep+Glob", note: "typed content + filename search (same Claude Code host)" },
22
+ evidence: "The plugin runs in the Claude Code host — identical typed Read/Grep/Glob acquisition surface.",
23
+ },
24
+ codex: {
25
+ provider: "codex",
26
+ status: "partial",
27
+ // Codex acquires through its shell, not a typed tool contract. Honest, not fabricated: we
28
+ // name the shell tools it actually uses (cat/ripgrep) and mark the whole surface advisory.
29
+ read: { tool: "shell:cat", note: "shell-mediated read — no typed read tool (advisory)" },
30
+ search: { tool: "shell:ripgrep", note: "shell-mediated search — no typed search tool (advisory)" },
31
+ evidence: "Codex acquires via its shell (cat/ripgrep), not a typed tool contract; acquisition works but is shell-mediated (advisory) ⇒ partial.",
32
+ },
33
+ };
34
+ /** The acquisition descriptor for a provider, or a report-only fallback that claims nothing. */
35
+ export function getAcquisitionDescriptor(provider) {
36
+ return (ACQUISITION_DESCRIPTORS[provider] ?? {
37
+ provider,
38
+ status: "report-only",
39
+ read: null,
40
+ search: null,
41
+ evidence: "No tested acquisition surface for this provider — report-only; the orchestrator relies on host-provided paths only.",
42
+ });
43
+ }
44
+ //# sourceMappingURL=repo-context-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-context-adapter.js","sourceRoot":"","sources":["../../src/core/repo-context-adapter.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,4FAA4F;AAC5F,4FAA4F;AAC5F,+FAA+F;AAC/F,+FAA+F;AAC/F,+FAA+F;AAC/F,mFAAmF;AAsBnF,2FAA2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAA0C;IAC7E,aAAa,EAAE;QACd,QAAQ,EAAE,aAAa;QACvB,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,6BAA6B,EAAE;QAC3D,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,sDAAsD,EAAE;QAC3F,QAAQ,EAAE,+HAA+H;KACzI;IACD,eAAe,EAAE;QAChB,QAAQ,EAAE,eAAe;QACzB,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,qDAAqD,EAAE;QACnF,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,yDAAyD,EAAE;QAC9F,QAAQ,EAAE,+FAA+F;KACzG;IACD,KAAK,EAAE;QACN,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,SAAS;QACjB,0FAA0F;QAC1F,2FAA2F;QAC3F,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,qDAAqD,EAAE;QACxF,MAAM,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,yDAAyD,EAAE;QAClG,QAAQ,EAAE,sIAAsI;KAChJ;CACD,CAAC;AAEF,gGAAgG;AAChG,MAAM,UAAU,wBAAwB,CAAC,QAAgB;IACxD,OAAO,CACN,uBAAuB,CAAC,QAAQ,CAAC,IAAI;QACpC,QAAQ;QACR,MAAM,EAAE,aAAa;QACrB,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,qHAAqH;KAC/H,CACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,147 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * A path is secret-shaped when ANY of its segments looks like a credential/key store
4
+ * (mirrors + extends injection-rules Rule 4). Checked per-segment so a `secrets/` or
5
+ * `.ssh/` directory anywhere in the path is caught, not just the basename.
6
+ */
7
+ export declare function isSecretPath(p: string): boolean;
8
+ export interface OwningRepo {
9
+ /** Repo root (git) or the boundary root (non-git) — a stable identity, never invented. */
10
+ identity: string;
11
+ /** Git HEAD revision when resolvable; null for non-git or unresolvable HEAD (provenance only). */
12
+ revision: string | null;
13
+ isGit: boolean;
14
+ }
15
+ /**
16
+ * Resolve the repository that OWNS `absPath` by walking up to the nearest ancestor containing
17
+ * a `.git` marker (never crossing above `boundaryRoot` when given). A git match yields the repo
18
+ * root + its HEAD revision; no match yields the boundary root (or the path's dir) as a stable
19
+ * non-git identity with a null revision — never a fabricated one. Each path resolves to its OWN
20
+ * nested repo, so a multi-repo parent (e.g. Aspire) is not treated as one repository.
21
+ */
22
+ export declare function resolveOwningRepo(absPath: string, boundaryRoot?: string): OwningRepo;
23
+ export declare const EvidenceRefSchema: z.ZodObject<{
24
+ path: z.ZodString;
25
+ /** SHA-256 of the file content at record time, or null when the file was missing. */
26
+ contentHash: z.ZodNullable<z.ZodString>;
27
+ owningRepoIdentity: z.ZodString;
28
+ revision: z.ZodNullable<z.ZodString>;
29
+ provenance: z.ZodDefault<z.ZodEnum<["host-read", "host-search"]>>;
30
+ /** True when the path is secret-shaped and its content must not be persisted verbatim. */
31
+ redacted: z.ZodDefault<z.ZodBoolean>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ path: string;
34
+ provenance: "host-read" | "host-search";
35
+ contentHash: string | null;
36
+ owningRepoIdentity: string;
37
+ revision: string | null;
38
+ redacted: boolean;
39
+ }, {
40
+ path: string;
41
+ contentHash: string | null;
42
+ owningRepoIdentity: string;
43
+ revision: string | null;
44
+ provenance?: "host-read" | "host-search" | undefined;
45
+ redacted?: boolean | undefined;
46
+ }>;
47
+ export type EvidenceRef = z.infer<typeof EvidenceRefSchema>;
48
+ export declare const ContextEnvelopeSchema: z.ZodObject<{
49
+ schemaVersion: z.ZodLiteral<"1.0">;
50
+ /** The task's scope/container (e.g. an Aspire-style parent holding many repos). It is NOT
51
+ * itself a repository — each evidence ref names its OWN owning repo + revision. Multi-repo
52
+ * context is therefore never collapsed into one identity. */
53
+ boundaryRoot: z.ZodString;
54
+ evidence: z.ZodDefault<z.ZodArray<z.ZodObject<{
55
+ path: z.ZodString;
56
+ /** SHA-256 of the file content at record time, or null when the file was missing. */
57
+ contentHash: z.ZodNullable<z.ZodString>;
58
+ owningRepoIdentity: z.ZodString;
59
+ revision: z.ZodNullable<z.ZodString>;
60
+ provenance: z.ZodDefault<z.ZodEnum<["host-read", "host-search"]>>;
61
+ /** True when the path is secret-shaped and its content must not be persisted verbatim. */
62
+ redacted: z.ZodDefault<z.ZodBoolean>;
63
+ }, "strip", z.ZodTypeAny, {
64
+ path: string;
65
+ provenance: "host-read" | "host-search";
66
+ contentHash: string | null;
67
+ owningRepoIdentity: string;
68
+ revision: string | null;
69
+ redacted: boolean;
70
+ }, {
71
+ path: string;
72
+ contentHash: string | null;
73
+ owningRepoIdentity: string;
74
+ revision: string | null;
75
+ provenance?: "host-read" | "host-search" | undefined;
76
+ redacted?: boolean | undefined;
77
+ }>, "many">>;
78
+ queryDescriptor: z.ZodDefault<z.ZodString>;
79
+ toolDescriptor: z.ZodDefault<z.ZodString>;
80
+ timestamp: z.ZodString;
81
+ omissions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
82
+ }, "strip", z.ZodTypeAny, {
83
+ schemaVersion: "1.0";
84
+ boundaryRoot: string;
85
+ evidence: {
86
+ path: string;
87
+ provenance: "host-read" | "host-search";
88
+ contentHash: string | null;
89
+ owningRepoIdentity: string;
90
+ revision: string | null;
91
+ redacted: boolean;
92
+ }[];
93
+ queryDescriptor: string;
94
+ toolDescriptor: string;
95
+ timestamp: string;
96
+ omissions: string[];
97
+ }, {
98
+ schemaVersion: "1.0";
99
+ boundaryRoot: string;
100
+ timestamp: string;
101
+ evidence?: {
102
+ path: string;
103
+ contentHash: string | null;
104
+ owningRepoIdentity: string;
105
+ revision: string | null;
106
+ provenance?: "host-read" | "host-search" | undefined;
107
+ redacted?: boolean | undefined;
108
+ }[] | undefined;
109
+ queryDescriptor?: string | undefined;
110
+ toolDescriptor?: string | undefined;
111
+ omissions?: string[] | undefined;
112
+ }>;
113
+ export type ContextEnvelope = z.infer<typeof ContextEnvelopeSchema>;
114
+ export interface RepoRef {
115
+ identity: string;
116
+ revision: string | null;
117
+ }
118
+ /**
119
+ * The DISTINCT owning repositories represented in an evidence set, each with its own revision.
120
+ * This is the multi-repo context view: a task touching several repos under one container (e.g.
121
+ * Aspire) surfaces every repo separately — no repo's identity/revision is lost or conflated.
122
+ */
123
+ export declare function distinctRepos(refs: EvidenceRef[]): RepoRef[];
124
+ /** Hash an evidence file for freshness; null when it does not exist (missing evidence). */
125
+ export declare function hashEvidence(absPath: string): string | null;
126
+ /**
127
+ * Build an evidence reference for a path: owning repo + revision, content hash, and a redaction
128
+ * flag for secret-shaped paths (whose CONTENT must never be persisted — only the hash + flag).
129
+ */
130
+ export declare function buildEvidenceRef(absPath: string, boundaryRoot: string, provenance?: EvidenceRef["provenance"]): EvidenceRef;
131
+ export type FreshnessStatus = "fresh" | "stale" | "missing" | "out-of-scope";
132
+ /**
133
+ * Path-scoped freshness: re-hash each recorded evidence path and compare to its recorded hash.
134
+ * A repo advancing its revision does NOT make untouched files stale — only a changed hash does.
135
+ *
136
+ * SECURITY: an envelope is untrusted DATA (it can ship in a third-party repo or be produced by
137
+ * an injection-tricked agent). When `boundaryRoot` is given, a path outside it is reported
138
+ * `out-of-scope` and is NEVER stat-ed or hashed — otherwise `check` would become an
139
+ * existence/hash oracle for arbitrary absolute paths (e.g. `~/.ssh/id_rsa`, `/etc/passwd`).
140
+ */
141
+ export declare function checkEvidenceFreshness(refs: EvidenceRef[], boundaryRoot?: string): {
142
+ path: string;
143
+ status: FreshnessStatus;
144
+ }[];
145
+ /** True when `target` stays within `boundaryRoot` (lexical; used to reject out-of-scope evidence). */
146
+ export declare function isWithinBoundary(boundaryRoot: string, target: string): boolean;
147
+ //# sour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GG;AACH,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,GAAE,WAAW,CAAC,YAAY,CAAe,GACjD,WAAW,CAab;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,cAAc,CAAC;AAE7E;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,WAAW,EAAE,EACnB,YAAY,CAAC,EAAE,MAAM,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,EAAE,CAU7C;AAED,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAG9E"}
@@ -0,0 +1,204 @@
1
+ // Task-scoped repository context (Phase 5): an on-demand evidence LEDGER, not a retrieval
2
+ // engine. MeowKit resolves a path's owning repository + revision, hashes it for path-scoped
3
+ // freshness, and records/verifies an evidence envelope — the HOST's native tools acquire the
4
+ // content. Retrieved bytes are DATA (never instructions); secret-shaped paths are redacted.
5
+ // Revision is read directly from git refs (no `git` binary), and is PROVENANCE — freshness is
6
+ // per-file-hash, so one repo advancing never marks another repo's untouched evidence stale.
7
+ import { existsSync, readFileSync, statSync } from "node:fs";
8
+ import { dirname, join, resolve, relative, isAbsolute, sep } from "node:path";
9
+ import { z } from "zod";
10
+ import { hashFile } from "./compute-checksums.js";
11
+ /**
12
+ * A path is secret-shaped when ANY of its segments looks like a credential/key store
13
+ * (mirrors + extends injection-rules Rule 4). Checked per-segment so a `secrets/` or
14
+ * `.ssh/` directory anywhere in the path is caught, not just the basename.
15
+ */
16
+ export function isSecretPath(p) {
17
+ return p.split(/[/\\]/).some((seg) => {
18
+ const s = seg.toLowerCase();
19
+ return (s === ".env" ||
20
+ s.startsWith(".env.") || // .env.local, .env.production, …
21
+ s === ".npmrc" ||
22
+ s === ".netrc" ||
23
+ s === ".ssh" ||
24
+ s.includes("credential") ||
25
+ s.includes("secret") ||
26
+ /(^|[._-])token([._-]|$)/.test(s) || // access_token, token.json — not "tokenizer"
27
+ /^id_(rsa|dsa|ecdsa|ed25519)$/.test(s) ||
28
+ /\.(pem|key|keystore|p12|pfx|jks)$/.test(s));
29
+ });
30
+ }
31
+ /** A resolved git revision must be a hex object id — never arbitrary file content. */
32
+ const SHA_RE = /^[0-9a-f]{7,64}$/;
33
+ /** Resolve the `.git` metadata dir, following a `.git` FILE (worktree/submodule gitdir pointer).
34
+ * Best-effort: any fs error yields null (revision is provenance, never load-bearing). */
35
+ function resolveGitDir(repoRoot) {
36
+ try {
37
+ const dotgit = join(repoRoot, ".git");
38
+ if (!existsSync(dotgit))
39
+ return null;
40
+ if (statSync(dotgit).isDirectory())
41
+ return dotgit;
42
+ // `.git` is a file: `gitdir: <path>`
43
+ const m = /^gitdir:\s*(.+)$/m.exec(readFileSync(dotgit, "utf-8"));
44
+ if (!m)
45
+ return null;
46
+ const gd = m[1].trim();
47
+ return isAbsolute(gd) ? gd : resolve(repoRoot, gd);
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
53
+ /** Read the HEAD revision from a git metadata dir directly (HEAD → ref → packed-refs). */
54
+ function readHeadRevision(gitDir) {
55
+ try {
56
+ return readHeadRevisionUnsafe(gitDir);
57
+ }
58
+ catch {
59
+ return null; // best-effort provenance — a crafted/unreadable repo never crashes resolution
60
+ }
61
+ }
62
+ function readHeadRevisionUnsafe(gitDir) {
63
+ const headPath = join(gitDir, "HEAD");
64
+ if (!existsSync(headPath))
65
+ return null;
66
+ const head = readFileSync(headPath, "utf-8").trim();
67
+ if (head.startsWith("ref:")) {
68
+ const ref = head.slice(4).trim(); // refs/heads/<branch>
69
+ const refFile = join(gitDir, ref);
70
+ // SECURITY: HEAD is untrusted repo DATA. Only return a value that is a hex object id,
71
+ // and only from a ref file still contained in gitDir — a crafted `ref: ../../etc/passwd`
72
+ // must never read arbitrary file content into the revision field.
73
+ if (existsSync(refFile) && isWithinBoundary(gitDir, refFile)) {
74
+ const sha = readFileSync(refFile, "utf-8").trim();
75
+ if (SHA_RE.test(sha))
76
+ return sha;
77
+ }
78
+ const packed = join(gitDir, "packed-refs");
79
+ if (existsSync(packed)) {
80
+ for (const line of readFileSync(packed, "utf-8").split("\n")) {
81
+ const m = /^([0-9a-f]{7,64})\s+(.+)$/.exec(line.trim());
82
+ if (m && m[2] === ref)
83
+ return m[1];
84
+ }
85
+ }
86
+ return null;
87
+ }
88
+ return SHA_RE.test(head) ? head : null; // detached HEAD
89
+ }
90
+ /**
91
+ * Resolve the repository that OWNS `absPath` by walking up to the nearest ancestor containing
92
+ * a `.git` marker (never crossing above `boundaryRoot` when given). A git match yields the repo
93
+ * root + its HEAD revision; no match yields the boundary root (or the path's dir) as a stable
94
+ * non-git identity with a null revision — never a fabricated one. Each path resolves to its OWN
95
+ * nested repo, so a multi-repo parent (e.g. Aspire) is not treated as one repository.
96
+ */
97
+ export function resolveOwningRepo(absPath, boundaryRoot) {
98
+ const startDir = existsSync(absPath) && statSync(absPath).isDirectory() ? absPath : dirname(absPath);
99
+ const boundary = boundaryRoot ? resolve(boundaryRoot) : null;
100
+ let dir = resolve(startDir);
101
+ // Defense in depth: never walk a start path that lies outside the boundary (a caller that
102
+ // skipped the containment gate must not make us climb to an unrelated parent repo).
103
+ if (boundary && !isWithinBoundary(boundary, dir))
104
+ return { identity: boundary, revision: null, isGit: false };
105
+ for (;;) {
106
+ if (existsSync(join(dir, ".git"))) {
107
+ const gitDir = resolveGitDir(dir);
108
+ return { identity: dir, revision: gitDir ? readHeadRevision(gitDir) : null, isGit: true };
109
+ }
110
+ if (boundary && dir === boundary)
111
+ break; // do not cross the boundary
112
+ const parent = dirname(dir);
113
+ if (parent === dir)
114
+ break; // filesystem root
115
+ dir = parent;
116
+ }
117
+ return { identity: boundary ?? startDir, revision: null, isGit: false };
118
+ }
119
+ export const EvidenceRefSchema = z.object({
120
+ path: z.string(),
121
+ /** SHA-256 of the file content at record time, or null when the file was missing. */
122
+ contentHash: z.string().nullable(),
123
+ owningRepoIdentity: z.string(),
124
+ revision: z.string().nullable(),
125
+ provenance: z.enum(["host-read", "host-search"]).default("host-read"),
126
+ /** True when the path is secret-shaped and its content must not be persisted verbatim. */
127
+ redacted: z.boolean().default(false),
128
+ });
129
+ export const ContextEnvelopeSchema = z.object({
130
+ schemaVersion: z.literal("1.0"),
131
+ /** The task's scope/container (e.g. an Aspire-style parent holding many repos). It is NOT
132
+ * itself a repository — each evidence ref names its OWN owning repo + revision. Multi-repo
133
+ * context is therefore never collapsed into one identity. */
134
+ boundaryRoot: z.string(),
135
+ evidence: z.array(EvidenceRefSchema).default([]),
136
+ queryDescriptor: z.string().default(""),
137
+ toolDescriptor: z.string().default(""),
138
+ timestamp: z.string(),
139
+ omissions: z.array(z.string()).default([]),
140
+ });
141
+ /**
142
+ * The DISTINCT owning repositories represented in an evidence set, each with its own revision.
143
+ * This is the multi-repo context view: a task touching several repos under one container (e.g.
144
+ * Aspire) surfaces every repo separately — no repo's identity/revision is lost or conflated.
145
+ */
146
+ export function distinctRepos(refs) {
147
+ const byIdentity = new Map();
148
+ for (const r of refs)
149
+ if (!byIdentity.has(r.owningRepoIdentity))
150
+ byIdentity.set(r.owningRepoIdentity, r.revision);
151
+ return [...byIdentity]
152
+ .map(([identity, revision]) => ({ identity, revision }))
153
+ .sort((a, b) => (a.identity < b.identity ? -1 : a.identity > b.identity ? 1 : 0));
154
+ }
155
+ /** Hash an evidence file for freshness; null when it does not exist (missing evidence). */
156
+ export function hashEvidence(absPath) {
157
+ return existsSync(absPath) ? hashFile(absPath) : null;
158
+ }
159
+ /**
160
+ * Build an evidence reference for a path: owning repo + revision, content hash, and a redaction
161
+ * flag for secret-shaped paths (whose CONTENT must never be persisted — only the hash + flag).
162
+ */
163
+ export function buildEvidenceRef(absPath, boundaryRoot, provenance = "host-read") {
164
+ const owner = resolveOwningRepo(absPath, boundaryRoot);
165
+ const redacted = isSecretPath(absPath);
166
+ return {
167
+ path: absPath,
168
+ // A secret-shaped file is NOT hashed — even a content hash of a low-entropy secret is a
169
+ // weak confirmation oracle. Its presence is tracked; its content never touches the record.
170
+ contentHash: redacted ? null : hashEvidence(absPath),
171
+ owningRepoIdentity: owner.identity,
172
+ revision: owner.revision,
173
+ provenance,
174
+ redacted,
175
+ };
176
+ }
177
+ /**
178
+ * Path-scoped freshness: re-hash each recorded evidence path and compare to its recorded hash.
179
+ * A repo advancing its revision does NOT make untouched files stale — only a changed hash does.
180
+ *
181
+ * SECURITY: an envelope is untrusted DATA (it can ship in a third-party repo or be produced by
182
+ * an injection-tricked agent). When `boundaryRoot` is given, a path outside it is reported
183
+ * `out-of-scope` and is NEVER stat-ed or hashed — otherwise `check` would become an
184
+ * existence/hash oracle for arbitrary absolute paths (e.g. `~/.ssh/id_rsa`, `/etc/passwd`).
185
+ */
186
+ export function checkEvidenceFreshness(refs, boundaryRoot) {
187
+ return refs.map((ref) => {
188
+ if (boundaryRoot && !isWithinBoundary(boundaryRoot, ref.path)) {
189
+ return { path: ref.path, status: "out-of-scope" };
190
+ }
191
+ const current = hashEvidence(ref.path);
192
+ if (current === null)
193
+ return { path: ref.path, status: "missing" };
194
+ if (ref.contentHash === null || current !== ref.contentHash)
195
+ return { path: ref.path, status: "stale" };
196
+ return { path: ref.path, status: "fresh" };
197
+ });
198
+ }
199
+ /** True when `target` stays within `boundaryRoot` (lexical; used to reject out-of-scope evidence). */
200
+ export function isWithinBoundary(boundaryRoot, target) {
201
+ const rel = relative(resolve(boundaryRoot), resolve(target));
202
+ return rel !== ".." && !rel.startsWith(".." + sep) && !isAbsolute(rel);
203
+ }
204
+ //# sourceMappingURL=repo-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-context.js","sourceRoot":"","sources":["../../src/core/repo-context.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,4FAA4F;AAC5F,6FAA6F;AAC7F,4FAA4F;AAC5F,8FAA8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G,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,SAAkB,EAAE,CAAC;QAC5E,IAAI,GAAG,CAAC,WAAW,KAAK,IAAI,IAAI,OAAO,KAAK,GAAG,CAAC,WAAW;YAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAgB,EAAE,CAAC;QACjH,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAgB,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,gBAAgB,CAAC,YAAoB,EAAE,MAAc;IACpE,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,OAAO,GAAG,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACxE,CAAC"}
@@ -0,0 +1,70 @@
1
+ import type { CapabilityEntry, ContextRequirement, SupportLevels, TypedRequirement, Verification } from "./capability.js";
2
+ import { type AvailabilityContext, type AvailabilitySnapshot, type AvailabilityStatus } from "./availability.js";
3
+ import { type AcquisitionDescriptor } from "./repo-context-adapter.js";
4
+ import { type LifecycleEvent } from "./provider-lifecycle.js";
5
+ export interface ResolvedCandidate {
6
+ id: string;
7
+ kind: string;
8
+ score: number;
9
+ reason: string;
10
+ /** Static per-provider support, or null when that provider has no recorded evidence. */
11
+ support: SupportLevels | null;
12
+ requirements: TypedRequirement[];
13
+ /** Set when the candidate must acquire a task-scoped repo-context envelope before
14
+ * source-grounded work (Phase 5). The orchestrator — not this pure resolver — acquires it. */
15
+ contextRequirement: ContextRequirement | null;
16
+ verification: Verification;
17
+ /** Runtime invocability is deferred to Phase 3's host snapshot — never asserted here. */
18
+ invocable: "pending-host-snapshot";
19
+ }
20
+ export interface ResolveResult {
21
+ intent: string;
22
+ provider: string | null;
23
+ candidates: ResolvedCandidate[];
24
+ /** True when no candidate matched OR the top two are within the near-tie threshold. */
25
+ ambiguous: boolean;
26
+ }
27
+ /**
28
+ * Resolve an intent to ranked candidates. Each query term is credited ONCE at its
29
+ * highest-matching field class (intent > alias > description) — no per-keyword summation,
30
+ * so keyword multiplicity cannot inflate a score. Authored intents weigh more than
31
+ * inferred keywords. Order: score desc, then id asc (stable). Zero-score candidates are
32
+ * dropped; if none remain the result is `ambiguous` with an empty list.
33
+ */
34
+ export declare function resolveCapabilities(entries: CapabilityEntry[], intent: string, provider?: string | null): ResolveResult;
35
+ /** A resolved candidate enriched with this host's real availability (Phase 3). */
36
+ export interface HostResolvedCandidate extends Omit<ResolvedCandidate, "invocable"> {
37
+ availability: AvailabilitySnapshot[];
38
+ /** Rolled-up host invocability — replaces the at-rest `pending-host-snapshot`. */
39
+ invocable: AvailabilityStatus;
40
+ }
41
+ export interface HostResolveResult {
42
+ intent: string;
43
+ provider: string;
44
+ ambiguous: boolean;
45
+ /** Selection outcome. `not_needed` is an agent-side decision, never emitted here. */
46
+ status: "selected" | "ambiguous" | "unavailable" | "unsupported";
47
+ candidates: HostResolvedCandidate[];
48
+ /** How THIS provider acquires repo-context evidence (Phase 5 slice 3). Actionable only when
49
+ * the selected candidate carries a `contextRequirement`; the orchestrator — not MeowKit —
50
+ * runs the named read/search tools and records the envelope via `context record`. */
51
+ acquisition: AcquisitionDescriptor;
52
+ /** Self-auditing provenance (Phase 6 slice 2): which adapter + evidence justified the provider
53
+ * claims in this result, and the events this provider can actually gate on. */
54
+ adapterCitation: {
55
+ provider: string;
56
+ projectionStatus: string;
57
+ projectionEvidence: string;
58
+ gatingEvents: LifecycleEvent[];
59
+ };
60
+ }
61
+ /**
62
+ * Resolve an intent AND check this host's real availability for each candidate. Selection
63
+ * (score-based) and invocability (availability-based) are surfaced SEPARATELY per the
64
+ * four-levels model: each candidate keeps its own `invocable` verdict, while the top-level
65
+ * `status` is the aggregate envelope outcome (which does fold in the top candidate's
66
+ * invocability and support). A provider that does not support the top candidate's surface
67
+ * → `unsupported`; a top candidate whose requirements are hard-blocked → `unavailable`.
68
+ */
69
+ export declare function resolveWithHost(entries: CapabilityEntry[], intent: string, ctx: AvailabilityContext): HostResolveResult;
70
+ //# sourceMappingURL=resolve-capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-capabilities.d.ts","sourceRoot":"","sources":["../../src/core/resolve-capabilities.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1H,OAAO,EAGN,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA4B,KAAK,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEjG,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAc5E,MAAM,WAAW,iBAAiB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC;kGAC8F;IAC9F,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC9C,YAAY,EAAE,YAAY,CAAC;IAC3B,yFAAyF;IACzF,SAAS,EAAE,uBAAuB,CAAC;CACnC;AAED,MAAM,WAAW,aAAa;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,uFAAuF;IACvF,SAAS,EAAE,OAAO,CAAC;CACnB;AAqBD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,aAAa,CA6C7H;AAED,kFAAkF;AAClF,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC;IAClF,YAAY,EAAE,oBAAoB,EAAE,CAAC;IACrC,kFAAkF;IAClF,SAAS,EAAE,kBAAkB,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,qFAAqF;IACrF,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,aAAa,CAAC;IACjE,UAAU,EAAE,qBAAqB,EAAE,CAAC;IACpC;;yFAEqF;IACrF,WAAW,EAAE,qBAAqB,CAAC;IACnC;mFAC+E;IAC/E,eAAe,EAAE;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,gBAAgB,EAAE,MAAM,CAAC;QACzB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,YAAY,EAAE,cAAc,EAAE,CAAC;KAC/B,CAAC;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,mBAAmB,GAAG,iBAAiB,CA+BvH"}
@@ -0,0 +1,124 @@
1
+ import { computeAvailability, rollUpInvocability, } from "./availability.js";
2
+ import { getAcquisitionDescriptor } from "./repo-context-adapter.js";
3
+ import { getProjection } from "./provider-projection.js";
4
+ import { gatingEvents } from "./provider-lifecycle.js";
5
+ // Field-class weights. A query term is credited ONCE at its highest-matching class
6
+ // (never summed across a capability's many keyword strings — that inflates keyword-heavy
7
+ // capabilities). Authored (curated flagship) intents outweigh inferred keywords so a
8
+ // flagship phrase cannot be out-ranked by incidental keyword overlap.
9
+ const WEIGHT_AUTHORED_INTENT = 6;
10
+ const WEIGHT_INFERRED_INTENT = 3;
11
+ const WEIGHT_ALIAS = 2;
12
+ const WEIGHT_TEXT = 1;
13
+ /** A top-two gap strictly below this ⇒ ambiguous (integer scores, so this flags 0- and
14
+ * 1-point near-ties as ambiguous while an authored-vs-inferred win of ≥3 stays confident). */
15
+ const AMBIGUITY_EPSILON = 2;
16
+ const STOPWORDS = new Set(["the", "a", "an", "to", "of", "in", "on", "this", "that", "for", "and", "or", "my", "me", "it"]);
17
+ /** Normalize free text to a set of lowercase terms (drop punctuation, stopwords, 1-char). */
18
+ function terms(text) {
19
+ return new Set(text
20
+ .toLowerCase()
21
+ .split(/[^a-z0-9]+/)
22
+ .filter((t) => t.length > 1 && !STOPWORDS.has(t)));
23
+ }
24
+ /** Union of terms across many field strings (deduped) — the set a query term can match. */
25
+ function fieldTerms(strings) {
26
+ const out = new Set();
27
+ for (const s of strings)
28
+ for (const t of terms(s))
29
+ out.add(t);
30
+ return out;
31
+ }
32
+ /**
33
+ * Resolve an intent to ranked candidates. Each query term is credited ONCE at its
34
+ * highest-matching field class (intent > alias > description) — no per-keyword summation,
35
+ * so keyword multiplicity cannot inflate a score. Authored intents weigh more than
36
+ * inferred keywords. Order: score desc, then id asc (stable). Zero-score candidates are
37
+ * dropped; if none remain the result is `ambiguous` with an empty list.
38
+ */
39
+ export function resolveCapabilities(entries, intent, provider = null) {
40
+ const query = terms(intent);
41
+ const scored = entries
42
+ .map((e) => {
43
+ const intentSet = fieldTerms(e.intents);
44
+ const aliasSet = fieldTerms(e.aliases);
45
+ const textSet = fieldTerms([e.whenToUse ?? "", e.description]);
46
+ const intentWeight = e.provenance.intents === "authored" ? WEIGHT_AUTHORED_INTENT : WEIGHT_INFERRED_INTENT;
47
+ let intentHits = 0, aliasHits = 0, textHits = 0;
48
+ for (const q of query) {
49
+ if (intentSet.has(q))
50
+ intentHits++;
51
+ else if (aliasSet.has(q))
52
+ aliasHits++;
53
+ else if (textSet.has(q))
54
+ textHits++;
55
+ }
56
+ const score = intentHits * intentWeight + aliasHits * WEIGHT_ALIAS + textHits * WEIGHT_TEXT;
57
+ const parts = [];
58
+ if (intentHits)
59
+ parts.push(`${intentHits} ${e.provenance.intents === "authored" ? "authored " : ""}intent term(s)`);
60
+ if (aliasHits)
61
+ parts.push(`${aliasHits} alias term(s)`);
62
+ if (textHits)
63
+ parts.push(`${textHits} description term(s)`);
64
+ return { e, score, reason: parts.length ? `matched ${parts.join(", ")}` : "no term overlap" };
65
+ })
66
+ .filter((c) => c.score > 0)
67
+ .sort((a, b) => (b.score !== a.score ? b.score - a.score : a.e.id < b.e.id ? -1 : 1));
68
+ const candidates = scored.map(({ e, score, reason }) => ({
69
+ id: e.id,
70
+ kind: e.kind,
71
+ score,
72
+ reason,
73
+ support: provider ? e.support[provider] ?? null : null,
74
+ requirements: e.requirements,
75
+ contextRequirement: e.contextRequirement,
76
+ verification: e.verification,
77
+ invocable: "pending-host-snapshot",
78
+ }));
79
+ const ambiguous = candidates.length === 0 ||
80
+ (candidates.length >= 2 && candidates[0].score - candidates[1].score < AMBIGUITY_EPSILON);
81
+ return { intent, provider, candidates, ambiguous };
82
+ }
83
+ /**
84
+ * Resolve an intent AND check this host's real availability for each candidate. Selection
85
+ * (score-based) and invocability (availability-based) are surfaced SEPARATELY per the
86
+ * four-levels model: each candidate keeps its own `invocable` verdict, while the top-level
87
+ * `status` is the aggregate envelope outcome (which does fold in the top candidate's
88
+ * invocability and support). A provider that does not support the top candidate's surface
89
+ * → `unsupported`; a top candidate whose requirements are hard-blocked → `unavailable`.
90
+ */
91
+ export function resolveWithHost(entries, intent, ctx) {
92
+ const byId = new Map(entries.map((e) => [e.id, e]));
93
+ const base = resolveCapabilities(entries, intent, ctx.provider);
94
+ const candidates = base.candidates.map((c) => {
95
+ const entry = byId.get(c.id);
96
+ const availability = entry ? computeAvailability(entry, ctx) : [];
97
+ // Spread-override the at-rest `pending-host-snapshot` invocable with the host verdict.
98
+ return { ...c, availability, invocable: rollUpInvocability(availability) };
99
+ });
100
+ let status;
101
+ if (candidates.length === 0)
102
+ status = "unavailable";
103
+ else if (base.ambiguous)
104
+ status = "ambiguous";
105
+ else if (candidates[0].support && candidates[0].support.discoverable === false)
106
+ status = "unsupported";
107
+ else
108
+ status = candidates[0].invocable === "unavailable" ? "unavailable" : "selected";
109
+ return {
110
+ intent: base.intent,
111
+ provider: ctx.provider,
112
+ ambiguous: base.ambiguous,
113
+ status,
114
+ candidates,
115
+ acquisition: getAcquisitionDescriptor(ctx.provider),
116
+ adapterCitation: {
117
+ provider: ctx.provider,
118
+ projectionStatus: getProjection(ctx.provider).status,
119
+ projectionEvidence: getProjection(ctx.provider).evidence,
120
+ gatingEvents: gatingEvents(ctx.provider),
121
+ },
122
+ };
123
+ }
124
+ //# sourceMappingURL=resolve-capabilities.js.map