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.
- package/LICENSE +21 -0
- package/README.md +589 -0
- package/SKILL.md +149 -0
- package/assets/workflow-catalog.json +57 -0
- package/bin/audit-issue-routing.sh +74 -0
- package/bin/issue-resource-class.sh +58 -0
- package/bin/label-follow-up-issues.sh +114 -0
- package/bin/pr-risk.sh +532 -0
- package/bin/sync-pr-labels.sh +112 -0
- package/hooks/heartbeat-hooks.sh +573 -0
- package/hooks/issue-reconcile-hooks.sh +217 -0
- package/hooks/pr-reconcile-hooks.sh +225 -0
- package/npm/bin/agent-control-plane.js +1984 -0
- package/npm/public-bin/agent-control-plane +3 -0
- package/package.json +61 -0
- package/tools/bin/agent-cleanup-worktree +247 -0
- package/tools/bin/agent-github-update-labels +66 -0
- package/tools/bin/agent-init-worktree +216 -0
- package/tools/bin/agent-project-archive-run +52 -0
- package/tools/bin/agent-project-capture-worker +46 -0
- package/tools/bin/agent-project-catch-up-merged-prs +137 -0
- package/tools/bin/agent-project-cleanup-session +244 -0
- package/tools/bin/agent-project-detached-launch +107 -0
- package/tools/bin/agent-project-heartbeat-loop +2347 -0
- package/tools/bin/agent-project-open-issue-worktree +89 -0
- package/tools/bin/agent-project-open-pr-worktree +80 -0
- package/tools/bin/agent-project-publish-issue-pr +349 -0
- package/tools/bin/agent-project-reconcile-issue-session +1128 -0
- package/tools/bin/agent-project-reconcile-pr-session +1005 -0
- package/tools/bin/agent-project-retry-state +147 -0
- package/tools/bin/agent-project-run-claude-session +657 -0
- package/tools/bin/agent-project-run-codex-resilient +718 -0
- package/tools/bin/agent-project-run-codex-session +316 -0
- package/tools/bin/agent-project-run-kilo-session +27 -0
- package/tools/bin/agent-project-run-openclaw-session +984 -0
- package/tools/bin/agent-project-run-opencode-session +27 -0
- package/tools/bin/agent-project-sync-anchor-repo +128 -0
- package/tools/bin/agent-project-worker-status +143 -0
- package/tools/bin/audit-agent-worktrees.sh +310 -0
- package/tools/bin/audit-issue-routing.sh +11 -0
- package/tools/bin/audit-retained-layout.sh +58 -0
- package/tools/bin/audit-retained-overlap.sh +135 -0
- package/tools/bin/audit-retained-worktrees.sh +228 -0
- package/tools/bin/branch-verification-guard.sh +351 -0
- package/tools/bin/capture-worker.sh +18 -0
- package/tools/bin/check-skill-contracts.sh +324 -0
- package/tools/bin/cleanup-worktree.sh +44 -0
- package/tools/bin/codex-quota +31 -0
- package/tools/bin/create-follow-up-issue.sh +114 -0
- package/tools/bin/dashboard-launchd-bootstrap.sh +38 -0
- package/tools/bin/flow-config-lib.sh +2127 -0
- package/tools/bin/flow-resident-worker-lib.sh +683 -0
- package/tools/bin/flow-runtime-doctor.sh +97 -0
- package/tools/bin/flow-shell-lib.sh +266 -0
- package/tools/bin/heartbeat-recovery-preflight.sh +106 -0
- package/tools/bin/heartbeat-safe-auto.sh +551 -0
- package/tools/bin/install-dashboard-launchd.sh +152 -0
- package/tools/bin/install-project-launchd.sh +219 -0
- package/tools/bin/issue-publish-scope-guard.sh +242 -0
- package/tools/bin/issue-requires-local-workspace-install.sh +31 -0
- package/tools/bin/issue-resource-class.sh +12 -0
- package/tools/bin/kick-scheduler.sh +75 -0
- package/tools/bin/label-follow-up-issues.sh +14 -0
- package/tools/bin/new-pr-worktree.sh +50 -0
- package/tools/bin/new-worktree.sh +49 -0
- package/tools/bin/pr-risk.sh +12 -0
- package/tools/bin/prepare-worktree.sh +140 -0
- package/tools/bin/profile-activate.sh +109 -0
- package/tools/bin/profile-adopt.sh +219 -0
- package/tools/bin/profile-smoke.sh +461 -0
- package/tools/bin/project-init.sh +189 -0
- package/tools/bin/project-launchd-bootstrap.sh +54 -0
- package/tools/bin/project-remove.sh +155 -0
- package/tools/bin/project-runtime-supervisor.sh +56 -0
- package/tools/bin/project-runtimectl.sh +586 -0
- package/tools/bin/provider-cooldown-state.sh +166 -0
- package/tools/bin/publish-issue-worker.sh +31 -0
- package/tools/bin/reconcile-issue-worker.sh +34 -0
- package/tools/bin/reconcile-pr-worker.sh +34 -0
- package/tools/bin/record-verification.sh +71 -0
- package/tools/bin/render-architecture-infographics.sh +110 -0
- package/tools/bin/render-dashboard-demo-media.sh +333 -0
- package/tools/bin/render-dashboard-snapshot.py +16 -0
- package/tools/bin/render-flow-config.sh +86 -0
- package/tools/bin/retry-state.sh +31 -0
- package/tools/bin/reuse-issue-worktree.sh +75 -0
- package/tools/bin/run-codex-bypass.sh +3 -0
- package/tools/bin/run-codex-safe.sh +3 -0
- package/tools/bin/run-codex-task.sh +231 -0
- package/tools/bin/scaffold-profile.sh +374 -0
- package/tools/bin/serve-dashboard.sh +5 -0
- package/tools/bin/split-retained-slice.sh +124 -0
- package/tools/bin/start-issue-worker.sh +796 -0
- package/tools/bin/start-pr-fix-worker.sh +458 -0
- package/tools/bin/start-pr-merge-repair-worker.sh +8 -0
- package/tools/bin/start-pr-review-worker.sh +227 -0
- package/tools/bin/start-resident-issue-loop.sh +908 -0
- package/tools/bin/sync-agent-repo.sh +52 -0
- package/tools/bin/sync-dependency-baseline.sh +247 -0
- package/tools/bin/sync-pr-labels.sh +12 -0
- package/tools/bin/sync-recurring-issue-checklist.sh +274 -0
- package/tools/bin/sync-shared-agent-home.sh +214 -0
- package/tools/bin/sync-vscode-workspace.sh +157 -0
- package/tools/bin/test-smoke.sh +63 -0
- package/tools/bin/uninstall-project-launchd.sh +55 -0
- package/tools/bin/update-github-labels.sh +14 -0
- package/tools/bin/worker-status.sh +19 -0
- package/tools/bin/workflow-catalog.sh +77 -0
- package/tools/dashboard/app.js +286 -0
- package/tools/dashboard/dashboard_snapshot.py +466 -0
- package/tools/dashboard/index.html +41 -0
- package/tools/dashboard/server.py +64 -0
- package/tools/dashboard/styles.css +351 -0
- package/tools/templates/issue-prompt-template.md +109 -0
- package/tools/templates/pr-fix-template.md +120 -0
- package/tools/templates/pr-merge-repair-template.md +91 -0
- package/tools/templates/pr-review-template.md +62 -0
- package/tools/templates/scheduled-issue-prompt-template.md +62 -0
- package/tools/tests/test-agent-control-plane-npm-cli.sh +279 -0
- package/tools/tests/test-agent-github-update-labels-falls-back-to-repository-id.sh +56 -0
- package/tools/tests/test-agent-project-claude-session-wrapper-clears-stale-sandbox-artifacts.sh +89 -0
- package/tools/tests/test-agent-project-claude-session-wrapper-does-not-retry-provider-quota.sh +82 -0
- package/tools/tests/test-agent-project-claude-session-wrapper-retries-transient-failures.sh +90 -0
- package/tools/tests/test-agent-project-claude-session-wrapper-times-out.sh +73 -0
- package/tools/tests/test-agent-project-claude-session-wrapper.sh +103 -0
- package/tools/tests/test-agent-project-cleanup-session-orphan-fallback.sh +90 -0
- package/tools/tests/test-agent-project-cleanup-session-skip-worktree-cleanup.sh +90 -0
- package/tools/tests/test-agent-project-codex-live-thread-persist.sh +76 -0
- package/tools/tests/test-agent-project-codex-recovery.sh +731 -0
- package/tools/tests/test-agent-project-codex-session-wrapper-clears-stale-sandbox-artifacts.sh +105 -0
- package/tools/tests/test-agent-project-codex-session-wrapper.sh +97 -0
- package/tools/tests/test-agent-project-open-pr-worktree-config-prefix.sh +81 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-clears-stale-sandbox-artifacts.sh +109 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-infers-blocked-result-contract.sh +89 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-recovers-literal-env-artifacts.sh +113 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-recovers-version-mismatch.sh +135 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-resident.sh +179 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-reuses-existing-agent-after-add-race.sh +119 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-terminates-rate-limit-hang.sh +91 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper.sh +117 -0
- package/tools/tests/test-agent-project-publish-issue-pr-prunes-stale-worktree-entry.sh +148 -0
- package/tools/tests/test-agent-project-publish-issue-pr-reads-archived-session.sh +146 -0
- package/tools/tests/test-agent-project-publish-issue-pr-recovers-final-head.sh +145 -0
- package/tools/tests/test-agent-project-publish-issue-pr-reuses-existing-worktree.sh +147 -0
- package/tools/tests/test-agent-project-reconcile-failure-reason.sh +456 -0
- package/tools/tests/test-agent-project-reconcile-issue-archived-session-fallback.sh +96 -0
- package/tools/tests/test-agent-project-reconcile-issue-before-blocked.sh +90 -0
- package/tools/tests/test-agent-project-reconcile-issue-host-verification-recovery-uses-recovered-worktree.sh +212 -0
- package/tools/tests/test-agent-project-reconcile-issue-host-verification-recovery.sh +207 -0
- package/tools/tests/test-agent-project-reconcile-issue-provider-quota-schedules-provider-cooldown.sh +101 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-backfills-lane-metadata-from-worker-key.sh +113 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-clears-stale-failed-summary.sh +117 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-initializes-shared-agent-home.sh +55 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-normalizes-runner-state.sh +125 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-records-invalid-contract-summary.sh +118 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-skips-duplicate-blocked-comment.sh +144 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-standardizes-no-commits-blocker.sh +145 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-synthesizes-blocked-comment.sh +139 -0
- package/tools/tests/test-agent-project-reconcile-pr-blocked-host-recovery.sh +242 -0
- package/tools/tests/test-agent-project-reconcile-pr-guard-blocked-no-commit.sh +142 -0
- package/tools/tests/test-agent-project-reconcile-pr-provider-quota-schedules-provider-cooldown.sh +106 -0
- package/tools/tests/test-agent-project-reconcile-pr-session-initializes-shared-agent-home.sh +66 -0
- package/tools/tests/test-agent-project-reconcile-pr-updated-branch-noop.sh +129 -0
- package/tools/tests/test-audit-agent-worktrees-active-launch-skips-git-inspection.sh +69 -0
- package/tools/tests/test-audit-agent-worktrees-broken-worktree.sh +43 -0
- package/tools/tests/test-audit-agent-worktrees-pending-launch-owner.sh +46 -0
- package/tools/tests/test-audit-agent-worktrees-unreconciled-owner.sh +79 -0
- package/tools/tests/test-audit-issue-routing-managed-branch-globs.sh +56 -0
- package/tools/tests/test-branch-verification-guard-generated-artifacts.sh +72 -0
- package/tools/tests/test-branch-verification-guard-targeted-coverage.sh +125 -0
- package/tools/tests/test-codex-quota-manager-failure-driven-rotation.sh +178 -0
- package/tools/tests/test-codex-quota-wrapper.sh +37 -0
- package/tools/tests/test-contribution-docs.sh +18 -0
- package/tools/tests/test-control-plane-dashboard-runtime-smoke.sh +343 -0
- package/tools/tests/test-create-follow-up-issue.sh +73 -0
- package/tools/tests/test-dashboard-launchd-bootstrap.sh +55 -0
- package/tools/tests/test-flow-export-execution-env-exports-repo-id.sh +30 -0
- package/tools/tests/test-flow-export-github-cli-auth-env-prefers-git-credential.sh +48 -0
- package/tools/tests/test-flow-github-api-repo-fallback-preserves-input.sh +85 -0
- package/tools/tests/test-flow-github-api-repo-prefers-explicit-repository-id.sh +60 -0
- package/tools/tests/test-flow-github-issue-list-falls-back-to-repository-id.sh +64 -0
- package/tools/tests/test-flow-github-pr-list-falls-back-to-repository-id.sh +77 -0
- package/tools/tests/test-flow-resident-can-reuse-does-not-leak-metadata.sh +52 -0
- package/tools/tests/test-flow-resident-reap-stale-controllers.sh +63 -0
- package/tools/tests/test-flow-resolve-codex-quota-tools.sh +104 -0
- package/tools/tests/test-flow-runtime-doctor-profile-selection.sh +27 -0
- package/tools/tests/test-heartbeat-codex-pr-linked-issue-exclusion.sh +79 -0
- package/tools/tests/test-heartbeat-hooks-enqueue-resident-issue-for-idle-controller.sh +115 -0
- package/tools/tests/test-heartbeat-hooks-enqueue-resident-issue-for-live-lane-controller.sh +117 -0
- package/tools/tests/test-heartbeat-hooks-start-resident-issue-loop-claude.sh +96 -0
- package/tools/tests/test-heartbeat-hooks-start-resident-issue-loop-codex.sh +96 -0
- package/tools/tests/test-heartbeat-hooks-start-resident-issue-loop.sh +96 -0
- package/tools/tests/test-heartbeat-loop-auth-wait-does-not-consume-capacity.sh +170 -0
- package/tools/tests/test-heartbeat-loop-blocked-recovery-lane.sh +201 -0
- package/tools/tests/test-heartbeat-loop-blocked-recovery-vs-pr-reservation.sh +201 -0
- package/tools/tests/test-heartbeat-loop-idle-resident-controller-does-not-block-launches.sh +160 -0
- package/tools/tests/test-heartbeat-loop-pr-launch-dedup.sh +133 -0
- package/tools/tests/test-heartbeat-loop-provider-cooldown-suppresses-launches.sh +157 -0
- package/tools/tests/test-heartbeat-loop-reaps-stale-resident-controller.sh +181 -0
- package/tools/tests/test-heartbeat-loop-waiting-provider-resident-controller-does-not-block-launches.sh +160 -0
- package/tools/tests/test-heartbeat-ready-issues-blocked-recovery.sh +134 -0
- package/tools/tests/test-heartbeat-safe-auto-dynamic-concurrency.sh +162 -0
- package/tools/tests/test-heartbeat-safe-auto-no-tmux-sessions.sh +136 -0
- package/tools/tests/test-heartbeat-safe-auto-openclaw-skips-codex-quota.sh +139 -0
- package/tools/tests/test-heartbeat-safe-auto-quota-health-signal.sh +119 -0
- package/tools/tests/test-heartbeat-safe-auto-stale-shared-loop-pid-does-not-skip.sh +140 -0
- package/tools/tests/test-heartbeat-safe-auto-static-capacity-without-quota-cache.sh +142 -0
- package/tools/tests/test-heartbeat-safe-auto-zero-healthy-pools.sh +141 -0
- package/tools/tests/test-heartbeat-sync-issue-labels-empty-schedule.sh +65 -0
- package/tools/tests/test-heartbeat-sync-open-agent-prs-terminal-clears-running.sh +179 -0
- package/tools/tests/test-install-dashboard-launchd.sh +78 -0
- package/tools/tests/test-install-project-launchd-adds-tool-paths.sh +87 -0
- package/tools/tests/test-install-project-launchd.sh +110 -0
- package/tools/tests/test-issue-local-workspace-install-policy.sh +81 -0
- package/tools/tests/test-issue-publish-scope-guard-docs-signal.sh +70 -0
- package/tools/tests/test-issue-reconcile-hooks-success-clears-blocked.sh +36 -0
- package/tools/tests/test-kick-scheduler-requires-explicit-profile.sh +47 -0
- package/tools/tests/test-label-follow-up-issues-falls-back-to-repository-id.sh +132 -0
- package/tools/tests/test-manual-operator-entrypoints-require-explicit-profile.sh +64 -0
- package/tools/tests/test-package-funding-metadata.sh +21 -0
- package/tools/tests/test-package-public-metadata.sh +62 -0
- package/tools/tests/test-placeholder-worker-adapters.sh +38 -0
- package/tools/tests/test-pr-reconcile-hooks-refreshes-recurring-issue-checklist.sh +110 -0
- package/tools/tests/test-pr-risk-cohesive-mobile-locale-scope.sh +70 -0
- package/tools/tests/test-pr-risk-fix-label-semantics.sh +114 -0
- package/tools/tests/test-pr-risk-local-first-no-checks.sh +70 -0
- package/tools/tests/test-prepare-worktree-simple-repo-baseline.sh +67 -0
- package/tools/tests/test-profile-activate.sh +33 -0
- package/tools/tests/test-profile-adopt-allow-missing-repo.sh +68 -0
- package/tools/tests/test-profile-adopt-skip-workspace-sync-missing-file.sh +61 -0
- package/tools/tests/test-profile-adopt-syncs-anchor-and-workspace.sh +90 -0
- package/tools/tests/test-profile-smoke-collision.sh +44 -0
- package/tools/tests/test-profile-smoke-invalid-claude-config.sh +31 -0
- package/tools/tests/test-profile-smoke-invalid-provider-pool.sh +68 -0
- package/tools/tests/test-profile-smoke-repo-slug-mismatch.sh +36 -0
- package/tools/tests/test-profile-smoke.sh +45 -0
- package/tools/tests/test-project-init-force-and-skip-sync.sh +61 -0
- package/tools/tests/test-project-init-repo-slug-mismatch.sh +29 -0
- package/tools/tests/test-project-init.sh +66 -0
- package/tools/tests/test-project-launchd-bootstrap.sh +66 -0
- package/tools/tests/test-project-remove.sh +150 -0
- package/tools/tests/test-project-runtime-supervisor.sh +47 -0
- package/tools/tests/test-project-runtimectl-launchd.sh +115 -0
- package/tools/tests/test-project-runtimectl-missing-profile.sh +54 -0
- package/tools/tests/test-project-runtimectl-start-falls-back-to-bootstrap.sh +108 -0
- package/tools/tests/test-project-runtimectl-status-reports-supervisor-as-heartbeat-parent.sh +95 -0
- package/tools/tests/test-project-runtimectl-status-supervisor-running.sh +59 -0
- package/tools/tests/test-project-runtimectl-stop-cancels-pending-kick.sh +85 -0
- package/tools/tests/test-project-runtimectl-stop-clears-running-labels.sh +78 -0
- package/tools/tests/test-project-runtimectl.sh +212 -0
- package/tools/tests/test-provider-cooldown-state-prefers-runtime-worker-context.sh +39 -0
- package/tools/tests/test-provider-cooldown-state.sh +59 -0
- package/tools/tests/test-public-repo-docs.sh +159 -0
- package/tools/tests/test-reconcile-pr-worker-acp-config-routing.sh +75 -0
- package/tools/tests/test-render-dashboard-snapshot.sh +149 -0
- package/tools/tests/test-render-flow-config-demo-profile.sh +36 -0
- package/tools/tests/test-render-flow-config-provider-pool-fallback.sh +81 -0
- package/tools/tests/test-render-flow-config.sh +52 -0
- package/tools/tests/test-run-codex-task-claude-routing.sh +125 -0
- package/tools/tests/test-run-codex-task-codex-resident-routing.sh +108 -0
- package/tools/tests/test-run-codex-task-kilo-routing.sh +98 -0
- package/tools/tests/test-run-codex-task-openclaw-resident-routing.sh +117 -0
- package/tools/tests/test-run-codex-task-openclaw-routing.sh +113 -0
- package/tools/tests/test-run-codex-task-opencode-routing.sh +98 -0
- package/tools/tests/test-run-codex-task-provider-pool-fallback-routing.sh +146 -0
- package/tools/tests/test-scaffold-profile.sh +108 -0
- package/tools/tests/test-serve-dashboard.sh +93 -0
- package/tools/tests/test-start-issue-worker-blocked-context.sh +129 -0
- package/tools/tests/test-start-issue-worker-blocks-complete-recurring-checklist.sh +189 -0
- package/tools/tests/test-start-issue-worker-local-install-routing.sh +157 -0
- package/tools/tests/test-start-issue-worker-profile-template-routing.sh +149 -0
- package/tools/tests/test-start-issue-worker-recurring-resident-reuse-codex.sh +212 -0
- package/tools/tests/test-start-issue-worker-recurring-resident-reuse.sh +219 -0
- package/tools/tests/test-start-issue-worker-renders-verification-snippet.sh +155 -0
- package/tools/tests/test-start-issue-worker-resident-reuse-falls-back-to-new-worktree.sh +199 -0
- package/tools/tests/test-start-pr-fix-worker-host-blocker-context.sh +275 -0
- package/tools/tests/test-start-resident-issue-loop-adopts-next-recurring-issue.sh +185 -0
- package/tools/tests/test-start-resident-issue-loop-clears-pending-while-waiting-due.sh +152 -0
- package/tools/tests/test-start-resident-issue-loop-consumes-queued-lease.sh +186 -0
- package/tools/tests/test-start-resident-issue-loop-fails-over-provider-pool.sh +212 -0
- package/tools/tests/test-start-resident-issue-loop-immediate-cycles.sh +148 -0
- package/tools/tests/test-start-resident-issue-loop-waits-for-provider.sh +194 -0
- package/tools/tests/test-start-resident-issue-loop-waits-for-terminal-reconcile-status.sh +198 -0
- package/tools/tests/test-start-resident-issue-loop-yields-to-live-lane-controller.sh +145 -0
- package/tools/tests/test-sync-pr-labels-fix-lane-uses-repair-queued.sh +67 -0
- package/tools/tests/test-sync-recurring-issue-checklist-backfills-workflow-complete-blocker.sh +70 -0
- package/tools/tests/test-sync-recurring-issue-checklist.sh +95 -0
- package/tools/tests/test-sync-shared-agent-home-local-source-root.sh +66 -0
- package/tools/tests/test-sync-shared-agent-home-preserves-unrelated-workflow-catalog-skill.sh +47 -0
- package/tools/tests/test-test-smoke.sh +86 -0
- package/tools/tests/test-uninstall-project-launchd.sh +37 -0
- package/tools/tests/test-update-github-labels-prefers-sibling-helper.sh +49 -0
- package/tools/tests/test-workflow-catalog.sh +43 -0
- package/tools/vendor/codex-quota/LICENSE +21 -0
- package/tools/vendor/codex-quota/README.md +459 -0
- package/tools/vendor/codex-quota/codex-quota.js +261 -0
- package/tools/vendor/codex-quota/lib/claude-accounts.js +226 -0
- package/tools/vendor/codex-quota/lib/claude-oauth.js +174 -0
- package/tools/vendor/codex-quota/lib/claude-tokens.js +471 -0
- package/tools/vendor/codex-quota/lib/claude-usage.js +929 -0
- package/tools/vendor/codex-quota/lib/codex-accounts.js +205 -0
- package/tools/vendor/codex-quota/lib/codex-tokens.js +326 -0
- package/tools/vendor/codex-quota/lib/codex-usage.js +32 -0
- package/tools/vendor/codex-quota/lib/color.js +72 -0
- package/tools/vendor/codex-quota/lib/constants.js +57 -0
- package/tools/vendor/codex-quota/lib/container.js +143 -0
- package/tools/vendor/codex-quota/lib/display.js +1111 -0
- package/tools/vendor/codex-quota/lib/fs.js +63 -0
- package/tools/vendor/codex-quota/lib/handlers.js +2060 -0
- package/tools/vendor/codex-quota/lib/jwt.js +33 -0
- package/tools/vendor/codex-quota/lib/oauth.js +486 -0
- package/tools/vendor/codex-quota/lib/paths.js +34 -0
- package/tools/vendor/codex-quota/lib/prompts.js +44 -0
- package/tools/vendor/codex-quota/lib/sync.js +1438 -0
- package/tools/vendor/codex-quota/lib/token-match.js +96 -0
- package/tools/vendor/codex-quota-manager/scripts/auto-switch.sh +500 -0
- package/tools/vendor/codex-quota-manager/scripts/batch-add.sh +123 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
usage() {
|
|
5
|
+
cat <<'EOF'
|
|
6
|
+
Usage:
|
|
7
|
+
install-dashboard-launchd.sh [--host 127.0.0.1] [--port 8765] [--label ai.agent.dashboard]
|
|
8
|
+
|
|
9
|
+
Installs a per-user LaunchAgent so the ACP worker dashboard starts automatically
|
|
10
|
+
after login/restart.
|
|
11
|
+
EOF
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
15
|
+
FLOW_SKILL_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
|
16
|
+
HOME_DIR="${ACP_DASHBOARD_HOME_DIR:-${HOME:-}}"
|
|
17
|
+
SOURCE_HOME="${ACP_DASHBOARD_SOURCE_HOME:-$(cd "${FLOW_SKILL_DIR}/../../.." && pwd)}"
|
|
18
|
+
RUNTIME_HOME="${ACP_DASHBOARD_RUNTIME_HOME:-${HOME_DIR}/.agent-runtime/runtime-home}"
|
|
19
|
+
WORKSPACE_DIR="${ACP_DASHBOARD_WORKSPACE_DIR:-${HOME_DIR}/.agent-runtime/control-plane/workspace}"
|
|
20
|
+
PROFILE_REGISTRY_ROOT="${ACP_DASHBOARD_PROFILE_REGISTRY_ROOT:-${ACP_PROFILE_REGISTRY_ROOT:-${HOME_DIR}/.agent-runtime/control-plane/profiles}}"
|
|
21
|
+
LAUNCH_AGENTS_DIR="${ACP_DASHBOARD_LAUNCH_AGENTS_DIR:-${HOME_DIR}/Library/LaunchAgents}"
|
|
22
|
+
LOG_DIR="${ACP_DASHBOARD_LOG_DIR:-${HOME_DIR}/.agent-runtime/logs}"
|
|
23
|
+
LABEL="${ACP_DASHBOARD_LABEL:-ai.agent.dashboard}"
|
|
24
|
+
HOST="${ACP_DASHBOARD_HOST:-127.0.0.1}"
|
|
25
|
+
PORT="${ACP_DASHBOARD_PORT:-8765}"
|
|
26
|
+
BASE_PATH="${ACP_DASHBOARD_PATH:-/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin}"
|
|
27
|
+
SYNC_SCRIPT="${ACP_DASHBOARD_SYNC_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/sync-shared-agent-home.sh}"
|
|
28
|
+
BOOTSTRAP_SCRIPT="${ACP_DASHBOARD_BOOTSTRAP_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/dashboard-launchd-bootstrap.sh}"
|
|
29
|
+
WRAPPER_PATH="${WORKSPACE_DIR}/bin/agent-dashboard-launchd.sh"
|
|
30
|
+
PLIST_PATH="${LAUNCH_AGENTS_DIR}/${LABEL}.plist"
|
|
31
|
+
STDOUT_LOG="${LOG_DIR}/agent-dashboard.stdout.log"
|
|
32
|
+
STDERR_LOG="${LOG_DIR}/agent-dashboard.stderr.log"
|
|
33
|
+
|
|
34
|
+
while [[ $# -gt 0 ]]; do
|
|
35
|
+
case "$1" in
|
|
36
|
+
--host)
|
|
37
|
+
HOST="${2:-}"
|
|
38
|
+
shift 2
|
|
39
|
+
;;
|
|
40
|
+
--port)
|
|
41
|
+
PORT="${2:-}"
|
|
42
|
+
shift 2
|
|
43
|
+
;;
|
|
44
|
+
--label)
|
|
45
|
+
LABEL="${2:-}"
|
|
46
|
+
PLIST_PATH="${LAUNCH_AGENTS_DIR}/${LABEL}.plist"
|
|
47
|
+
shift 2
|
|
48
|
+
;;
|
|
49
|
+
--help|-h)
|
|
50
|
+
usage
|
|
51
|
+
exit 0
|
|
52
|
+
;;
|
|
53
|
+
*)
|
|
54
|
+
echo "Unknown argument: $1" >&2
|
|
55
|
+
usage >&2
|
|
56
|
+
exit 64
|
|
57
|
+
;;
|
|
58
|
+
esac
|
|
59
|
+
done
|
|
60
|
+
|
|
61
|
+
if [[ -z "${HOME_DIR}" ]]; then
|
|
62
|
+
echo "install-dashboard-launchd requires HOME or ACP_DASHBOARD_HOME_DIR" >&2
|
|
63
|
+
exit 64
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
mkdir -p "${WORKSPACE_DIR}/bin" "${LAUNCH_AGENTS_DIR}" "${LOG_DIR}"
|
|
67
|
+
|
|
68
|
+
cat >"${WRAPPER_PATH}" <<EOF
|
|
69
|
+
#!/usr/bin/env bash
|
|
70
|
+
set -euo pipefail
|
|
71
|
+
export ACP_DASHBOARD_HOME_DIR='${HOME_DIR}'
|
|
72
|
+
export ACP_DASHBOARD_SOURCE_HOME='${SOURCE_HOME}'
|
|
73
|
+
export ACP_DASHBOARD_RUNTIME_HOME='${RUNTIME_HOME}'
|
|
74
|
+
export ACP_DASHBOARD_PROFILE_REGISTRY_ROOT='${PROFILE_REGISTRY_ROOT}'
|
|
75
|
+
export ACP_DASHBOARD_HOST='${HOST}'
|
|
76
|
+
export ACP_DASHBOARD_PORT='${PORT}'
|
|
77
|
+
export ACP_DASHBOARD_PATH='${BASE_PATH}'
|
|
78
|
+
export ACP_DASHBOARD_SYNC_SCRIPT='${SYNC_SCRIPT}'
|
|
79
|
+
exec bash '${BOOTSTRAP_SCRIPT}'
|
|
80
|
+
EOF
|
|
81
|
+
chmod +x "${WRAPPER_PATH}"
|
|
82
|
+
|
|
83
|
+
cat >"${PLIST_PATH}" <<EOF
|
|
84
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
85
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
86
|
+
<plist version="1.0">
|
|
87
|
+
<dict>
|
|
88
|
+
<key>Label</key>
|
|
89
|
+
<string>${LABEL}</string>
|
|
90
|
+
<key>ProcessType</key>
|
|
91
|
+
<string>Background</string>
|
|
92
|
+
<key>ProgramArguments</key>
|
|
93
|
+
<array>
|
|
94
|
+
<string>${WRAPPER_PATH}</string>
|
|
95
|
+
</array>
|
|
96
|
+
<key>RunAtLoad</key>
|
|
97
|
+
<true/>
|
|
98
|
+
<key>KeepAlive</key>
|
|
99
|
+
<true/>
|
|
100
|
+
<key>WorkingDirectory</key>
|
|
101
|
+
<string>${WORKSPACE_DIR}</string>
|
|
102
|
+
<key>StandardErrorPath</key>
|
|
103
|
+
<string>${STDERR_LOG}</string>
|
|
104
|
+
<key>StandardOutPath</key>
|
|
105
|
+
<string>${STDOUT_LOG}</string>
|
|
106
|
+
<key>EnvironmentVariables</key>
|
|
107
|
+
<dict>
|
|
108
|
+
<key>HOME</key>
|
|
109
|
+
<string>${HOME_DIR}</string>
|
|
110
|
+
<key>PATH</key>
|
|
111
|
+
<string>${BASE_PATH}</string>
|
|
112
|
+
<key>ACP_PROFILE_REGISTRY_ROOT</key>
|
|
113
|
+
<string>${PROFILE_REGISTRY_ROOT}</string>
|
|
114
|
+
<key>PYTHONDONTWRITEBYTECODE</key>
|
|
115
|
+
<string>1</string>
|
|
116
|
+
</dict>
|
|
117
|
+
</dict>
|
|
118
|
+
</plist>
|
|
119
|
+
EOF
|
|
120
|
+
|
|
121
|
+
if [[ "${ACP_DASHBOARD_SKIP_LAUNCHCTL:-0}" == "1" ]]; then
|
|
122
|
+
printf 'LAUNCHD_INSTALL_STATUS=skipped-launchctl\n'
|
|
123
|
+
printf 'LABEL=%s\n' "${LABEL}"
|
|
124
|
+
printf 'PLIST=%s\n' "${PLIST_PATH}"
|
|
125
|
+
printf 'WRAPPER=%s\n' "${WRAPPER_PATH}"
|
|
126
|
+
printf 'URL=http://%s:%s\n' "${HOST}" "${PORT}"
|
|
127
|
+
exit 0
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
user_domain="gui/$(id -u)"
|
|
131
|
+
launchctl bootout "${user_domain}/${LABEL}" >/dev/null 2>&1 || true
|
|
132
|
+
launchctl bootstrap "${user_domain}" "${PLIST_PATH}"
|
|
133
|
+
launchctl kickstart -k "${user_domain}/${LABEL}"
|
|
134
|
+
|
|
135
|
+
for _ in 1 2 3 4 5 6 7 8 9 10; do
|
|
136
|
+
if curl -fsS "http://${HOST}:${PORT}/api/snapshot.json" >/dev/null 2>&1; then
|
|
137
|
+
printf 'LAUNCHD_INSTALL_STATUS=ok\n'
|
|
138
|
+
printf 'LABEL=%s\n' "${LABEL}"
|
|
139
|
+
printf 'PLIST=%s\n' "${PLIST_PATH}"
|
|
140
|
+
printf 'WRAPPER=%s\n' "${WRAPPER_PATH}"
|
|
141
|
+
printf 'URL=http://%s:%s\n' "${HOST}" "${PORT}"
|
|
142
|
+
exit 0
|
|
143
|
+
fi
|
|
144
|
+
sleep 1
|
|
145
|
+
done
|
|
146
|
+
|
|
147
|
+
printf 'LAUNCHD_INSTALL_STATUS=unhealthy\n'
|
|
148
|
+
printf 'LABEL=%s\n' "${LABEL}"
|
|
149
|
+
printf 'PLIST=%s\n' "${PLIST_PATH}"
|
|
150
|
+
printf 'WRAPPER=%s\n' "${WRAPPER_PATH}"
|
|
151
|
+
printf 'URL=http://%s:%s\n' "${HOST}" "${PORT}"
|
|
152
|
+
exit 1
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
usage() {
|
|
5
|
+
cat <<'EOF'
|
|
6
|
+
Usage:
|
|
7
|
+
install-project-launchd.sh --profile-id <id> [options]
|
|
8
|
+
|
|
9
|
+
Install a per-user LaunchAgent so one ACP project runtime starts automatically
|
|
10
|
+
after login/restart.
|
|
11
|
+
|
|
12
|
+
Options:
|
|
13
|
+
--profile-id <id> Installed profile id to manage
|
|
14
|
+
--label <label> Override LaunchAgent label (default: ai.agent.project.<id>)
|
|
15
|
+
--delay-seconds <n> Initial supervisor delay before first bootstrap (default: 0)
|
|
16
|
+
--interval-seconds <n> Supervisor interval between bootstrap passes (default: 15)
|
|
17
|
+
--help Show this help
|
|
18
|
+
EOF
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
22
|
+
# shellcheck source=/dev/null
|
|
23
|
+
source "${SCRIPT_DIR}/flow-config-lib.sh"
|
|
24
|
+
|
|
25
|
+
append_path_dir() {
|
|
26
|
+
local value_name="${1:?value name required}"
|
|
27
|
+
local candidate="${2:-}"
|
|
28
|
+
local current=""
|
|
29
|
+
|
|
30
|
+
[[ -n "${candidate}" && -d "${candidate}" ]] || return 0
|
|
31
|
+
current="${!value_name:-}"
|
|
32
|
+
case ":${current}:" in
|
|
33
|
+
*":${candidate}:"*) return 0 ;;
|
|
34
|
+
esac
|
|
35
|
+
if [[ -n "${current}" ]]; then
|
|
36
|
+
printf -v "${value_name}" '%s:%s' "${current}" "${candidate}"
|
|
37
|
+
else
|
|
38
|
+
printf -v "${value_name}" '%s' "${candidate}"
|
|
39
|
+
fi
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
resolved_tool_dir() {
|
|
43
|
+
local tool_name="${1:-}"
|
|
44
|
+
local tool_path=""
|
|
45
|
+
|
|
46
|
+
[[ -n "${tool_name}" ]] || return 1
|
|
47
|
+
tool_path="$(command -v "${tool_name}" 2>/dev/null || true)"
|
|
48
|
+
[[ -n "${tool_path}" ]] || return 1
|
|
49
|
+
dirname "${tool_path}"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
build_launchd_base_path() {
|
|
53
|
+
local path_value="${ACP_PROJECT_RUNTIME_PATH:-/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin}"
|
|
54
|
+
local tool_name=""
|
|
55
|
+
local tool_dir=""
|
|
56
|
+
|
|
57
|
+
for tool_name in node gh git python3 openclaw codex claude; do
|
|
58
|
+
tool_dir="$(resolved_tool_dir "${tool_name}" || true)"
|
|
59
|
+
append_path_dir path_value "${tool_dir}"
|
|
60
|
+
done
|
|
61
|
+
|
|
62
|
+
printf '%s\n' "${path_value}"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
profile_id_override=""
|
|
66
|
+
label_override=""
|
|
67
|
+
delay_seconds="0"
|
|
68
|
+
interval_seconds="15"
|
|
69
|
+
profile_registry_root_override="${ACP_PROJECT_RUNTIME_PROFILE_REGISTRY_ROOT:-${ACP_PROFILE_REGISTRY_ROOT:-}}"
|
|
70
|
+
|
|
71
|
+
while [[ $# -gt 0 ]]; do
|
|
72
|
+
case "$1" in
|
|
73
|
+
--profile-id) profile_id_override="${2:-}"; shift 2 ;;
|
|
74
|
+
--label) label_override="${2:-}"; shift 2 ;;
|
|
75
|
+
--delay-seconds) delay_seconds="${2:-}"; shift 2 ;;
|
|
76
|
+
--interval-seconds) interval_seconds="${2:-}"; shift 2 ;;
|
|
77
|
+
--help|-h) usage; exit 0 ;;
|
|
78
|
+
*) echo "Unknown argument: $1" >&2; usage >&2; exit 64 ;;
|
|
79
|
+
esac
|
|
80
|
+
done
|
|
81
|
+
|
|
82
|
+
if [[ -z "${profile_id_override}" ]]; then
|
|
83
|
+
usage >&2
|
|
84
|
+
exit 64
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
case "${delay_seconds}" in
|
|
88
|
+
''|*[!0-9]*) echo "--delay-seconds must be numeric" >&2; exit 64 ;;
|
|
89
|
+
esac
|
|
90
|
+
|
|
91
|
+
case "${interval_seconds}" in
|
|
92
|
+
''|*[!0-9]*) echo "--interval-seconds must be numeric" >&2; exit 64 ;;
|
|
93
|
+
esac
|
|
94
|
+
|
|
95
|
+
export ACP_PROJECT_ID="${profile_id_override}"
|
|
96
|
+
export AGENT_PROJECT_ID="${profile_id_override}"
|
|
97
|
+
if [[ -n "${profile_registry_root_override}" ]]; then
|
|
98
|
+
export ACP_PROFILE_REGISTRY_ROOT="${profile_registry_root_override}"
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
|
|
102
|
+
if ! flow_require_explicit_profile_selection "${FLOW_SKILL_DIR}" "install-project-launchd.sh"; then
|
|
103
|
+
exit 64
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
|
|
107
|
+
if [[ ! -f "${CONFIG_YAML}" ]]; then
|
|
108
|
+
printf 'profile not installed: %s\n' "${profile_id_override}" >&2
|
|
109
|
+
exit 66
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
PROFILE_ID="$(flow_resolve_adapter_id "${CONFIG_YAML}")"
|
|
113
|
+
profile_slug="$(printf '%s' "${PROFILE_ID}" | tr -c 'A-Za-z0-9._-' '-')"
|
|
114
|
+
HOME_DIR="${ACP_PROJECT_RUNTIME_HOME_DIR:-${HOME:-}}"
|
|
115
|
+
SOURCE_HOME="${ACP_PROJECT_RUNTIME_SOURCE_HOME:-$(cd "${FLOW_SKILL_DIR}/../../.." && pwd)}"
|
|
116
|
+
RUNTIME_HOME="${ACP_PROJECT_RUNTIME_RUNTIME_HOME:-${HOME_DIR}/.agent-runtime/runtime-home}"
|
|
117
|
+
WORKSPACE_DIR="${ACP_PROJECT_RUNTIME_WORKSPACE_DIR:-${HOME_DIR}/.agent-runtime/control-plane/workspace}"
|
|
118
|
+
PROFILE_REGISTRY_ROOT="${ACP_PROJECT_RUNTIME_PROFILE_REGISTRY_ROOT:-${ACP_PROFILE_REGISTRY_ROOT:-${HOME_DIR}/.agent-runtime/control-plane/profiles}}"
|
|
119
|
+
LAUNCH_AGENTS_DIR="${ACP_PROJECT_RUNTIME_LAUNCH_AGENTS_DIR:-${HOME_DIR}/Library/LaunchAgents}"
|
|
120
|
+
LOG_DIR="${ACP_PROJECT_RUNTIME_LOG_DIR:-${HOME_DIR}/.agent-runtime/logs}"
|
|
121
|
+
LABEL="${label_override:-${ACP_PROJECT_RUNTIME_LAUNCHD_LABEL:-ai.agent.project.${profile_slug}}}"
|
|
122
|
+
BASE_PATH="$(build_launchd_base_path)"
|
|
123
|
+
SYNC_SCRIPT="${ACP_PROJECT_RUNTIME_SYNC_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/sync-shared-agent-home.sh}"
|
|
124
|
+
BOOTSTRAP_SCRIPT="${ACP_PROJECT_RUNTIME_BOOTSTRAP_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/project-launchd-bootstrap.sh}"
|
|
125
|
+
SUPERVISOR_SCRIPT="${ACP_PROJECT_RUNTIME_SUPERVISOR_SCRIPT:-${FLOW_SKILL_DIR}/tools/bin/project-runtime-supervisor.sh}"
|
|
126
|
+
STATE_ROOT="$(flow_resolve_state_root "${CONFIG_YAML}")"
|
|
127
|
+
SUPERVISOR_PID_FILE="${STATE_ROOT}/runtime-supervisor.pid"
|
|
128
|
+
ENV_FILE="${ACP_PROJECT_RUNTIME_ENV_FILE:-${PROFILE_REGISTRY_ROOT}/${PROFILE_ID}/runtime.env}"
|
|
129
|
+
WRAPPER_PATH="${WORKSPACE_DIR}/bin/agent-project-${profile_slug}-launchd.sh"
|
|
130
|
+
PLIST_PATH="${LAUNCH_AGENTS_DIR}/${LABEL}.plist"
|
|
131
|
+
STDOUT_LOG="${LOG_DIR}/agent-project-${profile_slug}.stdout.log"
|
|
132
|
+
STDERR_LOG="${LOG_DIR}/agent-project-${profile_slug}.stderr.log"
|
|
133
|
+
|
|
134
|
+
if [[ -z "${HOME_DIR}" ]]; then
|
|
135
|
+
echo "install-project-launchd requires HOME or ACP_PROJECT_RUNTIME_HOME_DIR" >&2
|
|
136
|
+
exit 64
|
|
137
|
+
fi
|
|
138
|
+
|
|
139
|
+
mkdir -p "${WORKSPACE_DIR}/bin" "${LAUNCH_AGENTS_DIR}" "${LOG_DIR}" "$(dirname "${SUPERVISOR_PID_FILE}")"
|
|
140
|
+
|
|
141
|
+
cat >"${WRAPPER_PATH}" <<EOF
|
|
142
|
+
#!/usr/bin/env bash
|
|
143
|
+
set -euo pipefail
|
|
144
|
+
export ACP_PROJECT_RUNTIME_HOME_DIR='${HOME_DIR}'
|
|
145
|
+
export ACP_PROJECT_RUNTIME_SOURCE_HOME='${SOURCE_HOME}'
|
|
146
|
+
export ACP_PROJECT_RUNTIME_RUNTIME_HOME='${RUNTIME_HOME}'
|
|
147
|
+
export ACP_PROJECT_RUNTIME_PROFILE_REGISTRY_ROOT='${PROFILE_REGISTRY_ROOT}'
|
|
148
|
+
export ACP_PROJECT_RUNTIME_PROFILE_ID='${PROFILE_ID}'
|
|
149
|
+
export ACP_PROJECT_RUNTIME_ENV_FILE='${ENV_FILE}'
|
|
150
|
+
export ACP_PROJECT_ID='${PROFILE_ID}'
|
|
151
|
+
export AGENT_PROJECT_ID='${PROFILE_ID}'
|
|
152
|
+
export ACP_PROJECT_RUNTIME_PATH='${BASE_PATH}'
|
|
153
|
+
export ACP_PROJECT_RUNTIME_SYNC_SCRIPT='${SYNC_SCRIPT}'
|
|
154
|
+
export ACP_PROFILE_REGISTRY_ROOT='${PROFILE_REGISTRY_ROOT}'
|
|
155
|
+
exec bash '${SUPERVISOR_SCRIPT}' --bootstrap-script '${BOOTSTRAP_SCRIPT}' --pid-file '${SUPERVISOR_PID_FILE}' --delay-seconds '${delay_seconds}' --interval-seconds '${interval_seconds}'
|
|
156
|
+
EOF
|
|
157
|
+
chmod +x "${WRAPPER_PATH}"
|
|
158
|
+
|
|
159
|
+
cat >"${PLIST_PATH}" <<EOF
|
|
160
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
161
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
162
|
+
<plist version="1.0">
|
|
163
|
+
<dict>
|
|
164
|
+
<key>Label</key>
|
|
165
|
+
<string>${LABEL}</string>
|
|
166
|
+
<key>ProcessType</key>
|
|
167
|
+
<string>Background</string>
|
|
168
|
+
<key>ProgramArguments</key>
|
|
169
|
+
<array>
|
|
170
|
+
<string>${WRAPPER_PATH}</string>
|
|
171
|
+
</array>
|
|
172
|
+
<key>RunAtLoad</key>
|
|
173
|
+
<true/>
|
|
174
|
+
<key>KeepAlive</key>
|
|
175
|
+
<true/>
|
|
176
|
+
<key>WorkingDirectory</key>
|
|
177
|
+
<string>${WORKSPACE_DIR}</string>
|
|
178
|
+
<key>StandardErrorPath</key>
|
|
179
|
+
<string>${STDERR_LOG}</string>
|
|
180
|
+
<key>StandardOutPath</key>
|
|
181
|
+
<string>${STDOUT_LOG}</string>
|
|
182
|
+
<key>EnvironmentVariables</key>
|
|
183
|
+
<dict>
|
|
184
|
+
<key>HOME</key>
|
|
185
|
+
<string>${HOME_DIR}</string>
|
|
186
|
+
<key>PATH</key>
|
|
187
|
+
<string>${BASE_PATH}</string>
|
|
188
|
+
<key>ACP_PROFILE_REGISTRY_ROOT</key>
|
|
189
|
+
<string>${PROFILE_REGISTRY_ROOT}</string>
|
|
190
|
+
</dict>
|
|
191
|
+
</dict>
|
|
192
|
+
</plist>
|
|
193
|
+
EOF
|
|
194
|
+
|
|
195
|
+
if [[ "${ACP_PROJECT_RUNTIME_SKIP_LAUNCHCTL:-0}" == "1" ]]; then
|
|
196
|
+
printf 'LAUNCHD_INSTALL_STATUS=skipped-launchctl\n'
|
|
197
|
+
printf 'PROFILE_ID=%s\n' "${PROFILE_ID}"
|
|
198
|
+
printf 'LABEL=%s\n' "${LABEL}"
|
|
199
|
+
printf 'PLIST=%s\n' "${PLIST_PATH}"
|
|
200
|
+
printf 'WRAPPER=%s\n' "${WRAPPER_PATH}"
|
|
201
|
+
exit 0
|
|
202
|
+
fi
|
|
203
|
+
|
|
204
|
+
user_domain="gui/$(id -u)"
|
|
205
|
+
launchctl bootout "${user_domain}/${LABEL}" >/dev/null 2>&1 || true
|
|
206
|
+
launchctl bootstrap "${user_domain}" "${PLIST_PATH}"
|
|
207
|
+
for _ in 1 2 3 4 5 6 7 8 9 10; do
|
|
208
|
+
if launchctl print "${user_domain}/${LABEL}" >/dev/null 2>&1; then
|
|
209
|
+
break
|
|
210
|
+
fi
|
|
211
|
+
sleep 1
|
|
212
|
+
done
|
|
213
|
+
launchctl kickstart -k "${user_domain}/${LABEL}" >/dev/null 2>&1 || true
|
|
214
|
+
|
|
215
|
+
printf 'LAUNCHD_INSTALL_STATUS=ok\n'
|
|
216
|
+
printf 'PROFILE_ID=%s\n' "${PROFILE_ID}"
|
|
217
|
+
printf 'LABEL=%s\n' "${LABEL}"
|
|
218
|
+
printf 'PLIST=%s\n' "${PLIST_PATH}"
|
|
219
|
+
printf 'WRAPPER=%s\n' "${WRAPPER_PATH}"
|
|
@@ -0,0 +1,242 @@
|
|
|
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
|
+
issue-publish-scope-guard.sh --worktree <path> --base-ref <git-ref> [--issue-id <number>]
|
|
12
|
+
|
|
13
|
+
Fail fast when an issue worker branch is too broad to publish safely as a single
|
|
14
|
+
PR slice.
|
|
15
|
+
EOF
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
worktree=""
|
|
19
|
+
base_ref=""
|
|
20
|
+
issue_id=""
|
|
21
|
+
|
|
22
|
+
while [[ $# -gt 0 ]]; do
|
|
23
|
+
case "$1" in
|
|
24
|
+
--worktree) worktree="${2:-}"; shift 2 ;;
|
|
25
|
+
--base-ref) base_ref="${2:-}"; shift 2 ;;
|
|
26
|
+
--issue-id) issue_id="${2:-}"; shift 2 ;;
|
|
27
|
+
--help|-h) usage; exit 0 ;;
|
|
28
|
+
*) echo "Unknown argument: $1" >&2; usage >&2; exit 1 ;;
|
|
29
|
+
esac
|
|
30
|
+
done
|
|
31
|
+
|
|
32
|
+
if [[ -z "$worktree" || -z "$base_ref" ]]; then
|
|
33
|
+
usage >&2
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
if [[ ! -d "$worktree" ]]; then
|
|
38
|
+
echo "missing worktree: $worktree" >&2
|
|
39
|
+
exit 1
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
changed_files="$(
|
|
43
|
+
git -C "$worktree" diff --name-only --diff-filter=ACMR "${base_ref}...HEAD"
|
|
44
|
+
)"
|
|
45
|
+
|
|
46
|
+
issue_title=""
|
|
47
|
+
issue_body=""
|
|
48
|
+
if [[ -n "$issue_id" ]]; then
|
|
49
|
+
CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
|
|
50
|
+
REPO_SLUG="$(flow_resolve_repo_slug "${CONFIG_YAML}")"
|
|
51
|
+
issue_json="$(flow_github_issue_view_json "${REPO_SLUG}" "${issue_id}" 2>/dev/null || true)"
|
|
52
|
+
if [[ -n "$issue_json" ]]; then
|
|
53
|
+
issue_title="$(jq -r '.title // ""' <<<"$issue_json" 2>/dev/null || true)"
|
|
54
|
+
issue_body="$(jq -r '.body // ""' <<<"$issue_json" 2>/dev/null || true)"
|
|
55
|
+
fi
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
CHANGED_FILES="$changed_files" ISSUE_ID="$issue_id" ISSUE_TITLE="$issue_title" ISSUE_BODY="$issue_body" node <<'EOF'
|
|
59
|
+
const files = String(process.env.CHANGED_FILES || '')
|
|
60
|
+
.split('\n')
|
|
61
|
+
.map((file) => file.trim())
|
|
62
|
+
.filter(Boolean);
|
|
63
|
+
|
|
64
|
+
const issueId = String(process.env.ISSUE_ID || '').trim();
|
|
65
|
+
const issueTitle = String(process.env.ISSUE_TITLE || '').trim();
|
|
66
|
+
const issueBody = String(process.env.ISSUE_BODY || '').trim();
|
|
67
|
+
|
|
68
|
+
const isDoc = (file) =>
|
|
69
|
+
/^openspec\//.test(file) ||
|
|
70
|
+
/^docs\//.test(file) ||
|
|
71
|
+
/^scripts\/README\.md$/.test(file) ||
|
|
72
|
+
/\.md$/i.test(file);
|
|
73
|
+
|
|
74
|
+
const isTest = (file) =>
|
|
75
|
+
/(?:^|\/)__tests__\//.test(file) ||
|
|
76
|
+
/(?:^|\/)e2e\//.test(file) ||
|
|
77
|
+
/\.(?:spec|test)\.[cm]?[jt]sx?$/.test(file);
|
|
78
|
+
|
|
79
|
+
const isLocaleResource = (file) =>
|
|
80
|
+
/^packages\/i18n\/src\/resources\/[^/]+\.json$/.test(file);
|
|
81
|
+
|
|
82
|
+
const isProductNonTest = (file) =>
|
|
83
|
+
!isDoc(file) &&
|
|
84
|
+
!isTest(file) &&
|
|
85
|
+
!isLocaleResource(file) &&
|
|
86
|
+
(/^apps\//.test(file) || /^packages\//.test(file));
|
|
87
|
+
|
|
88
|
+
const isMobileRouteFile = (file) =>
|
|
89
|
+
/^apps\/mobile\/app\/.+\.[cm]?[jt]sx?$/.test(file) &&
|
|
90
|
+
!isTest(file);
|
|
91
|
+
|
|
92
|
+
const mobileSurfaceKey = (file) => {
|
|
93
|
+
const relative = file
|
|
94
|
+
.replace(/^apps\/mobile\/app\//, '')
|
|
95
|
+
.replace(/\.[cm]?[jt]sx?$/, '');
|
|
96
|
+
const segments = relative
|
|
97
|
+
.split('/')
|
|
98
|
+
.filter(Boolean)
|
|
99
|
+
.filter((segment) => !/^\(.+\)$/.test(segment));
|
|
100
|
+
if (segments.length === 0) return relative;
|
|
101
|
+
return segments[0];
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const isAuthCriticalProductFile = (file) =>
|
|
105
|
+
/^apps\/api\/src\/modules\/auth\//.test(file) ||
|
|
106
|
+
file === 'apps/api/src/entities/user.entity.ts' ||
|
|
107
|
+
/^apps\/api\/src\/migrations\/.*(?:Email|Phone|Auth|User).*\.[cm]?[jt]s$/.test(file) ||
|
|
108
|
+
/^apps\/api\/src\/common\/utils\/(?:phone|tenant|email|auth)[^/]*\.[cm]?[jt]s$/.test(file);
|
|
109
|
+
|
|
110
|
+
const isAuthAdjacentProductFile = (file) =>
|
|
111
|
+
isAuthCriticalProductFile(file) ||
|
|
112
|
+
/^apps\/web\/src\/app\/\(auth\)\//.test(file) ||
|
|
113
|
+
/^apps\/api\/src\/modules\/organization\//.test(file);
|
|
114
|
+
|
|
115
|
+
const productNonTestFiles = files.filter(isProductNonTest);
|
|
116
|
+
const mobileProductFiles = productNonTestFiles.filter((file) => /^apps\/mobile\//.test(file));
|
|
117
|
+
const localeResourceFiles = files.filter(isLocaleResource);
|
|
118
|
+
const mobileRouteFiles = productNonTestFiles.filter(isMobileRouteFile);
|
|
119
|
+
const mobileSurfaceKeys = [...new Set(mobileRouteFiles.map(mobileSurfaceKey))];
|
|
120
|
+
const authCriticalTouched = productNonTestFiles.some(isAuthCriticalProductFile);
|
|
121
|
+
const authMixedScopeFiles = authCriticalTouched
|
|
122
|
+
? productNonTestFiles.filter((file) => !isAuthAdjacentProductFile(file))
|
|
123
|
+
: [];
|
|
124
|
+
const openspecChangeFiles = files.filter((file) => /^openspec\/changes\//.test(file));
|
|
125
|
+
const workflowRuleFiles = files.filter((file) =>
|
|
126
|
+
/^(?:AGENTS\.md|openspec\/AGENT_RULES\.md)$/.test(file),
|
|
127
|
+
);
|
|
128
|
+
const docsDeclaredScope =
|
|
129
|
+
/^(?:docs?|documentation)\b/i.test(issueTitle) ||
|
|
130
|
+
/^docs?\(/i.test(issueTitle) ||
|
|
131
|
+
/\b(?:docs?|documentation|openspec)[ -]?only\b/i.test(issueTitle) ||
|
|
132
|
+
/(?:^|\n)\s*(?:scope|mode|type)\s*:\s*(?:docs?|documentation|openspec)(?:[- ]only)?\b/i.test(issueBody) ||
|
|
133
|
+
/(?:^|\n)\s*(?:docs?|documentation|openspec)[ -]?only\b/i.test(issueBody);
|
|
134
|
+
|
|
135
|
+
const reasons = [];
|
|
136
|
+
if (productNonTestFiles.length > 14) {
|
|
137
|
+
reasons.push(`product_non_test_count=${productNonTestFiles.length} exceeds max=14`);
|
|
138
|
+
}
|
|
139
|
+
if (mobileProductFiles.length >= 8) {
|
|
140
|
+
reasons.push(`mobile_product_count=${mobileProductFiles.length} exceeds max=7`);
|
|
141
|
+
}
|
|
142
|
+
if (localeResourceFiles.length > 8 && productNonTestFiles.length >= 6) {
|
|
143
|
+
reasons.push(
|
|
144
|
+
`locale_resource_count=${localeResourceFiles.length} with product_non_test_count=${productNonTestFiles.length} exceeds mixed-scope limit`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
if (mobileRouteFiles.length > 3) {
|
|
148
|
+
reasons.push(`mobile_route_file_count=${mobileRouteFiles.length} exceeds max=3`);
|
|
149
|
+
}
|
|
150
|
+
if (mobileSurfaceKeys.length > 2) {
|
|
151
|
+
reasons.push(`mobile_surface_count=${mobileSurfaceKeys.length} exceeds max=2`);
|
|
152
|
+
}
|
|
153
|
+
if (authMixedScopeFiles.length > 0) {
|
|
154
|
+
reasons.push(
|
|
155
|
+
`auth_mixed_scope_count=${authMixedScopeFiles.length} requires a dedicated auth slice before publish`,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
if (docsDeclaredScope && productNonTestFiles.length > 0) {
|
|
159
|
+
reasons.push(`docs_declared_scope_contains_product_changes=${productNonTestFiles.length}`);
|
|
160
|
+
}
|
|
161
|
+
if (openspecChangeFiles.length > 0 && productNonTestFiles.length > 0) {
|
|
162
|
+
reasons.push(
|
|
163
|
+
`product_and_openspec_change_mix=product:${productNonTestFiles.length},openspec_change:${openspecChangeFiles.length}`,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
if (workflowRuleFiles.length > 0 && productNonTestFiles.length > 0) {
|
|
167
|
+
reasons.push(
|
|
168
|
+
`workflow_rule_files_mixed_with_product_changes=${workflowRuleFiles.length}`,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (reasons.length === 0) {
|
|
173
|
+
process.stdout.write('SCOPE_GUARD_STATUS=ok\n');
|
|
174
|
+
process.stdout.write(`PRODUCT_NON_TEST_COUNT=${productNonTestFiles.length}\n`);
|
|
175
|
+
process.stdout.write(`MOBILE_PRODUCT_COUNT=${mobileProductFiles.length}\n`);
|
|
176
|
+
process.stdout.write(`LOCALE_RESOURCE_COUNT=${localeResourceFiles.length}\n`);
|
|
177
|
+
process.stdout.write(`MOBILE_ROUTE_FILE_COUNT=${mobileRouteFiles.length}\n`);
|
|
178
|
+
process.stdout.write(`MOBILE_SURFACE_COUNT=${mobileSurfaceKeys.length}\n`);
|
|
179
|
+
process.stdout.write(`AUTH_MIXED_SCOPE_COUNT=${authMixedScopeFiles.length}\n`);
|
|
180
|
+
process.exit(0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const lines = [
|
|
184
|
+
`Scope guard blocked issue${issueId ? ` #${issueId}` : ''} from publishing as a single PR.`,
|
|
185
|
+
'',
|
|
186
|
+
'The branch is too broad for the current flow and should be split into a smaller slice before publish.',
|
|
187
|
+
'',
|
|
188
|
+
'Why it was blocked:',
|
|
189
|
+
...reasons.map((reason) => `- ${reason}`),
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
if (productNonTestFiles.length > 0) {
|
|
193
|
+
lines.push('', 'Representative product files:');
|
|
194
|
+
for (const file of productNonTestFiles.slice(0, 12)) {
|
|
195
|
+
lines.push(`- ${file}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (localeResourceFiles.length > 0) {
|
|
200
|
+
lines.push('', 'Locale resource files touched:');
|
|
201
|
+
for (const file of localeResourceFiles.slice(0, 12)) {
|
|
202
|
+
lines.push(`- ${file}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (openspecChangeFiles.length > 0) {
|
|
207
|
+
lines.push('', 'OpenSpec change files touched:');
|
|
208
|
+
for (const file of openspecChangeFiles.slice(0, 12)) {
|
|
209
|
+
lines.push(`- ${file}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (workflowRuleFiles.length > 0) {
|
|
214
|
+
lines.push('', 'Workflow or repo-rule files touched:');
|
|
215
|
+
for (const file of workflowRuleFiles.slice(0, 12)) {
|
|
216
|
+
lines.push(`- ${file}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (mobileRouteFiles.length > 0) {
|
|
221
|
+
lines.push('', 'Mobile route files touched:');
|
|
222
|
+
for (const file of mobileRouteFiles.slice(0, 12)) {
|
|
223
|
+
lines.push(`- ${file}`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (authMixedScopeFiles.length > 0) {
|
|
228
|
+
lines.push('', 'Files that should move to a separate follow-up PR from the auth slice:');
|
|
229
|
+
for (const file of authMixedScopeFiles.slice(0, 12)) {
|
|
230
|
+
lines.push(`- ${file}`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
lines.push(
|
|
235
|
+
'',
|
|
236
|
+
'Required next step:',
|
|
237
|
+
'- re-run the issue as a narrower slice that stays within one primary product surface, at most two mobile route surfaces, one dedicated auth/security contract change, or one docs/OpenSpec-only branch with no product code',
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
process.stderr.write(`${lines.join('\n')}\n`);
|
|
241
|
+
process.exit(42);
|
|
242
|
+
EOF
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
ISSUE_BODY="${ISSUE_BODY:-${1:-}}"
|
|
5
|
+
|
|
6
|
+
ISSUE_BODY="$ISSUE_BODY" node <<'EOF'
|
|
7
|
+
const body = process.env.ISSUE_BODY || '';
|
|
8
|
+
const scheduled = /^\s*(?:Agent schedule|Schedule|Cadence)\s*:\s*(?:every\s+)?(\d+)\s*([mhd])\s*$/im.test(body);
|
|
9
|
+
|
|
10
|
+
if (!scheduled) {
|
|
11
|
+
process.stdout.write('no\n');
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (/^\s*(?:Local workspace install|Worktree local install)\s*:\s*yes\s*$/im.test(body)) {
|
|
16
|
+
process.stdout.write('yes\n');
|
|
17
|
+
process.exit(0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const installLikePatterns = [
|
|
21
|
+
/(^|\n)\s*\d+\.\s*`(?:pnpm|npm|yarn)\s+(?:install|i|ci|add|remove|rm|up|update|rebuild|dlx)\b/im,
|
|
22
|
+
/(^|\n)\s*\d+\.\s*`pnpm\s+exec\s+pod\s+install\b/im,
|
|
23
|
+
/(^|\n)\s*\d+\.\s*`(?:npx\s+pod-install|expo\s+prebuild|pod\s+install|bundle\s+install)\b/im,
|
|
24
|
+
/`(?:pnpm|npm|yarn)\s+(?:install|i|ci|add|remove|rm|up|update|rebuild|dlx)\b/im,
|
|
25
|
+
/`pnpm\s+exec\s+pod\s+install\b/im,
|
|
26
|
+
/`(?:npx\s+pod-install|expo\s+prebuild|pod\s+install|bundle\s+install)\b/im,
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const needsLocalInstall = installLikePatterns.some((pattern) => pattern.test(body));
|
|
30
|
+
process.stdout.write(needsLocalInstall ? 'yes\n' : 'no\n');
|
|
31
|
+
EOF
|
|
@@ -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
|
+
ISSUE_ID="${1:?usage: issue-resource-class.sh ISSUE_ID}"
|
|
9
|
+
FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
|
|
10
|
+
ADAPTER_BIN_DIR="${FLOW_SKILL_DIR}/bin"
|
|
11
|
+
|
|
12
|
+
"${ADAPTER_BIN_DIR}/issue-resource-class.sh" "$ISSUE_ID"
|