@opensip-cli/core 0.1.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 (604) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +31 -0
  4. package/dist/__tests__/config-resolution.test.d.ts +2 -0
  5. package/dist/__tests__/config-resolution.test.d.ts.map +1 -0
  6. package/dist/__tests__/config-resolution.test.js +94 -0
  7. package/dist/__tests__/config-resolution.test.js.map +1 -0
  8. package/dist/__tests__/public-api.test.d.ts +16 -0
  9. package/dist/__tests__/public-api.test.d.ts.map +1 -0
  10. package/dist/__tests__/public-api.test.js +209 -0
  11. package/dist/__tests__/public-api.test.js.map +1 -0
  12. package/dist/__tests__/signal-batch.test.d.ts +2 -0
  13. package/dist/__tests__/signal-batch.test.d.ts.map +1 -0
  14. package/dist/__tests__/signal-batch.test.js +39 -0
  15. package/dist/__tests__/signal-batch.test.js.map +1 -0
  16. package/dist/__tests__/signal-sink.test.d.ts +2 -0
  17. package/dist/__tests__/signal-sink.test.d.ts.map +1 -0
  18. package/dist/__tests__/signal-sink.test.js +25 -0
  19. package/dist/__tests__/signal-sink.test.js.map +1 -0
  20. package/dist/__tests__/strip-utils.test.d.ts +2 -0
  21. package/dist/__tests__/strip-utils.test.d.ts.map +1 -0
  22. package/dist/__tests__/strip-utils.test.js +397 -0
  23. package/dist/__tests__/strip-utils.test.js.map +1 -0
  24. package/dist/__tests__/text-tree.test.d.ts +2 -0
  25. package/dist/__tests__/text-tree.test.d.ts.map +1 -0
  26. package/dist/__tests__/text-tree.test.js +31 -0
  27. package/dist/__tests__/text-tree.test.js.map +1 -0
  28. package/dist/baseline/__tests__/fingerprint-strategy.test.d.ts +2 -0
  29. package/dist/baseline/__tests__/fingerprint-strategy.test.d.ts.map +1 -0
  30. package/dist/baseline/__tests__/fingerprint-strategy.test.js +69 -0
  31. package/dist/baseline/__tests__/fingerprint-strategy.test.js.map +1 -0
  32. package/dist/baseline/fingerprint-strategy.d.ts +70 -0
  33. package/dist/baseline/fingerprint-strategy.d.ts.map +1 -0
  34. package/dist/baseline/fingerprint-strategy.js +90 -0
  35. package/dist/baseline/fingerprint-strategy.js.map +1 -0
  36. package/dist/config-resolution.d.ts +27 -0
  37. package/dist/config-resolution.d.ts.map +1 -0
  38. package/dist/config-resolution.js +92 -0
  39. package/dist/config-resolution.js.map +1 -0
  40. package/dist/index.d.ts +81 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +165 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/languages/__tests__/content-filter-dispatch.test.d.ts +2 -0
  45. package/dist/languages/__tests__/content-filter-dispatch.test.d.ts.map +1 -0
  46. package/dist/languages/__tests__/content-filter-dispatch.test.js +87 -0
  47. package/dist/languages/__tests__/content-filter-dispatch.test.js.map +1 -0
  48. package/dist/languages/__tests__/non-code-formats.test.d.ts +2 -0
  49. package/dist/languages/__tests__/non-code-formats.test.d.ts.map +1 -0
  50. package/dist/languages/__tests__/non-code-formats.test.js +31 -0
  51. package/dist/languages/__tests__/non-code-formats.test.js.map +1 -0
  52. package/dist/languages/__tests__/parse-cache.test.d.ts +2 -0
  53. package/dist/languages/__tests__/parse-cache.test.d.ts.map +1 -0
  54. package/dist/languages/__tests__/parse-cache.test.js +228 -0
  55. package/dist/languages/__tests__/parse-cache.test.js.map +1 -0
  56. package/dist/languages/__tests__/registry.test.d.ts +2 -0
  57. package/dist/languages/__tests__/registry.test.d.ts.map +1 -0
  58. package/dist/languages/__tests__/registry.test.js +193 -0
  59. package/dist/languages/__tests__/registry.test.js.map +1 -0
  60. package/dist/languages/__tests__/workspace-unit-contract.test.d.ts +2 -0
  61. package/dist/languages/__tests__/workspace-unit-contract.test.d.ts.map +1 -0
  62. package/dist/languages/__tests__/workspace-unit-contract.test.js +66 -0
  63. package/dist/languages/__tests__/workspace-unit-contract.test.js.map +1 -0
  64. package/dist/languages/adapter.d.ts +66 -0
  65. package/dist/languages/adapter.d.ts.map +1 -0
  66. package/dist/languages/adapter.js +2 -0
  67. package/dist/languages/adapter.js.map +1 -0
  68. package/dist/languages/content-filter-dispatch.d.ts +36 -0
  69. package/dist/languages/content-filter-dispatch.d.ts.map +1 -0
  70. package/dist/languages/content-filter-dispatch.js +75 -0
  71. package/dist/languages/content-filter-dispatch.js.map +1 -0
  72. package/dist/languages/generic-types.d.ts +22 -0
  73. package/dist/languages/generic-types.d.ts.map +1 -0
  74. package/dist/languages/generic-types.js +3 -0
  75. package/dist/languages/generic-types.js.map +1 -0
  76. package/dist/languages/index.d.ts +12 -0
  77. package/dist/languages/index.d.ts.map +1 -0
  78. package/dist/languages/index.js +7 -0
  79. package/dist/languages/index.js.map +1 -0
  80. package/dist/languages/non-code-formats.d.ts +37 -0
  81. package/dist/languages/non-code-formats.d.ts.map +1 -0
  82. package/dist/languages/non-code-formats.js +45 -0
  83. package/dist/languages/non-code-formats.js.map +1 -0
  84. package/dist/languages/parse-cache-class.d.ts +69 -0
  85. package/dist/languages/parse-cache-class.d.ts.map +1 -0
  86. package/dist/languages/parse-cache-class.js +135 -0
  87. package/dist/languages/parse-cache-class.js.map +1 -0
  88. package/dist/languages/parse-cache.d.ts +54 -0
  89. package/dist/languages/parse-cache.d.ts.map +1 -0
  90. package/dist/languages/parse-cache.js +88 -0
  91. package/dist/languages/parse-cache.js.map +1 -0
  92. package/dist/languages/registry.d.ts +35 -0
  93. package/dist/languages/registry.d.ts.map +1 -0
  94. package/dist/languages/registry.js +123 -0
  95. package/dist/languages/registry.js.map +1 -0
  96. package/dist/languages/strip-scanners.d.ts +170 -0
  97. package/dist/languages/strip-scanners.d.ts.map +1 -0
  98. package/dist/languages/strip-scanners.js +233 -0
  99. package/dist/languages/strip-scanners.js.map +1 -0
  100. package/dist/languages/strip-utils.d.ts +66 -0
  101. package/dist/languages/strip-utils.d.ts.map +1 -0
  102. package/dist/languages/strip-utils.js +88 -0
  103. package/dist/languages/strip-utils.js.map +1 -0
  104. package/dist/languages/text-tree.d.ts +44 -0
  105. package/dist/languages/text-tree.d.ts.map +1 -0
  106. package/dist/languages/text-tree.js +34 -0
  107. package/dist/languages/text-tree.js.map +1 -0
  108. package/dist/languages/workspace-unit.d.ts +18 -0
  109. package/dist/languages/workspace-unit.d.ts.map +1 -0
  110. package/dist/languages/workspace-unit.js +2 -0
  111. package/dist/languages/workspace-unit.js.map +1 -0
  112. package/dist/lib/__tests__/config-version.test.d.ts +12 -0
  113. package/dist/lib/__tests__/config-version.test.d.ts.map +1 -0
  114. package/dist/lib/__tests__/config-version.test.js +92 -0
  115. package/dist/lib/__tests__/config-version.test.js.map +1 -0
  116. package/dist/lib/__tests__/diagnostics-bus.test.d.ts +7 -0
  117. package/dist/lib/__tests__/diagnostics-bus.test.d.ts.map +1 -0
  118. package/dist/lib/__tests__/diagnostics-bus.test.js +44 -0
  119. package/dist/lib/__tests__/diagnostics-bus.test.js.map +1 -0
  120. package/dist/lib/__tests__/env-registry.test.d.ts +7 -0
  121. package/dist/lib/__tests__/env-registry.test.d.ts.map +1 -0
  122. package/dist/lib/__tests__/env-registry.test.js +82 -0
  123. package/dist/lib/__tests__/env-registry.test.js.map +1 -0
  124. package/dist/lib/__tests__/errors.test.d.ts +2 -0
  125. package/dist/lib/__tests__/errors.test.d.ts.map +1 -0
  126. package/dist/lib/__tests__/errors.test.js +218 -0
  127. package/dist/lib/__tests__/errors.test.js.map +1 -0
  128. package/dist/lib/__tests__/format.test.d.ts +2 -0
  129. package/dist/lib/__tests__/format.test.d.ts.map +1 -0
  130. package/dist/lib/__tests__/format.test.js +23 -0
  131. package/dist/lib/__tests__/format.test.js.map +1 -0
  132. package/dist/lib/__tests__/ids.test.d.ts +2 -0
  133. package/dist/lib/__tests__/ids.test.d.ts.map +1 -0
  134. package/dist/lib/__tests__/ids.test.js +80 -0
  135. package/dist/lib/__tests__/ids.test.js.map +1 -0
  136. package/dist/lib/__tests__/logger.test.d.ts +2 -0
  137. package/dist/lib/__tests__/logger.test.d.ts.map +1 -0
  138. package/dist/lib/__tests__/logger.test.js +284 -0
  139. package/dist/lib/__tests__/logger.test.js.map +1 -0
  140. package/dist/lib/__tests__/package-version.test.d.ts +2 -0
  141. package/dist/lib/__tests__/package-version.test.d.ts.map +1 -0
  142. package/dist/lib/__tests__/package-version.test.js +47 -0
  143. package/dist/lib/__tests__/package-version.test.js.map +1 -0
  144. package/dist/lib/__tests__/paths.test.d.ts +5 -0
  145. package/dist/lib/__tests__/paths.test.d.ts.map +1 -0
  146. package/dist/lib/__tests__/paths.test.js +59 -0
  147. package/dist/lib/__tests__/paths.test.js.map +1 -0
  148. package/dist/lib/__tests__/payload-version.test.d.ts +2 -0
  149. package/dist/lib/__tests__/payload-version.test.d.ts.map +1 -0
  150. package/dist/lib/__tests__/payload-version.test.js +35 -0
  151. package/dist/lib/__tests__/payload-version.test.js.map +1 -0
  152. package/dist/lib/__tests__/phantom-detect.test.d.ts +10 -0
  153. package/dist/lib/__tests__/phantom-detect.test.d.ts.map +1 -0
  154. package/dist/lib/__tests__/phantom-detect.test.js +84 -0
  155. package/dist/lib/__tests__/phantom-detect.test.js.map +1 -0
  156. package/dist/lib/__tests__/project-context.test.d.ts +10 -0
  157. package/dist/lib/__tests__/project-context.test.d.ts.map +1 -0
  158. package/dist/lib/__tests__/project-context.test.js +240 -0
  159. package/dist/lib/__tests__/project-context.test.js.map +1 -0
  160. package/dist/lib/__tests__/registry.test.d.ts +2 -0
  161. package/dist/lib/__tests__/registry.test.d.ts.map +1 -0
  162. package/dist/lib/__tests__/registry.test.js +333 -0
  163. package/dist/lib/__tests__/registry.test.js.map +1 -0
  164. package/dist/lib/__tests__/retry.test.d.ts +2 -0
  165. package/dist/lib/__tests__/retry.test.d.ts.map +1 -0
  166. package/dist/lib/__tests__/retry.test.js +71 -0
  167. package/dist/lib/__tests__/retry.test.js.map +1 -0
  168. package/dist/lib/__tests__/run-diagnostics.test.d.ts +9 -0
  169. package/dist/lib/__tests__/run-diagnostics.test.d.ts.map +1 -0
  170. package/dist/lib/__tests__/run-diagnostics.test.js +61 -0
  171. package/dist/lib/__tests__/run-diagnostics.test.js.map +1 -0
  172. package/dist/lib/__tests__/run-scope.test.d.ts +2 -0
  173. package/dist/lib/__tests__/run-scope.test.d.ts.map +1 -0
  174. package/dist/lib/__tests__/run-scope.test.js +202 -0
  175. package/dist/lib/__tests__/run-scope.test.js.map +1 -0
  176. package/dist/lib/__tests__/run-timer.test.d.ts +2 -0
  177. package/dist/lib/__tests__/run-timer.test.d.ts.map +1 -0
  178. package/dist/lib/__tests__/run-timer.test.js +152 -0
  179. package/dist/lib/__tests__/run-timer.test.js.map +1 -0
  180. package/dist/lib/__tests__/severity-policy.test.d.ts +6 -0
  181. package/dist/lib/__tests__/severity-policy.test.d.ts.map +1 -0
  182. package/dist/lib/__tests__/severity-policy.test.js +47 -0
  183. package/dist/lib/__tests__/severity-policy.test.js.map +1 -0
  184. package/dist/lib/__tests__/telemetry.test.d.ts +2 -0
  185. package/dist/lib/__tests__/telemetry.test.d.ts.map +1 -0
  186. package/dist/lib/__tests__/telemetry.test.js +212 -0
  187. package/dist/lib/__tests__/telemetry.test.js.map +1 -0
  188. package/dist/lib/__tests__/verdict-policy.test.d.ts +7 -0
  189. package/dist/lib/__tests__/verdict-policy.test.d.ts.map +1 -0
  190. package/dist/lib/__tests__/verdict-policy.test.js +91 -0
  191. package/dist/lib/__tests__/verdict-policy.test.js.map +1 -0
  192. package/dist/lib/__tests__/yaml.test.d.ts +6 -0
  193. package/dist/lib/__tests__/yaml.test.d.ts.map +1 -0
  194. package/dist/lib/__tests__/yaml.test.js +79 -0
  195. package/dist/lib/__tests__/yaml.test.js.map +1 -0
  196. package/dist/lib/config-version.d.ts +49 -0
  197. package/dist/lib/config-version.d.ts.map +1 -0
  198. package/dist/lib/config-version.js +56 -0
  199. package/dist/lib/config-version.js.map +1 -0
  200. package/dist/lib/diagnostics-bus.d.ts +48 -0
  201. package/dist/lib/diagnostics-bus.d.ts.map +1 -0
  202. package/dist/lib/diagnostics-bus.js +74 -0
  203. package/dist/lib/diagnostics-bus.js.map +1 -0
  204. package/dist/lib/env-registry.d.ts +108 -0
  205. package/dist/lib/env-registry.d.ts.map +1 -0
  206. package/dist/lib/env-registry.js +92 -0
  207. package/dist/lib/env-registry.js.map +1 -0
  208. package/dist/lib/errors.d.ts +132 -0
  209. package/dist/lib/errors.d.ts.map +1 -0
  210. package/dist/lib/errors.js +160 -0
  211. package/dist/lib/errors.js.map +1 -0
  212. package/dist/lib/execution/__tests__/execution.test.d.ts +7 -0
  213. package/dist/lib/execution/__tests__/execution.test.d.ts.map +1 -0
  214. package/dist/lib/execution/__tests__/execution.test.js +254 -0
  215. package/dist/lib/execution/__tests__/execution.test.js.map +1 -0
  216. package/dist/lib/execution/index.d.ts +15 -0
  217. package/dist/lib/execution/index.d.ts.map +1 -0
  218. package/dist/lib/execution/index.js +10 -0
  219. package/dist/lib/execution/index.js.map +1 -0
  220. package/dist/lib/execution/options.d.ts +32 -0
  221. package/dist/lib/execution/options.d.ts.map +1 -0
  222. package/dist/lib/execution/options.js +15 -0
  223. package/dist/lib/execution/options.js.map +1 -0
  224. package/dist/lib/execution/pipeline.d.ts +36 -0
  225. package/dist/lib/execution/pipeline.d.ts.map +1 -0
  226. package/dist/lib/execution/pipeline.js +38 -0
  227. package/dist/lib/execution/pipeline.js.map +1 -0
  228. package/dist/lib/execution/retry.d.ts +38 -0
  229. package/dist/lib/execution/retry.d.ts.map +1 -0
  230. package/dist/lib/execution/retry.js +56 -0
  231. package/dist/lib/execution/retry.js.map +1 -0
  232. package/dist/lib/execution/run-with-timeout.d.ts +46 -0
  233. package/dist/lib/execution/run-with-timeout.d.ts.map +1 -0
  234. package/dist/lib/execution/run-with-timeout.js +86 -0
  235. package/dist/lib/execution/run-with-timeout.js.map +1 -0
  236. package/dist/lib/execution/schedule.d.ts +62 -0
  237. package/dist/lib/execution/schedule.d.ts.map +1 -0
  238. package/dist/lib/execution/schedule.js +130 -0
  239. package/dist/lib/execution/schedule.js.map +1 -0
  240. package/dist/lib/format.d.ts +17 -0
  241. package/dist/lib/format.d.ts.map +1 -0
  242. package/dist/lib/format.js +26 -0
  243. package/dist/lib/format.js.map +1 -0
  244. package/dist/lib/ids.d.ts +13 -0
  245. package/dist/lib/ids.d.ts.map +1 -0
  246. package/dist/lib/ids.js +48 -0
  247. package/dist/lib/ids.js.map +1 -0
  248. package/dist/lib/logger.d.ts +166 -0
  249. package/dist/lib/logger.d.ts.map +1 -0
  250. package/dist/lib/logger.js +283 -0
  251. package/dist/lib/logger.js.map +1 -0
  252. package/dist/lib/package-version.d.ts +17 -0
  253. package/dist/lib/package-version.d.ts.map +1 -0
  254. package/dist/lib/package-version.js +52 -0
  255. package/dist/lib/package-version.js.map +1 -0
  256. package/dist/lib/paths.d.ts +139 -0
  257. package/dist/lib/paths.d.ts.map +1 -0
  258. package/dist/lib/paths.js +105 -0
  259. package/dist/lib/paths.js.map +1 -0
  260. package/dist/lib/payload-version.d.ts +15 -0
  261. package/dist/lib/payload-version.d.ts.map +1 -0
  262. package/dist/lib/payload-version.js +24 -0
  263. package/dist/lib/payload-version.js.map +1 -0
  264. package/dist/lib/phantom-detect.d.ts +21 -0
  265. package/dist/lib/phantom-detect.d.ts.map +1 -0
  266. package/dist/lib/phantom-detect.js +76 -0
  267. package/dist/lib/phantom-detect.js.map +1 -0
  268. package/dist/lib/project-context.d.ts +66 -0
  269. package/dist/lib/project-context.d.ts.map +1 -0
  270. package/dist/lib/project-context.js +112 -0
  271. package/dist/lib/project-context.js.map +1 -0
  272. package/dist/lib/recipe-id.d.ts +13 -0
  273. package/dist/lib/recipe-id.d.ts.map +1 -0
  274. package/dist/lib/recipe-id.js +15 -0
  275. package/dist/lib/recipe-id.js.map +1 -0
  276. package/dist/lib/registry.d.ts +98 -0
  277. package/dist/lib/registry.d.ts.map +1 -0
  278. package/dist/lib/registry.js +152 -0
  279. package/dist/lib/registry.js.map +1 -0
  280. package/dist/lib/retry.d.ts +26 -0
  281. package/dist/lib/retry.d.ts.map +1 -0
  282. package/dist/lib/retry.js +48 -0
  283. package/dist/lib/retry.js.map +1 -0
  284. package/dist/lib/run-diagnostics.d.ts +64 -0
  285. package/dist/lib/run-diagnostics.d.ts.map +1 -0
  286. package/dist/lib/run-diagnostics.js +25 -0
  287. package/dist/lib/run-diagnostics.js.map +1 -0
  288. package/dist/lib/run-scope.d.ts +167 -0
  289. package/dist/lib/run-scope.d.ts.map +1 -0
  290. package/dist/lib/run-scope.js +176 -0
  291. package/dist/lib/run-scope.js.map +1 -0
  292. package/dist/lib/run-timer.d.ts +82 -0
  293. package/dist/lib/run-timer.d.ts.map +1 -0
  294. package/dist/lib/run-timer.js +79 -0
  295. package/dist/lib/run-timer.js.map +1 -0
  296. package/dist/lib/scope-types.d.ts +172 -0
  297. package/dist/lib/scope-types.d.ts.map +1 -0
  298. package/dist/lib/scope-types.js +27 -0
  299. package/dist/lib/scope-types.js.map +1 -0
  300. package/dist/lib/severity-policy.d.ts +38 -0
  301. package/dist/lib/severity-policy.d.ts.map +1 -0
  302. package/dist/lib/severity-policy.js +44 -0
  303. package/dist/lib/severity-policy.js.map +1 -0
  304. package/dist/lib/telemetry.d.ts +93 -0
  305. package/dist/lib/telemetry.d.ts.map +1 -0
  306. package/dist/lib/telemetry.js +144 -0
  307. package/dist/lib/telemetry.js.map +1 -0
  308. package/dist/lib/ui-context.d.ts +34 -0
  309. package/dist/lib/ui-context.d.ts.map +1 -0
  310. package/dist/lib/ui-context.js +16 -0
  311. package/dist/lib/ui-context.js.map +1 -0
  312. package/dist/lib/verdict-policy.d.ts +71 -0
  313. package/dist/lib/verdict-policy.d.ts.map +1 -0
  314. package/dist/lib/verdict-policy.js +82 -0
  315. package/dist/lib/verdict-policy.js.map +1 -0
  316. package/dist/lib/yaml.d.ts +74 -0
  317. package/dist/lib/yaml.d.ts.map +1 -0
  318. package/dist/lib/yaml.js +118 -0
  319. package/dist/lib/yaml.js.map +1 -0
  320. package/dist/plugins/__tests__/as-if-external.test.d.ts +18 -0
  321. package/dist/plugins/__tests__/as-if-external.test.d.ts.map +1 -0
  322. package/dist/plugins/__tests__/as-if-external.test.js +159 -0
  323. package/dist/plugins/__tests__/as-if-external.test.js.map +1 -0
  324. package/dist/plugins/__tests__/authored-tool-discovery.test.d.ts +8 -0
  325. package/dist/plugins/__tests__/authored-tool-discovery.test.d.ts.map +1 -0
  326. package/dist/plugins/__tests__/authored-tool-discovery.test.js +97 -0
  327. package/dist/plugins/__tests__/authored-tool-discovery.test.js.map +1 -0
  328. package/dist/plugins/__tests__/capability-discovery.test.d.ts +2 -0
  329. package/dist/plugins/__tests__/capability-discovery.test.d.ts.map +1 -0
  330. package/dist/plugins/__tests__/capability-discovery.test.js +349 -0
  331. package/dist/plugins/__tests__/capability-discovery.test.js.map +1 -0
  332. package/dist/plugins/__tests__/capability-from-manifest.test.d.ts +2 -0
  333. package/dist/plugins/__tests__/capability-from-manifest.test.d.ts.map +1 -0
  334. package/dist/plugins/__tests__/capability-from-manifest.test.js +172 -0
  335. package/dist/plugins/__tests__/capability-from-manifest.test.js.map +1 -0
  336. package/dist/plugins/__tests__/capability-loader.test.d.ts +2 -0
  337. package/dist/plugins/__tests__/capability-loader.test.d.ts.map +1 -0
  338. package/dist/plugins/__tests__/capability-loader.test.js +122 -0
  339. package/dist/plugins/__tests__/capability-loader.test.js.map +1 -0
  340. package/dist/plugins/__tests__/capability-registry.test.d.ts +2 -0
  341. package/dist/plugins/__tests__/capability-registry.test.d.ts.map +1 -0
  342. package/dist/plugins/__tests__/capability-registry.test.js +185 -0
  343. package/dist/plugins/__tests__/capability-registry.test.js.map +1 -0
  344. package/dist/plugins/__tests__/discover.test.d.ts +2 -0
  345. package/dist/plugins/__tests__/discover.test.d.ts.map +1 -0
  346. package/dist/plugins/__tests__/discover.test.js +311 -0
  347. package/dist/plugins/__tests__/discover.test.js.map +1 -0
  348. package/dist/plugins/__tests__/loader.test.d.ts +2 -0
  349. package/dist/plugins/__tests__/loader.test.d.ts.map +1 -0
  350. package/dist/plugins/__tests__/loader.test.js +191 -0
  351. package/dist/plugins/__tests__/loader.test.js.map +1 -0
  352. package/dist/plugins/__tests__/manifest-discovery.test.d.ts +2 -0
  353. package/dist/plugins/__tests__/manifest-discovery.test.d.ts.map +1 -0
  354. package/dist/plugins/__tests__/manifest-discovery.test.js +132 -0
  355. package/dist/plugins/__tests__/manifest-discovery.test.js.map +1 -0
  356. package/dist/plugins/__tests__/manifest-loader.test.d.ts +2 -0
  357. package/dist/plugins/__tests__/manifest-loader.test.d.ts.map +1 -0
  358. package/dist/plugins/__tests__/manifest-loader.test.js +434 -0
  359. package/dist/plugins/__tests__/manifest-loader.test.js.map +1 -0
  360. package/dist/plugins/__tests__/marker-discovery.test.d.ts +2 -0
  361. package/dist/plugins/__tests__/marker-discovery.test.d.ts.map +1 -0
  362. package/dist/plugins/__tests__/marker-discovery.test.js +164 -0
  363. package/dist/plugins/__tests__/marker-discovery.test.js.map +1 -0
  364. package/dist/plugins/__tests__/node-modules-walk.test.d.ts +2 -0
  365. package/dist/plugins/__tests__/node-modules-walk.test.d.ts.map +1 -0
  366. package/dist/plugins/__tests__/node-modules-walk.test.js +76 -0
  367. package/dist/plugins/__tests__/node-modules-walk.test.js.map +1 -0
  368. package/dist/plugins/__tests__/package-entry.test.d.ts +9 -0
  369. package/dist/plugins/__tests__/package-entry.test.d.ts.map +1 -0
  370. package/dist/plugins/__tests__/package-entry.test.js +117 -0
  371. package/dist/plugins/__tests__/package-entry.test.js.map +1 -0
  372. package/dist/plugins/__tests__/recipe-loader.test.d.ts +2 -0
  373. package/dist/plugins/__tests__/recipe-loader.test.d.ts.map +1 -0
  374. package/dist/plugins/__tests__/recipe-loader.test.js +130 -0
  375. package/dist/plugins/__tests__/recipe-loader.test.js.map +1 -0
  376. package/dist/plugins/__tests__/scope-validation.test.d.ts +2 -0
  377. package/dist/plugins/__tests__/scope-validation.test.d.ts.map +1 -0
  378. package/dist/plugins/__tests__/scope-validation.test.js +68 -0
  379. package/dist/plugins/__tests__/scope-validation.test.js.map +1 -0
  380. package/dist/plugins/__tests__/single-core-guard.test.d.ts +10 -0
  381. package/dist/plugins/__tests__/single-core-guard.test.d.ts.map +1 -0
  382. package/dist/plugins/__tests__/single-core-guard.test.js +89 -0
  383. package/dist/plugins/__tests__/single-core-guard.test.js.map +1 -0
  384. package/dist/plugins/__tests__/tool-package-discovery.test.d.ts +2 -0
  385. package/dist/plugins/__tests__/tool-package-discovery.test.d.ts.map +1 -0
  386. package/dist/plugins/__tests__/tool-package-discovery.test.js +215 -0
  387. package/dist/plugins/__tests__/tool-package-discovery.test.js.map +1 -0
  388. package/dist/plugins/authored-tool-discovery.d.ts +45 -0
  389. package/dist/plugins/authored-tool-discovery.d.ts.map +1 -0
  390. package/dist/plugins/authored-tool-discovery.js +61 -0
  391. package/dist/plugins/authored-tool-discovery.js.map +1 -0
  392. package/dist/plugins/capability-discovery.d.ts +80 -0
  393. package/dist/plugins/capability-discovery.d.ts.map +1 -0
  394. package/dist/plugins/capability-discovery.js +278 -0
  395. package/dist/plugins/capability-discovery.js.map +1 -0
  396. package/dist/plugins/capability-loader.d.ts +50 -0
  397. package/dist/plugins/capability-loader.d.ts.map +1 -0
  398. package/dist/plugins/capability-loader.js +85 -0
  399. package/dist/plugins/capability-loader.js.map +1 -0
  400. package/dist/plugins/capability-registry.d.ts +169 -0
  401. package/dist/plugins/capability-registry.d.ts.map +1 -0
  402. package/dist/plugins/capability-registry.js +319 -0
  403. package/dist/plugins/capability-registry.js.map +1 -0
  404. package/dist/plugins/discover.d.ts +64 -0
  405. package/dist/plugins/discover.d.ts.map +1 -0
  406. package/dist/plugins/discover.js +303 -0
  407. package/dist/plugins/discover.js.map +1 -0
  408. package/dist/plugins/index.d.ts +37 -0
  409. package/dist/plugins/index.d.ts.map +1 -0
  410. package/dist/plugins/index.js +40 -0
  411. package/dist/plugins/index.js.map +1 -0
  412. package/dist/plugins/json-guards.d.ts +11 -0
  413. package/dist/plugins/json-guards.d.ts.map +1 -0
  414. package/dist/plugins/json-guards.js +15 -0
  415. package/dist/plugins/json-guards.js.map +1 -0
  416. package/dist/plugins/loader.d.ts +67 -0
  417. package/dist/plugins/loader.d.ts.map +1 -0
  418. package/dist/plugins/loader.js +137 -0
  419. package/dist/plugins/loader.js.map +1 -0
  420. package/dist/plugins/manifest-discovery.d.ts +28 -0
  421. package/dist/plugins/manifest-discovery.d.ts.map +1 -0
  422. package/dist/plugins/manifest-discovery.js +103 -0
  423. package/dist/plugins/manifest-discovery.js.map +1 -0
  424. package/dist/plugins/manifest-loader.d.ts +120 -0
  425. package/dist/plugins/manifest-loader.d.ts.map +1 -0
  426. package/dist/plugins/manifest-loader.js +410 -0
  427. package/dist/plugins/manifest-loader.js.map +1 -0
  428. package/dist/plugins/marker-discovery.d.ts +115 -0
  429. package/dist/plugins/marker-discovery.d.ts.map +1 -0
  430. package/dist/plugins/marker-discovery.js +172 -0
  431. package/dist/plugins/marker-discovery.js.map +1 -0
  432. package/dist/plugins/node-modules-walk.d.ts +61 -0
  433. package/dist/plugins/node-modules-walk.d.ts.map +1 -0
  434. package/dist/plugins/node-modules-walk.js +99 -0
  435. package/dist/plugins/node-modules-walk.js.map +1 -0
  436. package/dist/plugins/package-entry.d.ts +38 -0
  437. package/dist/plugins/package-entry.d.ts.map +1 -0
  438. package/dist/plugins/package-entry.js +86 -0
  439. package/dist/plugins/package-entry.js.map +1 -0
  440. package/dist/plugins/recipe-loader.d.ts +63 -0
  441. package/dist/plugins/recipe-loader.d.ts.map +1 -0
  442. package/dist/plugins/recipe-loader.js +67 -0
  443. package/dist/plugins/recipe-loader.js.map +1 -0
  444. package/dist/plugins/scope-validation.d.ts +35 -0
  445. package/dist/plugins/scope-validation.d.ts.map +1 -0
  446. package/dist/plugins/scope-validation.js +55 -0
  447. package/dist/plugins/scope-validation.js.map +1 -0
  448. package/dist/plugins/single-core-guard.d.ts +28 -0
  449. package/dist/plugins/single-core-guard.d.ts.map +1 -0
  450. package/dist/plugins/single-core-guard.js +69 -0
  451. package/dist/plugins/single-core-guard.js.map +1 -0
  452. package/dist/plugins/tool-package-discovery.d.ts +93 -0
  453. package/dist/plugins/tool-package-discovery.d.ts.map +1 -0
  454. package/dist/plugins/tool-package-discovery.js +118 -0
  455. package/dist/plugins/tool-package-discovery.js.map +1 -0
  456. package/dist/plugins/types.d.ts +78 -0
  457. package/dist/plugins/types.d.ts.map +1 -0
  458. package/dist/plugins/types.js +15 -0
  459. package/dist/plugins/types.js.map +1 -0
  460. package/dist/recipes/__tests__/registry.test.d.ts +2 -0
  461. package/dist/recipes/__tests__/registry.test.d.ts.map +1 -0
  462. package/dist/recipes/__tests__/registry.test.js +170 -0
  463. package/dist/recipes/__tests__/registry.test.js.map +1 -0
  464. package/dist/recipes/__tests__/selector.test.d.ts +20 -0
  465. package/dist/recipes/__tests__/selector.test.d.ts.map +1 -0
  466. package/dist/recipes/__tests__/selector.test.js +173 -0
  467. package/dist/recipes/__tests__/selector.test.js.map +1 -0
  468. package/dist/recipes/__tests__/unit-config.test.d.ts +7 -0
  469. package/dist/recipes/__tests__/unit-config.test.d.ts.map +1 -0
  470. package/dist/recipes/__tests__/unit-config.test.js +52 -0
  471. package/dist/recipes/__tests__/unit-config.test.js.map +1 -0
  472. package/dist/recipes/registry.d.ts +105 -0
  473. package/dist/recipes/registry.d.ts.map +1 -0
  474. package/dist/recipes/registry.js +141 -0
  475. package/dist/recipes/registry.js.map +1 -0
  476. package/dist/recipes/selector.d.ts +112 -0
  477. package/dist/recipes/selector.d.ts.map +1 -0
  478. package/dist/recipes/selector.js +134 -0
  479. package/dist/recipes/selector.js.map +1 -0
  480. package/dist/recipes/unit-config.d.ts +63 -0
  481. package/dist/recipes/unit-config.d.ts.map +1 -0
  482. package/dist/recipes/unit-config.js +68 -0
  483. package/dist/recipes/unit-config.js.map +1 -0
  484. package/dist/runtime/__tests__/in-process-transport.test.d.ts +6 -0
  485. package/dist/runtime/__tests__/in-process-transport.test.d.ts.map +1 -0
  486. package/dist/runtime/__tests__/in-process-transport.test.js +73 -0
  487. package/dist/runtime/__tests__/in-process-transport.test.js.map +1 -0
  488. package/dist/runtime/__tests__/subprocess-transport.test.d.ts +11 -0
  489. package/dist/runtime/__tests__/subprocess-transport.test.d.ts.map +1 -0
  490. package/dist/runtime/__tests__/subprocess-transport.test.js +118 -0
  491. package/dist/runtime/__tests__/subprocess-transport.test.js.map +1 -0
  492. package/dist/runtime/in-process-transport.d.ts +20 -0
  493. package/dist/runtime/in-process-transport.d.ts.map +1 -0
  494. package/dist/runtime/in-process-transport.js +49 -0
  495. package/dist/runtime/in-process-transport.js.map +1 -0
  496. package/dist/runtime/progress-transport.d.ts +73 -0
  497. package/dist/runtime/progress-transport.d.ts.map +1 -0
  498. package/dist/runtime/progress-transport.js +17 -0
  499. package/dist/runtime/progress-transport.js.map +1 -0
  500. package/dist/runtime/subprocess-transport.d.ts +43 -0
  501. package/dist/runtime/subprocess-transport.d.ts.map +1 -0
  502. package/dist/runtime/subprocess-transport.js +134 -0
  503. package/dist/runtime/subprocess-transport.js.map +1 -0
  504. package/dist/signals/comment-openers.d.ts +29 -0
  505. package/dist/signals/comment-openers.d.ts.map +1 -0
  506. package/dist/signals/comment-openers.js +41 -0
  507. package/dist/signals/comment-openers.js.map +1 -0
  508. package/dist/signals/comment-openers.test.d.ts +7 -0
  509. package/dist/signals/comment-openers.test.d.ts.map +1 -0
  510. package/dist/signals/comment-openers.test.js +41 -0
  511. package/dist/signals/comment-openers.test.js.map +1 -0
  512. package/dist/signals/create-signal-from-violation.d.ts +29 -0
  513. package/dist/signals/create-signal-from-violation.d.ts.map +1 -0
  514. package/dist/signals/create-signal-from-violation.js +29 -0
  515. package/dist/signals/create-signal-from-violation.js.map +1 -0
  516. package/dist/signals/signal-sink.d.ts +49 -0
  517. package/dist/signals/signal-sink.d.ts.map +1 -0
  518. package/dist/signals/signal-sink.js +6 -0
  519. package/dist/signals/signal-sink.js.map +1 -0
  520. package/dist/signals/suppress.d.ts +102 -0
  521. package/dist/signals/suppress.d.ts.map +1 -0
  522. package/dist/signals/suppress.js +325 -0
  523. package/dist/signals/suppress.js.map +1 -0
  524. package/dist/signals/suppress.test.d.ts +2 -0
  525. package/dist/signals/suppress.test.d.ts.map +1 -0
  526. package/dist/signals/suppress.test.js +213 -0
  527. package/dist/signals/suppress.test.js.map +1 -0
  528. package/dist/tools/__tests__/command-spec.test.d.ts +2 -0
  529. package/dist/tools/__tests__/command-spec.test.d.ts.map +1 -0
  530. package/dist/tools/__tests__/command-spec.test.js +191 -0
  531. package/dist/tools/__tests__/command-spec.test.js.map +1 -0
  532. package/dist/tools/__tests__/compatibility.test.d.ts +5 -0
  533. package/dist/tools/__tests__/compatibility.test.d.ts.map +1 -0
  534. package/dist/tools/__tests__/compatibility.test.js +41 -0
  535. package/dist/tools/__tests__/compatibility.test.js.map +1 -0
  536. package/dist/tools/__tests__/ids.test.d.ts +5 -0
  537. package/dist/tools/__tests__/ids.test.d.ts.map +1 -0
  538. package/dist/tools/__tests__/ids.test.js +56 -0
  539. package/dist/tools/__tests__/ids.test.js.map +1 -0
  540. package/dist/tools/__tests__/manifest-assert.test.d.ts +5 -0
  541. package/dist/tools/__tests__/manifest-assert.test.d.ts.map +1 -0
  542. package/dist/tools/__tests__/manifest-assert.test.js +66 -0
  543. package/dist/tools/__tests__/manifest-assert.test.js.map +1 -0
  544. package/dist/tools/__tests__/registry.test.d.ts +2 -0
  545. package/dist/tools/__tests__/registry.test.d.ts.map +1 -0
  546. package/dist/tools/__tests__/registry.test.js +93 -0
  547. package/dist/tools/__tests__/registry.test.js.map +1 -0
  548. package/dist/tools/__tests__/types.test.d.ts +2 -0
  549. package/dist/tools/__tests__/types.test.d.ts.map +1 -0
  550. package/dist/tools/__tests__/types.test.js +51 -0
  551. package/dist/tools/__tests__/types.test.js.map +1 -0
  552. package/dist/tools/capability.d.ts +257 -0
  553. package/dist/tools/capability.d.ts.map +1 -0
  554. package/dist/tools/capability.js +46 -0
  555. package/dist/tools/capability.js.map +1 -0
  556. package/dist/tools/command-spec.d.ts +211 -0
  557. package/dist/tools/command-spec.d.ts.map +1 -0
  558. package/dist/tools/command-spec.js +110 -0
  559. package/dist/tools/command-spec.js.map +1 -0
  560. package/dist/tools/compatibility.d.ts +45 -0
  561. package/dist/tools/compatibility.d.ts.map +1 -0
  562. package/dist/tools/compatibility.js +49 -0
  563. package/dist/tools/compatibility.js.map +1 -0
  564. package/dist/tools/ids.d.ts +61 -0
  565. package/dist/tools/ids.d.ts.map +1 -0
  566. package/dist/tools/ids.js +61 -0
  567. package/dist/tools/ids.js.map +1 -0
  568. package/dist/tools/index.d.ts +22 -0
  569. package/dist/tools/index.d.ts.map +1 -0
  570. package/dist/tools/index.js +28 -0
  571. package/dist/tools/index.js.map +1 -0
  572. package/dist/tools/manifest-assert.d.ts +35 -0
  573. package/dist/tools/manifest-assert.d.ts.map +1 -0
  574. package/dist/tools/manifest-assert.js +67 -0
  575. package/dist/tools/manifest-assert.js.map +1 -0
  576. package/dist/tools/manifest.d.ts +178 -0
  577. package/dist/tools/manifest.d.ts.map +1 -0
  578. package/dist/tools/manifest.js +35 -0
  579. package/dist/tools/manifest.js.map +1 -0
  580. package/dist/tools/registry.d.ts +37 -0
  581. package/dist/tools/registry.d.ts.map +1 -0
  582. package/dist/tools/registry.js +49 -0
  583. package/dist/tools/registry.js.map +1 -0
  584. package/dist/tools/types.d.ts +1021 -0
  585. package/dist/tools/types.d.ts.map +1 -0
  586. package/dist/tools/types.js +77 -0
  587. package/dist/tools/types.js.map +1 -0
  588. package/dist/types/__tests__/signal.test.d.ts +2 -0
  589. package/dist/types/__tests__/signal.test.d.ts.map +1 -0
  590. package/dist/types/__tests__/signal.test.js +111 -0
  591. package/dist/types/__tests__/signal.test.js.map +1 -0
  592. package/dist/types/index.d.ts +5 -0
  593. package/dist/types/index.d.ts.map +1 -0
  594. package/dist/types/index.js +3 -0
  595. package/dist/types/index.js.map +1 -0
  596. package/dist/types/signal-batch.d.ts +56 -0
  597. package/dist/types/signal-batch.d.ts.map +1 -0
  598. package/dist/types/signal-batch.js +54 -0
  599. package/dist/types/signal-batch.js.map +1 -0
  600. package/dist/types/signal.d.ts +77 -0
  601. package/dist/types/signal.d.ts.map +1 -0
  602. package/dist/types/signal.js +42 -0
  603. package/dist/types/signal.js.map +1 -0
  604. package/package.json +57 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-discovery.d.ts","sourceRoot":"","sources":["../../src/plugins/capability-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAcH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,WAAW,8BAA8B;IAC7C,wFAAwF;IACxF,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,kFAAkF;IAClF,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,2FAA2F;IAC3F,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,qFAAqF;AACrF,MAAM,WAAW,yBAAyB;IACxC,oFAAoF;IACpF,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,iFAAiF;IACjF,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,+FAA+F;AAC/F,MAAM,WAAW,6BAA6B;IAC5C,yEAAyE;IACzE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,2DAA2D;AAC3D,MAAM,WAAW,sCAAsC;IACrD,2DAA2D;IAC3D,QAAQ,CAAC,UAAU,EAAE,6BAA6B,CAAC;IACnD,uEAAuE;IACvE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,CAAC,EAAE,8BAA8B,CAAC;IACtD,kDAAkD;IAClD,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,6BAA6B,KAAK,IAAI,CAAC;CAC7E;AAgBD;;;;GAIG;AACH,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,sCAAsC,GAC9C,OAAO,CAAC,yBAAyB,EAAE,CAAC,CActC"}
