openplanr 3.2.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 (411) hide show
  1. package/CHANGELOG.md +73 -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/cli/commands/spec.d.ts +2 -1
  13. package/dist/cli/commands/spec.d.ts.map +1 -1
  14. package/dist/cli/commands/spec.js +45 -5
  15. package/dist/cli/commands/spec.js.map +1 -1
  16. package/dist/dashboard/.vite/manifest.json +2 -2
  17. package/dist/dashboard/assets/index-Cv4Vwhuw.css +2 -0
  18. package/dist/dashboard/assets/index-CvQAlBy3.js +75 -0
  19. package/dist/dashboard/assets/index-CvQAlBy3.js.map +1 -0
  20. package/dist/dashboard/dashboard-manifest.json +14 -14
  21. package/dist/dashboard/index.html +2 -2
  22. package/dist/services/claude-plugin-service.d.ts +5 -0
  23. package/dist/services/claude-plugin-service.d.ts.map +1 -1
  24. package/dist/services/claude-plugin-service.js +18 -2
  25. package/dist/services/claude-plugin-service.js.map +1 -1
  26. package/dist/services/codex-plugin-service.d.ts.map +1 -1
  27. package/dist/services/codex-plugin-service.js +11 -3
  28. package/dist/services/codex-plugin-service.js.map +1 -1
  29. package/dist/services/design-artifact-service.d.ts +20 -1
  30. package/dist/services/design-artifact-service.d.ts.map +1 -1
  31. package/dist/services/design-artifact-service.js +137 -18
  32. package/dist/services/design-artifact-service.js.map +1 -1
  33. package/dist/services/runtime-manager/codex-discovery.d.ts +1 -3
  34. package/dist/services/runtime-manager/codex-discovery.d.ts.map +1 -1
  35. package/dist/services/runtime-manager/codex-discovery.js +3 -16
  36. package/dist/services/runtime-manager/codex-discovery.js.map +1 -1
  37. package/dist/services/runtime-manager/doctor.d.ts +25 -0
  38. package/dist/services/runtime-manager/doctor.d.ts.map +1 -1
  39. package/dist/services/runtime-manager/doctor.js +480 -0
  40. package/dist/services/runtime-manager/doctor.js.map +1 -1
  41. package/dist/services/runtime-manager/errors.d.ts +12 -0
  42. package/dist/services/runtime-manager/errors.d.ts.map +1 -0
  43. package/dist/services/runtime-manager/errors.js +14 -0
  44. package/dist/services/runtime-manager/errors.js.map +1 -0
  45. package/dist/services/runtime-manager/global-state.d.ts +7 -0
  46. package/dist/services/runtime-manager/global-state.d.ts.map +1 -1
  47. package/dist/services/runtime-manager/global-state.js +116 -0
  48. package/dist/services/runtime-manager/global-state.js.map +1 -1
  49. package/dist/services/runtime-manager/host-version-probe.d.ts +8 -0
  50. package/dist/services/runtime-manager/host-version-probe.d.ts.map +1 -0
  51. package/dist/services/runtime-manager/host-version-probe.js +14 -0
  52. package/dist/services/runtime-manager/host-version-probe.js.map +1 -0
  53. package/dist/services/runtime-manager/install-plan.d.ts +25 -0
  54. package/dist/services/runtime-manager/install-plan.d.ts.map +1 -1
  55. package/dist/services/runtime-manager/install-plan.js +305 -0
  56. package/dist/services/runtime-manager/install-plan.js.map +1 -1
  57. package/dist/services/runtime-manager/inventory.d.ts +6 -0
  58. package/dist/services/runtime-manager/inventory.d.ts.map +1 -1
  59. package/dist/services/runtime-manager/inventory.js +16 -1
  60. package/dist/services/runtime-manager/inventory.js.map +1 -1
  61. package/dist/services/runtime-manager/legacy-adapters.d.ts +9 -0
  62. package/dist/services/runtime-manager/legacy-adapters.d.ts.map +1 -0
  63. package/dist/services/runtime-manager/legacy-adapters.js +187 -0
  64. package/dist/services/runtime-manager/legacy-adapters.js.map +1 -0
  65. package/dist/services/runtime-manager/paths.d.ts +18 -0
  66. package/dist/services/runtime-manager/paths.d.ts.map +1 -0
  67. package/dist/services/runtime-manager/paths.js +83 -0
  68. package/dist/services/runtime-manager/paths.js.map +1 -0
  69. package/dist/services/runtime-manager/runtime-package.d.ts +21 -0
  70. package/dist/services/runtime-manager/runtime-package.d.ts.map +1 -1
  71. package/dist/services/runtime-manager/runtime-package.js +77 -0
  72. package/dist/services/runtime-manager/runtime-package.js.map +1 -1
  73. package/dist/services/runtime-manager/storage.d.ts +47 -0
  74. package/dist/services/runtime-manager/storage.d.ts.map +1 -0
  75. package/dist/services/runtime-manager/storage.js +604 -0
  76. package/dist/services/runtime-manager/storage.js.map +1 -0
  77. package/dist/services/runtime-manager-service.d.ts +7 -17
  78. package/dist/services/runtime-manager-service.d.ts.map +1 -1
  79. package/dist/services/runtime-manager-service.js +32 -1695
  80. package/dist/services/runtime-manager-service.js.map +1 -1
  81. package/dist/services/ship-checks/contract.d.ts +15 -1
  82. package/dist/services/ship-checks/contract.d.ts.map +1 -1
  83. package/dist/services/ship-checks/contract.js +1 -1
  84. package/dist/services/ship-checks/contract.js.map +1 -1
  85. package/dist/services/ship-checks/coverage.d.ts +4 -0
  86. package/dist/services/ship-checks/coverage.d.ts.map +1 -0
  87. package/dist/services/ship-checks/coverage.js +113 -0
  88. package/dist/services/ship-checks/coverage.js.map +1 -0
  89. package/dist/services/ship-checks/discover.d.ts.map +1 -1
  90. package/dist/services/ship-checks/discover.js +5 -1
  91. package/dist/services/ship-checks/discover.js.map +1 -1
  92. package/dist/services/ship-checks/package-contents.d.ts +4 -0
  93. package/dist/services/ship-checks/package-contents.d.ts.map +1 -0
  94. package/dist/services/ship-checks/package-contents.js +91 -0
  95. package/dist/services/ship-checks/package-contents.js.map +1 -0
  96. package/dist/services/ship-checks/packages.d.ts +2 -0
  97. package/dist/services/ship-checks/packages.d.ts.map +1 -1
  98. package/dist/services/ship-checks/packages.js +4 -0
  99. package/dist/services/ship-checks/packages.js.map +1 -1
  100. package/dist/services/ship-checks/scope.js +2 -1
  101. package/dist/services/ship-checks/scope.js.map +1 -1
  102. package/dist/services/spec-service.d.ts +18 -0
  103. package/dist/services/spec-service.d.ts.map +1 -1
  104. package/dist/services/spec-service.js +174 -9
  105. package/dist/services/spec-service.js.map +1 -1
  106. package/dist/templates/spec/spec-shaped.md.hbs +1 -1
  107. package/dist/templates/spec/spec.md.hbs +2 -2
  108. package/dist/utils/splice-managed-block.js +1 -1
  109. package/dist/utils/splice-managed-block.js.map +1 -1
  110. package/docs/CLI.md +86 -2
  111. package/lib/host-packages/adapter-registry.json +5 -5
  112. package/lib/host-packages/capability-map.json +3 -3
  113. package/lib/host-packages/claude/.claude-plugin/marketplace.json +3 -3
  114. package/lib/host-packages/claude/openplanr/.claude-plugin/plugin.json +6 -6
  115. package/lib/host-packages/claude/openplanr/.openplanr-content.json +94 -146
  116. package/lib/host-packages/claude/openplanr/README.md +12 -12
  117. package/lib/host-packages/claude/openplanr/agents/planr-qa.md +5 -3
  118. package/lib/host-packages/claude/openplanr/references/agents/shared/modes/shared/task-context-resolution.md +4 -4
  119. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-artifact-shell.mjs +2 -4
  120. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-document.mjs +110 -25
  121. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-handoff.mjs +851 -57
  122. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review-state-store.mjs +45 -0
  123. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review.mjs +65 -74
  124. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -1
  125. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +321 -0
  126. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +1652 -0
  127. 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
  128. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +137 -0
  129. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design.mjs +374 -61
  130. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +32 -59
  131. 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
  132. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +1 -5608
  133. 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
  134. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +10 -74
  135. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/package.json +4 -4
  136. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +8 -2
  137. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +2 -2
  138. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +5 -5
  139. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +72 -2
  140. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +14 -7
  141. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +71 -34
  142. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +28 -14
  143. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +12 -12
  144. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +6 -2
  145. package/lib/host-packages/{openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.20.0 → claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0}/design-document.schema.json +131 -4
  146. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +822 -0
  147. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +616 -4775
  148. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design.mjs +219 -424
  149. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +6 -2
  150. package/lib/host-packages/claude/openplanr/skills/delegate/SKILL.md +2 -1
  151. package/lib/host-packages/claude/openplanr/skills/delegate/references/integration-review.md +26 -20
  152. package/lib/host-packages/claude/openplanr/skills/delegate/references/operator-guide.md +25 -1
  153. package/lib/host-packages/claude/openplanr/skills/delegate/references/run-handoff.md +2 -2
  154. package/lib/host-packages/claude/openplanr/skills/delegate/references/worktree-custody.md +17 -9
  155. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/adapters/claude.mjs +15 -3
  156. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/adapters/codex.mjs +38 -2
  157. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/adapters/native.mjs +5 -0
  158. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/custody.mjs +217 -10
  159. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/handoff.mjs +1080 -0
  160. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/integrate.mjs +96 -201
  161. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/integration-files.mjs +3 -382
  162. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/presentation.mjs +29 -12
  163. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-contract.mjs +11 -0
  164. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-execution.mjs +1 -1
  165. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-lifecycle.mjs +14 -10
  166. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-preparation.mjs +4 -0
  167. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/run-record.mjs +2 -2
  168. package/lib/host-packages/claude/openplanr/skills/design/references/design-system.md +17 -2
  169. package/lib/host-packages/claude/openplanr/skills/design/references/generation.md +60 -2
  170. package/lib/host-packages/claude/openplanr/skills/design/references/utilities.md +23 -7
  171. package/lib/host-packages/claude/openplanr/skills/design/schemas/design-document.schema.json +131 -4
  172. package/lib/host-packages/claude/openplanr/skills/design-loop/references/design-system.md +17 -2
  173. package/lib/host-packages/claude/openplanr/skills/design-loop/references/generation.md +60 -2
  174. package/lib/host-packages/claude/openplanr/skills/design-loop/references/utilities.md +23 -7
  175. package/lib/host-packages/claude/openplanr/skills/design-loop/schemas/design-document.schema.json +131 -4
  176. package/lib/host-packages/claude/openplanr/skills/design-review/references/design-system.md +17 -2
  177. package/lib/host-packages/claude/openplanr/skills/design-review/references/generation.md +60 -2
  178. package/lib/host-packages/claude/openplanr/skills/design-review/references/utilities.md +23 -7
  179. package/lib/host-packages/claude/openplanr/skills/design-review/schemas/design-document.schema.json +131 -4
  180. package/lib/host-packages/claude/openplanr/skills/investigate/SKILL.md +2 -1
  181. package/lib/host-packages/claude/openplanr/skills/investigate/references/fail-first.md +40 -0
  182. package/lib/host-packages/claude/openplanr/skills/plan/SKILL.md +21 -11
  183. package/lib/host-packages/claude/openplanr/skills/plan/schemas/design-document.schema.json +131 -4
  184. package/lib/host-packages/claude/openplanr/skills/ship/SKILL.md +51 -18
  185. package/lib/host-packages/claude/openplanr/skills/ship/references/fail-first.md +40 -0
  186. package/lib/host-packages/claude/openplanr/skills/ship/references/result-contract.md +7 -3
  187. package/lib/host-packages/claude/openplanr/skills/spec/SKILL.md +6 -0
  188. package/lib/host-packages/claude/openplanr/skills/spec/references/specification-contract.md +3 -1
  189. package/lib/host-packages/cursor/openplanr/.openplanr-content.json +91 -143
  190. package/lib/host-packages/cursor/openplanr/manifest.json +1 -1
  191. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/integration-review.md +26 -20
  192. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/operator-guide.md +25 -1
  193. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/run-handoff.md +2 -2
  194. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/references/worktree-custody.md +17 -9
  195. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/adapters/claude.mjs +15 -3
  196. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/adapters/codex.mjs +38 -2
  197. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/adapters/native.mjs +5 -0
  198. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/custody.mjs +217 -10
  199. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/handoff.mjs +1080 -0
  200. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/integrate.mjs +96 -201
  201. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/integration-files.mjs +3 -382
  202. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/presentation.mjs +29 -12
  203. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-contract.mjs +11 -0
  204. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-execution.mjs +1 -1
  205. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-lifecycle.mjs +14 -10
  206. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-preparation.mjs +4 -0
  207. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/run-record.mjs +2 -2
  208. package/lib/host-packages/cursor/openplanr/rules/planr-delegate.mdc +2 -1
  209. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/design-system.md +17 -2
  210. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/generation.md +60 -2
  211. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/utilities.md +23 -7
  212. package/lib/host-packages/cursor/openplanr/rules/planr-design/schemas/design-document.schema.json +131 -4
  213. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/design-system.md +17 -2
  214. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/generation.md +60 -2
  215. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/utilities.md +23 -7
  216. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/schemas/design-document.schema.json +131 -4
  217. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/design-system.md +17 -2
  218. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/generation.md +60 -2
  219. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/utilities.md +23 -7
  220. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/schemas/design-document.schema.json +131 -4
  221. package/lib/host-packages/cursor/openplanr/rules/planr-investigate/references/fail-first.md +40 -0
  222. package/lib/host-packages/cursor/openplanr/rules/planr-investigate.mdc +2 -1
  223. package/lib/host-packages/cursor/openplanr/rules/planr-plan/schemas/design-document.schema.json +131 -4
  224. package/lib/host-packages/cursor/openplanr/rules/planr-plan.mdc +21 -11
  225. package/lib/host-packages/cursor/openplanr/rules/planr-ship/references/fail-first.md +40 -0
  226. package/lib/host-packages/cursor/openplanr/rules/planr-ship/references/result-contract.md +7 -3
  227. package/lib/host-packages/cursor/openplanr/rules/planr-ship.mdc +51 -18
  228. package/lib/host-packages/cursor/openplanr/rules/planr-spec/references/specification-contract.md +3 -1
  229. package/lib/host-packages/cursor/openplanr/rules/planr-spec.mdc +6 -0
  230. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-artifact-shell.mjs +2 -4
  231. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-document.mjs +110 -25
  232. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-handoff.mjs +851 -57
  233. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review-state-store.mjs +45 -0
  234. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review.mjs +65 -74
  235. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -1
  236. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +321 -0
  237. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +1652 -0
  238. 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
  239. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +137 -0
  240. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design.mjs +374 -61
  241. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +32 -59
  242. 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
  243. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +1 -5608
  244. 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
  245. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +10 -74
  246. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/package.json +4 -4
  247. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +8 -2
  248. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +2 -2
  249. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +5 -5
  250. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +72 -2
  251. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +14 -7
  252. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +71 -34
  253. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +28 -14
  254. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +12 -12
  255. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +6 -2
  256. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/{v1.20.0 → v1.22.0}/design-document.schema.json +131 -4
  257. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +822 -0
  258. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +616 -4775
  259. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design.mjs +219 -424
  260. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +6 -2
  261. package/lib/host-packages/openai/.claude-plugin/marketplace.json +3 -3
  262. package/lib/host-packages/openai/openplanr/.codex-plugin/plugin.json +2 -2
  263. package/lib/host-packages/openai/openplanr/.openplanr-content.json +98 -150
  264. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-artifact-shell.mjs +2 -4
  265. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-document.mjs +110 -25
  266. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-handoff.mjs +851 -57
  267. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review-state-store.mjs +45 -0
  268. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review.mjs +65 -74
  269. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -1
  270. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +321 -0
  271. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +1652 -0
  272. 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
  273. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +137 -0
  274. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design.mjs +374 -61
  275. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +32 -59
  276. 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
  277. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +1 -5608
  278. 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
  279. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +10 -74
  280. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/package.json +4 -4
  281. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +8 -2
  282. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +2 -2
  283. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +5 -5
  284. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +72 -2
  285. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +14 -7
  286. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +71 -34
  287. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +28 -14
  288. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +12 -12
  289. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +6 -2
  290. package/lib/host-packages/{claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.20.0 → openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0}/design-document.schema.json +131 -4
  291. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +822 -0
  292. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +616 -4775
  293. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design.mjs +219 -424
  294. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +6 -2
  295. package/lib/host-packages/openai/openplanr/skills/delegate/SKILL.md +2 -1
  296. package/lib/host-packages/openai/openplanr/skills/delegate/openplanr.skill.json +1 -1
  297. package/lib/host-packages/openai/openplanr/skills/delegate/references/integration-review.md +26 -20
  298. package/lib/host-packages/openai/openplanr/skills/delegate/references/operator-guide.md +25 -1
  299. package/lib/host-packages/openai/openplanr/skills/delegate/references/run-handoff.md +2 -2
  300. package/lib/host-packages/openai/openplanr/skills/delegate/references/worktree-custody.md +17 -9
  301. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/adapters/claude.mjs +15 -3
  302. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/adapters/codex.mjs +38 -2
  303. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/adapters/native.mjs +5 -0
  304. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/custody.mjs +217 -10
  305. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/handoff.mjs +1080 -0
  306. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/integrate.mjs +96 -201
  307. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/integration-files.mjs +3 -382
  308. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/presentation.mjs +29 -12
  309. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-contract.mjs +11 -0
  310. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-execution.mjs +1 -1
  311. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-lifecycle.mjs +14 -10
  312. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-preparation.mjs +4 -0
  313. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/run-record.mjs +2 -2
  314. package/lib/host-packages/openai/openplanr/skills/design/references/design-system.md +17 -2
  315. package/lib/host-packages/openai/openplanr/skills/design/references/generation.md +60 -2
  316. package/lib/host-packages/openai/openplanr/skills/design/references/utilities.md +23 -7
  317. package/lib/host-packages/openai/openplanr/skills/design/schemas/design-document.schema.json +131 -4
  318. package/lib/host-packages/openai/openplanr/skills/design-loop/references/design-system.md +17 -2
  319. package/lib/host-packages/openai/openplanr/skills/design-loop/references/generation.md +60 -2
  320. package/lib/host-packages/openai/openplanr/skills/design-loop/references/utilities.md +23 -7
  321. package/lib/host-packages/openai/openplanr/skills/design-loop/schemas/design-document.schema.json +131 -4
  322. package/lib/host-packages/openai/openplanr/skills/design-review/references/design-system.md +17 -2
  323. package/lib/host-packages/openai/openplanr/skills/design-review/references/generation.md +60 -2
  324. package/lib/host-packages/openai/openplanr/skills/design-review/references/utilities.md +23 -7
  325. package/lib/host-packages/openai/openplanr/skills/design-review/schemas/design-document.schema.json +131 -4
  326. package/lib/host-packages/openai/openplanr/skills/investigate/SKILL.md +2 -1
  327. package/lib/host-packages/openai/openplanr/skills/investigate/agents/openai.yaml +1 -1
  328. package/lib/host-packages/openai/openplanr/skills/investigate/openplanr.skill.json +12 -1
  329. package/lib/host-packages/openai/openplanr/skills/investigate/references/fail-first.md +40 -0
  330. package/lib/host-packages/openai/openplanr/skills/plan/SKILL.md +21 -11
  331. package/lib/host-packages/openai/openplanr/skills/plan/openplanr.skill.json +1 -1
  332. package/lib/host-packages/openai/openplanr/skills/plan/schemas/design-document.schema.json +131 -4
  333. package/lib/host-packages/openai/openplanr/skills/ship/SKILL.md +51 -18
  334. package/lib/host-packages/openai/openplanr/skills/ship/agents/openai.yaml +1 -1
  335. package/lib/host-packages/openai/openplanr/skills/ship/openplanr.skill.json +12 -1
  336. package/lib/host-packages/openai/openplanr/skills/ship/references/fail-first.md +40 -0
  337. package/lib/host-packages/openai/openplanr/skills/ship/references/result-contract.md +7 -3
  338. package/lib/host-packages/openai/openplanr/skills/spec/SKILL.md +6 -0
  339. package/lib/host-packages/openai/openplanr/skills/spec/openplanr.skill.json +1 -1
  340. package/lib/host-packages/openai/openplanr/skills/spec/references/specification-contract.md +3 -1
  341. package/lib/json-schema.mjs +4 -0
  342. package/package.json +16 -16
  343. package/dist/dashboard/assets/index-BU5fzjyz.css +0 -1
  344. package/dist/dashboard/assets/index-L8qtwqv6.js +0 -572
  345. package/dist/dashboard/assets/index-L8qtwqv6.js.map +0 -1
  346. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +0 -555
  347. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-compression.mjs +0 -4180
  348. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +0 -647
  349. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-owner-custody.mjs +0 -129
  350. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-resource-pack.mjs +0 -698
  351. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-support-6774fd3d5d02.mjs +0 -24
  352. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-share.mjs +0 -1993
  353. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs +0 -1020
  354. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +0 -222
  355. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-protocol-contracts-b5f28f94.mjs +0 -5778
  356. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-upload-spool.mjs +0 -198
  357. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +0 -4175
  358. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +0 -65
  359. 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
  360. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +0 -62
  361. 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
  362. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-paste.schema.json +0 -49
  363. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-workspace.schema.json +0 -108
  364. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-create.schema.json +0 -170
  365. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-event.schema.json +0 -97
  366. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-revision.schema.json +0 -56
  367. package/lib/host-packages/claude/openplanr/skills/delegate/scripts/integration-transaction.mjs +0 -958
  368. package/lib/host-packages/cursor/openplanr/rules/planr-delegate/scripts/integration-transaction.mjs +0 -958
  369. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +0 -555
  370. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-compression.mjs +0 -4180
  371. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +0 -647
  372. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-owner-custody.mjs +0 -129
  373. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-resource-pack.mjs +0 -698
  374. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-support-6774fd3d5d02.mjs +0 -24
  375. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-share.mjs +0 -1993
  376. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs +0 -1020
  377. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +0 -222
  378. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-protocol-contracts-b5f28f94.mjs +0 -5778
  379. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-upload-spool.mjs +0 -198
  380. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +0 -4175
  381. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +0 -65
  382. 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
  383. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +0 -62
  384. 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
  385. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-paste.schema.json +0 -49
  386. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-workspace.schema.json +0 -108
  387. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-create.schema.json +0 -170
  388. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-event.schema.json +0 -97
  389. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-revision.schema.json +0 -56
  390. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-chunked-workspace-client.mjs +0 -555
  391. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-compression.mjs +0 -4180
  392. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-encrypted-workspace-client.mjs +0 -647
  393. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-owner-custody.mjs +0 -129
  394. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-resource-pack.mjs +0 -698
  395. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-support-6774fd3d5d02.mjs +0 -24
  396. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-share.mjs +0 -1993
  397. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-3d9b1a86.mjs +0 -1020
  398. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-protocol-contracts-75a938cc.mjs +0 -222
  399. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-protocol-contracts-b5f28f94.mjs +0 -5778
  400. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-upload-spool.mjs +0 -198
  401. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-compression.js +0 -4175
  402. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/05-artifact-sharing.js +0 -65
  403. 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
  404. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/07-artifact-sharing.js +0 -62
  405. 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
  406. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-paste.schema.json +0 -49
  407. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-workspace.schema.json +0 -108
  408. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-create.schema.json +0 -170
  409. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-event.schema.json +0 -97
  410. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-workspace-revision.schema.json +0 -56
  411. package/lib/host-packages/openai/openplanr/skills/delegate/scripts/integration-transaction.mjs +0 -958
