@fitlab-ai/agent-infra 0.9.10 → 0.9.12
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/README.md +19 -9
- package/README.zh-CN.md +19 -9
- package/bin/cli.ts +17 -4
- package/dist/bin/cli.js +19 -4
- package/dist/bin/internal-cli.js +55 -4
- package/dist/lib/agent-client.js +0 -1
- package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +71 -10
- package/dist/lib/agent-clients/adapters/opencode-sandbox.js +0 -4
- package/dist/lib/agent-clients/adapters/traecli.js +7 -8
- package/dist/lib/agent-clients/config.js +14 -99
- package/dist/lib/agent-clients/reconcile.js +1 -11
- package/dist/lib/agent-clients/schema.js +5 -4
- package/dist/lib/agent-clients/tokens.js +5 -15
- package/dist/lib/decide.js +14 -30
- package/dist/lib/defaults.json +8 -0
- package/dist/lib/git/workflow.js +43 -1
- package/dist/lib/init.js +3 -2
- package/dist/lib/internal/git-workflow.js +8 -1
- package/dist/lib/internal/platform-pr.js +8 -2
- package/dist/lib/internal/release-workflow.js +0 -1
- package/dist/lib/internal/task-delivery.js +59 -0
- package/dist/lib/internal/task-finalization.js +19 -9
- package/dist/lib/internal/task-ledger.js +8 -2
- package/dist/lib/internal/task-lifecycle.js +17 -93
- package/dist/lib/internal/task-orchestration.js +30 -216
- package/dist/lib/internal/task-validate.js +2 -1
- package/dist/lib/merge.js +205 -103
- package/dist/lib/platform/github-client.js +7 -1
- package/dist/lib/platform/pr-checks.js +8 -5
- package/dist/lib/platform/pr-summary.js +12 -8
- package/dist/lib/platform/pull-requests.js +393 -91
- package/dist/lib/platform/verification-required.js +13 -2
- package/dist/lib/platform/verification-sync.js +9 -4
- package/dist/lib/pr-review/evidence-grading.js +12 -4
- package/dist/lib/process-data/normalize.js +2 -9
- package/dist/lib/run/host.js +46 -16
- package/dist/lib/sandbox/agent-client-reconciler.js +4 -12
- package/dist/lib/sandbox/commands/create.js +3 -3
- package/dist/lib/sandbox/commands/enter.js +18 -4
- package/dist/lib/sandbox/config.js +8 -12
- package/dist/lib/sandbox/control/executor.js +131 -39
- package/dist/lib/sandbox/control/lifecycle.js +55 -24
- package/dist/lib/sandbox/control/server.js +18 -16
- package/dist/lib/sandbox/mounts.js +3 -2
- package/dist/lib/sandbox/recovery.js +123 -22
- package/dist/lib/sandbox/workspace-identity.js +14 -0
- package/dist/lib/sandbox/workspace-view.js +8 -9
- package/dist/lib/self-update.js +278 -0
- package/dist/lib/server/process-state.js +2 -2
- package/dist/lib/server/protocol.js +5 -5
- package/dist/lib/task/activity-log.js +4 -1
- package/dist/lib/task/artifact-lifecycle.js +6 -4
- package/dist/lib/task/codex-orchestration.js +1 -1
- package/dist/lib/task/command-options.js +1 -3
- package/dist/lib/task/commands/cat.js +0 -5
- package/dist/lib/task/commands/decisions.js +76 -92
- package/dist/lib/task/commands/files.js +6 -6
- package/dist/lib/task/commands/grep.js +25 -61
- package/dist/lib/task/commands/issue-body.js +6 -6
- package/dist/lib/task/commands/log.js +25 -10
- package/dist/lib/task/commands/show.js +5 -6
- package/dist/lib/task/commands/status.js +8 -8
- package/dist/lib/task/commit-intent.js +100 -0
- package/dist/lib/task/commit-operation.js +181 -91
- package/dist/lib/task/commit-policy.js +1 -1
- package/dist/lib/task/control-authority.js +431 -0
- package/dist/lib/task/create.js +39 -8
- package/dist/lib/task/current-contract.js +35 -0
- package/dist/lib/task/decision-details.js +218 -0
- package/dist/lib/task/decision-intents.js +5 -2
- package/dist/lib/task/delivery-target.js +97 -0
- package/dist/lib/task/delivery.js +153 -0
- package/dist/lib/task/events.js +11 -5
- package/dist/lib/task/human-override.js +5 -2
- package/dist/lib/task/index.js +19 -20
- package/dist/lib/task/ledger-intents.js +8 -9
- package/dist/lib/task/ledger.js +13 -6
- package/dist/lib/task/lifecycle.js +122 -9
- package/dist/lib/task/orchestration.js +105 -75
- package/dist/lib/task/pr-delivery-fact.js +182 -0
- package/dist/lib/task/review-artifacts.js +31 -12
- package/dist/lib/task/review-finalization.js +13 -4
- package/dist/lib/task/review-fingerprint.js +8 -0
- package/dist/lib/task/verification-engine.js +86 -39
- package/dist/lib/task/verification-review.js +2 -2
- package/dist/lib/task/workspace-snapshot.js +5 -11
- package/dist/lib/task/write.js +11 -1
- package/dist/lib/update.js +13 -35
- package/dist/lib/version.js +5 -1
- package/dist/lifecycle-build-manifest.json +3 -3
- package/lib/agent-client.ts +0 -1
- package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +105 -10
- package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +12 -1
- package/lib/agent-clients/adapters/opencode-sandbox.ts +0 -5
- package/lib/agent-clients/adapters/traecli.ts +7 -8
- package/lib/agent-clients/config.ts +14 -144
- package/lib/agent-clients/reconcile.ts +1 -12
- package/lib/agent-clients/schema.ts +5 -4
- package/lib/agent-clients/tokens.ts +5 -18
- package/lib/decide.ts +12 -22
- package/lib/defaults.json +8 -0
- package/lib/git/workflow.ts +38 -1
- package/lib/init.ts +5 -2
- package/lib/internal/git-workflow.ts +7 -1
- package/lib/internal/platform-pr.ts +8 -1
- package/lib/internal/release-workflow.ts +0 -1
- package/lib/internal/task-delivery.ts +53 -0
- package/lib/internal/task-finalization.ts +27 -13
- package/lib/internal/task-ledger.ts +8 -2
- package/lib/internal/task-lifecycle.ts +33 -76
- package/lib/internal/task-orchestration.ts +33 -190
- package/lib/internal/task-validate.ts +3 -2
- package/lib/merge.ts +236 -120
- package/lib/platform/github-client.ts +8 -1
- package/lib/platform/pr-checks.ts +7 -5
- package/lib/platform/pr-summary.ts +10 -7
- package/lib/platform/pull-requests.ts +425 -87
- package/lib/platform/verification-required.ts +12 -2
- package/lib/platform/verification-sync.ts +9 -4
- package/lib/pr-review/evidence-grading.ts +7 -4
- package/lib/process-data/normalize.ts +2 -8
- package/lib/run/host.ts +63 -14
- package/lib/sandbox/agent-client-reconciler.ts +5 -15
- package/lib/sandbox/commands/create.ts +4 -4
- package/lib/sandbox/commands/enter.ts +24 -4
- package/lib/sandbox/config.ts +9 -14
- package/lib/sandbox/control/container-identity.ts +2 -2
- package/lib/sandbox/control/executor.ts +148 -51
- package/lib/sandbox/control/lifecycle.ts +59 -31
- package/lib/sandbox/control/protocol.ts +1 -3
- package/lib/sandbox/control/server.ts +15 -12
- package/lib/sandbox/control/state.ts +7 -7
- package/lib/sandbox/mounts.ts +4 -3
- package/lib/sandbox/recovery.ts +162 -34
- package/lib/sandbox/tools.ts +1 -1
- package/lib/sandbox/workspace-identity.ts +28 -0
- package/lib/sandbox/workspace-view.ts +14 -10
- package/lib/self-update.ts +341 -0
- package/lib/server/process-state.ts +2 -2
- package/lib/server/protocol.ts +5 -5
- package/lib/task/activity-log.ts +6 -1
- package/lib/task/artifact-lifecycle.ts +7 -5
- package/lib/task/codex-orchestration.ts +2 -1
- package/lib/task/command-options.ts +1 -2
- package/lib/task/commands/cat.ts +0 -4
- package/lib/task/commands/decisions.ts +80 -75
- package/lib/task/commands/files.ts +6 -6
- package/lib/task/commands/grep.ts +23 -51
- package/lib/task/commands/issue-body.ts +6 -6
- package/lib/task/commands/log.ts +22 -10
- package/lib/task/commands/show.ts +5 -6
- package/lib/task/commands/status.ts +8 -8
- package/lib/task/commit-intent.ts +137 -0
- package/lib/task/commit-operation.ts +161 -79
- package/lib/task/commit-policy.ts +1 -2
- package/lib/task/control-authority.ts +563 -0
- package/lib/task/create.ts +40 -10
- package/lib/task/current-contract.ts +49 -0
- package/lib/task/decision-details.ts +280 -0
- package/lib/task/decision-intents.ts +7 -2
- package/lib/task/delivery-target.ts +130 -0
- package/lib/task/delivery.ts +160 -0
- package/lib/task/events.ts +10 -5
- package/lib/task/human-override.ts +5 -2
- package/lib/task/index.ts +19 -20
- package/lib/task/ledger-intents.ts +6 -8
- package/lib/task/ledger.ts +17 -7
- package/lib/task/lifecycle.ts +113 -4
- package/lib/task/orchestration.ts +102 -80
- package/lib/task/pr-delivery-fact.ts +254 -0
- package/lib/task/review-artifacts.ts +53 -15
- package/lib/task/review-finalization.ts +21 -5
- package/lib/task/review-fingerprint.ts +10 -0
- package/lib/task/verification-engine.ts +78 -46
- package/lib/task/verification-review.ts +3 -1
- package/lib/task/workspace-snapshot.ts +4 -13
- package/lib/task/write.ts +20 -1
- package/lib/update.ts +14 -38
- package/lib/version.ts +6 -1
- package/package.json +1 -1
- package/templates/.agents/README.en.md +5 -3
- package/templates/.agents/README.zh-CN.md +5 -3
- package/templates/.agents/rules/README.en.md +4 -2
- package/templates/.agents/rules/README.zh-CN.md +4 -2
- package/templates/.agents/rules/compatibility-policy.en.md +5 -4
- package/templates/.agents/rules/compatibility-policy.zh-CN.md +5 -4
- package/templates/.agents/rules/create-issue.en.md +11 -2
- package/templates/.agents/rules/create-issue.zh-CN.md +24 -2
- package/templates/.agents/rules/human-decision-context.en.md +9 -7
- package/templates/.agents/rules/human-decision-context.zh-CN.md +9 -7
- package/templates/.agents/rules/{issue-fields.github.en.md → issue-fields.en.md} +1 -1
- package/templates/.agents/rules/{issue-fields.github.zh-CN.md → issue-fields.zh-CN.md} +1 -1
- package/templates/.agents/rules/issue-pr-commands.en.md +5 -18
- package/templates/.agents/rules/issue-pr-commands.zh-CN.md +1 -1
- package/templates/.agents/rules/issue-sync.en.md +26 -5
- package/templates/.agents/rules/issue-sync.zh-CN.md +62 -5
- package/templates/.agents/rules/label-milestone-setup.en.md +15 -2
- package/templates/.agents/rules/label-milestone-setup.zh-CN.md +15 -2
- package/templates/.agents/rules/local-artifact-repair.en.md +46 -0
- package/templates/.agents/rules/local-artifact-repair.zh-CN.md +46 -0
- package/templates/.agents/rules/milestone-inference.en.md +12 -2
- package/templates/.agents/rules/milestone-inference.zh-CN.md +25 -3
- package/templates/.agents/rules/next-step-output.en.md +3 -3
- package/templates/.agents/rules/next-step-output.zh-CN.md +3 -3
- package/templates/.agents/rules/no-mid-flow-questions.en.md +1 -1
- package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +1 -1
- package/templates/.agents/rules/pr-sync.en.md +23 -14
- package/templates/.agents/rules/pr-sync.zh-CN.md +23 -2
- package/templates/.agents/rules/release-commands.en.md +42 -3
- package/templates/.agents/rules/release-commands.zh-CN.md +42 -3
- package/templates/.agents/rules/review-handshake.en.md +1 -1
- package/templates/.agents/rules/review-handshake.zh-CN.md +1 -1
- package/templates/.agents/rules/security-alerts.en.md +17 -2
- package/templates/.agents/rules/security-alerts.zh-CN.md +17 -2
- package/templates/.agents/rules/sync-content-generation.en.md +8 -0
- package/templates/.agents/rules/sync-content-generation.zh-CN.md +8 -0
- package/templates/.agents/rules/task-management.en.md +2 -3
- package/templates/.agents/rules/task-management.zh-CN.md +2 -3
- package/templates/.agents/scripts/security-alerts.github.sh +151 -0
- package/templates/.agents/scripts/security-alerts.sh +31 -0
- package/templates/.agents/skills/analyze-task/SKILL.en.md +4 -3
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +4 -3
- package/templates/.agents/skills/block-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/cancel-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/check-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/check-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/close-codescan/SKILL.en.md +3 -3
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +3 -3
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/code-task/SKILL.en.md +8 -5
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +9 -6
- package/templates/.agents/skills/commit/SKILL.en.md +30 -10
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +6 -7
- package/templates/.agents/skills/commit/config/verify.json +1 -1
- package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +3 -3
- package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +3 -3
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +2 -2
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +2 -2
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +7 -6
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +7 -6
- package/templates/.agents/skills/complete-manual-validation/config/verify.en.json +1 -1
- package/templates/.agents/skills/complete-manual-validation/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +1 -1
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +1 -1
- package/templates/.agents/skills/complete-task/SKILL.en.md +13 -13
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +13 -13
- package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +2 -2
- package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +2 -2
- package/templates/.agents/skills/create-pr/SKILL.en.md +9 -11
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +9 -11
- package/templates/.agents/skills/create-pr/reference/change-report.en.md +9 -4
- package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +9 -4
- package/templates/.agents/skills/create-pr/scripts/change-report.mjs +203 -0
- package/templates/.agents/skills/create-release-note/SKILL.en.md +5 -6
- package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +5 -6
- package/templates/.agents/skills/create-task/SKILL.en.md +2 -1
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +2 -1
- package/templates/.agents/skills/import-codescan/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/import-issue/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/init-labels/SKILL.en.md +9 -10
- package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +9 -10
- package/templates/.agents/skills/init-labels/scripts/init-labels.github.sh +57 -1
- package/templates/.agents/skills/init-labels/scripts/init-labels.sh +27 -1
- package/templates/.agents/skills/init-milestones/SKILL.en.md +3 -5
- package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +3 -5
- package/templates/.agents/skills/plan-task/SKILL.en.md +4 -3
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +4 -3
- package/templates/.agents/skills/restore-task/SKILL.en.md +1 -1
- package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/review-analysis/SKILL.en.md +8 -5
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +8 -5
- package/templates/.agents/skills/review-analysis/config/verify.en.json +1 -0
- package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +18 -0
- package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +18 -0
- package/templates/.agents/skills/review-code/SKILL.en.md +11 -8
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +11 -8
- package/templates/.agents/skills/review-code/config/verify.en.json +1 -0
- package/templates/.agents/skills/review-code/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/review-code/reference/migration-risks.en.md +2 -1
- package/templates/.agents/skills/review-code/reference/migration-risks.zh-CN.md +2 -1
- package/templates/.agents/skills/review-code/reference/output-templates.en.md +19 -1
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +19 -1
- package/templates/.agents/skills/review-code/reference/report-template.en.md +4 -2
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +4 -2
- package/templates/.agents/skills/review-plan/SKILL.en.md +8 -5
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +8 -5
- package/templates/.agents/skills/review-plan/config/verify.en.json +1 -0
- package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/review-plan/reference/output-templates.en.md +18 -0
- package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +18 -0
- package/templates/.agents/skills/review-pr/SKILL.en.md +1 -0
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +1 -0
- package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +2 -2
- package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +2 -2
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +5 -0
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +5 -0
- package/templates/.agents/skills/run-task/SKILL.en.md +5 -1
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +5 -1
- package/templates/.agents/skills/update-agent-infra/SKILL.en.md +2 -2
- package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +144 -109
- package/templates/.agents/skills/watch-pr/SKILL.en.md +5 -5
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +5 -5
- package/templates/.agents/templates/task.en.md +6 -2
- package/templates/.agents/templates/task.zh-CN.md +6 -2
- package/templates/.agents/workflows/bug-fix.en.yaml +9 -8
- package/templates/.agents/workflows/bug-fix.zh-CN.yaml +9 -8
- package/templates/.agents/workflows/feature-development.en.yaml +9 -8
- package/templates/.agents/workflows/feature-development.zh-CN.yaml +9 -8
- package/templates/.agents/workflows/refactoring.en.yaml +9 -8
- package/templates/.agents/workflows/refactoring.zh-CN.yaml +9 -8
- package/templates/.claude/commands/analyze-task.en.md +1 -1
- package/templates/.claude/commands/analyze-task.zh-CN.md +1 -1
- package/templates/.claude/commands/block-task.en.md +1 -1
- package/templates/.claude/commands/block-task.zh-CN.md +1 -1
- package/templates/.claude/commands/cancel-task.en.md +1 -1
- package/templates/.claude/commands/cancel-task.zh-CN.md +1 -1
- package/templates/.claude/commands/check-task.en.md +1 -1
- package/templates/.claude/commands/check-task.zh-CN.md +1 -1
- package/templates/.claude/commands/code-task.en.md +1 -1
- package/templates/.claude/commands/code-task.zh-CN.md +1 -1
- package/templates/.claude/commands/commit.en.md +1 -1
- package/templates/.claude/commands/commit.zh-CN.md +1 -1
- package/templates/.claude/commands/complete-manual-validation.en.md +1 -1
- package/templates/.claude/commands/complete-manual-validation.zh-CN.md +1 -1
- package/templates/.claude/commands/complete-task.en.md +1 -1
- package/templates/.claude/commands/complete-task.zh-CN.md +1 -1
- package/templates/.claude/commands/create-pr.en.md +1 -1
- package/templates/.claude/commands/create-pr.zh-CN.md +1 -1
- package/templates/.claude/commands/plan-task.en.md +1 -1
- package/templates/.claude/commands/plan-task.zh-CN.md +1 -1
- package/templates/.claude/commands/review-analysis.en.md +1 -1
- package/templates/.claude/commands/review-analysis.zh-CN.md +1 -1
- package/templates/.claude/commands/review-code.en.md +1 -1
- package/templates/.claude/commands/review-code.zh-CN.md +1 -1
- package/templates/.claude/commands/review-plan.en.md +1 -1
- package/templates/.claude/commands/review-plan.zh-CN.md +1 -1
- package/templates/.claude/commands/run-manual-validation.en.md +1 -1
- package/templates/.claude/commands/run-manual-validation.zh-CN.md +1 -1
- package/templates/.claude/commands/run-task.en.md +1 -1
- package/templates/.claude/commands/run-task.zh-CN.md +1 -1
- package/templates/.claude/commands/watch-pr.en.md +1 -1
- package/templates/.claude/commands/watch-pr.zh-CN.md +1 -1
- package/templates/{.trae/skills → .traecli/commands}/update-agent-infra.en.md +0 -1
- package/templates/{.trae/skills → .traecli/commands}/update-agent-infra.zh-CN.md +0 -1
- package/dist/lib/builtin-tuis.js +0 -40
- package/lib/builtin-tuis.ts +0 -56
- package/templates/.agents/rules/create-issue.github.en.md +0 -14
- package/templates/.agents/rules/create-issue.github.zh-CN.md +0 -27
- package/templates/.agents/rules/issue-pr-commands.github.en.md +0 -34
- package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +0 -49
- package/templates/.agents/rules/issue-sync.github.en.md +0 -40
- package/templates/.agents/rules/issue-sync.github.zh-CN.md +0 -76
- package/templates/.agents/rules/label-milestone-setup.github.en.md +0 -60
- package/templates/.agents/rules/label-milestone-setup.github.zh-CN.md +0 -60
- package/templates/.agents/rules/milestone-inference.github.en.md +0 -15
- package/templates/.agents/rules/milestone-inference.github.zh-CN.md +0 -27
- package/templates/.agents/rules/pr-checks-commands.github.en.md +0 -18
- package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +0 -34
- package/templates/.agents/rules/pr-sync.github.en.md +0 -43
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +0 -69
- package/templates/.agents/rules/release-commands.github.en.md +0 -38
- package/templates/.agents/rules/release-commands.github.zh-CN.md +0 -38
- package/templates/.agents/rules/security-alerts.github.en.md +0 -43
- package/templates/.agents/rules/security-alerts.github.zh-CN.md +0 -43
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
function intentRoot(repoRoot) {
|
|
5
|
+
return path.join(repoRoot, '.agents', 'workspace', '.task-commit-intents');
|
|
6
|
+
}
|
|
7
|
+
function intentPath(repoRoot, taskId) {
|
|
8
|
+
return path.join(intentRoot(repoRoot), `${taskId}.json`);
|
|
9
|
+
}
|
|
10
|
+
function checkpointIntentDigest(identity) {
|
|
11
|
+
return createHash('sha256').update(JSON.stringify({
|
|
12
|
+
taskId: identity.taskId,
|
|
13
|
+
branch: identity.branch,
|
|
14
|
+
mode: identity.mode,
|
|
15
|
+
expectedHead: identity.expectedHead,
|
|
16
|
+
expectedTree: identity.expectedTree,
|
|
17
|
+
paths: [...identity.paths],
|
|
18
|
+
message: identity.message,
|
|
19
|
+
round: identity.round
|
|
20
|
+
})).digest('hex');
|
|
21
|
+
}
|
|
22
|
+
function isIntent(value) {
|
|
23
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
24
|
+
return false;
|
|
25
|
+
const intent = value;
|
|
26
|
+
return intent.version === 1
|
|
27
|
+
&& typeof intent.taskId === 'string' && intent.taskId.length > 0
|
|
28
|
+
&& typeof intent.branch === 'string' && intent.branch.length > 0
|
|
29
|
+
&& intent.mode === 'local'
|
|
30
|
+
&& typeof intent.expectedHead === 'string' && /^[a-f0-9]{40,64}$/.test(intent.expectedHead)
|
|
31
|
+
&& typeof intent.expectedTree === 'string' && /^[a-f0-9]{40,64}$/.test(intent.expectedTree)
|
|
32
|
+
&& Array.isArray(intent.paths) && intent.paths.every((item) => typeof item === 'string' && item.length > 0)
|
|
33
|
+
&& typeof intent.message === 'string' && intent.message.length > 0
|
|
34
|
+
&& Number.isSafeInteger(intent.round) && Number(intent.round) > 0
|
|
35
|
+
&& typeof intent.digest === 'string' && /^[a-f0-9]{64}$/.test(intent.digest)
|
|
36
|
+
&& ['prepared', 'committed', 'synced'].includes(String(intent.state))
|
|
37
|
+
&& (intent.committedHead === null || (typeof intent.committedHead === 'string' && /^[a-f0-9]{40,64}$/.test(intent.committedHead)))
|
|
38
|
+
&& typeof intent.createdAt === 'string' && intent.createdAt.length > 0
|
|
39
|
+
&& typeof intent.updatedAt === 'string' && intent.updatedAt.length > 0
|
|
40
|
+
&& intent.digest === checkpointIntentDigest(intent);
|
|
41
|
+
}
|
|
42
|
+
function readCheckpointIntent(repoRoot, taskId) {
|
|
43
|
+
const target = intentPath(repoRoot, taskId);
|
|
44
|
+
if (!fs.existsSync(target))
|
|
45
|
+
return null;
|
|
46
|
+
const value = JSON.parse(fs.readFileSync(target, 'utf8'));
|
|
47
|
+
if (!isIntent(value))
|
|
48
|
+
throw new Error('COMMIT_INTENT_INVALID: checkpoint intent schema is invalid');
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
function writeCheckpointIntent(repoRoot, value) {
|
|
52
|
+
if (!isIntent(value))
|
|
53
|
+
throw new Error('COMMIT_INTENT_INVALID: checkpoint intent schema is invalid');
|
|
54
|
+
const directory = intentRoot(repoRoot);
|
|
55
|
+
fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
56
|
+
const target = intentPath(repoRoot, value.taskId);
|
|
57
|
+
const temporary = `${target}.${process.pid}.${Date.now()}.tmp`;
|
|
58
|
+
fs.writeFileSync(temporary, `${JSON.stringify(value)}\n`, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
|
|
59
|
+
try {
|
|
60
|
+
fs.renameSync(temporary, target);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
try {
|
|
64
|
+
fs.unlinkSync(temporary);
|
|
65
|
+
}
|
|
66
|
+
catch { /* preserve primary error */ }
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function updateCheckpointIntent(value, patch) {
|
|
71
|
+
const next = { ...value, ...patch };
|
|
72
|
+
if (next.state === 'prepared' && next.committedHead !== null)
|
|
73
|
+
throw new Error('COMMIT_INTENT_INVALID: prepared intent cannot have a committed head');
|
|
74
|
+
if (next.state !== 'prepared' && !next.committedHead)
|
|
75
|
+
throw new Error('COMMIT_INTENT_INVALID: committed intent requires a committed head');
|
|
76
|
+
return next;
|
|
77
|
+
}
|
|
78
|
+
function removeCheckpointIntent(repoRoot, taskId) {
|
|
79
|
+
const target = intentPath(repoRoot, taskId);
|
|
80
|
+
try {
|
|
81
|
+
fs.unlinkSync(target);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (error.code !== 'ENOENT')
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function sameCheckpointIntent(left, right) {
|
|
89
|
+
return left.digest === checkpointIntentDigest(right)
|
|
90
|
+
&& left.taskId === right.taskId
|
|
91
|
+
&& left.branch === right.branch
|
|
92
|
+
&& left.mode === right.mode
|
|
93
|
+
&& left.expectedHead === right.expectedHead
|
|
94
|
+
&& left.expectedTree === right.expectedTree
|
|
95
|
+
&& left.message === right.message
|
|
96
|
+
&& left.round === right.round
|
|
97
|
+
&& JSON.stringify(left.paths) === JSON.stringify(right.paths);
|
|
98
|
+
}
|
|
99
|
+
export { checkpointIntentDigest, intentPath, intentRoot, isIntent, readCheckpointIntent, removeCheckpointIntent, sameCheckpointIntent, updateCheckpointIntent, writeCheckpointIntent };
|
|
100
|
+
//# sourceMappingURL=commit-intent.js.map
|
|
@@ -8,7 +8,7 @@ import { mergeOperationWarnings } from './operation-outcome.js';
|
|
|
8
8
|
import { TaskExecutionLockError, withRepositoryMutationLock, withTaskExecutionLock } from './task-execution-lock.js';
|
|
9
9
|
import { appendActivityEntry, locateActivityLog } from './activity-log.js';
|
|
10
10
|
import { captureTaskWriteMetadata, writeTask } from './write.js';
|
|
11
|
-
import {
|
|
11
|
+
import { checkpointIntentDigest, readCheckpointIntent, removeCheckpointIntent, sameCheckpointIntent, updateCheckpointIntent, writeCheckpointIntent } from './commit-intent.js';
|
|
12
12
|
const HEAD_REF = /^refs\/heads\/(.+)$/;
|
|
13
13
|
function isCommitExecutionMode(value) {
|
|
14
14
|
return value === 'direct' || value === 'orchestrated';
|
|
@@ -20,6 +20,13 @@ function gitText(repoRoot, args) {
|
|
|
20
20
|
stdio: ['ignore', 'pipe', 'pipe']
|
|
21
21
|
}).trim();
|
|
22
22
|
}
|
|
23
|
+
function effectiveDelivery(input) {
|
|
24
|
+
if (input.delivery)
|
|
25
|
+
return input.delivery;
|
|
26
|
+
if (input.push)
|
|
27
|
+
return { mode: 'push', remote: input.push.remote, refs: input.push.refs };
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
23
30
|
function canonicalRepositoryRoot(cwd) {
|
|
24
31
|
return gitText(cwd, ['rev-parse', '--show-toplevel']);
|
|
25
32
|
}
|
|
@@ -82,12 +89,13 @@ function boundTask(input, taskId, taskDir, taskMdPath, repoRoot, state) {
|
|
|
82
89
|
function validateCommon(input, branch) {
|
|
83
90
|
if (!input.message.trim())
|
|
84
91
|
return { code: 'GIT_COMMIT_INPUT_INVALID', message: 'Commit message is required' };
|
|
85
|
-
if (input.paths.length === 0 && !input.push)
|
|
86
|
-
return { code: 'GIT_COMMIT_INPUT_INVALID', message: 'At least one explicit path is required unless this is a push-only retry' };
|
|
87
92
|
if (!/^[a-f0-9]{40,64}$/.test(input.expectedHead))
|
|
88
93
|
return { code: 'GIT_HEAD_EXPECTATION_REQUIRED', message: 'A valid expected HEAD is required' };
|
|
89
94
|
if (!/^[a-f0-9]{40,64}$/.test(input.expectedTree))
|
|
90
95
|
return { code: 'GIT_TREE_EXPECTATION_REQUIRED', message: 'A valid expected tree is required' };
|
|
96
|
+
const delivery = effectiveDelivery(input);
|
|
97
|
+
if (!delivery)
|
|
98
|
+
return { code: 'GIT_PUSH_INPUT_INVALID', message: 'Commit delivery requires a delivery policy' };
|
|
91
99
|
if (input.paths.some((candidate) => !candidate || candidate.startsWith('/') || candidate.split(/[\\/]/).includes('..'))) {
|
|
92
100
|
return { code: 'GIT_COMMIT_INPUT_INVALID', message: 'Commit paths must stay inside the repository' };
|
|
93
101
|
}
|
|
@@ -96,40 +104,16 @@ function validateCommon(input, branch) {
|
|
|
96
104
|
}
|
|
97
105
|
if (branch !== null && branch === '')
|
|
98
106
|
return { code: 'GIT_BRANCH_INVALID', message: 'A named branch is required' };
|
|
99
|
-
if (
|
|
100
|
-
if (!
|
|
107
|
+
if (delivery.mode === 'push') {
|
|
108
|
+
if (!delivery.remote || delivery.refs.length !== 1)
|
|
101
109
|
return { code: 'GIT_PUSH_INPUT_INVALID', message: 'Push requires one remote and one ref' };
|
|
102
|
-
const ref =
|
|
110
|
+
const ref = delivery.refs[0] ?? '';
|
|
103
111
|
if (!HEAD_REF.test(ref) || HEAD_REF.exec(ref)?.[1] !== branch) {
|
|
104
112
|
return { code: 'GIT_PUSH_INPUT_INVALID', message: 'Push ref must be the current full heads ref' };
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
115
|
return null;
|
|
108
116
|
}
|
|
109
|
-
function validateOrchestrated(input, task) {
|
|
110
|
-
if (!input.agent)
|
|
111
|
-
return { error: { code: 'ORCHESTRATION_PROVENANCE_MISMATCH', message: 'orchestrated commit requires an agent' } };
|
|
112
|
-
const planned = planOrchestrationStageCompletion(task.taskId, {
|
|
113
|
-
stage: 'commit',
|
|
114
|
-
round: 1,
|
|
115
|
-
artifact: 'commit',
|
|
116
|
-
role: 'executor',
|
|
117
|
-
agent: input.agent
|
|
118
|
-
}, { repoRoot: task.repoRoot });
|
|
119
|
-
const run = planned.result.run;
|
|
120
|
-
if (!planned.plan
|
|
121
|
-
|| !run
|
|
122
|
-
|| run.status !== 'running'
|
|
123
|
-
|| !run.commitAuthorization.issuedAt
|
|
124
|
-
|| run.commitAuthorization.consumedAt)
|
|
125
|
-
return {
|
|
126
|
-
error: {
|
|
127
|
-
code: planned.result.error?.code ?? 'ORCHESTRATION_PROVENANCE_MISMATCH',
|
|
128
|
-
message: planned.result.error?.message ?? 'orchestrated commit requires one matching activated commit delegation'
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
return { plan: planned.plan };
|
|
132
|
-
}
|
|
133
117
|
function syncTaskCommit(input, task, committedHead) {
|
|
134
118
|
let content;
|
|
135
119
|
try {
|
|
@@ -148,7 +132,10 @@ function syncTaskCommit(input, task, committedHead) {
|
|
|
148
132
|
heading: activity.heading,
|
|
149
133
|
body: appendActivityEntry(activity, { time: metadata.timestamp, step: 'Commit', agent: input.agent, note: commitNote })
|
|
150
134
|
});
|
|
151
|
-
const frontmatter = {
|
|
135
|
+
const frontmatter = {
|
|
136
|
+
assigned_to: input.agent,
|
|
137
|
+
checkpoint_commit: committedHead
|
|
138
|
+
};
|
|
152
139
|
mutations.push({ kind: 'frontmatter', set: frontmatter });
|
|
153
140
|
if (mutations.length === 0)
|
|
154
141
|
return null;
|
|
@@ -165,10 +152,44 @@ function syncTaskCommit(input, task, committedHead) {
|
|
|
165
152
|
return warning('TASK_STATUS_SYNC_FAILED', error instanceof Error ? error.message : String(error), true, 'task', task.taskId, 'ACTION_REQUIRED');
|
|
166
153
|
}
|
|
167
154
|
}
|
|
155
|
+
function checkpointChildMatches(task, intent, head) {
|
|
156
|
+
try {
|
|
157
|
+
const parent = gitText(task.repoRoot, ['rev-parse', `${head}^`]);
|
|
158
|
+
const tree = gitText(task.repoRoot, ['rev-parse', `${head}^{tree}`]);
|
|
159
|
+
const message = gitText(task.repoRoot, ['show', '-s', '--format=%s', head]);
|
|
160
|
+
const changed = gitText(task.repoRoot, ['diff-tree', '--no-commit-id', '--name-only', '-r', head]).split('\n').filter(Boolean).sort();
|
|
161
|
+
return parent === intent.expectedHead
|
|
162
|
+
&& tree === intent.expectedTree
|
|
163
|
+
&& message === intent.message
|
|
164
|
+
&& JSON.stringify(changed) === JSON.stringify([...intent.paths].sort());
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function checkpointIdentity(input, task, delivery) {
|
|
171
|
+
if (delivery.mode !== 'local')
|
|
172
|
+
throw new Error('checkpoint identity requires local delivery');
|
|
173
|
+
return {
|
|
174
|
+
taskId: task.taskId,
|
|
175
|
+
branch: task.branch,
|
|
176
|
+
mode: 'local',
|
|
177
|
+
expectedHead: input.expectedHead,
|
|
178
|
+
expectedTree: input.expectedTree,
|
|
179
|
+
paths: [...input.paths],
|
|
180
|
+
message: input.message,
|
|
181
|
+
round: input.round ?? 1
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function checkpointTimestamp() {
|
|
185
|
+
return new Date().toISOString();
|
|
186
|
+
}
|
|
168
187
|
function executeUnlocked(input, task, mode) {
|
|
169
188
|
const inspected = inspectGitWorkflow(input.cwd);
|
|
170
189
|
if (!inspected.snapshot)
|
|
171
190
|
return failure(input, mode, task?.taskId ?? null, 'GIT_INSPECT_FAILED', 'Unable to inspect Git repository');
|
|
191
|
+
if (mode === 'orchestrated')
|
|
192
|
+
return failure(input, mode, task?.taskId ?? null, 'ORCHESTRATED_COMMIT_REMOVED', 'Orchestrated commit is no longer a lifecycle stage; use local checkpoint delivery from code-task', 'blocked', inspected.snapshot);
|
|
172
193
|
const branch = inspected.snapshot.branch;
|
|
173
194
|
const commonError = validateCommon(input, branch);
|
|
174
195
|
if (commonError)
|
|
@@ -179,60 +200,131 @@ function executeUnlocked(input, task, mode) {
|
|
|
179
200
|
return failure(input, mode, task.taskId, 'GIT_BRANCH_MISMATCH', `Task branch '${task.branch}' does not match current branch '${branch}'`, 'blocked', inspected.snapshot);
|
|
180
201
|
if (task && !input.agent)
|
|
181
202
|
return failure(input, mode, task.taskId, 'COMMIT_AGENT_REQUIRED', 'task-bound commit requires an agent', 'blocked', inspected.snapshot);
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const error = orchestrationValidation.error;
|
|
189
|
-
return failure(input, mode, task?.taskId ?? null, error.code, error.message, 'blocked', inspected.snapshot);
|
|
190
|
-
}
|
|
191
|
-
const orchestrationCompletion = orchestrationValidation && 'plan' in orchestrationValidation
|
|
192
|
-
? orchestrationValidation.plan
|
|
193
|
-
: null;
|
|
194
|
-
const committed = input.paths.length === 0
|
|
203
|
+
const delivery = effectiveDelivery(input);
|
|
204
|
+
if (delivery.mode === 'local' && !task)
|
|
205
|
+
return failure(input, mode, null, 'CHECKPOINT_TASK_REQUIRED', 'local checkpoint delivery requires a task context', 'blocked', inspected.snapshot);
|
|
206
|
+
let pendingIntent = null;
|
|
207
|
+
let checkpointCommittedHead = null;
|
|
208
|
+
const committed = delivery.mode === 'local'
|
|
195
209
|
? (() => {
|
|
196
|
-
|
|
210
|
+
const identity = checkpointIdentity(input, task, delivery);
|
|
211
|
+
try {
|
|
212
|
+
pendingIntent = readCheckpointIntent(task.repoRoot, task.taskId);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
197
215
|
return {
|
|
198
|
-
status: 'failed',
|
|
199
|
-
|
|
200
|
-
snapshot: inspected.snapshot,
|
|
201
|
-
operations: [],
|
|
202
|
-
error: { code: 'GIT_COMMIT_INPUT_INVALID', message: 'Push-only retry requires a clean working tree' }
|
|
216
|
+
status: 'failed', changed: false, snapshot: inspected.snapshot, operations: [],
|
|
217
|
+
error: { code: 'COMMIT_INTENT_INVALID', message: error instanceof Error ? error.message : String(error) }
|
|
203
218
|
};
|
|
204
|
-
|
|
219
|
+
}
|
|
220
|
+
if (pendingIntent && !sameCheckpointIntent(pendingIntent, identity))
|
|
205
221
|
return {
|
|
206
|
-
status: 'failed',
|
|
207
|
-
|
|
208
|
-
snapshot: inspected.snapshot,
|
|
209
|
-
operations: [],
|
|
210
|
-
error: { code: 'GIT_HEAD_MISMATCH', message: `Expected HEAD ${input.expectedHead}, received ${inspected.snapshot.head}` }
|
|
222
|
+
status: 'failed', changed: false, snapshot: inspected.snapshot, operations: [],
|
|
223
|
+
error: { code: 'COMMIT_INTENT_CONFLICT', message: 'A different checkpoint intent is still pending for this task' }
|
|
211
224
|
};
|
|
212
|
-
|
|
213
|
-
|
|
225
|
+
if (!pendingIntent) {
|
|
226
|
+
const timestamp = checkpointTimestamp();
|
|
227
|
+
pendingIntent = {
|
|
228
|
+
version: 1, ...identity, digest: checkpointIntentDigest(identity), state: 'prepared',
|
|
229
|
+
committedHead: null, createdAt: timestamp, updatedAt: timestamp
|
|
230
|
+
};
|
|
231
|
+
try {
|
|
232
|
+
writeCheckpointIntent(task.repoRoot, pendingIntent);
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
return {
|
|
236
|
+
status: 'failed', changed: false, snapshot: inspected.snapshot, operations: [],
|
|
237
|
+
error: { code: 'COMMIT_INTENT_WRITE_FAILED', message: error instanceof Error ? error.message : String(error) }
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (pendingIntent.state !== 'prepared') {
|
|
242
|
+
checkpointCommittedHead = pendingIntent.committedHead;
|
|
214
243
|
return {
|
|
215
|
-
status: '
|
|
244
|
+
status: 'no-op', changed: false, snapshot: inspected.snapshot,
|
|
245
|
+
operations: [{ name: 'commit', status: 'no-op' }], error: null
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
if (inspected.snapshot.head !== identity.expectedHead && !checkpointChildMatches(task, pendingIntent, inspected.snapshot.head))
|
|
249
|
+
return {
|
|
250
|
+
status: 'failed', changed: false, snapshot: inspected.snapshot, operations: [],
|
|
251
|
+
error: { code: 'COMMIT_INTENT_HEAD_CONFLICT', message: 'Current HEAD does not match the pending checkpoint intent' }
|
|
252
|
+
};
|
|
253
|
+
if (inspected.snapshot.head !== identity.expectedHead) {
|
|
254
|
+
checkpointCommittedHead = inspected.snapshot.head;
|
|
255
|
+
pendingIntent = updateCheckpointIntent(pendingIntent, {
|
|
256
|
+
state: 'committed', committedHead: checkpointCommittedHead, updatedAt: checkpointTimestamp()
|
|
257
|
+
});
|
|
258
|
+
writeCheckpointIntent(task.repoRoot, pendingIntent);
|
|
259
|
+
return {
|
|
260
|
+
status: 'no-op', changed: false, snapshot: inspected.snapshot,
|
|
261
|
+
operations: [{ name: 'commit', status: 'no-op' }], error: null
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
if (input.paths.length === 0)
|
|
265
|
+
return {
|
|
266
|
+
status: 'failed', changed: false, snapshot: inspected.snapshot, operations: [],
|
|
267
|
+
error: { code: 'GIT_COMMIT_INPUT_INVALID', message: 'Local checkpoint requires explicit paths' }
|
|
268
|
+
};
|
|
269
|
+
const created = commitExplicitPaths({
|
|
270
|
+
cwd: input.cwd, paths: input.paths, message: input.message,
|
|
271
|
+
expectedHead: identity.expectedHead, expectedTree: identity.expectedTree
|
|
272
|
+
});
|
|
273
|
+
if (created.status === 'applied' && created.snapshot?.head) {
|
|
274
|
+
checkpointCommittedHead = created.snapshot.head;
|
|
275
|
+
pendingIntent = updateCheckpointIntent(pendingIntent, {
|
|
276
|
+
state: 'committed', committedHead: checkpointCommittedHead, updatedAt: checkpointTimestamp()
|
|
277
|
+
});
|
|
278
|
+
writeCheckpointIntent(task.repoRoot, pendingIntent);
|
|
279
|
+
}
|
|
280
|
+
else if (created.status === 'no-op') {
|
|
281
|
+
removeCheckpointIntent(task.repoRoot, task.taskId);
|
|
282
|
+
pendingIntent = null;
|
|
283
|
+
}
|
|
284
|
+
return created;
|
|
285
|
+
})()
|
|
286
|
+
: input.paths.length === 0
|
|
287
|
+
? (() => {
|
|
288
|
+
if (inspected.snapshot.worktree.length > 0 || inspected.snapshot.staged.length > 0)
|
|
289
|
+
return {
|
|
290
|
+
status: 'failed',
|
|
291
|
+
changed: false,
|
|
292
|
+
snapshot: inspected.snapshot,
|
|
293
|
+
operations: [],
|
|
294
|
+
error: { code: 'GIT_COMMIT_INPUT_INVALID', message: 'Push-only retry requires a clean working tree' }
|
|
295
|
+
};
|
|
296
|
+
if (inspected.snapshot.head !== input.expectedHead)
|
|
297
|
+
return {
|
|
298
|
+
status: 'failed',
|
|
299
|
+
changed: false,
|
|
300
|
+
snapshot: inspected.snapshot,
|
|
301
|
+
operations: [],
|
|
302
|
+
error: { code: 'GIT_HEAD_MISMATCH', message: `Expected HEAD ${input.expectedHead}, received ${inspected.snapshot.head}` }
|
|
303
|
+
};
|
|
304
|
+
const currentTree = gitText(input.cwd, ['rev-parse', 'HEAD^{tree}']);
|
|
305
|
+
if (currentTree !== input.expectedTree)
|
|
306
|
+
return {
|
|
307
|
+
status: 'failed',
|
|
308
|
+
changed: false,
|
|
309
|
+
snapshot: inspected.snapshot,
|
|
310
|
+
operations: [],
|
|
311
|
+
error: { code: 'GIT_TREE_MISMATCH', message: `Expected current tree ${input.expectedTree}, received ${currentTree}` }
|
|
312
|
+
};
|
|
313
|
+
return {
|
|
314
|
+
status: 'no-op',
|
|
216
315
|
changed: false,
|
|
217
316
|
snapshot: inspected.snapshot,
|
|
218
|
-
operations: [],
|
|
219
|
-
error:
|
|
317
|
+
operations: [{ name: 'commit', status: 'no-op' }],
|
|
318
|
+
error: null
|
|
220
319
|
};
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
: commitExplicitPaths({
|
|
230
|
-
cwd: input.cwd,
|
|
231
|
-
paths: input.paths,
|
|
232
|
-
message: input.message,
|
|
233
|
-
expectedHead: input.expectedHead,
|
|
234
|
-
expectedTree: input.expectedTree
|
|
235
|
-
});
|
|
320
|
+
})()
|
|
321
|
+
: commitExplicitPaths({
|
|
322
|
+
cwd: input.cwd,
|
|
323
|
+
paths: input.paths,
|
|
324
|
+
message: input.message,
|
|
325
|
+
expectedHead: input.expectedHead,
|
|
326
|
+
expectedTree: input.expectedTree
|
|
327
|
+
});
|
|
236
328
|
if (committed.status === 'failed')
|
|
237
329
|
return {
|
|
238
330
|
...committed,
|
|
@@ -243,27 +335,17 @@ function executeUnlocked(input, task, mode) {
|
|
|
243
335
|
snapshot: committed.snapshot
|
|
244
336
|
};
|
|
245
337
|
const warnings = [];
|
|
246
|
-
if (orchestrationCompletion) {
|
|
247
|
-
try {
|
|
248
|
-
commitOrchestrationStageCompletion(orchestrationCompletion);
|
|
249
|
-
}
|
|
250
|
-
catch (error) {
|
|
251
|
-
warnings.push(warning('ORCHESTRATION_COMPLETION_FAILED', error instanceof Error ? error.message : String(error), true, 'orchestration', task?.taskId ?? 'orchestration', 'ACTION_REQUIRED'));
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
338
|
let status = committed.status;
|
|
255
339
|
let result = committed.status === 'applied' ? 'committed' : 'no_op';
|
|
256
|
-
if (
|
|
257
|
-
const target = `${
|
|
258
|
-
const decision = commitPushDecision({ branch
|
|
340
|
+
if (delivery.mode === 'push') {
|
|
341
|
+
const target = `${delivery.remote}:${delivery.refs[0]}`;
|
|
342
|
+
const decision = commitPushDecision({ branch }, target);
|
|
259
343
|
if (!decision.shouldPush) {
|
|
260
344
|
warnings.push(decision.warning);
|
|
261
345
|
}
|
|
262
346
|
else {
|
|
263
347
|
const pushed = pushGitRefs({
|
|
264
|
-
cwd: input.cwd,
|
|
265
|
-
remote: input.push.remote,
|
|
266
|
-
refs: input.push.refs,
|
|
348
|
+
cwd: input.cwd, remote: delivery.remote, refs: delivery.refs,
|
|
267
349
|
expectedSha: committed.snapshot?.head ?? gitText(input.cwd, ['rev-parse', 'HEAD'])
|
|
268
350
|
});
|
|
269
351
|
if (pushed.status !== 'applied')
|
|
@@ -275,12 +357,20 @@ function executeUnlocked(input, task, mode) {
|
|
|
275
357
|
result = 'committed_with_warnings';
|
|
276
358
|
}
|
|
277
359
|
if (task && (committed.status === 'applied' || committed.status === 'no-op')) {
|
|
278
|
-
const
|
|
360
|
+
const committedHead = checkpointCommittedHead ?? committed.snapshot?.head ?? gitText(task.repoRoot, ['rev-parse', 'HEAD']);
|
|
361
|
+
const taskWarning = syncTaskCommit(input, task, committedHead);
|
|
279
362
|
if (taskWarning) {
|
|
280
363
|
warnings.push(taskWarning);
|
|
281
364
|
status = 'applied';
|
|
282
365
|
result = 'committed_with_warnings';
|
|
283
366
|
}
|
|
367
|
+
if (delivery.mode === 'local' && !taskWarning && pendingIntent && checkpointCommittedHead) {
|
|
368
|
+
const synced = updateCheckpointIntent(pendingIntent, {
|
|
369
|
+
state: 'synced', committedHead: checkpointCommittedHead, updatedAt: checkpointTimestamp()
|
|
370
|
+
});
|
|
371
|
+
writeCheckpointIntent(task.repoRoot, synced);
|
|
372
|
+
removeCheckpointIntent(task.repoRoot, task.taskId);
|
|
373
|
+
}
|
|
284
374
|
}
|
|
285
375
|
return {
|
|
286
376
|
status,
|