openplanr 3.3.0 → 3.4.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 (267) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/cli/commands/artifact-design-share.d.ts +9 -0
  3. package/dist/cli/commands/artifact-design-share.d.ts.map +1 -0
  4. package/dist/cli/commands/artifact-design-share.js +200 -0
  5. package/dist/cli/commands/artifact-design-share.js.map +1 -0
  6. package/dist/cli/commands/artifact.d.ts.map +1 -1
  7. package/dist/cli/commands/artifact.js +5 -18
  8. package/dist/cli/commands/artifact.js.map +1 -1
  9. package/dist/cli/commands/ship.d.ts.map +1 -1
  10. package/dist/cli/commands/ship.js +2 -0
  11. package/dist/cli/commands/ship.js.map +1 -1
  12. package/dist/dashboard/.vite/manifest.json +2 -2
  13. package/dist/dashboard/assets/index-Cv4Vwhuw.css +2 -0
  14. package/dist/dashboard/assets/index-CvQAlBy3.js +75 -0
  15. package/dist/dashboard/assets/index-CvQAlBy3.js.map +1 -0
  16. package/dist/dashboard/dashboard-manifest.json +14 -14
  17. package/dist/dashboard/index.html +2 -2
  18. package/dist/services/design-artifact-service.d.ts +20 -1
  19. package/dist/services/design-artifact-service.d.ts.map +1 -1
  20. package/dist/services/design-artifact-service.js +137 -18
  21. package/dist/services/design-artifact-service.js.map +1 -1
  22. package/dist/services/ship-checks/contract.d.ts +3 -1
  23. package/dist/services/ship-checks/contract.d.ts.map +1 -1
  24. package/dist/services/ship-checks/contract.js +1 -1
  25. package/dist/services/ship-checks/contract.js.map +1 -1
  26. package/dist/services/ship-checks/discover.d.ts.map +1 -1
  27. package/dist/services/ship-checks/discover.js +2 -1
  28. package/dist/services/ship-checks/discover.js.map +1 -1
  29. package/dist/services/ship-checks/package-contents.d.ts +4 -0
  30. package/dist/services/ship-checks/package-contents.d.ts.map +1 -0
  31. package/dist/services/ship-checks/package-contents.js +91 -0
  32. package/dist/services/ship-checks/package-contents.js.map +1 -0
  33. package/dist/services/ship-checks/packages.d.ts +2 -0
  34. package/dist/services/ship-checks/packages.d.ts.map +1 -1
  35. package/dist/services/ship-checks/packages.js +4 -0
  36. package/dist/services/ship-checks/packages.js.map +1 -1
  37. package/dist/services/ship-checks/scope.js +2 -1
  38. package/dist/services/ship-checks/scope.js.map +1 -1
  39. package/dist/utils/splice-managed-block.js +1 -1
  40. package/dist/utils/splice-managed-block.js.map +1 -1
  41. package/docs/CLI.md +38 -1
  42. package/lib/host-packages/adapter-registry.json +5 -5
  43. package/lib/host-packages/capability-map.json +1 -1
  44. package/lib/host-packages/claude/.claude-plugin/marketplace.json +3 -3
  45. package/lib/host-packages/claude/openplanr/.claude-plugin/plugin.json +6 -6
  46. package/lib/host-packages/claude/openplanr/.openplanr-content.json +67 -123
  47. package/lib/host-packages/claude/openplanr/README.md +12 -12
  48. package/lib/host-packages/claude/openplanr/references/agents/shared/modes/shared/task-context-resolution.md +4 -4
  49. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-artifact-shell.mjs +2 -4
  50. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-document.mjs +26 -26
  51. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-handoff.mjs +850 -56
  52. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review-state-store.mjs +45 -0
  53. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review.mjs +65 -74
  54. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -1
  55. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +321 -0
  56. package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs → claude/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs} +762 -223
  57. package/lib/host-packages/{openai/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs → claude/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-9f6918b0.mjs} +537 -5
  58. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +137 -0
  59. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design.mjs +107 -37
  60. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -27
  61. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +138 -133
  62. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +1 -5684
  63. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +2568 -0
  64. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +10 -74
  65. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
  66. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +8 -2
  67. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +5 -1
  68. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +545 -4781
  69. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design.mjs +219 -452
  70. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +5 -1
  71. package/lib/host-packages/claude/openplanr/skills/delegate/SKILL.md +2 -1
  72. package/lib/host-packages/claude/openplanr/skills/delegate/references/integration-review.md +26 -20
  73. package/lib/host-packages/claude/openplanr/skills/delegate/references/operator-guide.md +25 -1
  74. package/lib/host-packages/claude/openplanr/skills/delegate/references/run-handoff.md +2 -2
  75. package/lib/host-packages/claude/openplanr/skills/delegate/references/worktree-custody.md +17 -9
  76. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/adapters/claude.mjs +15 -3
  77. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/adapters/codex.mjs +38 -2
  78. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/adapters/native.mjs +5 -0
  79. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/custody.mjs +217 -10
  80. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/handoff.mjs +1080 -0
  81. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/integrate.mjs +96 -201
  82. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/integration-files.mjs +3 -382
  83. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/presentation.mjs +29 -12
  84. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-contract.mjs +11 -0
  85. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-execution.mjs +1 -1
  86. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-lifecycle.mjs +14 -10
  87. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-preparation.mjs +4 -0
  88. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-record.mjs +2 -2
  89. package/lib/host-packages/claude/openplanr/skills/design/references/utilities.md +14 -8
  90. package/lib/host-packages/claude/openplanr/skills/design-loop/references/utilities.md +14 -8
  91. package/lib/host-packages/claude/openplanr/skills/design-review/references/utilities.md +14 -8
  92. package/lib/host-packages/claude/openplanr/skills/investigate/SKILL.md +1 -0
  93. package/lib/host-packages/claude/openplanr/skills/investigate/references/fail-first.md +40 -0
  94. package/lib/host-packages/claude/openplanr/skills/ship/SKILL.md +22 -10
  95. package/lib/host-packages/claude/openplanr/skills/ship/references/fail-first.md +40 -0
  96. package/lib/host-packages/claude/openplanr/skills/ship/references/result-contract.md +7 -3
  97. package/lib/host-packages/cursor/openplanr/.openplanr-content.json +65 -121
  98. package/lib/host-packages/cursor/openplanr/manifest.json +1 -1
  99. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/integration-review.md +26 -20
  100. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/operator-guide.md +25 -1
  101. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/run-handoff.md +2 -2
  102. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/worktree-custody.md +17 -9
  103. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/adapters/claude.mjs +15 -3
  104. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/adapters/codex.mjs +38 -2
  105. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/adapters/native.mjs +5 -0
  106. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/custody.mjs +217 -10
  107. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/handoff.mjs +1080 -0
  108. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/integrate.mjs +96 -201
  109. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/integration-files.mjs +3 -382
  110. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/presentation.mjs +29 -12
  111. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-contract.mjs +11 -0
  112. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-execution.mjs +1 -1
  113. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-lifecycle.mjs +14 -10
  114. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-preparation.mjs +4 -0
  115. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-record.mjs +2 -2
  116. package/lib/host-packages/cursor/openplanr/rules/planr-delegate.mdc +2 -1
  117. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/utilities.md +14 -8
  118. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/utilities.md +14 -8
  119. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/utilities.md +14 -8
  120. package/lib/host-packages/cursor/openplanr/rules/planr-investigate/references/fail-first.md +40 -0
  121. package/lib/host-packages/cursor/openplanr/rules/planr-investigate.mdc +1 -0
  122. package/lib/host-packages/cursor/openplanr/rules/planr-ship/references/fail-first.md +40 -0
  123. package/lib/host-packages/cursor/openplanr/rules/planr-ship/references/result-contract.md +7 -3
  124. package/lib/host-packages/cursor/openplanr/rules/planr-ship.mdc +22 -10
  125. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-artifact-shell.mjs +2 -4
  126. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-document.mjs +26 -26
  127. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-handoff.mjs +850 -56
  128. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review-state-store.mjs +45 -0
  129. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review.mjs +65 -74
  130. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -1
  131. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +321 -0
  132. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/{design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs → design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs} +762 -223
  133. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/{design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs → design-shared-artifact-support-protocol-contracts-9f6918b0.mjs} +537 -5
  134. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +137 -0
  135. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design.mjs +107 -37
  136. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -27
  137. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +138 -133
  138. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +1 -5684
  139. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +2568 -0
  140. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +10 -74
  141. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
  142. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +8 -2
  143. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +5 -1
  144. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +545 -4781
  145. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design.mjs +219 -452
  146. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +5 -1
  147. package/lib/host-packages/openai/.claude-plugin/marketplace.json +3 -3
  148. package/lib/host-packages/openai/openplanr/.codex-plugin/plugin.json +2 -2
  149. package/lib/host-packages/openai/openplanr/.openplanr-content.json +68 -124
  150. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-artifact-shell.mjs +2 -4
  151. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-document.mjs +26 -26
  152. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-handoff.mjs +850 -56
  153. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review-state-store.mjs +45 -0
  154. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review.mjs +65 -74
  155. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -1
  156. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +321 -0
  157. package/lib/host-packages/{claude/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs → openai/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs} +762 -223
  158. package/lib/host-packages/{claude/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs → openai/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-9f6918b0.mjs} +537 -5
  159. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +137 -0
  160. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design.mjs +107 -37
  161. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -27
  162. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +138 -133
  163. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +1 -5684
  164. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +2568 -0
  165. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +10 -74
  166. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/package.json +3 -3
  167. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +8 -2
  168. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +5 -1
  169. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +545 -4781
  170. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design.mjs +219 -452
  171. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +5 -1
  172. package/lib/host-packages/openai/openplanr/skills/delegate/SKILL.md +2 -1
  173. package/lib/host-packages/openai/openplanr/skills/delegate/openplanr.skill.json +1 -1
  174. package/lib/host-packages/openai/openplanr/skills/delegate/references/integration-review.md +26 -20
  175. package/lib/host-packages/openai/openplanr/skills/delegate/references/operator-guide.md +25 -1
  176. package/lib/host-packages/openai/openplanr/skills/delegate/references/run-handoff.md +2 -2
  177. package/lib/host-packages/openai/openplanr/skills/delegate/references/worktree-custody.md +17 -9
  178. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/adapters/claude.mjs +15 -3
  179. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/adapters/codex.mjs +38 -2
  180. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/adapters/native.mjs +5 -0
  181. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/custody.mjs +217 -10
  182. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/handoff.mjs +1080 -0
  183. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/integrate.mjs +96 -201
  184. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/integration-files.mjs +3 -382
  185. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/presentation.mjs +29 -12
  186. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-contract.mjs +11 -0
  187. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-execution.mjs +1 -1
  188. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-lifecycle.mjs +14 -10
  189. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-preparation.mjs +4 -0
  190. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-record.mjs +2 -2
  191. package/lib/host-packages/openai/openplanr/skills/design/references/utilities.md +14 -8
  192. package/lib/host-packages/openai/openplanr/skills/design-loop/references/utilities.md +14 -8
  193. package/lib/host-packages/openai/openplanr/skills/design-review/references/utilities.md +14 -8
  194. package/lib/host-packages/openai/openplanr/skills/investigate/SKILL.md +1 -0
  195. package/lib/host-packages/openai/openplanr/skills/investigate/openplanr.skill.json +12 -1
  196. package/lib/host-packages/openai/openplanr/skills/investigate/references/fail-first.md +40 -0
  197. package/lib/host-packages/openai/openplanr/skills/ship/SKILL.md +22 -10
  198. package/lib/host-packages/openai/openplanr/skills/ship/openplanr.skill.json +12 -1
  199. package/lib/host-packages/openai/openplanr/skills/ship/references/fail-first.md +40 -0
  200. package/lib/host-packages/openai/openplanr/skills/ship/references/result-contract.md +7 -3
  201. package/package.json +8 -8
  202. package/dist/dashboard/assets/index-BU5fzjyz.css +0 -1
  203. package/dist/dashboard/assets/index-B_96uzCl.js +0 -572
  204. package/dist/dashboard/assets/index-B_96uzCl.js.map +0 -1
  205. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +0 -555
  206. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-compression.mjs +0 -4180
  207. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +0 -647
  208. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-owner-custody.mjs +0 -129
  209. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-resource-pack.mjs +0 -698
  210. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-support-25485dbf1cb2.mjs +0 -24
  211. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-share.mjs +0 -1993
  212. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +0 -222
  213. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-protocol-contracts-b5f28f94.mjs +0 -5907
  214. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-upload-spool.mjs +0 -198
  215. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +0 -4175
  216. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +0 -65
  217. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +0 -1755
  218. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +0 -62
  219. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +0 -2633
  220. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-paste.schema.json +0 -49
  221. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-workspace.schema.json +0 -108
  222. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-create.schema.json +0 -170
  223. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-event.schema.json +0 -97
  224. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-revision.schema.json +0 -56
  225. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/integration-transaction.mjs +0 -958
  226. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/integration-transaction.mjs +0 -958
  227. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +0 -555
  228. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-compression.mjs +0 -4180
  229. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +0 -647
  230. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-owner-custody.mjs +0 -129
  231. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-resource-pack.mjs +0 -698
  232. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-support-25485dbf1cb2.mjs +0 -24
  233. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-share.mjs +0 -1993
  234. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +0 -222
  235. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-protocol-contracts-b5f28f94.mjs +0 -5907
  236. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-upload-spool.mjs +0 -198
  237. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +0 -4175
  238. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +0 -65
  239. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +0 -1755
  240. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +0 -62
  241. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +0 -2633
  242. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-paste.schema.json +0 -49
  243. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-workspace.schema.json +0 -108
  244. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-create.schema.json +0 -170
  245. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-event.schema.json +0 -97
  246. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-revision.schema.json +0 -56
  247. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +0 -555
  248. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-compression.mjs +0 -4180
  249. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +0 -647
  250. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-owner-custody.mjs +0 -129
  251. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-resource-pack.mjs +0 -698
  252. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-support-25485dbf1cb2.mjs +0 -24
  253. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-share.mjs +0 -1993
  254. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +0 -222
  255. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-protocol-contracts-b5f28f94.mjs +0 -5907
  256. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-upload-spool.mjs +0 -198
  257. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +0 -4175
  258. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +0 -65
  259. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/06-artifact-review-ui.js +0 -1755
  260. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +0 -62
  261. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/08-artifact-review-ui.js +0 -2633
  262. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-paste.schema.json +0 -49
  263. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-workspace.schema.json +0 -108
  264. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-create.schema.json +0 -170
  265. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-event.schema.json +0 -97
  266. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-revision.schema.json +0 -56
  267. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/integration-transaction.mjs +0 -958
