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,95 @@
1
+ /**
2
+ * init command — scaffold the project layout.
3
+ *
4
+ * Registry-driven (ADR-0038): `init` scaffolds one directory tree per
5
+ * REGISTERED tool, never a hardcoded fit/sim pair. Each tool owns its own
6
+ * example bytes + config block; the host owns only the directory layout
7
+ * (`pluginLayout`), the document header, and `targets:`. With the bundled
8
+ * fitness + simulation tools registered, a TypeScript project gets:
9
+ * <cwd>/opensip-cli.config.yml (TRACKED)
10
+ * <cwd>/opensip-cli/fit/checks/example-check.mjs (TRACKED)
11
+ * <cwd>/opensip-cli/fit/recipes/example-recipe.mjs (TRACKED)
12
+ * <cwd>/opensip-cli/sim/scenarios/example-scenario.mjs (TRACKED)
13
+ * <cwd>/opensip-cli/sim/recipes/example-recipe.mjs (TRACKED)
14
+ * A tool with no `pluginLayout` (e.g. `graph`) contributes no directory.
15
+ *
16
+ * Consequence — the scaffolded set equals the REGISTERED set:
17
+ * - A tool installed AFTER `init` scaffolds on the next `init --keep`.
18
+ * - Back-compat behavior shift: if a bundled tool fails to load, init
19
+ * now scaffolds FEWER dirs (vs the old always-fit/sim). A bundled tool
20
+ * that's expected but absent is surfaced loudly via the
21
+ * `cli.tool.expected_bundled_absent` diagnostic (bootstrap) so a silent
22
+ * under-scaffold is observable; a genuinely uninstalled third-party
23
+ * tool stays silent (correct).
24
+ *
25
+ * Appends `opensip-cli/.runtime/` to <cwd>/.gitignore so the
26
+ * tool-generated state (sessions, logs, dashboards, baselines, plugin
27
+ * installs) stays untracked.
28
+ *
29
+ * Promotion path: when a customer's pack outgrows a handful of .mjs
30
+ * files (shared helpers, tests, more than a dozen checks/scenarios),
31
+ * `opensip-cli/<domain>/` can graduate to a real workspace npm
32
+ * package — `package.json` with `opensipTools.kind: "fit-pack"` or
33
+ * `"sim-pack"`, `tsconfig.json`, `index.ts` re-exporting checks/recipes.
34
+ * Marker-based discovery picks up the workspace package automatically
35
+ * regardless of npm scope. The init scaffold stays loose-`.mjs` to
36
+ * preserve the fast first-touch experience; graduation is a manual
37
+ * step the customer takes when their coverage becomes substantial.
38
+ * See docs/public/50-extend/01-plugin-authoring.md.
39
+ *
40
+ * Language selection drives:
41
+ * - which `targets:` entry shape goes into the YAML config
42
+ * - the `scope.languages` field on the example check
43
+ *
44
+ * `--language <list>` (comma-separated) overrides detection.
45
+ * Detection inspects filesystem markers (Cargo.toml, pyproject.toml,
46
+ * go.mod, pom.xml/build.gradle, CMakeLists.txt, package.json+tsconfig).
47
+ * When detection is ambiguous AND --language is missing, init exits
48
+ * 2 with a helpful prompt — no partial scaffolding.
49
+ *
50
+ * Partial-state handling:
51
+ *
52
+ * After language resolution, init classifies the working directory
53
+ * into one of four states based on the presence of the config file
54
+ * and the `opensip-cli/` directory:
55
+ *
56
+ * - 'pristine' — neither present; scaffold everything.
57
+ * - 'fully-initialized' — both present; refuse without a flag.
58
+ * - 'partial-config-only' — config XOR dir; refuse without a flag.
59
+ * - 'partial-dir-only' — config XOR dir; refuse without a flag.
60
+ *
61
+ * Two flags express explicit user intent for the non-pristine states:
62
+ *
63
+ * - `--keep` — re-scaffold examples; preserve custom files.
64
+ * - `--remove` — delete `opensip-cli/` entirely; scaffold fresh.
65
+ *
66
+ * The two flags are mutually exclusive. The legacy `--force` flag is
67
+ * gone; users who scripted it should migrate to `--remove`, the
68
+ * closest semantic match.
69
+ *
70
+ * Implementation is split across `./init/` siblings:
71
+ * - language-detection.ts — marker scanning + `--language` parsing
72
+ * - config-templates.ts — host-owned YAML document skeleton (header +
73
+ * targets); per-tool config blocks come from
74
+ * each tool's `scaffoldConfigBlock()`
75
+ * - file-classifier.ts — scaffolded / stale / custom tagging
76
+ * - state-machine.ts — working-dir state + refusal messages
77
+ * - scaffold-writer.ts — disk writes + gitignore patching
78
+ *
79
+ * This file is the orchestrator: argument validation → language
80
+ * resolution → state classification → file classification → scaffold
81
+ * (or refuse).
82
+ */
83
+ import { type ProjectContext } from '@opensip-cli/core';
84
+ import type { ToolScaffold } from './shared.js';
85
+ import type { InitOptions, InitResult } from '@opensip-cli/contracts';
86
+ /**
87
+ * Run init for the given args. Returns an InitResult — the caller
88
+ * (CLI render layer) prints it.
89
+ */
90
+ export declare function executeInit(args: InitOptions & {
91
+ projectContext?: ProjectContext;
92
+ cwdExplicit?: boolean;
93
+ toolScaffolds: readonly ToolScaffold[];
94
+ }): InitResult;
95
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AAIH,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAW7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,WAAW,GAAG;IAClB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,SAAS,YAAY,EAAE,CAAC;CACxC,GACA,UAAU,CAsIZ"}
@@ -0,0 +1,209 @@
1
+ /**
2
+ * init command — scaffold the project layout.
3
+ *
4
+ * Registry-driven (ADR-0038): `init` scaffolds one directory tree per
5
+ * REGISTERED tool, never a hardcoded fit/sim pair. Each tool owns its own
6
+ * example bytes + config block; the host owns only the directory layout
7
+ * (`pluginLayout`), the document header, and `targets:`. With the bundled
8
+ * fitness + simulation tools registered, a TypeScript project gets:
9
+ * <cwd>/opensip-cli.config.yml (TRACKED)
10
+ * <cwd>/opensip-cli/fit/checks/example-check.mjs (TRACKED)
11
+ * <cwd>/opensip-cli/fit/recipes/example-recipe.mjs (TRACKED)
12
+ * <cwd>/opensip-cli/sim/scenarios/example-scenario.mjs (TRACKED)
13
+ * <cwd>/opensip-cli/sim/recipes/example-recipe.mjs (TRACKED)
14
+ * A tool with no `pluginLayout` (e.g. `graph`) contributes no directory.
15
+ *
16
+ * Consequence — the scaffolded set equals the REGISTERED set:
17
+ * - A tool installed AFTER `init` scaffolds on the next `init --keep`.
18
+ * - Back-compat behavior shift: if a bundled tool fails to load, init
19
+ * now scaffolds FEWER dirs (vs the old always-fit/sim). A bundled tool
20
+ * that's expected but absent is surfaced loudly via the
21
+ * `cli.tool.expected_bundled_absent` diagnostic (bootstrap) so a silent
22
+ * under-scaffold is observable; a genuinely uninstalled third-party
23
+ * tool stays silent (correct).
24
+ *
25
+ * Appends `opensip-cli/.runtime/` to <cwd>/.gitignore so the
26
+ * tool-generated state (sessions, logs, dashboards, baselines, plugin
27
+ * installs) stays untracked.
28
+ *
29
+ * Promotion path: when a customer's pack outgrows a handful of .mjs
30
+ * files (shared helpers, tests, more than a dozen checks/scenarios),
31
+ * `opensip-cli/<domain>/` can graduate to a real workspace npm
32
+ * package — `package.json` with `opensipTools.kind: "fit-pack"` or
33
+ * `"sim-pack"`, `tsconfig.json`, `index.ts` re-exporting checks/recipes.
34
+ * Marker-based discovery picks up the workspace package automatically
35
+ * regardless of npm scope. The init scaffold stays loose-`.mjs` to
36
+ * preserve the fast first-touch experience; graduation is a manual
37
+ * step the customer takes when their coverage becomes substantial.
38
+ * See docs/public/50-extend/01-plugin-authoring.md.
39
+ *
40
+ * Language selection drives:
41
+ * - which `targets:` entry shape goes into the YAML config
42
+ * - the `scope.languages` field on the example check
43
+ *
44
+ * `--language <list>` (comma-separated) overrides detection.
45
+ * Detection inspects filesystem markers (Cargo.toml, pyproject.toml,
46
+ * go.mod, pom.xml/build.gradle, CMakeLists.txt, package.json+tsconfig).
47
+ * When detection is ambiguous AND --language is missing, init exits
48
+ * 2 with a helpful prompt — no partial scaffolding.
49
+ *
50
+ * Partial-state handling:
51
+ *
52
+ * After language resolution, init classifies the working directory
53
+ * into one of four states based on the presence of the config file
54
+ * and the `opensip-cli/` directory:
55
+ *
56
+ * - 'pristine' — neither present; scaffold everything.
57
+ * - 'fully-initialized' — both present; refuse without a flag.
58
+ * - 'partial-config-only' — config XOR dir; refuse without a flag.
59
+ * - 'partial-dir-only' — config XOR dir; refuse without a flag.
60
+ *
61
+ * Two flags express explicit user intent for the non-pristine states:
62
+ *
63
+ * - `--keep` — re-scaffold examples; preserve custom files.
64
+ * - `--remove` — delete `opensip-cli/` entirely; scaffold fresh.
65
+ *
66
+ * The two flags are mutually exclusive. The legacy `--force` flag is
67
+ * gone; users who scripted it should migrate to `--remove`, the
68
+ * closest semantic match.
69
+ *
70
+ * Implementation is split across `./init/` siblings:
71
+ * - language-detection.ts — marker scanning + `--language` parsing
72
+ * - config-templates.ts — host-owned YAML document skeleton (header +
73
+ * targets); per-tool config blocks come from
74
+ * each tool's `scaffoldConfigBlock()`
75
+ * - file-classifier.ts — scaffolded / stale / custom tagging
76
+ * - state-machine.ts — working-dir state + refusal messages
77
+ * - scaffold-writer.ts — disk writes + gitignore patching
78
+ *
79
+ * This file is the orchestrator: argument validation → language
80
+ * resolution → state classification → file classification → scaffold
81
+ * (or refuse).
82
+ */
83
+ import { existsSync } from 'node:fs';
84
+ import { resolveProjectPaths } from '@opensip-cli/core';
85
+ import { classifyFiles } from './init/file-classifier.js';
86
+ import { resolveLanguages } from './init/language-detection.js';
87
+ import { runScaffold } from './init/scaffold-writer.js';
88
+ import { buildPartialStateMessage, classifyWorkingDir, formatInsideExistingProjectMessage, } from './init/state-machine.js';
89
+ /**
90
+ * Run init for the given args. Returns an InitResult — the caller
91
+ * (CLI render layer) prints it.
92
+ */
93
+ export function executeInit(args) {
94
+ const cwd = args.cwd;
95
+ const keep = args.keep === true;
96
+ const remove = args.remove === true;
97
+ const paths = resolveProjectPaths(cwd);
98
+ const baseResult = {
99
+ type: 'init',
100
+ path: paths.configFile,
101
+ cwd,
102
+ configFilename: 'opensip-cli.config.yml',
103
+ };
104
+ // Discovery-aware refusal: if cwd sits inside an existing project and
105
+ // the user did NOT pass --cwd explicitly, offer the three corrective
106
+ // actions instead of silently scaffolding a phantom nested project.
107
+ const project = args.projectContext;
108
+ const cwdExplicit = args.cwdExplicit === true;
109
+ if (project?.scope === 'project' && project.projectRoot !== cwd && !cwdExplicit) {
110
+ const message = formatInsideExistingProjectMessage(project.projectRoot);
111
+ return {
112
+ ...baseResult,
113
+ path: '', // no scaffold target — we refused
114
+ created: false,
115
+ insideExistingProject: {
116
+ discoveredRoot: project.projectRoot,
117
+ message,
118
+ },
119
+ };
120
+ }
121
+ // Mutex: --keep and --remove are mutually exclusive.
122
+ if (keep && remove) {
123
+ return {
124
+ ...baseResult,
125
+ created: false,
126
+ partialStateError: {
127
+ state: 'fully-initialized',
128
+ preExistingFiles: [],
129
+ message: '--keep and --remove are mutually exclusive. Pick one.',
130
+ },
131
+ };
132
+ }
133
+ if (!existsSync(cwd)) {
134
+ // A non-existent target directory is a user error, not a "pristine
135
+ // success". Surface it through `ambiguousLanguageError` (which the
136
+ // register-init layer already maps to CONFIGURATION_ERROR / exit 2)
137
+ // so `opensip init --cwd /nonexistent` returns a nonzero exit
138
+ // code with a clear message instead of silently exiting 0.
139
+ return {
140
+ ...baseResult,
141
+ created: false,
142
+ ambiguousLanguageError: {
143
+ detected: [],
144
+ message: `Target directory does not exist: ${cwd}`,
145
+ },
146
+ };
147
+ }
148
+ const resolution = resolveLanguages(cwd, args.language);
149
+ if (!resolution.ok) {
150
+ return { ...baseResult, created: false, ambiguousLanguageError: resolution.error };
151
+ }
152
+ const { languages } = resolution;
153
+ const state = classifyWorkingDir(paths);
154
+ const preExistingFiles = state === 'pristine' ? [] : classifyFiles(paths, languages, args.toolScaffolds);
155
+ // Pristine: scaffold and exit. No flag interaction needed.
156
+ if (state === 'pristine') {
157
+ return runScaffold({
158
+ paths,
159
+ languages,
160
+ cwd,
161
+ state,
162
+ preExistingFiles: [],
163
+ removeFirst: false,
164
+ keepCustom: false,
165
+ toolScaffolds: args.toolScaffolds,
166
+ }, baseResult);
167
+ }
168
+ // Non-pristine without an explicit flag: refuse with partial-state
169
+ // error.
170
+ if (!keep && !remove) {
171
+ return {
172
+ ...baseResult,
173
+ created: false,
174
+ state,
175
+ languages,
176
+ preExistingFiles,
177
+ partialStateError: {
178
+ state,
179
+ preExistingFiles,
180
+ message: buildPartialStateMessage(state, preExistingFiles, cwd),
181
+ },
182
+ };
183
+ }
184
+ // --remove: blow away the dir, then scaffold from zero.
185
+ if (remove) {
186
+ return runScaffold({
187
+ paths,
188
+ languages,
189
+ cwd,
190
+ state,
191
+ preExistingFiles,
192
+ removeFirst: true,
193
+ keepCustom: false,
194
+ toolScaffolds: args.toolScaffolds,
195
+ }, baseResult);
196
+ }
197
+ // --keep: re-scaffold examples; preserve custom + stale-scaffolded files.
198
+ return runScaffold({
199
+ paths,
200
+ languages,
201
+ cwd,
202
+ state,
203
+ preExistingFiles,
204
+ removeFirst: false,
205
+ keepCustom: true,
206
+ toolScaffolds: args.toolScaffolds,
207
+ }, baseResult);
208
+ }
209
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;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zB,OAAO,WAAW,CAChB;YACE,KAAK;YACL,SAAS;YACT,GAAG;YACH,KAAK;YACL,gBAAgB,EAAE,EAAE;YACpB,WAAW,EAAE,KAAK;YAClB,UAAU,EAAE,KAAK;YACjB,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,EACD,UAAU,CACX,CAAC;IACJ,CAAC;IAED,mEAAmE;IACnE,SAAS;IACT,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACrB,OAAO;YACL,GAAG,UAAU;YACb,OAAO,EAAE,KAAK;YACd,KAAK;YACL,SAAS;YACT,gBAAgB;YAChB,iBAAiB,EAAE;gBACjB,KAAK;gBACL,gBAAgB;gBAChB,OAAO,EAAE,wBAAwB,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,CAAC;aAChE;SACF,CAAC;IACJ,CAAC;IAED,wDAAwD;IACxD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,WAAW,CAChB;YACE,KAAK;YACL,SAAS;YACT,GAAG;YACH,KAAK;YACL,gBAAgB;YAChB,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,KAAK;YACjB,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,EACD,UAAU,CACX,CAAC;IACJ,CAAC;IAED,0EAA0E;IAC1E,OAAO,WAAW,CAChB;QACE,KAAK;QACL,SAAS;QACT,GAAG;QACH,KAAK;QACL,gBAAgB;QAChB,WAAW,EAAE,KAAK;QAClB,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,IAAI,CAAC,aAAa;KAClC,EACD,UAAU,CACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * mount-command-spec — the host-owned layer that turns a declarative
3
+ * {@link CommandSpec} (core, Phase 0) into a wired Commander command.
4
+ *
5
+ * Generalizes {@link mountResultCommand}: it mounts ANY command (tool or host)
6
+ * from its typed spec — translating each `OptionSpec`/`ArgSpec` into Commander
7
+ * wiring, applying the shared common flags (ADR-0021), and owning the uniform
8
+ * `parse → handler → dispatch output → map error → exit` pipeline. Tools never
9
+ * touch Commander; they export specs and the host mounts them (north-star §5.4).
10
+ *
11
+ * The single output-dispatch seam — {@link dispatchOutput} — wraps every machine
12
+ * output in a `CommandOutcome` serialized through the one `renderOutcome` seam.
13
+ * The wrap lives in the host emit seams this delegates to (`emitCommandResult`,
14
+ * `ctx.emitEnvelope`), so the handler contract stayed byte-identical (§5.5).
15
+ */
16
+ import { type CliProgram, type CommandResult } from '@opensip-cli/contracts';
17
+ import { type LiveViewContext, type ToolRunCompletion, type CommandSpec, type ToolCliContext } from '@opensip-cli/core';
18
+ /**
19
+ * A {@link CommandSpec} whose handler receives the concrete host
20
+ * {@link ToolCliContext} (render/envelope/live-view emitters), not the kernel's
21
+ * unconstrained {@link CommandContext} marker. The host mounts THIS shape — the
22
+ * mounter is the only place that knows the real context type, so it pins it
23
+ * here. Tools author specs with `defineCommand<TOpts, ToolCliContext>(...)`.
24
+ */
25
+ export type HostCommandSpec<TOpts = Record<string, unknown>> = CommandSpec<TOpts, ToolCliContext>;
26
+ /**
27
+ * The minimal context surface {@link mountCommandSpec} / {@link dispatchOutput}
28
+ * actually touch — the mount layer's structural dependency, decoupled from the
29
+ * full handler-facing context.
30
+ *
31
+ * `render` + `setExitCode` are used by EVERY command (the `command-result`
32
+ * dispatch arm and the thrown-`ToolError` exit-code path). `emitEnvelope` /
33
+ * `renderLive` are used ONLY by the `signal-envelope` / `live-view` arms, so
34
+ * they are optional here: a context that mounts only `command-result` /
35
+ * `raw-stream` commands (the CLI-owned HOST commands) need not provide them.
36
+ * `dispatchOutput` guards those arms and throws if the mode is requested without
37
+ * the corresponding emitter — a mis-declared host spec fails loudly rather than
38
+ * silently no-op'ing.
39
+ *
40
+ * `ToolCliContext` (which provides all four as required members) is structurally
41
+ * assignable to this — so the existing tool-mount call sites pass unchanged. The
42
+ * generic `mountCommandSpec` lets host commands mount with a leaner context
43
+ * (`CliCommandsContext`) through the SAME plane, satisfying the launch "one
44
+ * command surface" invariant (no two-tier privilege).
45
+ */
46
+ export interface CommandMountContext {
47
+ readonly render: (result: CommandResult) => Promise<void>;
48
+ readonly setExitCode: (code: number) => void;
49
+ readonly emitEnvelope?: (envelope: unknown) => void;
50
+ /**
51
+ * Optional live view dispatch. When the command declares output:'live-view',
52
+ * the host calls this with an optional third argument carrying the LiveViewContext
53
+ * (with the host runSession). The impl (registry) forwards it as the second
54
+ * arg to the registered renderer fn.
55
+ */
56
+ readonly renderLive?: (key: string, args: unknown, liveContext?: LiveViewContext) => Promise<ToolRunCompletion | void>;
57
+ }
58
+ /**
59
+ * Mount a declarative {@link CommandSpec} onto `program` as a fully wired
60
+ * Commander command.
61
+ *
62
+ * Steps (mirroring each tool's former hand-rolled `register()` body, now
63
+ * host-owned and uniform):
64
+ * 1. `program.command(name)` + description + aliases.
65
+ * 2. `applyCommonFlags(cmd, spec.commonFlags)` — the ADR-0021 registry flags.
66
+ * `cwd` (the only computed default) is seeded with `process.cwd()`.
67
+ * 3. Each {@link OptionSpec} → a Commander `Option` (value vs boolean,
68
+ * `negatable` `--no-` form, `default` / `arrayDefault`, `choices`,
69
+ * `parse` argParser, `variadic`, `required` mandatory).
70
+ * 4. Each {@link ArgSpec} → `cmd.argument(...)` (variadic / optional bracketing).
71
+ * 5. `cmd.action(...)` → run `spec.handler(opts, ctx)` → {@link dispatchOutput}
72
+ * → on a thrown {@link ToolError}, `mapToolErrorToExitCode` → `ctx.setExitCode`.
73
+ *
74
+ * @param program The root Commander program (the entry layer's `CliProgram`).
75
+ * @param spec The declarative command surface the tool/host exported.
76
+ * @param ctx The per-invocation host context (render/envelope/live-view
77
+ * emitters, exit-code setter) — today's `ToolCliContext`.
78
+ */
79
+ export declare function mountCommandSpec<TCtx extends CommandMountContext>(program: CliProgram, spec: CommandSpec<unknown, TCtx>, ctx: TCtx): void;
80
+ /**
81
+ * The SINGLE output-dispatch seam. The launch `CommandOutcome` wrap is LANDED:
82
+ * the host emit seams this delegates to (`emitCommandResult`, `ctx.emitEnvelope`)
83
+ * now build a `CommandOutcome` and serialize it through the one `renderOutcome`
84
+ * seam. The handler contract and the mounter above stayed byte-identical — all
85
+ * the outer-shape change landed in those seams (north-star §5.5), so the handler
86
+ * keeps returning its pure-domain `CommandResult` / `SignalEnvelope`.
87
+ *
88
+ * Routes the handler's return value by the command's declared
89
+ * {@link CommandSpec.output} mode:
90
+ * - `command-result` — the existing `emitCommandResult` seam (json
91
+ * short-circuit / `ctx.render`), shared verbatim with
92
+ * {@link mountResultCommand}.
93
+ * - `signal-envelope` — the run-envelope machine-output path: `--json` emits
94
+ * through `ctx.emitEnvelope` (the shared ADR-0011
95
+ * formatter), otherwise `ctx.render`.
96
+ * - `raw-stream` — explicit raw output (no Ink): the handler already
97
+ * wrote its file + line; the host renders nothing.
98
+ * - `live-view` — the interactive Ink path: `ctx.renderLive(key, args)`
99
+ * against the tool's registered renderer.
100
+ *
101
+ * @throws {Error} When a command declares `signal-envelope` / `live-view` output
102
+ * but the mount context provides no `emitEnvelope` / `renderLive` emitter — a
103
+ * mis-declared host spec fails loudly here rather than silently no-op'ing.
104
+ */
105
+ export declare function dispatchOutput<TCtx extends CommandMountContext>(result: unknown, spec: CommandSpec<unknown, TCtx>, opts: Record<string, unknown>, positionals: readonly unknown[], ctx: TCtx): Promise<void>;
106
+ //# sourceMappingURL=mount-command-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount-command-spec.d.ts","sourceRoot":"","sources":["../../src/commands/mount-command-spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EAGtB,KAAK,WAAW,EAEhB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAO3B;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,CAAC,KAAK,GAAG,MAAM,C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