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
@@ -5,9 +5,9 @@ import { capsuleDirectory } from './capsule.mjs';
5
5
  import { AdapterError, destinationFromEndpoint, invokeProcess } from './generic.mjs';
6
6
  import {
7
7
  createNativeProgress,
8
+ EDIT_DEFAULT_EXECUTION_POLICY,
8
9
  knownDestination,
9
10
  NATIVE_CAPABILITIES,
10
- NATIVE_EXECUTION_POLICY,
11
11
  nativeFailure,
12
12
  nativeObserver,
13
13
  nativeTurn,
@@ -26,7 +26,7 @@ function routingVariables(env) {
26
26
  );
27
27
  }
28
28
 
29
- // Keeps only routing variables from settings files; callers expose source labels and origins.
29
+ // Keeps routing variables and whether a default permission mode is set; callers expose source labels.
30
30
  async function readClaudeRoutingSettings(profile, env, cwd, options = {}) {
31
31
  const managedRoot =
32
32
  options.managedRoot ??
@@ -108,6 +108,7 @@ async function readClaudeRoutingSettings(profile, env, cwd, options = {}) {
108
108
  inspected.push({
109
109
  source,
110
110
  env: routingVariables(settings.env ?? {}),
111
+ ...(settings.permissions?.defaultMode !== undefined ? { defaultMode: true } : {}),
111
112
  ...(settings.policyHelper ? { opaqueRouting: true } : {}),
112
113
  });
113
114
  } catch (error) {
@@ -202,6 +203,16 @@ export async function resolveClaudeRouting(profile, env, cwd, options) {
202
203
  };
203
204
  }
204
205
 
206
+ // Edit access only when no settings file chooses a mode; unreadable settings count as chosen.
207
+ export async function claudeWriteFlags(profile, env, cwd, options) {
208
+ try {
209
+ const settings = await readClaudeRoutingSettings(profile, env, cwd, options);
210
+ return settings.some((entry) => entry.defaultMode) ? [] : ['--permission-mode', 'acceptEdits'];
211
+ } catch {
212
+ return [];
213
+ }
214
+ }
215
+
205
216
  export async function resolveClaudeDestination(profile, env, cwd) {
206
217
  return (await resolveClaudeRouting(profile, env, cwd)).destination;
207
218
  }
@@ -263,6 +274,7 @@ async function execute({
263
274
  profile.executable,
264
275
  [
265
276
  ...profile.argv,
277
+ ...(await claudeWriteFlags(profile, env, cwd)),
266
278
  '--print',
267
279
  '--output-format',
268
280
  'stream-json',
@@ -317,7 +329,7 @@ export const claudeAdapter = Object.freeze({
317
329
  return {
318
330
  capabilities: NATIVE_CAPABILITIES,
319
331
  ...routing,
320
- executionPolicy: NATIVE_EXECUTION_POLICY,
332
+ executionPolicy: EDIT_DEFAULT_EXECUTION_POLICY,
321
333
  };
322
334
  },
323
335
  run: execute,
@@ -1,11 +1,12 @@
1
+ import { readFile, stat } from 'node:fs/promises';
1
2
  import { join } from 'node:path';
2
3
  import { capsuleDirectory } from './capsule.mjs';
3
4
  import { AdapterError, invokeProcess } from './generic.mjs';
4
5
  import {
5
6
  createNativeProgress,
7
+ EDIT_DEFAULT_EXECUTION_POLICY,
6
8
  knownDestination,
7
9
  NATIVE_CAPABILITIES,
8
- NATIVE_EXECUTION_POLICY,
9
10
  nativeFailure,
10
11
  nativeObserver,
11
12
  nativeTurn,
@@ -31,6 +32,39 @@ export async function resolveCodexDestination(profile, env) {
31
32
  return knownDestination(endpoint);
32
33
  }
33
34
 
35
+ // Any uncommented sandbox_mode key outside an inactive [profiles.<name>] table counts as set.
36
+ function sandboxModeSet(config) {
37
+ const active = /^\s*profile\s*=\s*["']([^"']+)["']/mu.exec(config.split(/^\s*\[/mu)[0])?.[1];
38
+ let skipped = false;
39
+ for (const line of config.split('\n')) {
40
+ const header = /^\s*\[\s*profiles\.(?:"([^"]+)"|'([^']+)'|([A-Za-z0-9_-]+))\s*\]/u.exec(line);
41
+ if (header) skipped = (header[1] ?? header[2] ?? header[3]) !== active;
42
+ else if (/^\s*\[/u.test(line)) skipped = false;
43
+ if (!skipped && /^[^#]*\bsandbox_mode["']?\s*=/u.test(line)) return true;
44
+ }
45
+ return false;
46
+ }
47
+
48
+ // Missing config means no sandbox choice; unreadable or oversized config counts as a choice.
49
+ async function codexConfigChoosesSandbox(path) {
50
+ let config;
51
+ try {
52
+ if ((await stat(path)).size > 64 * 1024) return true;
53
+ config = await readFile(path, 'utf8');
54
+ } catch (error) {
55
+ return error.code !== 'ENOENT';
56
+ }
57
+ return sandboxModeSet(config);
58
+ }
59
+
60
+ // Workspace writes only when neither the user nor the project config chooses a sandbox.
61
+ export async function codexWriteFlags(profile, env, cwd) {
62
+ const home = profile.configDir || env.CODEX_HOME || join(env.HOME ?? '', '.codex');
63
+ for (const path of [join(home, 'config.toml'), join(cwd, '.codex', 'config.toml')])
64
+ if (await codexConfigChoosesSandbox(path)) return [];
65
+ return ['--sandbox', 'workspace-write'];
66
+ }
67
+
34
68
  async function execute({
35
69
  profile,
36
70
  cwd,
@@ -84,6 +118,8 @@ async function execute({
84
118
  const args = [
85
119
  ...profile.argv,
86
120
  'exec',
121
+ // `exec resume` takes no sandbox flag of its own; the parent `exec` flag applies.
122
+ ...(await codexWriteFlags(profile, env, cwd)),
87
123
  ...(sessionId ? ['resume'] : []),
88
124
  '--json',
89
125
  ...(!sessionId ? ['--add-dir', directory] : []),
@@ -141,7 +177,7 @@ export const codexAdapter = Object.freeze({
141
177
  return {
142
178
  capabilities: NATIVE_CAPABILITIES,
143
179
  destination: await resolveCodexDestination(profile, env),
144
- executionPolicy: NATIVE_EXECUTION_POLICY,
180
+ executionPolicy: EDIT_DEFAULT_EXECUTION_POLICY,
145
181
  };
146
182
  },
147
183
  run: execute,
@@ -20,6 +20,11 @@ export const NATIVE_EXECUTION_POLICY = Object.freeze({
20
20
  extensions:
21
21
  'Trusted native hooks, plugins and MCP may execute code or contact additional services. OpenPlanr does not sandbox these extensions.',
22
22
  });
23
+ // Claude Code and Codex start in their edit mode when native settings choose none.
24
+ export const EDIT_DEFAULT_EXECUTION_POLICY = Object.freeze({
25
+ ...NATIVE_EXECUTION_POLICY,
26
+ permissions: 'native-managed; edit mode when none is configured',
27
+ });
23
28
  export const NATIVE_MANAGED_DESTINATION = Object.freeze({
24
29
  class: 'native-managed',
25
30
  origin: 'native-managed',
@@ -17,6 +17,7 @@ import {
17
17
  } from 'node:fs/promises';
18
18
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
19
19
  import { promisify } from 'node:util';
20
+ import { readRunRecord } from './run-record.mjs';
20
21
 
21
22
  const execFileAsync = promisify(execFile);
22
23
  export const CUSTODY_SCHEMA_VERSION = '1.0.0';
@@ -68,6 +69,148 @@ async function git(root, args, { allowFailure = false } = {}) {
68
69
  }
69
70
  }
70
71
 
72
+ function gitInput(root, args, input) {
73
+ return new Promise((resolveOutput, reject) => {
74
+ const child = execFile(
75
+ 'git',
76
+ args,
77
+ { cwd: root, encoding: 'buffer', maxBuffer: 32 * 1024 * 1024 },
78
+ (error, stdout) => {
79
+ const operation = args.find((arg) => !arg.startsWith('-'));
80
+ if (error)
81
+ reject(
82
+ new CustodyError('E_CUSTODY_GIT', `Git operation failed: ${operation}`, {
83
+ operation,
84
+ exitCode: error.code,
85
+ }),
86
+ );
87
+ else resolveOutput(stdout);
88
+ },
89
+ );
90
+ // Git may exit without reading stdin; its exit status, not the closed pipe, is the result.
91
+ child.stdin.on('error', (error) => {
92
+ if (error.code === 'EPIPE') return;
93
+ const operation = args.find((arg) => !arg.startsWith('-'));
94
+ reject(
95
+ new CustodyError('E_CUSTODY_GIT', `Git operation input failed: ${operation}`, {
96
+ operation,
97
+ cause: error.code,
98
+ }),
99
+ );
100
+ });
101
+ child.stdin.end(input);
102
+ });
103
+ }
104
+
105
+ export const RUN_BRANCH_PREFIX = 'planr-delegate/';
106
+ // Repository hooks, signing and the user's identity never apply to run commits.
107
+ export const HOOKLESS_COMMIT = [
108
+ '-c',
109
+ 'core.hooksPath=/dev/null',
110
+ '-c',
111
+ 'commit.gpgSign=false',
112
+ '-c',
113
+ 'user.name=planr-delegate',
114
+ '-c',
115
+ 'user.email=planr-delegate@localhost',
116
+ 'commit',
117
+ '--no-verify',
118
+ '--allow-empty',
119
+ '-q',
120
+ '-m',
121
+ ];
122
+ const RESTORE_REF = /^refs\/planr-delegate\/[^/]+\/restore$/u;
123
+
124
+ async function refSnapshot(root, branch) {
125
+ const refs = {};
126
+ for (const line of (await git(root, ['for-each-ref', '--format=%(refname)%00%(objectname)']))
127
+ .toString('utf8')
128
+ .split('\n')) {
129
+ const [name, oid] = line.split('\0');
130
+ if (oid && name !== `refs/heads/${branch}`) refs[name] = oid;
131
+ }
132
+ return refs;
133
+ }
134
+
135
+ async function isAncestor(root, ancestor, descendant) {
136
+ return (
137
+ (await git(root, ['merge-base', '--is-ancestor', ancestor, descendant], {
138
+ allowFailure: true,
139
+ })) !== null
140
+ );
141
+ }
142
+
143
+ // A restore ref is gone legitimately once its run applied, recovered or was cleaned up.
144
+ async function unresolvedRun(runDirectory, runId) {
145
+ if (!runDirectory) return true;
146
+ try {
147
+ const { integration } = await readRunRecord(runId, { directory: runDirectory });
148
+ return ['applying', 'interrupted'].includes(integration?.status);
149
+ } catch (error) {
150
+ if (['ENOENT', 'E_RUN_ID'].includes(error.code)) return false;
151
+ throw error;
152
+ }
153
+ }
154
+
155
+ async function branchViolations(root, record) {
156
+ const violations = [];
157
+ const head = (await git(root, ['symbolic-ref', '-q', 'HEAD'], { allowFailure: true }))
158
+ ?.toString('utf8')
159
+ .trim();
160
+ const branchRef = `refs/heads/${record.branch}`;
161
+ if (head !== branchRef)
162
+ violations.push({ code: 'E_CUSTODY_BRANCH', expected: record.branch, actual: head ?? null });
163
+ else if (
164
+ (await git(root, ['show-ref', '--verify', '--quiet', branchRef], { allowFailure: true })) ===
165
+ null
166
+ )
167
+ violations.push({ code: 'E_CUSTODY_BRANCH', expected: record.branch, actual: null });
168
+ else if (!(await isAncestor(root, record.base, 'HEAD')))
169
+ violations.push({ code: 'E_CUSTODY_BASE', base: record.base });
170
+ const parent = record.repositoryRoot;
171
+ const before = record.refs ?? {};
172
+ const now = await refSnapshot(parent, record.branch);
173
+ const reported = new Set([`refs/planr-delegate/${record.runId}/restore`]);
174
+ const previous = before[record.parentBranch] ?? record.initialHead;
175
+ const moved = record.parentBranch ? (now[record.parentBranch] ?? null) : undefined;
176
+ // Owner commits, amends and resets warn; only delegate work descends from base.
177
+ if (
178
+ moved === null ||
179
+ (moved && moved !== previous && (await isAncestor(parent, record.base, moved)))
180
+ ) {
181
+ reported.add(record.parentBranch);
182
+ violations.push({
183
+ code: 'E_CUSTODY_PARENT_BRANCH',
184
+ ref: record.parentBranch,
185
+ expected: previous,
186
+ actual: moved,
187
+ });
188
+ }
189
+ for (const name of Object.keys(before))
190
+ if (
191
+ RESTORE_REF.test(name) &&
192
+ !reported.has(name) &&
193
+ !now[name] &&
194
+ (await unresolvedRun(record.runDirectory, name.split('/')[2]))
195
+ ) {
196
+ reported.add(name);
197
+ violations.push({ code: 'E_CUSTODY_RESTORE_REF', ref: name });
198
+ }
199
+ const changed = [...new Set([...Object.keys(now), ...Object.keys(before)])]
200
+ .filter((name) => !reported.has(name) && now[name] !== before[name])
201
+ .sort();
202
+ const warnings = changed.length
203
+ ? [
204
+ {
205
+ code: 'W_CUSTODY_REFS',
206
+ refs: changed.slice(0, 20),
207
+ ...(changed.length > 20 ? { omitted: changed.length - 20 } : {}),
208
+ },
209
+ ]
210
+ : [];
211
+ return { violations, warnings };
212
+ }
213
+
71
214
  function digest(bytes) {
72
215
  return createHash('sha256').update(bytes).digest('hex');
73
216
  }
@@ -425,6 +568,8 @@ export async function createWorktreeCustody({
425
568
  worktreeParent,
426
569
  runId = randomUUID(),
427
570
  native = false,
571
+ branch = false,
572
+ runDirectory,
428
573
  } = {}) {
429
574
  if (
430
575
  !repositoryRoot ||
@@ -504,7 +649,11 @@ export async function createWorktreeCustody({
504
649
  JSON.stringify({ runId, custodyToken, repositoryRoot: root, worktreePath }),
505
650
  { mode: 0o600, flag: 'wx' },
506
651
  );
507
- await git(root, ['worktree', 'add', '--detach', '--', worktreePath, initialHead]);
652
+ const branchName = `${RUN_BRANCH_PREFIX}${runId}`;
653
+ if (branch) {
654
+ await git(root, ['worktree', 'add', '-b', branchName, '--', worktreePath, initialHead]);
655
+ await git(root, ['worktree', 'lock', '--reason', `planr-delegate ${runId}`, worktreePath]);
656
+ } else await git(root, ['worktree', 'add', '--detach', '--', worktreePath, initialHead]);
508
657
  const checkoutFiles = native
509
658
  ? await initialCheckoutFiles(worktreePath, initialHead, paths)
510
659
  : {};
@@ -526,6 +675,33 @@ export async function createWorktreeCustody({
526
675
  }
527
676
  startingFiles[path] = await fileState(worktreePath, path);
528
677
  }
678
+ let handoff = {};
679
+ if (branch) {
680
+ if (paths.length)
681
+ await gitInput(
682
+ worktreePath,
683
+ [
684
+ '--literal-pathspecs',
685
+ 'add',
686
+ '--force',
687
+ '--pathspec-from-file=-',
688
+ '--pathspec-file-nul',
689
+ ],
690
+ `${paths.join('\0')}\0`,
691
+ );
692
+ await git(worktreePath, [...HOOKLESS_COMMIT, `planr-delegate base ${runId}`]);
693
+ handoff = {
694
+ handoff: 'branch',
695
+ branch: branchName,
696
+ base: (await git(worktreePath, ['rev-parse', 'HEAD'])).toString('utf8').trim(),
697
+ parentBranch:
698
+ (await git(root, ['symbolic-ref', '-q', 'HEAD'], { allowFailure: true }))
699
+ ?.toString('utf8')
700
+ .trim() || null,
701
+ refs: await refSnapshot(root, branchName),
702
+ ...(runDirectory ? { runDirectory } : {}),
703
+ };
704
+ }
529
705
  const preservedFiles = {};
530
706
  for (const path of protectedPaths)
531
707
  preservedFiles[path] = await protectedState(worktreePath, path);
@@ -537,6 +713,7 @@ export async function createWorktreeCustody({
537
713
  repositoryRoot: root,
538
714
  worktreePath,
539
715
  initialHead,
716
+ ...handoff,
540
717
  initialIndex: await indexState(worktreePath),
541
718
  sourceIndex,
542
719
  selectedPaths: paths,
@@ -600,7 +777,7 @@ export async function inspectWorktreeSetup(record, options = {}) {
600
777
  const before =
601
778
  record.setupFiles?.[path] ??
602
779
  record.startingFiles?.[path] ??
603
- (await headFileState(record.worktreePath, path, record.initialHead));
780
+ (await headFileState(record.worktreePath, path, record.base ?? record.initialHead));
604
781
  const after = await captureFileState(record.worktreePath, path);
605
782
  if (
606
783
  !sameGitState(
@@ -621,13 +798,20 @@ export async function validateWorktreeCustody(
621
798
  throw new CustodyError('E_CUSTODY_RECORD', 'A custody record is required.');
622
799
  const root = await assertRepository(record.worktreePath);
623
800
  const violations = [];
801
+ let warnings = [];
624
802
  await assertRepository(record.repositoryRoot);
625
- // Source HEAD/index may advance on unrelated paths; integration checks each destination.
626
- const head = (await git(root, ['rev-parse', 'HEAD'])).toString('utf8').trim();
627
- if (head !== record.initialHead)
628
- violations.push({ code: 'E_CUSTODY_HEAD', expected: record.initialHead, actual: head });
629
- const currentIndex = await indexState(root);
630
- if (currentIndex !== record.initialIndex) violations.push({ code: 'E_CUSTODY_INDEX' });
803
+ if (record.handoff === 'branch') {
804
+ const branch = await branchViolations(root, record);
805
+ violations.push(...branch.violations);
806
+ warnings = branch.warnings;
807
+ } else {
808
+ // Source HEAD/index may advance on unrelated paths; integration checks each destination.
809
+ const head = (await git(root, ['rev-parse', 'HEAD'])).toString('utf8').trim();
810
+ if (head !== record.initialHead)
811
+ violations.push({ code: 'E_CUSTODY_HEAD', expected: record.initialHead, actual: head });
812
+ const currentIndex = await indexState(root);
813
+ if (currentIndex !== record.initialIndex) violations.push({ code: 'E_CUSTODY_INDEX' });
814
+ }
631
815
  if (!native && record.engineConfiguration) {
632
816
  const currentConfiguration = await captureEngineConfiguration(root);
633
817
  for (const path of Object.keys(record.engineConfiguration))
@@ -640,7 +824,7 @@ export async function validateWorktreeCustody(
640
824
  // Abandonment supplies its own complete raw-byte filesystem inventory. Avoid
641
825
  // Git status there because it may invoke configured clean filters as a side effect.
642
826
  const currentStatus = inspectStatus ? await status(root) : { changedPaths: [], stagedPaths: [] };
643
- if (currentStatus.stagedPaths.length)
827
+ if (currentStatus.stagedPaths.length && record.handoff !== 'branch')
644
828
  violations.push({ code: 'E_CUSTODY_STAGED', paths: currentStatus.stagedPaths });
645
829
  for (const path of record.preservePaths) {
646
830
  let now;
@@ -666,7 +850,12 @@ export async function validateWorktreeCustody(
666
850
  )
667
851
  violations.push({ code: 'E_CUSTODY_SETUP_CHANGED', path });
668
852
  }
669
- return { valid: violations.length === 0, violations, changedPaths: currentStatus.changedPaths };
853
+ return {
854
+ valid: violations.length === 0,
855
+ violations,
856
+ warnings,
857
+ changedPaths: currentStatus.changedPaths,
858
+ };
670
859
  }
671
860
 
672
861
  export async function cleanupWorktreeCustody(record, { disposition, beforeRemove } = {}) {
@@ -731,12 +920,23 @@ export async function cleanupWorktreeCustody(record, { disposition, beforeRemove
731
920
  if (registered) {
732
921
  // Validate accepted contents after ownership reads, immediately before native removal.
733
922
  if (present) await beforeRemove?.(target);
923
+ if (record.handoff === 'branch' && worktreeLocked(listed, target))
924
+ await git(root, ['worktree', 'unlock', target]);
734
925
  await git(root, ['worktree', 'remove', '--force', '--', target]);
735
926
  } else if (present)
736
927
  throw new CustodyError(
737
928
  'E_CUSTODY_CLEANUP',
738
929
  'Present worktree is not registered to this repository.',
739
930
  );
931
+ if (record.handoff === 'branch')
932
+ for (const ref of [
933
+ `refs/heads/${record.branch}`,
934
+ `refs/planr-delegate/${record.runId}/restore`,
935
+ ])
936
+ if (
937
+ (await git(root, ['show-ref', '--verify', '--quiet', ref], { allowFailure: true })) !== null
938
+ )
939
+ await git(root, ['update-ref', '-d', ref]);
740
940
  await rm(physicalParent, { recursive: true, force: true });
741
941
  return {
742
942
  removed: target,
@@ -744,3 +944,10 @@ export async function cleanupWorktreeCustody(record, { disposition, beforeRemove
744
944
  ...(!present && !registered ? { alreadyRemoved: true } : {}),
745
945
  };
746
946
  }
947
+
948
+ function worktreeLocked(listed, target) {
949
+ const block = listed.split('\n\n').find((entry) => entry.startsWith(`worktree ${target}\n`));
950
+ return Boolean(
951
+ block?.split('\n').some((line) => line === 'locked' || line.startsWith('locked ')),
952
+ );
953
+ }