@@ -26,32 +26,38 @@ parent host's normal execution controls and configuration. They are not an OpenP
26
26
  OS sandbox. Arguments, exits, timings and bounded private failure diagnostics are
27
27
  saved separately from native-agent check claims.
28
28
 
29
- Verification normally runs in the prepared owned worktree. Ordinary ignored
30
- build/cache outputs are allowed. If preparation, a check or generation changes
31
- reviewable source/tests/configuration/generated files, the old review is invalid:
32
- inspect the updated candidate and review again before acceptance. If the source
33
- checkout makes the prepared tree stale, verification uses a fresh candidate only
34
- when needed, retaining the original native session/worktree.
29
+ `review` commits the worktree's non-ignored state as the run branch tip and reviews
30
+ `git diff base tip`. Verification runs in the owned worktree at that tip: checks see
31
+ HEAD plus the selected files plus the delegate's changes, not the parent checkout's
32
+ other uncommitted files, which the report lists. Ordinary ignored build/cache outputs
33
+ are allowed. If preparation, a check or generation changes reviewable
34
+ source/tests/configuration/generated files, the old review is invalid: inspect the
35
+ updated candidate and review again before acceptance.
35
36
 
36
37
  Failed checks keep the candidate blocked. `baselineComparison: true` explicitly
