opensip-cli 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 (348) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +51 -0
  4. package/dist/api.d.ts +17 -0
  5. package/dist/api.d.ts.map +1 -0
  6. package/dist/api.js +16 -0
  7. package/dist/api.js.map +1 -0
  8. package/dist/bootstrap/admit-tool-package.d.ts +117 -0
  9. package/dist/bootstrap/admit-tool-package.d.ts.map +1 -0
  10. package/dist/bootstrap/admit-tool-package.js +170 -0
  11. package/dist/bootstrap/admit-tool-package.js.map +1 -0
  12. package/dist/bootstrap/baseline-seams.d.ts +30 -0
  13. package/dist/bootstrap/baseline-seams.d.ts.map +1 -0
  14. package/dist/bootstrap/baseline-seams.js +156 -0
  15. package/dist/bootstrap/baseline-seams.js.map +1 -0
  16. package/dist/bootstrap/bootstrap-error.d.ts +41 -0
  17. package/dist/bootstrap/bootstrap-error.d.ts.map +1 -0
  18. package/dist/bootstrap/bootstrap-error.js +33 -0
  19. package/dist/bootstrap/bootstrap-error.js.map +1 -0
  20. package/dist/bootstrap/build-command-registration-input.d.ts +34 -0
  21. package/dist/bootstrap/build-command-registration-input.d.ts.map +1 -0
  22. package/dist/bootstrap/build-command-registration-input.js +73 -0
  23. package/dist/bootstrap/build-command-registration-input.js.map +1 -0
  24. package/dist/bootstrap/build-per-run-scope.d.ts +62 -0
  25. package/dist/bootstrap/build-per-run-scope.d.ts.map +1 -0
  26. package/dist/bootstrap/build-per-run-scope.js +152 -0
  27. package/dist/bootstrap/build-per-run-scope.js.map +1 -0
  28. package/dist/bootstrap/build-targets.d.ts +42 -0
  29. package/dist/bootstrap/build-targets.d.ts.map +1 -0
  30. package/dist/bootstrap/build-targets.js +117 -0
  31. package/dist/bootstrap/build-targets.js.map +1 -0
  32. package/dist/bootstrap/cli-defaults.d.ts +35 -0
  33. package/dist/bootstrap/cli-defaults.d.ts.map +1 -0
  34. package/dist/bootstrap/cli-defaults.js +65 -0
  35. package/dist/bootstrap/cli-defaults.js.map +1 -0
  36. package/dist/bootstrap/config-and-capabilities.d.ts +74 -0
  37. package/dist/bootstrap/config-and-capabilities.d.ts.map +1 -0
  38. package/dist/bootstrap/config-and-capabilities.js +224 -0
  39. package/dist/bootstrap/config-and-capabilities.js.map +1 -0
  40. package/dist/bootstrap/deliver-envelope.d.ts +80 -0
  41. package/dist/bootstrap/deliver-envelope.d.ts.map +1 -0
  42. package/dist/bootstrap/deliver-envelope.js +195 -0
  43. package/dist/bootstrap/deliver-envelope.js.map +1 -0
  44. package/dist/bootstrap/egress-plane.d.ts +22 -0
  45. package/dist/bootstrap/egress-plane.d.ts.map +1 -0
  46. package/dist/bootstrap/egress-plane.js +37 -0
  47. package/dist/bootstrap/egress-plane.js.map +1 -0
  48. package/dist/bootstrap/host-planes.d.ts +28 -0
  49. package/dist/bootstrap/host-planes.d.ts.map +1 -0
  50. package/dist/bootstrap/host-planes.js +152 -0
  51. package/dist/bootstrap/host-planes.js.map +1 -0
  52. package/dist/bootstrap/index.d.ts +76 -0
  53. package/dist/bootstrap/index.d.ts.map +1 -0
  54. package/dist/bootstrap/index.js +109 -0
  55. package/dist/bootstrap/index.js.map +1 -0
  56. package/dist/bootstrap/live-plane.d.ts +51 -0
  57. package/dist/bootstrap/live-plane.d.ts.map +1 -0
  58. package/dist/bootstrap/live-plane.js +72 -0
  59. package/dist/bootstrap/live-plane.js.map +1 -0
  60. package/dist/bootstrap/load-tool-capabilities.d.ts +42 -0
  61. package/dist/bootstrap/load-tool-capabilities.d.ts.map +1 -0
  62. package/dist/bootstrap/load-tool-capabilities.js +76 -0
  63. package/dist/bootstrap/load-tool-capabilities.js.map +1 -0
  64. package/dist/bootstrap/output-plane.d.ts +37 -0
  65. package/dist/bootstrap/output-plane.d.ts.map +1 -0
  66. package/dist/bootstrap/output-plane.js +114 -0
  67. package/dist/bootstrap/output-plane.js.map +1 -0
  68. package/dist/bootstrap/owning-tool-init.d.ts +32 -0
  69. package/dist/bootstrap/owning-tool-init.d.ts.map +1 -0
  70. package/dist/bootstrap/owning-tool-init.js +69 -0
  71. package/dist/bootstrap/owning-tool-init.js.map +1 -0
  72. package/dist/bootstrap/pre-action-guards.d.ts +44 -0
  73. package/dist/bootstrap/pre-action-guards.d.ts.map +1 -0
  74. package/dist/bootstrap/pre-action-guards.js +136 -0
  75. package/dist/bootstrap/pre-action-guards.js.map +1 -0
  76. package/dist/bootstrap/pre-action-hook.d.ts +68 -0
  77. package/dist/bootstrap/pre-action-hook.d.ts.map +1 -0
  78. package/dist/bootstrap/pre-action-hook.js +289 -0
  79. package/dist/bootstrap/pre-action-hook.js.map +1 -0
  80. package/dist/bootstrap/pre-action-messages.d.ts +32 -0
  81. package/dist/bootstrap/pre-action-messages.d.ts.map +1 -0
  82. package/dist/bootstrap/pre-action-messages.js +49 -0
  83. package/dist/bootstrap/pre-action-messages.js.map +1 -0
  84. package/dist/bootstrap/process-idempotency.d.ts +17 -0
  85. package/dist/bootstrap/process-idempotency.d.ts.map +1 -0
  86. package/dist/bootstrap/process-idempotency.js +20 -0
  87. package/dist/bootstrap/process-idempotency.js.map +1 -0
  88. package/dist/bootstrap/register-language-adapters.d.ts +23 -0
  89. package/dist/bootstrap/register-language-adapters.d.ts.map +1 -0
  90. package/dist/bootstrap/register-language-adapters.js +35 -0
  91. package/dist/bootstrap/register-language-adapters.js.map +1 -0
  92. package/dist/bootstrap/register-tools.d.ts +228 -0
  93. package/dist/bootstrap/register-tools.d.ts.map +1 -0
  94. package/dist/bootstrap/register-tools.js +696 -0
  95. package/dist/bootstrap/register-tools.js.map +1 -0
  96. package/dist/bootstrap/render.d.ts +27 -0
  97. package/dist/bootstrap/render.d.ts.map +1 -0
  98. package/dist/bootstrap/render.js +53 -0
  99. package/dist/bootstrap/render.js.map +1 -0
  100. package/dist/bootstrap/report.d.ts +34 -0
  101. package/dist/bootstrap/report.d.ts.map +1 -0
  102. package/dist/bootstrap/report.js +47 -0
  103. package/dist/bootstrap/report.js.map +1 -0
  104. package/dist/bootstrap/run-plane.d.ts +105 -0
  105. package/dist/bootstrap/run-plane.d.ts.map +1 -0
  106. package/dist/bootstrap/run-plane.js +190 -0
  107. package/dist/bootstrap/run-plane.js.map +1 -0
  108. package/dist/bootstrap/scope-access.d.ts +68 -0
  109. package/dist/bootstrap/scope-access.d.ts.map +1 -0
  110. package/dist/bootstrap/scope-access.js +115 -0
  111. package/dist/bootstrap/scope-access.js.map +1 -0
  112. package/dist/bootstrap/state-seams.d.ts +14 -0
  113. package/dist/bootstrap/state-seams.d.ts.map +1 -0
  114. package/dist/bootstrap/state-seams.js +26 -0
  115. package/dist/bootstrap/state-seams.js.map +1 -0
  116. package/dist/bootstrap/tool-lifecycle.d.ts +102 -0
  117. package/dist/bootstrap/tool-lifecycle.d.ts.map +1 -0
  118. package/dist/bootstrap/tool-lifecycle.js +103 -0
  119. package/dist/bootstrap/tool-lifecycle.js.map +1 -0
  120. package/dist/bootstrap/tool-trust.d.ts +49 -0
  121. package/dist/bootstrap/tool-trust.d.ts.map +1 -0
  122. package/dist/bootstrap/tool-trust.js +65 -0
  123. package/dist/bootstrap/tool-trust.js.map +1 -0
  124. package/dist/bootstrap/validate-tool.d.ts +22 -0
  125. package/dist/bootstrap/validate-tool.d.ts.map +1 -0
  126. package/dist/bootstrap/validate-tool.js +38 -0
  127. package/dist/bootstrap/validate-tool.js.map +1 -0
  128. package/dist/cli-context.d.ts +38 -0
  129. package/dist/cli-context.d.ts.map +1 -0
  130. package/dist/cli-context.js +134 -0
  131. package/dist/cli-context.js.map +1 -0
  132. package/dist/commands/agent-catalog.d.ts +45 -0
  133. package/dist/commands/agent-catalog.d.ts.map +1 -0
  134. package/dist/commands/agent-catalog.js +115 -0
  135. package/dist/commands/agent-catalog.js.map +1 -0
  136. package/dist/commands/assemble-outcome.d.ts +69 -0
  137. package/dist/commands/assemble-outcome.d.ts.map +1 -0
  138. package/dist/commands/assemble-outcome.js +121 -0
  139. package/dist/commands/assemble-outcome.js.map +1 -0
  140. package/dist/commands/clear.d.ts +32 -0
  141. package/dist/commands/clear.d.ts.map +1 -0
  142. package/dist/commands/clear.js +73 -0
  143. package/dist/commands/clear.js.map +1 -0
  144. package/dist/commands/completion.d.ts +90 -0
  145. package/dist/commands/completion.d.ts.map +1 -0
  146. package/dist/commands/completion.js +233 -0
  147. package/dist/commands/completion.js.map +1 -0
  148. package/dist/commands/configure.d.ts +32 -0
  149. package/dist/commands/configure.d.ts.map +1 -0
  150. package/dist/commands/configure.js +94 -0
  151. package/dist/commands/configure.js.map +1 -0
  152. package/dist/commands/history.d.ts +18 -0
  153. package/dist/commands/history.d.ts.map +1 -0
  154. package/dist/commands/history.js +48 -0
  155. package/dist/commands/history.js.map +1 -0
  156. package/dist/commands/host-command-specs.d.ts +49 -0
  157. package/dist/commands/host-command-specs.d.ts.map +1 -0
  158. package/dist/commands/host-command-specs.js +331 -0
  159. package/dist/commands/host-command-specs.js.map +1 -0
  160. package/dist/commands/host-subcommand-groups.d.ts +69 -0
  161. package/dist/commands/host-subcommand-groups.d.ts.map +1 -0
  162. package/dist/commands/host-subcommand-groups.js +374 -0
  163. package/dist/commands/host-subcommand-groups.js.map +1 -0
  164. package/dist/commands/index.d.ts +36 -0
  165. package/dist/commands/index.d.ts.map +1 -0
  166. package/dist/commands/index.js +36 -0
  167. package/dist/commands/index.js.map +1 -0
  168. package/dist/commands/init/config-templates.d.ts +16 -0
  169. package/dist/commands/init/config-templates.d.ts.map +1 -0
  170. package/dist/commands/init/config-templates.js +108 -0
  171. package/dist/commands/init/config-templates.js.map +1 -0
  172. package/dist/commands/init/file-classifier.d.ts +40 -0
  173. package/dist/commands/init/file-classifier.d.ts.map +1 -0
  174. package/dist/commands/init/file-classifier.js +155 -0
  175. package/dist/commands/init/file-classifier.js.map +1 -0
  176. package/dist/commands/init/language-detection.d.ts +44 -0
  177. package/dist/commands/init/language-detection.d.ts.map +1 -0
  178. package/dist/commands/init/language-detection.js +124 -0
  179. package/dist/commands/init/language-detection.js.map +1 -0
  180. package/dist/commands/init/scaffold-writer.d.ts +26 -0
  181. package/dist/commands/init/scaffold-writer.d.ts.map +1 -0
  182. package/dist/commands/init/scaffold-writer.js +102 -0
  183. package/dist/commands/init/scaffold-writer.js.map +1 -0
  184. package/dist/commands/init/state-machine.d.ts +32 -0
  185. package/dist/commands/init/state-machine.d.ts.map +1 -0
  186. package/dist/commands/init/state-machine.js +105 -0
  187. package/dist/commands/init/state-machine.js.map +1 -0
  188. package/dist/commands/init.d.ts +95 -0
  189. package/dist/commands/init.d.ts.map +1 -0
  190. package/dist/commands/init.js +209 -0
  191. package/dist/commands/init.js.map +1 -0
  192. package/dist/commands/mount-command-spec.d.ts +106 -0
  193. package/dist/commands/mount-command-spec.d.ts.map +1 -0
  194. package/dist/commands/mount-command-spec.js +313 -0
  195. package/dist/commands/mount-command-spec.js.map +1 -0
  196. package/dist/commands/mount-result-command.d.ts +71 -0
  197. package/dist/commands/mount-result-command.d.ts.map +1 -0
  198. package/dist/commands/mount-result-command.js +76 -0
  199. package/dist/commands/mount-result-command.js.map +1 -0
  200. package/dist/commands/plugin/config-edit.d.ts +20 -0
  201. package/dist/commands/plugin/config-edit.d.ts.map +1 -0
  202. package/dist/commands/plugin/config-edit.js +102 -0
  203. package/dist/commands/plugin/config-edit.js.map +1 -0
  204. package/dist/commands/plugin/domain-resolution.d.ts +38 -0
  205. package/dist/commands/plugin/domain-resolution.d.ts.map +1 -0
  206. package/dist/commands/plugin/domain-resolution.js +98 -0
  207. package/dist/commands/plugin/domain-resolution.js.map +1 -0
  208. package/dist/commands/plugin/host-dir.d.ts +42 -0
  209. package/dist/commands/plugin/host-dir.d.ts.map +1 -0
  210. package/dist/commands/plugin/host-dir.js +168 -0
  211. package/dist/commands/plugin/host-dir.js.map +1 -0
  212. package/dist/commands/plugin-host-ops.d.ts +41 -0
  213. package/dist/commands/plugin-host-ops.d.ts.map +1 -0
  214. package/dist/commands/plugin-host-ops.js +114 -0
  215. package/dist/commands/plugin-host-ops.js.map +1 -0
  216. package/dist/commands/plugin.d.ts +81 -0
  217. package/dist/commands/plugin.d.ts.map +1 -0
  218. package/dist/commands/plugin.js +287 -0
  219. package/dist/commands/plugin.js.map +1 -0
  220. package/dist/commands/render-outcome.d.ts +52 -0
  221. package/dist/commands/render-outcome.d.ts.map +1 -0
  222. package/dist/commands/render-outcome.js +55 -0
  223. package/dist/commands/render-outcome.js.map +1 -0
  224. package/dist/commands/session-show.d.ts +27 -0
  225. package/dist/commands/session-show.d.ts.map +1 -0
  226. package/dist/commands/session-show.js +166 -0
  227. package/dist/commands/session-show.js.map +1 -0
  228. package/dist/commands/shared.d.ts +107 -0
  229. package/dist/commands/shared.d.ts.map +1 -0
  230. package/dist/commands/shared.js +13 -0
  231. package/dist/commands/shared.js.map +1 -0
  232. package/dist/commands/tools/data-purge.d.ts +20 -0
  233. package/dist/commands/tools/data-purge.d.ts.map +1 -0
  234. package/dist/commands/tools/data-purge.js +59 -0
  235. package/dist/commands/tools/data-purge.js.map +1 -0
  236. package/dist/commands/tools/index.d.ts +16 -0
  237. package/dist/commands/tools/index.d.ts.map +1 -0
  238. package/dist/commands/tools/index.js +213 -0
  239. package/dist/commands/tools/index.js.map +1 -0
  240. package/dist/commands/tools/install.d.ts +24 -0
  241. package/dist/commands/tools/install.d.ts.map +1 -0
  242. package/dist/commands/tools/install.js +83 -0
  243. package/dist/commands/tools/install.js.map +1 -0
  244. package/dist/commands/tools/list.d.ts +41 -0
  245. package/dist/commands/tools/list.d.ts.map +1 -0
  246. package/dist/commands/tools/list.js +103 -0
  247. package/dist/commands/tools/list.js.map +1 -0
  248. package/dist/commands/tools/runtime-probe-entry.d.ts +14 -0
  249. package/dist/commands/tools/runtime-probe-entry.d.ts.map +1 -0
  250. package/dist/commands/tools/runtime-probe-entry.js +36 -0
  251. package/dist/commands/tools/runtime-probe-entry.js.map +1 -0
  252. package/dist/commands/tools/runtime-probe.d.ts +29 -0
  253. package/dist/commands/tools/runtime-probe.d.ts.map +1 -0
  254. package/dist/commands/tools/runtime-probe.js +66 -0
  255. package/dist/commands/tools/runtime-probe.js.map +1 -0
  256. package/dist/commands/tools/storage-contract-checks.d.ts +37 -0
  257. package/dist/commands/tools/storage-contract-checks.d.ts.map +1 -0
  258. package/dist/commands/tools/storage-contract-checks.js +91 -0
  259. package/dist/commands/tools/storage-contract-checks.js.map +1 -0
  260. package/dist/commands/tools/uninstall.d.ts +29 -0
  261. package/dist/commands/tools/uninstall.d.ts.map +1 -0
  262. package/dist/commands/tools/uninstall.js +77 -0
  263. package/dist/commands/tools/uninstall.js.map +1 -0
  264. package/dist/commands/tools/validate.d.ts +44 -0
  265. package/dist/commands/tools/validate.d.ts.map +1 -0
  266. package/dist/commands/tools/validate.js +202 -0
  267. package/dist/commands/tools/validate.js.map +1 -0
  268. package/dist/commands/uninstall/targets.d.ts +53 -0
  269. package/dist/commands/uninstall/targets.d.ts.map +1 -0
  270. package/dist/commands/uninstall/targets.js +205 -0
  271. package/dist/commands/uninstall/targets.js.map +1 -0
  272. package/dist/commands/uninstall.d.ts +88 -0
  273. package/dist/commands/uninstall.d.ts.map +1 -0
  274. package/dist/commands/uninstall.js +184 -0
  275. package/dist/commands/uninstall.js.map +1 -0
  276. package/dist/env/host-env-specs.d.ts +52 -0
  277. package/dist/env/host-env-specs.d.ts.map +1 -0
  278. package/dist/env/host-env-specs.js +129 -0
  279. package/dist/env/host-env-specs.js.map +1 -0
  280. package/dist/error-handler.d.ts +64 -0
  281. package/dist/error-handler.d.ts.map +1 -0
  282. package/dist/error-handler.js +180 -0
  283. package/dist/error-handler.js.map +1 -0
  284. package/dist/index.d.ts +21 -0
  285. package/dist/index.d.ts.map +1 -0
  286. package/dist/index.js +154 -0
  287. package/dist/index.js.map +1 -0
  288. package/dist/open-report.d.ts +40 -0
  289. package/dist/open-report.d.ts.map +1 -0
  290. package/dist/open-report.js +54 -0
  291. package/dist/open-report.js.map +1 -0
  292. package/dist/report-compose.d.ts +35 -0
  293. package/dist/report-compose.d.ts.map +1 -0
  294. package/dist/report-compose.js +103 -0
  295. package/dist/report-compose.js.map +1 -0
  296. package/dist/session-replay-registry.d.ts +20 -0
  297. package/dist/session-replay-registry.d.ts.map +1 -0
  298. package/dist/session-replay-registry.js +38 -0
  299. package/dist/session-replay-registry.js.map +1 -0
  300. package/dist/telemetry/profiling.d.ts +42 -0
  301. package/dist/telemetry/profiling.d.ts.map +1 -0
  302. package/dist/telemetry/profiling.js +160 -0
  303. package/dist/telemetry/profiling.js.map +1 -0
  304. package/dist/telemetry/sdk-init.d.ts +87 -0
  305. package/dist/telemetry/sdk-init.d.ts.map +1 -0
  306. package/dist/telemetry/sdk-init.js +235 -0
  307. package/dist/telemetry/sdk-init.js.map +1 -0
  308. package/dist/ui/App.d.ts +32 -0
  309. package/dist/ui/App.d.ts.map +1 -0
  310. package/dist/ui/App.js +35 -0
  311. package/dist/ui/App.js.map +1 -0
  312. package/dist/ui/render.d.ts +15 -0
  313. package/dist/ui/render.d.ts.map +1 -0
  314. package/dist/ui/render.js +21 -0
  315. package/dist/ui/render.js.map +1 -0
  316. package/dist/ui/result-to-view.d.ts +40 -0
  317. package/dist/ui/result-to-view.d.ts.map +1 -0
  318. package/dist/ui/result-to-view.js +389 -0
  319. package/dist/ui/result-to-view.js.map +1 -0
  320. package/dist/ui/views/init-view.d.ts +9 -0
  321. package/dist/ui/views/init-view.d.ts.map +1 -0
  322. package/dist/ui/views/init-view.js +119 -0
  323. package/dist/ui/views/init-view.js.map +1 -0
  324. package/dist/ui/views/misc-views.d.ts +18 -0
  325. package/dist/ui/views/misc-views.d.ts.map +1 -0
  326. package/dist/ui/views/misc-views.js +244 -0
  327. package/dist/ui/views/misc-views.js.map +1 -0
  328. package/dist/ui/views/plugin-view.d.ts +8 -0
  329. package/dist/ui/views/plugin-view.d.ts.map +1 -0
  330. package/dist/ui/views/plugin-view.js +135 -0
  331. package/dist/ui/views/plugin-view.js.map +1 -0
  332. package/dist/ui/views/tools-views.d.ts +12 -0
  333. package/dist/ui/views/tools-views.d.ts.map +1 -0
  334. package/dist/ui/views/tools-views.js +152 -0
  335. package/dist/ui/views/tools-views.js.map +1 -0
  336. package/dist/update-notifier.d.ts +108 -0
  337. package/dist/update-notifier.d.ts.map +1 -0
  338. package/dist/update-notifier.js +188 -0
  339. package/dist/update-notifier.js.map +1 -0
  340. package/dist/update-state.d.ts +40 -0
  341. package/dist/update-state.d.ts.map +1 -0
  342. package/dist/update-state.js +81 -0
  343. package/dist/update-state.js.map +1 -0
  344. package/dist/welcome.d.ts +53 -0
  345. package/dist/welcome.d.ts.map +1 -0
  346. package/dist/welcome.js +89 -0
  347. package/dist/welcome.js.map +1 -0
  348. package/package.json +100 -0
