p-dev-harness 0.3.0 → 0.3.1

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 (808) hide show
  1. package/README.md +16 -5
  2. package/dist/github/client.d.ts +88 -1
  3. package/dist/github/client.d.ts.map +1 -1
  4. package/dist/github/client.js +98 -7
  5. package/dist/github/client.js.map +1 -1
  6. package/dist/github/rate-limit-metadata.d.ts +16 -0
  7. package/dist/github/rate-limit-metadata.d.ts.map +1 -0
  8. package/dist/github/rate-limit-metadata.js +73 -0
  9. package/dist/github/rate-limit-metadata.js.map +1 -0
  10. package/dist/p-dev/git-object-plumbing.d.ts +19 -0
  11. package/dist/p-dev/git-object-plumbing.d.ts.map +1 -0
  12. package/dist/p-dev/git-object-plumbing.js +196 -0
  13. package/dist/p-dev/git-object-plumbing.js.map +1 -0
  14. package/dist/p-dev/package-paths.d.ts +1 -0
  15. package/dist/p-dev/package-paths.d.ts.map +1 -1
  16. package/dist/p-dev/package-paths.js +3 -0
  17. package/dist/p-dev/package-paths.js.map +1 -1
  18. package/dist/p-dev/workspace-snapshot-digest.d.ts +12 -0
  19. package/dist/p-dev/workspace-snapshot-digest.d.ts.map +1 -0
  20. package/dist/p-dev/workspace-snapshot-digest.js +34 -0
  21. package/dist/p-dev/workspace-snapshot-digest.js.map +1 -0
  22. package/dist/p-dev/workspace-snapshot-generator.d.ts +15 -0
  23. package/dist/p-dev/workspace-snapshot-generator.d.ts.map +1 -0
  24. package/dist/p-dev/workspace-snapshot-generator.js +69 -0
  25. package/dist/p-dev/workspace-snapshot-generator.js.map +1 -0
  26. package/dist/p-dev/workspace-snapshot-git.d.ts +26 -0
  27. package/dist/p-dev/workspace-snapshot-git.d.ts.map +1 -0
  28. package/dist/p-dev/workspace-snapshot-git.js +151 -0
  29. package/dist/p-dev/workspace-snapshot-git.js.map +1 -0
  30. package/dist/p-dev/workspace-snapshot-manifest.d.ts +18 -0
  31. package/dist/p-dev/workspace-snapshot-manifest.d.ts.map +1 -0
  32. package/dist/p-dev/workspace-snapshot-manifest.js +292 -0
  33. package/dist/p-dev/workspace-snapshot-manifest.js.map +1 -0
  34. package/dist/p-dev/workspace-snapshot-policy.d.ts +16 -0
  35. package/dist/p-dev/workspace-snapshot-policy.d.ts.map +1 -0
  36. package/dist/p-dev/workspace-snapshot-policy.js +168 -0
  37. package/dist/p-dev/workspace-snapshot-policy.js.map +1 -0
  38. package/dist/p-dev/workspace-snapshot-types.d.ts +54 -0
  39. package/dist/p-dev/workspace-snapshot-types.d.ts.map +1 -0
  40. package/dist/p-dev/workspace-snapshot-types.js +7 -0
  41. package/dist/p-dev/workspace-snapshot-types.js.map +1 -0
  42. package/dist/p-dev/workspace-snapshot-validation.d.ts +17 -0
  43. package/dist/p-dev/workspace-snapshot-validation.d.ts.map +1 -0
  44. package/dist/p-dev/workspace-snapshot-validation.js +115 -0
  45. package/dist/p-dev/workspace-snapshot-validation.js.map +1 -0
  46. package/dist/setup/github-remote-provider.d.ts +129 -0
  47. package/dist/setup/github-remote-provider.d.ts.map +1 -1
  48. package/dist/setup/github-remote-provider.js +214 -3
  49. package/dist/setup/github-remote-provider.js.map +1 -1
  50. package/dist/setup/github-remote-setup-live.d.ts +46 -1
  51. package/dist/setup/github-remote-setup-live.d.ts.map +1 -1
  52. package/dist/setup/github-remote-setup-live.js +121 -4
  53. package/dist/setup/github-remote-setup-live.js.map +1 -1
  54. package/dist/setup/github-secret-encryption.d.ts.map +1 -1
  55. package/dist/setup/github-secret-encryption.js +3 -1
  56. package/dist/setup/github-secret-encryption.js.map +1 -1
  57. package/dist/setup/github-upload-rate-limit-gate.d.ts +17 -0
  58. package/dist/setup/github-upload-rate-limit-gate.d.ts.map +1 -0
  59. package/dist/setup/github-upload-rate-limit-gate.js +42 -0
  60. package/dist/setup/github-upload-rate-limit-gate.js.map +1 -0
  61. package/dist/setup/harness-managed-repo-marker.d.ts +28 -1
  62. package/dist/setup/harness-managed-repo-marker.d.ts.map +1 -1
  63. package/dist/setup/harness-managed-repo-marker.js +165 -2
  64. package/dist/setup/harness-managed-repo-marker.js.map +1 -1
  65. package/dist/setup/harness-provisioning-context.d.ts +14 -12
  66. package/dist/setup/harness-provisioning-context.d.ts.map +1 -1
  67. package/dist/setup/harness-provisioning-context.js +54 -42
  68. package/dist/setup/harness-provisioning-context.js.map +1 -1
  69. package/dist/setup/harness-provisioning-pending-state.d.ts +33 -22
  70. package/dist/setup/harness-provisioning-pending-state.d.ts.map +1 -1
  71. package/dist/setup/harness-provisioning-pending-state.js +49 -30
  72. package/dist/setup/harness-provisioning-pending-state.js.map +1 -1
  73. package/dist/setup/harness-repo-provisioning.d.ts +10 -5
  74. package/dist/setup/harness-repo-provisioning.d.ts.map +1 -1
  75. package/dist/setup/harness-repo-provisioning.js +403 -335
  76. package/dist/setup/harness-repo-provisioning.js.map +1 -1
  77. package/dist/setup/harness-snapshot-provisioning-helpers.d.ts +21 -0
  78. package/dist/setup/harness-snapshot-provisioning-helpers.d.ts.map +1 -0
  79. package/dist/setup/harness-snapshot-provisioning-helpers.js +55 -0
  80. package/dist/setup/harness-snapshot-provisioning-helpers.js.map +1 -0
  81. package/dist/setup/harness-snapshot-provisioning.d.ts +111 -0
  82. package/dist/setup/harness-snapshot-provisioning.d.ts.map +1 -0
  83. package/dist/setup/harness-snapshot-provisioning.js +684 -0
  84. package/dist/setup/harness-snapshot-provisioning.js.map +1 -0
  85. package/dist/setup/harness-workspace-snapshot-loader.d.ts +15 -0
  86. package/dist/setup/harness-workspace-snapshot-loader.d.ts.map +1 -0
  87. package/dist/setup/harness-workspace-snapshot-loader.js +80 -0
  88. package/dist/setup/harness-workspace-snapshot-loader.js.map +1 -0
  89. package/dist/setup/mock-git-repository-store.d.ts +43 -0
  90. package/dist/setup/mock-git-repository-store.d.ts.map +1 -0
  91. package/dist/setup/mock-git-repository-store.js +232 -0
  92. package/dist/setup/mock-git-repository-store.js.map +1 -0
  93. package/gui/.next/BUILD_ID +1 -1
  94. package/gui/.next/app-build-manifest.json +49 -49
  95. package/gui/.next/app-path-routes-manifest.json +15 -15
  96. package/gui/.next/build-manifest.json +2 -2
  97. package/gui/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  98. package/gui/.next/server/app/_not-found.html +1 -1
  99. package/gui/.next/server/app/_not-found.rsc +2 -2
  100. package/gui/.next/server/app/api/setup/apply-connect-services/route.js +1 -1
  101. package/gui/.next/server/app/api/setup/apply-connect-services/route.js.nft.json +1 -1
  102. package/gui/.next/server/app/api/setup/apply-connect-services/route_client-reference-manifest.js +1 -1
  103. package/gui/.next/server/app/api/setup/apply-harness-repo-provisioning/route.js +1 -1
  104. package/gui/.next/server/app/api/setup/apply-harness-repo-provisioning/route.js.nft.json +1 -1
  105. package/gui/.next/server/app/api/setup/apply-harness-repo-provisioning/route_client-reference-manifest.js +1 -1
  106. package/gui/.next/server/app/api/setup/apply-harness-secrets/route.js +1 -1
  107. package/gui/.next/server/app/api/setup/apply-harness-secrets/route.js.nft.json +1 -1
  108. package/gui/.next/server/app/api/setup/apply-harness-secrets/route_client-reference-manifest.js +1 -1
  109. package/gui/.next/server/app/api/setup/apply-linear-setup/route.js +1 -1
  110. package/gui/.next/server/app/api/setup/apply-linear-setup/route.js.nft.json +1 -1
  111. package/gui/.next/server/app/api/setup/apply-linear-setup/route_client-reference-manifest.js +1 -1
  112. package/gui/.next/server/app/api/setup/apply-local-files/route.js +1 -1
  113. package/gui/.next/server/app/api/setup/apply-local-files/route.js.nft.json +1 -1
  114. package/gui/.next/server/app/api/setup/apply-local-files/route_client-reference-manifest.js +1 -1
  115. package/gui/.next/server/app/api/setup/apply-target-workflow/route.js +1 -1
  116. package/gui/.next/server/app/api/setup/apply-target-workflow/route.js.nft.json +1 -1
  117. package/gui/.next/server/app/api/setup/apply-target-workflow/route_client-reference-manifest.js +1 -1
  118. package/gui/.next/server/app/api/setup/apply-vercel-bridge/route.js +1 -1
  119. package/gui/.next/server/app/api/setup/apply-vercel-bridge/route.js.nft.json +1 -1
  120. package/gui/.next/server/app/api/setup/apply-vercel-bridge/route_client-reference-manifest.js +1 -1
  121. package/gui/.next/server/app/api/setup/finalize-target-workflow/route.js +1 -1
  122. package/gui/.next/server/app/api/setup/finalize-target-workflow/route.js.nft.json +1 -1
  123. package/gui/.next/server/app/api/setup/finalize-target-workflow/route_client-reference-manifest.js +1 -1
  124. package/gui/.next/server/app/api/setup/harness-provisioning-summary/route.js +1 -1
  125. package/gui/.next/server/app/api/setup/harness-provisioning-summary/route.js.nft.json +1 -1
  126. package/gui/.next/server/app/api/setup/harness-provisioning-summary/route_client-reference-manifest.js +1 -1
  127. package/gui/.next/server/app/api/setup/linear-options/route.js +1 -1
  128. package/gui/.next/server/app/api/setup/linear-options/route.js.nft.json +1 -1
  129. package/gui/.next/server/app/api/setup/linear-options/route_client-reference-manifest.js +1 -1
  130. package/gui/.next/server/app/api/setup/linear-summary/route.js +1 -1
  131. package/gui/.next/server/app/api/setup/linear-summary/route.js.nft.json +1 -1
  132. package/gui/.next/server/app/api/setup/linear-summary/route_client-reference-manifest.js +1 -1
  133. package/gui/.next/server/app/api/setup/local-readiness/route_client-reference-manifest.js +1 -1
  134. package/gui/.next/server/app/api/setup/manual-harness-secret-values/route.js +1 -1
  135. package/gui/.next/server/app/api/setup/manual-harness-secret-values/route.js.nft.json +1 -1
  136. package/gui/.next/server/app/api/setup/manual-harness-secret-values/route_client-reference-manifest.js +1 -1
  137. package/gui/.next/server/app/api/setup/preview-connect-services/route.js +1 -1
  138. package/gui/.next/server/app/api/setup/preview-connect-services/route.js.nft.json +1 -1
  139. package/gui/.next/server/app/api/setup/preview-connect-services/route_client-reference-manifest.js +1 -1
  140. package/gui/.next/server/app/api/setup/preview-harness-repo-provisioning/route.js +1 -1
  141. package/gui/.next/server/app/api/setup/preview-harness-repo-provisioning/route.js.nft.json +1 -1
  142. package/gui/.next/server/app/api/setup/preview-harness-repo-provisioning/route_client-reference-manifest.js +1 -1
  143. package/gui/.next/server/app/api/setup/preview-harness-secrets/route.js +1 -1
  144. package/gui/.next/server/app/api/setup/preview-harness-secrets/route.js.nft.json +1 -1
  145. package/gui/.next/server/app/api/setup/preview-harness-secrets/route_client-reference-manifest.js +1 -1
  146. package/gui/.next/server/app/api/setup/preview-linear-setup/route.js +1 -1
  147. package/gui/.next/server/app/api/setup/preview-linear-setup/route.js.nft.json +1 -1
  148. package/gui/.next/server/app/api/setup/preview-linear-setup/route_client-reference-manifest.js +1 -1
  149. package/gui/.next/server/app/api/setup/preview-local-files/route.js +1 -1
  150. package/gui/.next/server/app/api/setup/preview-local-files/route.js.nft.json +1 -1
  151. package/gui/.next/server/app/api/setup/preview-local-files/route_client-reference-manifest.js +1 -1
  152. package/gui/.next/server/app/api/setup/preview-target-workflow/route.js +1 -1
  153. package/gui/.next/server/app/api/setup/preview-target-workflow/route.js.nft.json +1 -1
  154. package/gui/.next/server/app/api/setup/preview-target-workflow/route_client-reference-manifest.js +1 -1
  155. package/gui/.next/server/app/api/setup/preview-vercel-bridge/route.js +1 -1
  156. package/gui/.next/server/app/api/setup/preview-vercel-bridge/route.js.nft.json +1 -1
  157. package/gui/.next/server/app/api/setup/preview-vercel-bridge/route_client-reference-manifest.js +1 -1
  158. package/gui/.next/server/app/api/setup/remote-summary/route.js +1 -1
  159. package/gui/.next/server/app/api/setup/remote-summary/route.js.nft.json +1 -1
  160. package/gui/.next/server/app/api/setup/remote-summary/route_client-reference-manifest.js +1 -1
  161. package/gui/.next/server/app/api/setup/summary/route.js +1 -1
  162. package/gui/.next/server/app/api/setup/summary/route.js.nft.json +1 -1
  163. package/gui/.next/server/app/api/setup/summary/route_client-reference-manifest.js +1 -1
  164. package/gui/.next/server/app/api/setup/vercel-bridge-options/route.js +1 -1
  165. package/gui/.next/server/app/api/setup/vercel-bridge-options/route.js.nft.json +1 -1
  166. package/gui/.next/server/app/api/setup/vercel-bridge-options/route_client-reference-manifest.js +1 -1
  167. package/gui/.next/server/app/api/setup/vercel-bridge-redeploy-status/route.js +1 -1
  168. package/gui/.next/server/app/api/setup/vercel-bridge-redeploy-status/route.js.nft.json +1 -1
  169. package/gui/.next/server/app/api/setup/vercel-bridge-redeploy-status/route_client-reference-manifest.js +1 -1
  170. package/gui/.next/server/app/api/setup/vercel-summary/route.js +1 -1
  171. package/gui/.next/server/app/api/setup/vercel-summary/route.js.nft.json +1 -1
  172. package/gui/.next/server/app/api/setup/vercel-summary/route_client-reference-manifest.js +1 -1
  173. package/gui/.next/server/app/api/setup/verify-harness-repo/route.js +1 -1
  174. package/gui/.next/server/app/api/setup/verify-harness-repo/route.js.nft.json +1 -1
  175. package/gui/.next/server/app/api/setup/verify-harness-repo/route_client-reference-manifest.js +1 -1
  176. package/gui/.next/server/app/api/setup/verify-service/route_client-reference-manifest.js +1 -1
  177. package/gui/.next/server/app/api/setup/verify-target-repo/route_client-reference-manifest.js +1 -1
  178. package/gui/.next/server/app/index.html +1 -1
  179. package/gui/.next/server/app/index.rsc +2 -2
  180. package/gui/.next/server/app/page_client-reference-manifest.js +1 -1
  181. package/gui/.next/server/app/settings/configure/page.js +2 -2
  182. package/gui/.next/server/app/settings/configure/page.js.nft.json +1 -1
  183. package/gui/.next/server/app/settings/configure/page_client-reference-manifest.js +1 -1
  184. package/gui/.next/server/app-paths-manifest.json +15 -15
  185. package/gui/.next/server/chunks/477.js +2 -2
  186. package/gui/.next/server/chunks/647.js +82 -0
  187. package/gui/.next/server/chunks/900.js +1 -1
  188. package/gui/.next/server/pages/404.html +1 -1
  189. package/gui/.next/server/pages/500.html +1 -1
  190. package/gui/.next/static/css/781f3c93b6d7425a.css +3 -0
  191. package/gui/.next/trace +4 -4
  192. package/package.json +2 -1
  193. package/workspace-snapshot/files/.agents/skills/architecture-evolution-audit/SKILL.md +282 -0
  194. package/workspace-snapshot/files/.agents/skills/code-health-audit/SKILL.md +188 -0
  195. package/workspace-snapshot/files/.agents/skills/implementation/SKILL.md +279 -0
  196. package/workspace-snapshot/files/.agents/skills/issue-intake/SKILL.md +163 -0
  197. package/workspace-snapshot/files/.agents/skills/issue-intake/examples.md +112 -0
  198. package/workspace-snapshot/files/.agents/skills/planner/SKILL.md +253 -0
  199. package/workspace-snapshot/files/.agents/skills/security-audit/SKILL.md +270 -0
  200. package/workspace-snapshot/files/.env.example +37 -0
  201. package/workspace-snapshot/files/.github/CODEOWNERS +4 -0
  202. package/workspace-snapshot/files/.github/dependabot.yml +12 -0
  203. package/workspace-snapshot/files/.github/workflows/ci.yml +32 -0
  204. package/workspace-snapshot/files/.github/workflows/codeql.yml +35 -0
  205. package/workspace-snapshot/files/.github/workflows/harness-auto-runner.yml +561 -0
  206. package/workspace-snapshot/files/.harness/config.example.json +83 -0
  207. package/workspace-snapshot/files/AGENTS.md +130 -0
  208. package/workspace-snapshot/files/ARCHITECTURE.md +385 -0
  209. package/workspace-snapshot/files/CHANGELOG.md +166 -0
  210. package/workspace-snapshot/files/LICENSE +21 -0
  211. package/workspace-snapshot/files/README.md +110 -0
  212. package/workspace-snapshot/files/ROADMAP.md +50 -0
  213. package/workspace-snapshot/files/api/linear-webhook.ts +41 -0
  214. package/workspace-snapshot/files/apps/gui/app/api/setup/apply-connect-services/route.ts +21 -0
  215. package/workspace-snapshot/files/apps/gui/app/api/setup/apply-harness-repo-provisioning/route.ts +35 -0
  216. package/workspace-snapshot/files/apps/gui/app/api/setup/apply-harness-secrets/route.ts +42 -0
  217. package/workspace-snapshot/files/apps/gui/app/api/setup/apply-linear-setup/route.ts +23 -0
  218. package/workspace-snapshot/files/apps/gui/app/api/setup/apply-local-files/route.ts +42 -0
  219. package/workspace-snapshot/files/apps/gui/app/api/setup/apply-target-workflow/route.ts +49 -0
  220. package/workspace-snapshot/files/apps/gui/app/api/setup/apply-vercel-bridge/route.ts +26 -0
  221. package/workspace-snapshot/files/apps/gui/app/api/setup/finalize-target-workflow/route.ts +32 -0
  222. package/workspace-snapshot/files/apps/gui/app/api/setup/harness-provisioning-summary/route.ts +17 -0
  223. package/workspace-snapshot/files/apps/gui/app/api/setup/linear-options/route.ts +17 -0
  224. package/workspace-snapshot/files/apps/gui/app/api/setup/linear-summary/route.ts +15 -0
  225. package/workspace-snapshot/files/apps/gui/app/api/setup/local-readiness/route.ts +18 -0
  226. package/workspace-snapshot/files/apps/gui/app/api/setup/manual-harness-secret-values/route.ts +33 -0
  227. package/workspace-snapshot/files/apps/gui/app/api/setup/preview-connect-services/route.ts +17 -0
  228. package/workspace-snapshot/files/apps/gui/app/api/setup/preview-harness-repo-provisioning/route.ts +22 -0
  229. package/workspace-snapshot/files/apps/gui/app/api/setup/preview-harness-secrets/route.ts +19 -0
  230. package/workspace-snapshot/files/apps/gui/app/api/setup/preview-linear-setup/route.ts +20 -0
  231. package/workspace-snapshot/files/apps/gui/app/api/setup/preview-local-files/route.ts +17 -0
  232. package/workspace-snapshot/files/apps/gui/app/api/setup/preview-target-workflow/route.ts +25 -0
  233. package/workspace-snapshot/files/apps/gui/app/api/setup/preview-vercel-bridge/route.ts +23 -0
  234. package/workspace-snapshot/files/apps/gui/app/api/setup/remote-summary/route.ts +15 -0
  235. package/workspace-snapshot/files/apps/gui/app/api/setup/summary/route.ts +10 -0
  236. package/workspace-snapshot/files/apps/gui/app/api/setup/vercel-bridge-options/route.ts +29 -0
  237. package/workspace-snapshot/files/apps/gui/app/api/setup/vercel-bridge-redeploy-status/route.ts +22 -0
  238. package/workspace-snapshot/files/apps/gui/app/api/setup/vercel-summary/route.ts +15 -0
  239. package/workspace-snapshot/files/apps/gui/app/api/setup/verify-harness-repo/route.ts +31 -0
  240. package/workspace-snapshot/files/apps/gui/app/api/setup/verify-service/route.ts +41 -0
  241. package/workspace-snapshot/files/apps/gui/app/api/setup/verify-target-repo/route.ts +33 -0
  242. package/workspace-snapshot/files/apps/gui/app/layout.tsx +28 -0
  243. package/workspace-snapshot/files/apps/gui/app/page.tsx +5 -0
  244. package/workspace-snapshot/files/apps/gui/app/settings/configure/page.tsx +34 -0
  245. package/workspace-snapshot/files/apps/gui/components/custom/app-shell.tsx +39 -0
  246. package/workspace-snapshot/files/apps/gui/components/custom/configure-experience.tsx +671 -0
  247. package/workspace-snapshot/files/apps/gui/components/custom/configure-page-content.tsx +45 -0
  248. package/workspace-snapshot/files/apps/gui/components/custom/configure-workflow.tsx +1284 -0
  249. package/workspace-snapshot/files/apps/gui/components/custom/connected-status.tsx +30 -0
  250. package/workspace-snapshot/files/apps/gui/components/custom/environment-config-form.tsx +400 -0
  251. package/workspace-snapshot/files/apps/gui/components/custom/first-run-stepper.tsx +199 -0
  252. package/workspace-snapshot/files/apps/gui/components/custom/github-token-help-disclosure.tsx +142 -0
  253. package/workspace-snapshot/files/apps/gui/components/custom/guided-cloud-secrets-card.tsx +993 -0
  254. package/workspace-snapshot/files/apps/gui/components/custom/guided-linear-workspace-card.tsx +526 -0
  255. package/workspace-snapshot/files/apps/gui/components/custom/guided-local-readiness-card.tsx +132 -0
  256. package/workspace-snapshot/files/apps/gui/components/custom/guided-step-transition.tsx +60 -0
  257. package/workspace-snapshot/files/apps/gui/components/custom/guided-target-workflow-card.tsx +396 -0
  258. package/workspace-snapshot/files/apps/gui/components/custom/guided-vercel-bridge-card.tsx +861 -0
  259. package/workspace-snapshot/files/apps/gui/components/custom/local-write-confirmation.tsx +91 -0
  260. package/workspace-snapshot/files/apps/gui/components/custom/local-write-preview.tsx +52 -0
  261. package/workspace-snapshot/files/apps/gui/components/custom/preview-panel.tsx +19 -0
  262. package/workspace-snapshot/files/apps/gui/components/custom/primary-setup-task-card.tsx +65 -0
  263. package/workspace-snapshot/files/apps/gui/components/custom/readiness-banner.tsx +91 -0
  264. package/workspace-snapshot/files/apps/gui/components/custom/remote-action-confirmation.tsx +155 -0
  265. package/workspace-snapshot/files/apps/gui/components/custom/remote-action-preview.tsx +84 -0
  266. package/workspace-snapshot/files/apps/gui/components/custom/remote-secret-form.tsx +123 -0
  267. package/workspace-snapshot/files/apps/gui/components/custom/remote-setup-section.tsx +354 -0
  268. package/workspace-snapshot/files/apps/gui/components/custom/review-cloud-secrets-disclosure.tsx +59 -0
  269. package/workspace-snapshot/files/apps/gui/components/custom/review-generated-files-disclosure.tsx +67 -0
  270. package/workspace-snapshot/files/apps/gui/components/custom/section-card.tsx +33 -0
  271. package/workspace-snapshot/files/apps/gui/components/custom/service-icons.tsx +30 -0
  272. package/workspace-snapshot/files/apps/gui/components/custom/setup-apply-result.tsx +52 -0
  273. package/workspace-snapshot/files/apps/gui/components/custom/setup-checklist.tsx +206 -0
  274. package/workspace-snapshot/files/apps/gui/components/custom/setup-dashboard.tsx +124 -0
  275. package/workspace-snapshot/files/apps/gui/components/custom/setup-readonly-sections.tsx +210 -0
  276. package/workspace-snapshot/files/apps/gui/components/custom/status-badge.tsx +22 -0
  277. package/workspace-snapshot/files/apps/gui/components/custom/target-repo-config-form.tsx +647 -0
  278. package/workspace-snapshot/files/apps/gui/components/custom/target-workflow-pr-card.tsx +283 -0
  279. package/workspace-snapshot/files/apps/gui/components/custom/theme-provider.tsx +11 -0
  280. package/workspace-snapshot/files/apps/gui/components/custom/theme-toggle.tsx +44 -0
  281. package/workspace-snapshot/files/apps/gui/components/custom/workflow-install-pending-panel.tsx +116 -0
  282. package/workspace-snapshot/files/apps/gui/components/ui/badge.tsx +40 -0
  283. package/workspace-snapshot/files/apps/gui/components/ui/button.tsx +52 -0
  284. package/workspace-snapshot/files/apps/gui/components/ui/card.tsx +64 -0
  285. package/workspace-snapshot/files/apps/gui/components/ui/checkbox.tsx +21 -0
  286. package/workspace-snapshot/files/apps/gui/components/ui/input.tsx +22 -0
  287. package/workspace-snapshot/files/apps/gui/components/ui/label.tsx +20 -0
  288. package/workspace-snapshot/files/apps/gui/components/ui/separator.tsx +23 -0
  289. package/workspace-snapshot/files/apps/gui/components/ui/skeleton.tsx +13 -0
  290. package/workspace-snapshot/files/apps/gui/components/ui/textarea.tsx +22 -0
  291. package/workspace-snapshot/files/apps/gui/components.json +21 -0
  292. package/workspace-snapshot/files/apps/gui/lib/constants/breakpoints.ts +13 -0
  293. package/workspace-snapshot/files/apps/gui/lib/constants/form.ts +8 -0
  294. package/workspace-snapshot/files/apps/gui/lib/constants/index.ts +4 -0
  295. package/workspace-snapshot/files/apps/gui/lib/constants/layout.ts +9 -0
  296. package/workspace-snapshot/files/apps/gui/lib/constants/spacing.ts +8 -0
  297. package/workspace-snapshot/files/apps/gui/lib/guided-setup.ts +216 -0
  298. package/workspace-snapshot/files/apps/gui/lib/setup-json-response.ts +19 -0
  299. package/workspace-snapshot/files/apps/gui/lib/setup-server.ts +836 -0
  300. package/workspace-snapshot/files/apps/gui/lib/step6-remote-state.ts +43 -0
  301. package/workspace-snapshot/files/apps/gui/lib/utils.ts +6 -0
  302. package/workspace-snapshot/files/apps/gui/lib/vercel-bridge-polling-ui.ts +16 -0
  303. package/workspace-snapshot/files/apps/gui/lib/verification-state.ts +170 -0
  304. package/workspace-snapshot/files/apps/gui/next-env.d.ts +6 -0
  305. package/workspace-snapshot/files/apps/gui/next.config.ts +34 -0
  306. package/workspace-snapshot/files/apps/gui/postcss.config.mjs +8 -0
  307. package/workspace-snapshot/files/apps/gui/public/setup/github-token/github-pat-generate-classic.png +0 -0
  308. package/workspace-snapshot/files/apps/gui/public/setup/github-token/github-pat-generate-new-token.png +0 -0
  309. package/workspace-snapshot/files/apps/gui/public/setup/github-token/github-pat-verify-email.png +0 -0
  310. package/workspace-snapshot/files/apps/gui/styles/globals.css +86 -0
  311. package/workspace-snapshot/files/apps/gui/tsconfig.json +24 -0
  312. package/workspace-snapshot/files/apps/gui/tweetsodium.d.ts +14 -0
  313. package/workspace-snapshot/files/docs/architecture/linear-automation-state-machine.md +267 -0
  314. package/workspace-snapshot/files/docs/decisions/0001-cursor-first-v0.1.md +59 -0
  315. package/workspace-snapshot/files/docs/decisions/0003-automation-state-machine-and-auto-model-policy.md +65 -0
  316. package/workspace-snapshot/files/docs/decisions/0004-agent-provider-boundary.md +109 -0
  317. package/workspace-snapshot/files/docs/design/product-development-harness-gui.md +1024 -0
  318. package/workspace-snapshot/files/docs/getting-started.md +123 -0
  319. package/workspace-snapshot/files/docs/gui-local.md +151 -0
  320. package/workspace-snapshot/files/docs/gui-remote-setup.md +106 -0
  321. package/workspace-snapshot/files/docs/integration-repair.md +82 -0
  322. package/workspace-snapshot/files/docs/issue-intake.md +124 -0
  323. package/workspace-snapshot/files/docs/linear-watcher-setup.md +184 -0
  324. package/workspace-snapshot/files/docs/milestones/m1-runner-foundation.md +51 -0
  325. package/workspace-snapshot/files/docs/milestones/m2-planning-phase.md +129 -0
  326. package/workspace-snapshot/files/docs/milestones/m3-implementation-phase.md +158 -0
  327. package/workspace-snapshot/files/docs/milestones/m4-handoff-phase.md +122 -0
  328. package/workspace-snapshot/files/docs/milestones/m5-revision-phase.md +101 -0
  329. package/workspace-snapshot/files/docs/milestones/m6-merge-phase.md +143 -0
  330. package/workspace-snapshot/files/docs/milestones/m7-issue-intake.md +72 -0
  331. package/workspace-snapshot/files/docs/milestones/m8-linear-watcher.md +80 -0
  332. package/workspace-snapshot/files/docs/npm-packaging-spike.md +52 -0
  333. package/workspace-snapshot/files/docs/operator-config.md +187 -0
  334. package/workspace-snapshot/files/docs/p-dev.md +213 -0
  335. package/workspace-snapshot/files/docs/production-sync-automation.md +176 -0
  336. package/workspace-snapshot/files/docs/provider-portability.md +131 -0
  337. package/workspace-snapshot/files/docs/releases/release-process.md +272 -0
  338. package/workspace-snapshot/files/docs/releases/v0.2.0.md +193 -0
  339. package/workspace-snapshot/files/docs/releases/v0.3.0.md +188 -0
  340. package/workspace-snapshot/files/docs/releases/v0.3.1.md +102 -0
  341. package/workspace-snapshot/files/docs/research/001-manual-run-retrospective.md +64 -0
  342. package/workspace-snapshot/files/docs/research/002-linear-cursor-integration-smoke-test.md +64 -0
  343. package/workspace-snapshot/files/docs/research/003-cursor-automation-planning-router-spike.md +104 -0
  344. package/workspace-snapshot/files/docs/research/README.md +26 -0
  345. package/workspace-snapshot/files/docs/security.md +190 -0
  346. package/workspace-snapshot/files/docs/skills/README.md +7 -0
  347. package/workspace-snapshot/files/docs/skills/skill-architecture.md +197 -0
  348. package/workspace-snapshot/files/docs/target-repo-branch-setup.md +80 -0
  349. package/workspace-snapshot/files/evals/README.md +31 -0
  350. package/workspace-snapshot/files/examples/README.md +32 -0
  351. package/workspace-snapshot/files/examples/runs/001-target-app-github-link/README.md +49 -0
  352. package/workspace-snapshot/files/examples/runs/001-target-app-github-link/eval-scorecard.md +63 -0
  353. package/workspace-snapshot/files/examples/runs/001-target-app-github-link/implementation-plan.md +79 -0
  354. package/workspace-snapshot/files/examples/runs/001-target-app-github-link/linear-issue.md +74 -0
  355. package/workspace-snapshot/files/examples/runs/001-target-app-github-link/pr-readiness-report.md +92 -0
  356. package/workspace-snapshot/files/examples/runs/m5.5-live-sandbox-smoke/README.md +73 -0
  357. package/workspace-snapshot/files/gpt/issue-intake/custom-gpt-instructions.md +112 -0
  358. package/workspace-snapshot/files/gpt/issue-intake/knowledge.md +278 -0
  359. package/workspace-snapshot/files/gpt/issue-intake/setup-guide.md +115 -0
  360. package/workspace-snapshot/files/gpt/issue-intake/smoke-test.md +119 -0
  361. package/workspace-snapshot/files/harness.config.json +92 -0
  362. package/workspace-snapshot/files/harness.config.schema.json +352 -0
  363. package/workspace-snapshot/files/package-lock.json +3716 -0
  364. package/workspace-snapshot/files/package.json +60 -0
  365. package/workspace-snapshot/files/packages/p-dev/LICENSE +21 -0
  366. package/workspace-snapshot/files/packages/p-dev/README.md +64 -0
  367. package/workspace-snapshot/files/packages/p-dev/gui.next.config.mjs +13 -0
  368. package/workspace-snapshot/files/packages/p-dev/package.json +63 -0
  369. package/workspace-snapshot/files/prompts/issue-intake-chatgpt.md +264 -0
  370. package/workspace-snapshot/files/scripts/generate-config-schema.ts +16 -0
  371. package/workspace-snapshot/files/scripts/prepare-p-dev-package.ts +155 -0
  372. package/workspace-snapshot/files/skills/README.md +7 -0
  373. package/workspace-snapshot/files/skills/issue-intake/README.md +5 -0
  374. package/workspace-snapshot/files/src/agents/cursor-provider.ts +109 -0
  375. package/workspace-snapshot/files/src/agents/index.ts +68 -0
  376. package/workspace-snapshot/files/src/agents/provider.ts +7 -0
  377. package/workspace-snapshot/files/src/agents/types.ts +85 -0
  378. package/workspace-snapshot/files/src/artifacts/events.ts +31 -0
  379. package/workspace-snapshot/files/src/artifacts/manifest-fields.ts +9 -0
  380. package/workspace-snapshot/files/src/artifacts/manifest.ts +20 -0
  381. package/workspace-snapshot/files/src/artifacts/paths.ts +145 -0
  382. package/workspace-snapshot/files/src/artifacts/redact.ts +50 -0
  383. package/workspace-snapshot/files/src/artifacts/run-id.ts +4 -0
  384. package/workspace-snapshot/files/src/artifacts/snapshot.ts +13 -0
  385. package/workspace-snapshot/files/src/artifacts/summary.ts +116 -0
  386. package/workspace-snapshot/files/src/cli/commands/diagnose-vercel-bridge.ts +25 -0
  387. package/workspace-snapshot/files/src/cli/commands/doctor.ts +205 -0
  388. package/workspace-snapshot/files/src/cli/commands/inspect.ts +46 -0
  389. package/workspace-snapshot/files/src/cli/commands/operator-init.ts +39 -0
  390. package/workspace-snapshot/files/src/cli/commands/redact-output.ts +19 -0
  391. package/workspace-snapshot/files/src/cli/commands/resolve-route.ts +81 -0
  392. package/workspace-snapshot/files/src/cli/commands/run.ts +53 -0
  393. package/workspace-snapshot/files/src/cli/commands/sync-production.ts +207 -0
  394. package/workspace-snapshot/files/src/cli/commands/validate-issue.ts +72 -0
  395. package/workspace-snapshot/files/src/cli/exit-codes.ts +4 -0
  396. package/workspace-snapshot/files/src/cli/finalize-exit.ts +9 -0
  397. package/workspace-snapshot/files/src/cli/program.ts +200 -0
  398. package/workspace-snapshot/files/src/config/defaults.ts +33 -0
  399. package/workspace-snapshot/files/src/config/load-config.ts +80 -0
  400. package/workspace-snapshot/files/src/config/load-dotenv.ts +11 -0
  401. package/workspace-snapshot/files/src/config/resolve-config.ts +127 -0
  402. package/workspace-snapshot/files/src/config/schema.ts +129 -0
  403. package/workspace-snapshot/files/src/config/status-names.ts +63 -0
  404. package/workspace-snapshot/files/src/config/types.ts +1 -0
  405. package/workspace-snapshot/files/src/cursor/agent-factory.ts +126 -0
  406. package/workspace-snapshot/files/src/cursor/errors.ts +18 -0
  407. package/workspace-snapshot/files/src/cursor/git-result.ts +87 -0
  408. package/workspace-snapshot/files/src/cursor/model.ts +47 -0
  409. package/workspace-snapshot/files/src/cursor/revision-git-result.ts +80 -0
  410. package/workspace-snapshot/files/src/cursor/run-cleanup.ts +30 -0
  411. package/workspace-snapshot/files/src/cursor/run-observer.ts +367 -0
  412. package/workspace-snapshot/files/src/cursor/urls.ts +19 -0
  413. package/workspace-snapshot/files/src/fixture/frontmatter.ts +56 -0
  414. package/workspace-snapshot/files/src/github/actions-url.ts +13 -0
  415. package/workspace-snapshot/files/src/github/base-branch.ts +120 -0
  416. package/workspace-snapshot/files/src/github/check-policy.ts +108 -0
  417. package/workspace-snapshot/files/src/github/client.ts +796 -0
  418. package/workspace-snapshot/files/src/github/commit-reachability.ts +184 -0
  419. package/workspace-snapshot/files/src/github/links.ts +23 -0
  420. package/workspace-snapshot/files/src/github/merge-result.ts +31 -0
  421. package/workspace-snapshot/files/src/github/pr-discovery.ts +55 -0
  422. package/workspace-snapshot/files/src/github/pr-inspector.ts +297 -0
  423. package/workspace-snapshot/files/src/github/pr-url.ts +23 -0
  424. package/workspace-snapshot/files/src/github/rate-limit-metadata.ts +105 -0
  425. package/workspace-snapshot/files/src/gui/configure-health.ts +160 -0
  426. package/workspace-snapshot/files/src/gui/dev-server-process.ts +213 -0
  427. package/workspace-snapshot/files/src/gui/port.ts +78 -0
  428. package/workspace-snapshot/files/src/gui/repo-root.ts +61 -0
  429. package/workspace-snapshot/files/src/gui/start-configure-stable.ts +139 -0
  430. package/workspace-snapshot/files/src/gui/start-gui.ts +126 -0
  431. package/workspace-snapshot/files/src/index.ts +10 -0
  432. package/workspace-snapshot/files/src/linear/client.ts +49 -0
  433. package/workspace-snapshot/files/src/linear/comment-card.ts +74 -0
  434. package/workspace-snapshot/files/src/linear/comments.ts +891 -0
  435. package/workspace-snapshot/files/src/linear/handoff-comment.ts +19 -0
  436. package/workspace-snapshot/files/src/linear/issue-query.ts +70 -0
  437. package/workspace-snapshot/files/src/linear/markers.ts +238 -0
  438. package/workspace-snapshot/files/src/linear/merge-source-comment.ts +46 -0
  439. package/workspace-snapshot/files/src/linear/parser.ts +101 -0
  440. package/workspace-snapshot/files/src/linear/phase-labels.ts +58 -0
  441. package/workspace-snapshot/files/src/linear/planning-comment.ts +19 -0
  442. package/workspace-snapshot/files/src/linear/pm-feedback-comment.ts +41 -0
  443. package/workspace-snapshot/files/src/linear/revision-comment.ts +19 -0
  444. package/workspace-snapshot/files/src/linear/states.ts +20 -0
  445. package/workspace-snapshot/files/src/linear/writer.ts +216 -0
  446. package/workspace-snapshot/files/src/p-dev/browser.ts +26 -0
  447. package/workspace-snapshot/files/src/p-dev/cli.ts +93 -0
  448. package/workspace-snapshot/files/src/p-dev/git-object-plumbing.ts +271 -0
  449. package/workspace-snapshot/files/src/p-dev/launch.ts +173 -0
  450. package/workspace-snapshot/files/src/p-dev/main.ts +10 -0
  451. package/workspace-snapshot/files/src/p-dev/next-bin.ts +8 -0
  452. package/workspace-snapshot/files/src/p-dev/node-version.ts +46 -0
  453. package/workspace-snapshot/files/src/p-dev/package-paths.ts +47 -0
  454. package/workspace-snapshot/files/src/p-dev/package-version.ts +63 -0
  455. package/workspace-snapshot/files/src/p-dev/runtime-mode.ts +28 -0
  456. package/workspace-snapshot/files/src/p-dev/shutdown.ts +66 -0
  457. package/workspace-snapshot/files/src/p-dev/workspace-snapshot-digest.ts +50 -0
  458. package/workspace-snapshot/files/src/p-dev/workspace-snapshot-generator.ts +112 -0
  459. package/workspace-snapshot/files/src/p-dev/workspace-snapshot-git.ts +221 -0
  460. package/workspace-snapshot/files/src/p-dev/workspace-snapshot-manifest.ts +336 -0
  461. package/workspace-snapshot/files/src/p-dev/workspace-snapshot-policy.ts +198 -0
  462. package/workspace-snapshot/files/src/p-dev/workspace-snapshot-types.ts +59 -0
  463. package/workspace-snapshot/files/src/p-dev/workspace-snapshot-validation.ts +137 -0
  464. package/workspace-snapshot/files/src/p-dev/workspace.ts +114 -0
  465. package/workspace-snapshot/files/src/preview/production-from-merge.ts +143 -0
  466. package/workspace-snapshot/files/src/preview/urls.ts +28 -0
  467. package/workspace-snapshot/files/src/preview/vercel-from-pr.ts +123 -0
  468. package/workspace-snapshot/files/src/prompts/branch-name.ts +22 -0
  469. package/workspace-snapshot/files/src/prompts/builder.ts +88 -0
  470. package/workspace-snapshot/files/src/prompts/implementation.md +77 -0
  471. package/workspace-snapshot/files/src/prompts/integration-repair-builder.ts +65 -0
  472. package/workspace-snapshot/files/src/prompts/integration-repair.md +111 -0
  473. package/workspace-snapshot/files/src/prompts/planning.md +64 -0
  474. package/workspace-snapshot/files/src/prompts/revision-builder.ts +61 -0
  475. package/workspace-snapshot/files/src/prompts/revision.md +71 -0
  476. package/workspace-snapshot/files/src/resolver/allowed-repos.ts +18 -0
  477. package/workspace-snapshot/files/src/resolver/errors.ts +14 -0
  478. package/workspace-snapshot/files/src/resolver/normalize-repo.ts +32 -0
  479. package/workspace-snapshot/files/src/resolver/target-repo.ts +118 -0
  480. package/workspace-snapshot/files/src/runner/building-recovery.ts +26 -0
  481. package/workspace-snapshot/files/src/runner/dry-run.ts +137 -0
  482. package/workspace-snapshot/files/src/runner/errors.ts +70 -0
  483. package/workspace-snapshot/files/src/runner/execution-environment.ts +179 -0
  484. package/workspace-snapshot/files/src/runner/fixture.ts +25 -0
  485. package/workspace-snapshot/files/src/runner/idempotency.ts +507 -0
  486. package/workspace-snapshot/files/src/runner/orchestrator.ts +182 -0
  487. package/workspace-snapshot/files/src/runner/phase-args.ts +49 -0
  488. package/workspace-snapshot/files/src/runner/phase-infer.ts +67 -0
  489. package/workspace-snapshot/files/src/runner/phases/handoff.ts +615 -0
  490. package/workspace-snapshot/files/src/runner/phases/implementation.ts +617 -0
  491. package/workspace-snapshot/files/src/runner/phases/integration-repair.ts +613 -0
  492. package/workspace-snapshot/files/src/runner/phases/merge.ts +1202 -0
  493. package/workspace-snapshot/files/src/runner/phases/planning.ts +456 -0
  494. package/workspace-snapshot/files/src/runner/phases/production-sync.ts +308 -0
  495. package/workspace-snapshot/files/src/runner/phases/revision.ts +795 -0
  496. package/workspace-snapshot/files/src/runner/preflight.ts +218 -0
  497. package/workspace-snapshot/files/src/runner/resolve-route.ts +154 -0
  498. package/workspace-snapshot/files/src/setup/config-builder.ts +117 -0
  499. package/workspace-snapshot/files/src/setup/config-local-editor.ts +260 -0
  500. package/workspace-snapshot/files/src/setup/config-writer.ts +173 -0
  501. package/workspace-snapshot/files/src/setup/control-plane-readiness-server.ts +16 -0
  502. package/workspace-snapshot/files/src/setup/control-plane-readiness.ts +291 -0
  503. package/workspace-snapshot/files/src/setup/control-plane-setup-state.ts +60 -0
  504. package/workspace-snapshot/files/src/setup/control-plane-types.ts +121 -0
  505. package/workspace-snapshot/files/src/setup/doctor-summary.ts +96 -0
  506. package/workspace-snapshot/files/src/setup/env-merge.ts +266 -0
  507. package/workspace-snapshot/files/src/setup/env-writer.ts +179 -0
  508. package/workspace-snapshot/files/src/setup/first-run-readiness.ts +1431 -0
  509. package/workspace-snapshot/files/src/setup/generated-instructions.ts +96 -0
  510. package/workspace-snapshot/files/src/setup/github-dispatch-token.ts +88 -0
  511. package/workspace-snapshot/files/src/setup/github-remote-provider.ts +983 -0
  512. package/workspace-snapshot/files/src/setup/github-remote-setup-live.ts +775 -0
  513. package/workspace-snapshot/files/src/setup/github-repo-slug.ts +31 -0
  514. package/workspace-snapshot/files/src/setup/github-secret-encryption.ts +16 -0
  515. package/workspace-snapshot/files/src/setup/github-upload-rate-limit-gate.ts +58 -0
  516. package/workspace-snapshot/files/src/setup/github-workflow-permissions.ts +174 -0
  517. package/workspace-snapshot/files/src/setup/gui-view-model.ts +566 -0
  518. package/workspace-snapshot/files/src/setup/guided-config-form.ts +52 -0
  519. package/workspace-snapshot/files/src/setup/harness-dispatch-repo.ts +158 -0
  520. package/workspace-snapshot/files/src/setup/harness-managed-repo-marker.ts +653 -0
  521. package/workspace-snapshot/files/src/setup/harness-provisioning-context.ts +331 -0
  522. package/workspace-snapshot/files/src/setup/harness-provisioning-pending-state.ts +282 -0
  523. package/workspace-snapshot/files/src/setup/harness-repo-provisioning.ts +1656 -0
  524. package/workspace-snapshot/files/src/setup/harness-secret-fingerprint.ts +51 -0
  525. package/workspace-snapshot/files/src/setup/harness-secret-setup.ts +439 -0
  526. package/workspace-snapshot/files/src/setup/harness-snapshot-provisioning-helpers.ts +92 -0
  527. package/workspace-snapshot/files/src/setup/harness-snapshot-provisioning.ts +1007 -0
  528. package/workspace-snapshot/files/src/setup/harness-template-identity.ts +151 -0
  529. package/workspace-snapshot/files/src/setup/harness-workspace-snapshot-loader.ts +105 -0
  530. package/workspace-snapshot/files/src/setup/linear-setup-apply.ts +270 -0
  531. package/workspace-snapshot/files/src/setup/linear-setup-client.ts +276 -0
  532. package/workspace-snapshot/files/src/setup/linear-setup-plan.ts +353 -0
  533. package/workspace-snapshot/files/src/setup/linear-setup-summary.ts +33 -0
  534. package/workspace-snapshot/files/src/setup/linear-status-contract.ts +110 -0
  535. package/workspace-snapshot/files/src/setup/linear-webhook-env-local.ts +104 -0
  536. package/workspace-snapshot/files/src/setup/linear-webhook-secret.ts +441 -0
  537. package/workspace-snapshot/files/src/setup/local-apply-actions.ts +524 -0
  538. package/workspace-snapshot/files/src/setup/local-readiness-checks.ts +334 -0
  539. package/workspace-snapshot/files/src/setup/mock-git-repository-store.ts +291 -0
  540. package/workspace-snapshot/files/src/setup/mock-target-workflow-finalization.ts +445 -0
  541. package/workspace-snapshot/files/src/setup/model-settings.ts +73 -0
  542. package/workspace-snapshot/files/src/setup/permission-model.ts +79 -0
  543. package/workspace-snapshot/files/src/setup/redact-secrets.ts +85 -0
  544. package/workspace-snapshot/files/src/setup/remote-actions.ts +214 -0
  545. package/workspace-snapshot/files/src/setup/remote-apply-actions.ts +390 -0
  546. package/workspace-snapshot/files/src/setup/remote-preview-fingerprint.ts +37 -0
  547. package/workspace-snapshot/files/src/setup/remote-setup-summary.ts +143 -0
  548. package/workspace-snapshot/files/src/setup/secret-change-token.ts +14 -0
  549. package/workspace-snapshot/files/src/setup/service-verification.ts +549 -0
  550. package/workspace-snapshot/files/src/setup/setup-actions.ts +183 -0
  551. package/workspace-snapshot/files/src/setup/setup-github-auth.ts +15 -0
  552. package/workspace-snapshot/files/src/setup/setup-state.ts +74 -0
  553. package/workspace-snapshot/files/src/setup/stale-smoke-repo.ts +141 -0
  554. package/workspace-snapshot/files/src/setup/sync-downstream-summaries.ts +105 -0
  555. package/workspace-snapshot/files/src/setup/target-workflow-finalization-lock.ts +95 -0
  556. package/workspace-snapshot/files/src/setup/target-workflow-finalization-types.ts +55 -0
  557. package/workspace-snapshot/files/src/setup/target-workflow-finalization.ts +897 -0
  558. package/workspace-snapshot/files/src/setup/target-workflow-setup.ts +247 -0
  559. package/workspace-snapshot/files/src/setup/test-only-provisioning-provider.ts +51 -0
  560. package/workspace-snapshot/files/src/setup/test-only-remote-setup-provider.ts +51 -0
  561. package/workspace-snapshot/files/src/setup/tweetsodium.d.ts +14 -0
  562. package/workspace-snapshot/files/src/setup/vercel-bridge-diagnostics.ts +510 -0
  563. package/workspace-snapshot/files/src/setup/vercel-bridge-options.ts +160 -0
  564. package/workspace-snapshot/files/src/setup/vercel-bridge-readiness.ts +150 -0
  565. package/workspace-snapshot/files/src/setup/vercel-bridge-redeploy-poll.ts +744 -0
  566. package/workspace-snapshot/files/src/setup/vercel-bridge-redeploy-state.ts +46 -0
  567. package/workspace-snapshot/files/src/setup/vercel-bridge-structured-log.ts +86 -0
  568. package/workspace-snapshot/files/src/setup/vercel-bridge-verification.ts +63 -0
  569. package/workspace-snapshot/files/src/setup/vercel-production-redeploy.ts +298 -0
  570. package/workspace-snapshot/files/src/setup/vercel-setup-apply.ts +1058 -0
  571. package/workspace-snapshot/files/src/setup/vercel-setup-client.ts +695 -0
  572. package/workspace-snapshot/files/src/setup/vercel-setup-plan.ts +672 -0
  573. package/workspace-snapshot/files/src/setup/vercel-setup-summary.ts +42 -0
  574. package/workspace-snapshot/files/src/setup/vercel-webhook-probe.ts +161 -0
  575. package/workspace-snapshot/files/src/setup/workflow-install-merge-errors.ts +166 -0
  576. package/workspace-snapshot/files/src/types/parsed-issue.ts +8 -0
  577. package/workspace-snapshot/files/src/types/run.ts +157 -0
  578. package/workspace-snapshot/files/src/validate/constants.ts +2 -0
  579. package/workspace-snapshot/files/src/validate/issue.ts +286 -0
  580. package/workspace-snapshot/files/src/validate/report.ts +68 -0
  581. package/workspace-snapshot/files/src/validate/types.ts +29 -0
  582. package/workspace-snapshot/files/src/webhook/dispatch-github.ts +44 -0
  583. package/workspace-snapshot/files/src/webhook/dispatch-statuses.ts +26 -0
  584. package/workspace-snapshot/files/src/webhook/extract-issue-key.ts +49 -0
  585. package/workspace-snapshot/files/src/webhook/filter.ts +41 -0
  586. package/workspace-snapshot/files/src/webhook/handle-linear-webhook.ts +201 -0
  587. package/workspace-snapshot/files/src/webhook/parse-linear-issue-event.ts +105 -0
  588. package/workspace-snapshot/files/src/webhook/redact-log.ts +26 -0
  589. package/workspace-snapshot/files/src/webhook/types.ts +75 -0
  590. package/workspace-snapshot/files/src/webhook/verify.ts +68 -0
  591. package/workspace-snapshot/files/src/webhook/workflow-command.ts +10 -0
  592. package/workspace-snapshot/files/src/workflow/dispatch-metadata.ts +59 -0
  593. package/workspace-snapshot/files/src/workflow/manifest-summary.ts +57 -0
  594. package/workspace-snapshot/files/src/workflow/production-sync-dispatch.ts +65 -0
  595. package/workspace-snapshot/files/src/workflow/summarize-manifest.ts +20 -0
  596. package/workspace-snapshot/files/src/workflow/validate.ts +43 -0
  597. package/workspace-snapshot/files/src/workflow/write-dispatch-metadata.ts +8 -0
  598. package/workspace-snapshot/files/templates/eval-scorecard.md +54 -0
  599. package/workspace-snapshot/files/templates/implementation-plan.md +59 -0
  600. package/workspace-snapshot/files/templates/linear-issue.md +53 -0
  601. package/workspace-snapshot/files/templates/pr-readiness-report.md +57 -0
  602. package/workspace-snapshot/files/tests/agents/cursor-provider.test.ts +238 -0
  603. package/workspace-snapshot/files/tests/artifacts/manifest.test.ts +54 -0
  604. package/workspace-snapshot/files/tests/artifacts/redact.test.ts +47 -0
  605. package/workspace-snapshot/files/tests/cli/doctor.test.ts +120 -0
  606. package/workspace-snapshot/files/tests/cli/finalize-exit.test.ts +28 -0
  607. package/workspace-snapshot/files/tests/cli/operator-init.test.ts +146 -0
  608. package/workspace-snapshot/files/tests/cli/sync-production-dispatch.test.ts +103 -0
  609. package/workspace-snapshot/files/tests/cli/validate-issue.test.ts +99 -0
  610. package/workspace-snapshot/files/tests/config/load-dotenv.test.ts +64 -0
  611. package/workspace-snapshot/files/tests/config/resolve-config.test.ts +273 -0
  612. package/workspace-snapshot/files/tests/config/schema.test.ts +107 -0
  613. package/workspace-snapshot/files/tests/cursor/agent-factory.test.ts +217 -0
  614. package/workspace-snapshot/files/tests/cursor/git-result.test.ts +77 -0
  615. package/workspace-snapshot/files/tests/cursor/model.test.ts +108 -0
  616. package/workspace-snapshot/files/tests/cursor/revision-git-result.test.ts +68 -0
  617. package/workspace-snapshot/files/tests/cursor/run-cleanup.test.ts +52 -0
  618. package/workspace-snapshot/files/tests/cursor/run-observer.test.ts +280 -0
  619. package/workspace-snapshot/files/tests/cursor/urls.test.ts +27 -0
  620. package/workspace-snapshot/files/tests/fixtures/config/minimal.json +16 -0
  621. package/workspace-snapshot/files/tests/fixtures/github/pr-4-vercel-comment.json +10 -0
  622. package/workspace-snapshot/files/tests/fixtures/issues/broad-for-direct-impl.md +28 -0
  623. package/workspace-snapshot/files/tests/fixtures/issues/context-target-repo.md +21 -0
  624. package/workspace-snapshot/files/tests/fixtures/issues/explicit-target-repo.md +21 -0
  625. package/workspace-snapshot/files/tests/fixtures/issues/gpt-broad-example.md +35 -0
  626. package/workspace-snapshot/files/tests/fixtures/issues/gpt-narrow-example.md +30 -0
  627. package/workspace-snapshot/files/tests/fixtures/issues/invalid-missing-task.md +16 -0
  628. package/workspace-snapshot/files/tests/fixtures/issues/invalid-no-ac-bullets.md +20 -0
  629. package/workspace-snapshot/files/tests/fixtures/issues/missing-acceptance-criteria.md +17 -0
  630. package/workspace-snapshot/files/tests/fixtures/issues/unknown-repo.md +20 -0
  631. package/workspace-snapshot/files/tests/fixtures/issues/valid-minimal.md +20 -0
  632. package/workspace-snapshot/files/tests/fixtures/issues/valid-project-only.md +17 -0
  633. package/workspace-snapshot/files/tests/fixtures/issues/valid-target-app.md +31 -0
  634. package/workspace-snapshot/files/tests/fixtures/linear/implementation-comment-wes-13.md +16 -0
  635. package/workspace-snapshot/files/tests/fixtures/linear/pm-feedback-wes-13.md +3 -0
  636. package/workspace-snapshot/files/tests/fixtures/webhook/issue-building-to-pr-open.json +27 -0
  637. package/workspace-snapshot/files/tests/fixtures/webhook/issue-pm-review.json +27 -0
  638. package/workspace-snapshot/files/tests/fixtures/webhook/issue-ready-for-planning.json +27 -0
  639. package/workspace-snapshot/files/tests/fixtures/webhook/issue-title-only-update.json +25 -0
  640. package/workspace-snapshot/files/tests/fixtures/workflows/harness-auto-runner-with-production-sync.yml +561 -0
  641. package/workspace-snapshot/files/tests/fixtures/workflows/trigger-harness-production-sync.yml +31 -0
  642. package/workspace-snapshot/files/tests/github/actions-url.test.ts +45 -0
  643. package/workspace-snapshot/files/tests/github/base-branch.test.ts +156 -0
  644. package/workspace-snapshot/files/tests/github/check-policy.test.ts +59 -0
  645. package/workspace-snapshot/files/tests/github/client.test.ts +226 -0
  646. package/workspace-snapshot/files/tests/github/commit-reachability.test.ts +148 -0
  647. package/workspace-snapshot/files/tests/github/merge-result.test.ts +26 -0
  648. package/workspace-snapshot/files/tests/github/pr-discovery.test.ts +55 -0
  649. package/workspace-snapshot/files/tests/github/pr-inspector.test.ts +393 -0
  650. package/workspace-snapshot/files/tests/github/pr-url.test.ts +30 -0
  651. package/workspace-snapshot/files/tests/github/rate-limit-metadata.test.ts +92 -0
  652. package/workspace-snapshot/files/tests/gui/configure-fix-loop.test.ts +460 -0
  653. package/workspace-snapshot/files/tests/gui/configure-health.test.ts +67 -0
  654. package/workspace-snapshot/files/tests/gui/design-system.test.ts +86 -0
  655. package/workspace-snapshot/files/tests/gui/dev-server-process.test.ts +22 -0
  656. package/workspace-snapshot/files/tests/gui/guided-setup.test.ts +186 -0
  657. package/workspace-snapshot/files/tests/gui/m6-configure-boundaries.test.ts +884 -0
  658. package/workspace-snapshot/files/tests/gui/packaged-harness-cloud-secrets-routes.test.ts +287 -0
  659. package/workspace-snapshot/files/tests/gui/packaged-harness-provisioning-routes.test.ts +212 -0
  660. package/workspace-snapshot/files/tests/gui/packaged-harness-target-workflow-routes.test.ts +227 -0
  661. package/workspace-snapshot/files/tests/gui/port.test.ts +74 -0
  662. package/workspace-snapshot/files/tests/gui/repo-root.test.ts +60 -0
  663. package/workspace-snapshot/files/tests/gui/setup-api.test.ts +181 -0
  664. package/workspace-snapshot/files/tests/gui/setup-json-response.test.ts +34 -0
  665. package/workspace-snapshot/files/tests/gui/step6-remote-state.test.ts +75 -0
  666. package/workspace-snapshot/files/tests/gui/sync-downstream-summaries.test.ts +198 -0
  667. package/workspace-snapshot/files/tests/gui/vercel-bridge-polling-ui.test.ts +25 -0
  668. package/workspace-snapshot/files/tests/gui/verification-state.test.ts +172 -0
  669. package/workspace-snapshot/files/tests/linear/comment-assertions.ts +24 -0
  670. package/workspace-snapshot/files/tests/linear/comment-card.test.ts +73 -0
  671. package/workspace-snapshot/files/tests/linear/comments.test.ts +185 -0
  672. package/workspace-snapshot/files/tests/linear/handoff-comment.test.ts +34 -0
  673. package/workspace-snapshot/files/tests/linear/markers.test.ts +97 -0
  674. package/workspace-snapshot/files/tests/linear/merge-comment.test.ts +61 -0
  675. package/workspace-snapshot/files/tests/linear/merge-source-comment.test.ts +49 -0
  676. package/workspace-snapshot/files/tests/linear/parser.test.ts +83 -0
  677. package/workspace-snapshot/files/tests/linear/planning-comment.test.ts +29 -0
  678. package/workspace-snapshot/files/tests/linear/pm-feedback-comment.test.ts +63 -0
  679. package/workspace-snapshot/files/tests/p-dev/browser.test.ts +38 -0
  680. package/workspace-snapshot/files/tests/p-dev/cli.test.ts +39 -0
  681. package/workspace-snapshot/files/tests/p-dev/git-object-plumbing.test.ts +139 -0
  682. package/workspace-snapshot/files/tests/p-dev/launch.test.ts +110 -0
  683. package/workspace-snapshot/files/tests/p-dev/next-bin.test.ts +16 -0
  684. package/workspace-snapshot/files/tests/p-dev/node-version.test.ts +20 -0
  685. package/workspace-snapshot/files/tests/p-dev/package-manifest.test.ts +47 -0
  686. package/workspace-snapshot/files/tests/p-dev/package-packed-artifact.test.ts +130 -0
  687. package/workspace-snapshot/files/tests/p-dev/package-paths.test.ts +43 -0
  688. package/workspace-snapshot/files/tests/p-dev/package-version.test.ts +55 -0
  689. package/workspace-snapshot/files/tests/p-dev/packaged-workspace-setup.test.ts +87 -0
  690. package/workspace-snapshot/files/tests/p-dev/runtime-mode.test.ts +18 -0
  691. package/workspace-snapshot/files/tests/p-dev/workspace-snapshot-digest.test.ts +61 -0
  692. package/workspace-snapshot/files/tests/p-dev/workspace-snapshot-generator.test.ts +76 -0
  693. package/workspace-snapshot/files/tests/p-dev/workspace-snapshot-policy.test.ts +35 -0
  694. package/workspace-snapshot/files/tests/p-dev/workspace-snapshot-validation.test.ts +158 -0
  695. package/workspace-snapshot/files/tests/p-dev/workspace.test.ts +80 -0
  696. package/workspace-snapshot/files/tests/preview/production-from-merge.test.ts +39 -0
  697. package/workspace-snapshot/files/tests/preview/vercel-from-pr.test.ts +120 -0
  698. package/workspace-snapshot/files/tests/prompts/builder.test.ts +58 -0
  699. package/workspace-snapshot/files/tests/prompts/implementation-builder.test.ts +76 -0
  700. package/workspace-snapshot/files/tests/prompts/issue-intake-chatgpt.test.ts +105 -0
  701. package/workspace-snapshot/files/tests/resolver/allowed-repos.test.ts +44 -0
  702. package/workspace-snapshot/files/tests/resolver/normalize-repo.test.ts +44 -0
  703. package/workspace-snapshot/files/tests/resolver/target-repo.test.ts +91 -0
  704. package/workspace-snapshot/files/tests/runner/building-recovery.test.ts +30 -0
  705. package/workspace-snapshot/files/tests/runner/dry-run.test.ts +128 -0
  706. package/workspace-snapshot/files/tests/runner/execution-environment.test.ts +114 -0
  707. package/workspace-snapshot/files/tests/runner/handoff.test.ts +312 -0
  708. package/workspace-snapshot/files/tests/runner/idempotency-handoff.test.ts +170 -0
  709. package/workspace-snapshot/files/tests/runner/idempotency-implementation.test.ts +143 -0
  710. package/workspace-snapshot/files/tests/runner/idempotency-merge.test.ts +118 -0
  711. package/workspace-snapshot/files/tests/runner/idempotency-revision.test.ts +111 -0
  712. package/workspace-snapshot/files/tests/runner/idempotency.test.ts +83 -0
  713. package/workspace-snapshot/files/tests/runner/implementation.test.ts +196 -0
  714. package/workspace-snapshot/files/tests/runner/integration-repair.test.ts +263 -0
  715. package/workspace-snapshot/files/tests/runner/merge.test.ts +760 -0
  716. package/workspace-snapshot/files/tests/runner/orchestrator.test.ts +301 -0
  717. package/workspace-snapshot/files/tests/runner/phase-args.test.ts +38 -0
  718. package/workspace-snapshot/files/tests/runner/planning.test.ts +160 -0
  719. package/workspace-snapshot/files/tests/runner/resolve-route.test.ts +249 -0
  720. package/workspace-snapshot/files/tests/runner/revision.test.ts +326 -0
  721. package/workspace-snapshot/files/tests/setup/config-builder.test.ts +136 -0
  722. package/workspace-snapshot/files/tests/setup/config-local-editor.test.ts +164 -0
  723. package/workspace-snapshot/files/tests/setup/connect-services-credential-availability.test.ts +151 -0
  724. package/workspace-snapshot/files/tests/setup/connect-services-env.test.ts +84 -0
  725. package/workspace-snapshot/files/tests/setup/control-plane-readiness.test.ts +59 -0
  726. package/workspace-snapshot/files/tests/setup/doctor-summary.test.ts +48 -0
  727. package/workspace-snapshot/files/tests/setup/env-merge.test.ts +177 -0
  728. package/workspace-snapshot/files/tests/setup/env-writer.test.ts +97 -0
  729. package/workspace-snapshot/files/tests/setup/first-run-readiness.test.ts +1099 -0
  730. package/workspace-snapshot/files/tests/setup/generated-instructions.test.ts +48 -0
  731. package/workspace-snapshot/files/tests/setup/github-dispatch-token.test.ts +111 -0
  732. package/workspace-snapshot/files/tests/setup/github-remote-provider.test.ts +66 -0
  733. package/workspace-snapshot/files/tests/setup/github-remote-setup-live.test.ts +59 -0
  734. package/workspace-snapshot/files/tests/setup/github-workflow-permissions.test.ts +71 -0
  735. package/workspace-snapshot/files/tests/setup/gui-remote-storage.test.ts +43 -0
  736. package/workspace-snapshot/files/tests/setup/gui-view-model.test.ts +251 -0
  737. package/workspace-snapshot/files/tests/setup/guided-config-form.test.ts +54 -0
  738. package/workspace-snapshot/files/tests/setup/harness-dispatch-repo.test.ts +105 -0
  739. package/workspace-snapshot/files/tests/setup/harness-managed-repo-marker.test.ts +141 -0
  740. package/workspace-snapshot/files/tests/setup/harness-provisioning-context.test.ts +89 -0
  741. package/workspace-snapshot/files/tests/setup/harness-provisioning-pending-state.test.ts +88 -0
  742. package/workspace-snapshot/files/tests/setup/harness-repo-provisioning.test.ts +897 -0
  743. package/workspace-snapshot/files/tests/setup/harness-secret-setup.test.ts +255 -0
  744. package/workspace-snapshot/files/tests/setup/harness-snapshot-default-branch.test.ts +73 -0
  745. package/workspace-snapshot/files/tests/setup/harness-snapshot-description-finalization.test.ts +136 -0
  746. package/workspace-snapshot/files/tests/setup/harness-snapshot-marker-tree.test.ts +61 -0
  747. package/workspace-snapshot/files/tests/setup/harness-snapshot-reconciliation.test.ts +132 -0
  748. package/workspace-snapshot/files/tests/setup/harness-snapshot-structured-errors.test.ts +137 -0
  749. package/workspace-snapshot/files/tests/setup/harness-snapshot-upload-rate-limit.test.ts +105 -0
  750. package/workspace-snapshot/files/tests/setup/linear-setup-apply.test.ts +131 -0
  751. package/workspace-snapshot/files/tests/setup/linear-setup-plan.test.ts +106 -0
  752. package/workspace-snapshot/files/tests/setup/linear-webhook-env-local.test.ts +95 -0
  753. package/workspace-snapshot/files/tests/setup/linear-webhook-secret.test.ts +256 -0
  754. package/workspace-snapshot/files/tests/setup/live-provisioning-error-preservation.test.ts +98 -0
  755. package/workspace-snapshot/files/tests/setup/local-apply-actions.test.ts +352 -0
  756. package/workspace-snapshot/files/tests/setup/local-readiness-checks.test.ts +175 -0
  757. package/workspace-snapshot/files/tests/setup/model-settings.test.ts +52 -0
  758. package/workspace-snapshot/files/tests/setup/packaged-provisioning-permissions.test.ts +41 -0
  759. package/workspace-snapshot/files/tests/setup/permission-model.test.ts +38 -0
  760. package/workspace-snapshot/files/tests/setup/redact-secrets.test.ts +78 -0
  761. package/workspace-snapshot/files/tests/setup/remote-actions.test.ts +45 -0
  762. package/workspace-snapshot/files/tests/setup/remote-apply-actions.test.ts +302 -0
  763. package/workspace-snapshot/files/tests/setup/remote-preview-fingerprint.test.ts +121 -0
  764. package/workspace-snapshot/files/tests/setup/service-verification.test.ts +312 -0
  765. package/workspace-snapshot/files/tests/setup/setup-actions.test.ts +96 -0
  766. package/workspace-snapshot/files/tests/setup/setup-form-defaults.test.ts +35 -0
  767. package/workspace-snapshot/files/tests/setup/setup-server-remote.test.ts +90 -0
  768. package/workspace-snapshot/files/tests/setup/stale-smoke-repo.test.ts +84 -0
  769. package/workspace-snapshot/files/tests/setup/step6-automatic-apply-outcome.test.ts +303 -0
  770. package/workspace-snapshot/files/tests/setup/target-workflow-finalization-lock.test.ts +51 -0
  771. package/workspace-snapshot/files/tests/setup/target-workflow-finalization-step-github.test.ts +435 -0
  772. package/workspace-snapshot/files/tests/setup/target-workflow-finalization.test.ts +222 -0
  773. package/workspace-snapshot/files/tests/setup/target-workflow-setup.test.ts +62 -0
  774. package/workspace-snapshot/files/tests/setup/test-workspace-snapshot-fixture.ts +100 -0
  775. package/workspace-snapshot/files/tests/setup/vercel-bridge-diagnostics.test.ts +429 -0
  776. package/workspace-snapshot/files/tests/setup/vercel-bridge-options.test.ts +135 -0
  777. package/workspace-snapshot/files/tests/setup/vercel-bridge-preview-fingerprint.test.ts +52 -0
  778. package/workspace-snapshot/files/tests/setup/vercel-bridge-redeploy-poll.test.ts +582 -0
  779. package/workspace-snapshot/files/tests/setup/vercel-bridge-structured-log.test.ts +45 -0
  780. package/workspace-snapshot/files/tests/setup/vercel-bridge-verification.test.ts +39 -0
  781. package/workspace-snapshot/files/tests/setup/vercel-endpoint-reachability.test.ts +60 -0
  782. package/workspace-snapshot/files/tests/setup/vercel-production-redeploy.test.ts +184 -0
  783. package/workspace-snapshot/files/tests/setup/vercel-setup-apply.test.ts +1282 -0
  784. package/workspace-snapshot/files/tests/setup/vercel-setup-client.test.ts +395 -0
  785. package/workspace-snapshot/files/tests/setup/vercel-setup-plan.test.ts +261 -0
  786. package/workspace-snapshot/files/tests/setup/vercel-webhook-probe.test.ts +78 -0
  787. package/workspace-snapshot/files/tests/setup/workflow-install-merge-errors.test.ts +38 -0
  788. package/workspace-snapshot/files/tests/validate-issue/report.test.ts +56 -0
  789. package/workspace-snapshot/files/tests/validate-issue/validate-issue.test.ts +202 -0
  790. package/workspace-snapshot/files/tests/webhook/dispatch-github.test.ts +193 -0
  791. package/workspace-snapshot/files/tests/webhook/extract-issue-key.test.ts +65 -0
  792. package/workspace-snapshot/files/tests/webhook/filter.test.ts +132 -0
  793. package/workspace-snapshot/files/tests/webhook/harness-auto-runner-workflow.test.ts +169 -0
  794. package/workspace-snapshot/files/tests/webhook/parse-linear-issue-event.test.ts +89 -0
  795. package/workspace-snapshot/files/tests/webhook/verify.test.ts +125 -0
  796. package/workspace-snapshot/files/tests/workflow/dispatch-metadata.test.ts +38 -0
  797. package/workspace-snapshot/files/tests/workflow/manifest-summary.test.ts +58 -0
  798. package/workspace-snapshot/files/tests/workflow/production-sync-dispatch.test.ts +101 -0
  799. package/workspace-snapshot/files/tests/workflow/validate.test.ts +70 -0
  800. package/workspace-snapshot/files/tests/workflow/workflow-shell-safety.test.ts +92 -0
  801. package/workspace-snapshot/files/tsconfig.json +22 -0
  802. package/workspace-snapshot/files/vercel.json +10 -0
  803. package/workspace-snapshot/files/vitest.config.ts +15 -0
  804. package/workspace-snapshot/manifest.json +4911 -0
  805. package/gui/.next/server/chunks/120.js +0 -81
  806. package/gui/.next/static/css/cc2acc71c03f3b4b.css +0 -3
  807. /package/gui/.next/static/{7x8X_k4tESvkyqRnNCC9E → ZGJuemeaiW4yT7CTlmjdG}/_buildManifest.js +0 -0
  808. /package/gui/.next/static/{7x8X_k4tESvkyqRnNCC9E → ZGJuemeaiW4yT7CTlmjdG}/_ssgManifest.js +0 -0