37
- requests a relevant failed-check comparison; it is diagnostic and cannot turn a
38
- failure into acceptance. Earlier attempt evidence remains private. Narrowing a
38
+ requests a relevant failed-check comparison in a temporary worktree at the base
39
+ commit; it is diagnostic and cannot turn a failure into acceptance. Dependencies are
40
+ not copied there, so include their setup in `preparation`. Earlier attempt evidence remains private. Narrowing a
39
41
  previously failed check set requires `checkSelectionReason`. With no applicable
40
42
  automated check, `reviewOnlyReason` allows explicitly unverified review-only
41
43
  integration; zero checks never produces a verified outcome.
42
44
 
43
45
  ## Checkout protection and recovery
44
46
 
45
- The integration lock, scope/Preserve checks, reviewed patch identity, destination
46
- compare-and-swap and recovery journal protect checkout writes. Concurrent user
47
- edits are never overwritten or rolled back. A source change during checks requires
48
- reviewing the actual candidate again. The journal records intended states before
49
- the first source write and recovery touches only helper-written paths that still
50
- match those states.
47
+ The per-repository lock, scope/Preserve checks and the reviewed tip protect checkout
48
+ writes. `apply` saves a restore point (`git stash create`) under the private ref
49
+ `refs/planr-delegate/<runId>/restore`, then runs `git apply --check` and `git apply`
50
+ with the saved `patch.diff`. A parent edit elsewhere in a changed file merges; an
51
+ overlapping parent edit blocks with its path and leaves the checkout untouched.
52
+ Concurrent user edits are never overwritten or rolled back.
51
53
 
