@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { parseTaskFrontmatter } from '../task/frontmatter.js';
|
|
3
3
|
import { resolveTaskRef } from '../task/resolve-ref.js';
|
|
4
|
+
import { inspectPlatformRequiredChecks, registerPlatformCapabilities } from './adapters.js';
|
|
4
5
|
import { resolvePlatformContext } from './context.js';
|
|
5
6
|
import { createGitHubClient } from './github-client.js';
|
|
6
7
|
import { inspectPlatformPullRequest } from './pull-requests.js';
|
|
@@ -16,21 +17,14 @@ function classifyRequiredChecks(required) {
|
|
|
16
17
|
return { state: 'pending', required };
|
|
17
18
|
return { state: 'passed', required };
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (snapshot.state !== 'pending')
|
|
28
|
-
return snapshot;
|
|
29
|
-
const elapsed = now() - started;
|
|
30
|
-
if (elapsed >= options.deadlineMs)
|
|
31
|
-
return { state: 'timed-out', required: snapshot.required };
|
|
32
|
-
await sleep(Math.min(options.intervalMs, options.deadlineMs - elapsed));
|
|
33
|
-
}
|
|
20
|
+
function classifyPullRequestReadiness(input) {
|
|
21
|
+
if (input.mergeability === 'conflicting')
|
|
22
|
+
return { state: 'conflicting', headSha: input.headSha };
|
|
23
|
+
if (input.checks.state === 'failed' || input.checks.state === 'cancelled')
|
|
24
|
+
return { state: 'checks-failed', headSha: input.headSha };
|
|
25
|
+
if (input.mergeability === 'unknown' || input.checks.state === 'pending')
|
|
26
|
+
return { state: 'pending', headSha: input.headSha };
|
|
27
|
+
return { state: 'ready', headSha: input.headSha };
|
|
34
28
|
}
|
|
35
29
|
function parseRunJobIdentity(detailsUrl) {
|
|
36
30
|
try {
|
|
@@ -87,6 +81,18 @@ function normalizeChecks(value) {
|
|
|
87
81
|
}] : [];
|
|
88
82
|
});
|
|
89
83
|
}
|
|
84
|
+
registerPlatformCapabilities('github', {
|
|
85
|
+
inspectRequiredChecks({ client, repository, number, cwd }) {
|
|
86
|
+
const github = client || createGitHubClient();
|
|
87
|
+
const inspected = github.json([
|
|
88
|
+
'pr', 'checks', String(number), '--repo', repository, '--required',
|
|
89
|
+
'--json', 'name,state,bucket,link,workflow,startedAt,completedAt'
|
|
90
|
+
], { cwd });
|
|
91
|
+
return inspected.ok
|
|
92
|
+
? { ok: true, value: normalizeChecks(inspected.value) }
|
|
93
|
+
: { ok: false, error: inspected.error };
|
|
94
|
+
}
|
|
95
|
+
});
|
|
90
96
|
function resolvedTask(taskRef, options) {
|
|
91
97
|
const resolved = resolveTaskRef(taskRef, options.cwd ? { repoRoot: options.cwd } : {});
|
|
92
98
|
if (!resolved.ok)
|
|
@@ -109,19 +115,30 @@ function inspectRequiredChecks(taskRef, options = {}) {
|
|
|
109
115
|
const base = resolvedTask(taskRef, options);
|
|
110
116
|
if (!base.ok)
|
|
111
117
|
return base.output;
|
|
118
|
+
return inspectChecksForResolvedTask(base, options);
|
|
119
|
+
}
|
|
120
|
+
function inspectChecksForResolvedTask(base, options) {
|
|
112
121
|
const repository = base.context.platform.repository;
|
|
113
|
-
const inspected = base.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
const inspected = inspectPlatformRequiredChecks(base.context.platform.type, {
|
|
123
|
+
cwd: base.resolved.repoRoot,
|
|
124
|
+
repository,
|
|
125
|
+
number: base.prNumber,
|
|
126
|
+
headSha: base.pullRequest.head.sha,
|
|
127
|
+
client: options.client || base.client
|
|
128
|
+
});
|
|
129
|
+
if (!inspected.ok || !inspected.value) {
|
|
130
|
+
const error = inspected.error || {
|
|
131
|
+
code: 'REQUIRED_CHECKS_INSPECTION_INVALID',
|
|
132
|
+
message: 'Platform adapter returned no required-checks snapshot',
|
|
133
|
+
retryable: false
|
|
134
|
+
};
|
|
135
|
+
return checksResult(error.retryable ? 'blocked' : 'failed', {
|
|
119
136
|
platform: base.context.platform, capabilities: base.context.capabilities,
|
|
120
137
|
resource: { kind: 'pull-request', number: base.prNumber },
|
|
121
|
-
pullRequest: base.pullRequest, error
|
|
138
|
+
pullRequest: base.pullRequest, error
|
|
122
139
|
});
|
|
123
140
|
}
|
|
124
|
-
const classified = classifyRequiredChecks(
|
|
141
|
+
const classified = classifyRequiredChecks(inspected.value);
|
|
125
142
|
const status = classified.state === 'passed' || classified.state === 'no-required'
|
|
126
143
|
? 'no-op'
|
|
127
144
|
: classified.state === 'failed' || classified.state === 'cancelled' ? 'failed' : 'blocked';
|
|
@@ -136,33 +153,60 @@ function inspectRequiredChecks(taskRef, options = {}) {
|
|
|
136
153
|
}
|
|
137
154
|
});
|
|
138
155
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
function inspectPullRequestReadiness(taskRef, options = {}) {
|
|
157
|
+
const base = resolvedTask(taskRef, options);
|
|
158
|
+
if (!base.ok)
|
|
159
|
+
return base.output;
|
|
160
|
+
const checked = inspectChecksForResolvedTask(base, options);
|
|
161
|
+
const classifiedCodes = new Set(['REQUIRED_CHECKS_PENDING', 'REQUIRED_CHECKS_FAILED', 'REQUIRED_CHECKS_CANCELLED']);
|
|
162
|
+
if (checked.error && !classifiedCodes.has(checked.error.code))
|
|
163
|
+
return checked;
|
|
164
|
+
const readiness = classifyPullRequestReadiness({
|
|
165
|
+
headSha: base.pullRequest.head.sha,
|
|
166
|
+
mergeability: base.pullRequest.mergeability?.state ?? 'unknown',
|
|
167
|
+
checks: checked.checks
|
|
168
|
+
});
|
|
169
|
+
const status = readiness.state === 'ready' ? 'no-op'
|
|
170
|
+
: readiness.state === 'conflicting' || readiness.state === 'checks-failed' ? 'failed' : 'blocked';
|
|
171
|
+
return checksResult(status, {
|
|
172
|
+
...checked,
|
|
173
|
+
status,
|
|
174
|
+
changed: false,
|
|
175
|
+
readiness,
|
|
176
|
+
error: status === 'no-op' ? null : {
|
|
177
|
+
code: readiness.state === 'conflicting' ? 'PR_MERGE_CONFLICT'
|
|
178
|
+
: readiness.state === 'checks-failed' ? 'REQUIRED_CHECKS_FAILED' : 'PR_READINESS_PENDING',
|
|
179
|
+
message: `Pull request readiness is ${readiness.state}`,
|
|
180
|
+
retryable: readiness.state === 'pending'
|
|
152
181
|
}
|
|
153
182
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
183
|
+
}
|
|
184
|
+
async function watchPullRequestReadiness(taskRef, options) {
|
|
185
|
+
const now = options.now || (() => performance.now());
|
|
186
|
+
const sleep = options.sleep || ((delay) => new Promise((resolve) => setTimeout(resolve, delay)));
|
|
187
|
+
const started = now();
|
|
188
|
+
let last = null;
|
|
189
|
+
while (true) {
|
|
190
|
+
if (options.signal?.aborted)
|
|
191
|
+
return checksResult('blocked', {
|
|
192
|
+
...last,
|
|
193
|
+
status: 'blocked', changed: false,
|
|
194
|
+
readiness: { state: 'cancelled', headSha: last?.pullRequest?.head.sha ?? '' },
|
|
195
|
+
error: { code: 'PR_READINESS_CANCELLED', message: 'Pull request readiness watch was cancelled', retryable: false }
|
|
196
|
+
});
|
|
197
|
+
last = inspectPullRequestReadiness(taskRef, options);
|
|
198
|
+
if (last.readiness?.state !== 'pending' || last.error?.code !== 'PR_READINESS_PENDING')
|
|
199
|
+
return last;
|
|
200
|
+
const elapsed = now() - started;
|
|
201
|
+
if (elapsed >= options.deadlineSeconds * 1000)
|
|
202
|
+
return checksResult('blocked', {
|
|
203
|
+
...last,
|
|
204
|
+
status: 'blocked', changed: false,
|
|
205
|
+
readiness: { state: 'timed-out', headSha: last.pullRequest?.head.sha ?? '' },
|
|
206
|
+
error: { code: 'PR_READINESS_TIMEOUT', message: 'Pull request readiness watch timed out', retryable: true }
|
|
207
|
+
});
|
|
208
|
+
await sleep(Math.min(options.intervalSeconds * 1000, options.deadlineSeconds * 1000 - elapsed));
|
|
209
|
+
}
|
|
166
210
|
}
|
|
167
211
|
function resolvePlatformCheckRun(taskRef, options) {
|
|
168
212
|
const base = resolvedTask(taskRef, options);
|
|
@@ -194,6 +238,13 @@ function resolvePlatformCheckRun(taskRef, options) {
|
|
|
194
238
|
error: resolution.status === 'resolved' ? null : { code: resolution.status === 'ambiguous' ? 'CHECK_RUN_AMBIGUOUS' : 'CHECK_RUN_NOT_FOUND', message: `Check run is ${resolution.status}`, retryable: false }
|
|
195
239
|
});
|
|
196
240
|
}
|
|
241
|
+
function fetchCheckLogText(client, args, cwd) {
|
|
242
|
+
const fetched = client.text(args, { cwd });
|
|
243
|
+
if (fetched.ok || args[0] !== 'api' || !/response contains terminal escape sequences/i.test(fetched.error.message)) {
|
|
244
|
+
return fetched;
|
|
245
|
+
}
|
|
246
|
+
return client.text([...args, '--allow-escape-sequences'], { cwd });
|
|
247
|
+
}
|
|
197
248
|
function fetchPlatformCheckLogs(taskRef, options) {
|
|
198
249
|
const base = resolvedTask(taskRef, options);
|
|
199
250
|
if (!base.ok)
|
|
@@ -201,7 +252,7 @@ function fetchPlatformCheckLogs(taskRef, options) {
|
|
|
201
252
|
const args = options.job
|
|
202
253
|
? ['api', `repos/${base.context.platform.repository}/actions/jobs/${options.job}/logs`]
|
|
203
254
|
: ['run', 'view', String(options.run), '--repo', base.context.platform.repository, '--log-failed'];
|
|
204
|
-
const fetched = base.client
|
|
255
|
+
const fetched = fetchCheckLogText(base.client, args, base.resolved.repoRoot);
|
|
205
256
|
if (!fetched.ok)
|
|
206
257
|
return checksResult(fetched.error.retryable ? 'blocked' : 'failed', { platform: base.context.platform, capabilities: base.context.capabilities, error: fetched.error });
|
|
207
258
|
if (!fetched.value)
|
|
@@ -212,5 +263,5 @@ function fetchPlatformCheckLogs(taskRef, options) {
|
|
|
212
263
|
logs: { runId: options.run, ...(options.job ? { jobId: options.job } : {}), text: fetched.value }, error: null
|
|
213
264
|
});
|
|
214
265
|
}
|
|
215
|
-
export { classifyRequiredChecks, fetchPlatformCheckLogs, inspectRequiredChecks, parseRunJobIdentity, resolvePlatformCheckRun, resolveRunCandidate,
|
|
266
|
+
export { classifyPullRequestReadiness, classifyRequiredChecks, fetchCheckLogText, fetchPlatformCheckLogs, inspectRequiredChecks, inspectPullRequestReadiness, parseRunJobIdentity, resolvePlatformCheckRun, resolveRunCandidate, watchPullRequestReadiness };
|
|
216
267
|
//# sourceMappingURL=pr-checks.js.map
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { createGitHubClient } from './github-client.js';
|
|
2
|
+
import { resolvePlatformContext } from './context.js';
|
|
3
|
+
import { platformResult } from './types.js';
|
|
4
|
+
const REVIEW_EVENTS = ['COMMENT', 'APPROVE', 'REQUEST_CHANGES'];
|
|
5
|
+
// Marker-safe scope: a task id (`TASK-YYYYMMDD-HHMMSS`) or a bare PR number
|
|
6
|
+
// (`pr{N}`). Any other value (e.g. one containing `\r\n` or `-->`) would break
|
|
7
|
+
// the first-line marker idempotency contract of `reviewMarker` (PL-6).
|
|
8
|
+
const REVIEW_SCOPE_PATTERN = /^(?:pr\d+|TASK-\d{8}-\d{6})$/;
|
|
9
|
+
export function reviewMarker(identity) {
|
|
10
|
+
return `<!-- review-pr:${identity.scope}:r${identity.round} -->`;
|
|
11
|
+
}
|
|
12
|
+
export function reviewedCommitMarker(sha) {
|
|
13
|
+
return `<!-- reviewed-commit: ${sha} -->`;
|
|
14
|
+
}
|
|
15
|
+
function normalizeBody(body) {
|
|
16
|
+
return String(body || '').replace(/\r\n/g, '\n').replace(/\n+$/, '\n');
|
|
17
|
+
}
|
|
18
|
+
function firstLine(body) {
|
|
19
|
+
return normalizeBody(String(body || '')).split('\n', 1)[0] || '';
|
|
20
|
+
}
|
|
21
|
+
function hasUsableContext(context) {
|
|
22
|
+
return (context.status === 'no-op' || context.status === 'degraded') && context.platform.repository !== null;
|
|
23
|
+
}
|
|
24
|
+
function invalidPrNumber(prNumber) {
|
|
25
|
+
return !Number.isInteger(prNumber) || prNumber <= 0;
|
|
26
|
+
}
|
|
27
|
+
export function listPrReviews(prNumber, options = {}) {
|
|
28
|
+
const client = options.client || createGitHubClient();
|
|
29
|
+
const context = resolvePlatformContext({ cwd: options.cwd || process.cwd(), client });
|
|
30
|
+
if (!hasUsableContext(context)) {
|
|
31
|
+
return { ...platformResult(context.status, { platform: context.platform, capabilities: context.capabilities, error: context.error }), reviews: [] };
|
|
32
|
+
}
|
|
33
|
+
const repository = context.platform.repository;
|
|
34
|
+
if (invalidPrNumber(prNumber)) {
|
|
35
|
+
return {
|
|
36
|
+
...platformResult('failed', {
|
|
37
|
+
platform: context.platform, capabilities: context.capabilities,
|
|
38
|
+
error: { code: 'PR_NUMBER_INVALID', message: 'PR number must be positive', retryable: false }
|
|
39
|
+
}),
|
|
40
|
+
reviews: []
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const fetched = client.json(['api', '--paginate', '--slurp', `repos/${repository}/pulls/${prNumber}/reviews?per_page=100`], { cwd: options.cwd || process.cwd() });
|
|
44
|
+
if (!fetched.ok) {
|
|
45
|
+
return {
|
|
46
|
+
...platformResult(fetched.error.retryable ? 'blocked' : 'failed', {
|
|
47
|
+
platform: context.platform, capabilities: context.capabilities,
|
|
48
|
+
resource: { kind: 'pull-request', number: prNumber }, error: fetched.error
|
|
49
|
+
}),
|
|
50
|
+
reviews: []
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const flat = (fetched.value || []).flatMap((entry) => Array.isArray(entry) ? entry : [entry]);
|
|
54
|
+
const reviews = flat
|
|
55
|
+
.map((review) => ({
|
|
56
|
+
id: review.id ?? 0,
|
|
57
|
+
commitId: review.commit_id ?? '',
|
|
58
|
+
body: review.body ?? '',
|
|
59
|
+
url: review.html_url ?? ''
|
|
60
|
+
}))
|
|
61
|
+
.filter((review) => review.body !== '');
|
|
62
|
+
return {
|
|
63
|
+
...platformResult('no-op', {
|
|
64
|
+
platform: context.platform, capabilities: context.capabilities,
|
|
65
|
+
resource: { kind: 'pull-request', number: prNumber }, error: null
|
|
66
|
+
}),
|
|
67
|
+
reviews
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export function publishPrReview(options) {
|
|
71
|
+
const client = options.client || createGitHubClient();
|
|
72
|
+
const context = resolvePlatformContext({ cwd: options.cwd || process.cwd(), client });
|
|
73
|
+
if (!hasUsableContext(context)) {
|
|
74
|
+
return platformResult(context.status, { platform: context.platform, capabilities: context.capabilities, error: context.error });
|
|
75
|
+
}
|
|
76
|
+
const repository = context.platform.repository;
|
|
77
|
+
if (invalidPrNumber(options.prNumber)) {
|
|
78
|
+
return platformResult('failed', {
|
|
79
|
+
platform: context.platform, capabilities: context.capabilities,
|
|
80
|
+
error: { code: 'PR_NUMBER_INVALID', message: 'PR number must be positive', retryable: false }
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (!REVIEW_EVENTS.includes(options.event)) {
|
|
84
|
+
return platformResult('failed', {
|
|
85
|
+
platform: context.platform, capabilities: context.capabilities,
|
|
86
|
+
resource: { kind: 'pull-request', number: options.prNumber },
|
|
87
|
+
error: { code: 'REVIEW_EVENT_INVALID', message: `review event must be one of ${REVIEW_EVENTS.join('|')}`, retryable: false }
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (!REVIEW_SCOPE_PATTERN.test(options.identity.scope) || !/^[0-9a-f]{7,40}$/i.test(options.identity.commitSha)) {
|
|
91
|
+
return platformResult('failed', {
|
|
92
|
+
platform: context.platform, capabilities: context.capabilities,
|
|
93
|
+
resource: { kind: 'pull-request', number: options.prNumber },
|
|
94
|
+
error: { code: 'REVIEW_IDENTITY_INVALID', message: 'review scope must be a task id or pr{N}; commitSha is required', retryable: false }
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const marker = reviewMarker(options.identity);
|
|
98
|
+
const listed = listPrReviews(options.prNumber, { cwd: options.cwd, client });
|
|
99
|
+
if (listed.status === 'failed' || listed.status === 'blocked')
|
|
100
|
+
return listed;
|
|
101
|
+
const existing = listed.reviews.find((review) => firstLine(review.body) === marker) ?? null;
|
|
102
|
+
if (existing) {
|
|
103
|
+
if (existing.commitId === options.identity.commitSha) {
|
|
104
|
+
return platformResult('no-op', {
|
|
105
|
+
platform: context.platform, capabilities: context.capabilities,
|
|
106
|
+
resource: { kind: 'pull-request', number: options.prNumber },
|
|
107
|
+
operations: [{ name: 'review:publish', status: 'no-op', reasonCode: null }], error: null
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return platformResult('failed', {
|
|
111
|
+
platform: context.platform, capabilities: context.capabilities,
|
|
112
|
+
resource: { kind: 'pull-request', number: options.prNumber },
|
|
113
|
+
operations: [{ name: 'review:publish', status: 'failed', reasonCode: 'REVIEW_MARKER_CONFLICT' }],
|
|
114
|
+
error: { code: 'REVIEW_MARKER_CONFLICT', message: 'A review with the same marker targets a different commit; start a new round', retryable: false }
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const wrappedBody = [
|
|
118
|
+
marker,
|
|
119
|
+
reviewedCommitMarker(options.identity.commitSha),
|
|
120
|
+
'',
|
|
121
|
+
String(options.body || '').replace(/\r?\n/g, '\n').replace(/\n+$/, ''),
|
|
122
|
+
''
|
|
123
|
+
].join('\n');
|
|
124
|
+
if (options.dryRun) {
|
|
125
|
+
return platformResult('planned', {
|
|
126
|
+
platform: context.platform, capabilities: context.capabilities,
|
|
127
|
+
resource: { kind: 'pull-request', number: options.prNumber },
|
|
128
|
+
operations: [{ name: 'review:publish', status: 'planned', reasonCode: null }], error: null
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const posted = client.json(['api', `repos/${repository}/pulls/${options.prNumber}/reviews`, '-X', 'POST', '--input', '-'], {
|
|
132
|
+
cwd: options.cwd || process.cwd(),
|
|
133
|
+
method: 'POST',
|
|
134
|
+
input: JSON.stringify({ commit_id: options.identity.commitSha, body: wrappedBody, event: options.event })
|
|
135
|
+
});
|
|
136
|
+
if (!posted.ok) {
|
|
137
|
+
if (posted.error.retryable) {
|
|
138
|
+
const reconciled = listPrReviews(options.prNumber, { cwd: options.cwd, client });
|
|
139
|
+
const found = reconciled.reviews.find((review) => firstLine(review.body) === marker);
|
|
140
|
+
if (found) {
|
|
141
|
+
return platformResult('applied', {
|
|
142
|
+
changed: true, platform: context.platform, capabilities: context.capabilities,
|
|
143
|
+
resource: { kind: 'pull-request', number: options.prNumber },
|
|
144
|
+
operations: [{ name: 'review:publish', status: 'applied', reasonCode: 'CREATE_RECONCILED' }], error: null
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return platformResult('blocked', {
|
|
148
|
+
platform: context.platform, capabilities: context.capabilities,
|
|
149
|
+
resource: { kind: 'pull-request', number: options.prNumber },
|
|
150
|
+
operations: [{ name: 'review:publish', status: 'failed', reasonCode: 'REVIEW_CREATE_OUTCOME_UNKNOWN' }],
|
|
151
|
+
error: { code: 'REVIEW_CREATE_OUTCOME_UNKNOWN', message: posted.error.message, retryable: true }
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return platformResult('failed', {
|
|
155
|
+
platform: context.platform, capabilities: context.capabilities,
|
|
156
|
+
resource: { kind: 'pull-request', number: options.prNumber },
|
|
157
|
+
operations: [{ name: 'review:publish', status: 'failed', reasonCode: posted.error.code }], error: posted.error
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return platformResult('applied', {
|
|
161
|
+
changed: true, platform: context.platform, capabilities: context.capabilities,
|
|
162
|
+
resource: { kind: 'pull-request', number: options.prNumber },
|
|
163
|
+
operations: [{ name: 'review:publish', status: 'applied', reasonCode: null }], error: null
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=pr-review.js.map
|