@@ -0,0 +1,45 @@
1
+ import {
2
+ planrHome
3
+ } from "./design-runtime-home.mjs";
4
+
5
+ // packages/artifact/lib/artifact/internal/review-state-store.mjs
6
+ import { readdirSync } from "node:fs";
7
+ import { join } from "node:path";
8
+ var RECORD = /^(?:instance-[A-Za-z0-9_-]{22}|state-(?:default|\d+))\.json$/u;
9
+ var AUTHORIZATION_CONTROL_VERSIONS = /* @__PURE__ */ new Set([1, 2]);
10
+ function reviewStateDir(env = process.env) {
11
+ return join(planrHome(env), "artifact-daemon");
12
+ }
13
+ function artifactReviewStatePath(port = 0, env = process.env) {
14
+ const suffix = port === 0 ? "default" : String(port);
15
+ return join(reviewStateDir(env), `state-${suffix}.json`);
16
+ }
17
+ function reviewStateLockPath(port, env = process.env) {
18
+ const suffix = port === 0 ? "default" : String(port);
19
+ return join(reviewStateDir(env), `start-${suffix}.lock`);
20
+ }
21
+ function reviewInstanceStatePath(instanceId, env = process.env) {
22
+ return join(reviewStateDir(env), `instance-${instanceId}.json`);
23
+ }
24
+ function reviewStateRecordPaths(env = process.env) {
25
+ const directory = reviewStateDir(env);
26
+ let names;
27
+ try {
28
+ names = readdirSync(directory);
29
+ } catch (error) {
30
+ if (error?.code === "ENOENT") return [];
31
+ throw error;
32
+ }
33
+ return names.filter((name) => RECORD.test(name)).sort().map((name) => join(directory, name));
34
+ }
35
+ function reviewControlHeaders(state, controlHeader) {
36
+ return AUTHORIZATION_CONTROL_VERSIONS.has(state.serverVersion) ? { authorization: `Bearer ${state.controlToken}` } : { [controlHeader]: state.controlToken };
37
+ }
38
+
39
+ export {
40
+ artifactReviewStatePath,
41
+ reviewStateLockPath,
42
+ reviewInstanceStatePath,
43
+ reviewStateRecordPaths,
44
+ reviewControlHeaders
45
+ };
@@ -1,14 +1,25 @@
1
1
  import {
2
+ ARTIFACT_REVIEW_MAX_STATE_BYTES,
3
+ CLI_COMMAND,
4
+ PLANNING_FOLDER,
2
5
  assertDesignImplementationHandoff,
6
+ createReviewLedger,
3
7
  designImplementationHandoffDigest,
4
8
  designReviewKey,
5
9
  designReviewPath,
10
+ effectiveReviewDecision,
11
+ exportArtifactReview,
6
12
  isDesignHandoffRelativePath,
13
+ mergeReviewLedger,
14
+ readArtifactReviewState,
7
15
  readDesignExperience,
8
16
  readDesignFeedback,
9
17
  readDesignHandoff,
10
18
  readDesignHandoffReadiness,
11
- updateDesignHandoff
19
+ resolveArtifactReviewDestination,
20
+ updateDesignHandoff,
21
+ withArtifactReviewLock,
22
+ writeArtifactReviewState
12
23
  } from "./design-handoff.mjs";
