agent-control-plane 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +589 -0
  3. package/SKILL.md +149 -0
  4. package/assets/workflow-catalog.json +57 -0
  5. package/bin/audit-issue-routing.sh +74 -0
  6. package/bin/issue-resource-class.sh +58 -0
  7. package/bin/label-follow-up-issues.sh +114 -0
  8. package/bin/pr-risk.sh +532 -0
  9. package/bin/sync-pr-labels.sh +112 -0
  10. package/hooks/heartbeat-hooks.sh +573 -0
  11. package/hooks/issue-reconcile-hooks.sh +217 -0
  12. package/hooks/pr-reconcile-hooks.sh +225 -0
  13. package/npm/bin/agent-control-plane.js +1984 -0
  14. package/npm/public-bin/agent-control-plane +3 -0
  15. package/package.json +61 -0
  16. package/tools/bin/agent-cleanup-worktree +247 -0
  17. package/tools/bin/agent-github-update-labels +66 -0
  18. package/tools/bin/agent-init-worktree +216 -0
  19. package/tools/bin/agent-project-archive-run +52 -0
  20. package/tools/bin/agent-project-capture-worker +46 -0
  21. package/tools/bin/agent-project-catch-up-merged-prs +137 -0
  22. package/tools/bin/agent-project-cleanup-session +244 -0
  23. package/tools/bin/agent-project-detached-launch +107 -0
  24. package/tools/bin/agent-project-heartbeat-loop +2347 -0
  25. package/tools/bin/agent-project-open-issue-worktree +89 -0
  26. package/tools/bin/agent-project-open-pr-worktree +80 -0
  27. package/tools/bin/agent-project-publish-issue-pr +349 -0
  28. package/tools/bin/agent-project-reconcile-issue-session +1128 -0
  29. package/tools/bin/agent-project-reconcile-pr-session +1005 -0
  30. package/tools/bin/agent-project-retry-state +147 -0
  31. package/tools/bin/agent-project-run-claude-session +657 -0
  32. package/tools/bin/agent-project-run-codex-resilient +718 -0
  33. package/tools/bin/agent-project-run-codex-session +316 -0
  34. package/tools/bin/agent-project-run-kilo-session +27 -0
  35. package/tools/bin/agent-project-run-openclaw-session +984 -0
  36. package/tools/bin/agent-project-run-opencode-session +27 -0
  37. package/tools/bin/agent-project-sync-anchor-repo +128 -0
  38. package/tools/bin/agent-project-worker-status +143 -0
  39. package/tools/bin/audit-agent-worktrees.sh +310 -0
  40. package/tools/bin/audit-issue-routing.sh +11 -0
  41. package/tools/bin/audit-retained-layout.sh +58 -0
  42. package/tools/bin/audit-retained-overlap.sh +135 -0
  43. package/tools/bin/audit-retained-worktrees.sh +228 -0
  44. package/tools/bin/branch-verification-guard.sh +351 -0
  45. package/tools/bin/capture-worker.sh +18 -0
  46. package/tools/bin/check-skill-contracts.sh +324 -0
  47. package/tools/bin/cleanup-worktree.sh +44 -0
  48. package/tools/bin/codex-quota +31 -0
  49. package/tools/bin/create-follow-up-issue.sh +114 -0
  50. package/tools/bin/dashboard-launchd-bootstrap.sh +38 -0
  51. package/tools/bin/flow-config-lib.sh +2127 -0
  52. package/tools/bin/flow-resident-worker-lib.sh +683 -0
  53. package/tools/bin/flow-runtime-doctor.sh +97 -0
  54. package/tools/bin/flow-shell-lib.sh +266 -0
  55. package/tools/bin/heartbeat-recovery-preflight.sh +106 -0
  56. package/tools/bin/heartbeat-safe-auto.sh +551 -0
  57. package/tools/bin/install-dashboard-launchd.sh +152 -0
  58. package/tools/bin/install-project-launchd.sh +219 -0
  59. package/tools/bin/issue-publish-scope-guard.sh +242 -0
  60. package/tools/bin/issue-requires-local-workspace-install.sh +31 -0
  61. package/tools/bin/issue-resource-class.sh +12 -0
  62. package/tools/bin/kick-scheduler.sh +75 -0
  63. package/tools/bin/label-follow-up-issues.sh +14 -0
  64. package/tools/bin/new-pr-worktree.sh +50 -0
  65. package/tools/bin/new-worktree.sh +49 -0
  66. package/tools/bin/pr-risk.sh +12 -0
  67. package/tools/bin/prepare-worktree.sh +140 -0
  68. package/tools/bin/profile-activate.sh +109 -0
  69. package/tools/bin/profile-adopt.sh +219 -0
  70. package/tools/bin/profile-smoke.sh +461 -0
  71. package/tools/bin/project-init.sh +189 -0
  72. package/tools/bin/project-launchd-bootstrap.sh +54 -0
  73. package/tools/bin/project-remove.sh +155 -0
  74. package/tools/bin/project-runtime-supervisor.sh +56 -0
  75. package/tools/bin/project-runtimectl.sh +586 -0
  76. package/tools/bin/provider-cooldown-state.sh +166 -0
  77. package/tools/bin/publish-issue-worker.sh +31 -0
  78. package/tools/bin/reconcile-issue-worker.sh +34 -0
  79. package/tools/bin/reconcile-pr-worker.sh +34 -0
  80. package/tools/bin/record-verification.sh +71 -0
  81. package/tools/bin/render-architecture-infographics.sh +110 -0
  82. package/tools/bin/render-dashboard-demo-media.sh +333 -0
  83. package/tools/bin/render-dashboard-snapshot.py +16 -0
  84. package/tools/bin/render-flow-config.sh +86 -0
  85. package/tools/bin/retry-state.sh +31 -0
  86. package/tools/bin/reuse-issue-worktree.sh +75 -0
  87. package/tools/bin/run-codex-bypass.sh +3 -0
  88. package/tools/bin/run-codex-safe.sh +3 -0
  89. package/tools/bin/run-codex-task.sh +231 -0
  90. package/tools/bin/scaffold-profile.sh +374 -0
  91. package/tools/bin/serve-dashboard.sh +5 -0
  92. package/tools/bin/split-retained-slice.sh +124 -0
  93. package/tools/bin/start-issue-worker.sh +796 -0
  94. package/tools/bin/start-pr-fix-worker.sh +458 -0
  95. package/tools/bin/start-pr-merge-repair-worker.sh +8 -0
  96. package/tools/bin/start-pr-review-worker.sh +227 -0
  97. package/tools/bin/start-resident-issue-loop.sh +908 -0
  98. package/tools/bin/sync-agent-repo.sh +52 -0
  99. package/tools/bin/sync-dependency-baseline.sh +247 -0
  100. package/tools/bin/sync-pr-labels.sh +12 -0
  101. package/tools/bin/sync-recurring-issue-checklist.sh +274 -0
  102. package/tools/bin/sync-shared-agent-home.sh +214 -0
  103. package/tools/bin/sync-vscode-workspace.sh +157 -0
  104. package/tools/bin/test-smoke.sh +63 -0
  105. package/tools/bin/uninstall-project-launchd.sh +55 -0
  106. package/tools/bin/update-github-labels.sh +14 -0
  107. package/tools/bin/worker-status.sh +19 -0
  108. package/tools/bin/workflow-catalog.sh +77 -0
  109. package/tools/dashboard/app.js +286 -0
  110. package/tools/dashboard/dashboard_snapshot.py +466 -0
  111. package/tools/dashboard/index.html +41 -0
  112. package/tools/dashboard/server.py +64 -0
  113. package/tools/dashboard/styles.css +351 -0
  114. package/tools/templates/issue-prompt-template.md +109 -0
  115. package/tools/templates/pr-fix-template.md +120 -0
  116. package/tools/templates/pr-merge-repair-template.md +91 -0
  117. package/tools/templates/pr-review-template.md +62 -0
  118. package/tools/templates/scheduled-issue-prompt-template.md +62 -0
  119. package/tools/tests/test-agent-control-plane-npm-cli.sh +279 -0
  120. package/tools/tests/test-agent-github-update-labels-falls-back-to-repository-id.sh +56 -0
  121. package/tools/tests/test-agent-project-claude-session-wrapper-clears-stale-sandbox-artifacts.sh +89 -0
  122. package/tools/tests/test-agent-project-claude-session-wrapper-does-not-retry-provider-quota.sh +82 -0
  123. package/tools/tests/test-agent-project-claude-session-wrapper-retries-transient-failures.sh +90 -0
  124. package/tools/tests/test-agent-project-claude-session-wrapper-times-out.sh +73 -0
  125. package/tools/tests/test-agent-project-claude-session-wrapper.sh +103 -0
  126. package/tools/tests/test-agent-project-cleanup-session-orphan-fallback.sh +90 -0
  127. package/tools/tests/test-agent-project-cleanup-session-skip-worktree-cleanup.sh +90 -0
  128. package/tools/tests/test-agent-project-codex-live-thread-persist.sh +76 -0
  129. package/tools/tests/test-agent-project-codex-recovery.sh +731 -0
  130. package/tools/tests/test-agent-project-codex-session-wrapper-clears-stale-sandbox-artifacts.sh +105 -0
  131. package/tools/tests/test-agent-project-codex-session-wrapper.sh +97 -0
  132. package/tools/tests/test-agent-project-open-pr-worktree-config-prefix.sh +81 -0
  133. package/tools/tests/test-agent-project-openclaw-session-wrapper-clears-stale-sandbox-artifacts.sh +109 -0
  134. package/tools/tests/test-agent-project-openclaw-session-wrapper-infers-blocked-result-contract.sh +89 -0
  135. package/tools/tests/test-agent-project-openclaw-session-wrapper-recovers-literal-env-artifacts.sh +113 -0
  136. package/tools/tests/test-agent-project-openclaw-session-wrapper-recovers-version-mismatch.sh +135 -0
  137. package/tools/tests/test-agent-project-openclaw-session-wrapper-resident.sh +179 -0
  138. package/tools/tests/test-agent-project-openclaw-session-wrapper-reuses-existing-agent-after-add-race.sh +119 -0
  139. package/tools/tests/test-agent-project-openclaw-session-wrapper-terminates-rate-limit-hang.sh +91 -0
  140. package/tools/tests/test-agent-project-openclaw-session-wrapper.sh +117 -0
  141. package/tools/tests/test-agent-project-publish-issue-pr-prunes-stale-worktree-entry.sh +148 -0
  142. package/tools/tests/test-agent-project-publish-issue-pr-reads-archived-session.sh +146 -0
  143. package/tools/tests/test-agent-project-publish-issue-pr-recovers-final-head.sh +145 -0
  144. package/tools/tests/test-agent-project-publish-issue-pr-reuses-existing-worktree.sh +147 -0
  145. package/tools/tests/test-agent-project-reconcile-failure-reason.sh +456 -0
  146. package/tools/tests/test-agent-project-reconcile-issue-archived-session-fallback.sh +96 -0
  147. package/tools/tests/test-agent-project-reconcile-issue-before-blocked.sh +90 -0
  148. package/tools/tests/test-agent-project-reconcile-issue-host-verification-recovery-uses-recovered-worktree.sh +212 -0
  149. package/tools/tests/test-agent-project-reconcile-issue-host-verification-recovery.sh +207 -0
  150. package/tools/tests/test-agent-project-reconcile-issue-provider-quota-schedules-provider-cooldown.sh +101 -0
  151. package/tools/tests/test-agent-project-reconcile-issue-session-backfills-lane-metadata-from-worker-key.sh +113 -0
  152. package/tools/tests/test-agent-project-reconcile-issue-session-clears-stale-failed-summary.sh +117 -0
  153. package/tools/tests/test-agent-project-reconcile-issue-session-initializes-shared-agent-home.sh +55 -0
  154. package/tools/tests/test-agent-project-reconcile-issue-session-normalizes-runner-state.sh +125 -0
  155. package/tools/tests/test-agent-project-reconcile-issue-session-records-invalid-contract-summary.sh +118 -0
  156. package/tools/tests/test-agent-project-reconcile-issue-session-skips-duplicate-blocked-comment.sh +144 -0
  157. package/tools/tests/test-agent-project-reconcile-issue-session-standardizes-no-commits-blocker.sh +145 -0
  158. package/tools/tests/test-agent-project-reconcile-issue-session-synthesizes-blocked-comment.sh +139 -0
  159. package/tools/tests/test-agent-project-reconcile-pr-blocked-host-recovery.sh +242 -0
  160. package/tools/tests/test-agent-project-reconcile-pr-guard-blocked-no-commit.sh +142 -0
  161. package/tools/tests/test-agent-project-reconcile-pr-provider-quota-schedules-provider-cooldown.sh +106 -0
  162. package/tools/tests/test-agent-project-reconcile-pr-session-initializes-shared-agent-home.sh +66 -0
  163. package/tools/tests/test-agent-project-reconcile-pr-updated-branch-noop.sh +129 -0
  164. package/tools/tests/test-audit-agent-worktrees-active-launch-skips-git-inspection.sh +69 -0
  165. package/tools/tests/test-audit-agent-worktrees-broken-worktree.sh +43 -0
  166. package/tools/tests/test-audit-agent-worktrees-pending-launch-owner.sh +46 -0
  167. package/tools/tests/test-audit-agent-worktrees-unreconciled-owner.sh +79 -0
  168. package/tools/tests/test-audit-issue-routing-managed-branch-globs.sh +56 -0
  169. package/tools/tests/test-branch-verification-guard-generated-artifacts.sh +72 -0
  170. package/tools/tests/test-branch-verification-guard-targeted-coverage.sh +125 -0
  171. package/tools/tests/test-codex-quota-manager-failure-driven-rotation.sh +178 -0
  172. package/tools/tests/test-codex-quota-wrapper.sh +37 -0
  173. package/tools/tests/test-contribution-docs.sh +18 -0
  174. package/tools/tests/test-control-plane-dashboard-runtime-smoke.sh +343 -0
  175. package/tools/tests/test-create-follow-up-issue.sh +73 -0
  176. package/tools/tests/test-dashboard-launchd-bootstrap.sh +55 -0
  177. package/tools/tests/test-flow-export-execution-env-exports-repo-id.sh +30 -0
  178. package/tools/tests/test-flow-export-github-cli-auth-env-prefers-git-credential.sh +48 -0
  179. package/tools/tests/test-flow-github-api-repo-fallback-preserves-input.sh +85 -0
  180. package/tools/tests/test-flow-github-api-repo-prefers-explicit-repository-id.sh +60 -0
  181. package/tools/tests/test-flow-github-issue-list-falls-back-to-repository-id.sh +64 -0
  182. package/tools/tests/test-flow-github-pr-list-falls-back-to-repository-id.sh +77 -0
  183. package/tools/tests/test-flow-resident-can-reuse-does-not-leak-metadata.sh +52 -0
  184. package/tools/tests/test-flow-resident-reap-stale-controllers.sh +63 -0
  185. package/tools/tests/test-flow-resolve-codex-quota-tools.sh +104 -0
  186. package/tools/tests/test-flow-runtime-doctor-profile-selection.sh +27 -0
  187. package/tools/tests/test-heartbeat-codex-pr-linked-issue-exclusion.sh +79 -0
  188. package/tools/tests/test-heartbeat-hooks-enqueue-resident-issue-for-idle-controller.sh +115 -0
  189. package/tools/tests/test-heartbeat-hooks-enqueue-resident-issue-for-live-lane-controller.sh +117 -0
  190. package/tools/tests/test-heartbeat-hooks-start-resident-issue-loop-claude.sh +96 -0
  191. package/tools/tests/test-heartbeat-hooks-start-resident-issue-loop-codex.sh +96 -0
  192. package/tools/tests/test-heartbeat-hooks-start-resident-issue-loop.sh +96 -0
  193. package/tools/tests/test-heartbeat-loop-auth-wait-does-not-consume-capacity.sh +170 -0
  194. package/tools/tests/test-heartbeat-loop-blocked-recovery-lane.sh +201 -0
  195. package/tools/tests/test-heartbeat-loop-blocked-recovery-vs-pr-reservation.sh +201 -0
  196. package/tools/tests/test-heartbeat-loop-idle-resident-controller-does-not-block-launches.sh +160 -0
  197. package/tools/tests/test-heartbeat-loop-pr-launch-dedup.sh +133 -0
  198. package/tools/tests/test-heartbeat-loop-provider-cooldown-suppresses-launches.sh +157 -0
  199. package/tools/tests/test-heartbeat-loop-reaps-stale-resident-controller.sh +181 -0
  200. package/tools/tests/test-heartbeat-loop-waiting-provider-resident-controller-does-not-block-launches.sh +160 -0
  201. package/tools/tests/test-heartbeat-ready-issues-blocked-recovery.sh +134 -0
  202. package/tools/tests/test-heartbeat-safe-auto-dynamic-concurrency.sh +162 -0
  203. package/tools/tests/test-heartbeat-safe-auto-no-tmux-sessions.sh +136 -0
  204. package/tools/tests/test-heartbeat-safe-auto-openclaw-skips-codex-quota.sh +139 -0
  205. package/tools/tests/test-heartbeat-safe-auto-quota-health-signal.sh +119 -0
  206. package/tools/tests/test-heartbeat-safe-auto-stale-shared-loop-pid-does-not-skip.sh +140 -0
  207. package/tools/tests/test-heartbeat-safe-auto-static-capacity-without-quota-cache.sh +142 -0
  208. package/tools/tests/test-heartbeat-safe-auto-zero-healthy-pools.sh +141 -0
  209. package/tools/tests/test-heartbeat-sync-issue-labels-empty-schedule.sh +65 -0
  210. package/tools/tests/test-heartbeat-sync-open-agent-prs-terminal-clears-running.sh +179 -0
  211. package/tools/tests/test-install-dashboard-launchd.sh +78 -0
  212. package/tools/tests/test-install-project-launchd-adds-tool-paths.sh +87 -0
  213. package/tools/tests/test-install-project-launchd.sh +110 -0
  214. package/tools/tests/test-issue-local-workspace-install-policy.sh +81 -0
  215. package/tools/tests/test-issue-publish-scope-guard-docs-signal.sh +70 -0
  216. package/tools/tests/test-issue-reconcile-hooks-success-clears-blocked.sh +36 -0
  217. package/tools/tests/test-kick-scheduler-requires-explicit-profile.sh +47 -0
  218. package/tools/tests/test-label-follow-up-issues-falls-back-to-repository-id.sh +132 -0
  219. package/tools/tests/test-manual-operator-entrypoints-require-explicit-profile.sh +64 -0
  220. package/tools/tests/test-package-funding-metadata.sh +21 -0
  221. package/tools/tests/test-package-public-metadata.sh +62 -0
  222. package/tools/tests/test-placeholder-worker-adapters.sh +38 -0
  223. package/tools/tests/test-pr-reconcile-hooks-refreshes-recurring-issue-checklist.sh +110 -0
  224. package/tools/tests/test-pr-risk-cohesive-mobile-locale-scope.sh +70 -0
  225. package/tools/tests/test-pr-risk-fix-label-semantics.sh +114 -0
  226. package/tools/tests/test-pr-risk-local-first-no-checks.sh +70 -0
  227. package/tools/tests/test-prepare-worktree-simple-repo-baseline.sh +67 -0
  228. package/tools/tests/test-profile-activate.sh +33 -0
  229. package/tools/tests/test-profile-adopt-allow-missing-repo.sh +68 -0
  230. package/tools/tests/test-profile-adopt-skip-workspace-sync-missing-file.sh +61 -0
  231. package/tools/tests/test-profile-adopt-syncs-anchor-and-workspace.sh +90 -0
  232. package/tools/tests/test-profile-smoke-collision.sh +44 -0
  233. package/tools/tests/test-profile-smoke-invalid-claude-config.sh +31 -0
  234. package/tools/tests/test-profile-smoke-invalid-provider-pool.sh +68 -0
  235. package/tools/tests/test-profile-smoke-repo-slug-mismatch.sh +36 -0
  236. package/tools/tests/test-profile-smoke.sh +45 -0
  237. package/tools/tests/test-project-init-force-and-skip-sync.sh +61 -0
  238. package/tools/tests/test-project-init-repo-slug-mismatch.sh +29 -0
  239. package/tools/tests/test-project-init.sh +66 -0
  240. package/tools/tests/test-project-launchd-bootstrap.sh +66 -0
  241. package/tools/tests/test-project-remove.sh +150 -0
  242. package/tools/tests/test-project-runtime-supervisor.sh +47 -0
  243. package/tools/tests/test-project-runtimectl-launchd.sh +115 -0
  244. package/tools/tests/test-project-runtimectl-missing-profile.sh +54 -0
  245. package/tools/tests/test-project-runtimectl-start-falls-back-to-bootstrap.sh +108 -0
  246. package/tools/tests/test-project-runtimectl-status-reports-supervisor-as-heartbeat-parent.sh +95 -0
  247. package/tools/tests/test-project-runtimectl-status-supervisor-running.sh +59 -0
  248. package/tools/tests/test-project-runtimectl-stop-cancels-pending-kick.sh +85 -0
  249. package/tools/tests/test-project-runtimectl-stop-clears-running-labels.sh +78 -0
  250. package/tools/tests/test-project-runtimectl.sh +212 -0
  251. package/tools/tests/test-provider-cooldown-state-prefers-runtime-worker-context.sh +39 -0
  252. package/tools/tests/test-provider-cooldown-state.sh +59 -0
  253. package/tools/tests/test-public-repo-docs.sh +159 -0
  254. package/tools/tests/test-reconcile-pr-worker-acp-config-routing.sh +75 -0
  255. package/tools/tests/test-render-dashboard-snapshot.sh +149 -0
  256. package/tools/tests/test-render-flow-config-demo-profile.sh +36 -0
  257. package/tools/tests/test-render-flow-config-provider-pool-fallback.sh +81 -0
  258. package/tools/tests/test-render-flow-config.sh +52 -0
  259. package/tools/tests/test-run-codex-task-claude-routing.sh +125 -0
  260. package/tools/tests/test-run-codex-task-codex-resident-routing.sh +108 -0
  261. package/tools/tests/test-run-codex-task-kilo-routing.sh +98 -0
  262. package/tools/tests/test-run-codex-task-openclaw-resident-routing.sh +117 -0
  263. package/tools/tests/test-run-codex-task-openclaw-routing.sh +113 -0
  264. package/tools/tests/test-run-codex-task-opencode-routing.sh +98 -0
  265. package/tools/tests/test-run-codex-task-provider-pool-fallback-routing.sh +146 -0
  266. package/tools/tests/test-scaffold-profile.sh +108 -0
  267. package/tools/tests/test-serve-dashboard.sh +93 -0
  268. package/tools/tests/test-start-issue-worker-blocked-context.sh +129 -0
  269. package/tools/tests/test-start-issue-worker-blocks-complete-recurring-checklist.sh +189 -0
  270. package/tools/tests/test-start-issue-worker-local-install-routing.sh +157 -0
  271. package/tools/tests/test-start-issue-worker-profile-template-routing.sh +149 -0
  272. package/tools/tests/test-start-issue-worker-recurring-resident-reuse-codex.sh +212 -0
  273. package/tools/tests/test-start-issue-worker-recurring-resident-reuse.sh +219 -0
  274. package/tools/tests/test-start-issue-worker-renders-verification-snippet.sh +155 -0
  275. package/tools/tests/test-start-issue-worker-resident-reuse-falls-back-to-new-worktree.sh +199 -0
  276. package/tools/tests/test-start-pr-fix-worker-host-blocker-context.sh +275 -0
  277. package/tools/tests/test-start-resident-issue-loop-adopts-next-recurring-issue.sh +185 -0
  278. package/tools/tests/test-start-resident-issue-loop-clears-pending-while-waiting-due.sh +152 -0
  279. package/tools/tests/test-start-resident-issue-loop-consumes-queued-lease.sh +186 -0
  280. package/tools/tests/test-start-resident-issue-loop-fails-over-provider-pool.sh +212 -0
  281. package/tools/tests/test-start-resident-issue-loop-immediate-cycles.sh +148 -0
  282. package/tools/tests/test-start-resident-issue-loop-waits-for-provider.sh +194 -0
  283. package/tools/tests/test-start-resident-issue-loop-waits-for-terminal-reconcile-status.sh +198 -0
  284. package/tools/tests/test-start-resident-issue-loop-yields-to-live-lane-controller.sh +145 -0
  285. package/tools/tests/test-sync-pr-labels-fix-lane-uses-repair-queued.sh +67 -0
  286. package/tools/tests/test-sync-recurring-issue-checklist-backfills-workflow-complete-blocker.sh +70 -0
  287. package/tools/tests/test-sync-recurring-issue-checklist.sh +95 -0
  288. package/tools/tests/test-sync-shared-agent-home-local-source-root.sh +66 -0
  289. package/tools/tests/test-sync-shared-agent-home-preserves-unrelated-workflow-catalog-skill.sh +47 -0
  290. package/tools/tests/test-test-smoke.sh +86 -0
  291. package/tools/tests/test-uninstall-project-launchd.sh +37 -0
  292. package/tools/tests/test-update-github-labels-prefers-sibling-helper.sh +49 -0
  293. package/tools/tests/test-workflow-catalog.sh +43 -0
  294. package/tools/vendor/codex-quota/LICENSE +21 -0
  295. package/tools/vendor/codex-quota/README.md +459 -0
  296. package/tools/vendor/codex-quota/codex-quota.js +261 -0
  297. package/tools/vendor/codex-quota/lib/claude-accounts.js +226 -0
  298. package/tools/vendor/codex-quota/lib/claude-oauth.js +174 -0
  299. package/tools/vendor/codex-quota/lib/claude-tokens.js +471 -0
  300. package/tools/vendor/codex-quota/lib/claude-usage.js +929 -0
  301. package/tools/vendor/codex-quota/lib/codex-accounts.js +205 -0
  302. package/tools/vendor/codex-quota/lib/codex-tokens.js +326 -0
  303. package/tools/vendor/codex-quota/lib/codex-usage.js +32 -0
  304. package/tools/vendor/codex-quota/lib/color.js +72 -0
  305. package/tools/vendor/codex-quota/lib/constants.js +57 -0
  306. package/tools/vendor/codex-quota/lib/container.js +143 -0
  307. package/tools/vendor/codex-quota/lib/display.js +1111 -0
  308. package/tools/vendor/codex-quota/lib/fs.js +63 -0
  309. package/tools/vendor/codex-quota/lib/handlers.js +2060 -0
  310. package/tools/vendor/codex-quota/lib/jwt.js +33 -0
  311. package/tools/vendor/codex-quota/lib/oauth.js +486 -0
  312. package/tools/vendor/codex-quota/lib/paths.js +34 -0
  313. package/tools/vendor/codex-quota/lib/prompts.js +44 -0
  314. package/tools/vendor/codex-quota/lib/sync.js +1438 -0
  315. package/tools/vendor/codex-quota/lib/token-match.js +96 -0
  316. package/tools/vendor/codex-quota-manager/scripts/auto-switch.sh +500 -0
  317. package/tools/vendor/codex-quota-manager/scripts/batch-add.sh +123 -0
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ # shellcheck source=/dev/null
6
+ source "${SCRIPT_DIR}/flow-config-lib.sh"
7
+
8
+ DELAY_SECONDS="${1:-5}"
9
+ WORKSPACE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
10
+ FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
11
+ if ! flow_require_explicit_profile_selection "${FLOW_SKILL_DIR}" "kick-scheduler.sh"; then
12
+ exit 64
13
+ fi
14
+ CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
15
+ REPO_SLUG="$(flow_resolve_repo_slug "${CONFIG_YAML}")"
16
+ STATE_ROOT="$(flow_resolve_state_root "${CONFIG_YAML}")"
17
+ BOOTSTRAP_SCRIPT="${ACP_BOOTSTRAP_SCRIPT:-${F_LOSNING_BOOTSTRAP_SCRIPT:-${AGENT_SCHEDULER_BOOTSTRAP_SCRIPT:-$HOME/.agent-runtime/control-plane/workspace/bin/agent-scheduler-launchd.sh}}}"
18
+ FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
19
+ FLOW_SAFE_AUTO_SCRIPT="${ACP_FLOW_HEARTBEAT_SCRIPT:-${F_LOSNING_FLOW_HEARTBEAT_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/heartbeat-safe-auto.sh}}"
20
+ STATE_DIR="${ACP_SCHEDULER_KICK_STATE_DIR:-${STATE_ROOT}/kick-scheduler}"
21
+ PID_FILE="${STATE_DIR}/pid"
22
+
23
+ mkdir -p "${STATE_DIR}"
24
+
25
+ active_heartbeat_pid() {
26
+ ps -ax -o pid=,command= \
27
+ | while read -r pid command; do
28
+ [[ -n "${pid:-}" ]] || continue
29
+ case "$command" in
30
+ *"${BOOTSTRAP_SCRIPT}"*|*"${WORKSPACE_DIR}/bin/heartbeat-safe-auto.sh"*|*"${FLOW_SAFE_AUTO_SCRIPT}"*|*"agent-project-heartbeat-loop --repo-slug ${REPO_SLUG}"*)
31
+ printf '%s\n' "$pid"
32
+ return 0
33
+ ;;
34
+ esac
35
+ done
36
+ }
37
+
38
+ if active_pid="$(active_heartbeat_pid)"; [[ -n "$active_pid" ]]; then
39
+ printf 'KICK_STATUS=active-heartbeat\n'
40
+ printf 'PID=%s\n' "$active_pid"
41
+ exit 0
42
+ fi
43
+
44
+ if [[ -f "${PID_FILE}" ]]; then
45
+ existing_pid="$(cat "${PID_FILE}" 2>/dev/null || true)"
46
+ if [[ -n "${existing_pid}" ]] && kill -0 "${existing_pid}" 2>/dev/null; then
47
+ printf 'KICK_STATUS=already-pending\n'
48
+ printf 'PID=%s\n' "${existing_pid}"
49
+ exit 0
50
+ fi
51
+ fi
52
+
53
+ export DELAY_SECONDS BOOTSTRAP_SCRIPT FLOW_SAFE_AUTO_SCRIPT PID_FILE REPO_SLUG
54
+ nohup bash -lc '
55
+ trap '\''rm -f "$PID_FILE"'\'' EXIT
56
+ sleep "$DELAY_SECONDS"
57
+ active_pid="$(ps -ax -o pid=,command= | while read -r pid command; do
58
+ [[ -n "${pid:-}" ]] || continue
59
+ case "$command" in
60
+ *"$BOOTSTRAP_SCRIPT"*|*"$FLOW_SAFE_AUTO_SCRIPT"*|*"agent-project-heartbeat-loop --repo-slug $REPO_SLUG"*)
61
+ printf "%s\n" "$pid"
62
+ break
63
+ ;;
64
+ esac
65
+ done)"
66
+ if [[ -n "$active_pid" ]]; then
67
+ exit 0
68
+ fi
69
+ "$BOOTSTRAP_SCRIPT" >/dev/null 2>&1 || true
70
+ ' >/dev/null 2>&1 &
71
+
72
+ bg_pid="$!"
73
+ printf '%s\n' "${bg_pid}" >"${PID_FILE}"
74
+ printf 'KICK_STATUS=scheduled\n'
75
+ printf 'PID=%s\n' "${bg_pid}"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ # shellcheck source=/dev/null
6
+ source "${SCRIPT_DIR}/flow-config-lib.sh"
7
+
8
+ SESSION="${1:?usage: label-follow-up-issues.sh SESSION}"
9
+ CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
10
+ RUNS_ROOT="$(flow_resolve_runs_root "${CONFIG_YAML}")"
11
+ FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
12
+ ADAPTER_BIN_DIR="${FLOW_SKILL_DIR}/bin"
13
+
14
+ ACP_RUNS_ROOT="$RUNS_ROOT" F_LOSNING_RUNS_ROOT="$RUNS_ROOT" "${ADAPTER_BIN_DIR}/label-follow-up-issues.sh" "$SESSION"
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ # shellcheck source=/dev/null
6
+ source "${SCRIPT_DIR}/flow-config-lib.sh"
7
+
8
+ FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
9
+ if ! flow_require_explicit_profile_selection "${FLOW_SKILL_DIR}" "new-pr-worktree.sh"; then
10
+ exit 64
11
+ fi
12
+ FLOW_TOOLS_DIR="${FLOW_SKILL_DIR}/tools/bin"
13
+ flow_export_project_env_aliases
14
+ CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
15
+ AGENT_REPO_ROOT="$(flow_resolve_agent_repo_root "${CONFIG_YAML}")"
16
+ AUTOMATION_REPO_ROOT="$(flow_resolve_repo_root "${CONFIG_YAML}")"
17
+ WORKTREE_ROOT="$(flow_resolve_worktree_root "${CONFIG_YAML}")"
18
+ RETAINED_REPO_ROOT="$(flow_resolve_retained_repo_root "${CONFIG_YAML}")"
19
+ VSCODE_WORKSPACE_FILE="$(flow_resolve_vscode_workspace_file "${CONFIG_YAML}")"
20
+ PR_WORKTREE_BRANCH_PREFIX="$(flow_resolve_pr_worktree_branch_prefix "${CONFIG_YAML}")"
21
+
22
+ PR_NUMBER="${1:?usage: new-pr-worktree.sh PR_NUMBER HEAD_REF}"
23
+ HEAD_REF="${2:?usage: new-pr-worktree.sh PR_NUMBER HEAD_REF}"
24
+
25
+ ACP_AGENT_REPO_ROOT="$AGENT_REPO_ROOT" \
26
+ F_LOSNING_AGENT_REPO_ROOT="$AGENT_REPO_ROOT" \
27
+ "${SCRIPT_DIR}/sync-agent-repo.sh" >/dev/null
28
+
29
+ export ACP_REPO_ROOT="$AUTOMATION_REPO_ROOT"
30
+ export F_LOSNING_REPO_ROOT="$AUTOMATION_REPO_ROOT"
31
+
32
+ WORKTREE_OUT="$(
33
+ bash "${FLOW_TOOLS_DIR}/agent-project-open-pr-worktree" \
34
+ --repo-root "$AGENT_REPO_ROOT" \
35
+ --worktree-root "$WORKTREE_ROOT" \
36
+ --pr-number "$PR_NUMBER" \
37
+ --head-ref "$HEAD_REF" \
38
+ --local-branch-prefix "$PR_WORKTREE_BRANCH_PREFIX" \
39
+ --prepare-script "${SCRIPT_DIR}/prepare-worktree.sh"
40
+ )"
41
+
42
+ ACP_AGENT_REPO_ROOT="$AGENT_REPO_ROOT" \
43
+ ACP_RETAINED_REPO_ROOT="$RETAINED_REPO_ROOT" \
44
+ ACP_VSCODE_WORKSPACE_FILE="$VSCODE_WORKSPACE_FILE" \
45
+ F_LOSNING_AGENT_REPO_ROOT="$AGENT_REPO_ROOT" \
46
+ F_LOSNING_RETAINED_REPO_ROOT="$RETAINED_REPO_ROOT" \
47
+ F_LOSNING_VSCODE_WORKSPACE_FILE="$VSCODE_WORKSPACE_FILE" \
48
+ "${SCRIPT_DIR}/sync-vscode-workspace.sh" >/dev/null 2>&1 || true
49
+
50
+ printf '%s\n' "$WORKTREE_OUT"
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ # shellcheck source=/dev/null
6
+ source "${SCRIPT_DIR}/flow-config-lib.sh"
7
+
8
+ FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
9
+ if ! flow_require_explicit_profile_selection "${FLOW_SKILL_DIR}" "new-worktree.sh"; then
10
+ exit 64
11
+ fi
12
+ CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
13
+ AGENT_REPO_ROOT="$(flow_resolve_agent_repo_root "${CONFIG_YAML}")"
14
+ AUTOMATION_REPO_ROOT="$(flow_resolve_repo_root "${CONFIG_YAML}")"
15
+ WORKTREE_ROOT="$(flow_resolve_worktree_root "${CONFIG_YAML}")"
16
+ RETAINED_REPO_ROOT="$(flow_resolve_retained_repo_root "${CONFIG_YAML}")"
17
+ VSCODE_WORKSPACE_FILE="$(flow_resolve_vscode_workspace_file "${CONFIG_YAML}")"
18
+ FLOW_TOOLS_DIR="${FLOW_SKILL_DIR}/tools/bin"
19
+ ISSUE_BRANCH_PREFIX="$(flow_resolve_issue_branch_prefix "${CONFIG_YAML}")"
20
+
21
+ ISSUE_ID="${1:?usage: new-worktree.sh ISSUE_ID [SLUG]}"
22
+ SLUG_INPUT="${2:-task}"
23
+
24
+ ACP_AGENT_REPO_ROOT="$AGENT_REPO_ROOT" \
25
+ F_LOSNING_AGENT_REPO_ROOT="$AGENT_REPO_ROOT" \
26
+ "${SCRIPT_DIR}/sync-agent-repo.sh" >/dev/null
27
+
28
+ export ACP_REPO_ROOT="$AUTOMATION_REPO_ROOT"
29
+ export F_LOSNING_REPO_ROOT="$AUTOMATION_REPO_ROOT"
30
+
31
+ WORKTREE_OUT="$(
32
+ bash "${FLOW_TOOLS_DIR}/agent-project-open-issue-worktree" \
33
+ --repo-root "$AGENT_REPO_ROOT" \
34
+ --worktree-root "$WORKTREE_ROOT" \
35
+ --issue-id "$ISSUE_ID" \
36
+ --slug "$SLUG_INPUT" \
37
+ --branch-prefix "$ISSUE_BRANCH_PREFIX" \
38
+ --prepare-script "${SCRIPT_DIR}/prepare-worktree.sh"
39
+ )"
40
+
41
+ ACP_AGENT_REPO_ROOT="$AGENT_REPO_ROOT" \
42
+ ACP_RETAINED_REPO_ROOT="$RETAINED_REPO_ROOT" \
43
+ ACP_VSCODE_WORKSPACE_FILE="$VSCODE_WORKSPACE_FILE" \
44
+ F_LOSNING_AGENT_REPO_ROOT="$AGENT_REPO_ROOT" \
45
+ F_LOSNING_RETAINED_REPO_ROOT="$RETAINED_REPO_ROOT" \
46
+ F_LOSNING_VSCODE_WORKSPACE_FILE="$VSCODE_WORKSPACE_FILE" \
47
+ "${SCRIPT_DIR}/sync-vscode-workspace.sh" >/dev/null 2>&1 || true
48
+
49
+ printf '%s\n' "$WORKTREE_OUT"
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ # shellcheck source=/dev/null
6
+ source "${SCRIPT_DIR}/flow-shell-lib.sh"
7
+
8
+ PR_NUMBER="${1:?usage: pr-risk.sh PR_NUMBER}"
9
+ FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
10
+ ADAPTER_BIN_DIR="${FLOW_SKILL_DIR}/bin"
11
+
12
+ "${ADAPTER_BIN_DIR}/pr-risk.sh" "$PR_NUMBER"
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5
+ # shellcheck source=/dev/null
6
+ source "${SCRIPT_DIR}/flow-config-lib.sh"
7
+
8
+ CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
9
+ AGENT_REPO_ROOT="$(flow_resolve_agent_repo_root "${CONFIG_YAML}")"
10
+ CANONICAL_REPO_ROOT="$(flow_resolve_repo_root "${CONFIG_YAML}")"
11
+ DEFAULT_DEPENDENCY_SOURCE_ROOT="$CANONICAL_REPO_ROOT"
12
+ DEPENDENCY_SOURCE_ROOT="${ACP_DEPENDENCY_SOURCE_ROOT:-${F_LOSNING_DEPENDENCY_SOURCE_ROOT:-$DEFAULT_DEPENDENCY_SOURCE_ROOT}}"
13
+ SYNC_DEPENDENCY_BASELINE_SCRIPT="${ACP_SYNC_DEPENDENCY_BASELINE_SCRIPT:-${F_LOSNING_SYNC_DEPENDENCY_BASELINE_SCRIPT:-${SCRIPT_DIR}/sync-dependency-baseline.sh}}"
14
+ PACKAGE_MANAGER_BIN="${ACP_PACKAGE_MANAGER_BIN:-${F_LOSNING_PACKAGE_MANAGER_BIN:-pnpm}}"
15
+ LOCAL_WORKSPACE_INSTALL="${ACP_WORKTREE_LOCAL_INSTALL:-${F_LOSNING_WORKTREE_LOCAL_INSTALL:-false}}"
16
+ WORKTREE="${1:?usage: prepare-worktree.sh WORKTREE}"
17
+
18
+ realpath_safe() {
19
+ local path="${1:-}"
20
+ [[ -n "$path" ]] || return 1
21
+ if command -v python3 >/dev/null 2>&1; then
22
+ python3 - "$path" <<'PY'
23
+ import os
24
+ import sys
25
+ print(os.path.realpath(sys.argv[1]))
26
+ PY
27
+ return
28
+ fi
29
+ cd "$path" 2>/dev/null && pwd -P
30
+ }
31
+
32
+ link_shared_path() {
33
+ local source_path="${1:?source path required}"
34
+ local target_path="${2:?target path required}"
35
+
36
+ [[ -e "$source_path" ]] || return 0
37
+ if [[ -L "$target_path" ]]; then
38
+ return 0
39
+ fi
40
+ if [[ -e "$target_path" ]]; then
41
+ return 0
42
+ fi
43
+
44
+ mkdir -p "$(dirname "$target_path")"
45
+ ln -s "$source_path" "$target_path"
46
+ }
47
+
48
+ dependency_source_ready() {
49
+ local repo_root="${1:?repo root required}"
50
+ local workspace_dir=""
51
+
52
+ [[ -e "$repo_root/node_modules" ]] || return 1
53
+
54
+ while IFS= read -r workspace_dir; do
55
+ [[ -n "$workspace_dir" ]] || continue
56
+ [[ -d "$workspace_dir" ]] || continue
57
+ [[ -e "$workspace_dir/node_modules" ]] || return 1
58
+ done < <(
59
+ find "$repo_root/apps" -mindepth 1 -maxdepth 1 -type d 2>/dev/null || true
60
+ find "$repo_root/packages" -mindepth 1 -maxdepth 1 -type d 2>/dev/null || true
61
+ )
62
+ }
63
+
64
+ link_workspace_node_modules() {
65
+ local dependency_root="${1:?dependency root required}"
66
+ local worktree_root="${2:?worktree root required}"
67
+ local workspace_dir=""
68
+ local relative_path=""
69
+
70
+ while IFS= read -r workspace_dir; do
71
+ [[ -n "$workspace_dir" ]] || continue
72
+ [[ -d "$workspace_dir/node_modules" ]] || continue
73
+ relative_path="${workspace_dir#${dependency_root}/}"
74
+ link_shared_path "$workspace_dir/node_modules" "$worktree_root/$relative_path/node_modules"
75
+ done < <(
76
+ find "$dependency_root/apps" -mindepth 1 -maxdepth 1 -type d 2>/dev/null || true
77
+ find "$dependency_root/packages" -mindepth 1 -maxdepth 1 -type d 2>/dev/null || true
78
+ )
79
+ }
80
+
81
+ configure_worktree_excludes() {
82
+ local worktree="${1:?worktree required}"
83
+ local exclude_file="${worktree}/.openclaw-artifacts/git-exclude"
84
+
85
+ cat >"$exclude_file" <<'EOF'
86
+ node_modules
87
+ apps/*/node_modules
88
+ packages/*/node_modules
89
+ .openclaw-artifacts
90
+ .openclaw
91
+ SOUL.md
92
+ TOOLS.md
93
+ IDENTITY.md
94
+ USER.md
95
+ HEARTBEAT.md
96
+ BOOTSTRAP.md
97
+ .agent-session.env
98
+ EOF
99
+
100
+ git -C "$worktree" config extensions.worktreeConfig true >/dev/null 2>&1 || true
101
+ git -C "$worktree" config --worktree core.excludesFile "$exclude_file"
102
+ }
103
+
104
+ WORKTREE_REAL="$(realpath_safe "$WORKTREE")"
105
+ CANONICAL_REAL="$(realpath_safe "$CANONICAL_REPO_ROOT")"
106
+ DEPENDENCY_REAL="$(realpath_safe "$DEPENDENCY_SOURCE_ROOT")"
107
+
108
+ if [[ -n "$CANONICAL_REAL" && "$WORKTREE_REAL" == "$CANONICAL_REAL" ]]; then
109
+ echo "refusing to prepare canonical checkout as worker worktree: $WORKTREE" >&2
110
+ exit 1
111
+ fi
112
+
113
+ if [[ -n "$DEPENDENCY_REAL" && "$WORKTREE_REAL" == "$DEPENDENCY_REAL" ]]; then
114
+ echo "refusing to prepare retained checkout as worker worktree: $WORKTREE" >&2
115
+ exit 1
116
+ fi
117
+
118
+ mkdir -p "$WORKTREE/.openclaw-artifacts"
119
+ configure_worktree_excludes "$WORKTREE"
120
+
121
+ if [[ -x "$SYNC_DEPENDENCY_BASELINE_SCRIPT" && "$DEPENDENCY_REAL" == "$CANONICAL_REAL" ]]; then
122
+ "$SYNC_DEPENDENCY_BASELINE_SCRIPT" >/dev/null
123
+ fi
124
+
125
+ if [[ "$LOCAL_WORKSPACE_INSTALL" == "true" ]]; then
126
+ (
127
+ cd "$WORKTREE"
128
+ CI=1 "$PACKAGE_MANAGER_BIN" install --frozen-lockfile --prefer-offline
129
+ )
130
+ else
131
+ if ! dependency_source_ready "$DEPENDENCY_SOURCE_ROOT"; then
132
+ echo "dependency source is missing required node_modules or built workspace artifacts: $DEPENDENCY_SOURCE_ROOT" >&2
133
+ exit 1
134
+ fi
135
+ link_shared_path "$DEPENDENCY_SOURCE_ROOT/node_modules" "$WORKTREE/node_modules"
136
+ link_workspace_node_modules "$DEPENDENCY_SOURCE_ROOT" "$WORKTREE"
137
+ fi
138
+
139
+ printf 'WORKTREE=%s\n' "$WORKTREE"
140
+ printf 'SANDBOX_ARTIFACT_DIR=%s\n' "$WORKTREE/.openclaw-artifacts"
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ SCRIPT_PATH="${SCRIPT_DIR}/profile-activate.sh"
6
+ # shellcheck source=/dev/null
7
+ source "${SCRIPT_DIR}/flow-config-lib.sh"
8
+
9
+ usage() {
10
+ cat <<'EOF'
11
+ Usage:
12
+ profile-activate.sh --profile-id <id> [--exports]
13
+
14
+ Print the selected profile context or shell export statements for quickly
15
+ switching operator commands to a specific installed profile.
16
+ EOF
17
+ }
18
+
19
+ profile_id=""
20
+ exports_only="0"
21
+
22
+ while [[ $# -gt 0 ]]; do
23
+ case "$1" in
24
+ --profile-id) profile_id="${2:-}"; shift 2 ;;
25
+ --exports) exports_only="1"; shift ;;
26
+ --help|-h) usage; exit 0 ;;
27
+ *) echo "Unknown argument: $1" >&2; usage >&2; exit 1 ;;
28
+ esac
29
+ done
30
+
31
+ if [[ -z "${profile_id}" ]]; then
32
+ usage >&2
33
+ exit 1
34
+ fi
35
+
36
+ FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
37
+ PROFILE_REGISTRY_ROOT="$(resolve_flow_profile_registry_root)"
38
+ CONFIG_YAML="$(flow_find_profile_dir_by_id "${FLOW_SKILL_DIR}" "${profile_id}")/control-plane.yaml"
39
+ PROFILE_NOTES="$(flow_resolve_profile_notes_file "${CONFIG_YAML}")"
40
+ AVAILABLE_PROFILES="$(flow_list_profile_ids "${FLOW_SKILL_DIR}" | paste -sd, -)"
41
+
42
+ if [[ ! -f "${CONFIG_YAML}" ]]; then
43
+ echo "unknown profile id: ${profile_id}" >&2
44
+ echo "AVAILABLE_PROFILES=${AVAILABLE_PROFILES}" >&2
45
+ exit 1
46
+ fi
47
+
48
+ export ACP_PROJECT_ID="${profile_id}"
49
+ export AGENT_PROJECT_ID="${profile_id}"
50
+ flow_export_execution_env "${CONFIG_YAML}"
51
+
52
+ REPO_SLUG="$(flow_resolve_repo_slug "${CONFIG_YAML}")"
53
+ REPO_ROOT="$(flow_resolve_repo_root "${CONFIG_YAML}")"
54
+ AGENT_ROOT="$(flow_resolve_agent_root "${CONFIG_YAML}")"
55
+ AGENT_REPO_ROOT="$(flow_resolve_agent_repo_root "${CONFIG_YAML}")"
56
+ WORKTREE_ROOT="$(flow_resolve_worktree_root "${CONFIG_YAML}")"
57
+ RUNS_ROOT="$(flow_resolve_runs_root "${CONFIG_YAML}")"
58
+ STATE_ROOT="$(flow_resolve_state_root "${CONFIG_YAML}")"
59
+ CODING_WORKER="${ACP_CODING_WORKER:-${F_LOSNING_CODING_WORKER:-codex}}"
60
+ ACTIVE_PROVIDER_POOL_NAME="${ACP_ACTIVE_PROVIDER_POOL_NAME:-${F_LOSNING_ACTIVE_PROVIDER_POOL_NAME:-}}"
61
+
62
+ if [[ "${exports_only}" == "1" ]]; then
63
+ printf 'export ACP_PROJECT_ID=%q
64
+ ' "${profile_id}"
65
+ printf 'export AGENT_PROJECT_ID=%q
66
+ ' "${profile_id}"
67
+ printf 'export ACP_PROFILE_REGISTRY_ROOT=%q
68
+ ' "${PROFILE_REGISTRY_ROOT}"
69
+ printf 'export ACP_CONFIG=%q
70
+ ' "${CONFIG_YAML}"
71
+ printf 'export ACP_PROFILE_NOTES=%q
72
+ ' "${PROFILE_NOTES}"
73
+ printf 'export ACP_PROFILE_REPO_ROOT=%q
74
+ ' "${REPO_ROOT}"
75
+ printf 'export ACP_PROFILE_AGENT_ROOT=%q
76
+ ' "${AGENT_ROOT}"
77
+ exit 0
78
+ fi
79
+
80
+ printf 'PROFILE_ID=%s
81
+ ' "${profile_id}"
82
+ printf 'PROFILE_REGISTRY_ROOT=%s
83
+ ' "${PROFILE_REGISTRY_ROOT}"
84
+ printf 'CONFIG_YAML=%s
85
+ ' "${CONFIG_YAML}"
86
+ printf 'PROFILE_NOTES=%s
87
+ ' "${PROFILE_NOTES}"
88
+ printf 'AVAILABLE_PROFILES=%s
89
+ ' "${AVAILABLE_PROFILES}"
90
+ printf 'REPO_SLUG=%s
91
+ ' "${REPO_SLUG}"
92
+ printf 'REPO_ROOT=%s
93
+ ' "${REPO_ROOT}"
94
+ printf 'AGENT_ROOT=%s
95
+ ' "${AGENT_ROOT}"
96
+ printf 'AGENT_REPO_ROOT=%s
97
+ ' "${AGENT_REPO_ROOT}"
98
+ printf 'WORKTREE_ROOT=%s
99
+ ' "${WORKTREE_ROOT}"
100
+ printf 'RUNS_ROOT=%s
101
+ ' "${RUNS_ROOT}"
102
+ printf 'STATE_ROOT=%s
103
+ ' "${STATE_ROOT}"
104
+ printf 'CODING_WORKER=%s
105
+ ' "${CODING_WORKER}"
106
+ printf 'ACTIVE_PROVIDER_POOL_NAME=%s
107
+ ' "${ACTIVE_PROVIDER_POOL_NAME}"
108
+ printf 'NEXT_STEP=eval "$(%s --profile-id %s --exports)"
109
+ ' "${SCRIPT_PATH}" "${profile_id}"
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ # shellcheck source=/dev/null
6
+ source "${SCRIPT_DIR}/flow-config-lib.sh"
7
+
8
+ usage() {
9
+ cat <<'EOF'
10
+ Usage:
11
+ profile-adopt.sh [--profile-id <id>] [options]
12
+
13
+ Prepare an available profile for real scheduler use by creating runtime roots,
14
+ seeding the agent anchor repo when possible, syncing the VS Code workspace file,
15
+ and copying the selected installed profile into the runtime root for quick
16
+ operator access.
17
+
18
+ Options:
19
+ --profile-id <id> Profile id to adopt
20
+ --source-repo-root <path> Optional source repo used when seeding the agent repo
21
+ --skip-anchor-sync Do not run sync-agent-repo.sh
22
+ --skip-workspace-sync Do not run sync-vscode-workspace.sh
23
+ --allow-missing-repo Continue when canonical/source repos are missing
24
+ --help Show this help
25
+ EOF
26
+ }
27
+
28
+ profile_id_override=""
29
+ source_repo_root_override=""
30
+ skip_anchor_sync="0"
31
+ skip_workspace_sync="0"
32
+ allow_missing_repo="0"
33
+
34
+ while [[ $# -gt 0 ]]; do
35
+ case "$1" in
36
+ --profile-id) profile_id_override="${2:-}"; shift 2 ;;
37
+ --source-repo-root) source_repo_root_override="${2:-}"; shift 2 ;;
38
+ --skip-anchor-sync) skip_anchor_sync="1"; shift ;;
39
+ --skip-workspace-sync) skip_workspace_sync="1"; shift ;;
40
+ --allow-missing-repo) allow_missing_repo="1"; shift ;;
41
+ --help|-h) usage; exit 0 ;;
42
+ *) echo "Unknown argument: $1" >&2; usage >&2; exit 1 ;;
43
+ esac
44
+ done
45
+
46
+ if [[ -n "$profile_id_override" ]]; then
47
+ export ACP_PROJECT_ID="$profile_id_override"
48
+ export AGENT_PROJECT_ID="$profile_id_override"
49
+ fi
50
+
51
+ FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
52
+ CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
53
+ PROFILE_ID="$(flow_resolve_adapter_id "${CONFIG_YAML}")"
54
+ PROFILE_REGISTRY_ROOT="$(resolve_flow_profile_registry_root)"
55
+ if [[ ! -f "${CONFIG_YAML}" ]]; then
56
+ echo "[profile-adopt] missing installed profile config: ${CONFIG_YAML}" >&2
57
+ exit 1
58
+ fi
59
+
60
+ REPO_SLUG="$(flow_resolve_repo_slug "${CONFIG_YAML}")"
61
+ DEFAULT_BRANCH="$(flow_resolve_default_branch "${CONFIG_YAML}")"
62
+ PROJECT_LABEL="$(flow_resolve_project_label "${CONFIG_YAML}")"
63
+ REPO_ROOT="$(flow_resolve_repo_root "${CONFIG_YAML}")"
64
+ AGENT_REPO_ROOT="$(flow_resolve_agent_repo_root "${CONFIG_YAML}")"
65
+ AGENT_ROOT="$(flow_resolve_agent_root "${CONFIG_YAML}")"
66
+ RUNS_ROOT="$(flow_resolve_runs_root "${CONFIG_YAML}")"
67
+ STATE_ROOT="$(flow_resolve_state_root "${CONFIG_YAML}")"
68
+ HISTORY_ROOT="$(flow_resolve_history_root "${CONFIG_YAML}")"
69
+ WORKTREE_ROOT="$(flow_resolve_worktree_root "${CONFIG_YAML}")"
70
+ RETAINED_REPO_ROOT="$(flow_resolve_retained_repo_root "${CONFIG_YAML}")"
71
+ VSCODE_WORKSPACE_FILE="$(flow_resolve_vscode_workspace_file "${CONFIG_YAML}")"
72
+ REMOTE_NAME="${ACP_REMOTE_NAME:-${F_LOSNING_REMOTE_NAME:-origin}}"
73
+ SOURCE_REPO_ROOT="${source_repo_root_override:-${ACP_SOURCE_REPO_ROOT:-${F_LOSNING_SOURCE_REPO_ROOT:-${RETAINED_REPO_ROOT}}}}"
74
+ PROFILE_LINK="${AGENT_ROOT}/control-plane.yaml"
75
+ WORKSPACE_LINK="${AGENT_ROOT}/workspace.code-workspace"
76
+ INSTALLED_PROFILE_DIR="$(dirname "${CONFIG_YAML}")"
77
+ FLOW_TOOLS_DIR="${FLOW_SKILL_DIR}/tools/bin"
78
+ PROFILE_SMOKE_SCRIPT="${FLOW_TOOLS_DIR}/profile-smoke.sh"
79
+ SYNC_AGENT_REPO_SCRIPT="${FLOW_TOOLS_DIR}/sync-agent-repo.sh"
80
+ SYNC_VSCODE_WORKSPACE_SCRIPT="${FLOW_TOOLS_DIR}/sync-vscode-workspace.sh"
81
+
82
+ canonical_copy_source() {
83
+ local target_path="${1:-}"
84
+ local target_dir=""
85
+ local target_name=""
86
+
87
+ [[ -n "$target_path" ]] || return 1
88
+ target_dir="$(dirname "$target_path")"
89
+ target_name="$(basename "$target_path")"
90
+ target_dir="$(cd "$target_dir" && pwd -P)"
91
+ printf '%s/%s\n' "$target_dir" "$target_name"
92
+ }
93
+
94
+ path_status() {
95
+ local path="${1:-}"
96
+ if [[ -z "$path" ]]; then
97
+ printf 'missing\n'
98
+ elif [[ -d "$path/.git" || -f "$path/.git" ]]; then
99
+ printf 'git\n'
100
+ elif [[ -e "$path" ]]; then
101
+ printf 'exists\n'
102
+ else
103
+ printf 'missing\n'
104
+ fi
105
+ }
106
+
107
+ repo_has_remote() {
108
+ local repo_root="${1:-}"
109
+ local remote_name="${2:-origin}"
110
+ [[ -n "$repo_root" ]] || return 1
111
+ [[ -d "$repo_root/.git" || -f "$repo_root/.git" ]] || return 1
112
+ git -C "$repo_root" remote get-url "$remote_name" >/dev/null 2>&1
113
+ }
114
+
115
+ if ! smoke_output="$(ACP_PROJECT_ID="$PROFILE_ID" bash "$PROFILE_SMOKE_SCRIPT" --profile-id "$PROFILE_ID" 2>&1)"; then
116
+ printf '%s\n' "$smoke_output" >&2
117
+ exit 1
118
+ fi
119
+
120
+ mkdir -p "$AGENT_ROOT" "$RUNS_ROOT" "$STATE_ROOT" "$HISTORY_ROOT" "$WORKTREE_ROOT" "$(dirname "$VSCODE_WORKSPACE_FILE")"
121
+ copy_file_into_runtime() {
122
+ local source_file="${1:?source file required}"
123
+ local target_file="${2:?target file required}"
124
+ mkdir -p "$(dirname "$target_file")"
125
+ if [[ -L "$target_file" || -f "$target_file" ]]; then
126
+ rm -f "$target_file"
127
+ elif [[ -d "$target_file" ]]; then
128
+ rm -rf "$target_file"
129
+ fi
130
+ cp "$source_file" "$target_file"
131
+ }
132
+
133
+ copy_file_into_runtime "$(canonical_copy_source "$CONFIG_YAML")" "$PROFILE_LINK"
134
+
135
+ warnings=0
136
+ anchor_sync_status="skipped"
137
+ workspace_sync_status="skipped"
138
+
139
+ canonical_repo_status="$(path_status "$REPO_ROOT")"
140
+ source_repo_status="$(path_status "$SOURCE_REPO_ROOT")"
141
+ agent_repo_status_before="$(path_status "$AGENT_REPO_ROOT")"
142
+
143
+ if [[ "$skip_anchor_sync" == "1" ]]; then
144
+ anchor_sync_status="skipped"
145
+ else
146
+ if repo_has_remote "$REPO_ROOT" "$REMOTE_NAME" || repo_has_remote "$SOURCE_REPO_ROOT" "$REMOTE_NAME"; then
147
+ ACP_PROJECT_ID="$PROFILE_ID" \
148
+ ACP_REPO_ROOT="$REPO_ROOT" \
149
+ ACP_AGENT_REPO_ROOT="$AGENT_REPO_ROOT" \
150
+ ACP_RETAINED_REPO_ROOT="$RETAINED_REPO_ROOT" \
151
+ ACP_SOURCE_REPO_ROOT="$SOURCE_REPO_ROOT" \
152
+ ACP_DEFAULT_BRANCH="$DEFAULT_BRANCH" \
153
+ ACP_REMOTE_NAME="$REMOTE_NAME" \
154
+ bash "$SYNC_AGENT_REPO_SCRIPT" >/dev/null
155
+ anchor_sync_status="ok"
156
+ elif [[ "$allow_missing_repo" == "1" ]]; then
157
+ anchor_sync_status="skipped-missing-repo"
158
+ warnings=$((warnings + 1))
159
+ else
160
+ echo "[profile-adopt] no Git source with remote '${REMOTE_NAME}' for profile ${PROFILE_ID}" >&2
161
+ exit 1
162
+ fi
163
+ fi
164
+
165
+ if [[ "$skip_workspace_sync" == "1" ]]; then
166
+ workspace_sync_status="skipped"
167
+ else
168
+ ACP_PROJECT_ID="$PROFILE_ID" \
169
+ ACP_REPO_ROOT="$REPO_ROOT" \
170
+ ACP_AGENT_REPO_ROOT="$AGENT_REPO_ROOT" \
171
+ ACP_RETAINED_REPO_ROOT="$RETAINED_REPO_ROOT" \
172
+ ACP_VSCODE_WORKSPACE_FILE="$VSCODE_WORKSPACE_FILE" \
173
+ ACP_DEFAULT_BRANCH="$DEFAULT_BRANCH" \
174
+ bash "$SYNC_VSCODE_WORKSPACE_SCRIPT" >/dev/null
175
+ workspace_sync_status="ok"
176
+ fi
177
+
178
+ if [[ -f "$VSCODE_WORKSPACE_FILE" ]]; then
179
+ copy_file_into_runtime "$(canonical_copy_source "$VSCODE_WORKSPACE_FILE")" "$WORKSPACE_LINK"
180
+ else
181
+ rm -f "$WORKSPACE_LINK"
182
+ fi
183
+
184
+ agent_repo_status_after="$(path_status "$AGENT_REPO_ROOT")"
185
+ workspace_file_status="$(path_status "$VSCODE_WORKSPACE_FILE")"
186
+ adopt_status="ok"
187
+ if (( warnings > 0 )); then
188
+ adopt_status="ok-with-warnings"
189
+ fi
190
+
191
+ printf 'PROFILE_ID=%s\n' "$PROFILE_ID"
192
+ printf 'PROJECT_LABEL=%s\n' "$PROJECT_LABEL"
193
+ printf 'PROFILE_REGISTRY_ROOT=%s\n' "$PROFILE_REGISTRY_ROOT"
194
+ printf 'INSTALLED_PROFILE_DIR=%s\n' "$INSTALLED_PROFILE_DIR"
195
+ printf 'CONFIG_YAML=%s\n' "$CONFIG_YAML"
196
+ printf 'REPO_SLUG=%s\n' "$REPO_SLUG"
197
+ printf 'DEFAULT_BRANCH=%s\n' "$DEFAULT_BRANCH"
198
+ printf 'REMOTE_NAME=%s\n' "$REMOTE_NAME"
199
+ printf 'REPO_ROOT=%s\n' "$REPO_ROOT"
200
+ printf 'SOURCE_REPO_ROOT=%s\n' "$SOURCE_REPO_ROOT"
201
+ printf 'AGENT_REPO_ROOT=%s\n' "$AGENT_REPO_ROOT"
202
+ printf 'AGENT_ROOT=%s\n' "$AGENT_ROOT"
203
+ printf 'RUNS_ROOT=%s\n' "$RUNS_ROOT"
204
+ printf 'STATE_ROOT=%s\n' "$STATE_ROOT"
205
+ printf 'HISTORY_ROOT=%s\n' "$HISTORY_ROOT"
206
+ printf 'WORKTREE_ROOT=%s\n' "$WORKTREE_ROOT"
207
+ printf 'VSCODE_WORKSPACE_FILE=%s\n' "$VSCODE_WORKSPACE_FILE"
208
+ printf 'PROFILE_LINK=%s\n' "$PROFILE_LINK"
209
+ printf 'WORKSPACE_LINK=%s\n' "$WORKSPACE_LINK"
210
+ printf 'CANONICAL_REPO_STATUS=%s\n' "$canonical_repo_status"
211
+ printf 'SOURCE_REPO_STATUS=%s\n' "$source_repo_status"
212
+ printf 'AGENT_REPO_STATUS_BEFORE=%s\n' "$agent_repo_status_before"
213
+ printf 'AGENT_REPO_STATUS_AFTER=%s\n' "$agent_repo_status_after"
214
+ printf 'WORKSPACE_FILE_STATUS=%s\n' "$workspace_file_status"
215
+ printf 'PROFILE_SMOKE_STATUS=ok\n'
216
+ printf 'ANCHOR_SYNC_STATUS=%s\n' "$anchor_sync_status"
217
+ printf 'WORKSPACE_SYNC_STATUS=%s\n' "$workspace_sync_status"
218
+ printf 'WARNING_COUNT=%s\n' "$warnings"
219
+ printf 'ADOPT_STATUS=%s\n' "$adopt_status"