@fitlab-ai/agent-infra 0.9.1 → 0.9.3
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 +24 -11
- package/README.zh-CN.md +24 -11
- package/bin/cli.ts +12 -0
- package/dist/bin/cli.js +14 -0
- package/dist/bin/internal-cli.js +30 -0
- package/dist/lib/agent-client.js +163 -0
- package/dist/lib/agent-clients/adapter.js +337 -0
- package/dist/lib/agent-clients/adapters/antigravity-cli.js +64 -0
- package/dist/lib/agent-clients/adapters/claude-code.js +71 -0
- package/dist/lib/agent-clients/adapters/codex-sandbox.js +210 -0
- package/dist/lib/agent-clients/adapters/codex.js +63 -0
- package/dist/lib/agent-clients/adapters/index.js +20 -0
- package/dist/lib/agent-clients/adapters/opencode.js +73 -0
- package/dist/lib/agent-clients/config.js +215 -0
- package/dist/lib/agent-clients/custom-tuis.js +99 -0
- package/dist/lib/agent-clients/invocation.js +9 -0
- package/dist/lib/agent-clients/next-steps.js +47 -0
- package/dist/lib/agent-clients/project-assets.js +45 -0
- package/dist/lib/agent-clients/reconcile.js +236 -0
- package/dist/lib/agent-clients/registry.js +78 -0
- package/dist/lib/agent-clients/schema.js +75 -0
- package/dist/lib/agent-clients/tokens.js +49 -0
- package/dist/lib/agent-clients/types.js +29 -0
- package/dist/lib/builtin-tuis.js +9 -14
- package/dist/lib/defaults.json +85 -73
- package/dist/lib/git/review-snapshot.js +25 -10
- package/dist/lib/git/reviewed-commit-equivalence.js +110 -0
- package/dist/lib/git/workflow.js +54 -1
- package/dist/lib/init.js +47 -91
- package/dist/lib/internal/agent-client.js +174 -0
- package/dist/lib/internal/git-workflow.js +7 -2
- package/dist/lib/internal/platform-checks.js +3 -3
- package/dist/lib/internal/platform-comment.js +29 -2
- package/dist/lib/internal/platform-issue.js +7 -0
- package/dist/lib/internal/platform-pr-review.js +132 -0
- package/dist/lib/internal/platform-pr.js +20 -2
- package/dist/lib/internal/platform-release-notes.js +52 -16
- package/dist/lib/internal/pr-review-grade.js +140 -0
- package/dist/lib/internal/release-workflow.js +82 -20
- package/dist/lib/internal/task-activity.js +73 -0
- package/dist/lib/internal/task-event.js +17 -1
- package/dist/lib/internal/task-lifecycle.js +7 -0
- package/dist/lib/internal/task-orchestration.js +196 -0
- package/dist/lib/internal/task-review.js +70 -0
- package/dist/lib/merge.js +2 -1
- package/dist/lib/platform/adapters.js +45 -1
- package/dist/lib/platform/change-request-git-evidence.js +113 -0
- package/dist/lib/platform/completion-backfill.js +122 -0
- package/dist/lib/platform/issue-comments.js +3 -2
- package/dist/lib/platform/merged-pr-equivalence.js +156 -16
- package/dist/lib/platform/pr-checks.js +101 -50
- package/dist/lib/platform/pr-review.js +166 -0
- package/dist/lib/platform/pull-requests.js +432 -7
- package/dist/lib/platform/release-notes.js +85 -3
- package/dist/lib/platform/releases.js +1 -1
- package/dist/lib/platform/verification-required.js +8 -10
- package/dist/lib/pr-review/evidence-grading.js +229 -0
- package/dist/lib/prompt.js +15 -3
- package/dist/lib/release/channels.js +4 -1
- package/dist/lib/release/workflow.js +4 -2
- package/dist/lib/remove-dir.js +25 -0
- package/dist/lib/run/tui.js +11 -7
- package/dist/lib/sandbox/agent-client-reconciler.js +234 -0
- package/dist/lib/sandbox/clipboard/linux.js +2 -1
- package/dist/lib/sandbox/commands/create.js +76 -200
- package/dist/lib/sandbox/commands/enter.js +17 -1
- package/dist/lib/sandbox/commands/prune.js +2 -2
- package/dist/lib/sandbox/commands/rm.js +3 -2
- package/dist/lib/sandbox/commands/show.js +1 -1
- package/dist/lib/sandbox/config.js +21 -4
- package/dist/lib/sandbox/constants.js +3 -0
- package/dist/lib/sandbox/dockerfile.js +2 -1
- package/dist/lib/sandbox/managed-fs.js +10 -5
- package/dist/lib/sandbox/recovery.js +52 -36
- package/dist/lib/sandbox/shell.js +1 -1
- package/dist/lib/sandbox/tool-types.js +8 -0
- package/dist/lib/sandbox/tools.js +2 -126
- package/dist/lib/task/activity-intent.js +101 -0
- package/dist/lib/task/artifact-lifecycle.js +3 -50
- package/dist/lib/task/commands/decisions.js +50 -20
- package/dist/lib/task/commands/log.js +15 -14
- package/dist/lib/task/delegation-receipts.js +128 -0
- package/dist/lib/task/events.js +146 -8
- package/dist/lib/task/finalization-artifacts.js +35 -0
- package/dist/lib/task/lifecycle-execution.js +46 -0
- package/dist/lib/task/orchestration.js +784 -0
- package/dist/lib/task/review-artifacts.js +143 -59
- package/dist/lib/task/review-finalization.js +186 -0
- package/dist/lib/task/review-fingerprint.js +4 -0
- package/dist/lib/task/task-execution-lock.js +231 -0
- package/dist/lib/task/verification-checks.js +2 -1
- package/dist/lib/task/verification-engine.js +372 -28
- package/dist/lib/task/verification-review.js +1 -1
- package/dist/lib/task/verification.js +5 -2
- package/dist/lib/task/workspace-snapshot.js +46 -0
- package/dist/lib/update.js +42 -161
- package/lib/agent-client.ts +214 -0
- package/lib/agent-clients/adapter.ts +534 -0
- package/lib/agent-clients/adapters/antigravity-cli.ts +65 -0
- package/lib/agent-clients/adapters/claude-code.ts +79 -0
- package/lib/agent-clients/adapters/codex-sandbox.ts +245 -0
- package/lib/agent-clients/adapters/codex.ts +67 -0
- package/lib/agent-clients/adapters/index.ts +27 -0
- package/lib/agent-clients/adapters/opencode.ts +75 -0
- package/lib/agent-clients/config.ts +323 -0
- package/lib/agent-clients/custom-tuis.ts +149 -0
- package/lib/agent-clients/invocation.ts +19 -0
- package/lib/agent-clients/next-steps.ts +85 -0
- package/lib/agent-clients/project-assets.ts +96 -0
- package/lib/agent-clients/reconcile.ts +325 -0
- package/lib/agent-clients/registry.ts +154 -0
- package/lib/agent-clients/schema.ts +80 -0
- package/lib/agent-clients/tokens.ts +53 -0
- package/lib/agent-clients/types.ts +92 -0
- package/lib/benchmark/schemas/v1.0.0/case-manifest.schema.json +120 -0
- package/lib/benchmark/schemas/v1.0.0/common.schema.json +109 -0
- package/lib/benchmark/schemas/v1.0.0/grader-result.schema.json +160 -0
- package/lib/benchmark/schemas/v1.0.0/run-manifest.schema.json +122 -0
- package/lib/benchmark/schemas/v1.0.0/subject.schema.json +227 -0
- package/lib/builtin-tuis.ts +16 -15
- package/lib/defaults.json +24 -12
- package/lib/git/review-snapshot.ts +39 -9
- package/lib/git/reviewed-commit-equivalence.ts +135 -0
- package/lib/git/workflow.ts +66 -2
- package/lib/init.ts +53 -121
- package/lib/internal/agent-client.ts +186 -0
- package/lib/internal/git-workflow.ts +6 -2
- package/lib/internal/platform-checks.ts +4 -4
- package/lib/internal/platform-comment.ts +17 -2
- package/lib/internal/platform-issue.ts +4 -0
- package/lib/internal/platform-pr-review.ts +104 -0
- package/lib/internal/platform-pr.ts +14 -1
- package/lib/internal/platform-release-notes.ts +59 -16
- package/lib/internal/pr-review-grade.ts +130 -0
- package/lib/internal/release-workflow.ts +79 -20
- package/lib/internal/task-activity.ts +55 -0
- package/lib/internal/task-event.ts +9 -1
- package/lib/internal/task-lifecycle.ts +4 -0
- package/lib/internal/task-orchestration.ts +171 -0
- package/lib/internal/task-review.ts +70 -0
- package/lib/merge.ts +2 -1
- package/lib/platform/adapters.ts +169 -3
- package/lib/platform/change-request-git-evidence.ts +159 -0
- package/lib/platform/completion-backfill.ts +134 -0
- package/lib/platform/issue-comments.ts +3 -2
- package/lib/platform/merged-pr-equivalence.ts +178 -19
- package/lib/platform/pr-checks.ts +121 -66
- package/lib/platform/pr-review.ts +201 -0
- package/lib/platform/pull-requests.ts +529 -27
- package/lib/platform/release-notes.ts +100 -4
- package/lib/platform/releases.ts +1 -1
- package/lib/platform/verification-required.ts +12 -10
- package/lib/pr-review/evidence-grading.ts +318 -0
- package/lib/prompt.ts +16 -3
- package/lib/release/channels.ts +4 -1
- package/lib/release/workflow.ts +4 -3
- package/lib/remove-dir.ts +28 -0
- package/lib/run/tui.ts +12 -5
- package/lib/sandbox/agent-client-reconciler.ts +378 -0
- package/lib/sandbox/clipboard/linux.ts +2 -1
- package/lib/sandbox/commands/create.ts +111 -212
- package/lib/sandbox/commands/enter.ts +23 -1
- package/lib/sandbox/commands/prune.ts +2 -2
- package/lib/sandbox/commands/rm.ts +3 -2
- package/lib/sandbox/commands/show.ts +1 -1
- package/lib/sandbox/config.ts +31 -4
- package/lib/sandbox/constants.ts +6 -0
- package/lib/sandbox/dockerfile.ts +2 -1
- package/lib/sandbox/managed-fs.ts +18 -5
- package/lib/sandbox/recovery.ts +98 -67
- package/lib/sandbox/shell.ts +1 -1
- package/lib/sandbox/tool-types.ts +143 -0
- package/lib/sandbox/tools.ts +5 -157
- package/lib/server/server.schema.json +2 -2
- package/lib/task/activity-intent.ts +128 -0
- package/lib/task/artifact-lifecycle.ts +3 -39
- package/lib/task/commands/decisions.ts +53 -20
- package/lib/task/commands/log.ts +15 -14
- package/lib/task/delegation-receipts.ts +199 -0
- package/lib/task/events.ts +164 -11
- package/lib/task/finalization-artifacts.ts +58 -0
- package/lib/task/lifecycle-execution.ts +106 -0
- package/lib/task/orchestration.ts +1022 -0
- package/lib/task/review-artifacts.ts +201 -69
- package/lib/task/review-finalization.ts +306 -0
- package/lib/task/review-fingerprint.ts +5 -0
- package/lib/task/task-execution-lock.ts +296 -0
- package/lib/task/verification-checks.ts +2 -1
- package/lib/task/verification-engine.ts +424 -28
- package/lib/task/verification-review.ts +1 -0
- package/lib/task/verification.ts +8 -3
- package/lib/task/workspace-snapshot.ts +57 -0
- package/lib/update.ts +48 -184
- package/package.json +4 -4
- package/templates/.agents/QUICKSTART.en.md +25 -8
- package/templates/.agents/QUICKSTART.zh-CN.md +25 -8
- package/templates/.agents/README.en.md +29 -25
- package/templates/.agents/README.zh-CN.md +29 -25
- package/templates/.agents/hooks/lifecycle-delegation.js +75 -0
- package/templates/.agents/rules/README.en.md +2 -0
- package/templates/.agents/rules/README.zh-CN.md +2 -0
- package/templates/.agents/rules/commit-and-pr.en.md +1 -0
- package/templates/.agents/rules/commit-and-pr.zh-CN.md +1 -0
- package/templates/.agents/rules/create-issue.github.en.md +4 -2
- package/templates/.agents/rules/create-issue.github.zh-CN.md +4 -2
- package/templates/.agents/rules/human-decision-context.en.md +14 -12
- package/templates/.agents/rules/human-decision-context.zh-CN.md +14 -12
- package/templates/.agents/rules/issue-fields.github.en.md +3 -1
- package/templates/.agents/rules/issue-fields.github.zh-CN.md +3 -1
- package/templates/.agents/rules/issue-pr-commands.en.md +5 -3
- package/templates/.agents/rules/issue-pr-commands.github.en.md +5 -3
- package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +5 -3
- package/templates/.agents/rules/issue-pr-commands.zh-CN.md +5 -3
- package/templates/.agents/rules/issue-sync.github.en.md +7 -3
- package/templates/.agents/rules/issue-sync.github.zh-CN.md +8 -4
- package/templates/.agents/rules/lifecycle-orchestration.en.md +24 -0
- package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +24 -0
- package/templates/.agents/rules/milestone-inference.github.en.md +4 -2
- package/templates/.agents/rules/milestone-inference.github.zh-CN.md +4 -2
- package/templates/.agents/rules/next-step-output.en.md +18 -0
- package/templates/.agents/rules/next-step-output.zh-CN.md +18 -0
- package/templates/.agents/rules/no-mid-flow-questions.en.md +19 -0
- package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +19 -0
- package/templates/.agents/rules/pr-checks-commands.en.md +3 -3
- package/templates/.agents/rules/pr-checks-commands.github.en.md +2 -2
- package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +2 -2
- package/templates/.agents/rules/pr-checks-commands.zh-CN.md +3 -3
- package/templates/.agents/rules/pr-sync.en.md +3 -1
- package/templates/.agents/rules/pr-sync.github.en.md +11 -1
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +11 -1
- package/templates/.agents/rules/pr-sync.zh-CN.md +3 -1
- package/templates/.agents/rules/release-commands.en.md +1 -1
- package/templates/.agents/rules/release-commands.github.en.md +21 -5
- package/templates/.agents/rules/release-commands.github.zh-CN.md +21 -5
- package/templates/.agents/rules/release-commands.zh-CN.md +1 -1
- package/templates/.agents/rules/review-handshake.en.md +4 -4
- package/templates/.agents/rules/review-handshake.zh-CN.md +4 -4
- package/templates/.agents/rules/review-method.en.md +113 -0
- package/templates/.agents/rules/review-method.zh-CN.md +98 -0
- package/templates/.agents/rules/task-management.en.md +11 -0
- package/templates/.agents/rules/task-management.zh-CN.md +11 -0
- package/templates/.agents/skills/analyze-task/SKILL.en.md +15 -12
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +15 -12
- package/templates/.agents/skills/block-task/SKILL.en.md +11 -9
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +11 -9
- package/templates/.agents/skills/cancel-task/SKILL.en.md +10 -8
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +11 -9
- package/templates/.agents/skills/check-task/SKILL.en.md +16 -16
- package/templates/.agents/skills/check-task/SKILL.zh-CN.md +16 -16
- package/templates/.agents/skills/close-codescan/SKILL.en.md +7 -5
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +7 -5
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +7 -5
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +7 -5
- package/templates/.agents/skills/code-task/SKILL.en.md +10 -7
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +13 -10
- package/templates/.agents/skills/code-task/reference/fix-mode.en.md +14 -16
- package/templates/.agents/skills/code-task/reference/fix-mode.zh-CN.md +14 -16
- package/templates/.agents/skills/code-task/reference/output-template.en.md +3 -3
- package/templates/.agents/skills/code-task/reference/output-template.zh-CN.md +3 -3
- package/templates/.agents/skills/commit/SKILL.en.md +13 -1
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +13 -1
- package/templates/.agents/skills/commit/reference/commit-message.en.md +1 -1
- package/templates/.agents/skills/commit/reference/commit-message.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +1 -1
- 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 +24 -28
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +24 -28
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +6 -4
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +6 -4
- 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 +23 -8
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +23 -8
- package/templates/.agents/skills/complete-task/config/verify.en.json +1 -0
- package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +17 -0
- package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +17 -0
- package/templates/.agents/skills/create-pr/SKILL.en.md +13 -11
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +13 -11
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +1 -1
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +1 -1
- package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +3 -3
- package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +3 -3
- package/templates/.agents/skills/create-release-note/SKILL.en.md +17 -16
- package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +17 -16
- package/templates/.agents/skills/create-task/SKILL.en.md +16 -14
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +16 -14
- package/templates/.agents/skills/import-codescan/SKILL.en.md +5 -5
- package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +5 -5
- package/templates/.agents/skills/import-dependabot/SKILL.en.md +5 -5
- package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +5 -5
- package/templates/.agents/skills/import-issue/SKILL.en.md +10 -8
- package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +10 -8
- package/templates/.agents/skills/init-labels/SKILL.en.md +4 -4
- package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/init-milestones/SKILL.en.md +4 -4
- package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/plan-task/SKILL.en.md +13 -10
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +13 -10
- package/templates/.agents/skills/post-release/SKILL.en.md +2 -0
- package/templates/.agents/skills/post-release/SKILL.zh-CN.md +2 -0
- package/templates/.agents/skills/refine-title/SKILL.en.md +1 -1
- package/templates/.agents/skills/refine-title/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/release/SKILL.en.md +16 -10
- package/templates/.agents/skills/release/SKILL.zh-CN.md +16 -10
- package/templates/.agents/skills/restore-task/SKILL.en.md +4 -1
- package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +4 -1
- package/templates/.agents/skills/review-analysis/SKILL.en.md +18 -4
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +19 -5
- package/templates/.agents/skills/review-analysis/config/verify.en.json +6 -0
- package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +6 -0
- package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +13 -15
- package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +13 -15
- package/templates/.agents/skills/review-analysis/reference/report-template.en.md +51 -5
- package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +52 -6
- package/templates/.agents/skills/review-analysis/reference/review-criteria.en.md +25 -22
- package/templates/.agents/skills/review-analysis/reference/review-criteria.zh-CN.md +25 -22
- package/templates/.agents/skills/review-code/SKILL.en.md +35 -12
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +35 -12
- package/templates/.agents/skills/review-code/config/verify.en.json +7 -0
- package/templates/.agents/skills/review-code/config/verify.zh-CN.json +7 -0
- package/templates/.agents/skills/review-code/reference/concurrency-risks.en.md +25 -0
- package/templates/.agents/skills/review-code/reference/concurrency-risks.zh-CN.md +25 -0
- package/templates/.agents/skills/review-code/reference/cross-platform-risks.en.md +27 -0
- package/templates/.agents/skills/review-code/reference/cross-platform-risks.zh-CN.md +27 -0
- package/templates/.agents/skills/review-code/reference/documentation-antipatterns.en.md +13 -0
- package/templates/.agents/skills/review-code/reference/documentation-antipatterns.zh-CN.md +13 -0
- package/templates/.agents/skills/review-code/reference/migration-risks.en.md +25 -0
- package/templates/.agents/skills/review-code/reference/migration-risks.zh-CN.md +25 -0
- package/templates/.agents/skills/review-code/reference/output-templates.en.md +22 -24
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +22 -24
- package/templates/.agents/skills/review-code/reference/report-template.en.md +54 -7
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +54 -7
- package/templates/.agents/skills/review-code/reference/review-criteria.en.md +29 -24
- package/templates/.agents/skills/review-code/reference/review-criteria.zh-CN.md +29 -24
- package/templates/.agents/skills/review-code/reference/security-risks.en.md +25 -0
- package/templates/.agents/skills/review-code/reference/security-risks.zh-CN.md +25 -0
- package/templates/.agents/skills/review-plan/SKILL.en.md +18 -4
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +19 -5
- package/templates/.agents/skills/review-plan/config/verify.en.json +6 -0
- package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +6 -0
- package/templates/.agents/skills/review-plan/reference/output-templates.en.md +13 -15
- package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +13 -15
- package/templates/.agents/skills/review-plan/reference/report-template.en.md +61 -5
- package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +61 -5
- package/templates/.agents/skills/review-plan/reference/review-criteria.en.md +21 -24
- package/templates/.agents/skills/review-plan/reference/review-criteria.zh-CN.md +21 -24
- package/templates/.agents/skills/review-pr/SKILL.en.md +158 -0
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +158 -0
- package/templates/.agents/skills/review-pr/config/verify.en.json +37 -0
- package/templates/.agents/skills/review-pr/config/verify.zh-CN.json +37 -0
- package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +65 -0
- package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +65 -0
- package/templates/.agents/skills/review-pr/reference/output-guidance.en.md +18 -0
- package/templates/.agents/skills/review-pr/reference/output-guidance.zh-CN.md +18 -0
- package/templates/.agents/skills/review-pr/reference/report-template.en.md +85 -0
- package/templates/.agents/skills/review-pr/reference/report-template.zh-CN.md +85 -0
- package/templates/.agents/skills/run-task/SKILL.en.md +22 -0
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +22 -0
- package/templates/.agents/skills/run-task/config/verify.en.json +10 -0
- package/templates/.agents/skills/run-task/config/verify.zh-CN.json +10 -0
- package/templates/.agents/skills/run-task/reference/host-validation.en.md +20 -0
- package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +20 -0
- package/templates/.agents/skills/test/SKILL.en.md +4 -4
- package/templates/.agents/skills/test/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/test-integration/SKILL.en.md +4 -4
- package/templates/.agents/skills/test-integration/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/update-agent-infra/SKILL.en.md +5 -5
- package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +5 -5
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +664 -246
- package/templates/.agents/skills/upgrade-dependency/SKILL.en.md +4 -4
- package/templates/.agents/skills/upgrade-dependency/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/watch-pr/SKILL.en.md +21 -21
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +21 -21
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +27 -6
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +26 -5
- package/templates/.agents/templates/task.en.md +1 -1
- package/templates/.agents/templates/task.zh-CN.md +1 -1
- package/templates/.agents/workflows/bug-fix.en.yaml +3 -3
- package/templates/.agents/workflows/bug-fix.zh-CN.yaml +3 -3
- package/templates/.agents/workflows/code-review.en.yaml +1 -1
- package/templates/.agents/workflows/code-review.zh-CN.yaml +1 -1
- package/templates/.agents/workflows/feature-development.en.yaml +4 -4
- package/templates/.agents/workflows/feature-development.zh-CN.yaml +4 -4
- package/templates/.agents/workflows/refactoring.en.yaml +3 -3
- package/templates/.agents/workflows/refactoring.zh-CN.yaml +3 -3
- package/templates/.claude/agents/agent-infra-lifecycle-executor.en.md +6 -0
- package/templates/.claude/agents/agent-infra-lifecycle-executor.zh-CN.md +6 -0
- package/templates/.claude/agents/agent-infra-lifecycle-reviewer.en.md +6 -0
- package/templates/.claude/agents/agent-infra-lifecycle-reviewer.zh-CN.md +6 -0
- package/templates/.claude/commands/post-release.en.md +1 -0
- package/templates/.claude/commands/post-release.zh-CN.md +1 -0
- package/templates/.claude/commands/review-pr.en.md +8 -0
- package/templates/.claude/commands/review-pr.zh-CN.md +8 -0
- package/templates/.claude/commands/run-task.en.md +8 -0
- package/templates/.claude/commands/run-task.zh-CN.md +8 -0
- package/templates/.claude/settings.json +24 -0
- package/templates/.codex/agents/agent-infra-lifecycle-executor.en.toml +3 -0
- package/templates/.codex/agents/agent-infra-lifecycle-executor.zh-CN.toml +3 -0
- package/templates/.codex/agents/agent-infra-lifecycle-reviewer.en.toml +3 -0
- package/templates/.codex/agents/agent-infra-lifecycle-reviewer.zh-CN.toml +3 -0
- package/templates/.gemini/commands/_project_/review-pr.en.toml +10 -0
- package/templates/.gemini/commands/_project_/review-pr.zh-CN.toml +10 -0
- package/templates/.opencode/commands/post-release.en.md +2 -0
- package/templates/.opencode/commands/post-release.zh-CN.md +2 -0
- package/templates/.opencode/commands/review-pr.en.md +11 -0
- package/templates/.opencode/commands/review-pr.zh-CN.md +11 -0
- package/templates/.opencode/commands/run-task.en.md +11 -0
- package/templates/.opencode/commands/run-task.zh-CN.md +11 -0
- package/templates/.gemini/commands/_project_/analyze-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/analyze-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/archive-tasks.en.toml +0 -10
- package/templates/.gemini/commands/_project_/archive-tasks.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/block-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/block-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/cancel-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/cancel-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/check-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/check-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/close-codescan.en.toml +0 -8
- package/templates/.gemini/commands/_project_/close-codescan.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/close-dependabot.en.toml +0 -8
- package/templates/.gemini/commands/_project_/close-dependabot.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/code-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/code-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/commit.en.toml +0 -10
- package/templates/.gemini/commands/_project_/commit.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-manual-validation.en.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-manual-validation.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/create-pr.en.toml +0 -10
- package/templates/.gemini/commands/_project_/create-pr.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/create-release-note.en.toml +0 -8
- package/templates/.gemini/commands/_project_/create-release-note.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/create-task.en.toml +0 -8
- package/templates/.gemini/commands/_project_/create-task.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/import-codescan.en.toml +0 -8
- package/templates/.gemini/commands/_project_/import-codescan.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/import-dependabot.en.toml +0 -8
- package/templates/.gemini/commands/_project_/import-dependabot.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/import-issue.en.toml +0 -8
- package/templates/.gemini/commands/_project_/import-issue.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/init-labels.en.toml +0 -8
- package/templates/.gemini/commands/_project_/init-labels.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/init-milestones.en.toml +0 -10
- package/templates/.gemini/commands/_project_/init-milestones.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/plan-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/plan-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/post-release.en.toml +0 -6
- package/templates/.gemini/commands/_project_/post-release.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/refine-title.en.toml +0 -8
- package/templates/.gemini/commands/_project_/refine-title.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/release.en.toml +0 -8
- package/templates/.gemini/commands/_project_/release.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/restore-task.en.toml +0 -8
- package/templates/.gemini/commands/_project_/restore-task.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/review-analysis.en.toml +0 -10
- package/templates/.gemini/commands/_project_/review-analysis.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/review-code.en.toml +0 -10
- package/templates/.gemini/commands/_project_/review-code.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/review-plan.en.toml +0 -10
- package/templates/.gemini/commands/_project_/review-plan.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/test-integration.en.toml +0 -6
- package/templates/.gemini/commands/_project_/test-integration.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/test.en.toml +0 -6
- package/templates/.gemini/commands/_project_/test.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/update-agent-infra.en.toml +0 -6
- package/templates/.gemini/commands/_project_/update-agent-infra.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/upgrade-dependency.en.toml +0 -8
- package/templates/.gemini/commands/_project_/upgrade-dependency.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/watch-pr.en.toml +0 -10
- package/templates/.gemini/commands/_project_/watch-pr.zh-CN.toml +0 -10
- package/templates/.gemini/settings.json +0 -3
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
5
|
+
import { resolvePlatformChangeRequestGitEvidence } from "./adapters.js";
|
|
6
|
+
import { resolveReviewedHeadRelation } from "./merged-pr-equivalence.js";
|
|
7
|
+
const SHA_PATTERN = /^[0-9a-f]{40}$/i;
|
|
8
|
+
const REVIEWED_HEAD_REF = "refs/agent-infra/reviewed-head";
|
|
9
|
+
const TARGET_HEAD_REF = "refs/agent-infra/target-head";
|
|
10
|
+
function git(cwd, args) {
|
|
11
|
+
return execFileSync("git", args, {
|
|
12
|
+
cwd,
|
|
13
|
+
encoding: "utf8",
|
|
14
|
+
maxBuffer: 32 * 1024 * 1024,
|
|
15
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
16
|
+
}).trim();
|
|
17
|
+
}
|
|
18
|
+
function validRef(ref) {
|
|
19
|
+
return spawnSync("git", ["check-ref-format", ref], {
|
|
20
|
+
encoding: "utf8",
|
|
21
|
+
stdio: ["ignore", "ignore", "ignore"]
|
|
22
|
+
}).status === 0;
|
|
23
|
+
}
|
|
24
|
+
function blocked(code, message) {
|
|
25
|
+
return { status: "blocked", code, message };
|
|
26
|
+
}
|
|
27
|
+
function failed(code, message) {
|
|
28
|
+
return { status: "failed", code, message };
|
|
29
|
+
}
|
|
30
|
+
function validMergeIdentity(lastReviewedCommit, pullRequest) {
|
|
31
|
+
if (pullRequest.state !== "closed" ||
|
|
32
|
+
!pullRequest.mergedAt ||
|
|
33
|
+
!pullRequest.mergeCommitSha ||
|
|
34
|
+
!SHA_PATTERN.test(lastReviewedCommit) ||
|
|
35
|
+
lastReviewedCommit !== pullRequest.head.sha) {
|
|
36
|
+
return failed("PR_MERGE_IDENTITY_INVALID", "PR merge identity does not match the reviewed head");
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
function resolveMaterializedReviewedHeadRelation(input) {
|
|
41
|
+
const identityFailure = validMergeIdentity(input.lastReviewedCommit, input.pullRequest);
|
|
42
|
+
if (identityFailure)
|
|
43
|
+
return identityFailure;
|
|
44
|
+
const source = resolvePlatformChangeRequestGitEvidence(input.platformType, {
|
|
45
|
+
cwd: input.cwd,
|
|
46
|
+
repository: input.pullRequest.repository,
|
|
47
|
+
number: input.pullRequest.number,
|
|
48
|
+
pullRequest: input.pullRequest
|
|
49
|
+
});
|
|
50
|
+
if (!source.ok || !source.value) {
|
|
51
|
+
return blocked(source.error?.code || "PR_MERGE_EVIDENCE_SOURCE_UNAVAILABLE", source.error?.message || "Unable to resolve authoritative PR Git evidence");
|
|
52
|
+
}
|
|
53
|
+
if (!source.value.remoteUrl.trim() ||
|
|
54
|
+
source.value.remoteUrl.trimStart().startsWith("-") ||
|
|
55
|
+
!validRef(source.value.reviewedHeadRef) ||
|
|
56
|
+
!validRef(source.value.targetHeadRef)) {
|
|
57
|
+
return blocked("PR_MERGE_EVIDENCE_SOURCE_UNAVAILABLE", "Platform returned an invalid PR Git evidence source");
|
|
58
|
+
}
|
|
59
|
+
let evidenceRoot = null;
|
|
60
|
+
let phase = "prepare";
|
|
61
|
+
let result = blocked("PR_MERGE_GIT_EVIDENCE_UNAVAILABLE", "Unable to prepare isolated PR Git evidence");
|
|
62
|
+
try {
|
|
63
|
+
evidenceRoot = fs.mkdtempSync(path.join(os.tmpdir(), "agent-infra-pr-evidence-"));
|
|
64
|
+
execFileSync("git", ["init", "--bare", "-q", evidenceRoot], {
|
|
65
|
+
cwd: input.cwd,
|
|
66
|
+
encoding: "utf8",
|
|
67
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
68
|
+
});
|
|
69
|
+
phase = "fetch";
|
|
70
|
+
git(evidenceRoot, [
|
|
71
|
+
"fetch",
|
|
72
|
+
"--no-tags",
|
|
73
|
+
"--no-write-fetch-head",
|
|
74
|
+
source.value.remoteUrl,
|
|
75
|
+
`+${source.value.reviewedHeadRef}:${REVIEWED_HEAD_REF}`,
|
|
76
|
+
`+${source.value.targetHeadRef}:${TARGET_HEAD_REF}`
|
|
77
|
+
]);
|
|
78
|
+
phase = "resolve";
|
|
79
|
+
const fetchedReviewedHead = git(evidenceRoot, ["rev-parse", `${REVIEWED_HEAD_REF}^{commit}`]);
|
|
80
|
+
const comparisonHead = git(evidenceRoot, ["rev-parse", `${TARGET_HEAD_REF}^{commit}`]);
|
|
81
|
+
if (fetchedReviewedHead !== input.pullRequest.head.sha) {
|
|
82
|
+
result = failed("PR_MERGE_FETCHED_HEAD_MISMATCH", "Fetched PR head does not match the authoritative platform snapshot");
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
result = resolveReviewedHeadRelation({
|
|
86
|
+
gitRoot: evidenceRoot,
|
|
87
|
+
comparisonHead,
|
|
88
|
+
lastReviewedCommit: input.lastReviewedCommit,
|
|
89
|
+
pullRequest: input.pullRequest
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
result = phase === "fetch"
|
|
95
|
+
? blocked("PR_MERGE_EVIDENCE_FETCH_FAILED", "Unable to fetch PR Git evidence; verify Git credentials and platform refs")
|
|
96
|
+
: phase === "resolve"
|
|
97
|
+
? blocked("PR_MERGE_OBJECT_MISSING", "Fetched PR Git evidence is incomplete")
|
|
98
|
+
: blocked("PR_MERGE_GIT_EVIDENCE_UNAVAILABLE", "Unable to prepare isolated PR Git evidence");
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
if (evidenceRoot) {
|
|
102
|
+
try {
|
|
103
|
+
fs.rmSync(evidenceRoot, { recursive: true, force: true });
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
result = blocked("PR_MERGE_EVIDENCE_CLEANUP_FAILED", "Unable to clean up isolated PR Git evidence");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
export { resolveMaterializedReviewedHeadRelation };
|
|
113
|
+
//# sourceMappingURL=change-request-git-evidence.js.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { COMPLETION_BACKFILL_FAMILIES, inspectCompletionArtifacts } from '../task/finalization-artifacts.js';
|
|
4
|
+
import { parseArtifactName } from '../task/artifact-lifecycle.js';
|
|
5
|
+
import { parseTaskFrontmatter } from '../task/frontmatter.js';
|
|
6
|
+
import { resolveTaskRef } from '../task/resolve-ref.js';
|
|
7
|
+
import { getOpenWorkflowWarnings } from '../task/workflow-warnings.js';
|
|
8
|
+
import { applyWorkflowWarningIntent } from '../task/workflow-warning-intents.js';
|
|
9
|
+
import { captureTaskWriteMetadata } from '../task/write.js';
|
|
10
|
+
import { syncPlatformComment } from './issue-comments.js';
|
|
11
|
+
import { platformResult } from './types.js';
|
|
12
|
+
function result(base, artifacts, warnings) {
|
|
13
|
+
return { ...base, artifacts, warnings };
|
|
14
|
+
}
|
|
15
|
+
function excludedPrReview(taskDir, message) {
|
|
16
|
+
const names = [...message.matchAll(/(?:^|[^A-Za-z0-9_-])(pr-review(?:-r[1-9]\d*)?\.md)(?=$|[^A-Za-z0-9_.-])/g)]
|
|
17
|
+
.map((match) => match[1]);
|
|
18
|
+
if (names.length !== 1)
|
|
19
|
+
return null;
|
|
20
|
+
const parsed = parseArtifactName(names[0]);
|
|
21
|
+
if (!parsed || parsed.family !== 'pr-review')
|
|
22
|
+
return null;
|
|
23
|
+
const artifactPath = path.join(taskDir, parsed.name);
|
|
24
|
+
try {
|
|
25
|
+
const stat = fs.lstatSync(artifactPath);
|
|
26
|
+
return stat.isFile() && !stat.isSymbolicLink() ? parsed.name : null;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function backfillCompletionComments(taskRef, options) {
|
|
33
|
+
const resolved = resolveTaskRef(taskRef, options.cwd ? { repoRoot: options.cwd } : {});
|
|
34
|
+
if (!resolved.ok)
|
|
35
|
+
return result(platformResult('failed', {
|
|
36
|
+
error: { code: resolved.code, message: resolved.message, retryable: false }
|
|
37
|
+
}), [], []);
|
|
38
|
+
const inventory = inspectCompletionArtifacts(resolved.taskId, { repoRoot: resolved.repoRoot });
|
|
39
|
+
if (inventory.status === 'failed')
|
|
40
|
+
return result(platformResult('failed', {
|
|
41
|
+
error: {
|
|
42
|
+
code: inventory.error?.code || 'ARTIFACT_TOPOLOGY_CONFLICT',
|
|
43
|
+
message: inventory.error?.message || 'Completion artifact inventory failed',
|
|
44
|
+
retryable: false
|
|
45
|
+
}
|
|
46
|
+
}), [], []);
|
|
47
|
+
const initialContent = fs.readFileSync(resolved.taskMdPath, 'utf8');
|
|
48
|
+
const issueNumber = Number(parseTaskFrontmatter(initialContent).issue_number);
|
|
49
|
+
if (!Number.isInteger(issueNumber) || issueNumber <= 0)
|
|
50
|
+
return result(platformResult('no-op', {
|
|
51
|
+
error: { code: 'ISSUE_NOT_LINKED', message: 'Task has no valid issue_number', retryable: false }
|
|
52
|
+
}), [], []);
|
|
53
|
+
const artifacts = [];
|
|
54
|
+
const operations = [];
|
|
55
|
+
let latest = platformResult('no-op', { error: null });
|
|
56
|
+
for (const artifact of inventory.artifacts) {
|
|
57
|
+
latest = syncPlatformComment(resolved.taskId, {
|
|
58
|
+
kind: 'artifact',
|
|
59
|
+
artifact: artifact.name,
|
|
60
|
+
agent: options.agent,
|
|
61
|
+
backfill: true,
|
|
62
|
+
cwd: resolved.repoRoot,
|
|
63
|
+
client: options.client
|
|
64
|
+
});
|
|
65
|
+
operations.push(...latest.operations.map((operation) => ({
|
|
66
|
+
...operation,
|
|
67
|
+
name: `${artifact.name}:${operation.name}`
|
|
68
|
+
})));
|
|
69
|
+
artifacts.push({ artifact: artifact.name, status: latest.status });
|
|
70
|
+
if (latest.status === 'failed' || latest.status === 'blocked')
|
|
71
|
+
return result({ ...latest, operations }, artifacts, []);
|
|
72
|
+
if (latest.error)
|
|
73
|
+
return result(platformResult(latest.error.retryable ? 'blocked' : 'failed', {
|
|
74
|
+
platform: latest.platform,
|
|
75
|
+
resource: latest.resource,
|
|
76
|
+
capabilities: latest.capabilities,
|
|
77
|
+
operations,
|
|
78
|
+
error: latest.error
|
|
79
|
+
}), artifacts, []);
|
|
80
|
+
}
|
|
81
|
+
const matching = getOpenWorkflowWarnings(initialContent).flatMap((warning) => {
|
|
82
|
+
if (warning.step !== 'complete-task' || warning.code !== 'COMMENT_SYNC_FAILED' || warning.target !== 'artifact')
|
|
83
|
+
return [];
|
|
84
|
+
const excluded = excludedPrReview(resolved.taskDir, warning.message);
|
|
85
|
+
return excluded ? [{ warning, excluded }] : [];
|
|
86
|
+
});
|
|
87
|
+
const warnings = [];
|
|
88
|
+
let metadata = null;
|
|
89
|
+
for (const { warning, excluded } of matching) {
|
|
90
|
+
metadata ??= captureTaskWriteMetadata();
|
|
91
|
+
const resolution = [
|
|
92
|
+
`excluded=${excluded}`,
|
|
93
|
+
`completionFamilies=${COMPLETION_BACKFILL_FAMILIES.join(',')}`,
|
|
94
|
+
`synchronized=${inventory.artifacts.map((artifact) => artifact.name).join(',') || 'none'}`,
|
|
95
|
+
`completedAt=${metadata.timestamp}`
|
|
96
|
+
].join('; ');
|
|
97
|
+
const updated = applyWorkflowWarningIntent({
|
|
98
|
+
kind: 'set-status', taskRef: resolved.taskId, id: warning.id, status: 'resolved', resolution
|
|
99
|
+
}, { repoRoot: resolved.repoRoot, metadataProvider: () => metadata });
|
|
100
|
+
if (updated.status === 'failed')
|
|
101
|
+
return result(platformResult('failed', {
|
|
102
|
+
platform: latest.platform,
|
|
103
|
+
resource: latest.resource,
|
|
104
|
+
capabilities: latest.capabilities,
|
|
105
|
+
operations,
|
|
106
|
+
changed: artifacts.some((item) => item.status === 'applied'),
|
|
107
|
+
error: { code: updated.error?.code || 'WARNING_UPDATE_FAILED', message: updated.error?.message || 'Unable to resolve workflow warning', retryable: false }
|
|
108
|
+
}), artifacts, warnings);
|
|
109
|
+
warnings.push({ id: warning.id, status: updated.status });
|
|
110
|
+
}
|
|
111
|
+
const changed = artifacts.some((item) => item.status === 'applied') || warnings.some((item) => item.status === 'applied');
|
|
112
|
+
return result(platformResult(changed ? 'applied' : 'no-op', {
|
|
113
|
+
platform: latest.platform,
|
|
114
|
+
resource: latest.resource,
|
|
115
|
+
capabilities: latest.capabilities,
|
|
116
|
+
changed,
|
|
117
|
+
operations,
|
|
118
|
+
error: null
|
|
119
|
+
}), artifacts, warnings);
|
|
120
|
+
}
|
|
121
|
+
export { backfillCompletionComments };
|
|
122
|
+
//# sourceMappingURL=completion-backfill.js.map
|
|
@@ -19,7 +19,8 @@ const ARTIFACT_TITLES = {
|
|
|
19
19
|
'review-plan': '技术方案审查',
|
|
20
20
|
code: '实现报告',
|
|
21
21
|
'review-code': '代码审查',
|
|
22
|
-
'manual-validation': '人工验证报告'
|
|
22
|
+
'manual-validation': '人工验证报告',
|
|
23
|
+
'pr-review': 'PR 审查报告'
|
|
23
24
|
};
|
|
24
25
|
function normalizeCommentContent(content) {
|
|
25
26
|
return content.replace(/\r\n/g, '\n').replace(/\n+$/, '\n');
|
|
@@ -51,7 +52,7 @@ function renderTaskComment(content, taskId, agent) {
|
|
|
51
52
|
}
|
|
52
53
|
function artifactIdentity(artifact) {
|
|
53
54
|
const stem = path.basename(artifact, '.md');
|
|
54
|
-
const match = stem.match(/^(analysis|review-analysis|plan|review-plan|code|review-code|manual-validation)(?:-r(\d+))?$/);
|
|
55
|
+
const match = stem.match(/^(analysis|review-analysis|plan|review-plan|code|review-code|manual-validation|pr-review)(?:-r(\d+))?$/);
|
|
55
56
|
if (!match)
|
|
56
57
|
throw new Error(`unsupported artifact '${artifact}'`);
|
|
57
58
|
const base = ARTIFACT_TITLES[match[1]];
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { execFileSync } from "node:child_process";
|
|
1
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
2
5
|
const SHA_PATTERN = /^[0-9a-f]{40}$/i;
|
|
3
6
|
function git(cwd, args) {
|
|
4
|
-
return execFileSync("git", args, {
|
|
7
|
+
return execFileSync("git", args, {
|
|
8
|
+
cwd,
|
|
9
|
+
encoding: "utf8",
|
|
10
|
+
maxBuffer: 32 * 1024 * 1024,
|
|
11
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
12
|
+
});
|
|
5
13
|
}
|
|
6
14
|
function commitExists(gitRoot, sha) {
|
|
7
15
|
try {
|
|
@@ -12,35 +20,166 @@ function commitExists(gitRoot, sha) {
|
|
|
12
20
|
return false;
|
|
13
21
|
}
|
|
14
22
|
}
|
|
23
|
+
function isAncestor(gitRoot, ancestor, descendant) {
|
|
24
|
+
const result = spawnSync("git", ["merge-base", "--is-ancestor", ancestor, descendant], {
|
|
25
|
+
cwd: gitRoot,
|
|
26
|
+
encoding: "utf8",
|
|
27
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
28
|
+
});
|
|
29
|
+
if (result.status === 0)
|
|
30
|
+
return { status: "yes" };
|
|
31
|
+
if (result.status === 1)
|
|
32
|
+
return { status: "no" };
|
|
33
|
+
return { status: "error" };
|
|
34
|
+
}
|
|
35
|
+
function blocked(message) {
|
|
36
|
+
return { status: "blocked", code: "PR_MERGE_GIT_EVIDENCE_UNAVAILABLE", message };
|
|
37
|
+
}
|
|
38
|
+
function resolveUniqueMergeBase(gitRoot, reviewedHead, squashParent) {
|
|
39
|
+
const result = spawnSync("git", ["merge-base", "--all", reviewedHead, squashParent], {
|
|
40
|
+
cwd: gitRoot,
|
|
41
|
+
encoding: "utf8",
|
|
42
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
43
|
+
});
|
|
44
|
+
if (result.error || result.status === null || result.status > 1) {
|
|
45
|
+
return { status: "blocked", relation: blocked("Unable to compute the reviewed PR merge base") };
|
|
46
|
+
}
|
|
47
|
+
const candidates = result.stdout.trim() === "" ? [] : result.stdout.trim().split(/\s+/);
|
|
48
|
+
if (result.status === 1 || candidates.length !== 1) {
|
|
49
|
+
return {
|
|
50
|
+
status: "failed",
|
|
51
|
+
relation: {
|
|
52
|
+
status: "failed",
|
|
53
|
+
code: "PR_MERGE_TOPOLOGY_INVALID",
|
|
54
|
+
message: "Reviewed head and squash parent do not have a unique merge base"
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const [candidate] = candidates;
|
|
59
|
+
if (!candidate || !SHA_PATTERN.test(candidate)) {
|
|
60
|
+
return { status: "blocked", relation: blocked("Git returned an invalid reviewed PR merge base") };
|
|
61
|
+
}
|
|
62
|
+
return { status: "ok", mergeBase: candidate };
|
|
63
|
+
}
|
|
64
|
+
function compareReplayedTree(input) {
|
|
65
|
+
const { gitRoot, mergeBase, reviewedHead, squashParent, squashCommit } = input;
|
|
66
|
+
let tempDir;
|
|
67
|
+
let relation = null;
|
|
68
|
+
try {
|
|
69
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "agent-infra-merge-equivalence-"));
|
|
70
|
+
const env = { ...process.env, GIT_INDEX_FILE: path.join(tempDir, "index") };
|
|
71
|
+
const readTree = spawnSync("git", ["read-tree", squashParent], {
|
|
72
|
+
cwd: gitRoot, env, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"]
|
|
73
|
+
});
|
|
74
|
+
if (readTree.error || readTree.status !== 0) {
|
|
75
|
+
relation = blocked("Unable to initialize isolated squash merge evidence");
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const patchResult = spawnSync("git", ["diff", "--no-renames", "--binary", "--full-index", mergeBase, reviewedHead], { cwd: gitRoot, env, encoding: "utf8", maxBuffer: 32 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
|
|
79
|
+
if (patchResult.error || patchResult.status !== 0) {
|
|
80
|
+
relation = blocked("Unable to generate the reviewed PR patch");
|
|
81
|
+
}
|
|
82
|
+
else if (patchResult.stdout !== "") {
|
|
83
|
+
const applyResult = spawnSync("git", ["apply", "--cached", "--3way", "--binary", "-q"], {
|
|
84
|
+
cwd: gitRoot,
|
|
85
|
+
env,
|
|
86
|
+
encoding: "utf8",
|
|
87
|
+
input: patchResult.stdout,
|
|
88
|
+
maxBuffer: 32 * 1024 * 1024,
|
|
89
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
90
|
+
});
|
|
91
|
+
if (applyResult.status === 1) {
|
|
92
|
+
relation = {
|
|
93
|
+
status: "failed",
|
|
94
|
+
code: "PR_MERGE_CONTENT_MISMATCH",
|
|
95
|
+
message: "Reviewed PR patch cannot be replayed without conflicts, so content equivalence cannot be established"
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
else if (applyResult.error || applyResult.status !== 0) {
|
|
99
|
+
relation = blocked("Unable to replay the reviewed PR patch");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (relation === null) {
|
|
103
|
+
const compareResult = spawnSync("git", ["diff", "--cached", "--quiet", "--no-ext-diff", squashCommit, "--"], { cwd: gitRoot, env, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
104
|
+
if (compareResult.status === 1) {
|
|
105
|
+
relation = {
|
|
106
|
+
status: "failed",
|
|
107
|
+
code: "PR_MERGE_CONTENT_MISMATCH",
|
|
108
|
+
message: "Replayed reviewed PR content differs from the squash merge tree"
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
else if (compareResult.error || compareResult.status !== 0) {
|
|
112
|
+
relation = blocked("Unable to compare replayed PR content with the squash merge tree");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
relation = blocked("Unable to create isolated squash merge evidence");
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
if (tempDir) {
|
|
122
|
+
try {
|
|
123
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
relation = blocked("Unable to clean up isolated squash merge evidence");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return relation;
|
|
131
|
+
}
|
|
15
132
|
export function resolveReviewedHeadRelation(input) {
|
|
16
|
-
const { gitRoot,
|
|
17
|
-
if (
|
|
133
|
+
const { gitRoot, comparisonHead, lastReviewedCommit, pullRequest } = input;
|
|
134
|
+
if (comparisonHead === lastReviewedCommit &&
|
|
135
|
+
lastReviewedCommit === pullRequest.head.sha &&
|
|
136
|
+
!(pullRequest.state === "closed" && pullRequest.mergedAt && pullRequest.mergeCommitSha)) {
|
|
18
137
|
return { status: "strict", reviewedHead: lastReviewedCommit };
|
|
19
138
|
}
|
|
20
139
|
if (pullRequest.state !== "closed" || !pullRequest.mergedAt || !pullRequest.mergeCommitSha ||
|
|
21
140
|
lastReviewedCommit !== pullRequest.head.sha) {
|
|
22
141
|
return { status: "failed", code: "PR_MERGE_IDENTITY_INVALID", message: "PR merge identity does not match the reviewed head" };
|
|
23
142
|
}
|
|
24
|
-
const shas = [pullRequest.base.sha, pullRequest.head.sha, pullRequest.mergeCommitSha,
|
|
143
|
+
const shas = [pullRequest.base.sha, pullRequest.head.sha, pullRequest.mergeCommitSha, comparisonHead];
|
|
25
144
|
if (shas.some((sha) => !SHA_PATTERN.test(sha) || !commitExists(gitRoot, sha))) {
|
|
26
145
|
return { status: "blocked", code: "PR_MERGE_OBJECT_MISSING", message: "Required PR merge Git objects are unavailable" };
|
|
27
146
|
}
|
|
147
|
+
const ancestry = isAncestor(gitRoot, pullRequest.mergeCommitSha, comparisonHead);
|
|
148
|
+
if (ancestry.status === "no") {
|
|
149
|
+
return {
|
|
150
|
+
status: "failed",
|
|
151
|
+
code: "PR_MERGE_TARGET_MISMATCH",
|
|
152
|
+
message: "PR merge commit is not in the authoritative target history"
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (ancestry.status === "error") {
|
|
156
|
+
return {
|
|
157
|
+
status: "blocked",
|
|
158
|
+
code: "PR_MERGE_GIT_EVIDENCE_UNAVAILABLE",
|
|
159
|
+
message: "Unable to verify PR merge ancestry"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
28
162
|
try {
|
|
29
|
-
git(gitRoot, ["merge-base", "--is-ancestor", pullRequest.mergeCommitSha, localHead]);
|
|
30
163
|
const parents = git(gitRoot, ["rev-list", "--parents", "-n", "1", pullRequest.mergeCommitSha]).trim().split(/\s+/);
|
|
31
164
|
if (parents.length !== 2) {
|
|
32
165
|
return { status: "failed", code: "PR_MERGE_TOPOLOGY_INVALID", message: "PR merge commit is not a single-parent squash commit" };
|
|
33
166
|
}
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (reviewedDiff !== mergedDiff) {
|
|
38
|
-
return { status: "failed", code: "PR_MERGE_CONTENT_MISMATCH", message: "Squash merge content differs from the reviewed PR changes" };
|
|
39
|
-
}
|
|
40
|
-
const postMerge = git(gitRoot, ["rev-list", `${pullRequest.mergeCommitSha}..${localHead}`, "--", ...pathspecs]).trim();
|
|
41
|
-
if (postMerge) {
|
|
42
|
-
return { status: "failed", code: "POST_MERGE_CHANGES", message: "Protected paths changed after the squash merge" };
|
|
167
|
+
const squashParent = parents[1];
|
|
168
|
+
if (!squashParent) {
|
|
169
|
+
return { status: "failed", code: "PR_MERGE_TOPOLOGY_INVALID", message: "PR merge commit is not a single-parent squash commit" };
|
|
43
170
|
}
|
|
171
|
+
const mergeBase = resolveUniqueMergeBase(gitRoot, pullRequest.head.sha, squashParent);
|
|
172
|
+
if (mergeBase.status !== "ok")
|
|
173
|
+
return mergeBase.relation;
|
|
174
|
+
const replayFailure = compareReplayedTree({
|
|
175
|
+
gitRoot,
|
|
176
|
+
mergeBase: mergeBase.mergeBase,
|
|
177
|
+
reviewedHead: pullRequest.head.sha,
|
|
178
|
+
squashParent,
|
|
179
|
+
squashCommit: pullRequest.mergeCommitSha
|
|
180
|
+
});
|
|
181
|
+
if (replayFailure)
|
|
182
|
+
return replayFailure;
|
|
44
183
|
}
|
|
45
184
|
catch {
|
|
46
185
|
return { status: "blocked", code: "PR_MERGE_GIT_EVIDENCE_UNAVAILABLE", message: "Unable to verify PR merge topology or content" };
|
|
@@ -48,7 +187,8 @@ export function resolveReviewedHeadRelation(input) {
|
|
|
48
187
|
return {
|
|
49
188
|
status: "merged-equivalent",
|
|
50
189
|
reviewedHead: lastReviewedCommit,
|
|
51
|
-
mergeCommit: pullRequest.mergeCommitSha
|
|
190
|
+
mergeCommit: pullRequest.mergeCommitSha,
|
|
191
|
+
comparisonHead
|
|
52
192
|
};
|
|
53
193
|
}
|
|
54
194
|
//# sourceMappingURL=merged-pr-equivalence.js.map
|