@skaile/workspaces 2.1.0 → 2.3.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 (198) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +33 -3
  3. package/dist/{asset-feeds-FBGBQEYD.js → asset-feeds-DKNYRLED.js} +10 -10
  4. package/dist/{asset-feeds-FBGBQEYD.js.map → asset-feeds-DKNYRLED.js.map} +1 -1
  5. package/dist/asset-manager/catalog-deployer.js +5 -5
  6. package/dist/asset-manager/index.js +9 -9
  7. package/dist/asset-manager/installer.js +6 -6
  8. package/dist/bridge/drivers/claude-sdk.js +9 -6
  9. package/dist/bridge/drivers/claude-sdk.js.map +1 -1
  10. package/dist/bridge/drivers/codex.js +1 -1
  11. package/dist/bridge/drivers/continue.js +2 -2
  12. package/dist/bridge/drivers/echo.js +1 -1
  13. package/dist/bridge/drivers/gemini.js +3 -3
  14. package/dist/bridge/drivers/goose.js +2 -2
  15. package/dist/bridge/drivers/omp.js +1 -1
  16. package/dist/bridge/drivers/opencode.js +2 -2
  17. package/dist/bridge/drivers/qwen.js +3 -3
  18. package/dist/bridge/index.js +2 -2
  19. package/dist/bridge/src/drivers/claude-sdk.d.ts.map +1 -1
  20. package/dist/{chunk-ZWFLEMI4.js → chunk-3F54MH2T.js} +4 -4
  21. package/dist/{chunk-ZWFLEMI4.js.map → chunk-3F54MH2T.js.map} +1 -1
  22. package/dist/{chunk-RTLQAZAE.js → chunk-63ZPKREA.js} +3 -3
  23. package/dist/{chunk-RTLQAZAE.js.map → chunk-63ZPKREA.js.map} +1 -1
  24. package/dist/{chunk-MLYV6WEM.js → chunk-7IRH7MGV.js} +10 -10
  25. package/dist/{chunk-MLYV6WEM.js.map → chunk-7IRH7MGV.js.map} +1 -1
  26. package/dist/{chunk-Y6VSFX2A.js → chunk-7UZGKVSK.js} +3 -3
  27. package/dist/{chunk-Y6VSFX2A.js.map → chunk-7UZGKVSK.js.map} +1 -1
  28. package/dist/{chunk-XQVP6XWR.js → chunk-BFIK6NPZ.js} +3 -3
  29. package/dist/{chunk-XQVP6XWR.js.map → chunk-BFIK6NPZ.js.map} +1 -1
  30. package/dist/{chunk-L26NGI43.js → chunk-BLWNI5KW.js} +2 -2
  31. package/dist/{chunk-L26NGI43.js.map → chunk-BLWNI5KW.js.map} +1 -1
  32. package/dist/{chunk-CTWE7I7Z.js → chunk-CERGXDGG.js} +4 -4
  33. package/dist/{chunk-CTWE7I7Z.js.map → chunk-CERGXDGG.js.map} +1 -1
  34. package/dist/{chunk-VPXBAEWE.js → chunk-CILACPUC.js} +8 -8
  35. package/dist/{chunk-VPXBAEWE.js.map → chunk-CILACPUC.js.map} +1 -1
  36. package/dist/{chunk-43TAGQ3Z.js → chunk-CXX3UGJP.js} +8 -8
  37. package/dist/{chunk-43TAGQ3Z.js.map → chunk-CXX3UGJP.js.map} +1 -1
  38. package/dist/chunk-DZM33LQO.js +38 -0
  39. package/dist/chunk-DZM33LQO.js.map +1 -0
  40. package/dist/{chunk-PSVF3LDU.js → chunk-ETFETLLB.js} +6 -6
  41. package/dist/{chunk-PSVF3LDU.js.map → chunk-ETFETLLB.js.map} +1 -1
  42. package/dist/{chunk-Y662DNQQ.js → chunk-FB4GPWYC.js} +18 -15
  43. package/dist/chunk-FB4GPWYC.js.map +1 -0
  44. package/dist/{chunk-BTR3ZJ7S.js → chunk-G2ILW47R.js} +4 -4
  45. package/dist/{chunk-BTR3ZJ7S.js.map → chunk-G2ILW47R.js.map} +1 -1
  46. package/dist/{chunk-2BSXXTUP.js → chunk-LD6YGIKZ.js} +105 -16
  47. package/dist/chunk-LD6YGIKZ.js.map +1 -0
  48. package/dist/{chunk-HOL5KD7U.js → chunk-PTS3QN5P.js} +67 -25
  49. package/dist/chunk-PTS3QN5P.js.map +1 -0
  50. package/dist/{chunk-YODP3STD.js → chunk-Q26C5GLO.js} +3 -3
  51. package/dist/{chunk-YODP3STD.js.map → chunk-Q26C5GLO.js.map} +1 -1
  52. package/dist/{chunk-GUKMNUQK.js → chunk-RIEXN7WA.js} +2 -2
  53. package/dist/{chunk-GUKMNUQK.js.map → chunk-RIEXN7WA.js.map} +1 -1
  54. package/dist/chunk-SIF5F5SN.js +86 -0
  55. package/dist/chunk-SIF5F5SN.js.map +1 -0
  56. package/dist/{chunk-RBOPTTTK.js → chunk-TAJBFYCT.js} +32 -17
  57. package/dist/chunk-TAJBFYCT.js.map +1 -0
  58. package/dist/{chunk-MAN7AGQJ.js → chunk-TK66CMXV.js} +21 -6
  59. package/dist/chunk-TK66CMXV.js.map +1 -0
  60. package/dist/{chunk-5BGEYZ7I.js → chunk-UFY2HFLO.js} +3 -3
  61. package/dist/{chunk-5BGEYZ7I.js.map → chunk-UFY2HFLO.js.map} +1 -1
  62. package/dist/{chunk-N6TYW6EB.js → chunk-UNP4M5ZZ.js} +4 -4
  63. package/dist/{chunk-N6TYW6EB.js.map → chunk-UNP4M5ZZ.js.map} +1 -1
  64. package/dist/{chunk-HPGV54O4.js → chunk-UQ3RJKDD.js} +41 -23
  65. package/dist/chunk-UQ3RJKDD.js.map +1 -0
  66. package/dist/{chunk-XSIXGVH6.js → chunk-W3Q37HEF.js} +4 -4
  67. package/dist/{chunk-XSIXGVH6.js.map → chunk-W3Q37HEF.js.map} +1 -1
  68. package/dist/{chunk-WVPL4OGD.js → chunk-WG3L5VHF.js} +2 -2
  69. package/dist/{chunk-WVPL4OGD.js.map → chunk-WG3L5VHF.js.map} +1 -1
  70. package/dist/{chunk-SGLGA2AZ.js → chunk-X6BPVUV2.js} +3 -3
  71. package/dist/{chunk-SGLGA2AZ.js.map → chunk-X6BPVUV2.js.map} +1 -1
  72. package/dist/chunk-ZE2KEPE2.js +1002 -0
  73. package/dist/chunk-ZE2KEPE2.js.map +1 -0
  74. package/dist/{chunk-BHLNQ4L5.js → chunk-ZNIHTT22.js} +3 -3
  75. package/dist/{chunk-BHLNQ4L5.js.map → chunk-ZNIHTT22.js.map} +1 -1
  76. package/dist/{chunk-PYYL5XMA.js → chunk-ZR5Q4KZK.js} +3 -3
  77. package/dist/{chunk-PYYL5XMA.js.map → chunk-ZR5Q4KZK.js.map} +1 -1
  78. package/dist/cli/index.js +53 -50
  79. package/dist/cli/index.js.map +1 -1
  80. package/dist/connectors/config.js +6 -6
  81. package/dist/connectors/index.js +11 -9
  82. package/dist/core/index.js +5 -5
  83. package/dist/core/runtime-assets.js +3 -3
  84. package/dist/core/workspace-config.js +2 -2
  85. package/dist/deploy/index.js +5 -5
  86. package/dist/discovery/index.js +1 -1
  87. package/dist/discovery/src/requires-graph.d.ts +1 -1
  88. package/dist/discovery/src/requires-graph.d.ts.map +1 -1
  89. package/dist/{ensure-sources-AVCVX7CV.js → ensure-sources-R6KW7K3M.js} +12 -12
  90. package/dist/{ensure-sources-AVCVX7CV.js.map → ensure-sources-R6KW7K3M.js.map} +1 -1
  91. package/dist/factory-assets/connectors/box.js +11 -9
  92. package/dist/factory-assets/connectors/deploy.js +11 -9
  93. package/dist/factory-assets/connectors/devserver.js +11 -9
  94. package/dist/factory-assets/connectors/flow/CONNECTOR.md +7 -1
  95. package/dist/factory-assets/connectors/flow/adapter.d.ts +2 -3
  96. package/dist/factory-assets/connectors/flow/adapter.d.ts.map +1 -1
  97. package/dist/factory-assets/connectors/flow/adapter.js +11 -9
  98. package/dist/factory-assets/connectors/flow/contract/expression.d.ts +46 -0
  99. package/dist/factory-assets/connectors/flow/contract/expression.d.ts.map +1 -0
  100. package/dist/factory-assets/connectors/flow/contract/flow.v2.schema.json +948 -0
  101. package/dist/factory-assets/connectors/flow/contract/hash.d.ts +6 -0
  102. package/dist/factory-assets/connectors/flow/contract/hash.d.ts.map +1 -0
  103. package/dist/factory-assets/connectors/flow/contract/index.d.ts +6 -0
  104. package/dist/factory-assets/connectors/flow/contract/index.d.ts.map +1 -0
  105. package/dist/factory-assets/connectors/flow/contract/json-schema.d.ts +6 -0
  106. package/dist/factory-assets/connectors/flow/contract/json-schema.d.ts.map +1 -0
  107. package/dist/factory-assets/connectors/flow/contract/normalize.d.ts +38 -0
  108. package/dist/factory-assets/connectors/flow/contract/normalize.d.ts.map +1 -0
  109. package/dist/factory-assets/connectors/flow/contract/schema.d.ts +364 -0
  110. package/dist/factory-assets/connectors/flow/contract/schema.d.ts.map +1 -0
  111. package/dist/factory-assets/connectors/flow/contract.d.ts +2 -0
  112. package/dist/factory-assets/connectors/flow/contract.js +5 -0
  113. package/dist/factory-assets/connectors/flow/contract.js.map +1 -0
  114. package/dist/factory-assets/connectors/flow/engine/engine.d.ts +4 -4
  115. package/dist/factory-assets/connectors/flow/engine/engine.d.ts.map +1 -1
  116. package/dist/factory-assets/connectors/flow/engine/flow-kind-provider.d.ts +1 -1
  117. package/dist/factory-assets/connectors/flow/engine/flow-kind-provider.d.ts.map +1 -1
  118. package/dist/factory-assets/connectors/flow/engine/loader.d.ts.map +1 -1
  119. package/dist/factory-assets/connectors/flow/engine/node-shape.d.ts +20 -0
  120. package/dist/factory-assets/connectors/flow/engine/node-shape.d.ts.map +1 -0
  121. package/dist/factory-assets/connectors/flow/engine/types.d.ts +56 -28
  122. package/dist/factory-assets/connectors/flow/engine/types.d.ts.map +1 -1
  123. package/dist/factory-assets/connectors/flow/engine.js +8 -6
  124. package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts +4 -6
  125. package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts.map +1 -1
  126. package/dist/factory-assets/connectors/flow/prompt-fragments.js +2 -1
  127. package/dist/factory-assets/connectors/flow/run-flow.d.ts.map +1 -1
  128. package/dist/factory-assets/connectors/flow/run-flow.js +12 -10
  129. package/dist/factory-assets/connectors/flow.js +11 -9
  130. package/dist/factory-assets/connectors/git.js +11 -9
  131. package/dist/factory-assets/connectors/gmail.js +11 -9
  132. package/dist/factory-assets/connectors/googledrive.js +11 -9
  133. package/dist/factory-assets/connectors/local.js +11 -9
  134. package/dist/factory-assets/connectors/mattermost.js +11 -9
  135. package/dist/factory-assets/connectors/memory.js +11 -9
  136. package/dist/factory-assets/connectors/minio.js +11 -9
  137. package/dist/factory-assets/connectors/postgres.js +11 -9
  138. package/dist/factory-assets/connectors/s3.js +11 -9
  139. package/dist/factory-assets/connectors/sharepoint.js +11 -9
  140. package/dist/factory-assets/connectors/sqlite.js +11 -9
  141. package/dist/factory-assets/connectors/static-server.js +11 -9
  142. package/dist/factory-assets/connectors/tunnel.js +11 -9
  143. package/dist/factory-assets/connectors/webdav.js +11 -9
  144. package/dist/factory-assets/connectors/xstate-store.js +11 -9
  145. package/dist/factory-assets/connectors/xstate.js +11 -9
  146. package/dist/{flows-CXVFGR27.js → flows-F3CJNMK6.js} +8 -8
  147. package/dist/{flows-CXVFGR27.js.map → flows-F3CJNMK6.js.map} +1 -1
  148. package/dist/{helpers-M5SXB4LL.js → helpers-KPOLCGKX.js} +12 -12
  149. package/dist/{helpers-M5SXB4LL.js.map → helpers-KPOLCGKX.js.map} +1 -1
  150. package/dist/library/index.js +7 -7
  151. package/dist/library/install.js +5 -5
  152. package/dist/{library-publish-HVIIQMI6.js → library-publish-ZAPZS64O.js} +18 -16
  153. package/dist/library-publish-ZAPZS64O.js.map +1 -0
  154. package/dist/{open-library-EJQISBWV.js → open-library-I4F2UNOY.js} +16 -14
  155. package/dist/{open-library-EJQISBWV.js.map → open-library-I4F2UNOY.js.map} +1 -1
  156. package/dist/{paths-2HMHL25W.js → paths-KBACHM5B.js} +10 -10
  157. package/dist/{paths-2HMHL25W.js.map → paths-KBACHM5B.js.map} +1 -1
  158. package/dist/{plugin-store-TLBQ5XRS.js → plugin-store-CYSNVZIX.js} +7 -7
  159. package/dist/{plugin-store-TLBQ5XRS.js.map → plugin-store-CYSNVZIX.js.map} +1 -1
  160. package/dist/{project-M2COJFPZ.js → project-SIHZBTGB.js} +13 -13
  161. package/dist/{project-M2COJFPZ.js.map → project-SIHZBTGB.js.map} +1 -1
  162. package/dist/resolver/index.js +5 -5
  163. package/dist/runner/index.js +17 -14
  164. package/dist/runner/src/serve.d.ts.map +1 -1
  165. package/dist/sdk/asset-manager.js +9 -9
  166. package/dist/sdk/bridge.js +2 -2
  167. package/dist/sdk/core.js +5 -5
  168. package/dist/sdk/flow.js +8 -6
  169. package/dist/sdk/index.js +17 -14
  170. package/dist/sdk/index.js.map +1 -1
  171. package/dist/sdk/resolver.js +5 -5
  172. package/dist/sdk/runner.js +17 -14
  173. package/dist/sdk/transport/ws.js +1 -1
  174. package/dist/sdk/transport.js +1 -1
  175. package/dist/{setup-GWXEG3G2.js → setup-KMBXMV25.js} +9 -9
  176. package/dist/{setup-GWXEG3G2.js.map → setup-KMBXMV25.js.map} +1 -1
  177. package/dist/{skills-YTMGG23D.js → skills-LHS4TOKK.js} +7 -7
  178. package/dist/{skills-YTMGG23D.js.map → skills-LHS4TOKK.js.map} +1 -1
  179. package/dist/{source-WMXH2OBW.js → source-X226ZJPR.js} +17 -15
  180. package/dist/{source-WMXH2OBW.js.map → source-X226ZJPR.js.map} +1 -1
  181. package/dist/{source-manifest-publish-MTHUGBAY.js → source-manifest-publish-N2QVUR5U.js} +19 -17
  182. package/dist/source-manifest-publish-N2QVUR5U.js.map +1 -0
  183. package/dist/transport/index.js +1 -1
  184. package/dist/transport/ws.js +1 -1
  185. package/dist/tui/index.js +17 -14
  186. package/dist/tui/index.js.map +1 -1
  187. package/dist/workspace-plugin/adapters/mcp.js +6 -6
  188. package/dist/workspace-plugin/adapters/omp.js +7 -7
  189. package/dist/workspace-plugin/index.js +1 -1
  190. package/package.json +18 -1
  191. package/dist/chunk-2BSXXTUP.js.map +0 -1
  192. package/dist/chunk-HOL5KD7U.js.map +0 -1
  193. package/dist/chunk-HPGV54O4.js.map +0 -1
  194. package/dist/chunk-MAN7AGQJ.js.map +0 -1
  195. package/dist/chunk-RBOPTTTK.js.map +0 -1
  196. package/dist/chunk-Y662DNQQ.js.map +0 -1
  197. package/dist/library-publish-HVIIQMI6.js.map +0 -1
  198. package/dist/source-manifest-publish-MTHUGBAY.js.map +0 -1