52
- An interrupted source write must use `recover` with rollback (default) or accept
53
- after inspecting every journaled path. Keep conflicting user edits. Do not bypass
54
- a rejected helper by manually applying its patch.
54
+ If `git apply` fails without writing, for example after a parent save between its check
55
+ and the write, the run returns to review with the conflicting paths. An apply
56
+ interrupted between its check and completion must use `recover`, which compares each
57
+ patch path with its pre- and post-apply content. A fully applied patch can be accepted;
58
+ rollback (default) restores only paths that match their post-apply content and keeps
59
+ file permissions. Keep conflicting user edits. Do not bypass a rejected helper by manually applying
60
+ its patch.
55
61
 
56
62
  Successful native integration closes the exact run, saves evidence/report and
57
63
  removes only its owned worktree unless retained. `status` recovers the five-field
@@ -61,8 +67,8 @@ deployment are outside this helper.
61
67
  Experimental generic protocol-v1 adapters and older pinned helpers retain their
62
68
  original check interface and lifecycle; native v2 does not expand their permissions.
63
69
 
64
- Destination publication claims the existing directory entry and compares its bytes before exclusive creation of the replacement. Concurrent replacements block integration. Claimed originals remain in private write custody (Git metadata, or destination-local custody when volumes differ) for crash recovery and writers holding an old inode; conflicts report their retained paths. Rollback uses the same guard and cannot discard a changed claimed original.
70
+ ## Process custody and runs pinned to older helpers
65
71
 