@@ -0,0 +1,115 @@
1
+ /**
2
+ * scope-access — per-run scope + datastore readers.
3
+ *
4
+ * Extracted from `cli-context.ts` so that module stays focused on context
5
+ * ASSEMBLY (live-view registry + `buildToolCliContext`). This module owns the
6
+ * complementary concern: reading the entered `RunScope` and opening the
7
+ * project-local SQLite datastore lazily.
8
+ *
9
+ * After Phase 3 hygiene the ONLY way to obtain the per-run scope is
10
+ * `currentScope()` (entered by the pre-action-hook, or explicit `runWithScope`
11
+ * in tests). There are no holder fallbacks. Non-action paths (report, errors)
12
+ * that need scope must ensure entry or restructure to run inside an entered
13
+ * action.
14
+ */
15
+ import { ConfigurationError, SystemError, currentScope, logger as defaultLogger, resolveProjectPaths, } from '@opensip-cli/core';
16
+ import { DataStoreFactory } from '@opensip-cli/datastore';
17
+ /**
18
+ * Strict reader: the only way to obtain the per-run scope is `currentScope()`
19
+ * (entered by pre-action-hook or explicit runWithScope in tests). All previous
20
+ * holder fallbacks were removed.
21
+ *
22
+ * @throws {SystemError} (`SYSTEM.SCOPE.NOT_ENTERED`) When accessed before the
23
+ * pre-action-hook constructed and entered the scope.
24
+ */
25
+ export function readScope() {
26
+ const bound = currentScope();
27
+ if (!bound) {
28
+ throw new SystemError('CLI scope accessed before pre-action-hook constructed and entered it (enterScope + ALS). ' +
29
+ 'All production paths (tool actions, host commands, report/error seams) must run inside ' +
30
+ 'an entered RunScope. See host-planes-scope-seams-hygiene plan Phase 3 and currentScope().', { code: 'SYSTEM.SCOPE.NOT_ENTERED' });
31
+ }
32
+ return bound;
33
+ }
34
+ /**
35
+ * Read the current project root. Convenience for non-tool bootstrap
36
+ * helpers (e.g. `maybeOpenReport`) that need the project root but
37
+ * don't carry a ToolCliContext.
38
+ *
39
+ * @throws {SystemError} (`SYSTEM.BOOTSTRAP.PROJECT_UNSET`) When accessed before
40
+ * the pre-action-hook resolved the context.
41
+ */
42
+ export function getCurrentProjectRoot() {
43
+ const project = readScope().projectContext;
44
+ if (!project) {
45
+ throw new SystemError('getCurrentProjectRoot() called before pre-action-hook resolved the context.', { code: 'SYSTEM.BOOTSTRAP.PROJECT_UNSET' });
46
+ }
47
+ return project.projectRoot;
48
+ }
49
+ /**
50
+ * Build a closure-based datastore thunk for the given project.
51
+ * Caches the open DataStore on first access. The pre-action-hook
52
+ * wires the result into `RunScope.datastore` so tools and CLI
53
+ * commands reach the same instance.
54
+ *
55
+ * @throws {SystemError} (`SYSTEM.BOOTSTRAP.DATASTORE_OUTSIDE_PROJECT`) When the
56
+ * returned thunk is invoked outside a project scope — callers must check
57
+ * `project.scope === 'project'` first or handle the throw as a "no project
58
+ * found" error.
59
+ */
60
+ export function buildDatastoreThunk(project, log = defaultLogger) {
61
+ let cached;
62
+ return () => {
63
+ if (cached)
64
+ return cached;
65
+ if (project.scope !== 'project') {
66
+ throw new SystemError('Datastore accessed in a non-project context. The action body should have ' +
67
+ 'errored earlier with "No OpenSIP CLI project found" before touching this.', { code: 'SYSTEM.BOOTSTRAP.DATASTORE_OUTSIDE_PROJECT' });
68
+ }
69
+ const path = `${resolveProjectPaths(project.projectRoot).runtimeDir}/datastore.sqlite`;
70
+ cached = DataStoreFactory.open({ backend: 'sqlite', path });
71
+ log.info({
72
+ evt: 'cli.datastore.opened',
73
+ module: 'cli:context',
74
+ path,
75
+ });
76
+ return cached;
77
+ };
78
+ }
79
+ /**
80
+ * Open (or return cached) project-local SQLite DataStore via the
81
+ * scope's datastore thunk. Shared between tool action bodies and
82
+ * the host commands (e.g. `sessions`, in `host-subcommand-groups.ts`) so
83
+ * both paths are equally lazy.
84
+ *
85
+ * @throws {SystemError} When called outside a project scope — see
86
+ * `buildDatastoreThunk`'s contract.
87
+ */
88
+ export function getOrOpenDatastore(_log = defaultLogger) {
89
+ const thunk = readScope().datastore;
90
+ return thunk();
91
+ }
92
+ /**
93
+ * Project-scoped datastore accessor for the host-owned planes (baseline,
94
+ * toolState, hostPlanes). Converts the internal DATASTORE_OUTSIDE_PROJECT
95
+ * SystemError into a clear ConfigurationError so callers of the documented
96
+ * ToolCliContext seams get a user-actionable error (exit 2) instead of an
97
+ * internal SYSTEM.* code.
98
+ *
99
+ * @throws {ConfigurationError} When called outside a project scope (no open
100
+ * datastore); other datastore-open failures propagate unchanged.
101
+ */
102
+ export function getProjectDatastore() {
103
+ try {
104
+ return getOrOpenDatastore();
105
+ }
106
+ catch (error) {
107
+ if (error instanceof SystemError &&
108
+ error.code === 'SYSTEM.BOOTSTRAP.DATASTORE_OUTSIDE_PROJECT') {
109
+ throw new ConfigurationError('This operation requires an OpenSIP CLI project (an opensip-cli.config.yml with a targets: block or similar). ' +
110
+ 'Run from within a project directory, or pass --cwd to an initialized project.', { code: 'CONFIGURATION.REQUIRES_PROJECT' });
111
+ }
112
+ throw error;
113
+ }
114
+ }
115
+ //# sourceMappingURL=scope-access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-access.js","sourceRoot":"","sources":["../../src/bootstrap/scope-access.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,kBAAkB,EAIlB,WAAW,EACX,YAAY,EACZ,MAAM,IAAI,aAAa,EACvB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAkB,MAAM,wBAAwB,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;IAC7B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,WAAW,CACnB,2FAA2F;YACzF,yFAAyF;YACzF,2FAA2F,EAC7F,EAAE,IAAI,EAAE,0BAA0B,EAAE,CACrC,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC,cAAc,CAAC;IAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,WAAW,CACnB,6EAA6E,EAC7E,EAAE,IAAI,EAAE,gCAAgC,EAAE,CAC3C,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,WAAW,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAuB,EACvB,MAAc,aAAa;IAE3B,IAAI,MAA6B,CAAC;IAClC,OAAO,GAAG,EAAE;QACV,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAC1B,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,WAAW,CACnB,2EAA2E;gBACzE,2EAA2E,EAC7E,EAAE,IAAI,EAAE,4CAA4C,EAAE,CACvD,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,GAAG,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,UAAU,mBAAmB,CAAC;QACvF,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,GAAG,CAAC,IAAI,CAAC;YACP,GAAG,EAAE,sBAAsB;YAC3B,MAAM,EAAE,aAAa;YACrB,IAAI;SACL,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe,aAAa;IAC7D,MAAM,KAAK,GAAG,SAAS,EAAE,CAAC,SAAS,CAAC;IACpC,OAAO,KAAK,EAAe,CAAC;AAC9B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC;QACH,OAAO,kBAAkB,EAAE,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IACE,KAAK,YAAY,WAAW;YAC5B,KAAK,CAAC,IAAI,KAAK,4CAA4C,EAC3D,CAAC;YACD,MAAM,IAAI,kBAAkB,CAC1B,+GAA+G;gBAC7G,+EAA+E,EACjF,EAAE,IAAI,EAAE,gCAAgC,EAAE,CAC3C,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * state-seams — the host implementation behind the `ToolCliContext.toolState`
3
+ * grouped seam (ADR-0042): durable keyed JSON persistence over the host-owned
4
+ * `tool_state` table via `ToolStateRepo`. Mirrors `baseline-seams.ts`
5
+ * structurally (lazy datastore resolver; sync SQLite bodies typed Promise so a
6
+ * sync throw still rejects for an awaiting caller).
7
+ */
8
+ import { type DataStore } from '@opensip-cli/datastore';
9
+ import type { ToolCliContext } from '@opensip-cli/core';
10
+ /** Build the `toolState` seam group over a lazy datastore resolver. */
11
+ export declare function buildStateSeams(deps: {
12
+ readonly getDatastore: () => DataStore;
13
+ }): ToolCliContext['toolState'];
14
+ //# sourceMappingURL=state-seams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-seams.d.ts","sourceRoot":"","sources":["../../src/bootstrap/state-seams.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,QAAQ,CAAC,YAAY,EAAE,MAAM,SAAS,CAAC;CACxC,GAAG,cAAc,CAAC,WAAW,CAAC,CAc9B"}
@@ -0,0 +1,26 @@
1
+ // @fitness-ignore-file null-safety -- repoFor() returns a freshly constructed ToolStateRepo (never null); the heuristic misreads the fluent .put/.list calls
2
+ /**
3
+ * state-seams — the host implementation behind the `ToolCliContext.toolState`
4
+ * grouped seam (ADR-0042): durable keyed JSON persistence over the host-owned
5
+ * `tool_state` table via `ToolStateRepo`. Mirrors `baseline-seams.ts`
6
+ * structurally (lazy datastore resolver; sync SQLite bodies typed Promise so a
7
+ * sync throw still rejects for an awaiting caller).
8
+ */
9
+ import { ToolStateRepo } from '@opensip-cli/datastore';
10
+ /** Build the `toolState` seam group over a lazy datastore resolver. */
11
+ export function buildStateSeams(deps) {
12
+ const repoFor = () => new ToolStateRepo(deps.getDatastore());
13
+ return {
14
+ get: (tool, key) => Promise.resolve(repoFor().get(tool, key)),
15
+ put: (tool, key, payload) => {
16
+ repoFor().put(tool, key, payload);
17
+ return Promise.resolve();
18
+ },
19
+ delete: (tool, key) => {
20
+ repoFor().delete(tool, key);
21
+ return Promise.resolve();
22
+ },
23
+ list: (tool) => Promise.resolve(repoFor().list(tool)),
24
+ };
25
+ }
26
+ //# sourceMappingURL=state-seams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-seams.js","sourceRoot":"","sources":["../../src/bootstrap/state-seams.ts"],"names":[],"mappings":"AAAA,6JAA6J;AAC7J;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAkB,MAAM,wBAAwB,CAAC;AAIvE,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,IAE/B;IACC,MAAM,OAAO,GAAG,GAAkB,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IAC5E,OAAO;QACL,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC7D,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;YAC1B,OAAO,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;YAClC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;QACD,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;YACpB,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAC5B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACtD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * tool-lifecycle — the NAMED, ordered tool-admission lifecycle (release
3
+ * launch, §5.4). A thin sequencer/driver that documents + orders the existing
4
+ * bootstrap calls into one canonical sequence, rather than re-architecting the
5
+ * individual hooks (which keep their own homes and contracts).
6
+ *
7
+ * The 10 steps span two temporal phases of a CLI invocation:
8
+ *
9
+ * ── STARTUP (once per process, composition root) ──────────────────────────
10
+ * 1. DISCOVER — enumerate tool sources: bundled first-party
11
+ * ({@link registerFirstPartyTools}) + on-disk packages
12
+ * ({@link discoverAndRegisterToolPackages} via
13
+ * `discoverToolPackagesFromAnchors`).
14
+ * 2. COMPAT — run each candidate's static `package.json#opensipTools`
15
+ * manifest through the `admitTool` compatibility gate. Bundled = fail-
16
+ * closed; installed = best-effort skip; project-local = trust-gated.
17
+ * 3. TRUST — deny-by-default trust check for project-local executable
18
+ * tools (`admitProjectLocalTool`), BEFORE any module import.
19
+ * 4. IMPORT — dynamic-`import()` an admitted installed/project-local
20
+ * package's entry, then VALIDATE the exported `tool` shape
21
+ * (`isValidTool`) and REGISTER it into the `ToolRegistry`
22
+ * (first-writer-wins). Steps 1-4 all complete inside {@link bootstrapCli}.
23
+ * 8. MOUNT — walk the registry and mount each tool's declared
24
+ * `commandSpecs` ({@link mountAllToolCommands}). Provenance stops mattering
25
+ * here, so bundled and installed tools share the identical mount path.
26
+ *
27
+ * ── PER-RUN (per invocation, pre-action hook) ─────────────────────────────
28
+ * 5. CONFIG — compose every tool's `config` Zod block into one strict
29
+ * whole-document schema and validate the config file once
30
+ * (`composeAndValidateToolConfig`).
31
+ * 6. SCOPE — each tool contributes its per-run subscope
32
+ * (`tool.contributeScope()`); the kernel `Object.assign`s it onto the
33
+ * `RunScope` before `enterScope`.
34
+ * 7. CAPABILITIES — wire the per-run capability registry: register each
35
+ * manifest's declared domains, then replace the deferred placeholder with
36
+ * the owning tool's real registrar (`wireCapabilityRegistry`).
37
+ * 9. INITIALIZE — lazy, memoized `tool.initialize()` for the tool owning the
38
+ * invoked subcommand, exactly once per process, after `enterScope`
39
+ * (`maybeInitializeOwningTool`).
40
+ * 10. DISPATCH — Commander invokes the command's action body; the
41
+ * `mountCommandSpec` pipeline (parse → handler → dispatch → error → exit)
42
+ * runs the tool's handler.
43
+ *
44
+ * Steps 5-7, 9, 10 are inherently per-invocation (they read the entered
45
+ * `RunScope`) and live in `pre-action-hook.ts`; this module does NOT move them
46
+ * — it names them so the full lifecycle has one documented source of truth and
47
+ * drives the contiguous STARTUP steps (discover→…→register, then mount) through
48
+ * one ordered entry point. The driver is intentionally THIN: it sequences the
49
+ * pre-existing helpers, it does not reimplement them.
50
+ */
51
+ import type { CliProgram } from '@opensip-cli/contracts';
52
+ import type { ToolCliContext, ToolRegistry } from '@opensip-cli/core';
53
+ /**
54
+ * Canonical, ordered tool-lifecycle steps (launch, §5.4). The numeric
55
+ * values are the step ordinals used in the JSDoc above and in
56
+ * lifecycle-ordering tests; the string keys name each step. This is the single
57
+ * source of truth for the sequence — a test asserts the STARTUP driver fires
58
+ * its steps in this order.
59
+ */
60
+ export declare const TOOL_LIFECYCLE_STEPS: {
61
+ /** 1 — enumerate bundled + on-disk tool sources. */
62
+ readonly discover: 1;
63
+ /** 2 — `admitTool` compatibility gate over the static manifest. */
64
+ readonly compat: 2;
65
+ /** 3 — deny-by-default trust check for project-local executable tools. */
66
+ readonly trust: 3;
67
+ /** 4 — import an admitted package, validate its shape, register it. */
68
+ readonly import: 4;
69
+ /** 5 — compose + strict-validate every tool's config block. */
70
+ readonly config: 5;
71
+ /** 6 — each tool contributes its per-run subscope. */
72
+ readonly scope: 6;
73
+ /** 7 — wire the per-run capability registry (manifest domains → registrars). */
74
+ readonly capabilities: 7;
75
+ /** 8 — mount each tool's declared commandSpecs. */
76
+ readonly mount: 8;
77
+ /** 9 — lazy, memoized initialize() for the invoked subcommand's owner. */
78
+ readonly initialize: 9;
79
+ /** 10 — Commander dispatches the action body through the mount pipeline. */
80
+ readonly dispatch: 10;
81
+ };
82
+ /**
83
+ * Drive the STARTUP-phase command-mount step (step 8) for every registered
84
+ * tool. By the time this runs, steps 1-4 have already populated `registry`
85
+ * inside {@link bootstrapCli} (provenance no longer matters — bundled and
86
+ * installed tools mount identically). This is the single ordered entry point
87
+ * the composition root calls for step 8, replacing the bare
88
+ * `mountAllToolCommands(...)` call so the lifecycle has one named seam.
89
+ *
90
+ * Kept THIN deliberately: it delegates straight to
91
+ * {@link mountAllToolCommands}, which mounts each tool's declared `commandSpecs`
92
+ * (the one command surface, launch) with per-tool failure isolation. The naming +
93
+ * ordering is the value here, not new logic.
94
+ *
95
+ * @param registry The per-invocation tool registry, already populated by
96
+ * steps 1-4.
97
+ * @param program The root Commander program (host-owned; passed in since the tool
98
+ * context no longer carries it, §8).
99
+ * @param ctx The per-invocation handler context handed to each mounted command.
100
+ */
101
+ export declare function mountToolCommands(registry: ToolRegistry, program: CliProgram, ctx: ToolCliContext): void;
102
+ //# sourceMappingURL=tool-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-lifecycle.d.ts","sourceRoot":"","sources":["../../src/bootstrap/tool-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;IAC/B,oDAAoD;;IAEpD,mEAAmE;;IAEnE,0EAA0E;;IAE1E,uEAAuE;;IAEvE,+DAA+D;;IAE/D,sDAAsD;;IAEtD,gFAAgF;;IAEhF,mDAAmD;;IAEnD,0EAA0E;;IAE1E,4EAA4E;;CAEpE,CAAC;AAEX;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,cAAc,GAClB,IAAI,CAEN"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * tool-lifecycle — the NAMED, ordered tool-admission lifecycle (release
3
+ * launch, §5.4). A thin sequencer/driver that documents + orders the existing
4
+ * bootstrap calls into one canonical sequence, rather than re-architecting the
5
+ * individual hooks (which keep their own homes and contracts).
6
+ *
7
+ * The 10 steps span two temporal phases of a CLI invocation:
8
+ *
9
+ * ── STARTUP (once per process, composition root) ──────────────────────────
10
+ * 1. DISCOVER — enumerate tool sources: bundled first-party
11
+ * ({@link registerFirstPartyTools}) + on-disk packages
12
+ * ({@link discoverAndRegisterToolPackages} via
13
+ * `discoverToolPackagesFromAnchors`).
14
+ * 2. COMPAT — run each candidate's static `package.json#opensipTools`
15
+ * manifest through the `admitTool` compatibility gate. Bundled = fail-
16
+ * closed; installed = best-effort skip; project-local = trust-gated.
17
+ * 3. TRUST — deny-by-default trust check for project-local executable
18
+ * tools (`admitProjectLocalTool`), BEFORE any module import.
19
+ * 4. IMPORT — dynamic-`import()` an admitted installed/project-local
20
+ * package's entry, then VALIDATE the exported `tool` shape
21
+ * (`isValidTool`) and REGISTER it into the `ToolRegistry`
22
+ * (first-writer-wins). Steps 1-4 all complete inside {@link bootstrapCli}.
23
+ * 8. MOUNT — walk the registry and mount each tool's declared
24
+ * `commandSpecs` ({@link mountAllToolCommands}). Provenance stops mattering
25
+ * here, so bundled and installed tools share the identical mount path.
26
+ *
27
+ * ── PER-RUN (per invocation, pre-action hook) ─────────────────────────────
28
+ * 5. CONFIG — compose every tool's `config` Zod block into one strict
29
+ * whole-document schema and validate the config file once
30
+ * (`composeAndValidateToolConfig`).
31
+ * 6. SCOPE — each tool contributes its per-run subscope
32
+ * (`tool.contributeScope()`); the kernel `Object.assign`s it onto the
33
+ * `RunScope` before `enterScope`.
34
+ * 7. CAPABILITIES — wire the per-run capability registry: register each
35
+ * manifest's declared domains, then replace the deferred placeholder with
36
+ * the owning tool's real registrar (`wireCapabilityRegistry`).
37
+ * 9. INITIALIZE — lazy, memoized `tool.initialize()` for the tool owning the
38
+ * invoked subcommand, exactly once per process, after `enterScope`
39
+ * (`maybeInitializeOwningTool`).
40
+ * 10. DISPATCH — Commander invokes the command's action body; the
41
+ * `mountCommandSpec` pipeline (parse → handler → dispatch → error → exit)
42
+ * runs the tool's handler.
43
+ *
44
+ * Steps 5-7, 9, 10 are inherently per-invocation (they read the entered
45
+ * `RunScope`) and live in `pre-action-hook.ts`; this module does NOT move them
46
+ * — it names them so the full lifecycle has one documented source of truth and
47
+ * drives the contiguous STARTUP steps (discover→…→register, then mount) through
48
+ * one ordered entry point. The driver is intentionally THIN: it sequences the
49
+ * pre-existing helpers, it does not reimplement them.
50
+ */
51
+ import { mountAllToolCommands } from './register-tools.js';
52
+ /**
53
+ * Canonical, ordered tool-lifecycle steps (launch, §5.4). The numeric
54
+ * values are the step ordinals used in the JSDoc above and in
55
+ * lifecycle-ordering tests; the string keys name each step. This is the single
56
+ * source of truth for the sequence — a test asserts the STARTUP driver fires
57
+ * its steps in this order.
58
+ */
59
+ export const TOOL_LIFECYCLE_STEPS = {
60
+ /** 1 — enumerate bundled + on-disk tool sources. */
61
+ discover: 1,
62
+ /** 2 — `admitTool` compatibility gate over the static manifest. */
63
+ compat: 2,
64
+ /** 3 — deny-by-default trust check for project-local executable tools. */
65
+ trust: 3,
66
+ /** 4 — import an admitted package, validate its shape, register it. */
67
+ import: 4,
68
+ /** 5 — compose + strict-validate every tool's config block. */
69
+ config: 5,
70
+ /** 6 — each tool contributes its per-run subscope. */
71
+ scope: 6,
72
+ /** 7 — wire the per-run capability registry (manifest domains → registrars). */
73
+ capabilities: 7,
74
+ /** 8 — mount each tool's declared commandSpecs. */
75
+ mount: 8,
76
+ /** 9 — lazy, memoized initialize() for the invoked subcommand's owner. */
77
+ initialize: 9,
78
+ /** 10 — Commander dispatches the action body through the mount pipeline. */
79
+ dispatch: 10,
80
+ };
81
+ /**
82
+ * Drive the STARTUP-phase command-mount step (step 8) for every registered
83
+ * tool. By the time this runs, steps 1-4 have already populated `registry`
84
+ * inside {@link bootstrapCli} (provenance no longer matters — bundled and
85
+ * installed tools mount identically). This is the single ordered entry point
86
+ * the composition root calls for step 8, replacing the bare
87
+ * `mountAllToolCommands(...)` call so the lifecycle has one named seam.
88
+ *
89
+ * Kept THIN deliberately: it delegates straight to
90
+ * {@link mountAllToolCommands}, which mounts each tool's declared `commandSpecs`
91
+ * (the one command surface, launch) with per-tool failure isolation. The naming +
92
+ * ordering is the value here, not new logic.
93
+ *
94
+ * @param registry The per-invocation tool registry, already populated by
95
+ * steps 1-4.
96
+ * @param program The root Commander program (host-owned; passed in since the tool
97
+ * context no longer carries it, §8).
98
+ * @param ctx The per-invocation handler context handed to each mounted command.
99
+ */
100
+ export function mountToolCommands(registry, program, ctx) {
101
+ mountAllToolCommands(registry, program, ctx);
102
+ }
103
+ //# sourceMappingURL=tool-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-lifecycle.js","sourceRoot":"","sources":["../../src/bootstrap/tool-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAK3D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,oDAAoD;IACpD,QAAQ,EAAE,CAAC;IACX,mEAAmE;IACnE,MAAM,EAAE,CAAC;IACT,0EAA0E;IAC1E,KAAK,EAAE,CAAC;IACR,uEAAuE;IACvE,MAAM,EAAE,CAAC;IACT,+DAA+D;IAC/D,MAAM,EAAE,CAAC;IACT,sDAAsD;IACtD,KAAK,EAAE,CAAC;IACR,gFAAgF;IAChF,YAAY,EAAE,CAAC;IACf,mDAAmD;IACnD,KAAK,EAAE,CAAC;IACR,0EAA0E;IAC1E,UAAU,EAAE,CAAC;IACb,4EAA4E;IAC5E,QAAQ,EAAE,EAAE;CACJ,CAAC;AAEX;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAsB,EACtB,OAAmB,EACnB,GAAmB;IAEnB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * tool-trust — the project-local executable-tool trust policy (release
3
+ * launch, Phase 3 Task 3.2).
4
+ *
5
+ * A `project-local` tool is authored code under `<project>/opensip-cli/…`
6
+ * that changes with the repo (§5.2.1). Running it imports arbitrary code
7
+ * from the working tree, so the host MUST make the trust decision explicit
8
+ * rather than load-by-presence.
9
+ *
10
+ * Policy for launch (signed off): **deny-by-default for non-interactive
11
+ * runs; admit-with-allowlist when configured.** No interactive prompt UX
12
+ * in this release. The allowlist is a comma/whitespace-separated list of
13
+ * tool ids in the `OPENSIP_CLI_ALLOW_PROJECT_TOOLS` environment variable
14
+ * — a minimal, documented opt-in:
15
+ *
16
+ * OPENSIP_CLI_ALLOW_PROJECT_TOOLS="my-audit, my-lint" # admit by id
17
+ * OPENSIP_CLI_ALLOW_PROJECT_TOOLS="*" # admit all
18
+ *
19
+ * The decision is made BEFORE the tool's module is imported: a disallowed
20
+ * project-local tool is fail-closed (exit 5) without its code ever running.
21
+ */
22
+ /**
23
+ * Environment variable carrying the project-local tool allowlist. Read
24
+ * once per decision (cheap), never cached, so a test can set/unset it
25
+ * around a single call.
26
+ */
27
+ export declare const PROJECT_TOOL_ALLOWLIST_ENV = "OPENSIP_CLI_ALLOW_PROJECT_TOOLS";
28
+ /**
29
+ * Decide whether a project-local executable tool with the given `id` is
30
+ * trusted to load, under the deny-by-default + allowlist-opt-in policy.
31
+ *
32
+ * **Env governance (pre-scope exception).** The allowlist var is declared as a
33
+ * first-class `EnvVarSpec` in `CLI_ENV_SPECS`
34
+ * (`OPENSIP_CLI_ALLOW_PROJECT_TOOLS`, `host-env-specs.ts`) — that declaration
35
+ * is the documentation home, so it appears in the generated env-surface
36
+ * reference. The read here stays on the INJECTED `env` param rather than
37
+ * `hostEnv.get(...)`: this trust check runs at BOOTSTRAP, before any `RunScope`
38
+ * exists, and the injectable seam is what keeps it unit-testable without
39
+ * mutating global `process.env` (the same posture the repo takes for
40
+ * `NODE_OPTIONS`). The `env-via-registry` guardrail is satisfied because this is
41
+ * an injected-param read (`env[...]`), not a raw `process.env.<NAME>` read.
42
+ *
43
+ * @param id The tool's stable id (from its sidecar manifest).
44
+ * @param env The environment to read the allowlist from (defaults to
45
+ * `process.env`; injectable for tests).
46
+ * @returns `true` iff the allowlist contains `id` or the wildcard `'*'`.
47
+ */
48
+ export declare function isProjectLocalToolTrusted(id: string, env?: NodeJS.ProcessEnv): boolean;
49
+ //# sourceMappingURL=tool-trust.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-trust.d.ts","sourceRoot":"","sources":["../../src/bootstrap/tool-trust.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,oCAAoC,CAAC;AAiB5E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,MAAM,EACV,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAGT"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * tool-trust — the project-local executable-tool trust policy (release
3
+ * launch, Phase 3 Task 3.2).
4
+ *
5
+ * A `project-local` tool is authored code under `<project>/opensip-cli/…`
6
+ * that changes with the repo (§5.2.1). Running it imports arbitrary code
7
+ * from the working tree, so the host MUST make the trust decision explicit
8
+ * rather than load-by-presence.
9
+ *
10
+ * Policy for launch (signed off): **deny-by-default for non-interactive
11
+ * runs; admit-with-allowlist when configured.** No interactive prompt UX
12
+ * in this release. The allowlist is a comma/whitespace-separated list of
13
+ * tool ids in the `OPENSIP_CLI_ALLOW_PROJECT_TOOLS` environment variable
14
+ * — a minimal, documented opt-in:
15
+ *
16
+ * OPENSIP_CLI_ALLOW_PROJECT_TOOLS="my-audit, my-lint" # admit by id
17
+ * OPENSIP_CLI_ALLOW_PROJECT_TOOLS="*" # admit all
18
+ *
19
+ * The decision is made BEFORE the tool's module is imported: a disallowed
20
+ * project-local tool is fail-closed (exit 5) without its code ever running.
21
+ */
22
+ /**
23
+ * Environment variable carrying the project-local tool allowlist. Read
24
+ * once per decision (cheap), never cached, so a test can set/unset it
25
+ * around a single call.
26
+ */
27
+ export const PROJECT_TOOL_ALLOWLIST_ENV = 'OPENSIP_CLI_ALLOW_PROJECT_TOOLS';
28
+ /**
29
+ * Parse the allowlist env var into a set of permitted tool ids. Empty/
30
+ * unset ⇒ empty set (deny-by-default). The wildcard `'*'` admits all
31
+ * (surfaced via {@link isProjectLocalToolTrusted}).
32
+ */
33
+ function parseAllowlist(raw) {
34
+ if (!raw)
35
+ return new Set();
36
+ return new Set(raw
37
+ .split(/[\s,]+/)
38
+ .map((s) => s.trim())
39
+ .filter((s) => s.length > 0));
40
+ }
41
+ /**
42
+ * Decide whether a project-local executable tool with the given `id` is
43
+ * trusted to load, under the deny-by-default + allowlist-opt-in policy.
44
+ *
45
+ * **Env governance (pre-scope exception).** The allowlist var is declared as a
46
+ * first-class `EnvVarSpec` in `CLI_ENV_SPECS`
47
+ * (`OPENSIP_CLI_ALLOW_PROJECT_TOOLS`, `host-env-specs.ts`) — that declaration
48
+ * is the documentation home, so it appears in the generated env-surface
49
+ * reference. The read here stays on the INJECTED `env` param rather than
50
+ * `hostEnv.get(...)`: this trust check runs at BOOTSTRAP, before any `RunScope`
51
+ * exists, and the injectable seam is what keeps it unit-testable without
52
+ * mutating global `process.env` (the same posture the repo takes for
53
+ * `NODE_OPTIONS`). The `env-via-registry` guardrail is satisfied because this is
54
+ * an injected-param read (`env[...]`), not a raw `process.env.<NAME>` read.
55
+ *
56
+ * @param id The tool's stable id (from its sidecar manifest).
57
+ * @param env The environment to read the allowlist from (defaults to
58
+ * `process.env`; injectable for tests).
59
+ * @returns `true` iff the allowlist contains `id` or the wildcard `'*'`.
60
+ */
61
+ export function isProjectLocalToolTrusted(id, env = process.env) {
62
+ const allow = parseAllowlist(env[PROJECT_TOOL_ALLOWLIST_ENV]);
63
+ return allow.has('*') || allow.has(id);
64
+ }
65
+ //# sourceMappingURL=tool-trust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-trust.js","sourceRoot":"","sources":["../../src/bootstrap/tool-trust.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,iCAAiC,CAAC;AAE5E;;;;GAIG;AACH,SAAS,cAAc,CAAC,GAAuB;IAC7C,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,GAAG,EAAE,CAAC;IAC3B,OAAO,IAAI,GAAG,CACZ,GAAG;SACA,KAAK,CAAC,QAAQ,CAAC;SACf,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAC/B,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,yBAAyB,CACvC,EAAU,EACV,MAAyB,OAAO,CAAC,GAAG;IAEpC,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC,CAAC;IAC9D,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Runtime shape validation for third-party `tool` exports — the
3
+ * untrusted boundary where `discoverAndRegisterToolPackages` imports
4
+ * an arbitrary npm package and inspects whatever it exports.
5
+ *
6
+ * Verifies the minimal contract the registry depends on: a
7
+ * `metadata.id` string (used for dedupe + listing), a `commands` array,
8
+ * and a command surface — a non-empty `commandSpecs` array (the one command
9
+ * surface as of launch; `register()` was removed). A tool with no `commandSpecs`
10
+ * cannot mount any command, so it fails the shape check. `initialize` and
11
+ * `contributeScope` stay optional per the Tool interface.
12
+ *
13
+ * Ordering vs. the admission gate: this shape check runs AFTER a
14
+ * tool's module is imported. The compatibility gate (`admitTool`) and the
15
+ * project-local TRUST gate (`admitProjectLocalTool`, deny-by-default) run
16
+ * on the STATIC manifest *before* import — so a project-local executable
17
+ * tool that is not allowlisted is fail-closed without its code ever running,
18
+ * and never reaches `isValidTool`.
19
+ */
20
+ import type { Tool } from '@opensip-cli/core';
21
+ export declare function isValidTool(value: unknown): value is Tool;
22
+ //# sourceMappingURL=validate-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-tool.d.ts","sourceRoot":"","sources":["../../src/bootstrap/validate-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAgBzD"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Runtime shape validation for third-party `tool` exports — the
3
+ * untrusted boundary where `discoverAndRegisterToolPackages` imports
4
+ * an arbitrary npm package and inspects whatever it exports.
5
+ *
6
+ * Verifies the minimal contract the registry depends on: a
7
+ * `metadata.id` string (used for dedupe + listing), a `commands` array,
8
+ * and a command surface — a non-empty `commandSpecs` array (the one command
9
+ * surface as of launch; `register()` was removed). A tool with no `commandSpecs`
10
+ * cannot mount any command, so it fails the shape check. `initialize` and
11
+ * `contributeScope` stay optional per the Tool interface.
12
+ *
13
+ * Ordering vs. the admission gate: this shape check runs AFTER a
14
+ * tool's module is imported. The compatibility gate (`admitTool`) and the
15
+ * project-local TRUST gate (`admitProjectLocalTool`, deny-by-default) run
16
+ * on the STATIC manifest *before* import — so a project-local executable
17
+ * tool that is not allowlisted is fail-closed without its code ever running,
18
+ * and never reaches `isValidTool`.
19
+ */
20
+ export function isValidTool(value) {
21
+ if (typeof value !== 'object' || value === null)
22
+ return false;
23
+ const candidate = value;
24
+ if (typeof candidate.metadata !== 'object' || candidate.metadata === null)
25
+ return false;
26
+ if (typeof candidate.metadata.id !== 'string')
27
+ return false;
28
+ if (!Array.isArray(candidate.commands))
29
+ return false;
30
+ // A tool must expose a command surface: a non-empty declarative `commandSpecs`
31
+ // array (the one command surface, launch — `register()` was removed). A tool
32
+ // with no commandSpecs cannot contribute any command and is rejected.
33
+ const hasSpecs = Array.isArray(candidate.commandSpecs) && candidate.commandSpecs.length > 0;
34
+ if (!hasSpecs)
35
+ return false;
36
+ return true;
37
+ }
38
+ //# sourceMappingURL=validate-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-tool.js","sourceRoot":"","sources":["../../src/bootstrap/validate-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,SAAS,GAAG,KAIjB,CAAC;IACF,IAAI,OAAO,SAAS,CAAC,QAAQ,KAAK,QAAQ,IAAI,SAAS,CAAC,QAAQ,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACxF,IAAI,OAAQ,SAAS,CAAC,QAA6B,CAAC,EAAE,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAClF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IACrD,+EAA+E;IAC/E,6EAA6E;IAC7E,sEAAsE;IACtE,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5F,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * cli-context — the thin `ToolCliContext` assembler (host-owned-run-timing
3
+ * Phase 6). `buildToolCliContext` wires together the focused host planes —
4
+ * output, egress, run, live, baseline, state, host-planes — into the single
5
+ * coherent context handed to each tool and host command. Each concern's logic
6
+ * lives in its own `bootstrap/*-plane` (or `*-seams`) module; this file only
7
+ * composes them and exposes the `scope` getter + the assembled context.
8
+ *
9
+ * There is NO module-global bootstrap-handoff bag. The populated registries +
10
+ * admitted-tool manifests/provenance are captured in the pre-action-hook closure
11
+ * (`installPreActionHook` is called AFTER `bootstrapCli` in `main()`), the hook
12
+ * builds + enters the per-run `RunScope`, and from there every per-run read
13
+ * (project, datastore, manifests, provenance, …) goes through `currentScope()`.
14
+ *
15
+ * Lazy datastore: a closure-based thunk caches the open DataStore on first access and
16
+ * lands on `RunScope.datastore`; paths that never touch it never materialise
17
+ * `.runtime/datastore.sqlite`.
18
+ */
19
+ import { type Logger, type ToolCliContext } from '@opensip-cli/core';
20
+ import { type LiveViewRegistry } from './bootstrap/live-plane.js';
21
+ import type { CommandResult } from '@opensip-cli/contracts';
22
+ export { buildDatastoreThunk, getCurrentProjectRoot, getOrOpenDatastore, } from './bootstrap/scope-access.js';
23
+ export { createLiveViewRegistry, type LiveViewRegistry } from './bootstrap/live-plane.js';
24
+ export interface BuildToolCliContextOptions {
25
+ readonly render: (result: CommandResult) => Promise<void>;
26
+ readonly liveViews: LiveViewRegistry;
27
+ readonly maybeOpenReport: (opts: {
28
+ openRequested: boolean;
29
+ jsonOutput: boolean;
30
+ }) => Promise<void>;
31
+ readonly logger?: Logger;
32
+ }
33
+ export interface ToolCliContextHandle {
34
+ readonly ctx: ToolCliContext;
35
+ readonly getExitCode: () => number | undefined;
36
+ }
37
+ export declare function buildToolCliContext(opts: BuildToolCliContextOptions): ToolCliContextHandle;
38
+ //# sourceMappingURL=cli-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-context.d.ts","sourceRoot":"","sources":["../src/cli-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAWnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAsB5D,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE1F,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,eAAe,EAAE,CAAC,IAAI,EAAE;QAC/B,aAAa,EAAE,OAAO,CAAC;QACvB,UAAU,EAAE,OAAO,CAAC;KACrB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CAChD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,0BAA0B,GAAG,oBAAoB,CA2F1F"}