@@ -0,0 +1,1656 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { resolveHarnessPackageVersion } from "../p-dev/package-version.js";
3
+ import { isPackagedPDevRuntime } from "../p-dev/runtime-mode.js";
4
+ import { GitHubApiError } from "../github/client.js";
5
+ import { readExistingEnvFile } from "./env-merge.js";
6
+ import {
7
+ buildHarnessProvisioningPreviewContext,
8
+ normalizeRepoSlug,
9
+ serializeHarnessProvisioningPreviewContext,
10
+ validateSubmittedHarnessProvisioningFingerprint,
11
+ type HarnessProvisioningClassification,
12
+ } from "./harness-provisioning-context.js";
13
+ import {
14
+ buildHarnessManagedRepoMarker,
15
+ HARNESS_MANAGED_REPO_MARKER_FILE,
16
+ markersAreEquivalentForOperation,
17
+ markerValidForExistingWorkspace,
18
+ parseHarnessManagedRepoMarkerJson,
19
+ validateManagedMarkerForReconnect,
20
+ } from "./harness-managed-repo-marker.js";
21
+ import {
22
+ buildPendingValidationContext,
23
+ clearHarnessProvisioningPendingState,
24
+ readHarnessProvisioningPendingState,
25
+ validatePendingProvisioningState,
26
+ withHarnessProvisioningMutex,
27
+ writeHarnessProvisioningPendingStateAtomic,
28
+ type HarnessProvisioningPendingState,
29
+ type HarnessProvisioningPhase,
30
+ } from "./harness-provisioning-pending-state.js";
31
+ import { parseRepoSlug } from "./github-remote-setup-live.js";
32
+ import type { GitHubHarnessProvisioningProvider } from "./github-remote-provider.js";
33
+ import {
34
+ assessPackagedProvisioningTokenCapabilities,
35
+ type GitHubTokenMetadata,
36
+ } from "./github-workflow-permissions.js";
37
+ import {
38
+ HARNESS_DEFAULT_DESTINATION_DESCRIPTION,
39
+ HARNESS_DEFAULT_DESTINATION_REPO_NAME,
40
+ HARNESS_LEGACY_PUBLIC_SOURCE_REPO,
41
+ HARNESS_TEMPLATE_IDENTITY_FILE,
42
+ parseHarnessTemplateIdentityJson,
43
+ } from "./harness-template-identity.js";
44
+ import {
45
+ SnapshotProvisioningError,
46
+ } from "./harness-snapshot-provisioning-helpers.js";
47
+ import {
48
+ provisionHarnessWorkspaceFromSnapshot,
49
+ verifyProvisionedHarnessWorkspace,
50
+ } from "./harness-snapshot-provisioning.js";
51
+ import { loadEmbeddedWorkspaceSnapshot } from "./harness-workspace-snapshot-loader.js";
52
+ import { persistGithubDispatchRepository } from "./local-apply-actions.js";
53
+ import { resolveLocalFilePaths } from "./setup-state.js";
54
+
55
+ export type HarnessProvisioningState =
56
+ | "skipped-not-packaged"
57
+ | "skipped-source-mode"
58
+ | "token-unavailable"
59
+ | "token-invalid"
60
+ | "token-unsupported"
61
+ | "token-scope-ambiguous"
62
+ | "token-insufficient"
63
+ | "explicit-repo-present"
64
+ | "explicit-packaged-repo-invalid"
65
+ | "explicit-packaged-repo-legacy-source"
66
+ | "snapshot-unavailable"
67
+ | "snapshot-manifest-missing"
68
+ | "snapshot-manifest-invalid"
69
+ | "snapshot-incompatible"
70
+ | "snapshot-tampered"
71
+ | "snapshot-preview-ready"
72
+ | "snapshot-preview-stale"
73
+ | "repo-absent"
74
+ | "valid-existing-managed-repo"
75
+ | "same-name-public-collision"
76
+ | "same-name-unmanaged-collision"
77
+ | "same-name-malformed-marker"
78
+ | "same-name-snapshot-only-without-pending"
79
+ | "same-name-snapshot-only-with-pending"
80
+ | "repo-created-pending-verification"
81
+ | "marker-write-pending"
82
+ | "verified-and-persisted"
83
+ | "created-but-persistence-failed"
84
+ | "api-timeout-unknown"
85
+ | "concurrent-request-recovered";
86
+
87
+ export interface HarnessRepoProvisioningSummary {
88
+ runtimeMode: "packaged" | "source" | "unknown";
89
+ eligible: boolean;
90
+ state: HarnessProvisioningState;
91
+ harnessDispatchRepo: string | null;
92
+ authenticatedLogin: string | null;
93
+ message: string;
94
+ recoverable: boolean;
95
+ connectedAutomatically: boolean;
96
+ verifiedSavedRepo: boolean;
97
+ }
98
+
99
+ export interface HarnessRepoProvisioningPreview {
100
+ state: HarnessProvisioningState;
101
+ fingerprint: string;
102
+ operationId: string;
103
+ creationPreviewFingerprint: string | null;
104
+ resumedFromPending: boolean;
105
+ harnessDispatchRepo: string | null;
106
+ authenticatedLogin: string | null;
107
+ packageName: string;
108
+ packageVersion: string;
109
+ sourceRepository: string;
110
+ sourceCommit: string;
111
+ snapshotContentId: string | null;
112
+ snapshotFingerprint: string | null;
113
+ /** @deprecated Use snapshotContentId. */
114
+ templateContentId: string | null;
115
+ message: string;
116
+ recoverable: boolean;
117
+ willCreateRepository: boolean;
118
+ tokenCapabilities: {
119
+ tokenType: GitHubTokenMetadata["tokenType"];
120
+ hasRepoScope: boolean;
121
+ hasWorkflowScope: boolean;
122
+ scopeAmbiguous: boolean;
123
+ };
124
+ }
125
+
126
+ export interface HarnessRepoProvisioningApplyResult {
127
+ state: HarnessProvisioningState;
128
+ harnessDispatchRepo: string | null;
129
+ message: string;
130
+ recoverable: boolean;
131
+ persisted: boolean;
132
+ }
133
+
134
+ function buildFingerprint(input: Record<string, unknown>): string {
135
+ return JSON.stringify(input);
136
+ }
137
+
138
+ function destinationSlug(login: string): string {
139
+ return `${login}/${HARNESS_DEFAULT_DESTINATION_REPO_NAME}`;
140
+ }
141
+
142
+ type SnapshotPreviewOk = Extract<
143
+ Awaited<ReturnType<typeof loadEmbeddedWorkspaceSnapshot>>,
144
+ { ok: true }
145
+ >;
146
+
147
+ function emptySnapshotPreviewFields(): Pick<
148
+ HarnessRepoProvisioningPreview,
149
+ | "packageName"
150
+ | "packageVersion"
151
+ | "sourceRepository"
152
+ | "sourceCommit"
153
+ | "snapshotContentId"
154
+ | "snapshotFingerprint"
155
+ | "templateContentId"
156
+ > {
157
+ return {
158
+ packageName: "p-dev-harness",
159
+ packageVersion: "",
160
+ sourceRepository: "",
161
+ sourceCommit: "",
162
+ snapshotContentId: null,
163
+ snapshotFingerprint: null,
164
+ templateContentId: null,
165
+ };
166
+ }
167
+
168
+ function snapshotPreviewFields(
169
+ snapshot: SnapshotPreviewOk | null,
170
+ templateContentIdOverride?: string | null,
171
+ ): Pick<
172
+ HarnessRepoProvisioningPreview,
173
+ | "packageName"
174
+ | "packageVersion"
175
+ | "sourceRepository"
176
+ | "sourceCommit"
177
+ | "snapshotContentId"
178
+ | "snapshotFingerprint"
179
+ | "templateContentId"
180
+ > {
181
+ if (!snapshot) {
182
+ return emptySnapshotPreviewFields();
183
+ }
184
+ const snapshotContentId = snapshot.manifest.snapshotContentId;
185
+ return {
186
+ packageName: snapshot.manifest.packageName,
187
+ packageVersion: snapshot.manifest.packageVersion,
188
+ sourceRepository: snapshot.manifest.sourceRepository,
189
+ sourceCommit: snapshot.manifest.sourceCommit,
190
+ snapshotContentId,
191
+ snapshotFingerprint: snapshot.fingerprint,
192
+ templateContentId: templateContentIdOverride ?? snapshotContentId,
193
+ };
194
+ }
195
+
196
+ function readSavedRepositoryId(
197
+ existingEnv: Awaited<ReturnType<typeof readExistingEnvFile>>,
198
+ ): number | null {
199
+ const raw = existingEnv?.values.GITHUB_DISPATCH_REPOSITORY_ID?.trim();
200
+ if (!raw) {
201
+ return null;
202
+ }
203
+ const parsed = Number(raw);
204
+ if (!Number.isInteger(parsed) || parsed <= 0) {
205
+ return null;
206
+ }
207
+ return parsed;
208
+ }
209
+
210
+ function buildSnapshotPendingValidationContext(
211
+ snapshot: SnapshotPreviewOk,
212
+ input: {
213
+ operationId?: string;
214
+ authenticatedUserId: number;
215
+ authenticatedLogin: string;
216
+ targetOwner: string;
217
+ targetRepo: string;
218
+ previewFingerprint?: string;
219
+ },
220
+ ) {
221
+ return buildPendingValidationContext({
222
+ operationId: input.operationId,
223
+ authenticatedUserId: input.authenticatedUserId,
224
+ authenticatedLogin: input.authenticatedLogin,
225
+ targetOwner: input.targetOwner,
226
+ targetRepo: input.targetRepo,
227
+ packageName: snapshot.manifest.packageName,
228
+ packageVersion: snapshot.manifest.packageVersion,
229
+ sourceRepository: snapshot.manifest.sourceRepository,
230
+ sourceCommit: snapshot.manifest.sourceCommit,
231
+ manifestSchemaVersion: snapshot.manifest.schemaVersion,
232
+ snapshotContentId: snapshot.manifest.snapshotContentId,
233
+ snapshotSha256: snapshot.manifest.snapshotSha256,
234
+ snapshotGitTreeSha1: snapshot.manifest.gitRootTreeSha1,
235
+ previewFingerprint: input.previewFingerprint,
236
+ });
237
+ }
238
+
239
+ function buildProvisioningPreviewFingerprint(input: {
240
+ operationId: string;
241
+ user: { id: number; login: string };
242
+ destination: string;
243
+ snapshotPreview: SnapshotPreviewOk;
244
+ classification: HarnessProvisioningClassification;
245
+ envBaseline: string;
246
+ pDevVersion: string;
247
+ resumedFromPending: boolean;
248
+ creationPreviewFingerprint: string | null;
249
+ }): string {
250
+ const context = buildHarnessProvisioningPreviewContext({
251
+ operationId: input.operationId,
252
+ user: input.user,
253
+ destination: input.destination,
254
+ manifest: input.snapshotPreview.manifest,
255
+ snapshotFingerprint: input.snapshotPreview.fingerprint,
256
+ classification: input.classification,
257
+ envBaseline: input.envBaseline,
258
+ pDevVersion: input.pDevVersion,
259
+ resumedFromPending: input.resumedFromPending,
260
+ creationPreviewFingerprint: input.creationPreviewFingerprint,
261
+ });
262
+ return serializeHarnessProvisioningPreviewContext(context);
263
+ }
264
+
265
+ async function resolveProvisioningOperation(input: {
266
+ cwd?: string;
267
+ requestedOperationId?: string;
268
+ user: { id: number; login: string };
269
+ snapshotPreview: SnapshotPreviewOk;
270
+ }): Promise<
271
+ | {
272
+ ok: true;
273
+ operationId: string;
274
+ resumedFromPending: boolean;
275
+ creationPreviewFingerprint: string | null;
276
+ pending: HarnessProvisioningPendingState | null;
277
+ }
278
+ | { ok: false; state: HarnessProvisioningState; message: string }
279
+ > {
280
+ const validationContext = buildSnapshotPendingValidationContext(
281
+ input.snapshotPreview,
282
+ {
283
+ authenticatedUserId: input.user.id,
284
+ authenticatedLogin: input.user.login,
285
+ targetOwner: input.user.login,
286
+ targetRepo: HARNESS_DEFAULT_DESTINATION_REPO_NAME,
287
+ },
288
+ );
289
+
290
+ if (input.requestedOperationId) {
291
+ const pending = await readHarnessProvisioningPendingState(input.cwd);
292
+ if (pending && pending.operationId !== input.requestedOperationId) {
293
+ return {
294
+ ok: false,
295
+ state: "concurrent-request-recovered",
296
+ message:
297
+ "Another provisioning operation is already in progress for this workspace.",
298
+ };
299
+ }
300
+ return {
301
+ ok: true,
302
+ operationId: input.requestedOperationId,
303
+ resumedFromPending: Boolean(pending),
304
+ creationPreviewFingerprint: pending?.previewFingerprint ?? null,
305
+ pending,
306
+ };
307
+ }
308
+
309
+ const pending = await readHarnessProvisioningPendingState(input.cwd);
310
+ if (!pending) {
311
+ return {
312
+ ok: true,
313
+ operationId: randomUUID(),
314
+ resumedFromPending: false,
315
+ creationPreviewFingerprint: null,
316
+ pending: null,
317
+ };
318
+ }
319
+
320
+ const validation = validatePendingProvisioningState(pending, validationContext);
321
+ if (!validation.ok) {
322
+ return {
323
+ ok: false,
324
+ state: "same-name-unmanaged-collision",
325
+ message: validation.reason,
326
+ };
327
+ }
328
+
329
+ return {
330
+ ok: true,
331
+ operationId: pending.operationId,
332
+ resumedFromPending: true,
333
+ creationPreviewFingerprint: pending.previewFingerprint,
334
+ pending,
335
+ };
336
+ }
337
+
338
+ async function validateExplicitPackagedRepo(
339
+ provider: GitHubHarnessProvisioningProvider,
340
+ repoSlug: string,
341
+ savedRepositoryId: number | null,
342
+ ): Promise<
343
+ | {
344
+ ok: true;
345
+ repoSlug: string;
346
+ repositoryId: number;
347
+ marker: ReturnType<typeof parseHarnessManagedRepoMarkerJson> & {
348
+ ok: true;
349
+ };
350
+ }
351
+ | { ok: false; state: HarnessProvisioningState; message: string }
352
+ > {
353
+ if (repoSlug === HARNESS_LEGACY_PUBLIC_SOURCE_REPO) {
354
+ return {
355
+ ok: false,
356
+ state: "explicit-packaged-repo-legacy-source",
357
+ message:
358
+ "Saved harness repo points at the public source repo. Use advanced recovery to adopt a private managed workspace.",
359
+ };
360
+ }
361
+
362
+ let resolvedSlug = normalizeRepoSlug(repoSlug);
363
+ let metadata = null as Awaited<
364
+ ReturnType<GitHubHarnessProvisioningProvider["getRepositoryMetadata"]>
365
+ >;
366
+
367
+ if (savedRepositoryId) {
368
+ metadata = await provider.getRepositoryMetadataById(savedRepositoryId);
369
+ if (!metadata) {
370
+ return {
371
+ ok: false,
372
+ state: "explicit-packaged-repo-invalid",
373
+ message: `Saved harness repository ID ${savedRepositoryId} is missing or inaccessible.`,
374
+ };
375
+ }
376
+ resolvedSlug = normalizeRepoSlug(`${metadata.owner}/${metadata.repo}`);
377
+ if (
378
+ normalizeRepoSlug(repoSlug) !== resolvedSlug &&
379
+ savedRepositoryId !== metadata.repositoryId
380
+ ) {
381
+ return {
382
+ ok: false,
383
+ state: "explicit-packaged-repo-invalid",
384
+ message: `Saved harness repo ${repoSlug} does not match repository ID ${savedRepositoryId}.`,
385
+ };
386
+ }
387
+ } else {
388
+ const { owner, repo } = parseRepoSlug(resolvedSlug);
389
+ metadata = await provider.getRepositoryMetadata(owner, repo);
390
+ }
391
+
392
+ if (!metadata) {
393
+ return {
394
+ ok: false,
395
+ state: "explicit-packaged-repo-invalid",
396
+ message: `Saved harness repo ${repoSlug} is missing or inaccessible.`,
397
+ };
398
+ }
399
+ if (savedRepositoryId && metadata.repositoryId !== savedRepositoryId) {
400
+ return {
401
+ ok: false,
402
+ state: "explicit-packaged-repo-invalid",
403
+ message: `Saved harness repository ID does not match GitHub metadata for ${resolvedSlug}.`,
404
+ };
405
+ }
406
+ if (!metadata.private || metadata.visibility !== "private") {
407
+ return {
408
+ ok: false,
409
+ state: "explicit-packaged-repo-invalid",
410
+ message: `Saved harness repo ${resolvedSlug} must be private in packaged mode.`,
411
+ };
412
+ }
413
+ if (!metadata.permissions.admin) {
414
+ return {
415
+ ok: false,
416
+ state: "explicit-packaged-repo-invalid",
417
+ message: `Saved harness repo ${resolvedSlug} requires admin access.`,
418
+ };
419
+ }
420
+
421
+ const markerRaw = await provider.readRepositoryFileContent(
422
+ metadata.owner,
423
+ metadata.repo,
424
+ HARNESS_MANAGED_REPO_MARKER_FILE,
425
+ metadata.defaultBranch,
426
+ );
427
+ if (!markerRaw) {
428
+ return {
429
+ ok: false,
430
+ state: "explicit-packaged-repo-invalid",
431
+ message: `Saved harness repo ${resolvedSlug} is missing a compatible managed marker.`,
432
+ };
433
+ }
434
+ const marker = parseHarnessManagedRepoMarkerJson(markerRaw);
435
+ if (!marker.ok) {
436
+ return {
437
+ ok: false,
438
+ state: "explicit-packaged-repo-invalid",
439
+ message: marker.reason,
440
+ };
441
+ }
442
+ const reconnect = validateManagedMarkerForReconnect(
443
+ marker.marker,
444
+ resolvedSlug,
445
+ { repositoryId: metadata.repositoryId },
446
+ );
447
+ if (!reconnect.ok) {
448
+ return {
449
+ ok: false,
450
+ state: "explicit-packaged-repo-invalid",
451
+ message: reconnect.reason,
452
+ };
453
+ }
454
+
455
+ return {
456
+ ok: true,
457
+ repoSlug: resolvedSlug,
458
+ repositoryId: metadata.repositoryId,
459
+ marker,
460
+ };
461
+ }
462
+
463
+ type DestinationClassification =
464
+ | { kind: "absent" }
465
+ | { kind: "valid-managed"; repoSlug: string; repositoryId: number }
466
+ | { kind: "public-collision" }
467
+ | { kind: "unmanaged-collision" }
468
+ | { kind: "malformed-marker"; reason: string }
469
+ | { kind: "snapshot-only-without-pending" }
470
+ | { kind: "snapshot-only-with-pending" };
471
+
472
+ async function classifyDestinationRepo(
473
+ provider: GitHubHarnessProvisioningProvider,
474
+ user: { id: number; login: string },
475
+ cwd?: string,
476
+ snapshotPreview?: SnapshotPreviewOk,
477
+ ): Promise<DestinationClassification> {
478
+ const repoSlug = destinationSlug(user.login);
479
+ const { owner, repo } = parseRepoSlug(repoSlug);
480
+ const metadata = await provider.getRepositoryMetadata(owner, repo);
481
+ if (!metadata) {
482
+ return { kind: "absent" };
483
+ }
484
+ if (!metadata.private || metadata.visibility !== "private") {
485
+ return { kind: "public-collision" };
486
+ }
487
+ if (!metadata.permissions.admin) {
488
+ return { kind: "unmanaged-collision" };
489
+ }
490
+
491
+ const markerRaw = await provider.readRepositoryFileContent(
492
+ owner,
493
+ repo,
494
+ HARNESS_MANAGED_REPO_MARKER_FILE,
495
+ metadata.defaultBranch,
496
+ );
497
+ if (markerRaw) {
498
+ const marker = parseHarnessManagedRepoMarkerJson(markerRaw);
499
+ if (!marker.ok) {
500
+ return { kind: "malformed-marker", reason: marker.reason };
501
+ }
502
+ const reconnect = validateManagedMarkerForReconnect(marker.marker, repoSlug, {
503
+ repositoryId: metadata.repositoryId,
504
+ });
505
+ if (!reconnect.ok) {
506
+ return { kind: "malformed-marker", reason: reconnect.reason };
507
+ }
508
+ return {
509
+ kind: "valid-managed",
510
+ repoSlug,
511
+ repositoryId: metadata.repositoryId,
512
+ };
513
+ }
514
+
515
+ const pending = await readHarnessProvisioningPendingState(cwd);
516
+ if (pending && snapshotPreview) {
517
+ const validation = validatePendingProvisioningState(
518
+ pending,
519
+ buildSnapshotPendingValidationContext(snapshotPreview, {
520
+ authenticatedUserId: user.id,
521
+ authenticatedLogin: user.login,
522
+ targetOwner: user.login,
523
+ targetRepo: HARNESS_DEFAULT_DESTINATION_REPO_NAME,
524
+ }),
525
+ );
526
+ if (validation.ok) {
527
+ return { kind: "snapshot-only-with-pending" };
528
+ }
529
+ if (!validation.ok) {
530
+ return { kind: "unmanaged-collision" };
531
+ }
532
+ }
533
+
534
+ const templateRaw = await provider.readRepositoryFileContent(
535
+ owner,
536
+ repo,
537
+ HARNESS_TEMPLATE_IDENTITY_FILE,
538
+ metadata.defaultBranch,
539
+ );
540
+ if (templateRaw) {
541
+ const parsedTemplate = parseHarnessTemplateIdentityJson(templateRaw);
542
+ if (!parsedTemplate.ok) {
543
+ return {
544
+ kind: "malformed-marker",
545
+ reason: `Generated repository template identity is invalid: ${parsedTemplate.reason}`,
546
+ };
547
+ }
548
+ return { kind: "snapshot-only-without-pending" };
549
+ }
550
+
551
+ return { kind: "unmanaged-collision" };
552
+ }
553
+
554
+ function buildSnapshotPendingState(input: {
555
+ operationId: string;
556
+ user: { id: number; login: string };
557
+ snapshotPreview: SnapshotPreviewOk;
558
+ previewFingerprint: string;
559
+ pending?: HarnessProvisioningPendingState | null;
560
+ phase?: HarnessProvisioningPhase;
561
+ repositoryId?: number;
562
+ defaultBranch?: string;
563
+ initializedCommitSha?: string;
564
+ snapshotCommitSha?: string;
565
+ markerCommitSha?: string;
566
+ }): HarnessProvisioningPendingState {
567
+ const manifest = input.snapshotPreview.manifest;
568
+ return {
569
+ operationId: input.operationId,
570
+ authenticatedUserId: input.user.id,
571
+ authenticatedLogin: input.user.login,
572
+ packageName: manifest.packageName,
573
+ packageVersion: manifest.packageVersion,
574
+ sourceRepository: manifest.sourceRepository,
575
+ sourceCommit: manifest.sourceCommit,
576
+ manifestSchemaVersion: manifest.schemaVersion,
577
+ snapshotContentId: manifest.snapshotContentId,
578
+ snapshotSha256: manifest.snapshotSha256,
579
+ snapshotGitTreeSha1: manifest.gitRootTreeSha1,
580
+ targetOwner: input.user.login,
581
+ targetRepo: HARNESS_DEFAULT_DESTINATION_REPO_NAME,
582
+ previewFingerprint: input.previewFingerprint,
583
+ startedAt: input.pending?.startedAt ?? new Date().toISOString(),
584
+ phase: input.phase ?? input.pending?.phase,
585
+ repositoryId: input.repositoryId ?? input.pending?.repositoryId,
586
+ defaultBranch: input.defaultBranch ?? input.pending?.defaultBranch,
587
+ initializedCommitSha:
588
+ input.initializedCommitSha ?? input.pending?.initializedCommitSha,
589
+ snapshotCommitSha: input.snapshotCommitSha ?? input.pending?.snapshotCommitSha,
590
+ markerCommitSha: input.markerCommitSha ?? input.pending?.markerCommitSha,
591
+ };
592
+ }
593
+
594
+ async function finalizeLegacyTemplateManagedMarker(
595
+ provider: GitHubHarnessProvisioningProvider,
596
+ input: {
597
+ repoSlug: string;
598
+ repositoryId: number;
599
+ defaultBranch: string;
600
+ templateIdentity: ReturnType<typeof parseHarnessTemplateIdentityJson> & {
601
+ ok: true;
602
+ };
603
+ templateHeadSha: string;
604
+ operationId: string;
605
+ user: { id: number; login: string };
606
+ pDevVersion: string;
607
+ },
608
+ ): Promise<{ ok: true } | { ok: false; message: string }> {
609
+ const { owner, repo } = parseRepoSlug(input.repoSlug);
610
+ const metadata = await provider.getRepositoryMetadata(owner, repo);
611
+ if (!metadata) {
612
+ return {
613
+ ok: false,
614
+ message: `Generated harness workspace ${input.repoSlug} is not accessible for marker finalization.`,
615
+ };
616
+ }
617
+ if (metadata.repositoryId !== input.repositoryId) {
618
+ return {
619
+ ok: false,
620
+ message: `Generated harness workspace repository ID mismatch for ${input.repoSlug}.`,
621
+ };
622
+ }
623
+ const expectedMarker = buildHarnessManagedRepoMarker({
624
+ repository: input.repoSlug,
625
+ repositoryId: input.repositoryId,
626
+ templateIdentity: input.templateIdentity.identity,
627
+ defaultBranch: input.defaultBranch,
628
+ sourceHeadSha: input.templateHeadSha,
629
+ operationId: input.operationId,
630
+ createdByGithubUserId: input.user.id,
631
+ createdByLogin: input.user.login,
632
+ pDevVersion: input.pDevVersion,
633
+ });
634
+ const existingRaw = await provider.readRepositoryFileContent(
635
+ owner,
636
+ repo,
637
+ HARNESS_MANAGED_REPO_MARKER_FILE,
638
+ input.defaultBranch,
639
+ );
640
+ if (existingRaw) {
641
+ const existing = parseHarnessManagedRepoMarkerJson(existingRaw);
642
+ if (!existing.ok) {
643
+ return { ok: false, message: existing.reason };
644
+ }
645
+ if (
646
+ markersAreEquivalentForOperation(existing.marker, expectedMarker) ||
647
+ markerValidForExistingWorkspace(existing.marker, input.repoSlug, {
648
+ repositoryId: input.repositoryId,
649
+ })
650
+ ) {
651
+ return { ok: true };
652
+ }
653
+ return {
654
+ ok: false,
655
+ message:
656
+ "Existing managed marker belongs to a different operation or repository.",
657
+ };
658
+ }
659
+
660
+ try {
661
+ await provider.writeRepositoryFile({
662
+ owner,
663
+ repo,
664
+ path: HARNESS_MANAGED_REPO_MARKER_FILE,
665
+ branch: input.defaultBranch,
666
+ message: "Initialize p-dev managed harness workspace marker",
667
+ content: `${JSON.stringify(expectedMarker, null, 2)}\n`,
668
+ });
669
+ } catch (error) {
670
+ return {
671
+ ok: false,
672
+ message:
673
+ error instanceof Error
674
+ ? error.message
675
+ : "Failed to write managed harness workspace marker.",
676
+ };
677
+ }
678
+ return { ok: true };
679
+ }
680
+
681
+ async function readLegacyTemplateIdentityAtHead(
682
+ provider: GitHubHarnessProvisioningProvider,
683
+ repoSlug: string,
684
+ ): Promise<
685
+ | {
686
+ ok: true;
687
+ defaultBranch: string;
688
+ repositoryId: number;
689
+ identity: ReturnType<typeof parseHarnessTemplateIdentityJson> & {
690
+ ok: true;
691
+ };
692
+ }
693
+ | { ok: false; message: string }
694
+ > {
695
+ const { owner, repo } = parseRepoSlug(repoSlug);
696
+ const metadata = await provider.getRepositoryMetadata(owner, repo);
697
+ if (!metadata) {
698
+ return {
699
+ ok: false,
700
+ message: `Harness workspace ${repoSlug} is not accessible.`,
701
+ };
702
+ }
703
+ const identityRaw = await provider.readRepositoryFileContent(
704
+ owner,
705
+ repo,
706
+ HARNESS_TEMPLATE_IDENTITY_FILE,
707
+ metadata.defaultBranch,
708
+ );
709
+ if (!identityRaw) {
710
+ return {
711
+ ok: false,
712
+ message: "Legacy generated repository template identity is missing.",
713
+ };
714
+ }
715
+ const parsed = parseHarnessTemplateIdentityJson(identityRaw);
716
+ if (!parsed.ok) {
717
+ return { ok: false, message: parsed.reason };
718
+ }
719
+ return {
720
+ ok: true,
721
+ defaultBranch: metadata.defaultBranch,
722
+ repositoryId: metadata.repositoryId,
723
+ identity: parsed,
724
+ };
725
+ }
726
+
727
+ export async function loadHarnessRepoProvisioningSummary(options: {
728
+ cwd?: string;
729
+ provider?: GitHubHarnessProvisioningProvider;
730
+ }): Promise<HarnessRepoProvisioningSummary> {
731
+ const runtimeMode: HarnessRepoProvisioningSummary["runtimeMode"] =
732
+ isPackagedPDevRuntime()
733
+ ? "packaged"
734
+ : process.env.P_DEV_RUNTIME_MODE?.trim()
735
+ ? "source"
736
+ : "unknown";
737
+
738
+ const paths = resolveLocalFilePaths(options.cwd);
739
+ const existingEnv = await readExistingEnvFile(paths);
740
+ const explicitRepo = existingEnv?.values.GITHUB_DISPATCH_REPOSITORY?.trim();
741
+ const pending = await readHarnessProvisioningPendingState(options.cwd);
742
+
743
+ const base = {
744
+ runtimeMode,
745
+ harnessDispatchRepo: explicitRepo ?? null,
746
+ authenticatedLogin: null as string | null,
747
+ verifiedSavedRepo: false,
748
+ connectedAutomatically: false,
749
+ };
750
+
751
+ if (!isPackagedPDevRuntime()) {
752
+ return {
753
+ ...base,
754
+ eligible: false,
755
+ state: runtimeMode === "source" ? "skipped-source-mode" : "skipped-not-packaged",
756
+ message:
757
+ runtimeMode === "source"
758
+ ? "Source mode does not auto-provision a harness workspace."
759
+ : "Packaged runtime mode is not active.",
760
+ recoverable: false,
761
+ };
762
+ }
763
+
764
+ if (pending) {
765
+ return {
766
+ ...base,
767
+ eligible: true,
768
+ state: "repo-created-pending-verification",
769
+ message:
770
+ "Harness workspace provisioning is incomplete. Retry Step 1 Continue to resume.",
771
+ recoverable: true,
772
+ };
773
+ }
774
+
775
+ if (!explicitRepo) {
776
+ return {
777
+ ...base,
778
+ eligible: true,
779
+ state: "repo-absent",
780
+ message: "Packaged workspace provisioning has not completed yet.",
781
+ recoverable: true,
782
+ };
783
+ }
784
+
785
+ if (!options.provider) {
786
+ return {
787
+ ...base,
788
+ eligible: true,
789
+ state: "explicit-repo-present",
790
+ message: `Saved harness workspace ${explicitRepo} requires server validation.`,
791
+ recoverable: true,
792
+ };
793
+ }
794
+
795
+ const capabilities = await options.provider.inspectTokenCapabilities();
796
+ const validated = await validateExplicitPackagedRepo(
797
+ options.provider,
798
+ explicitRepo,
799
+ readSavedRepositoryId(existingEnv),
800
+ );
801
+ if (!validated.ok) {
802
+ return {
803
+ ...base,
804
+ eligible: true,
805
+ state: validated.state,
806
+ authenticatedLogin: capabilities.login,
807
+ message: validated.message,
808
+ recoverable: true,
809
+ };
810
+ }
811
+
812
+ const isDefaultDestination =
813
+ explicitRepo === destinationSlug(capabilities.login) ||
814
+ explicitRepo === destinationSlug(validated.marker.marker.createdByLogin ?? "");
815
+
816
+ return {
817
+ ...base,
818
+ eligible: true,
819
+ state: "verified-and-persisted",
820
+ harnessDispatchRepo: explicitRepo,
821
+ authenticatedLogin: capabilities.login,
822
+ message: `Connected to validated harness workspace ${explicitRepo}.`,
823
+ recoverable: false,
824
+ verifiedSavedRepo: true,
825
+ connectedAutomatically:
826
+ isDefaultDestination && Boolean(validated.marker.marker.operationId),
827
+ };
828
+ }
829
+
830
+ export async function previewHarnessRepoProvisioning(options: {
831
+ cwd?: string;
832
+ provider: GitHubHarnessProvisioningProvider;
833
+ operationId?: string;
834
+ moduleUrl?: string;
835
+ }): Promise<HarnessRepoProvisioningPreview> {
836
+ const basePreview = {
837
+ creationPreviewFingerprint: null as string | null,
838
+ resumedFromPending: false,
839
+ harnessDispatchRepo: null as string | null,
840
+ authenticatedLogin: null as string | null,
841
+ recoverable: false,
842
+ willCreateRepository: false,
843
+ tokenCapabilities: {
844
+ tokenType: "unknown" as GitHubTokenMetadata["tokenType"],
845
+ hasRepoScope: false,
846
+ hasWorkflowScope: false,
847
+ scopeAmbiguous: true,
848
+ },
849
+ };
850
+
851
+ if (!isPackagedPDevRuntime()) {
852
+ return {
853
+ state: "skipped-not-packaged",
854
+ fingerprint: buildFingerprint({ action: "preview", skipped: true }),
855
+ operationId: options.operationId ?? randomUUID(),
856
+ message: "Packaged runtime mode is not active.",
857
+ ...basePreview,
858
+ ...emptySnapshotPreviewFields(),
859
+ };
860
+ }
861
+
862
+ const paths = resolveLocalFilePaths(options.cwd);
863
+ const existingEnv = await readExistingEnvFile(paths);
864
+ const explicitRepo = existingEnv?.values.GITHUB_DISPATCH_REPOSITORY?.trim();
865
+ const pDevVersion = resolveHarnessPackageVersion();
866
+
867
+ const capabilities = await options.provider.inspectTokenCapabilities();
868
+ const tokenMetadata: GitHubTokenMetadata = {
869
+ login: capabilities.login,
870
+ tokenType: capabilities.tokenType,
871
+ oauthScopes: [],
872
+ hasRepoScope: capabilities.hasRepoScope,
873
+ hasWorkflowScope: capabilities.hasWorkflowScope,
874
+ };
875
+ const capabilityCheck = assessPackagedProvisioningTokenCapabilities({
876
+ ...tokenMetadata,
877
+ oauthScopes:
878
+ capabilities.scopeAmbiguous || capabilities.tokenType !== "classic"
879
+ ? []
880
+ : [
881
+ ...(capabilities.hasRepoScope ? ["repo"] : []),
882
+ ...(capabilities.hasWorkflowScope ? ["workflow"] : []),
883
+ ],
884
+ });
885
+
886
+ if (capabilities.scopeAmbiguous) {
887
+ const operationId = options.operationId ?? randomUUID();
888
+ return {
889
+ state: "token-scope-ambiguous",
890
+ fingerprint: buildFingerprint({ action: "preview", operationId }),
891
+ operationId,
892
+ message: capabilityCheck.ok
893
+ ? "Token scope metadata is ambiguous."
894
+ : capabilityCheck.message,
895
+ ...basePreview,
896
+ recoverable: true,
897
+ harnessDispatchRepo: explicitRepo ?? null,
898
+ authenticatedLogin: capabilities.login,
899
+ ...emptySnapshotPreviewFields(),
900
+ tokenCapabilities: {
901
+ tokenType: capabilities.tokenType,
902
+ hasRepoScope: capabilities.hasRepoScope,
903
+ hasWorkflowScope: capabilities.hasWorkflowScope,
904
+ scopeAmbiguous: capabilities.scopeAmbiguous,
905
+ },
906
+ };
907
+ }
908
+
909
+ if (!capabilityCheck.ok) {
910
+ const state =
911
+ capabilities.tokenType === "fine-grained"
912
+ ? "token-unsupported"
913
+ : capabilities.tokenType === "unknown"
914
+ ? "token-scope-ambiguous"
915
+ : "token-insufficient";
916
+ const operationId = options.operationId ?? randomUUID();
917
+ return {
918
+ state,
919
+ fingerprint: buildFingerprint({ action: "preview", operationId }),
920
+ operationId,
921
+ message: capabilityCheck.message,
922
+ ...basePreview,
923
+ recoverable: true,
924
+ harnessDispatchRepo: explicitRepo ?? null,
925
+ authenticatedLogin: capabilities.login,
926
+ ...emptySnapshotPreviewFields(),
927
+ tokenCapabilities: {
928
+ tokenType: capabilities.tokenType,
929
+ hasRepoScope: capabilities.hasRepoScope,
930
+ hasWorkflowScope: capabilities.hasWorkflowScope,
931
+ scopeAmbiguous: capabilities.scopeAmbiguous,
932
+ },
933
+ };
934
+ }
935
+
936
+ const user = await options.provider.resolveAuthenticatedUser();
937
+
938
+ if (explicitRepo) {
939
+ const operationId = options.operationId ?? randomUUID();
940
+ const explicit = await validateExplicitPackagedRepo(
941
+ options.provider,
942
+ explicitRepo,
943
+ readSavedRepositoryId(existingEnv),
944
+ );
945
+ const fingerprint = buildFingerprint({
946
+ action: "preview",
947
+ operationId,
948
+ authenticatedLogin: user.login,
949
+ explicitRepo,
950
+ pDevVersion,
951
+ });
952
+ if (!explicit.ok) {
953
+ return {
954
+ state: explicit.state,
955
+ fingerprint,
956
+ operationId,
957
+ message: explicit.message,
958
+ ...basePreview,
959
+ recoverable: true,
960
+ harnessDispatchRepo: explicitRepo,
961
+ authenticatedLogin: user.login,
962
+ ...emptySnapshotPreviewFields(),
963
+ tokenCapabilities: {
964
+ tokenType: capabilities.tokenType,
965
+ hasRepoScope: capabilities.hasRepoScope,
966
+ hasWorkflowScope: capabilities.hasWorkflowScope,
967
+ scopeAmbiguous: capabilities.scopeAmbiguous,
968
+ },
969
+ };
970
+ }
971
+
972
+ const legacyTemplateContentId =
973
+ explicit.marker.marker.createdFromTemplate?.templateContentId ?? null;
974
+
975
+ return {
976
+ state: "explicit-repo-present",
977
+ fingerprint,
978
+ operationId,
979
+ message: `Reconnecting to saved harness workspace ${explicitRepo}.`,
980
+ ...basePreview,
981
+ harnessDispatchRepo: explicitRepo,
982
+ authenticatedLogin: user.login,
983
+ ...snapshotPreviewFields(null, legacyTemplateContentId),
984
+ tokenCapabilities: {
985
+ tokenType: capabilities.tokenType,
986
+ hasRepoScope: capabilities.hasRepoScope,
987
+ hasWorkflowScope: capabilities.hasWorkflowScope,
988
+ scopeAmbiguous: capabilities.scopeAmbiguous,
989
+ },
990
+ };
991
+ }
992
+
993
+ const snapshotPreview = await loadEmbeddedWorkspaceSnapshot(
994
+ options.moduleUrl ?? import.meta.url,
995
+ );
996
+ if (!snapshotPreview.ok) {
997
+ const operationId = options.operationId ?? randomUUID();
998
+ return {
999
+ state: snapshotPreview.state,
1000
+ fingerprint: buildFingerprint({ action: "preview", operationId }),
1001
+ operationId,
1002
+ message: snapshotPreview.message,
1003
+ ...basePreview,
1004
+ authenticatedLogin: user.login,
1005
+ ...emptySnapshotPreviewFields(),
1006
+ tokenCapabilities: {
1007
+ tokenType: capabilities.tokenType,
1008
+ hasRepoScope: capabilities.hasRepoScope,
1009
+ hasWorkflowScope: capabilities.hasWorkflowScope,
1010
+ scopeAmbiguous: capabilities.scopeAmbiguous,
1011
+ },
1012
+ };
1013
+ }
1014
+
1015
+ const resolvedOperation = await resolveProvisioningOperation({
1016
+ cwd: options.cwd,
1017
+ requestedOperationId: options.operationId,
1018
+ user,
1019
+ snapshotPreview,
1020
+ });
1021
+ if (!resolvedOperation.ok) {
1022
+ return {
1023
+ state: resolvedOperation.state,
1024
+ fingerprint: buildFingerprint({
1025
+ action: "preview",
1026
+ conflict: resolvedOperation.message,
1027
+ }),
1028
+ operationId: options.operationId ?? randomUUID(),
1029
+ message: resolvedOperation.message,
1030
+ ...basePreview,
1031
+ recoverable: true,
1032
+ authenticatedLogin: user.login,
1033
+ ...snapshotPreviewFields(snapshotPreview),
1034
+ tokenCapabilities: {
1035
+ tokenType: capabilities.tokenType,
1036
+ hasRepoScope: capabilities.hasRepoScope,
1037
+ hasWorkflowScope: capabilities.hasWorkflowScope,
1038
+ scopeAmbiguous: capabilities.scopeAmbiguous,
1039
+ },
1040
+ };
1041
+ }
1042
+
1043
+ const {
1044
+ operationId,
1045
+ resumedFromPending,
1046
+ creationPreviewFingerprint,
1047
+ } = resolvedOperation;
1048
+
1049
+ const destination = destinationSlug(user.login);
1050
+ const classification = await classifyDestinationRepo(
1051
+ options.provider,
1052
+ user,
1053
+ options.cwd,
1054
+ snapshotPreview,
1055
+ );
1056
+
1057
+ let state: HarnessProvisioningState = "snapshot-preview-ready";
1058
+ let message = `p-dev will create or reconnect ${destination} as your private harness workspace.`;
1059
+ let willCreateRepository = false;
1060
+
1061
+ switch (classification.kind) {
1062
+ case "absent":
1063
+ state = "repo-absent";
1064
+ willCreateRepository = true;
1065
+ message = `p-dev will create private harness workspace ${destination} from the packaged workspace snapshot.`;
1066
+ break;
1067
+ case "valid-managed":
1068
+ state = "valid-existing-managed-repo";
1069
+ message = `Reconnecting to existing managed harness workspace ${destination}.`;
1070
+ break;
1071
+ case "public-collision":
1072
+ state = "same-name-public-collision";
1073
+ message = `${destination} exists but is not private. p-dev will not change it automatically.`;
1074
+ break;
1075
+ case "unmanaged-collision":
1076
+ state = "same-name-unmanaged-collision";
1077
+ message = `${destination} exists without a compatible managed marker.`;
1078
+ break;
1079
+ case "malformed-marker":
1080
+ state = "same-name-malformed-marker";
1081
+ message = classification.reason;
1082
+ break;
1083
+ case "snapshot-only-without-pending":
1084
+ state = "same-name-snapshot-only-without-pending";
1085
+ message = `${destination} looks like an unmanaged generated repo.`;
1086
+ break;
1087
+ case "snapshot-only-with-pending":
1088
+ state = "same-name-snapshot-only-with-pending";
1089
+ message = `Resuming snapshot provisioning for ${destination}.`;
1090
+ break;
1091
+ }
1092
+
1093
+ const fingerprint = buildProvisioningPreviewFingerprint({
1094
+ operationId,
1095
+ user,
1096
+ destination,
1097
+ snapshotPreview,
1098
+ classification: classification.kind,
1099
+ envBaseline: existingEnv?.values.GITHUB_DISPATCH_REPOSITORY ?? "",
1100
+ pDevVersion,
1101
+ resumedFromPending,
1102
+ creationPreviewFingerprint,
1103
+ });
1104
+
1105
+ return {
1106
+ state,
1107
+ fingerprint,
1108
+ operationId,
1109
+ creationPreviewFingerprint,
1110
+ resumedFromPending,
1111
+ harnessDispatchRepo:
1112
+ classification.kind === "valid-managed" ? destination : null,
1113
+ authenticatedLogin: user.login,
1114
+ message,
1115
+ recoverable:
1116
+ state === "repo-absent" ||
1117
+ state === "valid-existing-managed-repo" ||
1118
+ state === "same-name-snapshot-only-with-pending",
1119
+ willCreateRepository,
1120
+ ...snapshotPreviewFields(snapshotPreview),
1121
+ tokenCapabilities: {
1122
+ tokenType: capabilities.tokenType,
1123
+ hasRepoScope: capabilities.hasRepoScope,
1124
+ hasWorkflowScope: capabilities.hasWorkflowScope,
1125
+ scopeAmbiguous: capabilities.scopeAmbiguous,
1126
+ },
1127
+ };
1128
+ }
1129
+
1130
+ export async function applyHarnessRepoProvisioning(options: {
1131
+ cwd?: string;
1132
+ provider: GitHubHarnessProvisioningProvider;
1133
+ confirmed: boolean;
1134
+ fingerprint: string;
1135
+ operationId: string;
1136
+ moduleUrl?: string;
1137
+ }): Promise<HarnessRepoProvisioningApplyResult> {
1138
+ return withHarnessProvisioningMutex(
1139
+ resolveLocalFilePaths(options.cwd).cwd,
1140
+ async () => applyHarnessRepoProvisioningLocked(options),
1141
+ );
1142
+ }
1143
+
1144
+ async function applyHarnessRepoProvisioningLocked(options: {
1145
+ cwd?: string;
1146
+ provider: GitHubHarnessProvisioningProvider;
1147
+ confirmed: boolean;
1148
+ fingerprint: string;
1149
+ operationId: string;
1150
+ moduleUrl?: string;
1151
+ }): Promise<HarnessRepoProvisioningApplyResult> {
1152
+ const preview = await previewHarnessRepoProvisioning({
1153
+ cwd: options.cwd,
1154
+ provider: options.provider,
1155
+ operationId: options.operationId,
1156
+ moduleUrl: options.moduleUrl,
1157
+ });
1158
+
1159
+ if (!options.confirmed) {
1160
+ return {
1161
+ state: preview.state,
1162
+ harnessDispatchRepo: preview.harnessDispatchRepo,
1163
+ message: "Confirmation is required before provisioning.",
1164
+ recoverable: true,
1165
+ persisted: false,
1166
+ };
1167
+ }
1168
+
1169
+ if (preview.fingerprint !== options.fingerprint) {
1170
+ return {
1171
+ state: "snapshot-preview-stale",
1172
+ harnessDispatchRepo: preview.harnessDispatchRepo,
1173
+ message: "Provisioning preview is stale. Retry Step 1 Continue.",
1174
+ recoverable: true,
1175
+ persisted: false,
1176
+ };
1177
+ }
1178
+
1179
+ if (
1180
+ preview.state === "skipped-not-packaged" ||
1181
+ preview.state === "token-unsupported" ||
1182
+ preview.state === "token-insufficient" ||
1183
+ preview.state === "token-scope-ambiguous" ||
1184
+ preview.state === "snapshot-unavailable" ||
1185
+ preview.state === "snapshot-manifest-missing" ||
1186
+ preview.state === "snapshot-manifest-invalid" ||
1187
+ preview.state === "snapshot-incompatible" ||
1188
+ preview.state === "snapshot-tampered" ||
1189
+ preview.state === "same-name-public-collision" ||
1190
+ preview.state === "same-name-unmanaged-collision" ||
1191
+ preview.state === "same-name-malformed-marker" ||
1192
+ preview.state === "same-name-snapshot-only-without-pending" ||
1193
+ preview.state === "explicit-packaged-repo-invalid" ||
1194
+ preview.state === "explicit-packaged-repo-legacy-source"
1195
+ ) {
1196
+ return {
1197
+ state: preview.state,
1198
+ harnessDispatchRepo: preview.harnessDispatchRepo,
1199
+ message: preview.message,
1200
+ recoverable: preview.recoverable,
1201
+ persisted: false,
1202
+ };
1203
+ }
1204
+
1205
+ const user = await options.provider.resolveAuthenticatedUser();
1206
+ const pDevVersion = resolveHarnessPackageVersion();
1207
+ const paths = resolveLocalFilePaths(options.cwd);
1208
+ const existingEnv = await readExistingEnvFile(paths);
1209
+ const explicitRepo = existingEnv?.values.GITHUB_DISPATCH_REPOSITORY?.trim();
1210
+
1211
+ if (explicitRepo) {
1212
+ const explicit = await validateExplicitPackagedRepo(
1213
+ options.provider,
1214
+ explicitRepo,
1215
+ readSavedRepositoryId(existingEnv),
1216
+ );
1217
+ if (!explicit.ok) {
1218
+ return {
1219
+ state: explicit.state,
1220
+ harnessDispatchRepo: explicitRepo,
1221
+ message: explicit.message,
1222
+ recoverable: true,
1223
+ persisted: false,
1224
+ };
1225
+ }
1226
+
1227
+ const persist = await persistGithubDispatchRepository({
1228
+ cwd: options.cwd,
1229
+ githubDispatchRepository: explicit.repoSlug,
1230
+ githubDispatchRepositoryId: explicit.repositoryId,
1231
+ });
1232
+ if (persist.outcome !== "changed" && persist.outcome !== "skipped") {
1233
+ return {
1234
+ state: "created-but-persistence-failed",
1235
+ harnessDispatchRepo: explicit.repoSlug,
1236
+ message: persist.reason ?? "Failed to persist GITHUB_DISPATCH_REPOSITORY.",
1237
+ recoverable: true,
1238
+ persisted: false,
1239
+ };
1240
+ }
1241
+ await clearHarnessProvisioningPendingState(options.cwd);
1242
+ return {
1243
+ state: "verified-and-persisted",
1244
+ harnessDispatchRepo: explicit.repoSlug,
1245
+ message: `Connected to saved harness workspace ${explicit.repoSlug}.`,
1246
+ recoverable: false,
1247
+ persisted: true,
1248
+ };
1249
+ }
1250
+
1251
+ const snapshotPreview = await loadEmbeddedWorkspaceSnapshot(
1252
+ options.moduleUrl ?? import.meta.url,
1253
+ );
1254
+ if (!snapshotPreview.ok) {
1255
+ return {
1256
+ state: snapshotPreview.state,
1257
+ harnessDispatchRepo: null,
1258
+ message: snapshotPreview.message,
1259
+ recoverable: false,
1260
+ persisted: false,
1261
+ };
1262
+ }
1263
+
1264
+ const classification = await classifyDestinationRepo(
1265
+ options.provider,
1266
+ user,
1267
+ options.cwd,
1268
+ snapshotPreview,
1269
+ );
1270
+
1271
+ const currentContext = buildHarnessProvisioningPreviewContext({
1272
+ operationId: options.operationId,
1273
+ user,
1274
+ destination: destinationSlug(user.login),
1275
+ manifest: snapshotPreview.manifest,
1276
+ snapshotFingerprint: snapshotPreview.fingerprint,
1277
+ classification: classification.kind as HarnessProvisioningClassification,
1278
+ envBaseline: existingEnv?.values.GITHUB_DISPATCH_REPOSITORY ?? "",
1279
+ pDevVersion,
1280
+ resumedFromPending: preview.resumedFromPending,
1281
+ creationPreviewFingerprint: preview.creationPreviewFingerprint,
1282
+ });
1283
+ const contextValidation = validateSubmittedHarnessProvisioningFingerprint({
1284
+ submittedFingerprint: options.fingerprint,
1285
+ currentContext,
1286
+ });
1287
+ if (!contextValidation.ok) {
1288
+ return {
1289
+ state: "snapshot-preview-stale",
1290
+ harnessDispatchRepo: null,
1291
+ message: contextValidation.message,
1292
+ recoverable: true,
1293
+ persisted: false,
1294
+ };
1295
+ }
1296
+
1297
+ let targetRepo = destinationSlug(user.login);
1298
+ let targetRepositoryId: number | undefined =
1299
+ classification.kind === "valid-managed"
1300
+ ? classification.repositoryId
1301
+ : undefined;
1302
+
1303
+ const pending = await readHarnessProvisioningPendingState(options.cwd);
1304
+ if (preview.resumedFromPending) {
1305
+ if (!pending || !preview.creationPreviewFingerprint) {
1306
+ return {
1307
+ state: "same-name-snapshot-only-without-pending",
1308
+ harnessDispatchRepo: destinationSlug(user.login),
1309
+ message:
1310
+ "Matching local pending provisioning evidence is required to resume.",
1311
+ recoverable: true,
1312
+ persisted: false,
1313
+ };
1314
+ }
1315
+ const pendingValidation = validatePendingProvisioningState(
1316
+ pending,
1317
+ buildSnapshotPendingValidationContext(snapshotPreview, {
1318
+ operationId: options.operationId,
1319
+ authenticatedUserId: user.id,
1320
+ authenticatedLogin: user.login,
1321
+ targetOwner: user.login,
1322
+ targetRepo: HARNESS_DEFAULT_DESTINATION_REPO_NAME,
1323
+ previewFingerprint: preview.creationPreviewFingerprint,
1324
+ }),
1325
+ );
1326
+ if (!pendingValidation.ok) {
1327
+ return {
1328
+ state: "same-name-unmanaged-collision",
1329
+ harnessDispatchRepo: destinationSlug(user.login),
1330
+ message: pendingValidation.reason,
1331
+ recoverable: true,
1332
+ persisted: false,
1333
+ };
1334
+ }
1335
+ } else if (
1336
+ pending &&
1337
+ preview.state !== "valid-existing-managed-repo" &&
1338
+ classification.kind !== "valid-managed"
1339
+ ) {
1340
+ return {
1341
+ state: "concurrent-request-recovered",
1342
+ harnessDispatchRepo: null,
1343
+ message:
1344
+ "Another provisioning operation is already in progress for this workspace.",
1345
+ recoverable: true,
1346
+ persisted: false,
1347
+ };
1348
+ }
1349
+
1350
+ const creationFingerprint =
1351
+ preview.creationPreviewFingerprint ?? options.fingerprint;
1352
+ let activePending = pending;
1353
+ let requiresSnapshotVerification = false;
1354
+
1355
+ if (classification.kind === "valid-managed") {
1356
+ targetRepo = classification.repoSlug;
1357
+ } else if (
1358
+ classification.kind === "absent" ||
1359
+ classification.kind === "snapshot-only-with-pending"
1360
+ ) {
1361
+ const legacyTemplateIdentity =
1362
+ classification.kind === "snapshot-only-with-pending"
1363
+ ? await readLegacyTemplateIdentityAtHead(options.provider, targetRepo)
1364
+ : null;
1365
+
1366
+ if (
1367
+ classification.kind === "snapshot-only-with-pending" &&
1368
+ legacyTemplateIdentity?.ok
1369
+ ) {
1370
+ const { owner, repo } = parseRepoSlug(targetRepo);
1371
+ const legacyHeadSha = await options.provider.getRepositoryDefaultBranchHead(
1372
+ owner,
1373
+ repo,
1374
+ legacyTemplateIdentity.defaultBranch,
1375
+ );
1376
+ const markerResult = await finalizeLegacyTemplateManagedMarker(
1377
+ options.provider,
1378
+ {
1379
+ repoSlug: targetRepo,
1380
+ repositoryId: legacyTemplateIdentity.repositoryId,
1381
+ defaultBranch: legacyTemplateIdentity.defaultBranch,
1382
+ templateIdentity: legacyTemplateIdentity.identity,
1383
+ templateHeadSha: legacyHeadSha,
1384
+ operationId: options.operationId,
1385
+ user,
1386
+ pDevVersion,
1387
+ },
1388
+ );
1389
+ if (!markerResult.ok) {
1390
+ return {
1391
+ state: "marker-write-pending",
1392
+ harnessDispatchRepo: targetRepo,
1393
+ message: markerResult.message,
1394
+ recoverable: true,
1395
+ persisted: false,
1396
+ };
1397
+ }
1398
+ targetRepositoryId = legacyTemplateIdentity.repositoryId;
1399
+ } else {
1400
+ if (classification.kind === "absent" && !preview.resumedFromPending) {
1401
+ await writeHarnessProvisioningPendingStateAtomic(
1402
+ buildSnapshotPendingState({
1403
+ operationId: options.operationId,
1404
+ user,
1405
+ snapshotPreview,
1406
+ previewFingerprint: creationFingerprint,
1407
+ }),
1408
+ options.cwd,
1409
+ );
1410
+ activePending = await readHarnessProvisioningPendingState(options.cwd);
1411
+ }
1412
+
1413
+ let provisionResult:
1414
+ | Awaited<ReturnType<typeof provisionHarnessWorkspaceFromSnapshot>>
1415
+ | undefined;
1416
+ try {
1417
+ provisionResult = await provisionHarnessWorkspaceFromSnapshot({
1418
+ provider: options.provider,
1419
+ user,
1420
+ repoName: HARNESS_DEFAULT_DESTINATION_REPO_NAME,
1421
+ description: HARNESS_DEFAULT_DESTINATION_DESCRIPTION,
1422
+ snapshotRoot: snapshotPreview.snapshotRoot,
1423
+ manifest: snapshotPreview.manifest,
1424
+ packageVersion: snapshotPreview.packageVersion,
1425
+ operationId: options.operationId,
1426
+ pending: activePending,
1427
+ onCheckpoint: async (checkpoint) => {
1428
+ await writeHarnessProvisioningPendingStateAtomic(
1429
+ buildSnapshotPendingState({
1430
+ operationId: options.operationId,
1431
+ user,
1432
+ snapshotPreview,
1433
+ previewFingerprint: creationFingerprint,
1434
+ pending: activePending,
1435
+ phase: checkpoint.phase,
1436
+ repositoryId: checkpoint.repositoryId,
1437
+ defaultBranch: checkpoint.defaultBranch,
1438
+ initializedCommitSha: checkpoint.initializedCommitSha,
1439
+ snapshotCommitSha: checkpoint.snapshotCommitSha,
1440
+ markerCommitSha: checkpoint.markerCommitSha,
1441
+ }),
1442
+ options.cwd,
1443
+ );
1444
+ activePending = await readHarnessProvisioningPendingState(options.cwd);
1445
+ },
1446
+ });
1447
+ } catch (error) {
1448
+ const message =
1449
+ error instanceof Error
1450
+ ? error.message
1451
+ : "Repository provisioning failed unexpectedly.";
1452
+ if (
1453
+ error instanceof SnapshotProvisioningError &&
1454
+ error.code === "marker-commit-failed"
1455
+ ) {
1456
+ const { owner, repo } = parseRepoSlug(destinationSlug(user.login));
1457
+ const metadata = await options.provider.getRepositoryMetadata(owner, repo);
1458
+ if (metadata) {
1459
+ const headSha = await options.provider.getRepositoryDefaultBranchHead(
1460
+ owner,
1461
+ repo,
1462
+ metadata.defaultBranch,
1463
+ );
1464
+ let initializedCommitSha = activePending?.initializedCommitSha;
1465
+ try {
1466
+ const headCommit = await options.provider.getGitCommit(owner, repo, headSha);
1467
+ initializedCommitSha =
1468
+ headCommit.parents[0]?.sha ?? initializedCommitSha;
1469
+ } catch {
1470
+ // keep best-effort pending evidence
1471
+ }
1472
+ await writeHarnessProvisioningPendingStateAtomic(
1473
+ buildSnapshotPendingState({
1474
+ operationId: options.operationId,
1475
+ user,
1476
+ snapshotPreview,
1477
+ previewFingerprint: creationFingerprint,
1478
+ pending: activePending,
1479
+ phase: "marker-pending",
1480
+ repositoryId: metadata.repositoryId,
1481
+ initializedCommitSha,
1482
+ snapshotCommitSha: headSha,
1483
+ }),
1484
+ options.cwd,
1485
+ );
1486
+ }
1487
+ return {
1488
+ state: "marker-write-pending",
1489
+ harnessDispatchRepo: destinationSlug(user.login),
1490
+ message,
1491
+ recoverable: true,
1492
+ persisted: false,
1493
+ };
1494
+ }
1495
+
1496
+ const recovered = await classifyDestinationRepo(
1497
+ options.provider,
1498
+ user,
1499
+ options.cwd,
1500
+ snapshotPreview,
1501
+ );
1502
+ if (
1503
+ recovered.kind === "valid-managed" ||
1504
+ recovered.kind === "snapshot-only-with-pending"
1505
+ ) {
1506
+ return {
1507
+ state: "repo-created-pending-verification",
1508
+ harnessDispatchRepo: destinationSlug(user.login),
1509
+ message,
1510
+ recoverable: true,
1511
+ persisted: false,
1512
+ };
1513
+ } else if (error instanceof GitHubApiError && error.status === 422) {
1514
+ const retryClassification = await classifyDestinationRepo(
1515
+ options.provider,
1516
+ user,
1517
+ options.cwd,
1518
+ snapshotPreview,
1519
+ );
1520
+ if (retryClassification.kind === "absent") {
1521
+ return {
1522
+ state: "api-timeout-unknown",
1523
+ harnessDispatchRepo: destinationSlug(user.login),
1524
+ message:
1525
+ "Repository creation returned an ambiguous result. Retry Step 1 Continue.",
1526
+ recoverable: true,
1527
+ persisted: false,
1528
+ };
1529
+ }
1530
+ return {
1531
+ state: "repo-created-pending-verification",
1532
+ harnessDispatchRepo: destinationSlug(user.login),
1533
+ message,
1534
+ recoverable: true,
1535
+ persisted: false,
1536
+ };
1537
+ } else {
1538
+ return {
1539
+ state: "api-timeout-unknown",
1540
+ harnessDispatchRepo: destinationSlug(user.login),
1541
+ message,
1542
+ recoverable: true,
1543
+ persisted: false,
1544
+ };
1545
+ }
1546
+ }
1547
+
1548
+ if (provisionResult) {
1549
+ if (!provisionResult.ok) {
1550
+ const markerPending =
1551
+ provisionResult.code === "marker-commit-failed" ||
1552
+ provisionResult.code === "description-finalization-failed" ||
1553
+ activePending?.phase === "marker-pending" ||
1554
+ activePending?.phase === "description-pending" ||
1555
+ Boolean(activePending?.snapshotCommitSha);
1556
+ return {
1557
+ state: markerPending
1558
+ ? "marker-write-pending"
1559
+ : provisionResult.recoverable
1560
+ ? "repo-created-pending-verification"
1561
+ : "api-timeout-unknown",
1562
+ harnessDispatchRepo: destinationSlug(user.login),
1563
+ message: provisionResult.message,
1564
+ recoverable: provisionResult.recoverable,
1565
+ persisted: false,
1566
+ };
1567
+ }
1568
+
1569
+ targetRepo = provisionResult.fullName;
1570
+ targetRepositoryId = provisionResult.repositoryId;
1571
+ requiresSnapshotVerification = true;
1572
+ await writeHarnessProvisioningPendingStateAtomic(
1573
+ buildSnapshotPendingState({
1574
+ operationId: options.operationId,
1575
+ user,
1576
+ snapshotPreview,
1577
+ previewFingerprint: creationFingerprint,
1578
+ pending: activePending,
1579
+ phase: "persistence-pending",
1580
+ repositoryId: provisionResult.repositoryId,
1581
+ defaultBranch: provisionResult.defaultBranch,
1582
+ initializedCommitSha: provisionResult.initializedCommitSha,
1583
+ snapshotCommitSha: provisionResult.snapshotCommitSha,
1584
+ markerCommitSha: provisionResult.markerCommitSha,
1585
+ }),
1586
+ options.cwd,
1587
+ );
1588
+ }
1589
+ }
1590
+ } else {
1591
+ return {
1592
+ state: preview.state,
1593
+ harnessDispatchRepo: preview.harnessDispatchRepo,
1594
+ message: preview.message,
1595
+ recoverable: preview.recoverable,
1596
+ persisted: false,
1597
+ };
1598
+ }
1599
+
1600
+ if (targetRepositoryId === undefined) {
1601
+ const { owner, repo } = parseRepoSlug(targetRepo);
1602
+ const metadata = await options.provider.getRepositoryMetadata(owner, repo);
1603
+ if (!metadata) {
1604
+ return {
1605
+ state: "repo-created-pending-verification",
1606
+ harnessDispatchRepo: targetRepo,
1607
+ message: `Harness workspace ${targetRepo} is not accessible for verification.`,
1608
+ recoverable: true,
1609
+ persisted: false,
1610
+ };
1611
+ }
1612
+ targetRepositoryId = metadata.repositoryId;
1613
+ }
1614
+
1615
+ if (requiresSnapshotVerification) {
1616
+ const verification = await verifyProvisionedHarnessWorkspace({
1617
+ provider: options.provider,
1618
+ repoSlug: targetRepo,
1619
+ repositoryId: targetRepositoryId,
1620
+ manifest: snapshotPreview.manifest,
1621
+ });
1622
+ if (!verification.ok) {
1623
+ return {
1624
+ state: "repo-created-pending-verification",
1625
+ harnessDispatchRepo: targetRepo,
1626
+ message: verification.message,
1627
+ recoverable: true,
1628
+ persisted: false,
1629
+ };
1630
+ }
1631
+ }
1632
+
1633
+ const persist = await persistGithubDispatchRepository({
1634
+ cwd: options.cwd,
1635
+ githubDispatchRepository: targetRepo,
1636
+ githubDispatchRepositoryId: targetRepositoryId,
1637
+ });
1638
+ if (persist.outcome !== "changed" && persist.outcome !== "skipped") {
1639
+ return {
1640
+ state: "created-but-persistence-failed",
1641
+ harnessDispatchRepo: targetRepo,
1642
+ message: persist.reason ?? "Failed to persist GITHUB_DISPATCH_REPOSITORY.",
1643
+ recoverable: true,
1644
+ persisted: false,
1645
+ };
1646
+ }
1647
+
1648
+ await clearHarnessProvisioningPendingState(options.cwd);
1649
+ return {
1650
+ state: "verified-and-persisted",
1651
+ harnessDispatchRepo: targetRepo,
1652
+ message: `Private harness workspace ${targetRepo} is connected.`,
1653
+ recoverable: false,
1654
+ persisted: true,
1655
+ };
1656
+ }