66
- Candidate identity is checked across verification and acceptance; a changed owned worktree is retained instead of automatically removed. Guarded writes validate parent-directory identities as well as final entries. The parent host provides filesystem containment: these checks are conflict detection, not an OS sandbox against processes that deliberately rename ancestors between syscalls. Process custody stops the owned process group; intentionally detached services and processes outside that group remain the native harness/operator responsibility. Independent commands must finish their work before returning success.
72
+ Process custody stops the owned process group; intentionally detached services and processes outside that group remain the native harness/operator responsibility. Independent commands must finish their work before returning success. Cleanup checks that the owned worktree is still at the accepted tip after ownership reads, just before removal; a changed worktree is retained for inspection.
67
73
 
68
- Native interruption recovery validates the complete checkout against the journaled candidate identity before accepting saved verification. Cleanup validates accepted worktree contents after ownership reads, just before removal; an already absent owned worktree can still be unregistered. Concurrent editor saves detected at either boundary retain their files and require review or recovery.
74
+ A run prepared by an older helper, without a run branch, finishes review, apply and recovery through that pinned helper. The current helper refuses its custody instead of integrating it.
@@ -114,7 +114,31 @@ a GGUF filename or display label is not automatically its request ID. Apply an
114
114
  explicit model override only to this run through the existing native options;