@@ -0,0 +1,278 @@
1
+ /**
2
+ * @fileoverview The generic capability-contribution discovery substrate (§5.3).
3
+ *
4
+ * One walker that, given a capability domain's manifest-declared discovery
5
+ * descriptor + resolved preferences, finds every contributing package (by marker
6
+ * OR name-pattern), dynamic-imports each one, reads its declared export, and
7
+ * yields the raw contributions. It hoists the machinery previously split across
8
+ * three bespoke loaders — fitness's `check-loader.ts`, simulation's
9
+ * `scenario-package-discovery.ts`, and graph's `graph-adapter-discovery.ts`.
10
+ *
11
+ * Pure infra: it takes NO scope, touches NO registry, and imports NO tool. It
12
+ * yields `{ contribution, sourcePackage }` records that the host's capability
13
+ * registry routes to the owning tool's registrar (Phase 2). Per-package failures
14
+ * are isolated — a bad export or an import that throws skips that package with a
15
+ * structured diagnostic, never the whole run.
16
+ */
17
+ import { pathToFileURL } from 'node:url';
18
+ import { logger } from '../lib/logger.js';
19
+ import { discoverPackagesByDeclaredKind, } from './marker-discovery.js';
20
+ import { discoverScopedPackages, resolvePackageDir } from './node-modules-walk.js';
21
+ import { resolvePackageEntryPoint } from './package-entry.js';
22
+ import { filterSameCorePackages, selfCore } from './single-core-guard.js';
23
+ /**
24
+ * Max packages imported concurrently. Per-package loads are independent, so we
25
+ * fan them out — but in bounded batches, so a project with many capability packs
26
+ * can't spawn unbounded parallel dynamic imports (each import is real I/O +
27
+ * module-graph evaluation). Order is preserved across batches.
28
+ */
29
+ const LOAD_CONCURRENCY = 8;
30
+ /**
31
+ * Discover + load every contributing package for one capability domain and
32
+ * return the flat list of raw contributions. See the file header for the
33
+ * contract; per-package failures are isolated via `onDiagnostic`.
34
+ */
35
+ export async function discoverCapabilityContributions(options) {
36
+ const packages = selectPackages(options);
37
+ // Per-package loads are independent (each resolves + imports its own entry and
38
+ // reads one export; no shared mutable state), so fan them out — but in bounded
39
+ // batches of LOAD_CONCURRENCY, not unbounded. Promise.all preserves order within
40
+ // a batch and batches run in sequence, so the flattened result is deterministic.
41
+ const out = [];
42
+ for (let i = 0; i < packages.length; i += LOAD_CONCURRENCY) {
43
+ const batch = packages.slice(i, i + LOAD_CONCURRENCY);
44
+ // @fitness-ignore-next-line performance-anti-patterns -- bounded fan-out: each batch runs in parallel via Promise.all; running batches serially caps in-flight imports (the bounded-concurrency pattern), not a per-item serial loop.
45
+ const loaded = await Promise.all(batch.map((pkg) => loadPackageContributions(pkg, options)));
46
+ for (const contributions of loaded)
47
+ out.push(...contributions);
48
+ }
49
+ return out;
50
+ }
51
+ /**
52
+ * Resolve which packages to load, applying the preference rules:
53
+ * - explicit `preferences.packages` list resolved (built-ins from `cliDir`);
54
+ * - auto-discovery (by the descriptor's mode) runs UNLESS `autoDiscover: false`
55
+ * OR (an explicit list is present AND `explicitListMode` is `'replace'`);
56
+ * - `'augment'` mode unions explicit + auto-discovered, deduped.
57
+ * Finally, the single-core guard drops any pack resolving a foreign
58
+ * `@opensip-cli/core` (a split run scope → false positives).
59
+ */
60
+ function selectPackages(options) {
61
+ const { descriptor, preferences = {}, onDiagnostic } = options;
62
+ const explicitMode = descriptor.explicitListMode ?? 'replace';
63
+ const hasExplicit = preferences.packages !== undefined;
64
+ const explicit = hasExplicit ? resolveExplicit(preferences.packages ?? [], options) : [];
65
+ // 'replace' + an explicit list → skip auto-discovery; otherwise auto-discover
66
+ // (unless opted out). 'augment' always auto-discovers and adds the explicit list.
67
+ const includeAuto = preferences.autoDiscover !== false && !(hasExplicit && explicitMode === 'replace');
68
+ const auto = includeAuto ? autoDiscover(options) : [];
69
+ // Explicit config wins on a name collision (listed first).
70
+ const merged = dedupeSelected([...explicit, ...auto]);
71
+ return applySingleCoreGuard(merged, onDiagnostic);
72
+ }
73
+ /** Auto-discover packages by the descriptor's mode (marker | name-pattern). */
74
+ function autoDiscover(options) {
75
+ const { descriptor, projectDir, cliDir, preferences = {} } = options;
76
+ return descriptor.discovery.mode === 'marker'
77
+ ? autoDiscoverByMarker(descriptor, projectDir, cliDir)
78
+ : autoDiscoverByNamePattern(descriptor, projectDir, preferences.scopes);
79
+ }
80
+ /**
81
+ * Resolve an explicit package-name list to on-disk dirs. Built-in names (under
82
+ * `descriptor.builtinScope`) resolve from `cliDir`; the rest from `projectDir` —
83
+ * the same ownership split auto-discovery applies. Diagnose any not installed.
84
+ */
85
+ function resolveExplicit(names, options) {
86
+ const { descriptor, projectDir, cliDir, onDiagnostic } = options;
87
+ const scope = descriptor.builtinScope;
88
+ const out = [];
89
+ for (const name of names) {
90
+ const anchor = scope !== undefined && cliDir !== undefined && isUnderScope(name, scope)
91
+ ? cliDir
92
+ : projectDir;
93
+ const packageDir = resolvePackageDir(anchor, name);
94
+ if (packageDir) {
95
+ out.push({ name, packageDir });
96
+ }
97
+ else {
98
+ onDiagnostic?.({
99
+ evt: 'capability.discovery.package_not_resolved',
100
+ packageName: name,
101
+ message: `configured package "${name}" is not installed in node_modules — skipping`,
102
+ });
103
+ }
104
+ }
105
+ return out;
106
+ }
107
+ /**
108
+ * Marker mode. When the descriptor declares a `builtinScope`, packages split by
109
+ * ownership: built-ins (names under the scope) resolve from `cliDir`; everything
110
+ * else from `projectDir`, and a project-installed built-in is dropped as a shadow.
111
+ * Without a `builtinScope`, all markers resolve from `projectDir`.
112
+ */
113
+ function autoDiscoverByMarker(descriptor, projectDir, cliDir) {
114
+ if (descriptor.discovery.mode !== 'marker')
115
+ return [];
116
+ const { markerKind } = descriptor.discovery;
117
+ const scope = descriptor.builtinScope;
118
+ if (scope === undefined || cliDir === undefined) {
119
+ return dedupe(discoverPackagesByDeclaredKind(projectDir, markerKind));
120
+ }
121
+ const builtin = discoverPackagesByDeclaredKind(cliDir, markerKind).filter((p) => isUnderScope(p.name, scope));
122
+ const custom = discoverPackagesByDeclaredKind(projectDir, markerKind).filter((p) => !isUnderScope(p.name, scope));
123
+ return dedupe([...builtin, ...custom]);
124
+ }
125
+ /** name-pattern mode: scan the descriptor's (or override) scopes for `<scope>/<prefix>*`. */
126
+ function autoDiscoverByNamePattern(descriptor, projectDir, scopeOverride) {
127
+ if (descriptor.discovery.mode !== 'name-pattern')
128
+ return [];
129
+ const { prefix, defaultScopes } = descriptor.discovery;
130
+ const scopes = scopeOverride ?? defaultScopes;
131
+ return discoverScopedPackages({ projectDir, scopes, prefix }).map((p) => ({
132
+ name: p.name,
133
+ packageDir: p.packageDir,
134
+ }));
135
+ }
136
+ /** A package name is "under" a scope when it begins with `<scope>/`. */
137
+ function isUnderScope(name, scope) {
138
+ return name.startsWith(scope.endsWith('/') ? scope : `${scope}/`);
139
+ }
140
+ /** Dedupe discovered packages by name (first occurrence wins) and drop the kind tag. */
141
+ function dedupe(packages) {
142
+ const seen = new Set();
143
+ const out = [];
144
+ for (const p of packages) {
145
+ if (seen.has(p.name))
146
+ continue;
147
+ seen.add(p.name);
148
+ out.push({ name: p.name, packageDir: p.packageDir });
149
+ }
150
+ return out;
151
+ }
152
+ /** Dedupe selected packages by name (first occurrence wins). */
153
+ function dedupeSelected(packages) {
154
+ const seen = new Set();
155
+ const out = [];
156
+ for (const p of packages) {
157
+ if (seen.has(p.name))
158
+ continue;
159
+ seen.add(p.name);
160
+ out.push(p);
161
+ }
162
+ return out;
163
+ }
164
+ /**
165
+ * Single-core guard: drop any pack that resolves a DIFFERENT `@opensip-cli/core`
166
+ * than this runtime (a split run scope → false positives). Delegates to the shared
167
+ * {@link filterSameCorePackages}; wraps each drop in a discovery diagnostic.
168
+ * Generic: every domain's packs get the guard, not just fit's.
169
+ */
170
+ function applySingleCoreGuard(packages, onDiagnostic) {
171
+ return filterSameCorePackages(packages, (pkg, foreignCore) => {
172
+ onDiagnostic?.({
173
+ evt: 'capability.discovery.foreign_core',
174
+ packageName: pkg.name,
175
+ message: `package ${pkg.name} resolves a different @opensip-cli/core (${foreignCore}) than this ` +
176
+ `runtime (${selfCore() ?? '<unknown>'}) — skipping to avoid a split run scope`,
177
+ });
178
+ });
179
+ }
180
+ /**
181
+ * Resolve a package's entry, dynamic-import it, and read the declared export.
182
+ * `exportShape: 'array'` spreads the array; `'single'` yields the one value.
183
+ * Missing package metadata, a missing/wrong-shape export, or an import that
184
+ * throws all skip the package with a diagnostic — never propagate.
185
+ */
186
+ async function loadPackageContributions(pkg, options) {
187
+ const { descriptor, onDiagnostic } = options;
188
+ const resolved = resolvePackageEntryPoint(pkg.packageDir, pkg.name);
189
+ if (!resolved) {
190
+ onDiagnostic?.({
191
+ evt: 'capability.discovery.unreadable_package',
192
+ packageName: pkg.name,
193
+ message: `package ${pkg.name} has no readable package.json — skipping`,
194
+ });
195
+ return [];
196
+ }
197
+ try {
198
+ const mod = (await import(pathToFileURL(resolved.entry).href));
199
+ // Primary export (required — a missing/wrong-shape primary is diagnosed).
200
+ const out = readOneExport(mod, pkg.name, onDiagnostic, {
201
+ exportName: descriptor.exportName,
202
+ exportShape: descriptor.exportShape,
203
+ required: true,
204
+ });
205
+ // Co-contributions (§5.3): secondary exports routed to OTHER domains (e.g.
206
+ // `recipes` → fit-recipe). OPTIONAL — a package that exports no recipes is
207
+ // fine, so a missing co-export is silent (not diagnosed).
208
+ for (const co of descriptor.coContributions ?? []) {
209
+ out.push(...readOneExport(mod, pkg.name, onDiagnostic, {
210
+ exportName: co.exportName,
211
+ exportShape: co.exportShape,
212
+ targetDomainId: co.domainId,
213
+ required: false,
214
+ }));
215
+ }
216
+ return out;
217
+ }
218
+ catch (error) {
219
+ const msg = error instanceof Error ? error.message : String(error);
220
+ // Structured log of the substrate's own failure (the caller's onDiagnostic is
221
+ // a separate channel; this keeps the import failure observable in the logs even
222
+ // when no diagnostic sink is wired). Per-package isolation: skip, never throw.
223
+ logger.warn({
224
+ evt: 'capability.discovery.load_failed',
225
+ module: 'core:plugins',
226
+ name: pkg.name,
227
+ error: msg,
228
+ });
229
+ onDiagnostic?.({
230
+ evt: 'capability.discovery.load_failed',
231
+ packageName: pkg.name,
232
+ message: `failed to load package ${pkg.name}: ${msg}`,
233
+ });
234
+ return [];
235
+ }
236
+ }
237
+ /**
238
+ * Read one export (`mod[spec.exportName]`) per `spec.exportShape`, tagging each
239
+ * contribution with `spec.targetDomainId` (undefined = the primary domain).
240
+ * `spec.required` governs the missing-export behavior: a missing PRIMARY export
241
+ * is diagnosed + skipped; a missing co-contribution export is silent.
242
+ */
243
+ function readOneExport(mod, sourcePackage, onDiagnostic, spec) {
244
+ const { exportName, exportShape, targetDomainId, required } = spec;
245
+ const tag = targetDomainId === undefined ? {} : { targetDomainId };
246
+ const value = mod[exportName];
247
+ if (exportShape === 'array') {
248
+ if (value === undefined && !required)
249
+ return [];
250
+ if (!Array.isArray(value)) {
251
+ if (required) {
252
+ onDiagnostic?.({
253
+ evt: 'capability.discovery.bad_export',
254
+ packageName: sourcePackage,
255
+ message: `package ${sourcePackage} does not export a "${exportName}" array — skipping`,
256
+ });
257
+ }
258
+ return [];
259
+ }
260
+ return value.map((contribution) => ({
261
+ contribution,
262
+ sourcePackage,
263
+ ...tag,
264
+ }));
265
+ }
266
+ if (value === undefined) {
267
+ if (required) {
268
+ onDiagnostic?.({
269
+ evt: 'capability.discovery.bad_export',
270
+ packageName: sourcePackage,
271
+ message: `package ${sourcePackage} does not export "${exportName}" — skipping`,
272
+ });
273
+ }
274
+ return [];
275
+ }
276
+ return [{ contribution: value, sourcePackage, ...tag }];
277
+ }
278
+ //# sourceMappingURL=capability-discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-discovery.js","sourceRoot":"","sources":["../../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AAQ,KAA4B,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;YAC1D,YAAY;YACZ,aAAa;YACb,GAAG,GAAG;SACP,CAAC,CAAC,CAAC;IACN,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,IAAI,QAAQ,EAAE,CAAC;YACb,YAAY,EAAE,CAAC;gBACb,GAAG,EAAE,iCAAiC;gBACtC,WAAW,EAAE,aAAa;gBAC1B,OAAO,EAAE,WAAW,aAAa,qBAAqB,UAAU,cAAc;aAC/E,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @fileoverview The scope-owned capability loader (§5.3, Phase 2) — the live
3
+ * conduit that wakes `routeContribution`.
4
+ *
5
+ * `wireCapabilityRegistry` registers each manifest-declared domain and swaps in
6
+ * the owner's real registrar, but never FEEDS the registry. This loader closes
7
+ * the loop: for one domain it drives the generic discovery substrate
8
+ * ({@link discoverCapabilityContributions}) and routes every contribution through
9
+ * `registry.routeContribution(domainId, contribution)` → the owner's registrar →
10
+ * the per-`RunScope` registry. That is the same end state the three bespoke
11
+ * loaders reach (checks/scenarios/adapters), now through the one seam.
12
+ *
13
+ * Memoized per `(domainId, projectKey)` on the per-scope registry's load-state
14
+ * (see {@link CapabilityRegistry}), NOT on a module-level marker — so a second
15
+ * scope for the same project re-loads into its own fresh registry. This is the
16
+ * structural fix for the audit's F1.
17
+ *
18
+ * Pure of config: preferences are RESOLVED BY THE CALLER (Phase 3) and passed in,
19
+ * so this stays in `core` with no edge to the config/cli layer.
20
+ */
21
+ import { type CapabilityDiscoveryDiagnostic, type CapabilityDiscoveryPreferences } from './capability-discovery.js';
22
+ import type { CapabilityRegistry } from './capability-registry.js';
23
+ /** Options for {@link loadCapabilityDomain}. */
24
+ export interface LoadCapabilityDomainOptions {
25
+ /** The per-scope registry that declares the domain + routes contributions. */
26
+ readonly registry: CapabilityRegistry;
27
+ /** The domain to discovery-load (must already be registered in `registry`). */
28
+ readonly domainId: string;
29
+ /** Discovery anchor for consumer-owned packages (the project root); `''` when none. */
30
+ readonly projectDir?: string;
31
+ /** Discovery anchor for built-ins (those under the descriptor's `builtinScope`). */
32
+ readonly cliDir?: string;
33
+ /** Resolved discovery preferences for this domain (Phase 3 resolves these from config). */
34
+ readonly preferences?: CapabilityDiscoveryPreferences;
35
+ /** Optional sink for the substrate's per-package discovery diagnostics. */
36
+ readonly onDiagnostic?: (diagnostic: CapabilityDiscoveryDiagnostic) => void;
37
+ }
38
+ /**
39
+ * Discovery-load one capability domain through the live `routeContribution` path,
40
+ * memoized per `(domainId, projectKey)` on the scope-owned registry. Returns the
41
+ * routing errors recorded for the domain (empty when all contributions routed
42
+ * cleanly). Idempotent: a second call for the same domain + project is a no-op
43
+ * that returns the prior errors.
44
+ *
45
+ * A domain with no `discovery` descriptor auto-discovers nothing — it is marked
46
+ * loaded immediately with no contributions (its registrar is fed some other way,
47
+ * e.g. an explicit in-process registration).
48
+ */
49
+ export declare function loadCapabilityDomain(options: LoadCapabilityDomainOptions): Promise<readonly string[]>;
50
+ //# sourceMappingURL=capability-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-loader.d.ts","sourceRoot":"","sources":["../../src/plugins/capability-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACpC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,gDAAgD;AAChD,MAAM,WAAW,2BAA2B;IAC1C,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,uFAAuF;IACvF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,2FAA2F;IAC3F,QAAQ,CAAC,WAAW,CAAC,EAAE,8BAA8B,CAAC;IACtD,2EAA2E;IAC3E,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,6BAA6B,KAAK,IAAI,CAAC;CAC7E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CA4C5B"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @fileoverview The scope-owned capability loader (§5.3, Phase 2) — the live
3
+ * conduit that wakes `routeContribution`.
4
+ *
5
+ * `wireCapabilityRegistry` registers each manifest-declared domain and swaps in
6
+ * the owner's real registrar, but never FEEDS the registry. This loader closes
7
+ * the loop: for one domain it drives the generic discovery substrate
8
+ * ({@link discoverCapabilityContributions}) and routes every contribution through
9
+ * `registry.routeContribution(domainId, contribution)` → the owner's registrar →
10
+ * the per-`RunScope` registry. That is the same end state the three bespoke
11
+ * loaders reach (checks/scenarios/adapters), now through the one seam.
12
+ *
13
+ * Memoized per `(domainId, projectKey)` on the per-scope registry's load-state
14
+ * (see {@link CapabilityRegistry}), NOT on a module-level marker — so a second
15
+ * scope for the same project re-loads into its own fresh registry. This is the
16
+ * structural fix for the audit's F1.
17
+ *
18
+ * Pure of config: preferences are RESOLVED BY THE CALLER (Phase 3) and passed in,
19
+ * so this stays in `core` with no edge to the config/cli layer.
20
+ */
21
+ import { currentScope } from '../lib/run-scope.js';
22
+ import { discoverCapabilityContributions, } from './capability-discovery.js';
23
+ /**
24
+ * Discovery-load one capability domain through the live `routeContribution` path,
25
+ * memoized per `(domainId, projectKey)` on the scope-owned registry. Returns the
26
+ * routing errors recorded for the domain (empty when all contributions routed
27
+ * cleanly). Idempotent: a second call for the same domain + project is a no-op
28
+ * that returns the prior errors.
29
+ *
30
+ * A domain with no `discovery` descriptor auto-discovers nothing — it is marked
31
+ * loaded immediately with no contributions (its registrar is fed some other way,
32
+ * e.g. an explicit in-process registration).
33
+ */
34
+ export async function loadCapabilityDomain(options) {
35
+ const { registry, domainId, projectDir, cliDir, preferences, onDiagnostic } = options;
36
+ const projectKey = projectDir ?? '';
37
+ if (registry.isDomainLoaded(domainId, projectKey)) {
38
+ return registry.domainLoadErrors(domainId);
39
+ }
40
+ const descriptor = registry.getDomain(domainId)?.discovery;
41
+ if (descriptor === undefined) {
42
+ // No auto-discovery for this domain — mark loaded so we don't re-check.
43
+ registry.markDomainLoaded(domainId, projectKey, []);
44
+ return [];
45
+ }
46
+ const errors = [];
47
+ const contributions = await discoverCapabilityContributions({
48
+ descriptor,
49
+ projectDir: projectKey,
50
+ ...(cliDir === undefined ? {} : { cliDir }),
51
+ ...(preferences === undefined ? {} : { preferences }),
52
+ onDiagnostic: (diagnostic) => {
53
+ errors.push(diagnostic.message);
54
+ onDiagnostic?.(diagnostic);
55
+ },
56
+ });
57
+ let routed = 0;
58
+ for (const { contribution, sourcePackage, targetDomainId } of contributions) {
59
+ // A co-contribution (§5.3) routes to its OWN domain (e.g. recipes → fit-recipe);
60
+ // a primary contribution routes to the domain being loaded.
61
+ const target = targetDomainId ?? domainId;
62
+ try {
63
+ registry.routeContribution(target, contribution);
64
+ routed++;
65
+ }
66
+ catch (error) {
67
+ const msg = error instanceof Error ? error.message : String(error);
68
+ errors.push(`${sourcePackage} → ${target}: ${msg}`);
69
+ }
70
+ }
71
+ registry.markDomainLoaded(domainId, projectKey, errors);
72
+ emitLoadedEvent(domainId, routed, errors);
73
+ return errors;
74
+ }
75
+ /**
76
+ * Emit one unified `capability.<domainId>.loaded` lifecycle event on the
77
+ * scope-owned diagnostics bus (the single vocabulary that replaces the three
78
+ * per-domain event sets). No-op when there is no active scope (a programmatic
79
+ * call outside `runWithScope`).
80
+ */
81
+ function emitLoadedEvent(domainId, routed, errors) {
82
+ currentScope()?.diagnostics.event('load', errors.length > 0 ? 'warn' : 'info', `capability domain '${domainId}' loaded ${String(routed)} contribution(s)` +
83
+ (errors.length > 0 ? `, ${String(errors.length)} error(s)` : ''), { domainId, routed, errors: errors.length });
84
+ }
85
+ //# sourceMappingURL=capability-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-loader.js","sourceRoot":"","sources":["../../src/plugins/capability-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EACL,+BAA+B,GAGhC,MAAM,2BAA2B,CAAC;AAoBnC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAoC;IAEpC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACtF,MAAM,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;IAEpC,IAAI,QAAQ,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;QAClD,OAAO,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC3D,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,wEAAwE;QACxE,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;QACpD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,aAAa,GAAG,MAAM,+BAA+B,CAAC;QAC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AAyB;IAClF,YAAY,EAAE,EAAE,WAAW,CAAC,KAAK,CAC/B,MAAM,EACN,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EACnC,sBAAsB,QAAQ,YAAY,MAAM,CAAC,MAAM,CAAC,kBAAkB;QACxE,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAClE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAC5C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * @fileoverview Scope-owned capability registry (launch, §5.3).
3
+ *
4
+ * The host-side runtime for the capability model in `tools/capability.ts`.
5
+ * A tool declares the domains it OWNS in its static manifest; the host
6
+ * registers each declared domain here alongside the owner-supplied
7
+ * REGISTRAR, then routes incoming contributions to the owning registrar
8
+ * after a Zod-free schema check. The host never interprets a
9
+ * contribution — it only confirms "targets a declared domain + passes its
10
+ * schema" and hands off (north-star §4.5).
11
+ *
12
+ * **Per-`RunScope`, no module singleton.** Mirrors the simulation §5.11
13
+ * template (`createScenarioRegistry` / `currentScenarioRegistry`):
14
+ *
15
+ * - `createCapabilityRegistry()` — factory the CLI bootstrap calls once
16
+ * per invocation, attaching the result to `scope.capabilities`.
17
+ * - `currentCapabilityRegistry()` — reads the scope-bound registry off
18
+ * `currentScope()`; throws when called outside a `RunScope`.
19
+ *
20
+ * Unlike a tool subscope, the capability registry is a KERNEL concern (the
21
+ * host owns it, not any one tool), so its slot lives directly on
22
+ * `ToolScope` (`capabilities?`) rather than under a tool's name. A run that
23
+ * never constructs one carries `scope.capabilities === undefined` and reads
24
+ * return `undefined`.
25
+ *
26
+ * Errors are typed + structured (§ Steps 2.1.3): an unknown domain is a
27
+ * `NotFoundError` (`CAPABILITY.DOMAIN.UNKNOWN`); a schema mismatch is a
28
+ * `ValidationError` (`CAPABILITY.CONTRIBUTION.SCHEMA_MISMATCH`), both
29
+ * carrying a structured `diagnostic` for the CLI error boundary.
30
+ */
31
+ import { type Logger } from '../lib/logger.js';
32
+ import { type CapabilityDomainSpec, type CapabilityRegistrar } from '../tools/capability.js';
33
+ import type { ToolPluginManifest } from '../tools/manifest.js';
34
+ export type { CapabilityRegistrar } from '../tools/capability.js';
35
+ /**
36
+ * Per-`RunScope` capability registry. Holds the declared domains (by id)
37
+ * and routes contributions to their owners. Construct one per CLI
38
+ * invocation via {@link createCapabilityRegistry}; read the scope-bound
39
+ * instance via {@link currentCapabilityRegistry}.
40
+ */
41
+ export declare class CapabilityRegistry {
42
+ private readonly domains;
43
+ /**
44
+ * Per-domain discovery load-state, keyed by domain id. This is the per-scope
45
+ * memoization that the capability loader reads/writes so a domain's
46
+ * contributions are discovered + routed exactly once per project per scope.
47
+ * Because the registry is itself per-`RunScope`, this state is per-scope too —
48
+ * a second run for the same project re-loads into its own fresh registry.
49
+ * This is the structural fix for the audit's F1 (sim's module-level
50
+ * `scenariosLoadedFor`): the marker lives on a scope-owned object, not a module.
51
+ */
52
+ private readonly loadState;
53
+ private readonly logger;
54
+ constructor(logger?: Logger);
55
+ /** True when domain `domainId` has been discovery-loaded for `projectKey` in this scope. */
56
+ isDomainLoaded(domainId: string, projectKey: string): boolean;
57
+ /** Record that `domainId` finished discovery-loading for `projectKey`, with any routing errors. */
58
+ markDomainLoaded(domainId: string, projectKey: string, errors: readonly string[]): void;
59
+ /** Routing errors recorded during the most recent load of `domainId` (empty if none / never loaded). */
60
+ domainLoadErrors(domainId: string): readonly string[];
61
+ /**
62
+ * Register a capability domain + its owner's registrar. First-writer-wins
63
+ * on duplicate domain id: a second registration of the same id is a no-op
64
+ * (logged at debug) — mirrors the discovery walker's nearest-ancestor
65
+ * dedup, so re-running discovery is idempotent.
66
+ *
67
+ * @param spec The domain description (id, owner, epoch, schema, kind).
68
+ * @param registrar The owner callback invoked for a validated contribution.
69
+ */
70
+ registerDomain(spec: CapabilityDomainSpec, registrar: CapabilityRegistrar): void;
71
+ /**
72
+ * Replace the registrar for an ALREADY-REGISTERED domain (Phase 4). The
73
+ * manifest-read path ({@link registerCapabilityDomainsFromManifest})
74
+ * registers each declared domain with a DEFERRED placeholder registrar that
75
+ * throws on any contribution; once the owning tool's runtime module loads,
76
+ * the host calls this to swap in the tool's REAL registrar.
77
+ *
78
+ * This is the deliberate complement to {@link registerDomain}'s
79
+ * first-writer-wins: a domain's REGISTRAR is owner-replaceable (the owner
80
+ * supplies it late), but its SPEC is not — the spec stays exactly as the
81
+ * manifest declared it, so identity/epoch/schema cannot be overwritten by a
82
+ * late registrar wiring. Only the owning tool should call this (the host
83
+ * routes by `ownerToolId`); the spec is left untouched.
84
+ *
85
+ * @param domainId The domain whose registrar to replace.
86
+ * @param registrar The owner's real registrar.
87
+ * @throws {NotFoundError} (`CAPABILITY.DOMAIN.UNKNOWN`) when no domain
88
+ * `domainId` is registered — a registrar cannot be wired for a domain the
89
+ * host never declared (a manifest/tool-id mismatch).
90
+ */
91
+ setRegistrar(domainId: string, registrar: CapabilityRegistrar): void;
92
+ /** Whether a domain with `domainId` is registered. */
93
+ hasDomain(domainId: string): boolean;
94
+ /** Look up a registered domain's spec, or `undefined`. */
95
+ getDomain(domainId: string): CapabilityDomainSpec | undefined;
96
+ /** All registered domain specs (registration order). */
97
+ listDomains(): readonly CapabilityDomainSpec[];
98
+ /**
99
+ * Route a contribution to the owner of `domainId`. The host (a) confirms
100
+ * the domain is declared, (b) validates `contribution` against the
101
+ * domain's `contributionSchema`, then (c) hands it to the owner's
102
+ * registrar. The host never interprets the contribution beyond the
103
+ * schema check — the domain owner does.
104
+ *
105
+ * @throws {NotFoundError} (`CAPABILITY.DOMAIN.UNKNOWN`) when no domain
106
+ * `domainId` is registered.
107
+ * @throws {ValidationError} (`CAPABILITY.CONTRIBUTION.SCHEMA_MISMATCH`)
108
+ * when the contribution fails the domain's schema check.
109
+ */
110
+ routeContribution(domainId: string, contribution: unknown): void;
111
+ }
112
+ /**
113
+ * Augment the kernel scope with the capability registry slot. Unlike a
114
+ * tool subscope (which a tool augments from ITS package), the capability
115
+ * registry is a kernel concern, so core declares the slot itself here —
116
+ * keeping the leaf `scope-types.ts` free of any edge back to this module
117
+ * (which imports `run-scope.ts`). Optional + mutable: only the CLI
118
+ * bootstrap (or a test) attaches it; a run without it reads `undefined`.
119
+ */
120
+ declare module '../lib/scope-types.js' {
121
+ interface ScopeContribution {
122
+ /**
123
+ * The host's per-run capability registry. Seeded by the CLI bootstrap
124
+ * (Phase 4) and read via {@link currentCapabilityRegistry}. Absent on
125
+ * a scope that never constructed one — consumers MUST null-check (the
126
+ * reader throws a descriptive error in that case).
127
+ */
128
+ capabilities?: CapabilityRegistry;
129
+ }
130
+ }
131
+ /** Construct a fresh capability registry for a single `RunScope`. */
132
+ export declare function createCapabilityRegistry(logger?: Logger): CapabilityRegistry;
133
+ /**
134
+ * Read the current scope's capability registry. Throws when no scope is
135
+ * active or when the scope has no capability registry — both indicate the
136
+ * caller is running outside the CLI's pre-action-hook (or a test fixture
137
+ * forgot to construct + attach one).
138
+ *
139
+ * @throws {Error} When called outside `runWithScope(...)`, or when the
140
+ * active scope carries no `capabilities` registry.
141
+ */
142
+ export declare function currentCapabilityRegistry(): CapabilityRegistry;
143
+ /**
144
+ * Register every capability domain a manifest declares into the per-run
145
+ * {@link CapabilityRegistry}, stamping `ownerToolId = manifest.stableId ??
146
+ * manifest.id` on each (§5.3 / Task 2.2; ADR-0048 — the owner key must equal the
147
+ * owning tool's `metadata.id`, which is the stable UUID for modern tools). This
148
+ * is how `MARKER_KINDS` becomes a BOOTSTRAP DEFAULT:
149
+ * the marker enum still seeds the discovery vocabulary, and a
150
+ * manifest-declared domain EXTENDS that set — registered here without any
151
+ * host-enum edit. Additive: a manifest with no `capabilities` registers
152
+ * nothing.
153
+ *
154
+ * The owner-supplied registrar is NOT known at manifest-read time (the
155
+ * tool's runtime module hasn't been imported), so this registers the
156
+ * domain with a deferred-registrar placeholder that THROWS if a
157
+ * contribution is routed before the owning tool wires its real registrar
158
+ * (Phase 4). The host knows the domain EXISTS and who owns it; the owner
159
+ * supplies the actual registrar when its module loads.
160
+ *
161
+ * Emits one structured `capability.domain.from_manifest` evt per domain so
162
+ * a manifest-sourced domain is observable in structured logs (Task 2.2.3).
163
+ *
164
+ * @param manifest The validated manifest carrying the declarations.
165
+ * @param registry The per-run capability registry to populate.
166
+ * @returns The {@link CapabilityDomainSpec}s registered (owner-stamped).
167
+ */
168
+ export declare function registerCapabilityDomainsFromManifest(manifest: ToolPluginManifest, registry: CapabilityRegistry): readonly CapabilityDomainSpec[];
169
+ //# sourceMappingURL=capability-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-registry.d.ts","sourceRoot":"","sources":["../../src/plugins/capability-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAOH,OAAO,EAA2B,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAExE,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAK/D,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAQlE;;;;;GAKG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuE;IACjG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,MAAM,GAAE,MAAsB;IAI1C,4FAA4F;IAC5F,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO;IAI7D,mGAAmG;IACnG,gBAAgB,CAAC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