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,52 @@
|
|
|
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
|
+
CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
|
|
9
|
+
SOURCE_REPO_ROOT="${ACP_SOURCE_REPO_ROOT:-${F_LOSNING_SOURCE_REPO_ROOT:-$(flow_resolve_retained_repo_root "${CONFIG_YAML}")}}"
|
|
10
|
+
CANONICAL_REPO_ROOT="$(flow_resolve_repo_root "${CONFIG_YAML}")"
|
|
11
|
+
AGENT_REPO_ROOT="$(flow_resolve_agent_repo_root "${CONFIG_YAML}")"
|
|
12
|
+
DEFAULT_BRANCH="$(flow_resolve_default_branch "${CONFIG_YAML}")"
|
|
13
|
+
REMOTE_NAME="${ACP_REMOTE_NAME:-${F_LOSNING_REMOTE_NAME:-origin}}"
|
|
14
|
+
FLOW_SKILL_DIR="$(resolve_flow_skill_dir "${BASH_SOURCE[0]}")"
|
|
15
|
+
FLOW_TOOLS_DIR="${FLOW_SKILL_DIR}/tools/bin"
|
|
16
|
+
|
|
17
|
+
is_git_checkout() {
|
|
18
|
+
local repo_root="${1:-}"
|
|
19
|
+
[[ -n "$repo_root" ]] || return 1
|
|
20
|
+
[[ -d "$repo_root/.git" || -f "$repo_root/.git" ]]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
has_remote() {
|
|
24
|
+
local repo_root="${1:-}"
|
|
25
|
+
[[ -n "$repo_root" ]] || return 1
|
|
26
|
+
git -C "$repo_root" remote get-url "$REMOTE_NAME" >/dev/null 2>&1
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
SYNC_SEED_ROOT="$AGENT_REPO_ROOT"
|
|
30
|
+
if ! is_git_checkout "$SYNC_SEED_ROOT" || ! has_remote "$SYNC_SEED_ROOT"; then
|
|
31
|
+
SYNC_SEED_ROOT="$CANONICAL_REPO_ROOT"
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
if ! is_git_checkout "$SYNC_SEED_ROOT" || ! has_remote "$SYNC_SEED_ROOT"; then
|
|
35
|
+
SYNC_SEED_ROOT="$SOURCE_REPO_ROOT"
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
if ! is_git_checkout "$SYNC_SEED_ROOT"; then
|
|
39
|
+
echo "[sync-agent-repo] source repo is not a Git checkout: $SYNC_SEED_ROOT" >&2
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
if ! has_remote "$SYNC_SEED_ROOT"; then
|
|
44
|
+
echo "[sync-agent-repo] missing remote '$REMOTE_NAME' in source repo: $SYNC_SEED_ROOT" >&2
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
bash "${FLOW_TOOLS_DIR}/agent-project-sync-anchor-repo" \
|
|
49
|
+
--canonical-root "$SYNC_SEED_ROOT" \
|
|
50
|
+
--anchor-root "$AGENT_REPO_ROOT" \
|
|
51
|
+
--remote "$REMOTE_NAME" \
|
|
52
|
+
--default-branch "$DEFAULT_BRANCH"
|
|
@@ -0,0 +1,247 @@
|
|
|
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
|
+
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
|
+
AGENT_ROOT="$(flow_resolve_agent_root "${CONFIG_YAML}")"
|
|
12
|
+
STATE_ROOT="$(flow_resolve_state_root "${CONFIG_YAML}")"
|
|
13
|
+
LOCK_DIR="${STATE_ROOT}/dependency-baseline.lock"
|
|
14
|
+
PID_FILE="${LOCK_DIR}/pid"
|
|
15
|
+
HASH_FILE="${STATE_ROOT}/dependency-baseline.sha256"
|
|
16
|
+
PACKAGE_MANAGER_BIN="${ACP_PACKAGE_MANAGER_BIN:-${F_LOSNING_PACKAGE_MANAGER_BIN:-pnpm}}"
|
|
17
|
+
WORKSPACE_BUILD_PACKAGES_RAW="${ACP_WORKSPACE_BUILD_PACKAGES:-${F_LOSNING_WORKSPACE_BUILD_PACKAGES:-}}"
|
|
18
|
+
WORKSPACE_BUILD_ARTIFACTS_RAW="${ACP_WORKSPACE_BUILD_ARTIFACTS:-${F_LOSNING_WORKSPACE_BUILD_ARTIFACTS:-}}"
|
|
19
|
+
declare -a WORKSPACE_BUILD_PACKAGES=()
|
|
20
|
+
declare -a WORKSPACE_BUILD_ARTIFACTS=()
|
|
21
|
+
|
|
22
|
+
usage() {
|
|
23
|
+
cat <<'USAGE'
|
|
24
|
+
Usage:
|
|
25
|
+
sync-dependency-baseline.sh [--force]
|
|
26
|
+
|
|
27
|
+
Ensures the clean automation checkout has a current dependency baseline so
|
|
28
|
+
worker worktrees no longer need to borrow node_modules from the retained human
|
|
29
|
+
checkout.
|
|
30
|
+
USAGE
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
force="false"
|
|
34
|
+
while [[ $# -gt 0 ]]; do
|
|
35
|
+
case "$1" in
|
|
36
|
+
--force) force="true"; shift ;;
|
|
37
|
+
--help|-h) usage; exit 0 ;;
|
|
38
|
+
*) echo "Unknown argument: $1" >&2; usage >&2; exit 1 ;;
|
|
39
|
+
esac
|
|
40
|
+
done
|
|
41
|
+
|
|
42
|
+
realpath_safe() {
|
|
43
|
+
local path_value="${1:-}"
|
|
44
|
+
[[ -n "$path_value" ]] || return 1
|
|
45
|
+
python3 - "$path_value" <<'PY'
|
|
46
|
+
import os
|
|
47
|
+
import sys
|
|
48
|
+
print(os.path.realpath(sys.argv[1]))
|
|
49
|
+
PY
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
split_list() {
|
|
53
|
+
local raw="${1:-}"
|
|
54
|
+
local item=""
|
|
55
|
+
|
|
56
|
+
[[ -n "$raw" ]] || return 0
|
|
57
|
+
while IFS= read -r item; do
|
|
58
|
+
[[ -n "$item" ]] || continue
|
|
59
|
+
printf '%s\n' "$item"
|
|
60
|
+
done < <(tr ' ' '\n' <<<"$raw")
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
discover_workspace_build_packages() {
|
|
64
|
+
local repo_root="${1:?repo root required}"
|
|
65
|
+
python3 - "$repo_root" <<'PY'
|
|
66
|
+
from pathlib import Path
|
|
67
|
+
import json
|
|
68
|
+
import sys
|
|
69
|
+
|
|
70
|
+
repo_root = Path(sys.argv[1])
|
|
71
|
+
packages_root = repo_root / "packages"
|
|
72
|
+
if not packages_root.is_dir():
|
|
73
|
+
raise SystemExit(0)
|
|
74
|
+
|
|
75
|
+
for package_json in sorted(packages_root.glob("*/package.json")):
|
|
76
|
+
try:
|
|
77
|
+
data = json.loads(package_json.read_text(encoding="utf-8"))
|
|
78
|
+
except Exception:
|
|
79
|
+
continue
|
|
80
|
+
name = data.get("name")
|
|
81
|
+
if isinstance(name, str) and name.strip():
|
|
82
|
+
print(name.strip())
|
|
83
|
+
PY
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
load_workspace_lists() {
|
|
87
|
+
local item=""
|
|
88
|
+
|
|
89
|
+
WORKSPACE_BUILD_PACKAGES=()
|
|
90
|
+
if [[ -n "$WORKSPACE_BUILD_PACKAGES_RAW" ]]; then
|
|
91
|
+
while IFS= read -r item; do
|
|
92
|
+
[[ -n "$item" ]] || continue
|
|
93
|
+
WORKSPACE_BUILD_PACKAGES+=("$item")
|
|
94
|
+
done < <(split_list "$WORKSPACE_BUILD_PACKAGES_RAW")
|
|
95
|
+
else
|
|
96
|
+
while IFS= read -r item; do
|
|
97
|
+
[[ -n "$item" ]] || continue
|
|
98
|
+
WORKSPACE_BUILD_PACKAGES+=("$item")
|
|
99
|
+
done < <(discover_workspace_build_packages "$CANONICAL_REPO_ROOT")
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
WORKSPACE_BUILD_ARTIFACTS=()
|
|
103
|
+
if [[ -n "$WORKSPACE_BUILD_ARTIFACTS_RAW" ]]; then
|
|
104
|
+
while IFS= read -r item; do
|
|
105
|
+
[[ -n "$item" ]] || continue
|
|
106
|
+
WORKSPACE_BUILD_ARTIFACTS+=("$item")
|
|
107
|
+
done < <(split_list "$WORKSPACE_BUILD_ARTIFACTS_RAW")
|
|
108
|
+
fi
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
compute_hash() {
|
|
112
|
+
local repo_root="${1:?repo root required}"
|
|
113
|
+
(
|
|
114
|
+
cd "$repo_root"
|
|
115
|
+
local files=()
|
|
116
|
+
local candidate
|
|
117
|
+
for candidate in package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc; do
|
|
118
|
+
[[ -e "$candidate" ]] && files+=("$candidate")
|
|
119
|
+
done
|
|
120
|
+
{
|
|
121
|
+
shasum -a 256 "${files[@]}"
|
|
122
|
+
git rev-parse HEAD 2>/dev/null || true
|
|
123
|
+
} | shasum -a 256 | awk '{print $1}'
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
baseline_paths_ready() {
|
|
128
|
+
local repo_root="${1:?repo root required}"
|
|
129
|
+
local workspace_dir=""
|
|
130
|
+
|
|
131
|
+
[[ -e "$repo_root/node_modules" ]] || return 1
|
|
132
|
+
|
|
133
|
+
while IFS= read -r workspace_dir; do
|
|
134
|
+
[[ -n "$workspace_dir" ]] || continue
|
|
135
|
+
[[ -d "$workspace_dir" ]] || continue
|
|
136
|
+
[[ -e "$workspace_dir/node_modules" ]] || return 1
|
|
137
|
+
done < <(
|
|
138
|
+
find "$repo_root/apps" -mindepth 1 -maxdepth 1 -type d 2>/dev/null || true
|
|
139
|
+
find "$repo_root/packages" -mindepth 1 -maxdepth 1 -type d 2>/dev/null || true
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
workspace_artifacts_ready() {
|
|
144
|
+
local repo_root="${1:?repo root required}"
|
|
145
|
+
local artifact=""
|
|
146
|
+
|
|
147
|
+
if [[ "${#WORKSPACE_BUILD_ARTIFACTS[@]}" -eq 0 ]]; then
|
|
148
|
+
return 0
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
for artifact in "${WORKSPACE_BUILD_ARTIFACTS[@]}"; do
|
|
152
|
+
[[ -f "${repo_root}/${artifact}" ]] || return 1
|
|
153
|
+
done
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
build_workspace_artifacts() {
|
|
157
|
+
local repo_root="${1:?repo root required}"
|
|
158
|
+
local build_args=()
|
|
159
|
+
local pkg=""
|
|
160
|
+
|
|
161
|
+
if [[ "${#WORKSPACE_BUILD_PACKAGES[@]}" -eq 0 ]]; then
|
|
162
|
+
return 0
|
|
163
|
+
fi
|
|
164
|
+
|
|
165
|
+
for pkg in "${WORKSPACE_BUILD_PACKAGES[@]}"; do
|
|
166
|
+
build_args+=(--filter "$pkg")
|
|
167
|
+
done
|
|
168
|
+
|
|
169
|
+
(
|
|
170
|
+
cd "$repo_root"
|
|
171
|
+
CI=1 "$PACKAGE_MANAGER_BIN" "${build_args[@]}" build
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
acquire_lock() {
|
|
176
|
+
mkdir -p "$STATE_ROOT"
|
|
177
|
+
while ! mkdir "$LOCK_DIR" 2>/dev/null; do
|
|
178
|
+
if [[ -f "$PID_FILE" ]]; then
|
|
179
|
+
local existing_pid
|
|
180
|
+
existing_pid="$(cat "$PID_FILE" 2>/dev/null || true)"
|
|
181
|
+
if [[ -n "$existing_pid" ]] && ! kill -0 "$existing_pid" 2>/dev/null; then
|
|
182
|
+
rm -rf "$LOCK_DIR"
|
|
183
|
+
continue
|
|
184
|
+
fi
|
|
185
|
+
else
|
|
186
|
+
rm -rf "$LOCK_DIR"
|
|
187
|
+
continue
|
|
188
|
+
fi
|
|
189
|
+
sleep 1
|
|
190
|
+
done
|
|
191
|
+
printf '%s\n' "$$" >"$PID_FILE"
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
cleanup() {
|
|
195
|
+
rm -rf "$LOCK_DIR"
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
trap cleanup EXIT
|
|
199
|
+
|
|
200
|
+
CANONICAL_REPO_ROOT="$(realpath_safe "$CANONICAL_REPO_ROOT")"
|
|
201
|
+
if [[ ! -d "$CANONICAL_REPO_ROOT/.git" && ! -f "$CANONICAL_REPO_ROOT/.git" ]]; then
|
|
202
|
+
echo "canonical checkout is not a Git repo: $CANONICAL_REPO_ROOT" >&2
|
|
203
|
+
exit 1
|
|
204
|
+
fi
|
|
205
|
+
|
|
206
|
+
if ! command -v "$PACKAGE_MANAGER_BIN" >/dev/null 2>&1; then
|
|
207
|
+
echo "missing package manager: $PACKAGE_MANAGER_BIN" >&2
|
|
208
|
+
exit 1
|
|
209
|
+
fi
|
|
210
|
+
|
|
211
|
+
load_workspace_lists
|
|
212
|
+
expected_hash="$(compute_hash "$CANONICAL_REPO_ROOT")"
|
|
213
|
+
current_hash="$(cat "$HASH_FILE" 2>/dev/null || true)"
|
|
214
|
+
|
|
215
|
+
if [[ "$force" != "true" && "$expected_hash" == "$current_hash" ]] && baseline_paths_ready "$CANONICAL_REPO_ROOT" && workspace_artifacts_ready "$CANONICAL_REPO_ROOT"; then
|
|
216
|
+
printf 'DEPENDENCY_BASELINE=ready\n'
|
|
217
|
+
printf 'REPO_ROOT=%s\n' "$CANONICAL_REPO_ROOT"
|
|
218
|
+
printf 'HASH=%s\n' "$expected_hash"
|
|
219
|
+
exit 0
|
|
220
|
+
fi
|
|
221
|
+
|
|
222
|
+
acquire_lock
|
|
223
|
+
|
|
224
|
+
load_workspace_lists
|
|
225
|
+
expected_hash="$(compute_hash "$CANONICAL_REPO_ROOT")"
|
|
226
|
+
current_hash="$(cat "$HASH_FILE" 2>/dev/null || true)"
|
|
227
|
+
if [[ "$force" != "true" && "$expected_hash" == "$current_hash" ]] && baseline_paths_ready "$CANONICAL_REPO_ROOT" && workspace_artifacts_ready "$CANONICAL_REPO_ROOT"; then
|
|
228
|
+
printf 'DEPENDENCY_BASELINE=ready\n'
|
|
229
|
+
printf 'REPO_ROOT=%s\n' "$CANONICAL_REPO_ROOT"
|
|
230
|
+
printf 'HASH=%s\n' "$expected_hash"
|
|
231
|
+
exit 0
|
|
232
|
+
fi
|
|
233
|
+
|
|
234
|
+
(
|
|
235
|
+
cd "$CANONICAL_REPO_ROOT"
|
|
236
|
+
CI=1 "$PACKAGE_MANAGER_BIN" install --frozen-lockfile --prefer-offline
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
build_workspace_artifacts "$CANONICAL_REPO_ROOT"
|
|
240
|
+
|
|
241
|
+
baseline_paths_ready "$CANONICAL_REPO_ROOT"
|
|
242
|
+
workspace_artifacts_ready "$CANONICAL_REPO_ROOT"
|
|
243
|
+
printf '%s\n' "$expected_hash" >"$HASH_FILE"
|
|
244
|
+
|
|
245
|
+
printf 'DEPENDENCY_BASELINE=updated\n'
|
|
246
|
+
printf 'REPO_ROOT=%s\n' "$CANONICAL_REPO_ROOT"
|
|
247
|
+
printf 'HASH=%s\n' "$expected_hash"
|
|
@@ -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: sync-pr-labels.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}/sync-pr-labels.sh" "$PR_NUMBER"
|
|
@@ -0,0 +1,274 @@
|
|
|
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
|
+
sync-recurring-issue-checklist.sh --repo-slug <owner/repo> --issue-id <id> [--dry-run]
|
|
12
|
+
|
|
13
|
+
Best-effort sync of recurring keep-open issue checklist boxes against merged PR
|
|
14
|
+
history referenced from prior "Opened PR #..." issue comments.
|
|
15
|
+
EOF
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
repo_slug=""
|
|
19
|
+
issue_id=""
|
|
20
|
+
dry_run="false"
|
|
21
|
+
|
|
22
|
+
while [[ $# -gt 0 ]]; do
|
|
23
|
+
case "$1" in
|
|
24
|
+
--repo-slug) repo_slug="${2:-}"; shift 2 ;;
|
|
25
|
+
--issue-id) issue_id="${2:-}"; shift 2 ;;
|
|
26
|
+
--dry-run) dry_run="true"; shift ;;
|
|
27
|
+
--help|-h) usage; exit 0 ;;
|
|
28
|
+
*)
|
|
29
|
+
echo "Unknown argument: $1" >&2
|
|
30
|
+
usage >&2
|
|
31
|
+
exit 1
|
|
32
|
+
;;
|
|
33
|
+
esac
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
if [[ -z "${repo_slug}" || -z "${issue_id}" ]]; then
|
|
37
|
+
usage >&2
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
issue_json="$(flow_github_issue_view_json "${repo_slug}" "${issue_id}")"
|
|
42
|
+
pr_numbers="$(
|
|
43
|
+
ISSUE_JSON="${issue_json}" node -e '
|
|
44
|
+
const issue = JSON.parse(process.env.ISSUE_JSON || "{}");
|
|
45
|
+
const seen = new Set();
|
|
46
|
+
const numbers = [];
|
|
47
|
+
for (const comment of issue.comments || []) {
|
|
48
|
+
const body = String((comment && comment.body) || "");
|
|
49
|
+
for (const match of body.matchAll(/Opened PR #(\d+)/g)) {
|
|
50
|
+
const prNumber = String(match[1] || "").trim();
|
|
51
|
+
if (!prNumber || seen.has(prNumber)) continue;
|
|
52
|
+
seen.add(prNumber);
|
|
53
|
+
numbers.push(prNumber);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
process.stdout.write(numbers.join("\n"));
|
|
57
|
+
'
|
|
58
|
+
)"
|
|
59
|
+
|
|
60
|
+
pr_jsonl_file="$(mktemp)"
|
|
61
|
+
sync_json_file="$(mktemp)"
|
|
62
|
+
trap 'rm -f "${pr_jsonl_file}" "${sync_json_file}"' EXIT
|
|
63
|
+
|
|
64
|
+
while IFS= read -r pr_number; do
|
|
65
|
+
[[ -n "${pr_number}" ]] || continue
|
|
66
|
+
pr_json="$(flow_github_pr_view_json "${repo_slug}" "${pr_number}" 2>/dev/null || true)"
|
|
67
|
+
[[ -n "${pr_json}" ]] || continue
|
|
68
|
+
printf '%s\n' "${pr_json}" >>"${pr_jsonl_file}"
|
|
69
|
+
done <<<"${pr_numbers}"
|
|
70
|
+
|
|
71
|
+
ISSUE_JSON="${issue_json}" PR_JSONL_FILE="${pr_jsonl_file}" node <<'EOF' >"${sync_json_file}"
|
|
72
|
+
const fs = require('fs');
|
|
73
|
+
|
|
74
|
+
const issue = JSON.parse(process.env.ISSUE_JSON || '{}');
|
|
75
|
+
const issueBody = String(issue.body || '');
|
|
76
|
+
const prJsonlFile = process.env.PR_JSONL_FILE || '';
|
|
77
|
+
const prs = [];
|
|
78
|
+
|
|
79
|
+
if (prJsonlFile && fs.existsSync(prJsonlFile)) {
|
|
80
|
+
const raw = fs.readFileSync(prJsonlFile, 'utf8');
|
|
81
|
+
for (const line of raw.split('\n')) {
|
|
82
|
+
const trimmed = line.trim();
|
|
83
|
+
if (!trimmed) continue;
|
|
84
|
+
prs.push(JSON.parse(trimmed));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const labels = new Set((issue.labels || []).map((label) => String(label?.name || '')));
|
|
89
|
+
const isRecurring = labels.has('agent-keep-open');
|
|
90
|
+
const lines = issueBody.split(/\r?\n/);
|
|
91
|
+
const checklistPattern = /^(\s*-\s+\[)( |x|X)(\]\s+)(.*)$/;
|
|
92
|
+
const allChecklistCompletedComment = (issue.comments || []).find((comment) =>
|
|
93
|
+
/^# Blocker: All checklist items already completed\b/m.test(String(comment?.body || '')),
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const stopWords = new Set([
|
|
97
|
+
'a', 'an', 'and', 'are', 'as', 'at', 'be', 'by', 'do', 'does', 'each',
|
|
98
|
+
'for', 'from', 'if', 'in', 'into', 'is', 'it', 'its', 'now', 'of', 'on',
|
|
99
|
+
'one', 'only', 'or', 'per', 'so', 'than', 'that', 'the', 'their', 'them',
|
|
100
|
+
'then', 'this', 'to', 'up', 'with', 'within',
|
|
101
|
+
]);
|
|
102
|
+
|
|
103
|
+
const splitCamel = (value) =>
|
|
104
|
+
String(value || '')
|
|
105
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
106
|
+
.replace(/([A-Z])([A-Z][a-z])/g, '$1 $2');
|
|
107
|
+
|
|
108
|
+
const normalizeWords = (value) =>
|
|
109
|
+
splitCamel(value)
|
|
110
|
+
.replace(/[`*_()[\]{}:;,!?/\\]+/g, ' ')
|
|
111
|
+
.replace(/\.(?=[A-Za-z])/g, ' ')
|
|
112
|
+
.toLowerCase()
|
|
113
|
+
.split(/[^a-z0-9-]+/)
|
|
114
|
+
.map((token) => token.trim())
|
|
115
|
+
.filter((token) => token.length >= 3 && !stopWords.has(token));
|
|
116
|
+
|
|
117
|
+
const unique = (items) => [...new Set(items.filter(Boolean))];
|
|
118
|
+
|
|
119
|
+
const extractCodeTokens = (value) => {
|
|
120
|
+
const raw = String(value || '');
|
|
121
|
+
const tokens = [];
|
|
122
|
+
for (const match of raw.matchAll(/`([^`]+)`/g)) {
|
|
123
|
+
tokens.push(match[1]);
|
|
124
|
+
}
|
|
125
|
+
for (const match of raw.matchAll(/\B--[a-z0-9-]+\b/gi)) {
|
|
126
|
+
tokens.push(match[0]);
|
|
127
|
+
}
|
|
128
|
+
for (const match of raw.matchAll(/\b[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+\b/g)) {
|
|
129
|
+
tokens.push(match[0]);
|
|
130
|
+
}
|
|
131
|
+
return unique(
|
|
132
|
+
tokens.map((token) =>
|
|
133
|
+
String(token || '')
|
|
134
|
+
.replace(/[`*_()[\]{}:;,!?/\\]+/g, ' ')
|
|
135
|
+
.trim()
|
|
136
|
+
.toLowerCase(),
|
|
137
|
+
),
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const mergedPrs = prs.filter((pr) => String(pr.mergedAt || '').trim() || String(pr.state || '').toUpperCase() === 'MERGED');
|
|
142
|
+
|
|
143
|
+
const buildPrMatcher = (pr) => {
|
|
144
|
+
const combined = `${pr.title || ''}\n${pr.body || ''}`;
|
|
145
|
+
return {
|
|
146
|
+
number: pr.number,
|
|
147
|
+
combinedLower: combined.toLowerCase(),
|
|
148
|
+
words: new Set(normalizeWords(combined)),
|
|
149
|
+
codeTokens: new Set(extractCodeTokens(combined)),
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const prMatchers = mergedPrs.map(buildPrMatcher);
|
|
154
|
+
|
|
155
|
+
const matchChecklistItem = (itemText) => {
|
|
156
|
+
const itemWords = unique(normalizeWords(itemText));
|
|
157
|
+
const itemCodeTokens = unique(extractCodeTokens(itemText));
|
|
158
|
+
let best = null;
|
|
159
|
+
|
|
160
|
+
for (const pr of prMatchers) {
|
|
161
|
+
const matchedWords = itemWords.filter((word) => pr.words.has(word));
|
|
162
|
+
const matchedCodeTokens = itemCodeTokens.filter((token) =>
|
|
163
|
+
pr.codeTokens.has(token) || pr.combinedLower.includes(token),
|
|
164
|
+
);
|
|
165
|
+
const wordScore = itemWords.length > 0 ? matchedWords.length / itemWords.length : 0;
|
|
166
|
+
const codeScore = itemCodeTokens.length > 0 ? matchedCodeTokens.length / itemCodeTokens.length : 0;
|
|
167
|
+
|
|
168
|
+
let matched = false;
|
|
169
|
+
if (itemCodeTokens.length > 0) {
|
|
170
|
+
matched =
|
|
171
|
+
(matchedCodeTokens.length > 0 && (codeScore >= 0.5 || wordScore >= 0.35)) ||
|
|
172
|
+
(matchedWords.length >= 2 && wordScore >= 0.45);
|
|
173
|
+
} else {
|
|
174
|
+
matched = matchedWords.length >= 2 && wordScore >= 0.45;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!matched) continue;
|
|
178
|
+
|
|
179
|
+
const candidate = {
|
|
180
|
+
number: pr.number,
|
|
181
|
+
wordScore,
|
|
182
|
+
codeScore,
|
|
183
|
+
matchedWords: matchedWords.length,
|
|
184
|
+
matchedCodeTokens: matchedCodeTokens.length,
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
if (
|
|
188
|
+
!best ||
|
|
189
|
+
candidate.codeScore > best.codeScore ||
|
|
190
|
+
candidate.wordScore > best.wordScore ||
|
|
191
|
+
candidate.matchedWords > best.matchedWords
|
|
192
|
+
) {
|
|
193
|
+
best = candidate;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return best;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const checklistEntries = [];
|
|
201
|
+
const matchedPrNumbers = new Set();
|
|
202
|
+
let changed = false;
|
|
203
|
+
|
|
204
|
+
const updatedLines = lines.map((line, index) => {
|
|
205
|
+
const match = line.match(checklistPattern);
|
|
206
|
+
if (!match) return line;
|
|
207
|
+
|
|
208
|
+
const checked = String(match[2] || '').toLowerCase() === 'x';
|
|
209
|
+
const text = String(match[4] || '');
|
|
210
|
+
const entry = { index, checked, text, matchedPr: null };
|
|
211
|
+
|
|
212
|
+
if (!checked) {
|
|
213
|
+
if (allChecklistCompletedComment) {
|
|
214
|
+
changed = true;
|
|
215
|
+
checklistEntries.push({ ...entry, checked: true, matchedByWorkflowComment: true });
|
|
216
|
+
return `${match[1]}x${match[3]}${text}`;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
entry.matchedPr = matchChecklistItem(text);
|
|
220
|
+
if (entry.matchedPr) {
|
|
221
|
+
matchedPrNumbers.add(String(entry.matchedPr.number));
|
|
222
|
+
changed = true;
|
|
223
|
+
checklistEntries.push({ ...entry, checked: true });
|
|
224
|
+
return `${match[1]}x${match[3]}${text}`;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
checklistEntries.push(entry);
|
|
229
|
+
return line;
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const total = checklistEntries.length;
|
|
233
|
+
const checkedCount = checklistEntries.filter((entry) => entry.checked || entry.matchedPr).length;
|
|
234
|
+
const uncheckedCount = Math.max(total - checkedCount, 0);
|
|
235
|
+
|
|
236
|
+
let status = 'noop';
|
|
237
|
+
if (!isRecurring) {
|
|
238
|
+
status = 'skipped-not-recurring';
|
|
239
|
+
} else if (total === 0) {
|
|
240
|
+
status = 'skipped-no-checklist';
|
|
241
|
+
} else if (changed) {
|
|
242
|
+
status = 'updated';
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const result = {
|
|
246
|
+
status,
|
|
247
|
+
total,
|
|
248
|
+
checked: checkedCount,
|
|
249
|
+
unchecked: uncheckedCount,
|
|
250
|
+
changed,
|
|
251
|
+
matchedPrNumbers: [...matchedPrNumbers],
|
|
252
|
+
body: changed ? updatedLines.join('\n') : issueBody,
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
256
|
+
EOF
|
|
257
|
+
|
|
258
|
+
sync_status="$(jq -r '.status' "${sync_json_file}")"
|
|
259
|
+
total_count="$(jq -r '.total' "${sync_json_file}")"
|
|
260
|
+
checked_count="$(jq -r '.checked' "${sync_json_file}")"
|
|
261
|
+
unchecked_count="$(jq -r '.unchecked' "${sync_json_file}")"
|
|
262
|
+
changed="$(jq -r '.changed' "${sync_json_file}")"
|
|
263
|
+
matched_pr_numbers="$(jq -r '.matchedPrNumbers | join(",")' "${sync_json_file}")"
|
|
264
|
+
|
|
265
|
+
if [[ "${dry_run}" != "true" && "${changed}" == "true" ]]; then
|
|
266
|
+
updated_body="$(jq -r '.body' "${sync_json_file}")"
|
|
267
|
+
flow_github_issue_update_body "${repo_slug}" "${issue_id}" "${updated_body}"
|
|
268
|
+
fi
|
|
269
|
+
|
|
270
|
+
printf 'CHECKLIST_SYNC_STATUS=%s\n' "${sync_status}"
|
|
271
|
+
printf 'CHECKLIST_TOTAL=%s\n' "${total_count}"
|
|
272
|
+
printf 'CHECKLIST_CHECKED=%s\n' "${checked_count}"
|
|
273
|
+
printf 'CHECKLIST_UNCHECKED=%s\n' "${unchecked_count}"
|
|
274
|
+
printf 'CHECKLIST_MATCHED_PR_NUMBERS=%s\n' "${matched_pr_numbers}"
|