115
115
  rewrite or enroll a saved profile only when the user requests it.
116
116
 
117
- If a native CLI uses read-only permissions for non-interactive runs, delegation reports attention rather than enabling writes. Resolve access in that CLI’s own configuration or explicitly authorized exact-session invocation, then continue the recorded session. Model summaries are never sufficient evidence of implementation.
117
+ When the CLI's own settings choose no permission mode, dispatch and resume start
118
+ Claude Code with `--permission-mode acceptEdits` and Codex with `--sandbox
119
+ workspace-write`, so a stock install can edit files in its worktree. In
120
+ `acceptEdits`, Claude also runs `mkdir`, `touch`, `rm`, `rmdir`, `mv`, `cp` and `sed`
121
+ without asking, for paths in the worktree and the added context directory. A
122
+ configured mode always wins: Claude `permissions.defaultMode` in user, project, local
123
+ or managed settings files, or Codex `sandbox_mode` in `config.toml` or the project's
124
+ `.codex/config.toml`, outside an inactive profile. Unreadable or oversized settings
125
+ count as configured. Cursor runs with `--trust`. Other shell commands still follow
126
+ the CLI's allowlist and approval settings, and no bypass flag is passed.
127
+
128
+ Limits of this check: it reads settings files only, so system or MDM-delivered
129
+ policies and Codex managed configuration are not seen. A Codex profile selected in
130
+ one file but defined in the other is not matched. A project-level Claude
131
+ `defaultMode`, including `"auto"`, counts as configured. The check runs again on each
132
+ `resume`, so a settings change between turns can change the flag.
133
+
134
+ If the CLI still denies an action, delegation
135
+ reports attention rather than widening access. Resolve access in that CLI’s own configuration or explicitly authorized exact-session invocation, then continue the recorded session. Model summaries are never sufficient evidence of implementation.
136
+
137
+ Cursor's CLI writes its own state back to `~/.cursor/cli-config.json` when a run
138
+ ends, so `permissions.allow` entries added while a run is active can be lost. Add
139
+ the commands the task needs (for example `Shell(pnpm)`) before `dispatch`. After an
140
+ `E_ADAPTER_PERMISSION` attention state, wait until the run has stopped, edit the
141
+ allowlist, then `resume` the same run.
118
142
 
