@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,26 @@
1
+ /**
2
+ * Retry with exponential backoff for opensip-cli.
3
+ * Designed for network calls (e.g., --report-to SARIF POST).
4
+ */
5
+ export interface RetryOptions {
6
+ /** Maximum number of attempts (including the first). Default: 3 */
7
+ maxAttempts?: number;
8
+ /** Initial delay in ms before first retry. Default: 500 */
9
+ initialDelayMs?: number;
10
+ /** Maximum delay in ms. Default: 10000 */
11
+ maxDelayMs?: number;
12
+ /** Multiplier for exponential backoff. Default: 2 */
13
+ backoffMultiplier?: number;
14
+ /** Called before each retry with attempt number, error, and delay. */
15
+ onRetry?: (attempt: number, error: Error, delayMs: number) => void;
16
+ }
17
+ /**
18
+ * Execute an async function with exponential backoff retry.
19
+ * Throws the last error if all attempts fail.
20
+ *
21
+ * @throws {Error} The last error thrown by `fn` after exhausting
22
+ * `effectiveMaxAttempts` attempts. Non-Error throws are wrapped in
23
+ * an `Error` whose message is `String(value)`.
24
+ */
25
+ export declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
26
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/lib/retry.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sEAAsE;IACtE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpE;AAED;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CA2C/F"}
@@ -0,0 +1,48 @@
1
+ // @fitness-ignore-file performance-anti-patterns -- sequential await is the entire point of a retry/backoff loop; running attempts in parallel would defeat retry semantics
2
+ /**
3
+ * Retry with exponential backoff for opensip-cli.
4
+ * Designed for network calls (e.g., --report-to SARIF POST).
5
+ */
6
+ /**
7
+ * Execute an async function with exponential backoff retry.
8
+ * Throws the last error if all attempts fail.
9
+ *
10
+ * @throws {Error} The last error thrown by `fn` after exhausting
11
+ * `effectiveMaxAttempts` attempts. Non-Error throws are wrapped in
12
+ * an `Error` whose message is `String(value)`.
13
+ */
14
+ export async function withRetry(fn, options = {}) {
15
+ const { maxAttempts = 3, initialDelayMs = 500, maxDelayMs = 10_000, backoffMultiplier = 2, onRetry, } = options;
16
+ // Floor defensively against zero/negative/NaN/non-integer values. Math.max(1, NaN)
17
+ // returns NaN per spec, so an unguarded `Math.max(1, maxAttempts)` would let
18
+ // NaN reach the loop condition (attempt <= NaN is false) and throw
19
+ // `undefined` for `lastError!`. Compare against effectiveMaxAttempts everywhere
20
+ // so the original maxAttempts can never re-enter the comparison.
21
+ const effectiveMaxAttempts = Number.isFinite(maxAttempts)
22
+ ? Math.max(1, Math.floor(maxAttempts))
23
+ : 1;
24
+ let lastError;
25
+ for (let attempt = 1; attempt <= effectiveMaxAttempts; attempt++) {
26
+ try {
27
+ return await fn();
28
+ }
29
+ catch (error) {
30
+ lastError = error instanceof Error ? error : new Error(String(error));
31
+ if (attempt >= effectiveMaxAttempts)
32
+ break;
33
+ // Exponential backoff with jitter
34
+ const baseDelay = initialDelayMs * Math.pow(backoffMultiplier, attempt - 1);
35
+ const jitter = Math.random() * baseDelay * 0.5;
36
+ const delay = Math.min(baseDelay + jitter, maxDelayMs);
37
+ onRetry?.(attempt, lastError, delay);
38
+ await new Promise((resolve) => setTimeout(resolve, delay));
39
+ }
40
+ }
41
+ // `lastError` is always assigned before reaching here: the loop runs
42
+ // `effectiveMaxAttempts >= 1` times and assigns `lastError` on every catch
43
+ // path before the loop terminates. Guard explicitly for type-safety.
44
+ if (!lastError)
45
+ throw new Error('withRetry: unreachable — no attempts ran');
46
+ throw lastError;
47
+ }
48
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/lib/retry.ts"],"names":[],"mappings":"AAAA,4KAA4K;AAC5K;;;GAGG;AAeH;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,EAAoB,EAAE,UAAwB,EAAE;IACjF,MAAM,EACJ,WAAW,GAAG,CAAC,EACf,cAAc,GAAG,GAAG,EACpB,UAAU,GAAG,MAAM,EACnB,iBAAiB,GAAG,CAAC,EACrB,OAAO,GACR,GAAG,OAAO,CAAC;IAEZ,mFAAmF;IACnF,6EAA6E;IAC7E,mEAAmE;IACnE,gFAAgF;IAChF,iEAAiE;IACjE,MAAM,oBAAoB,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC;QACvD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC,CAAC;IACN,IAAI,SAA4B,CAAC;IAEjC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,oBAAoB,EAAE,OAAO,EAAE,EAAE,CAAC;QACjE,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,EAAE,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,SAAS,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAEtE,IAAI,OAAO,IAAI,oBAAoB;gBAAE,MAAM;YAE3C,kCAAkC;YAClC,MAAM,SAAS,GAAG,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;YAC5E,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,SAAS,GAAG,GAAG,CAAC;YAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,EAAE,UAAU,CAAC,CAAC;YAEvD,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAErC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,qEAAqE;IACrE,2EAA2E;IAC3E,qEAAqE;IACrE,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC5E,MAAM,SAAS,CAAC;AAClB,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * RunDiagnostics — the shared, JSON-emittable diagnostics shape carried on a
3
+ * {@link CommandOutcome} (north-star §5.10, launch).
4
+ *
5
+ * Today observability is per-subsystem: graph has OTEL spans, fitness has rich
6
+ * callbacks, sim has simple progress, and the bootstrap writes loose log lines.
7
+ * There is no common vocabulary a machine consumer can read. `RunDiagnostics` is
8
+ * that vocabulary: one structured event stream spanning the uniform tool
9
+ * lifecycle (discover → load → validate → execute → render → deliver → persist),
10
+ * a flat metrics-counter map, and a thin bridge to the existing OTEL trace
11
+ * context.
12
+ *
13
+ * The currency is deliberately **minimal-but-extensible** for launch (spec
14
+ * decision): one `DiagnosticEvent` per lifecycle boundary that already exists,
15
+ * not a metrics/timer rebuild. The `metrics`/`trace` slots are reserved so later
16
+ * releases can enrich them without another outer-shape break.
17
+ *
18
+ * Serialization-safe by construction: every field is a primitive, a readonly
19
+ * array of primitives/records, or a plain record — no functions, no class
20
+ * instances, no clock captured here. The producer (the scope-owned diagnostics
21
+ * bus, `@opensip-cli/core`) stamps `at` at the emit site; this layer stays
22
+ * pure (the formatter-purity contract that `SignalEnvelope` also honours).
23
+ */
24
+ /**
25
+ * The seven phases of the uniform tool lifecycle (north-star §5.6 / Figure 5),
26
+ * used to tag every {@link DiagnosticEvent}. A consumer can filter the stream by
27
+ * phase to answer "what happened during config load?" or "did delivery run?".
28
+ */
29
+ export type DiagnosticPhase = 'discover' | 'load' | 'validate' | 'execute' | 'render' | 'deliver' | 'persist';
30
+ /** Severity of a single diagnostic event. Independent of signal severity. */
31
+ export type DiagnosticLevel = 'debug' | 'info' | 'warn' | 'error';
32
+ /**
33
+ * One structured diagnostics event. `at` is an ISO-8601 timestamp supplied by
34
+ * the emitter (core stays `Date.now()`-free in its pure paths; the bus owns the
35
+ * clock). `data` is an optional bag of JSON-safe extras (e.g. which plugin
36
+ * loaded, how many checks matched) — never functions or class instances.
37
+ */
38
+ export interface DiagnosticEvent {
39
+ readonly phase: DiagnosticPhase;
40
+ readonly level: DiagnosticLevel;
41
+ readonly message: string;
42
+ readonly at: string;
43
+ readonly data?: Readonly<Record<string, unknown>>;
44
+ }
45
+ /**
46
+ * The diagnostics snapshot carried on every {@link CommandOutcome}.
47
+ *
48
+ * - `runId` correlates the snapshot with the invocation's logger/runId.
49
+ * - `events` is the ordered lifecycle stream.
50
+ * - `metrics` is a flat counter map (e.g. `{ 'plugins.loaded': 3 }`); reserved
51
+ * and populated emit-site-by-emit-site as counters are needed.
52
+ * - `trace` bridges to the existing OTEL span context when telemetry is on
53
+ * (`OTEL_EXPORTER_OTLP_ENDPOINT` set); absent otherwise.
54
+ */
55
+ export interface RunDiagnostics {
56
+ readonly runId: string;
57
+ readonly events: readonly DiagnosticEvent[];
58
+ readonly metrics?: Readonly<Record<string, number>>;
59
+ readonly trace?: {
60
+ readonly traceId?: string;
61
+ readonly spanId?: string;
62
+ };
63
+ }
64
+ //# sourceMappingURL=run-diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-diagnostics.d.ts","sourceRoot":"","sources":["../../src/lib/run-diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,MAAM,GACN,UAAU,GACV,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,CAAC;AAEd,6EAA6E;AAC7E,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAElE;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACnD;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAC5C,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE;QACf,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * RunDiagnostics — the shared, JSON-emittable diagnostics shape carried on a
3
+ * {@link CommandOutcome} (north-star §5.10, launch).
4
+ *
5
+ * Today observability is per-subsystem: graph has OTEL spans, fitness has rich
6
+ * callbacks, sim has simple progress, and the bootstrap writes loose log lines.
7
+ * There is no common vocabulary a machine consumer can read. `RunDiagnostics` is
8
+ * that vocabulary: one structured event stream spanning the uniform tool
9
+ * lifecycle (discover → load → validate → execute → render → deliver → persist),
10
+ * a flat metrics-counter map, and a thin bridge to the existing OTEL trace
11
+ * context.
12
+ *
13
+ * The currency is deliberately **minimal-but-extensible** for launch (spec
14
+ * decision): one `DiagnosticEvent` per lifecycle boundary that already exists,
15
+ * not a metrics/timer rebuild. The `metrics`/`trace` slots are reserved so later
16
+ * releases can enrich them without another outer-shape break.
17
+ *
18
+ * Serialization-safe by construction: every field is a primitive, a readonly
19
+ * array of primitives/records, or a plain record — no functions, no class
20
+ * instances, no clock captured here. The producer (the scope-owned diagnostics
21
+ * bus, `@opensip-cli/core`) stamps `at` at the emit site; this layer stays
22
+ * pure (the formatter-purity contract that `SignalEnvelope` also honours).
23
+ */
24
+ export {};
25
+ //# sourceMappingURL=run-diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-diagnostics.js","sourceRoot":"","sources":["../../src/lib/run-diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG"}
@@ -0,0 +1,167 @@
1
+ /**
2
+ * @fileoverview RunScope — per-invocation execution scope.
3
+ *
4
+ * Owns the lifecycle of every singleton the codebase previously hung on
5
+ * module-level state (logger, caches, registries, recipe-config slot,
6
+ * project context, datastore thunk). Constructed exactly once per CLI
7
+ * invocation; SaaS hosts construct one per concurrent run.
8
+ *
9
+ * Threading happens at the `ToolCliContext` boundary (Phase 5). Tools
10
+ * read `cli.scope.foo` instead of reaching into module globals.
11
+ *
12
+ * AsyncLocalStorage seam: `runWithScope(scope, fn)` binds `scope` as
13
+ * the current scope for the dynamic extent of `fn`. Library functions
14
+ * deep inside the call tree (e.g. fitness's `getCheckConfig(slug)`)
15
+ * read from `currentScope()` instead of `globalThis`. The two-copies-of-
16
+ * fitness hazard documented at the prior `Symbol.for(globalThis)` site
17
+ * is solved by ALS — both fitness copies share the same
18
+ * `AsyncLocalStorage` instance exported from `@opensip-cli/core`.
19
+ */
20
+ import { LanguageParseCache } from '../languages/parse-cache-class.js';
21
+ import { LanguageRegistry } from '../languages/registry.js';
22
+ import { ToolRegistry } from '../tools/registry.js';
23
+ import { DiagnosticsBus } from './diagnostics-bus.js';
24
+ import type { Logger } from './logger.js';
25
+ import type { ProjectContext } from './project-context.js';
26
+ import type { DataStoreThunk, RecipeUnitConfigSlot, ToolScope } from './scope-types.js';
27
+ import type { UiContext } from './ui-context.js';
28
+ import type { SignalSink } from '../signals/signal-sink.js';
29
+ import type { ToolPluginManifest, ToolProvenance } from '../tools/manifest.js';
30
+ /** Constructor input for {@link RunScope}: registries, services, and per-run identifiers. */
31
+ export interface RunScopeOptions {
32
+ readonly logger?: Logger;
33
+ readonly parseCache?: LanguageParseCache;
34
+ readonly projectContext?: ProjectContext;
35
+ readonly datastore?: DataStoreThunk;
36
+ readonly tools?: ToolRegistry;
37
+ readonly languages?: LanguageRegistry;
38
+ /**
39
+ * Per-invocation presentation settings (banner size, CLI version) read
40
+ * by the render paths. Optional: tests and non-rendering callers omit it,
41
+ * in which case `RunScope.ui` is `undefined` and render sites apply their
42
+ * own defaults (banner → `lg`, version → empty).
43
+ */
44
+ readonly ui?: UiContext;
45
+ /**
46
+ * Correlation id for the current CLI invocation. D7 designates this a
47
+ * KERNEL concern (every invocation has one) — it stays flat on the
48
+ * scope rather than under a tool subnamespace. The CLI bootstrap
49
+ * generates it via `generatePrefixedId('run')` and passes it here;
50
+ * the logger reads it back via `currentScope()?.runId` for
51
+ * event-stamping. Optional in `RunScopeOptions` (tests can construct
52
+ * a bare scope) but if omitted, `RunScope.runId` is the empty string
53
+ * — matching the prior logger-singleton reset value used in
54
+ * `configureLogger({ runId: '' })`. Production paths always supply
55
+ * a non-empty id via the pre-action-hook.
56
+ */
57
+ readonly runId?: string;
58
+ /**
59
+ * Cloud signal sink for this invocation (ADR-0008). Defaults to
60
+ * `noopSignalSink` — the CLI bootstrap sets the OpenSIP Cloud sink only
61
+ * when an API key resolves and entitlement is positive. No module-level
62
+ * state: selection is always explicit at the composition root.
63
+ */
64
+ readonly signalSink?: SignalSink;
65
+ /**
66
+ * The manifests of the tools admitted through the compatibility gate this
67
+ * run, in registration order. Recorded by the CLI bootstrap and stamped on
68
+ * the scope so host commands (`tools list`) read them via `currentScope()`
69
+ * instead of a module global. Defaults to `[]` (no tools admitted — e.g. an
70
+ * isolated test scope). HOST-only: tools never read these, so they live on
71
+ * `RunScope`, not the tool-facing `ToolScope`.
72
+ */
73
+ readonly toolManifests?: readonly ToolPluginManifest[];
74
+ /**
75
+ * The provenance records of the tools admitted this run (source, identity,
76
+ * manifest hash), paired index-wise with {@link toolManifests}. Recorded by
77
+ * the CLI bootstrap and stamped on the scope so host commands (`plugin list`,
78
+ * `tools list`, `tools uninstall`) read them via `currentScope()` rather than
79
+ * a module global. Defaults to `[]`.
80
+ */
81
+ readonly toolProvenance?: readonly ToolProvenance[];
82
+ }
83
+ /**
84
+ * Per-invocation execution scope.
85
+ *
86
+ * Construct exactly once per CLI invocation. Pass via
87
+ * `ToolCliContext.scope` (Phase 5). Tools read `cli.scope.foo`
88
+ * instead of reaching into module globals (the T1 invariant).
89
+ *
90
+ * Defaults: when no overrides are provided, the scope wires up the
91
+ * default `Logger`, a fresh `LanguageParseCache`, and FRESH empty
92
+ * `ToolRegistry` / `LanguageRegistry` instances. The CLI bootstrap
93
+ * constructs and populates one pair per run and passes them in via
94
+ * `RunScopeOptions` so language adapters and tool plugins land where
95
+ * `currentScope()?.languages` / `.tools` will find them. Tests that
96
+ * exercise registry-aware code paths must either construct a populated
97
+ * registry and pass it in, or register fixtures into `scope.languages`
98
+ * inside the test body's `runWithScope` block.
99
+ */
100
+ export declare class RunScope {
101
+ readonly logger: Logger;
102
+ readonly parseCache: LanguageParseCache;
103
+ readonly recipeUnitConfig: RecipeUnitConfigSlot;
104
+ readonly projectContext: ProjectContext | undefined;
105
+ readonly datastore: DataStoreThunk;
106
+ readonly tools: ToolRegistry;
107
+ readonly languages: LanguageRegistry;
108
+ /** Per-invocation presentation settings; `undefined` outside the CLI render path. */
109
+ readonly ui: UiContext | undefined;
110
+ /**
111
+ * Correlation id for the current invocation. Read by the logger via
112
+ * `currentScope()?.runId` for event-stamping. Empty string when no
113
+ * caller supplied one (matches the prior singleton reset semantics —
114
+ * the logger's `formatEntry` only emits a `runId` field when truthy).
115
+ */
116
+ readonly runId: string;
117
+ /** Cloud signal sink for this invocation; `noopSignalSink` unless cloud sync is on. */
118
+ readonly signalSink: SignalSink;
119
+ /**
120
+ * Per-invocation diagnostics collector (north-star §5.10, launch).
121
+ * Library code emits lifecycle events via `currentScope()?.diagnostics`; the
122
+ * host assembler snapshots it onto every `CommandOutcome`. Scope-owned so
123
+ * concurrent runs share no diagnostics state (the no-module-singleton rule).
124
+ */
125
+ readonly diagnostics: DiagnosticsBus;
126
+ /**
127
+ * Manifests of the tools admitted this run (registration order). Empty unless
128
+ * the CLI bootstrap recorded them. Read by host commands via `currentScope()`.
129
+ */
130
+ readonly toolManifests: readonly ToolPluginManifest[];
131
+ /**
132
+ * Provenance of the tools admitted this run, paired index-wise with
133
+ * {@link toolManifests}. Empty unless the CLI bootstrap recorded them.
134
+ */
135
+ readonly toolProvenance: readonly ToolProvenance[];
136
+ constructor(opts?: RunScopeOptions);
137
+ /** Release per-run resources (caches, recipe-config slot). */
138
+ dispose(): void;
139
+ }
140
+ /**
141
+ * Declaration-merge: `RunScope` IS-A `ToolScope` (the Tool-facing view)
142
+ * plus the `tools` registry it adds. Extending `ToolScope` here also
143
+ * brings in the augmentable `ScopeContribution` slots, so
144
+ * `currentScope()?.simulation` / `?.graph` stay readable on a RunScope.
145
+ * Tools augment `ScopeContribution` (not `RunScope`) from their own
146
+ * packages; the slots flow in through `ToolScope extends ScopeContribution`.
147
+ */
148
+ export interface RunScope extends ToolScope {
149
+ }
150
+ /** Run `fn` with `scope` bound as the current scope for everything in its dynamic extent. */
151
+ export declare function runWithScope<T>(scope: RunScope, fn: () => Promise<T>): Promise<T>;
152
+ /** Synchronous variant of `runWithScope`. */
153
+ export declare function runWithScopeSync<T>(scope: RunScope, fn: () => T): T;
154
+ /**
155
+ * Set `scope` as the current scope for the rest of the calling async
156
+ * context — without needing a callback wrapper. Backed by
157
+ * `AsyncLocalStorage.enterWith`. Use this in Commander's `preAction`
158
+ * hook where the action body runs after the hook returns but in the
159
+ * same async chain: `enterWith` propagates the scope forward without
160
+ * needing to wrap the action invocation, which Commander does not let
161
+ * us do directly. Throws on misuse: an existing scope must NOT be
162
+ * replaced silently (call `runWithScope` for nested scopes).
163
+ */
164
+ export declare function enterScope(scope: RunScope): void;
165
+ /** Read the current scope. Returns undefined when called outside a runWithScope. */
166
+ export declare function currentScope(): RunScope | undefined;
167
+ //# sourceMappingURL=run-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-scope.d.ts","sourceRoot":"","sources":["../../src/lib/run-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA4B/E,6FAA6F;AAC7F,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;IACzC,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IACtC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC;IACxB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACvD;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;GAgBG;AAEH,qBAAa,QAAQ;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,oBAAoB,CAAC;IAChD,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,CAAC;IACpD,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,qFAAqF;IACrF,QAAQ,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uFAAuF;IACvF,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACtD;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,SAAS,cAAc,EAAE,CAAC;gBAEvC,IAAI,GAAE,eAAoB;IAiBtC,8DAA8D;IAC9D,OAAO,IAAI,IAAI;CAOhB;AAED;;;;;;;GAOG;AAEH,MAAM,WAAW,QAAS,SAAQ,SAAS;CAAG;AAgB9C,6FAA6F;AAC7F,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEjF;AAED,6CAA6C;AAC7C,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAEhD;AAED,oFAAoF;AACpF,wBAAgB,YAAY,IAAI,QAAQ,GAAG,SAAS,CAEnD"}
@@ -0,0 +1,176 @@
1
+ /**
2
+ * @fileoverview RunScope — per-invocation execution scope.
3
+ *
4
+ * Owns the lifecycle of every singleton the codebase previously hung on
5
+ * module-level state (logger, caches, registries, recipe-config slot,
6
+ * project context, datastore thunk). Constructed exactly once per CLI
7
+ * invocation; SaaS hosts construct one per concurrent run.
8
+ *
9
+ * Threading happens at the `ToolCliContext` boundary (Phase 5). Tools
10
+ * read `cli.scope.foo` instead of reaching into module globals.
11
+ *
12
+ * AsyncLocalStorage seam: `runWithScope(scope, fn)` binds `scope` as
13
+ * the current scope for the dynamic extent of `fn`. Library functions
14
+ * deep inside the call tree (e.g. fitness's `getCheckConfig(slug)`)
15
+ * read from `currentScope()` instead of `globalThis`. The two-copies-of-
16
+ * fitness hazard documented at the prior `Symbol.for(globalThis)` site
17
+ * is solved by ALS — both fitness copies share the same
18
+ * `AsyncLocalStorage` instance exported from `@opensip-cli/core`.
19
+ */
20
+ import { AsyncLocalStorage } from 'node:async_hooks';
21
+ import { LanguageParseCache } from '../languages/parse-cache-class.js';
22
+ import { LanguageRegistry } from '../languages/registry.js';
23
+ import { noopSignalSink } from '../signals/signal-sink.js';
24
+ import { ToolRegistry } from '../tools/registry.js';
25
+ import { DiagnosticsBus } from './diagnostics-bus.js';
26
+ import { logger as defaultLogger } from './logger.js';
27
+ // RecipeUnitConfigSlot, DataStoreThunk, ToolScope, and ScopeContribution
28
+ // live in the leaf `scope-types.ts` (audit 2026-05-29, M4) so the `Tool`
29
+ // contract can depend on them without naming the concrete `RunScope` —
30
+ // breaking the RunScope⟷Tool type cycle. The core barrel sources them
31
+ // directly from `scope-types.ts`; `run-scope.ts` imports what it needs below.
32
+ class DefaultRecipeUnitConfigSlot {
33
+ store = {};
34
+ get(slug) {
35
+ return this.store[slug];
36
+ }
37
+ set(slug, config) {
38
+ this.store[slug] = config;
39
+ }
40
+ setAll(config) {
41
+ this.store = { ...config };
42
+ }
43
+ clear() {
44
+ this.store = {};
45
+ }
46
+ }
47
+ /**
48
+ * Per-invocation execution scope.
49
+ *
50
+ * Construct exactly once per CLI invocation. Pass via
51
+ * `ToolCliContext.scope` (Phase 5). Tools read `cli.scope.foo`
52
+ * instead of reaching into module globals (the T1 invariant).
53
+ *
54
+ * Defaults: when no overrides are provided, the scope wires up the
55
+ * default `Logger`, a fresh `LanguageParseCache`, and FRESH empty
56
+ * `ToolRegistry` / `LanguageRegistry` instances. The CLI bootstrap
57
+ * constructs and populates one pair per run and passes them in via
58
+ * `RunScopeOptions` so language adapters and tool plugins land where
59
+ * `currentScope()?.languages` / `.tools` will find them. Tests that
60
+ * exercise registry-aware code paths must either construct a populated
61
+ * registry and pass it in, or register fixtures into `scope.languages`
62
+ * inside the test body's `runWithScope` block.
63
+ */
64
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -- intentional: the class merges with the `interface RunScope extends ToolScope` below to gain the augmentable ScopeContribution slots for reading. The slots are optional and runtime-installed via Object.assign (the kernel's contributeScope loop), so the "interface declares members the class lacks" warning is the desired, safe behavior here.
65
+ export class RunScope {
66
+ logger;
67
+ parseCache;
68
+ recipeUnitConfig;
69
+ projectContext;
70
+ datastore;
71
+ tools;
72
+ languages;
73
+ /** Per-invocation presentation settings; `undefined` outside the CLI render path. */
74
+ ui;
75
+ /**
76
+ * Correlation id for the current invocation. Read by the logger via
77
+ * `currentScope()?.runId` for event-stamping. Empty string when no
78
+ * caller supplied one (matches the prior singleton reset semantics —
79
+ * the logger's `formatEntry` only emits a `runId` field when truthy).
80
+ */
81
+ runId;
82
+ /** Cloud signal sink for this invocation; `noopSignalSink` unless cloud sync is on. */
83
+ signalSink;
84
+ /**
85
+ * Per-invocation diagnostics collector (north-star §5.10, launch).
86
+ * Library code emits lifecycle events via `currentScope()?.diagnostics`; the
87
+ * host assembler snapshots it onto every `CommandOutcome`. Scope-owned so
88
+ * concurrent runs share no diagnostics state (the no-module-singleton rule).
89
+ */
90
+ diagnostics;
91
+ /**
92
+ * Manifests of the tools admitted this run (registration order). Empty unless
93
+ * the CLI bootstrap recorded them. Read by host commands via `currentScope()`.
94
+ */
95
+ toolManifests;
96
+ /**
97
+ * Provenance of the tools admitted this run, paired index-wise with
98
+ * {@link toolManifests}. Empty unless the CLI bootstrap recorded them.
99
+ */
100
+ toolProvenance;
101
+ constructor(opts = {}) {
102
+ this.logger = opts.logger ?? defaultLogger;
103
+ this.parseCache = opts.parseCache ?? new LanguageParseCache();
104
+ this.recipeUnitConfig = new DefaultRecipeUnitConfigSlot();
105
+ this.projectContext = opts.projectContext;
106
+ // eslint-disable-next-line unicorn/no-useless-undefined -- explicit no-store sentinel matches the prior `cli.datastore` contract (tools cast to `DataStore | undefined`).
107
+ this.datastore = opts.datastore ?? (() => undefined);
108
+ this.tools = opts.tools ?? new ToolRegistry();
109
+ this.languages = opts.languages ?? new LanguageRegistry();
110
+ this.ui = opts.ui;
111
+ this.runId = opts.runId ?? '';
112
+ this.signalSink = opts.signalSink ?? noopSignalSink;
113
+ this.diagnostics = new DiagnosticsBus(this.runId);
114
+ this.toolManifests = opts.toolManifests ?? [];
115
+ this.toolProvenance = opts.toolProvenance ?? [];
116
+ }
117
+ /** Release per-run resources (caches, recipe-config slot). */
118
+ dispose() {
119
+ this.parseCache.dispose();
120
+ this.recipeUnitConfig.clear();
121
+ // FileCache lifecycle is owned by fitness; not on RunScope.
122
+ // datastore close is the consumer's responsibility — RunScope
123
+ // doesn't open it eagerly.
124
+ }
125
+ }
126
+ // ─── AsyncLocalStorage seam ──────────────────────────────────────────
127
+ //
128
+ // `runWithScope(scope, fn)` binds `scope` for the dynamic extent of
129
+ // `fn`. Library functions read `currentScope()` instead of any
130
+ // module global.
131
+ //
132
+ // Both copies of a package import the same `AsyncLocalStorage`
133
+ // instance from this module — so the slot identity is bound to core,
134
+ // not to whichever package is reading from it. This solves the
135
+ // two-copies-of-fitness hazard documented at the prior
136
+ // `Symbol.for(globalThis)` site.
137
+ const scopeStorage = new AsyncLocalStorage();
138
+ /** Run `fn` with `scope` bound as the current scope for everything in its dynamic extent. */
139
+ export function runWithScope(scope, fn) {
140
+ return scopeStorage.run(scope, fn);
141
+ }
142
+ /** Synchronous variant of `runWithScope`. */
143
+ export function runWithScopeSync(scope, fn) {
144
+ return scopeStorage.run(scope, fn);
145
+ }
146
+ /**
147
+ * Set `scope` as the current scope for the rest of the calling async
148
+ * context — without needing a callback wrapper. Backed by
149
+ * `AsyncLocalStorage.enterWith`. Use this in Commander's `preAction`
150
+ * hook where the action body runs after the hook returns but in the
151
+ * same async chain: `enterWith` propagates the scope forward without
152
+ * needing to wrap the action invocation, which Commander does not let
153
+ * us do directly. Throws on misuse: an existing scope must NOT be
154
+ * replaced silently (call `runWithScope` for nested scopes).
155
+ */
156
+ export function enterScope(scope) {
157
+ scopeStorage.enterWith(scope);
158
+ }
159
+ /** Read the current scope. Returns undefined when called outside a runWithScope. */
160
+ export function currentScope() {
161
+ return scopeStorage.getStore();
162
+ }
163
+ // ─── Logger ↔ RunScope wiring ────────────────────────────────────────
164
+ //
165
+ // Inject `currentScope()?.runId` as the logger singleton's runId source
166
+ // at module init. The logger module itself cannot import from this file
167
+ // (run-scope already imports logger, so the reverse direction would
168
+ // produce a cycle that depcruise rejects). The wiring lives here, where
169
+ // both symbols are already in scope.
170
+ //
171
+ // `defaultLogger` is typed as `Logger` (a narrow interface) so we
172
+ // type-assert to `LoggerImpl` to reach the `setRunIdProvider` setter —
173
+ // the singleton is always a `LoggerImpl` (see logger.ts), so this is
174
+ // a structural narrowing, not a behavioural cast.
175
+ defaultLogger.setRunIdProvider(() => currentScope()?.runId);
176
+ //# sourceMappingURL=run-scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-scope.js","sourceRoot":"","sources":["../../src/lib/run-scope.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @fileoverview Host-owned RunTimer / RunLifecycle primitive
3
+ * (host-owned-run-timing plan).
4
+ *
5
+ * Single source of truth for wall-clock start + monotonic elapsed for one
6
+ * user-visible CLI tool run. The host run-lifecycle plane creates one lifecycle
7
+ * inside the selected command action (after `RunScope` entry, before any
8
+ * tool-owned work) and `complete()`s it once the tool handler / live renderer
9
+ * returns its completion data — that frozen snapshot feeds the generic
10
+ * `StoredSession.startedAt` / `completedAt` / `durationMs`.
11
+ *
12
+ * Tools and engines must never capture their own `Date.now` / `new Date` for
13
+ * the generic session timing fields; only the host lifecycle feeds those.
14
+ * Internal tool timers (per-unit, per-stage, etc.) remain tool-owned for
15
+ * diagnostics.
16
+ *
17
+ * `startedAt` is ISO wall time captured at construction. `complete()` is
18
+ * idempotent: the first call freezes `completedAt` + `durationMs`; later calls
19
+ * return the same frozen snapshot. `snapshot()` reads live before completion
20
+ * (for the ticking live display) and the frozen values after. Elapsed uses a
21
+ * monotonic clock (`performance.now` when available) to avoid skew on long runs
22
+ * or system clock adjustments.
23
+ */
24
+ export interface RunTimingSnapshot {
25
+ /** ISO-8601 timestamp of run start (wall time, captured early by host). */
26
+ readonly startedAt: string;
27
+ /** ISO-8601 timestamp captured at the moment of this snapshot. */
28
+ readonly completedAt: string;
29
+ /** Wall duration in milliseconds (>= 0). */
30
+ readonly durationMs: number;
31
+ }
32
+ /**
33
+ * Host-owned run timer: the single source of run start time and wall duration
34
+ * for a tool invocation. Tools read timing through `ToolCliContext.runSession`
35
+ * rather than capturing their own `Date.now()` (see the
36
+ * `no-tool-owned-session-timing` check).
37
+ */
38
+ export interface RunTimer {
39
+ /** ISO-8601 timestamp of run start (fixed for the lifetime of this timer). */
40
+ readonly startedAt: string;
41
+ /** Epoch ms at start (for fallback elapsed calculations). */
42
+ readonly startedAtEpochMs: number;
43
+ /**
44
+ * Current elapsed wall time since start, in ms.
45
+ * Uses monotonic source when available; clamped to >= 0.
46
+ */
47
+ elapsedMs(): number;
48
+ /**
49
+ * Capture a point-in-time snapshot. `startedAt` is stable; `completedAt`
50
+ * and `durationMs` reflect now — unless the lifecycle has already been
51
+ * `complete()`d, in which case the frozen completion snapshot is returned.
52
+ */
53
+ snapshot(): RunTimingSnapshot;
54
+ /**
55
+ * Freeze the run lifecycle. Idempotent: the first call captures
56
+ * `completedAt` + `durationMs`; subsequent calls return the same frozen
57
+ * snapshot. The host run-lifecycle plane calls this once the tool handler /
58
+ * live renderer has returned, before host persistence / render / egress.
59
+ */
60
+ complete(): RunTimingSnapshot;
61
+ }
62
+ /**
63
+ * The run lifecycle object the host owns for a single tool invocation
64
+ * (host-owned-run-timing §6.1). Structurally identical to {@link RunTimer};
65
+ * the alias gives the spec-named type and creator without churning the many
66
+ * existing `RunTimer` references.
67
+ */
68
+ export type RunLifecycle = RunTimer;
69
+ /**
70
+ * Create a fresh host-owned run timer.
71
+ *
72
+ * Must be called by the CLI host after `RunScope` is entered (so `runId` etc.
73
+ * are available for logging in Phase 1 wiring) but before any tool work that
74
+ * will be timed.
75
+ */
76
+ export declare function createRunTimer(): RunTimer;
77
+ /**
78
+ * Create a fresh host-owned run lifecycle. Alias of {@link createRunTimer}
79
+ * under the spec-named factory (host-owned-run-timing §6.1).
80
+ */
81
+ export declare const createRunLifecycle: () => RunLifecycle;
82
+ //# sourceMappingURL=run-timer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-timer.d.ts","sourceRoot":"","sources":["../../src/lib/run-timer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,kEAAkE;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAElC;;;OAGG;IACH,SAAS,IAAI,MAAM,CAAC;IAEpB;;;;OAIG;IACH,QAAQ,IAAI,iBAAiB,CAAC;IAE9B;;;;;OAKG;IACH,QAAQ,IAAI,iBAAiB,CAAC;CAC/B;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;AAEpC;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,QAAQ,CAkDzC;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,YAA6B,CAAC"}