13
24
  import {
14
25
  createArtifactBridgeNonce,
@@ -24,43 +35,46 @@ import {
24
35
  standaloneDesignHtml,
25
36
  timingSafeTokenEqual
26
37
  } from "./design-document.mjs";
38
+ import {
39
+ canonicalizeJson,
40
+ listDesignRevisions,
41
+ readDesignRevision,
42
+ reviewDigest
43
+ } from "./design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs";
44
+ import {
45
+ reviewControlHeaders,
46
+ reviewInstanceStatePath,
47
+ reviewStateRecordPaths
48
+ } from "./design-review-state-store.mjs";
27
49
  import {
28
50
  renderArtifactShellDocument
29
51
  } from "./design-artifact-shell.mjs";
30
52
  import {
31
- ARTIFACT_REVIEW_MAX_STATE_BYTES,
32
- createReviewLedger,
33
- effectiveReviewDecision,
34
- exportArtifactReview,
53
+ ARTIFACT_ERROR_CODES,
54
+ MAX_ARTIFACT_HTML_BYTES,
55
+ PipelineError,
56
+ digestArtifactEnvelope,
57
+ resolveArtifactHtml,
58
+ validateArtifactEnvelope,
59
+ validateArtifactReview
60
+ } from "./design-shared-artifact-support-protocol-contracts-9f6918b0.mjs";
61
+ import {
62
+ defaultDesignRecoveryOutput,
35
63
  exportDesignShareRecovery,
36
64
  getDesignShareStatus,
65
+ getDesignShareStatusAsync,
37
66
  manageDesignShare,
38
- mergeReviewLedger,
39
67
  publishDesignShare,
40
- readArtifactReviewState,
41
- resolveArtifactReviewDestination,
42
68
  shareDesign,
43
- syncDesignShare,
44
- withArtifactReviewLock,
45
- writeArtifactReviewState
46
- } from "./design-share.mjs";
69
+ syncDesignShare
70
+ } from "./design-share-cli-bridge.mjs";
47
71
  import {
48
72
  atomicJson,
49
73
  currentDesign,
50
74
  designSpecPath,
51
75
  hash,
52
- listDesignRevisions,
53
- readDesignRevision,
54
- readJson,
55
- reviewDigest
56
- } from "./design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs";
57
- import {
58
- CLI_COMMAND,
59
- PLANNING_FOLDER
60
- } from "./design-owner-custody.mjs";
61
- import {
62
- planrHome
63
- } from "./design-runtime-home.mjs";
76
+ readJson
77
+ } from "./design-shared-design-support-0bac378d.mjs";
64
78
  import {
65
79
  LOOPBACK_HOST,
66
80
  acquireStartLock,
@@ -72,18 +86,6 @@ import {
72
86
  readRequestBody,
73
87
  writePrivateJsonState
74
88
  } from "./design-loopback-server.mjs";
75
- import {
76
- ARTIFACT_ERROR_CODES,
77
- MAX_ARTIFACT_HTML_BYTES,
78
- PipelineError,
79
- digestArtifactEnvelope,
80
- resolveArtifactHtml,
81
- validateArtifactEnvelope,
82
- validateArtifactReview
83
- } from "./design-shared-artifact-support-protocol-contracts-ea2cd15e.mjs";
84
- import {
85
- canonicalizeJson
86
- } from "./design-shared-protocol-contracts-75a938cc.mjs";
87
89
 
88
90
  // packages/design/lib/design/review-export.mjs
89
91
  function reviewExportTools() {
@@ -420,9 +422,9 @@ import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:f
420
422
  import { dirname as dirname4, join as join5, relative, resolve as resolve3 } from "node:path";
421
423
 
422
424
  // packages/artifact/lib/artifact/review-server.mjs
423
- import { existsSync, lstatSync, readdirSync, readFileSync, rmSync } from "node:fs";
425
+ import { existsSync, lstatSync, readFileSync, rmSync } from "node:fs";
424
426
  import { createServer } from "node:http";
425
- import { dirname, isAbsolute, join, resolve } from "node:path";
427
+ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
426
428
  import { fileURLToPath } from "node:url";
427
429
  var here = dirname(fileURLToPath(new URL("./runtime/packages/artifact/lib/artifact/review-server.mjs", import.meta.url).href));
428
430
  var STAGE_RUNTIME_PATH = join(here, "..", "..", "templates", "artifact-review-stage.js");
@@ -431,7 +433,6 @@ var ARTIFACT_REVIEW_SERVER_KIND = "artifact-review";
431
433
  var CONTROL_HEADER = "x-openplanr-control";
432
434
  var CONTROLLABLE_SERVER_VERSIONS = /* @__PURE__ */ new Set([2, ARTIFACT_REVIEW_SERVER_VERSION]);
433
435
  var EXPORT_ONLY_SERVER_VERSIONS = /* @__PURE__ */ new Set([1]);
434
- var AUTHORIZATION_CONTROL_VERSIONS = /* @__PURE__ */ new Set([1, 2]);
435
436
  var CONTROL_WINDOW_BYTES = 64 * 1024 * 1024;
436
437
  var ARTIFACT_REVIEW_MAX_CONTROL_BYTES = Math.ceil((MAX_ARTIFACT_HTML_BYTES * 2 + ARTIFACT_REVIEW_MAX_STATE_BYTES) / CONTROL_WINDOW_BYTES) * CONTROL_WINDOW_BYTES;
437
438
  var ARTIFACT_REVIEW_MAX_STATE_BYTES2 = ARTIFACT_REVIEW_MAX_STATE_BYTES;
@@ -491,10 +492,7 @@ function artifactReviewControlHeaders(controlToken) {
491
492
  return { [CONTROL_HEADER]: controlToken };
492
493
  }
493
494
  function stateControlHeaders(state) {
494
- return AUTHORIZATION_CONTROL_VERSIONS.has(state.serverVersion) ? { authorization: `Bearer ${state.controlToken}` } : artifactReviewControlHeaders(state.controlToken);
495
- }
496
- function reviewStateDir(env = process.env) {
497
- return join(planrHome(env), "artifact-daemon");
495
+ return reviewControlHeaders(state, CONTROL_HEADER);
498
496
  }
499
497
  function statusForError(error) {
500
498
  if (error?.code === "E_REQUEST_BODY_LIMIT" || error?.code === ARTIFACT_ERROR_CODES.REQUEST_LIMIT)
@@ -832,7 +830,7 @@ function createArtifactReviewServer({
832
830
  }
833
831
  if (serverMetadata !== void 0 && (!serverMetadata || !["artifact", "design", "diagram"].includes(serverMetadata.kind) || typeof serverMetadata.projectRoot !== "string" || !isAbsolute(serverMetadata.projectRoot)))
834
832
  throw artifactError(ARTIFACT_ERROR_CODES.LOOPBACK_STATE, "Local server metadata is invalid.");
835
- const instanceStatePath = serverMetadata ? join(reviewStateDir(env), `instance-${instanceId}.json`) : null;
833
+ const instanceStatePath = serverMetadata ? reviewInstanceStatePath(instanceId, env) : null;
836
834
  const sessions = /* @__PURE__ */ new Map();
837
835
  const pendingStudioIds = /* @__PURE__ */ new Set();
838
836
  const pendingMutations = /* @__PURE__ */ new Set();
@@ -1501,20 +1499,11 @@ async function controlRequest(descriptor, path, { method, body, fetchImpl } = {}
1501
1499
  return value;
1502
1500
  }
1503
1501
  async function discoveredArtifactServers({ env, fetchImpl }) {
1504
- let names;
1505
- try {
1506
- names = readdirSync(reviewStateDir(env));
1507
- } catch (error) {
1508
- if (error.code === "ENOENT") return [];
1509
- throw error;
1510
- }
1511
1502
  const live = /* @__PURE__ */ new Map();
1512
- for (const name of names.sort()) {
1513
- if (!/^(?:instance-[A-Za-z0-9_-]{22}|state-(?:default|\d+))\.json$/u.test(name)) continue;
1514
- const path = join(reviewStateDir(env), name);
1503
+ for (const path of reviewStateRecordPaths(env)) {
1515
1504
  const state = readReviewServerState(path);
1516
1505
  if (!validState(state, 0) || !await stateIsHealthy(state, fetchImpl)) continue;
1517
- if (!live.has(state.instanceId) || name.startsWith("instance-"))
1506
+ if (!live.has(state.instanceId) || basename(path).startsWith("instance-"))
1518
1507
  live.set(state.instanceId, state);
1519
1508
  }
1520
1509
  return [...live.values()];
@@ -1550,7 +1539,7 @@ async function stopArtifactReviewServer(instanceId, { env = process.env, fetchIm
1550
1539
  }
1551
1540
 
1552
1541
  // packages/protocol/src/planning-folder.mjs
1553
- import { existsSync as existsSync2, readdirSync as readdirSync2, statSync } from "node:fs";
1542
+ import { existsSync as existsSync2, readdirSync, statSync } from "node:fs";
1554
1543
  import { join as join2 } from "node:path";
1555
1544
  var FOREIGN_FILES = Object.freeze(["planr.config.json", "board.html"]);
1556
1545
  var GOAL_DIRECTORIES = Object.freeze(["tasks", "plans"]);
@@ -1561,7 +1550,7 @@ function foreignPlanningFolderSigns(projectRoot2) {
1561
1550
  const signs = FOREIGN_FILES.filter((name) => existsSync2(join2(folder, name)));
1562
1551
  for (const name of GOAL_DIRECTORIES) {
1563
1552
  const directory = join2(folder, name);
1564
- if (isDirectory(directory) && readdirSync2(directory).some((entry) => entry.endsWith("-goal.md")))
1553
+ if (isDirectory(directory) && readdirSync(directory).some((entry) => entry.endsWith("-goal.md")))
1565
1554
  signs.push(`*-goal.md files in ${name}`);
1566
1555
  }
1567
1556
  return signs;
@@ -1945,7 +1934,7 @@ import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypt
1945
1934
  import {
1946
1935
  existsSync as existsSync4,
1947
1936
  mkdirSync as mkdirSync2,
1948
- readdirSync as readdirSync3,
1937
+ readdirSync as readdirSync2,
1949
1938
  readFileSync as readFileSync3,
1950
1939
  renameSync as renameSync2,
1951
1940
  rmSync as rmSync3,
@@ -2125,7 +2114,7 @@ function listImplementationHandoffHistory(root) {
2125
2114
  recoverImplementationHandoffApproval(root);
2126
2115
  const directory = implementationHandoffPaths(root).history;
2127
2116
  if (!existsSync4(directory)) return [];
2128
- return readdirSync3(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map(
2117
+ return readdirSync2(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map(
2129
2118
  (entry) => assertImplementationHandoffProjection(readJson2(join4(directory, entry.name, "handoff.json")))
2130
2119
  ).sort((left, right) => left.version - right.version || left.id.localeCompare(right.id));
2131
2120
  }
@@ -2133,7 +2122,7 @@ function readImplementationHandoffLifecycle(root) {
2133
2122
  recoverImplementationHandoffApproval(root);
2134
2123
  const paths = implementationHandoffApprovalPaths(root);
2135
2124
  const current = readJson2(paths.current, null);
2136
- const events = existsSync4(paths.events) ? readdirSync3(paths.events).filter((name) => name.endsWith(".json")).map((name) => readJson2(join4(paths.events, name))).sort(
2125
+ const events = existsSync4(paths.events) ? readdirSync2(paths.events).filter((name) => name.endsWith(".json")).map((name) => readJson2(join4(paths.events, name))).sort(
2137
2126
  (left, right) => left.at.localeCompare(right.at) || left.eventId.localeCompare(right.eventId)
2138
2127
  ) : [];
2139
2128
  return Object.freeze({ current, history: listImplementationHandoffHistory(root), events });
@@ -2489,7 +2478,7 @@ function studioContentIdentity(current) {
2489
2478
  })
2490
2479
  );
2491
2480
  }
2492
- function exportDesignReview(file, { scope = "all", env = process.env } = {}) {
2481
+ function exportDesignReview(file, { scope = "all", env = process.env, shared: known } = {}) {
2493
2482
  if (!["all", "current"].includes(scope))
2494
2483
  throw new Error("Review export scope must be current or all.");
2495
2484
  const current = currentDesign(file), feedback = readDesignFeedback(file, env);
@@ -2518,11 +2507,12 @@ function exportDesignReview(file, { scope = "all", env = process.env } = {}) {
2518
2507
  const byDigest = /* @__PURE__ */ new Map();
2519
2508
  for (const value of local.values())
2520
2509
  byDigest.set(value.reviewOf, [...byDigest.get(value.reviewOf) ?? [], value]);
2521
- let shared = null;
2522
- try {
2523
- shared = getDesignShareStatus(file, { env });
2524
- } catch {
2525
- }
2510
+ let shared = known ?? null;
2511
+ if (known === void 0)
2512
+ try {
2513
+ shared = getDesignShareStatus(file, { env });
2514
+ } catch {
2515
+ }
2526
2516
  const currentRevisionId = shared?.publishedRevision === current.revision && shared?.revision ? shared.revision : current.revision;
2527
2517
  const revisions = [...local.values()];
2528
2518
  const entries = (feedback.ledger?.reviews ?? []).filter(
@@ -3120,8 +3110,13 @@ ${renderArtifactParentRuntime({ ...options, adapterRuntimeUrl: `${base}api/desig
3120
3110
  } else if (route === "design-feedback-export") {
3121
3111
  if (!input || typeof input !== "object" || Array.isArray(input) || Object.keys(input).some((key) => key !== "scope") || input.scope !== void 0 && !["all", "current"].includes(input.scope))
3122
3112
  throw new Error("Review export requires scope current or all.");
3123
- await syncDesignShare(file, { env, fetchImpl });
3124
- respond(res, 200, exportDesignReview(file, { scope: input.scope ?? "all", env }));
3113
+ await syncDesignShare(file, { env, fetchImpl, unavailable: "skip" });
3114
+ const shared = await getDesignShareStatusAsync(file, { env }).catch(() => null);
3115
+ respond(
3116
+ res,
3117
+ 200,
3118
+ exportDesignReview(file, { scope: input.scope ?? "all", env, shared })
3119
+ );
3125
3120
  } else {
3126
3121
  if (!input || typeof input !== "object" || Array.isArray(input) || Object.keys(input).some((key) => !["revision", "artifactIds"].includes(key)) || input.artifactIds !== void 0 && (!Array.isArray(input.artifactIds) || input.artifactIds.length < 1 || input.artifactIds.length > 2 || input.artifactIds.some((id) => typeof id !== "string") || new Set(input.artifactIds).size !== input.artifactIds.length))
3127
3122
  throw new Error("Revision comparison requires one or two distinct view IDs.");
@@ -3160,7 +3155,7 @@ ${renderArtifactParentRuntime({ ...options, adapterRuntimeUrl: `${base}api/desig
3160
3155
  readFileSync4(new URL("../../templates/studio/share.js", new URL("./runtime/packages/design/lib/design/review.mjs", import.meta.url).href), "utf8")
3161
3156
  );
3162
3157
  } else if (route === "design-share" && req.method === "GET") {
3163
- respond(res, 200, getDesignShareStatus(file, { env }));
3158
+ respond(res, 200, await getDesignShareStatusAsync(file, { env }));
3164
3159
  } else if (route === "design-share" && req.method === "POST") {
3165
3160
  if (req.headers["x-openplanr-design"] !== "1" || !String(req.headers["content-type"] ?? "").startsWith("application/json"))
3166
3161
  throw Object.assign(new Error("Sharing requires a same-origin studio request."), {
@@ -3180,11 +3175,7 @@ ${renderArtifactParentRuntime({ ...options, adapterRuntimeUrl: `${base}api/desig
3180
3175
  else if (action === "recovery")
3181
3176
  result = await exportDesignShareRecovery(file, {
3182
3177
  ...options,
3183
- output: join5(
3184
- env.HOME ?? process.env.HOME,
3185
- "Downloads",
3186
- `openplanr-design-recovery-${Date.now()}.json`
3187
- )
3178
+ output: defaultDesignRecoveryOutput(env)
3188
3179
  });
3189
3180
  else result = await manageDesignShare(file, action, options);
3190
3181
  respond(res, 200, result);
@@ -34,6 +34,5 @@ function planrHome(env = process.env) {
34
34
  }
35
35
 
36
36
  export {
37
- configuredPlanrHome,
38
37
  planrHome
39
38
  };
@@ -0,0 +1,321 @@
1
+ import {
2
+ currentDesign
3
+ } from "./design-shared-design-support-0bac378d.mjs";
4
+ import {
5
+ planrHome
6
+ } from "./design-runtime-home.mjs";
7
+
8
+ // packages/design/lib/design/recovery-location.mjs
9
+ import { chmodSync, mkdirSync } from "node:fs";
10
+ import { join } from "node:path";
11
+ function defaultDesignRecoveryOutput(env = process.env, now = Date.now()) {
12
+ const directory = join(planrHome(env), "design-recovery");
13
+ mkdirSync(directory, { recursive: true, mode: 448 });
14
+ chmodSync(directory, 448);
15
+ return join(directory, `openplanr-design-recovery-${now}.json`);
16
+ }
17
+
18
+ // packages/design/lib/design/share-cli-bridge.mjs
19
+ import { execFile, execFileSync } from "node:child_process";
20
+ import { existsSync, readFileSync } from "node:fs";
21
+ import { join as join2 } from "node:path";
22
+
23
+ // packages/design/lib/design/share-compat.mjs
24
+ var DESIGN_SHARE_COMPAT = 1;
25
+
26
+ // packages/design/lib/design/share-cli-bridge.mjs
27
+ var CLI = "openplanr";
28
+ var UPLOAD_TIMEOUT_MS = 30 * 6e4;
29
+ var TIMEOUT_MS = 12e4;
30
+ var STATUS_TIMEOUT_MS = 5e3;
31
+ var FAILED_HANDSHAKE_TTL_MS = 3e4;
32
+ var STATUS_TTL_MS = 1e4;
33
+ var INSTALL = "Install the OpenPlanr CLI with `npm install -g openplanr`, then retry; your local design is unchanged.";
34
+ var UNAVAILABLE = Object.freeze([
35
+ "E_DESIGN_SHARE_CLI_REQUIRED",
36
+ "E_DESIGN_SHARE_CLI_UNRESPONSIVE",
37
+ "E_DESIGN_SHARE_RUNTIME_MISMATCH",
38
+ "E_DESIGN_SHARE_PIPELINE_MISSING"
39
+ ]);
40
+ function shareError(code, message, fix) {
41
+ return Object.assign(new Error(fix ? `${message} ${fix}` : message), { code, name: code });
42
+ }
43
+ function cliMissing() {
44
+ return shareError(
45
+ "E_DESIGN_SHARE_CLI_REQUIRED",
46
+ "Sharing runs in the OpenPlanr CLI, which is not installed.",
47
+ INSTALL
48
+ );
49
+ }
50
+ function pathOf(env) {
51
+ const key = Object.keys(env).find((name) => name.toUpperCase() === "PATH");
52
+ return key ? env[key] ?? "" : "";
53
+ }
54
+ function cliLauncher({
55
+ platform = process.platform,
56
+ env = process.env,
57
+ execPath = process.execPath
58
+ } = {}) {
59
+ if (platform !== "win32") return { file: CLI, args: [] };
60
+ for (const directory of pathOf(env).split(";").filter(Boolean)) {
61
+ const shim = join2(directory, `${CLI}.cmd`);
62
+ if (!existsSync(shim)) continue;
63
+ const target = /"%~?dp0%?\\([^"\r\n]+?\.js)"/iu.exec(readFileSync(shim, "utf8"))?.[1];
64
+ const script = target ? join2(directory, ...target.split("\\")) : join2(directory, "node_modules", CLI, "bin", `${CLI}.js`);
65
+ if (existsSync(script)) return { file: execPath, args: [script] };
66
+ }
67
+ return null;
68
+ }
69
+ function lastJsonLine(stdout) {
70
+ const line = String(stdout ?? "").trim().split("\n").at(-1);
71
+ try {
72
+ return line ? JSON.parse(line) : null;
73
+ } catch {
74
+ return null;
75
+ }
76
+ }
77
+ function settle(command, timeout, error, stdout, stderr) {
78
+ if (error?.code === "ENOENT") throw cliMissing();
79
+ if (error?.code === "ETIMEDOUT" || error?.killed || error?.signal)
80
+ throw shareError(
81
+ "E_DESIGN_SHARE_CLI_UNRESPONSIVE",
82
+ `The OpenPlanr CLI did not finish \`artifact ${command}\` within ${Math.round(timeout / 1e3)} s.`,
83
+ "Check that `openplanr --version` answers, then retry."
84
+ );
85
+ const value = lastJsonLine(stdout);
86
+ if (!error && value && value.ok !== false) return value;
87
+ if (value && value.ok === false)
88
+ throw shareError(
89
+ value.code ?? "E_DESIGN_SHARE_FAILED",
90
+ value.problem ?? "The OpenPlanr CLI could not complete the sharing operation.",
91
+ value.recovery
92
+ );
93
+ const detail = String(stderr ?? "").trim().split("\n").at(-1) || error?.message || "no output";
94
+ throw shareError(
95
+ "E_DESIGN_SHARE_FAILED",
96
+ `openplanr artifact ${command} failed without a JSON result: ${detail}`
97
+ );
98
+ }
99
+ function argv(command, file, flags) {
100
+ return ["artifact", command, ...flags, "--json", ...file === void 0 ? [] : ["--", file]];
101
+ }
102
+ function launch(env) {
103
+ const launcher = cliLauncher({ env });
104
+ if (!launcher) throw cliMissing();
105
+ return launcher;
106
+ }
107
+ function runSync(command, file, flags, { env = process.env, timeout = STATUS_TIMEOUT_MS } = {}) {
108
+ const { file: program, args } = launch(env);
109
+ let stdout;
110
+ try {
111
+ stdout = execFileSync(program, [...args, ...argv(command, file, flags)], {
112
+ env,
113
+ encoding: "utf8",
114
+ stdio: ["ignore", "pipe", "pipe"],
115
+ timeout,
116
+ windowsHide: true
117
+ });
118
+ } catch (error) {
119
+ return settle(command, timeout, error, error?.stdout, error?.stderr);
120
+ }
121
+ return settle(command, timeout, null, stdout, "");
122
+ }
123
+ function runAsync(command, file, flags, { env = process.env, input, timeout = TIMEOUT_MS } = {}) {
124
+ return new Promise((resolve, reject) => {
125
+ const { file: program, args } = launch(env);
126
+ const child = execFile(
127
+ program,
128
+ [...args, ...argv(command, file, flags)],
129
+ { env, encoding: "utf8", timeout, windowsHide: true, maxBuffer: 16 * 1024 * 1024 },
130
+ (error, stdout, stderr) => {
131
+ try {
132
+ resolve(settle(command, timeout, error, stdout, stderr));
133
+ } catch (failure) {
134
+ reject(failure);
135
+ }
136
+ }
137
+ );
138
+ child.stdin?.end(input ?? "");
139
+ });
140
+ }
141
+ function compatibility(runtime, error) {
142
+ if (error) {
143
+ if (UNAVAILABLE.includes(error.code)) return { error };
144
+ return {
145
+ error: shareError(
146
+ "E_DESIGN_SHARE_RUNTIME_MISMATCH",
147
+ `The installed OpenPlanr CLI is too old to share designs for this skill (${error.message}).`,
148
+ "Update the CLI with `npm install -g openplanr`, then retry."
149
+ )
150
+ };
151
+ }
152
+ if (runtime.designShareCompat === DESIGN_SHARE_COMPAT) return { runtime };
153
+ const older = typeof runtime.designShareCompat !== "number" || runtime.designShareCompat < DESIGN_SHARE_COMPAT;
154
+ return {
155
+ error: shareError(
156
+ "E_DESIGN_SHARE_RUNTIME_MISMATCH",
157
+ `The installed OpenPlanr CLI (${runtime.cli}) shares designs in format ${runtime.designShareCompat ?? "unknown"}, but this skill uses format ${DESIGN_SHARE_COMPAT}.`,
158
+ older ? "Update the CLI with `npm install -g openplanr`, then retry." : "Update the OpenPlanr plugin or skills to match the CLI, then retry."
159
+ )
160
+ };
161
+ }
162
+ var handshakes = /* @__PURE__ */ new Map();
163
+ function remembered(env) {
164
+ const known = handshakes.get(pathOf(env));
165
+ if (known?.outcome?.error && Date.now() - known.at > FAILED_HANDSHAKE_TTL_MS) {
166
+ handshakes.delete(pathOf(env));
167
+ return void 0;
168
+ }
169
+ return known;
170
+ }
171
+ function remember(env, outcome) {
172
+ handshakes.set(pathOf(env), { at: Date.now(), outcome });
173
+ return outcome;
174
+ }
175
+ function outcomeOf(outcome) {
176
+ if (outcome.error) throw outcome.error;
177
+ return outcome.runtime;
178
+ }
179
+ function requireCompatibleRuntime(env = process.env) {
180
+ const known = remembered(env);
181
+ if (known?.outcome) return outcomeOf(known.outcome);
182
+ let outcome;
183
+ try {
184
+ outcome = compatibility(runSync("share-runtime", void 0, [], { env }));
185
+ } catch (error) {
186
+ outcome = compatibility(null, error);
187
+ }
188
+ return outcomeOf(remember(env, outcome));
189
+ }
190
+ async function requireCompatibleRuntimeAsync(env = process.env) {
191
+ const known = remembered(env);
192
+ if (known?.outcome) return outcomeOf(known.outcome);
193
+ if (known?.pending) return outcomeOf(await known.pending);
194
+ const pending = runAsync("share-runtime", void 0, [], {
195
+ env,
196
+ timeout: STATUS_TIMEOUT_MS
197
+ }).then(
198
+ (runtime) => remember(env, compatibility(runtime)),
199
+ (error) => remember(env, compatibility(null, error))
200
+ );
201
+ handshakes.set(pathOf(env), { at: Date.now(), pending });
202
+ return outcomeOf(await pending);
203
+ }
204
+ var statuses = /* @__PURE__ */ new Map();
205
+ function statusKey(file, env) {
206
+ try {
207
+ return `${pathOf(env)}\0${file}\0${currentDesign(file).revision}`;
208
+ } catch {
209
+ return null;
210
+ }
211
+ }
212
+ function forget(file) {
213
+ for (const key of statuses.keys()) if (key.split("\0")[1] === file) statuses.delete(key);
214
+ }
215
+ function cachedStatus(key) {
216
+ const known = key && statuses.get(key);
217
+ return known && Date.now() - known.at <= STATUS_TTL_MS ? known.value : void 0;
218
+ }
219
+ function unavailableStatus(error) {
220
+ if (!UNAVAILABLE.includes(error.code)) throw error;
221
+ return { ok: true, shared: false, unavailable: { code: error.code, message: error.message } };
222
+ }
223
+ function required(value, flag, action) {
224
+ if (typeof value !== "string" || !value)
225
+ throw shareError("E_DESIGN_SHARE_INPUT_INVALID", `${action} requires ${flag}.`);
226
+ return value;
227
+ }
228
+ async function share(command, file, flags = [], options = {}) {
229
+ await requireCompatibleRuntimeAsync(options.env);
230
+ try {
231
+ return await runAsync(command, file, flags, options);
232
+ } finally {
233
+ forget(file);
234
+ }
235
+ }
236
+ function assertDesignShareAvailable({ env } = {}) {
237
+ requireCompatibleRuntime(env);
238
+ }
239
+ async function shareDesign(file, options = {}) {
240
+ return share("share", file, ["--yes", "--no-open"], { ...options, timeout: UPLOAD_TIMEOUT_MS });
241
+ }
242
+ async function publishDesignShare(file, options = {}) {
243
+ return share("publish", file, ["--yes"], { ...options, timeout: UPLOAD_TIMEOUT_MS });
244
+ }
245
+ async function syncDesignShare(file, options = {}) {
246
+ try {
247
+ return await share("sync", file, [], options);
248
+ } catch (error) {
249
+ if (options.unavailable === "skip" && UNAVAILABLE.includes(error.code))
250
+ return { ok: true, skipped: error.code, reason: error.message };
251
+ throw error;
252
+ }
253
+ }
254
+ async function manageDesignShare(file, action, options = {}) {
255
+ return share("manage", file, ["--action", action, "--yes"], options);
256
+ }
257
+ async function exportDesignShareRecovery(file, { output, ...options } = {}) {
258
+ return share(
259
+ "manage",
260
+ file,
261
+ ["--action", "recovery", ...output ? ["--output", output] : []],
262
+ options
263
+ );
264
+ }
265
+ async function importDesignShareRecovery(file, { input, ...options } = {}) {
266
+ const path = required(input, "--input <private recovery file>", "Recovery restore");
267
+ return share("manage", file, ["--action", "restore", "--input", path, "--yes"], options);
268
+ }
269
+ async function publishDesignReviewMetadata(file, payload, { revisionId, ...options } = {}) {
270
+ const revision = required(
271
+ revisionId,
272
+ "--revision <shared revision>",
273
+ "Publishing review metadata"
274
+ );
275
+ return share("review-metadata", file, ["--revision", revision, "--input", "-"], {
276
+ ...options,
277
+ input: JSON.stringify(payload)
278
+ });
279
+ }
280
+ function getDesignShareStatus(file, { env } = {}) {
281
+ const key = statusKey(file, env);
282
+ const known = cachedStatus(key);
283
+ if (known) return known;
284
+ let value;
285
+ try {
286
+ requireCompatibleRuntime(env);
287
+ value = runSync("status", file, [], { env });
288
+ } catch (error) {
289
+ value = unavailableStatus(error);
290
+ }
291
+ if (key) statuses.set(key, { at: Date.now(), value });
292
+ return value;
293
+ }
294
+ async function getDesignShareStatusAsync(file, { env } = {}) {
295
+ const key = statusKey(file, env);
296
+ const known = cachedStatus(key);
297
+ if (known) return known;
298
+ let value;
299
+ try {
300
+ await requireCompatibleRuntimeAsync(env);
301
+ value = await runAsync("status", file, [], { env, timeout: STATUS_TIMEOUT_MS });
302
+ } catch (error) {
303
+ value = unavailableStatus(error);
304
+ }
305
+ if (key) statuses.set(key, { at: Date.now(), value });
306
+ return value;
307
+ }
308
+
309
+ export {
310
+ defaultDesignRecoveryOutput,
311
+ assertDesignShareAvailable,
312
+ shareDesign,
313
+ publishDesignShare,
314
+ syncDesignShare,
315
+ manageDesignShare,
316
+ exportDesignShareRecovery,
317
+ importDesignShareRecovery,
318
+ publishDesignReviewMetadata,
319
+ getDesignShareStatus,
320
+ getDesignShareStatusAsync
321
+ };