@@ -1 +0,0 @@
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2BAAA;AACH,MAAA,OAAO,2BAAA;AAAA,IACT,KAAK,WAAA;AACH,MAAA,OAAO,WAAA;AAAA,IACT,KAAK,eAAA;AACH,MAAA,OAAO,eAAA;AAAA;AAEb","file":"chunk-Y662DNQQ.js","sourcesContent":["/**\n * Prompt fragments for the flow connector.\n *\n * Pure functions that translate a {@link TurnStimulus} into the strings the\n * runner's flow orchestrator splices into the per-turn agent prompt.\n * Extracted from `runner/src/flow-orchestrator.ts` in Phase 3 of the\n * flow-connector extraction (2026-05-08) so the connector owns its\n * prompt-rendering surface without a runtime dep on the orchestrator.\n *\n * The contract is byte-identical to the previous inline implementation —\n * any divergence is a regression.\n *\n * @docLink packages/factory-assets/flow#prompt-fragments\n */\n\nimport type { FlowExecution } from \"@skaile/workspaces/types\";\nimport type { FlowDefinition } from \"./engine/types.js\";\n\n/**\n * Reasons why a new turn is starting. The flow orchestrator's prompt template\n * renders a stimulus-specific paragraph (via {@link renderStimulusPrompt}) so\n * the agent knows exactly why it has been invoked.\n *\n * @docLink packages/factory-assets/flow#turn-stimulus\n */\nexport type TurnStimulus =\n | { kind: \"flow_started\" }\n | {\n kind: \"approval_received\";\n nodeId: string;\n decision: \"approved\" | \"rejected\";\n feedback?: string;\n decidedBy: string;\n }\n | { kind: \"input_received\"; nodeId: string; response: unknown; providedBy: string }\n | { kind: \"retry_requested\"; nodeId: string; requestedBy: string }\n | { kind: \"user_message\"; text: string; senderId: string }\n | { kind: \"resumed_after_hibernation\" }\n | { kind: \"cancelled\" }\n | { kind: \"state_changed\" };\n\n/**\n * Render the stimulus paragraph the agent sees at turn start.\n *\n * The output is a single paragraph (one or more sentences, no surrounding\n * whitespace) describing why the runner has woken the agent. Spliced into\n * the orchestrator prompt under the `## Why this turn is happening` heading.\n *\n * @docLink packages/factory-assets/flow#render-stimulus-prompt\n */\nexport function renderStimulusPrompt(stimulus: TurnStimulus): string {\n switch (stimulus.kind) {\n case \"flow_started\":\n return \"The user just started this flow. Begin with the first available node — call `get_available`, then `build_handoff` for your chosen node, then `start_node`.\";\n case \"approval_received\": {\n const { nodeId, decision, decidedBy, feedback } = stimulus;\n if (decision === \"approved\") {\n return `Node \\`${nodeId}\\` was **approved** by ${decidedBy}. Call \\`complete_node\\` for this node with the approved output, then advance to the next available node.`;\n }\n const fb = feedback ? ` Feedback: \"${feedback}\".` : \"\";\n return `Node \\`${nodeId}\\` was **rejected** by ${decidedBy}.${fb} Decide how to proceed: retry the node (the engine returned it to \\`available\\`), ask clarifying questions via \\`request_input\\`, or call \\`fail_node(..., recoverable: false)\\` if the issue cannot be addressed.`;\n }\n case \"input_received\":\n return `The user just provided input for node \\`${stimulus.nodeId}\\` (provided by ${stimulus.providedBy}). The node has returned to its prior status. Continue executing the node with this input.`;\n case \"retry_requested\":\n return `A user requested a retry of node \\`${stimulus.nodeId}\\` (requested by ${stimulus.requestedBy}). The node has been returned to \\`available\\` with its prior error preserved in history. Start a fresh attempt — review the error context if relevant and try a different approach.`;\n case \"user_message\":\n return `A user sent a message: \"${stimulus.text}\" (from ${stimulus.senderId}). You can respond directly without touching the flow, continue flow work, or both. If the message is a question about the flow, answer it; if it signals a new direction, consider whether to pause.`;\n case \"resumed_after_hibernation\":\n return \"This session was hibernated and has just resumed. Review the current state above and continue where you left off. No state was lost.\";\n case \"cancelled\":\n return \"The user has cancelled this flow. Wrap up cleanly: do not start any new nodes. You may record a short summary if relevant, then stop.\";\n case \"state_changed\":\n return \"The flow state changed. Review the current state above and continue work accordingly.\";\n }\n}\n\n/**\n * Build the full agent-orchestrator prompt for a flow turn.\n *\n * Reassembles the five-section prompt from the current FlowExecution snapshot\n * and the supplied stimulus:\n *\n * 1. Flow definition (markdown table of nodes)\n * 2. Current state (progress, available/blocked, interaction pointers)\n * 3. Why this turn is happening (stimulus-specific paragraph)\n * 4. Flow tools available (static documentation)\n * 5. Rules\n *\n * Originally a byte-identical lift of the (since-deleted)\n * `FlowOrchestrator.buildOrchestratorPrompt`; the contract now is simply\n * this function's own output. Two additions beyond the lift: when\n * `flowDef.globals` is a non-empty object, a `## Flow globals` section is\n * rendered between \"Current state\" and \"Why this turn is happening\" so the\n * agent can see run-scoped parameters like `run_input` (flows without\n * globals render no such section), and the tool list unconditionally\n * documents `get_globals()` since the operation exists for every flow.\n * Pure — depends only on its inputs.\n *\n * @docLink packages/factory-assets/flow#build-orchestrator-prompt\n * @since 2.2.0\n */\nexport function buildOrchestratorPrompt(\n flowDef: FlowDefinition,\n state: FlowExecution,\n stimulus: TurnStimulus,\n): string {\n const skillNodes = flowDef.nodes.filter((n) => n.type === \"skill\");\n\n // ── Section 1: definition table ──\n const nodeRows = skillNodes\n .map((n) => {\n const deps =\n flowDef.edges\n .filter((e) => e.target === n.id && e.type === \"flow\")\n .map((e) => e.source)\n .join(\", \") || \"—\";\n const required = n.data?.optional ? \"optional\" : \"required\";\n const gate = n.data?.approval?.mandatory ? \"mandatory\" : \"—\";\n const nodeState = state.nodes[n.id];\n const status = nodeState?.status ?? \"not_started\";\n return `| ${n.id} | ${n.data?.skill ?? n.id} | ${n.data?.label ?? n.id} | ${required} | ${gate} | ${status} | ${deps} |`;\n })\n .join(\"\\n\");\n\n // ── Section 2: current state summary ──\n const nodesByStatus = (s: string) =>\n Object.values(state.nodes)\n .filter((n) => n.status === s)\n .map((n) => n.id);\n const available = nodesByStatus(\"available\");\n const awaitingApproval = nodesByStatus(\"awaiting_approval\");\n const awaitingInput = nodesByStatus(\"awaiting_input\");\n const running = nodesByStatus(\"running\");\n const failed = nodesByStatus(\"failed\");\n const completed = nodesByStatus(\"complete\");\n const totalRequired = skillNodes.filter((n) => !n.data?.optional).length;\n\n const stateSummary = [\n `- Run ID: ${state.runId}`,\n `- Status: ${state.status}`,\n `- Autonomous mode: ${state.autonomousMode}`,\n `- Progress: ${completed.length} / ${totalRequired} required nodes complete`,\n `- Available now: ${available.join(\", \") || \"(none)\"}`,\n `- Currently running: ${running.join(\", \") || \"(none)\"}`,\n `- Awaiting approval: ${awaitingApproval.join(\", \") || \"(none)\"}`,\n `- Awaiting input: ${awaitingInput.join(\", \") || \"(none)\"}`,\n `- Failed: ${failed.join(\", \") || \"(none)\"}`,\n ].join(\"\\n\");\n\n // ── Section 2b: flow globals (additive — omitted entirely when empty so\n // flows without globals keep the byte-identical Phase 3 prompt) ──\n const globals = flowDef.globals ?? {};\n const globalsSection =\n Object.keys(globals).length > 0\n ? `## Flow globals\n\nRun-scoped parameters set by the flow author or by the host that started this run. When \\`run_input\\` is present it carries the payload this run was started with (e.g. a scheduled or webhook-triggered run) — treat it as the run's initial input instead of asking the user for it.\n\n\\`\\`\\`json\n${JSON.stringify(globals, null, 2)}\n\\`\\`\\`\n\n`\n : \"\";\n\n // ── Section 3: stimulus paragraph ──\n const stimulusParagraph = renderStimulusPrompt(stimulus);\n\n // ── Section 4+5: static tool surface and rules ──\n return `# Flow Execution Context\n\nYou are orchestrating the flow **${flowDef.name}** (${flowDef.id} v${flowDef.version}). This is a governed flow execution: your job is to run nodes through the flow tools, summarize their outputs for human review, and yield control at approval gates.\n\n## Flow definition\n\n| ID | Skill | Label | Required | Gate | Status | Depends on |\n|----|-------|-------|----------|------|--------|------------|\n${nodeRows}\n\nNodes with **Gate = mandatory** are hard approval gates: they always require \\`request_approval\\` and a human decision, even when autonomous mode is on. They cannot be skipped — \\`request_approval\\` → approval is their only completion path.\n\n## Current state\n\n${stateSummary}\n\n${globalsSection}## Why this turn is happening\n\n${stimulusParagraph}\n\n## Flow tools available\n\nAll tools are exposed by the \\`flow\\` connector:\n\n- \\`get_available()\\` — list node IDs that are ready to start\n- \\`get_state()\\` — full current state including approvals, inputs, outputs\n- \\`get_globals()\\` — the flow's run-scoped globals (e.g. the \\`run_input\\` payload for scheduled/params-bound runs)\n- \\`build_handoff(nodeId)\\` — curated context from upstream predecessors (summaries + artifacts)\n- \\`start_node(nodeId)\\` — transition \\`available\\` → \\`running\\`; call before executing the skill\n- \\`request_approval(nodeId, summary, artifacts)\\` — transition \\`running\\` → \\`awaiting_approval\\`. **This ends your turn.**\n- \\`request_input(nodeId, prompt, schema)\\` — transition to \\`awaiting_input\\`. **This ends your turn.** Legal from \\`available\\`, \\`running\\`, or \\`awaiting_approval\\`.\n- \\`complete_node(nodeId, output)\\` — transition to \\`complete\\`. Valid only if the node was approved, OR autonomousMode is true and the node is not a mandatory gate.\n- \\`fail_node(nodeId, message, recoverable)\\` — transition to \\`failed\\`. \\`recoverable=true\\` returns the node to \\`available\\`.\n- \\`skip_node(nodeId)\\` — transition to \\`skipped\\`. Only valid for optional nodes.\n\n## Rules\n\n1. Before executing a skill, call \\`start_node(nodeId)\\`.\n2. After executing the skill, call \\`request_approval\\` unless \\`autonomousMode\\` is true — in which case call \\`complete_node\\` directly. Exception: nodes marked **Gate = mandatory** always require \\`request_approval\\` and a human decision, even in autonomous mode.\n3. If you need information from the user before or during execution, call \\`request_input\\`. This ends your turn until the user responds.\n4. On unrecoverable failure, call \\`fail_node(..., recoverable: false)\\`. On recoverable failure, call \\`fail_node(..., recoverable: true)\\` and the engine returns the node to \\`available\\`.\n5. When all required nodes are \\`complete\\` or \\`skipped\\`, stop. The runner marks the flow done automatically.\n6. Free-chat user messages do not require flow action. Respond directly, continue flow work, or both — your call.\n`;\n}\n\n/**\n * Single-line tag suitable for telemetry / logging. Derives a short, stable\n * summary of a stimulus that's safe to attach to spans, log entries, and\n * trace events. The kind is always included; node-specific stimuli also\n * include their `nodeId` so log queries can pivot on it.\n *\n * @docLink packages/factory-assets/flow#describe-stimulus\n */\nexport function describeStimulus(stimulus: TurnStimulus): string {\n switch (stimulus.kind) {\n case \"flow_started\":\n return \"flow_started\";\n case \"approval_received\":\n return `approval_received:${stimulus.nodeId}:${stimulus.decision}`;\n case \"input_received\":\n return `input_received:${stimulus.nodeId}`;\n case \"retry_requested\":\n return `retry_requested:${stimulus.nodeId}`;\n case \"user_message\":\n return `user_message:${stimulus.senderId}`;\n case \"resumed_after_hibernation\":\n return \"resumed_after_hibernation\";\n case \"cancelled\":\n return \"cancelled\";\n case \"state_changed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,EAAG;AAC3B,MAAA,OAAA,CAAQ,qDAAgD,CAAA;AACxD,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,SAAmB,EAAC;AAC1B,IAAA,KAAA,MAAW,KAAK,UAAA,EAAY;AAC1B,MAAA,IAAI;AACF,QAAA,MAAM,GAAA,CAAI,cAAA,CAAe,CAAA,CAAE,EAAE,CAAA;AAC7B,QAAA,MAAA,CAAO,KAAK,CAAA,EAAG,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,CAAE,CAAA;AAAA,MACnC,SAAS,GAAA,EAAK;AACZ,QAAA,MAAA;AAAA,UACE,CAAA,eAAA,EAAkB,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,EAAA,EAAK,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,SACzF;AAAA,MACF;AAAA,IACF;AAEA,IAAA,KAAA,CAAM,CAAA,OAAA,EAAU,MAAA,CAAO,MAAM,CAAA,UAAA,CAAY,CAAA;AACzC,IAAA,KAAA,MAAW,CAAA,IAAK,MAAA,EAAQ,OAAA,CAAQ,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA;AAAA,EAC1C,CAAA,SAAE;AACA,IAAA,KAAA,EAAM;AAAA,EACR;AACF","file":"library-publish-HVIIQMI6.js","sourcesContent":["/**\n * `skaile library publish / register / yank` — the first-party publish flow.\n * A git-backed library you own carries an in-repo `skaile.manifest.yaml`; this\n * commits + pushes the library repo (publish), or takes the current remote HEAD\n * as-is (register), then registers + syncs it as a store source and publishes\n * the manifest's assets under the manifest's own `publisher` (no namespace\n * remap — first-party authors intend their declared namespace).\n *\n * - `publish` = commit (if dirty) + push + register + sync + publish.\n * - `register` = same, but skip the commit/push (bytes already on GitHub).\n * - `yank` = unpublish the library's published assets (all, or one).\n *\n * The store REST surface is reached through the injectable {@link PublisherClient}\n * (default HTTP); git side-effects go through an injectable `spawn`. Both seams\n * keep the flow unit/integration-testable without a live store or a real remote.\n *\n * @docLink cli/commands/library\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { decodeSkaileManifest, type SkPublishManifest } from \"@skaile/workspaces/core\";\nimport type { GitBackendConfig, Library } from \"@skaile/workspaces/library\";\nimport { logErr, logInfo, logOk, S } from \"../helpers.ts\";\nimport { openLibraryManager } from \"../open-library.ts\";\nimport { isStoreAuthenticated } from \"../store-client.ts\";\nimport { makeHttpPublisherClient, type PublisherClient } from \"../store-publisher.ts\";\nimport {\n bareName,\n formatNamespaceAvailability,\n preflightNamespace,\n publishToStore,\n refFor,\n} from \"./publish-core.ts\";\n\n/** Injectable spawn contract — the subset of `spawnSync` these helpers use. */\ntype SpawnLike = typeof spawnSync;\n\n/** The fixed filename a library carries at its root for publication. */\nconst MANIFEST_FILENAME = \"skaile.manifest.yaml\";\n\n/** The remote url of a git-backed library, or `undefined` for a local one. */\nfunction remoteUrlOf(lib: Library): string | undefined {\n if (lib.backend !== \"git\") return undefined;\n return (lib.backendConfig as GitBackendConfig).url;\n}\n\n/** The publish branch of a git-backed library (defaults to `main`). */\nfunction branchOf(lib: Library): string {\n if (lib.backend !== \"git\") return \"main\";\n return (lib.backendConfig as GitBackendConfig).branch ?? \"main\";\n}\n\n/**\n * Read + decode the in-repo `skaile.manifest.yaml`. Prints each error\n * diagnostic and exits (1) — mirroring the sidecar flow's validation gate.\n */\nfunction loadManifest(libPath: string): SkPublishManifest {\n let text: string;\n try {\n text = readFileSync(join(libPath, MANIFEST_FILENAME), \"utf-8\");\n } catch {\n logErr(\n `No ${S.dim(MANIFEST_FILENAME)} in the library — author it (see \\`skaile library create\\`) ` +\n \"and run `skaile validate` before publishing.\",\n );\n process.exit(1);\n }\n const { manifest, diagnostics } = decodeSkaileManifest(text);\n const errors = diagnostics.filter((d) => d.severity === \"error\");\n if (errors.length > 0) {\n for (const d of errors) logErr(`${d.code}: ${d.message}`);\n logErr(\"The manifest has errors — fix them with `skaile validate` before publishing.\");\n process.exit(1);\n }\n return manifest;\n}\n\n/** Run a git command in `cwd` via the injected spawn; returns the result. */\nfunction runGit(spawn: SpawnLike, cwd: string, args: string[]) {\n return spawn(\"git\", [\"-C\", cwd, ...args], { encoding: \"utf-8\" });\n}\n\n/**\n * Ensure `libPath` is a git repo whose `origin` points at `remoteUrl`, then\n * commit any changes and push to `branch`. Idempotent re-publish: an unchanged\n * tree makes `git commit` fail with \"nothing to commit\" — swallowed. Push (or\n * any other git) failures surface as thrown Errors carrying git's stderr.\n */\nfunction commitAndPush(opts: {\n libPath: string;\n remoteUrl: string;\n branch: string;\n spawn: SpawnLike;\n}): void {\n const { libPath, remoteUrl, branch, spawn } = opts;\n\n const gitDir = runGit(spawn, libPath, [\"rev-parse\", \"--git-dir\"]);\n if (gitDir.status !== 0) {\n const init = runGit(spawn, libPath, [\"init\"]);\n if (init.status !== 0) {\n throw new Error(\n `git init failed: ${(init.stderr ?? \"\").toString().trim() || `exit ${init.status}`}`,\n );\n }\n }\n\n // Point origin at the resolved remote (add if absent, else set-url).\n const getUrl = runGit(spawn, libPath, [\"remote\", \"get-url\", \"origin\"]);\n const originArgs =\n getUrl.status === 0\n ? [\"remote\", \"set-url\", \"origin\", remoteUrl]\n : [\"remote\", \"add\", \"origin\", remoteUrl];\n const setOrigin = runGit(spawn, libPath, originArgs);\n if (setOrigin.status !== 0) {\n throw new Error(\n `git remote failed: ${(setOrigin.stderr ?? \"\").toString().trim() || `exit ${setOrigin.status}`}`,\n );\n }\n\n const add = runGit(spawn, libPath, [\"add\", \"-A\"]);\n if (add.status !== 0) {\n throw new Error(\n `git add failed: ${(add.stderr ?? \"\").toString().trim() || `exit ${add.status}`}`,\n );\n }\n\n // Fixed bot identity via -c so the commit succeeds regardless of the author's\n // git config (the publish commit is a machine action).\n const commit = spawn(\n \"git\",\n [\n \"-C\",\n libPath,\n \"-c\",\n \"user.email=publish@skaile.store\",\n \"-c\",\n \"user.name=skaile\",\n \"commit\",\n \"-m\",\n \"chore: publish\",\n ],\n { encoding: \"utf-8\" },\n );\n if (commit.status !== 0) {\n const out = `${commit.stdout ?? \"\"}${commit.stderr ?? \"\"}`;\n if (!/nothing to commit/i.test(out)) {\n throw new Error(`git commit failed: ${out.trim() || `exit ${commit.status}`}`);\n }\n }\n\n const push = runGit(spawn, libPath, [\"push\", \"origin\", `HEAD:${branch}`]);\n if (push.status !== 0) {\n throw new Error(\n `git push failed: ${(push.stderr ?? \"\").toString().trim() || `exit ${push.status}`}`,\n );\n }\n}\n\n/**\n * Provision a public GitHub repo `github.com/<you>/<name>` via `gh` and return\n * its https url. Parses the url `gh` prints on success. Throws on failure.\n */\nfunction createRepoViaGh(name: string, spawn: SpawnLike): string {\n const res = spawn(\"gh\", [\"repo\", \"create\", name, \"--public\"], { encoding: \"utf-8\" });\n if (res.status !== 0) {\n const stderr = (res.stderr ?? \"\").toString().trim();\n throw new Error(`gh repo create ${name} failed: ${stderr || `exit ${res.status}`}`);\n }\n // `gh repo create` prints the repo url (e.g. `https://github.com/<owner>/<name>`);\n // scan combined output for the first github.com url so we capture whatever\n // owner gh resolved (the authed user).\n const out = `${res.stdout ?? \"\"}\\n${res.stderr ?? \"\"}`;\n const match = out.match(/https:\\/\\/github\\.com\\/[^\\s]+/);\n if (!match) {\n throw new Error(`gh repo create ${name} succeeded but printed no repo url:\\n${out.trim()}`);\n }\n return match[0].replace(/\\.git$/, \"\").trim();\n}\n\n/** Shared publish body for `publish` (pushes) and `register` (skips the push). */\nasync function publishLibrary(\n name: string,\n opts: {\n asset?: string;\n createRepo?: boolean;\n ref?: string;\n dryRun?: boolean;\n skipPush: boolean;\n },\n client?: PublisherClient,\n spawn: SpawnLike = spawnSync,\n): Promise<void> {\n const injected = client !== undefined;\n const { manager, close } = await openLibraryManager();\n try {\n const lib = await manager.requireLibrary(name);\n const manifest = loadManifest(lib.path);\n\n // Resolve the remote: git-backed → its url; local + --create-repo → provision\n // and link; else stop with a hint.\n let remoteUrl = remoteUrlOf(lib);\n let wouldCreateRepo = false;\n if (!remoteUrl) {\n if (opts.createRepo) {\n if (opts.dryRun) {\n // A dry-run must not provision anything — defer the real\n // `gh repo create` to the live run and just show the would-be remote.\n wouldCreateRepo = true;\n remoteUrl = `https://github.com/<your-account>/${lib.name}`;\n } else {\n remoteUrl = createRepoViaGh(lib.name, spawn);\n await manager.updateLibrary(name, {\n backend: \"git\",\n backendConfig: { url: remoteUrl, branch: \"main\", authHint: \"ssh\" },\n });\n logOk(`Created + linked ${S.dim(remoteUrl)}.`);\n }\n } else {\n logErr(\n `Library \"${name}\" has no remote — run ${S.cmd(`skaile library link ${name} <url>`)} ` +\n \"first, or pass `--create-repo` to provision a public repo.\",\n );\n process.exit(1);\n }\n }\n\n // The manifest's own publisher is the namespace (first-party — no remap).\n const namespace = manifest.publisher ?? \"<manifest publisher>\";\n const targetName = opts.asset ? bareName(opts.asset) : undefined;\n const wouldBeRefs = (manifest.assets ?? [])\n .filter((a) => !targetName || a.name === targetName)\n .map((a) => refFor(a.kind, namespace, a.name, a.version ?? manifest.version));\n\n const sourceRef = opts.ref ?? branchOf(lib);\n\n if (opts.dryRun) {\n logInfo(`Publish plan for ${S.bold(name)}:`);\n logInfo(\n ` remote: ${remoteUrl}${wouldCreateRepo ? \" (would be created via `gh repo create --public`)\" : \"\"}`,\n );\n logInfo(` publisher: ${namespace}`);\n // Best-effort namespace-availability probe — a read-only GET, only when\n // signed in (or a client is injected). A failure keeps dry-run offline-safe.\n if (manifest.publisher && (injected || isStoreAuthenticated())) {\n try {\n const avail = await (client ?? makeHttpPublisherClient()).namespaceAvailability(\n manifest.publisher,\n );\n logInfo(` namespace: ${formatNamespaceAvailability(avail)}`);\n } catch {\n // Store unreachable / not signed in — skip the advisory, never fail.\n }\n }\n logInfo(` source ref: ${sourceRef}`);\n logInfo(` would publish ${wouldBeRefs.length} asset(s):`);\n for (const r of wouldBeRefs) logInfo(` ${r}`);\n return;\n }\n\n // A real publish makes store calls, so it needs a token (injected fakes bypass).\n if (!injected && !isStoreAuthenticated()) {\n logErr(\"Not signed in — run `skaile store login` first.\");\n process.exit(1);\n }\n\n const pub = client ?? makeHttpPublisherClient();\n\n // Preflight the namespace BEFORE the public git push, so a reserved/unclaimed\n // namespace fails fast with guidance instead of after publishing bytes.\n if (manifest.publisher) {\n const gate = await preflightNamespace(pub, manifest.publisher);\n if (!gate.ok) {\n logErr(gate.message ?? `Cannot publish under @${manifest.publisher}.`);\n process.exit(1);\n }\n }\n\n // publish commits + pushes the library repo; register takes the remote HEAD as-is.\n if (!opts.skipPush) {\n // `git add -A` stages every non-ignored file → a PUBLIC push. Surface it so\n // an unexpected file in the working tree is not silently published.\n logInfo(\n `Committing the library and pushing to the PUBLIC remote ${S.dim(remoteUrl)} ` +\n \"(.gitignore honored; anything else in the working tree becomes public).\",\n );\n commitAndPush({ libPath: lib.path, remoteUrl, branch: branchOf(lib), spawn });\n logOk(`Pushed ${S.dim(name)} to ${S.dim(remoteUrl)}.`);\n }\n\n const { published } = await publishToStore({\n sourceUrl: remoteUrl,\n ref: sourceRef,\n manifest,\n assetName: targetName,\n client: pub,\n });\n\n if (published.length > 0) {\n logInfo(`Consumers can now \\`skaile add ${published[0]}\\`.`);\n }\n } finally {\n close();\n }\n}\n\n/**\n * `skaile library publish <lib>` — commit + push the library repo, register +\n * sync it as a store source, and publish its manifest's assets under the\n * manifest publisher. See the module header for the full flow.\n */\nexport async function runLibraryPublish(\n name: string,\n opts: { asset?: string; createRepo?: boolean; ref?: string; dryRun?: boolean },\n client?: PublisherClient,\n spawn: SpawnLike = spawnSync,\n): Promise<void> {\n await publishLibrary(name, { ...opts, skipPush: false }, client, spawn);\n}\n\n/**\n * `skaile library register <lib>` — same as publish but skips the commit/push\n * (the bytes are already on GitHub at the current remote HEAD). Still requires a\n * git-backed remote.\n */\nexport async function runLibraryRegister(\n name: string,\n opts: { asset?: string; ref?: string; dryRun?: boolean },\n client?: PublisherClient,\n spawn: SpawnLike = spawnSync,\n): Promise<void> {\n await publishLibrary(name, { ...opts, skipPush: true }, client, spawn);\n}\n\n/**\n * `skaile library yank <lib>` — unpublish the library's published assets from\n * the store (all, or the single asset matching `opts.asset`'s name).\n * Auth-gated like publish.\n */\nexport async function runLibraryYank(\n name: string,\n opts: { asset?: string },\n client?: PublisherClient,\n): Promise<void> {\n const injected = client !== undefined;\n const { manager, close } = await openLibraryManager();\n try {\n const lib = await manager.requireLibrary(name);\n const remoteUrl = remoteUrlOf(lib);\n if (!remoteUrl) {\n logErr(`Library \"${name}\" has no remote — nothing published to yank.`);\n process.exit(1);\n }\n\n if (!injected && !isStoreAuthenticated()) {\n logErr(\"Not signed in — run `skaile store login` first.\");\n process.exit(1);\n }\n\n const pub = client ?? makeHttpPublisherClient();\n const rows = await pub.sourcesList();\n const source = rows.find((r) => r.url === remoteUrl);\n if (!source) {\n logErr(`Library \"${name}\" is not registered in the store — nothing to yank.`);\n process.exit(1);\n }\n\n const targetName = opts.asset ? bareName(opts.asset) : undefined;\n const candidates = (await pub.sourceCandidates(source.id)).filter(\n (c) => c.published && (!targetName || c.name === targetName),\n );\n if (candidates.length === 0) {\n logInfo(\"No published assets matched — nothing to yank.\");\n return;\n }\n\n const yanked: string[] = [];\n for (const c of candidates) {\n try {\n await pub.assetUnpublish(c.id);\n yanked.push(`${c.kind}:${c.name}`);\n } catch (err) {\n logErr(\n `Failed to yank ${c.kind}:${c.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n logOk(`Yanked ${yanked.length} asset(s):`);\n for (const r of yanked) logInfo(` ${r}`);\n } finally {\n close();\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../cli/src/commands/source-manifest-publish.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAM,yBAAA,GAA4B,sBAAA;AAW3B,SAAS,0BAAA,CACd,UACA,SAAA,E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AAA,CAAI,gBAAA,CAAiB,MAAA,CAAO,EAAE,CAAA,EAAG,MAAA;AAAA,IACzD,CAAC,CAAA,KAAM,CAAA,CAAE,cAAc,CAAC,UAAA,IAAc,EAAE,IAAA,KAAS,UAAA;AAAA,GACnD;AACA,EAAA,IAAI,UAAA,CAAW,WAAW,CAAA,EAAG;AAC3B,IAAA,OAAA,CAAQ,qDAAgD,CAAA;AACxD,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,SAAmB,EAAC;AAC1B,EAAA,KAAA,MAAW,KAAK,UAAA,EAAY;AAC1B,IAAA,IAAI;AACF,MAAA,MAAM,GAAA,CAAI,cAAA,CAAe,CAAA,CAAE,EAAE,CAAA;AAC7B,MAAA,MAAA,CAAO,KAAK,CAAA,EAAG,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,CAAE,CAAA;AAAA,IACnC,SAAS,GAAA,EAAK;AACZ,MAAA,OAAA;AAAA,QACE,CAAA,eAAA,EAAkB,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,EAAA,EAAK,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,OACzF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,KAAA,CAAM,CAAA,OAAA,EAAU,MAAA,CAAO,MAAM,CAAA,UAAA,CAAY,CAAA;AACzC,EAAA,KAAA,MAAW,CAAA,IAAK,MAAA,EAAQ,OAAA,CAAQ,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA;AAC1C","file":"source-manifest-publish-MTHUGBAY.js","sourcesContent":["/**\n * `skaile source manifest publish` / `yank` — the curator-publish flow. Takes a\n * locally-curated sidecar manifest (over a foreign public GitHub repo) and:\n *\n * 1. Pushes the curated `skaile.manifest.yaml` to the curator's OWN public\n * \"sidecar\" repo (bytes stay in the foreign source; the sidecar holds only\n * the manifest pointing at it).\n * 2. Registers the foreign source + the sidecar (url + pinned commit) with the\n * store, syncs it, and publishes each curated asset.\n *\n * `yank` is the inverse: unpublish each currently-published asset of the source.\n *\n * The store REST surface is reached through the injectable {@link PublisherClient}\n * (default HTTP client); git side-effects go through an injectable `spawn`. Both\n * seams keep the pure helpers + orchestration unit/integration-testable without a\n * live store or a real remote.\n *\n * @docLink cli/commands/source#manifest-publish\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport {\n decodeSkaileManifest,\n encodeSkaileManifest,\n type SkPublishManifest,\n sourceCacheKey,\n} from \"@skaile/workspaces/core\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport { makeHttpPublisherClient, type PublisherClient } from \"../store-publisher.ts\";\nimport { isStoreAuthenticated } from \"../store-client.ts\";\nimport { bareName, publishToStore, refFor } from \"./publish-core.ts\";\nimport { sourceClonePath } from \"./source.ts\";\nimport { resolveSourceArg } from \"./source-manifest.ts\";\n\n/** The fixed filename a sidecar repo carries at its root. */\nconst SIDECAR_MANIFEST_FILENAME = \"skaile.manifest.yaml\";\n\n/** Injectable spawn contract — the subset of `spawnSync` these helpers use. */\ntype SpawnLike = typeof spawnSync;\n\n/**\n * Return a copy of `manifest` normalized for publication under `namespace`:\n * the top-level `publisher` is set to `namespace` and every per-asset\n * `publisher` override is removed so all assets inherit the top-level one.\n * Pure — the input is not mutated.\n */\nexport function normalizePublishedManifest(\n manifest: SkPublishManifest,\n namespace: string,\n): SkPublishManifest {\n const assets = (manifest.assets ?? []).map((a) => {\n const { publisher: _drop, ...rest } = a;\n return rest;\n });\n return { ...manifest, publisher: namespace, assets };\n}\n\n// ── Sidecar-repo association (~/.skaile/settings.json) ────────────────────────\n\n/**\n * Path to the user settings file — the same `~/.skaile/settings.json` the store\n * client reads tokens from. Resolves the `.skaile` root exactly as `getStoreRoot`\n * does (`SKAILE_HOME` when set — it IS the `.skaile` dir — else `~/.skaile`), so\n * the sidecar association lives beside the store manifests under one convention\n * and tests isolate through the same `SKAILE_HOME` seam.\n */\nfunction settingsFile(): string {\n const root = process.env.SKAILE_HOME ?? join(homedir(), \".skaile\");\n return join(root, \"settings.json\");\n}\n\nfunction readSettings(): Record<string, any> {\n const file = settingsFile();\n if (!existsSync(file)) return {};\n try {\n return JSON.parse(readFileSync(file, \"utf-8\"));\n } catch {\n return {};\n }\n}\n\n/**\n * The sidecar repo URL previously associated with a source `slug`, if any.\n * Reads `settings.sidecarRepos?.[slug]?.repo`.\n */\nexport function getSidecarRepo(slug: string): string | undefined {\n const settings = readSettings();\n return settings.sidecarRepos?.[slug]?.repo;\n}\n\n/**\n * Persist the sidecar repo URL for a source `slug`, preserving every other\n * settings key. Stored as an object (`{ repo }`) so a `path` (or other fields)\n * can be added later without a schema migration.\n */\nexport function saveSidecarRepo(slug: string, repo: string): void {\n const file = settingsFile();\n mkdirSync(dirname(file), { recursive: true });\n const settings = readSettings();\n const sidecarRepos = { ...(settings.sidecarRepos ?? {}) };\n sidecarRepos[slug] = { ...(sidecarRepos[slug] ?? {}), repo };\n settings.sidecarRepos = sidecarRepos;\n writeFileSync(file, JSON.stringify(settings, null, 2), \"utf-8\");\n}\n\n// ── Sidecar push ──────────────────────────────────────────────────────────────\n\n/**\n * Run a git command in `cwd` via the injected spawn, throwing with the captured\n * stderr on failure. Returns trimmed stdout.\n */\nfunction git(spawn: SpawnLike, cwd: string, args: string[]): string {\n const res = spawn(\"git\", [\"-C\", cwd, ...args], { encoding: \"utf-8\" });\n if (res.status !== 0) {\n const stderr = (res.stderr ?? \"\").toString().trim();\n throw new Error(`git ${args.join(\" \")} failed: ${stderr || `exit ${res.status}`}`);\n }\n return (res.stdout ?? \"\").toString().trim();\n}\n\n/**\n * Clone the curator's sidecar repo, write the curated manifest at its root, and\n * commit + push. Returns the pushed commit sha (used to pin the store source).\n *\n * Idempotent re-publish: when the manifest is unchanged `git commit` fails with\n * \"nothing to commit\" — we swallow that and return the current HEAD so a no-op\n * re-run still yields a valid pin. Any push/auth failure surfaces as a thrown\n * Error carrying git's stderr.\n */\nexport function pushSidecarManifest(opts: {\n sidecarRepoUrl: string;\n manifestText: string;\n spawn?: SpawnLike;\n}): { commitSha: string } {\n const spawn = opts.spawn ?? spawnSync;\n // Dedicated dir next to the source clone cache; wipe any stale clone first so\n // a re-publish always starts from a clean shallow checkout of the remote.\n const cloneDir = `${sourceClonePath(sourceCacheKey(opts.sidecarRepoUrl))}-sidecar-push`;\n rmSync(cloneDir, { recursive: true, force: true });\n mkdirSync(dirname(cloneDir), { recursive: true });\n\n // The clone is scratch — always remove it afterwards (success or failure) so a\n // failed push never leaves a stale checkout in the cache dir.\n try {\n const cloneRes = spawn(\"git\", [\"clone\", \"--depth\", \"1\", opts.sidecarRepoUrl, cloneDir], {\n encoding: \"utf-8\",\n });\n if (cloneRes.status !== 0) {\n const stderr = (cloneRes.stderr ?? \"\").toString().trim();\n throw new Error(\n `git clone ${opts.sidecarRepoUrl} failed: ${stderr || `exit ${cloneRes.status}`}`,\n );\n }\n\n writeFileSync(join(cloneDir, SIDECAR_MANIFEST_FILENAME), opts.manifestText, \"utf-8\");\n git(spawn, cloneDir, [\"add\", SIDECAR_MANIFEST_FILENAME]);\n\n // Fixed bot identity via -c so the commit succeeds regardless of the curator's\n // git config (the sidecar push is a machine action, not authored work).\n const commitRes = spawn(\n \"git\",\n [\n \"-C\",\n cloneDir,\n \"-c\",\n \"user.email=publish@skaile.store\",\n \"-c\",\n \"user.name=skaile\",\n \"commit\",\n \"-m\",\n \"chore(sidecar): publish curated manifest\",\n ],\n { encoding: \"utf-8\" },\n );\n if (commitRes.status !== 0) {\n const out = `${commitRes.stdout ?? \"\"}${commitRes.stderr ?? \"\"}`;\n // Nothing changed → idempotent re-publish; keep the existing HEAD.\n if (!/nothing to commit/i.test(out)) {\n throw new Error(`git commit failed: ${out.trim() || `exit ${commitRes.status}`}`);\n }\n } else {\n // `push origin HEAD` (not a bare `push`) so a fresh sidecar repo with an\n // unborn/renamed default branch still gets its branch created on the remote.\n git(spawn, cloneDir, [\"push\", \"origin\", \"HEAD\"]);\n }\n\n return { commitSha: git(spawn, cloneDir, [\"rev-parse\", \"HEAD\"]) };\n } finally {\n rmSync(cloneDir, { recursive: true, force: true });\n }\n}\n\n// ── Orchestration ───────────────────────────────────────────────────────────\n\n/**\n * `source manifest publish <src>` — publish a curated sidecar manifest to the\n * store. See the module header for the full flow. Store calls go through\n * `client` (default HTTP); git side-effects through `spawn` (default\n * `spawnSync`). The auth gate is enforced only for the default HTTP client so\n * injected fakes bypass it.\n */\nexport async function runPublish(\n arg: string,\n opts: {\n projectDir: string;\n as?: string;\n sidecarRepo?: string;\n ref?: string;\n dryRun?: boolean;\n },\n client?: PublisherClient,\n spawn: SpawnLike = spawnSync,\n): Promise<void> {\n const injected = client !== undefined;\n const pub = client ?? makeHttpPublisherClient();\n\n const { url, slug, manifestFile } = resolveSourceArg(arg, opts.projectDir);\n\n if (!existsSync(manifestFile)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${S.dim(manifestFile)} — ` +\n \"run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n const { manifest, diagnostics } = decodeSkaileManifest(readFileSync(manifestFile, \"utf-8\"));\n if (diagnostics.some((d) => d.severity === \"error\")) {\n for (const d of diagnostics.filter((x) => x.severity === \"error\")) {\n logErr(`${d.code}: ${d.message}`);\n }\n logErr(\n \"The curated manifest has errors — fix them with `skaile source manifest edit` / \" +\n \"`verify` before publishing.\",\n );\n process.exit(1);\n }\n\n // A real publish makes store calls (+ `me()` when `--as` is omitted), so it\n // needs a token. `--dry-run` is an offline preview: never gate it on auth.\n const authed = injected || isStoreAuthenticated();\n if (!opts.dryRun && !authed) {\n logErr(\"Not signed in — run `skaile store login` first.\");\n process.exit(1);\n }\n\n // Namespace: `--as` wins; else the caller's verified identity. Prefer the\n // GitHub handle (`githubLogin`) over the store login (`username`) — for a user\n // whose login differs from their GitHub handle the login namespace may be\n // reserved (matches the CLI's `resolveLibraryPublisher` precedence). In an\n // unauthenticated dry-run we cannot call `me()`, so show a placeholder.\n let namespace: string;\n if (opts.as) namespace = opts.as;\n else if (authed) {\n const me = await pub.me();\n // `||` not `??`: an empty-string githubLogin (partially-connected account) is\n // not a usable namespace — fall back to the login rather than publish under \"\".\n namespace = me.githubLogin || me.username;\n } else namespace = \"<your store username>\";\n\n const normalized = normalizePublishedManifest(manifest, namespace);\n const publishedText = encodeSkaileManifest(normalized);\n\n const wouldBeRefs = (normalized.assets ?? []).map((a) =>\n refFor(a.kind, namespace, a.name, a.version ?? normalized.version),\n );\n\n if (opts.dryRun) {\n const sidecar = opts.sidecarRepo ?? getSidecarRepo(slug) ?? \"<none — pass --sidecar-repo>\";\n logInfo(`Publish plan for ${S.bold(slug)}:`);\n logInfo(` namespace: ${namespace}`);\n logInfo(` sidecar repo: ${sidecar}`);\n logInfo(` source ref: ${opts.ref ?? \"main\"}`);\n logInfo(` would publish ${wouldBeRefs.length} asset(s):`);\n for (const r of wouldBeRefs) logInfo(` ${r}`);\n return;\n }\n\n const sidecarRepoUrl = opts.sidecarRepo ?? getSidecarRepo(slug);\n if (!sidecarRepoUrl) {\n logErr(\n \"No sidecar repo associated with this source. Pass \" +\n `${S.cmd(\"--sidecar-repo https://github.com/<you>/<repo>\")} — it must be a ` +\n \"PUBLIC GitHub repo you own; the curated manifest is committed there and the \" +\n \"store pins to that commit.\",\n );\n process.exit(1);\n }\n if (opts.sidecarRepo) saveSidecarRepo(slug, sidecarRepoUrl);\n\n const { commitSha } = pushSidecarManifest({ sidecarRepoUrl, manifestText: publishedText, spawn });\n logOk(`Pushed curated manifest to ${S.dim(sidecarRepoUrl)} @ ${commitSha.slice(0, 10)}.`);\n\n // The FOREIGN repo's ref to ingest (branch/sha). Defaults to `main`.\n const sourceRef = opts.ref ?? \"main\";\n\n const { published } = await publishToStore({\n sourceUrl: url,\n ref: sourceRef,\n sidecar: { url: sidecarRepoUrl, ref: commitSha },\n manifest: normalized,\n client: pub,\n });\n\n if (published.length > 0) {\n logInfo(`Consumers can now install them with \\`skaile add ${published[0]}\\`.`);\n }\n}\n\n/**\n * `source manifest yank <src>` — unpublish the source's published assets (all,\n * or the single asset matching `opts.asset`'s name). Auth-gated like publish.\n */\nexport async function runYank(\n arg: string,\n opts: { projectDir: string; asset?: string },\n client?: PublisherClient,\n): Promise<void> {\n const injected = client !== undefined;\n const pub = client ?? makeHttpPublisherClient();\n\n const { url, slug } = resolveSourceArg(arg, opts.projectDir);\n\n if (!injected && !isStoreAuthenticated()) {\n logErr(\"Not signed in — run `skaile store login` first.\");\n process.exit(1);\n }\n\n const rows = await pub.sourcesList();\n const source = rows.find((r) => r.url === url);\n if (!source) {\n logErr(`Source \"${slug}\" is not registered in the store — nothing to yank.`);\n process.exit(1);\n }\n\n // Optionally narrow to a single asset by name (accept a bare name or a ref).\n const targetName = opts.asset ? bareName(opts.asset) : undefined;\n const candidates = (await pub.sourceCandidates(source.id)).filter(\n (c) => c.published && (!targetName || c.name === targetName),\n );\n if (candidates.length === 0) {\n logWarn(\"No published assets matched — nothing to yank.\");\n return;\n }\n\n const yanked: string[] = [];\n for (const c of candidates) {\n try {\n await pub.assetUnpublish(c.id);\n yanked.push(`${c.kind}:${c.name}`);\n } catch (err) {\n logWarn(\n `Failed to yank ${c.kind}:${c.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n logOk(`Yanked ${yanked.length} asset(s):`);\n for (const r of yanked) logInfo(` ${r}`);\n}\n"]}