119
143
  ## Diagnostics and unused runs
120
144
 
@@ -1,7 +1,7 @@
1
1
  # Run/session lifecycle
2
2
 
3
- Each new run has private v2 records, a complete readable capsule, one owned detached
4
- worktree and a pinned helper snapshot. Records contain configuration references,
3
+ Each new run has private v3 records, a complete readable capsule, one owned worktree
4
+ on its run branch and a pinned helper snapshot. Records contain configuration references,
5
5
  not credential values. Old runs route operations through their unchanged pinned
6
6
  helpers; there is no automatic migration or permission expansion.
7
7
 
@@ -1,13 +1,21 @@
1
1
  # Worktree and context custody
2
2
 
3
- One run owns one detached worktree outside the user's checkout. Copy only selected
4
- dirty state, preserving starting bytes, deletion and the Git executable bit. Full
5
- required ignored planning and repository instructions live in the readable capsule.
6
- The source checkout and unrelated worktrees remain independent.
3
+ One run owns one locked worktree on its own branch, `planr-delegate/<runId>`, outside
4
+ the user's checkout. Only selected dirty state is copied, preserving starting bytes,
5
+ deletion and the Git executable bit, then committed as the run's base commit without
6
+ repository hooks. Full required ignored planning and repository instructions live in
7
+ the readable capsule. The source checkout and unrelated worktrees remain independent.
7
8
 
