@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,410 @@
1
+ // @fitness-ignore-file file-length-limit -- one cohesive manifest pipeline: the static reader (loadToolManifest), the single admission gate (admitTool), and their private validate/normalize/hash/diagnose helpers form one read→validate→admit subsystem over the raw-vs-admitted compatibility contract. The helpers are admission-internal (not reused elsewhere); hoisting them out would scatter one contract across files. Grew past the 400-line soft limit with the per-field normalization helpers.
2
+ /**
3
+ * @fileoverview Static manifest reader + the single admission gate
4
+ * (launch, raw-vs-admitted compatibility contract).
5
+ *
6
+ * `loadToolManifest` reads a tool's static front matter **before**
7
+ * importing its runtime `Tool` module:
8
+ *
9
+ * - **bundled** / **installed** — `package.json#opensipTools` in the tool's
10
+ * own package dir (one read for both; the discovery walker already
11
+ * touches these package.json files).
12
+ * - **project-local** / **user-global** — a JSON sidecar
13
+ * (`opensip-tool.manifest.json`) in the tool's directory, since an
14
+ * authored tool is authored content, not an installed npm package with a
15
+ * package.json marker. Both authored sources read the SAME sidecar; only
16
+ * their trust posture differs (deny-by-default vs trusted-by-default),
17
+ * which is the admission caller's concern, not the loader's.
18
+ *
19
+ * It validates the raw identity subset (`kind: 'tool'`, `id`, `commands`),
20
+ * derives `name`/`version` from the package.json's own top-level fields
21
+ * (the manifest block does NOT redeclare them — single source of truth),
22
+ * validates concrete additive descriptors such as `capabilities`, and returns
23
+ * `undefined` (with a structured logger diagnostic) on a malformed or missing
24
+ * manifest. A missing `apiVersion` is still representable as a
25
+ * `RawToolPluginManifest` so `admitTool` can reject it with a compatibility
26
+ * diagnostic. It NEVER imports the tool module.
27
+ *
28
+ * `admitTool` is the single gate the bundled and external paths share: it
29
+ * records `ToolProvenance` (incl. a `manifestHash` over the canonical
30
+ * manifest JSON) and runs `checkCompatibility(manifest.apiVersion)`:
31
+ * - compatible → `admit`
32
+ * - incompatible + not requested → `skip` (with diagnostic)
33
+ * - incompatible + explicitly asked → `fail-closed` (with diagnostic)
34
+ * It emits exactly one structured logger evt per decision.
35
+ *
36
+ * Both functions are pure over real filesystem reads of package.json /
37
+ * the sidecar — no tool-module import, no module singletons. They stay in
38
+ * core (the kernel) and import nothing from contracts/cli/tools-runtime.
39
+ */
40
+ import { createHash } from 'node:crypto';
41
+ import { existsSync, readFileSync } from 'node:fs';
42
+ import { join } from 'node:path';
43
+ import { logger } from '../lib/logger.js';
44
+ import { checkCompatibility } from '../tools/compatibility.js';
45
+ import { PLUGIN_API_VERSION } from '../tools/manifest.js';
46
+ import { isRecord, isStringArray } from './json-guards.js';
47
+ import { normalizeDiscovery } from './manifest-discovery.js';
48
+ /**
49
+ * Filename of the project-local manifest sidecar. A project-local tool is
50
+ * authored content under `<project>/opensip-cli/…`, not an installed npm
51
+ * package, so it has no `package.json#opensipTools` marker — it declares
52
+ * its identity via this JSON sidecar (deliberately NOT an executable
53
+ * `.mjs`, so the host reads identity without running tool code).
54
+ */
55
+ export const PROJECT_LOCAL_MANIFEST_FILE = 'opensip-tool.manifest.json';
56
+ /** `module` field stamped on every structured log event from this file. */
57
+ const LOADER_MODULE = 'core:plugins';
58
+ /**
59
+ * Read + validate a tool's static `ToolPluginManifest` for the given
60
+ * source, WITHOUT importing the tool's runtime module.
61
+ *
62
+ * - `bundled` / `installed` — reads `<dir>/package.json`, taking identity
63
+ * from the `opensipTools` block and `name`/`version` from the
64
+ * package.json's own top-level fields.
65
+ * - `project-local` / `user-global` — reads
66
+ * `<dir>/opensip-tool.manifest.json` (the JSON sidecar), which carries the
67
+ * full identity inline. Both authored sources share the sidecar branch.
68
+ *
69
+ * @param source Where the tool came from — selects the manifest location.
70
+ * @param dir The tool's package/authoring directory.
71
+ * @returns The validated manifest, or `undefined` (with a structured
72
+ * `plugin.manifest.read_failed` diagnostic) when the file is missing,
73
+ * unparseable, or fails identity validation.
74
+ */
75
+ export function loadToolManifest(source, dir) {
76
+ // Both authored sources (project-local + user-global) declare identity via
77
+ // the JSON sidecar; bundled/installed read package.json#opensipTools.
78
+ const authored = source === 'project-local' || source === 'user-global';
79
+ const raw = authored ? readSidecar(dir) : readPackageManifest(dir);
80
+ if (raw === undefined) {
81
+ diagnose(dir, source, 'manifest file missing or unreadable');
82
+ return undefined;
83
+ }
84
+ const manifest = validateManifest(raw.block, raw.name, raw.version);
85
+ if (manifest === undefined) {
86
+ diagnose(dir, source, raw.reason ?? 'manifest failed identity validation');
87
+ return undefined;
88
+ }
89
+ return manifest;
90
+ }
91
+ /**
92
+ * Run the single compatibility gate over a manifest and produce an
93
+ * {@link AdmissionResult}. Records `ToolProvenance` (source + identity +
94
+ * `manifestHash`) regardless of verdict, then maps the
95
+ * `checkCompatibility` outcome to a decision:
96
+ *
97
+ * - compatible → `admit`
98
+ * - incompatible + `!explicitlyRequested` → `skip`
99
+ * - incompatible + `explicitlyRequested` → `fail-closed`
100
+ *
101
+ * Emits exactly one structured logger evt per decision
102
+ * (`plugin.manifest.loaded` / `plugin.incompatible.skipped` /
103
+ * `plugin.incompatible.failed`). Never throws, never imports the tool.
104
+ *
105
+ * @param args.manifest The validated manifest (from {@link loadToolManifest}).
106
+ * @param args.source Where the tool came from.
107
+ * @param args.dir The tool's resolved directory (recorded as `resolvedPath`).
108
+ * @param args.packageName npm package name, when known (bundled/installed).
109
+ * @param args.explicitlyRequested Whether the user named this tool directly
110
+ * (e.g. via a plugin pin) — promotes an incompatible `skip` to `fail-closed`.
111
+ */
112
+ export function admitTool(args) {
113
+ const { manifest, source, dir, packageName, explicitlyRequested } = args;
114
+ const manifestHash = hashManifest(manifest);
115
+ const provenance = {
116
+ source,
117
+ id: manifest.id,
118
+ ...(manifest.stableId ? { stableId: manifest.stableId } : {}),
119
+ version: manifest.version,
120
+ ...(packageName === undefined ? {} : { packageName }),
121
+ resolvedPath: dir,
122
+ manifestHash,
123
+ };
124
+ const verdict = checkCompatibility(manifest.apiVersion);
125
+ if (verdict.kind === 'compatible') {
126
+ const admittedManifest = {
127
+ ...manifest,
128
+ // `verdict.kind === 'compatible'` ⇒ apiVersion equals the engine epoch (a
129
+ // defined number); the `?? PLUGIN_API_VERSION` fallback is never reached
130
+ // when compatible — it only narrows the type to `number` without a
131
+ // non-null assertion.
132
+ apiVersion: manifest.apiVersion ?? PLUGIN_API_VERSION,
133
+ };
134
+ logger.info({
135
+ evt: 'plugin.manifest.loaded',
136
+ module: LOADER_MODULE,
137
+ id: manifest.id,
138
+ source,
139
+ apiVersion: admittedManifest.apiVersion,
140
+ engine: undefined,
141
+ manifestHash,
142
+ decision: 'admit',
143
+ });
144
+ return { decision: 'admit', provenance, verdict, manifest: admittedManifest };
145
+ }
146
+ // incompatible
147
+ const diagnostic = verdict.reason;
148
+ if (explicitlyRequested) {
149
+ logger.error({
150
+ evt: 'plugin.incompatible.failed',
151
+ module: LOADER_MODULE,
152
+ id: manifest.id,
153
+ source,
154
+ apiVersion: verdict.declared,
155
+ engine: verdict.engine,
156
+ manifestHash,
157
+ decision: 'fail-closed',
158
+ diagnostic,
159
+ });
160
+ return { decision: 'fail-closed', provenance, verdict, diagnostic };
161
+ }
162
+ logger.warn({
163
+ evt: 'plugin.incompatible.skipped',
164
+ module: LOADER_MODULE,
165
+ id: manifest.id,
166
+ source,
167
+ apiVersion: verdict.declared,
168
+ engine: verdict.engine,
169
+ manifestHash,
170
+ decision: 'skip',
171
+ diagnostic,
172
+ });
173
+ return { decision: 'skip', provenance, verdict, diagnostic };
174
+ }
175
+ /**
176
+ * Read `<dir>/package.json` and extract the `opensipTools` block plus the
177
+ * top-level `name`/`version`. Returns `undefined` when the file is missing
178
+ * or unparseable, or when there is no object-shaped `opensipTools` block.
179
+ */
180
+ function readPackageManifest(dir) {
181
+ const json = readJson(join(dir, 'package.json'));
182
+ if (json === undefined)
183
+ return undefined;
184
+ const block = json.opensipTools;
185
+ if (!isRecord(block))
186
+ return undefined;
187
+ return { block, name: json.name, version: json.version };
188
+ }
189
+ /**
190
+ * Read the project-local JSON sidecar. The sidecar IS the manifest block
191
+ * and carries `name`/`version` inline (there is no package.json alongside
192
+ * an authored project-local tool).
193
+ */
194
+ function readSidecar(dir) {
195
+ const json = readJson(join(dir, PROJECT_LOCAL_MANIFEST_FILE));
196
+ if (json === undefined)
197
+ return undefined;
198
+ return { block: json, name: json.name, version: json.version };
199
+ }
200
+ /**
201
+ * Validate the identity subset of a manifest block and assemble a typed
202
+ * `RawToolPluginManifest`. `name`/`version` come from the package.json's own
203
+ * fields (bundled/installed) or inline (sidecar). Returns `undefined` (with
204
+ * a `reason` is reported by the caller) on any identity violation.
205
+ */
206
+ /** Narrow an unknown value to a non-empty string (the manifest identity-field guard). */
207
+ function isNonEmptyString(value) {
208
+ return typeof value === 'string' && value !== '';
209
+ }
210
+ /** Narrow to an optional non-empty string: absent, or a non-empty string. */
211
+ function isAbsentOrNonEmptyString(value) {
212
+ return value === undefined || isNonEmptyString(value);
213
+ }
214
+ /**
215
+ * Validate the optional `capabilities` slot. Returns `undefined` when absent
216
+ * (additive — no declared domains), the normalized array when valid, or the
217
+ * `'invalid'` sentinel when present-but-malformed (the caller then rejects the
218
+ * whole manifest). Keeps the absent/invalid distinction out of the main
219
+ * validator's control flow.
220
+ */
221
+ function validateOptionalCapabilities(raw) {
222
+ if (raw === undefined)
223
+ return undefined;
224
+ return normalizeCapabilities(raw) ?? 'invalid';
225
+ }
226
+ function validateManifest(block, name, version) {
227
+ if (block.kind !== 'tool')
228
+ return undefined;
229
+ if (!isNonEmptyString(block.id))
230
+ return undefined;
231
+ if (!isNonEmptyString(name))
232
+ return undefined;
233
+ if (!isNonEmptyString(version))
234
+ return undefined;
235
+ const commands = normalizeCommands(block.commands);
236
+ if (commands === undefined)
237
+ return undefined;
238
+ const apiVersion = block.apiVersion;
239
+ if (apiVersion !== undefined && typeof apiVersion !== 'number')
240
+ return undefined;
241
+ // ADR-0048: the tool's stable machine identity (UUID). Additive + optional —
242
+ // present-but-non-string fails validation, mirroring the `id` guard above.
243
+ // MUST be carried onto the manifest: the drift guard (assertManifestMatchesTool)
244
+ // matches it against the runtime `metadata.id`, and capability-domain ownership
245
+ // (registerCapabilityDomainsFromManifest) stamps `ownerToolId = stableId ?? id`.
246
+ // Dropping it here silently breaks graph-adapter discovery (owner never matches
247
+ // the tool's UUID `metadata.id`).
248
+ if (!isAbsentOrNonEmptyString(block.stableId))
249
+ return undefined;
250
+ const stableId = block.stableId;
251
+ // §5.3 (launch): the `capabilities` slot. Absent ⇒ no declared domains;
252
+ // present-but-malformed ⇒ the whole manifest is invalid (the `'invalid'`
253
+ // sentinel), mirroring the strict `commands` parse above.
254
+ const capabilities = validateOptionalCapabilities(block.capabilities);
255
+ if (capabilities === 'invalid')
256
+ return undefined;
257
+ // Reserved for future community/catalog (see ToolPluginManifestBase).
258
+ // We explicitly copy them through as `unknown` (additive) so they survive
259
+ // load → admit without loss. This is the lightweight consumer hygiene
260
+ // (roadmap item 3) — authors get structural round-tripping now; future
261
+ // releases can add non-fatal warnings or concrete schemas without
262
+ // breaking GA-era manifests. The admission gate already treats extra
263
+ // fields permissively; this just makes the intent explicit.
264
+ const compatibility = block.compatibility;
265
+ const distribution = block.distribution;
266
+ const extensionMetadata = block.extensionMetadata;
267
+ return {
268
+ kind: 'tool',
269
+ id: block.id,
270
+ ...(stableId === undefined ? {} : { stableId }),
271
+ name,
272
+ version,
273
+ ...(apiVersion === undefined ? {} : { apiVersion }),
274
+ commands,
275
+ ...(capabilities === undefined ? {} : { capabilities }),
276
+ ...(compatibility === undefined ? {} : { compatibility }),
277
+ ...(distribution === undefined ? {} : { distribution }),
278
+ ...(extensionMetadata === undefined ? {} : { extensionMetadata }),
279
+ };
280
+ }
281
+ /** Closed set of valid `contributionKind` values for a capability declaration. */
282
+ const CONTRIBUTION_KINDS = [
283
+ 'module-export',
284
+ 'manifest-entry',
285
+ 'file',
286
+ ];
287
+ /**
288
+ * Validate + normalize a PRESENT `capabilities` array to
289
+ * `ToolCapabilityDeclaration[]`. Each entry needs a non-empty string `id`,
290
+ * a numeric `apiVersion`, and a `contributionKind` in the closed set;
291
+ * `contributionSchema` is `unknown` (the kernel carries no Zod) and is
292
+ * passed through verbatim. Returns the declarations on success, or
293
+ * `undefined` when the slot is malformed (the caller fails the manifest,
294
+ * mirroring `normalizeCommands`). The absent case is handled by the caller.
295
+ */
296
+ function normalizeCapabilities(value) {
297
+ if (!Array.isArray(value))
298
+ return undefined;
299
+ const out = [];
300
+ for (const entry of value) {
301
+ if (!isRecord(entry))
302
+ return undefined;
303
+ if (typeof entry.id !== 'string' || entry.id === '')
304
+ return undefined;
305
+ if (typeof entry.apiVersion !== 'number')
306
+ return undefined;
307
+ const kind = entry.contributionKind;
308
+ if (!isContributionKind(kind))
309
+ return undefined;
310
+ // `discovery` is optional, but a PRESENT-but-malformed descriptor fails the
311
+ // manifest (mirroring the strict `contributionKind` check above).
312
+ const discovery = normalizeDiscovery(entry.discovery);
313
+ if (discovery.status === 'invalid')
314
+ return undefined;
315
+ out.push({
316
+ id: entry.id,
317
+ apiVersion: entry.apiVersion,
318
+ // `contributionSchema` is unknown by contract — pass through as-is
319
+ // (may legitimately be absent for a domain that validates inside its
320
+ // own registrar).
321
+ contributionSchema: entry.contributionSchema,
322
+ contributionKind: kind,
323
+ ...(discovery.status === 'ok' ? { discovery: discovery.descriptor } : {}),
324
+ });
325
+ }
326
+ return out;
327
+ }
328
+ /** Type guard for the closed `CapabilityContributionKind` union. */
329
+ function isContributionKind(value) {
330
+ return typeof value === 'string' && CONTRIBUTION_KINDS.includes(value);
331
+ }
332
+ /**
333
+ * Validate + normalize the `commands` array to `ToolCommandManifest[]`.
334
+ * Each entry must carry a string `name` + `description`; optional
335
+ * `aliases` must be a string array. Returns `undefined` on any violation.
336
+ */
337
+ function normalizeCommands(value) {
338
+ if (!Array.isArray(value))
339
+ return undefined;
340
+ const out = [];
341
+ for (const entry of value) {
342
+ if (!isRecord(entry))
343
+ return undefined;
344
+ if (typeof entry.name !== 'string' || entry.name === '')
345
+ return undefined;
346
+ if (typeof entry.description !== 'string')
347
+ return undefined;
348
+ const { aliases } = entry;
349
+ if (aliases !== undefined && !isStringArray(aliases))
350
+ return undefined;
351
+ out.push({
352
+ name: entry.name,
353
+ description: entry.description,
354
+ ...(aliases === undefined ? {} : { aliases }),
355
+ });
356
+ }
357
+ return out;
358
+ }
359
+ function hashManifest(manifest) {
360
+ const canonical = JSON.stringify({
361
+ kind: manifest.kind,
362
+ id: manifest.id,
363
+ name: manifest.name,
364
+ version: manifest.version,
365
+ apiVersion: manifest.apiVersion ?? null,
366
+ commands: manifest.commands.map((c) => ({
367
+ name: c.name,
368
+ description: c.description,
369
+ aliases: c.aliases ?? null,
370
+ })),
371
+ });
372
+ return createHash('sha256').update(canonical, 'utf8').digest('hex');
373
+ }
374
+ /**
375
+ * Read + JSON-parse a file, returning the parsed object or `undefined`
376
+ * when the file is missing, unreadable, unparseable, or not an object.
377
+ * Mirrors the JSON-read pattern in `marker-discovery.ts` (best-effort,
378
+ * never throws) so the discovery surfaces share one read style.
379
+ */
380
+ function readJson(path) {
381
+ if (!existsSync(path))
382
+ return undefined;
383
+ try {
384
+ const parsed = JSON.parse(readFileSync(path, 'utf8'));
385
+ return isRecord(parsed) ? parsed : undefined;
386
+ }
387
+ catch (error) {
388
+ // Best-effort read (mirrors marker-discovery.ts): a malformed/unreadable
389
+ // manifest file is a skip, not a crash — but we surface WHY at debug so a
390
+ // genuinely broken file is diagnosable rather than silently invisible.
391
+ logger.debug({
392
+ evt: 'plugin.manifest.read_failed',
393
+ module: LOADER_MODULE,
394
+ path,
395
+ error: error instanceof Error ? error.message : String(error),
396
+ });
397
+ return undefined;
398
+ }
399
+ }
400
+ /** Emit the structured read-failure diagnostic (debug — a missing/malformed manifest is a skip, not a crash). */
401
+ function diagnose(dir, source, reason) {
402
+ logger.debug({
403
+ evt: 'plugin.manifest.read_failed',
404
+ module: LOADER_MODULE,
405
+ dir,
406
+ source,
407
+ reason,
408
+ });
409
+ }
410
+ //# sourceMappingURL=manifest-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-loader.js","sourceRoot":"","sources":["../../src/plugins/manifest-loader.ts"],"names":[],"mappings":"AAAA,8eAA8e;AAC9e;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAA6B,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAW7D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,4BAA4B,CAAC;AAExE,2EAA2E;AAC3E,MAAM,aAAa,GAAG,cAAc,CAAC;AAErC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAkB,EAClB,GAAW;IAEX,2EAA2E;IAC3E,sEAAsE;IACtE,MAAM,QAAQ,GAAG,MAAM,KAAK,eAAe,IAAI,MAAM,KAAK,aAAa,CAAC;IACxE,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACnE,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,qCAAqC,C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S,QAAQ,CAAC,IAAY;IAC5B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAC/D,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,yEAAyE;QACzE,0EAA0E;QAC1E,uEAAuE;QACvE,MAAM,CAAC,KAAK,CAAC;YACX,GAAG,EAAE,6BAA6B;YAClC,MAAM,EAAE,aAAa;YACrB,IAAI;YACJ,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,iHAAiH;AACjH,SAAS,QAAQ,CAAC,GAAW,EAAE,MAAkB,EAAE,MAAc;IAC/D,MAAM,CAAC,KAAK,CAAC;QACX,GAAG,EAAE,6BAA6B;QAClC,MAAM,EAAE,aAAa;QACrB,GAAG;QACH,MAAM;QACN,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * @fileoverview Generic marker-based plugin discovery.
3
+ *
4
+ * Walks ancestor `node_modules/` directories from a project root, looking
5
+ * for packages whose `package.json` declares an `opensipTools.kind` value
6
+ * matching the requested kind. Returns the deduplicated list (first
7
+ * occurrence walking outward wins, matching Node's nearest-ancestor
8
+ * module resolution).
9
+ *
10
+ * `MarkerKind` is the closed union of HOST marker kinds — just `'tool'` now
11
+ * (whole-subcommand Tool plugins, a host concern). The former DOMAIN markers
12
+ * (`'fit-pack'`, `'sim-pack'`, `'graph-adapter'`) were RETIRED from this union
13
+ * once discovery became descriptor-driven (§5.3): a tool's manifest declares its
14
+ * own marker kind, the generic substrate discovers it via the string-typed
15
+ * {@link discoverPackagesByDeclaredKind}, and nothing in the host compiles in the
16
+ * domain vocabulary. Use {@link readDeclaredKind} for any kind that is not the
17
+ * host `'tool'` marker.
18
+ *
19
+ * Why a marker rather than a name pattern (for `'tool'`): a name-prefix rule
20
+ * breaks down once organisations publish their own scoped tool packages. The
21
+ * marker decouples publication scope from plugin shape.
22
+ */
23
+ /**
24
+ * The closed vocabulary of HOST `opensipTools.kind` markers — `'tool'` only.
25
+ * Domain markers (fit-pack/sim-pack/graph-adapter) are NOT here anymore: they are
26
+ * declared per-tool in manifests and discovered via {@link discoverPackagesByDeclaredKind}
27
+ * (§5.3). The workspace-invariant test validates a package.json marker against
28
+ * `'tool'` PLUS the marker kinds the bundled manifests declare — descriptor-driven,
29
+ * not a compiled-in domain list.
30
+ */
31
+ export declare const MARKER_KINDS: readonly ["tool"];
32
+ /** The closed union of HOST `opensipTools.kind` marker values — currently just `'tool'`. */
33
+ export type MarkerKind = (typeof MARKER_KINDS)[number];
34
+ /** Inputs for {@link discoverPackagesByMarker}: the project root to walk from and the marker kind to discover. */
35
+ export interface MarkerDiscoveryOptions {
36
+ /** Absolute path to the project root. */
37
+ readonly projectDir: string;
38
+ /** Which marker kind to discover. */
39
+ readonly kind: MarkerKind;
40
+ }
41
+ /** A package discovered by its closed-union marker kind, with name, on-disk directory, and the echoed kind. */
42
+ export interface DiscoveredMarkerPackage {
43
+ /** npm package name, e.g. '@opensip-cli/fitness' or '@my-co/fit'. */
44
+ readonly name: string;
45
+ /** Absolute path to the package's directory inside node_modules. */
46
+ readonly packageDir: string;
47
+ /** Echoed back so callers consuming multiple kinds can multiplex. */
48
+ readonly kind: MarkerKind;
49
+ }
50
+ /**
51
+ * Narrow an unknown string to MarkerKind. Used by readMarkerKind below
52
+ * and re-exported for callers that need to validate dynamic input.
53
+ */
54
+ export declare function isMarkerKind(value: unknown): value is MarkerKind;
55
+ /**
56
+ * Walk up from `projectDir` looking for `node_modules/` directories.
57
+ * For each one, scan top-level entries (and one level into scoped
58
+ * directories like `@opensip-cli/`) for packages declaring
59
+ * `opensipTools.kind === options.kind`. Return the deduplicated list.
60
+ *
61
+ * Same-named packages are returned once — the first occurrence walking
62
+ * from `projectDir` outward wins, matching Node's nearest-ancestor
63
+ * resolution behavior.
64
+ */
65
+ export declare function discoverPackagesByMarker(options: MarkerDiscoveryOptions): DiscoveredMarkerPackage[];
66
+ /**
67
+ * Scan EXACTLY ONE `node_modules` directory for packages declaring
68
+ * `opensipTools.kind === kind` — no ancestor walk. Used for fixed plugin
69
+ * host dirs (`~/.opensip-cli/plugins/tool/node_modules`,
70
+ * `<project>/.runtime/plugins/tool/node_modules`) where walking up would
71
+ * wrongly pull in `$HOME/node_modules` or unrelated ancestor trees.
72
+ */
73
+ export declare function discoverPackagesInNodeModules(nodeModulesDir: string, kind: MarkerKind): DiscoveredMarkerPackage[];
74
+ /**
75
+ * A package discovered by its declared `opensipTools.kind`, with the kind as a
76
+ * raw string (NOT narrowed to the closed `MarkerKind` union). This is the shape
77
+ * the generic capability-discovery substrate consumes — a domain's marker kind
78
+ * comes from its manifest descriptor, so it cannot be a compile-time union member.
79
+ */
80
+ export interface DiscoveredDeclaredPackage {
81
+ readonly name: string;
82
+ readonly packageDir: string;
83
+ readonly kind: string;
84
+ }
85
+ /**
86
+ * Walk ancestor `node_modules/` directories from `projectDir`, returning every
87
+ * package whose `package.json` declares `opensipTools.kind === kind` for the
88
+ * given raw-string kind. The string-typed generalization of
89
+ * {@link discoverPackagesByMarker}: the closed-union version is a thin wrapper
90
+ * over this. Deduplicated; first occurrence walking outward wins.
91
+ */
92
+ export declare function discoverPackagesByDeclaredKind(projectDir: string, kind: string): DiscoveredDeclaredPackage[];
93
+ /**
94
+ * Read the declared `opensipTools.kind` from a package's package.json.
95
+ * Returns the kind if it parses, is a string, and matches the closed
96
+ * MarkerKind union; otherwise undefined. Parse failures are logged at
97
+ * debug — a malformed package.json under node_modules is not a discovery
98
+ * concern, just an entry to skip.
99
+ *
100
+ * Exported as the canonical host-tool marker reader. Domain markers such as
101
+ * fit-pack and graph-adapter are descriptor-driven and use the string-typed
102
+ * `readDeclaredKind` / `discoverPackagesByDeclaredKind` path.
103
+ */
104
+ export declare function readMarkerKind(packageDir: string): MarkerKind | undefined;
105
+ /**
106
+ * Read the RAW `opensipTools.kind` string from a package's package.json — the
107
+ * string-typed sibling of {@link readMarkerKind}, with no closed-union narrowing.
108
+ * Returns the string if it parses and is a string; otherwise undefined. Parse
109
+ * failures are logged at debug (a malformed node_modules package.json is an
110
+ * entry to skip, not a discovery error). The generic discovery substrate reads
111
+ * declared kinds through this one function so there is no second implementation
112
+ * to drift.
113
+ */
114
+ export declare function readDeclaredKind(packageDir: string): string | undefined;
115
+ //# sourceMappingURL=marker-discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marker-discovery.d.ts","sourceRoot":"","sources":["../../src/plugins/marker-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AASH;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,mBAAoB,CAAC;AAE9C,4FAA4F;AAC5F,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,kHAAkH;AAClH,MAAM,WAAW,sBAAsB;IACrC,yCAAyC;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B;AAED,+GAA+G;AAC/G,MAAM,WAAW,uBAAuB;IACtC,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B;AA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