8
- Custody records bind the run, worktree ownership, starting HEAD/index, selected
9
- source state and Preserve paths. Commits, staging, Preserve changes, scope violations
10
- and destination conflicts block acceptance. Integration scope constrains accepted
9
+ Custody records bind the run, worktree ownership, base commit, selected source state,
10
+ Preserve paths and the repository's refs. The delegate may commit; the run branch must
11
+ stay checked out and descend from its base. The branch checked out in the parent at
12
+ prepare may not be deleted or moved to a commit that contains the run's base, and a
13
+ restore ref may not be deleted while its run is still applying or interrupted. Any
14
+ other ref change, such as a branch switch, amend, reset, stash, fetch or tag, is a
15
+ report warning.
16
+ Preserve changes, scope violations, submodule (gitlink) changes, including ones that
17
+ `ignore` settings hide, and patches the parent
18
+ checkout no longer accepts block acceptance. Integration scope constrains accepted
11
19
  changes; it does not sandbox every native tool operation. Native tools, hooks,
12
20
  plugins and MCP run under the native harness's permissions and trusted configuration.
13
21
 
@@ -16,10 +24,10 @@ and join the candidate; no manual digest acceptance or immutable setup-path list
16
24
  needed. Ignored dependencies/build/cache outputs are ordinary worktree outputs.
17
25
 
18
26
  Successful native integration removes only the owned worktree by checking its
19
- ownership token and Git registration. Retention can be requested before dispatch.
27
+ ownership token and Git registration, then deletes its run branch. Retention can be requested before dispatch.
20
28
  Failures/interruption retain custody. The private run keeps context, accepted patch,
21
29
  verification evidence, report and exact native session reference after cleanup.
22
30
  Old runs continue through their pinned helper; never broaden their policy or migrate
23
31
  their records automatically.
24
32
 
25
- Guarded integration keeps original directory entries for recovery and for writers holding the old inode. If Git metadata is on a different filesystem, private ignored write custody stays beside the destination and its location is recorded in the Git metadata before the first source write. Recovery validates that location inside the checkout. Existing metadata-based custody and pinned legacy helpers remain readable.
33
+ Runs prepared by older helpers use detached worktrees and their own integration; they finish through that pinned helper.
@@ -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
+ }