@fitlab-ai/agent-infra 0.9.10 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -9
- package/README.zh-CN.md +19 -9
- package/bin/cli.ts +17 -4
- package/dist/bin/cli.js +19 -4
- package/dist/bin/internal-cli.js +55 -4
- package/dist/lib/agent-client.js +0 -1
- package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +71 -10
- package/dist/lib/agent-clients/adapters/opencode-sandbox.js +0 -4
- package/dist/lib/agent-clients/adapters/traecli.js +7 -8
- package/dist/lib/agent-clients/config.js +14 -99
- package/dist/lib/agent-clients/reconcile.js +1 -11
- package/dist/lib/agent-clients/schema.js +5 -4
- package/dist/lib/agent-clients/tokens.js +5 -15
- package/dist/lib/decide.js +14 -30
- package/dist/lib/defaults.json +8 -0
- package/dist/lib/git/workflow.js +43 -1
- package/dist/lib/init.js +3 -2
- package/dist/lib/internal/git-workflow.js +8 -1
- package/dist/lib/internal/platform-pr.js +8 -2
- package/dist/lib/internal/release-workflow.js +0 -1
- package/dist/lib/internal/task-delivery.js +59 -0
- package/dist/lib/internal/task-finalization.js +19 -9
- package/dist/lib/internal/task-ledger.js +8 -2
- package/dist/lib/internal/task-lifecycle.js +17 -93
- package/dist/lib/internal/task-orchestration.js +30 -216
- package/dist/lib/internal/task-validate.js +2 -1
- package/dist/lib/merge.js +205 -103
- package/dist/lib/platform/github-client.js +7 -1
- package/dist/lib/platform/pr-checks.js +8 -5
- package/dist/lib/platform/pr-summary.js +12 -8
- package/dist/lib/platform/pull-requests.js +393 -91
- package/dist/lib/platform/verification-required.js +13 -2
- package/dist/lib/platform/verification-sync.js +9 -4
- package/dist/lib/pr-review/evidence-grading.js +12 -4
- package/dist/lib/process-data/normalize.js +2 -9
- package/dist/lib/run/host.js +46 -16
- package/dist/lib/sandbox/agent-client-reconciler.js +4 -12
- package/dist/lib/sandbox/commands/create.js +3 -3
- package/dist/lib/sandbox/commands/enter.js +18 -4
- package/dist/lib/sandbox/config.js +8 -12
- package/dist/lib/sandbox/control/executor.js +131 -39
- package/dist/lib/sandbox/control/lifecycle.js +55 -24
- package/dist/lib/sandbox/control/server.js +18 -16
- package/dist/lib/sandbox/mounts.js +3 -2
- package/dist/lib/sandbox/recovery.js +123 -22
- package/dist/lib/sandbox/workspace-identity.js +14 -0
- package/dist/lib/sandbox/workspace-view.js +8 -9
- package/dist/lib/self-update.js +278 -0
- package/dist/lib/server/process-state.js +2 -2
- package/dist/lib/server/protocol.js +5 -5
- package/dist/lib/task/activity-log.js +4 -1
- package/dist/lib/task/artifact-lifecycle.js +6 -4
- package/dist/lib/task/codex-orchestration.js +1 -1
- package/dist/lib/task/command-options.js +1 -3
- package/dist/lib/task/commands/cat.js +0 -5
- package/dist/lib/task/commands/decisions.js +76 -92
- package/dist/lib/task/commands/files.js +6 -6
- package/dist/lib/task/commands/grep.js +25 -61
- package/dist/lib/task/commands/issue-body.js +6 -6
- package/dist/lib/task/commands/log.js +25 -10
- package/dist/lib/task/commands/show.js +5 -6
- package/dist/lib/task/commands/status.js +8 -8
- package/dist/lib/task/commit-intent.js +100 -0
- package/dist/lib/task/commit-operation.js +181 -91
- package/dist/lib/task/commit-policy.js +1 -1
- package/dist/lib/task/control-authority.js +431 -0
- package/dist/lib/task/create.js +39 -8
- package/dist/lib/task/current-contract.js +35 -0
- package/dist/lib/task/decision-details.js +218 -0
- package/dist/lib/task/decision-intents.js +5 -2
- package/dist/lib/task/delivery-target.js +97 -0
- package/dist/lib/task/delivery.js +153 -0
- package/dist/lib/task/events.js +11 -5
- package/dist/lib/task/human-override.js +5 -2
- package/dist/lib/task/index.js +19 -20
- package/dist/lib/task/ledger-intents.js +8 -9
- package/dist/lib/task/ledger.js +13 -6
- package/dist/lib/task/lifecycle.js +122 -9
- package/dist/lib/task/orchestration.js +105 -75
- package/dist/lib/task/pr-delivery-fact.js +182 -0
- package/dist/lib/task/review-artifacts.js +31 -12
- package/dist/lib/task/review-finalization.js +13 -4
- package/dist/lib/task/review-fingerprint.js +8 -0
- package/dist/lib/task/verification-engine.js +86 -39
- package/dist/lib/task/verification-review.js +2 -2
- package/dist/lib/task/workspace-snapshot.js +5 -11
- package/dist/lib/task/write.js +11 -1
- package/dist/lib/update.js +13 -35
- package/dist/lib/version.js +5 -1
- package/dist/lifecycle-build-manifest.json +3 -3
- package/lib/agent-client.ts +0 -1
- package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +105 -10
- package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +12 -1
- package/lib/agent-clients/adapters/opencode-sandbox.ts +0 -5
- package/lib/agent-clients/adapters/traecli.ts +7 -8
- package/lib/agent-clients/config.ts +14 -144
- package/lib/agent-clients/reconcile.ts +1 -12
- package/lib/agent-clients/schema.ts +5 -4
- package/lib/agent-clients/tokens.ts +5 -18
- package/lib/decide.ts +12 -22
- package/lib/defaults.json +8 -0
- package/lib/git/workflow.ts +38 -1
- package/lib/init.ts +5 -2
- package/lib/internal/git-workflow.ts +7 -1
- package/lib/internal/platform-pr.ts +8 -1
- package/lib/internal/release-workflow.ts +0 -1
- package/lib/internal/task-delivery.ts +53 -0
- package/lib/internal/task-finalization.ts +27 -13
- package/lib/internal/task-ledger.ts +8 -2
- package/lib/internal/task-lifecycle.ts +33 -76
- package/lib/internal/task-orchestration.ts +33 -190
- package/lib/internal/task-validate.ts +3 -2
- package/lib/merge.ts +236 -120
- package/lib/platform/github-client.ts +8 -1
- package/lib/platform/pr-checks.ts +7 -5
- package/lib/platform/pr-summary.ts +10 -7
- package/lib/platform/pull-requests.ts +425 -87
- package/lib/platform/verification-required.ts +12 -2
- package/lib/platform/verification-sync.ts +9 -4
- package/lib/pr-review/evidence-grading.ts +7 -4
- package/lib/process-data/normalize.ts +2 -8
- package/lib/run/host.ts +63 -14
- package/lib/sandbox/agent-client-reconciler.ts +5 -15
- package/lib/sandbox/commands/create.ts +4 -4
- package/lib/sandbox/commands/enter.ts +24 -4
- package/lib/sandbox/config.ts +9 -14
- package/lib/sandbox/control/container-identity.ts +2 -2
- package/lib/sandbox/control/executor.ts +148 -51
- package/lib/sandbox/control/lifecycle.ts +59 -31
- package/lib/sandbox/control/protocol.ts +1 -3
- package/lib/sandbox/control/server.ts +15 -12
- package/lib/sandbox/control/state.ts +7 -7
- package/lib/sandbox/mounts.ts +4 -3
- package/lib/sandbox/recovery.ts +162 -34
- package/lib/sandbox/tools.ts +1 -1
- package/lib/sandbox/workspace-identity.ts +28 -0
- package/lib/sandbox/workspace-view.ts +14 -10
- package/lib/self-update.ts +341 -0
- package/lib/server/process-state.ts +2 -2
- package/lib/server/protocol.ts +5 -5
- package/lib/task/activity-log.ts +6 -1
- package/lib/task/artifact-lifecycle.ts +7 -5
- package/lib/task/codex-orchestration.ts +2 -1
- package/lib/task/command-options.ts +1 -2
- package/lib/task/commands/cat.ts +0 -4
- package/lib/task/commands/decisions.ts +80 -75
- package/lib/task/commands/files.ts +6 -6
- package/lib/task/commands/grep.ts +23 -51
- package/lib/task/commands/issue-body.ts +6 -6
- package/lib/task/commands/log.ts +22 -10
- package/lib/task/commands/show.ts +5 -6
- package/lib/task/commands/status.ts +8 -8
- package/lib/task/commit-intent.ts +137 -0
- package/lib/task/commit-operation.ts +161 -79
- package/lib/task/commit-policy.ts +1 -2
- package/lib/task/control-authority.ts +563 -0
- package/lib/task/create.ts +40 -10
- package/lib/task/current-contract.ts +49 -0
- package/lib/task/decision-details.ts +280 -0
- package/lib/task/decision-intents.ts +7 -2
- package/lib/task/delivery-target.ts +130 -0
- package/lib/task/delivery.ts +160 -0
- package/lib/task/events.ts +10 -5
- package/lib/task/human-override.ts +5 -2
- package/lib/task/index.ts +19 -20
- package/lib/task/ledger-intents.ts +6 -8
- package/lib/task/ledger.ts +17 -7
- package/lib/task/lifecycle.ts +113 -4
- package/lib/task/orchestration.ts +102 -80
- package/lib/task/pr-delivery-fact.ts +254 -0
- package/lib/task/review-artifacts.ts +53 -15
- package/lib/task/review-finalization.ts +21 -5
- package/lib/task/review-fingerprint.ts +10 -0
- package/lib/task/verification-engine.ts +78 -46
- package/lib/task/verification-review.ts +3 -1
- package/lib/task/workspace-snapshot.ts +4 -13
- package/lib/task/write.ts +20 -1
- package/lib/update.ts +14 -38
- package/lib/version.ts +6 -1
- package/package.json +1 -1
- package/templates/.agents/README.en.md +5 -3
- package/templates/.agents/README.zh-CN.md +5 -3
- package/templates/.agents/rules/README.en.md +4 -2
- package/templates/.agents/rules/README.zh-CN.md +4 -2
- package/templates/.agents/rules/compatibility-policy.en.md +5 -4
- package/templates/.agents/rules/compatibility-policy.zh-CN.md +5 -4
- package/templates/.agents/rules/create-issue.en.md +11 -2
- package/templates/.agents/rules/create-issue.zh-CN.md +24 -2
- package/templates/.agents/rules/human-decision-context.en.md +9 -7
- package/templates/.agents/rules/human-decision-context.zh-CN.md +9 -7
- package/templates/.agents/rules/{issue-fields.github.en.md → issue-fields.en.md} +1 -1
- package/templates/.agents/rules/{issue-fields.github.zh-CN.md → issue-fields.zh-CN.md} +1 -1
- package/templates/.agents/rules/issue-pr-commands.en.md +5 -18
- package/templates/.agents/rules/issue-pr-commands.zh-CN.md +1 -1
- package/templates/.agents/rules/issue-sync.en.md +26 -5
- package/templates/.agents/rules/issue-sync.zh-CN.md +62 -5
- package/templates/.agents/rules/label-milestone-setup.en.md +15 -2
- package/templates/.agents/rules/label-milestone-setup.zh-CN.md +15 -2
- package/templates/.agents/rules/local-artifact-repair.en.md +46 -0
- package/templates/.agents/rules/local-artifact-repair.zh-CN.md +46 -0
- package/templates/.agents/rules/milestone-inference.en.md +12 -2
- package/templates/.agents/rules/milestone-inference.zh-CN.md +25 -3
- package/templates/.agents/rules/next-step-output.en.md +3 -3
- package/templates/.agents/rules/next-step-output.zh-CN.md +3 -3
- package/templates/.agents/rules/no-mid-flow-questions.en.md +1 -1
- package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +1 -1
- package/templates/.agents/rules/pr-sync.en.md +23 -14
- package/templates/.agents/rules/pr-sync.zh-CN.md +23 -2
- package/templates/.agents/rules/release-commands.en.md +42 -3
- package/templates/.agents/rules/release-commands.zh-CN.md +42 -3
- package/templates/.agents/rules/review-handshake.en.md +1 -1
- package/templates/.agents/rules/review-handshake.zh-CN.md +1 -1
- package/templates/.agents/rules/security-alerts.en.md +17 -2
- package/templates/.agents/rules/security-alerts.zh-CN.md +17 -2
- package/templates/.agents/rules/sync-content-generation.en.md +8 -0
- package/templates/.agents/rules/sync-content-generation.zh-CN.md +8 -0
- package/templates/.agents/rules/task-management.en.md +2 -3
- package/templates/.agents/rules/task-management.zh-CN.md +2 -3
- package/templates/.agents/scripts/security-alerts.github.sh +151 -0
- package/templates/.agents/scripts/security-alerts.sh +31 -0
- package/templates/.agents/skills/analyze-task/SKILL.en.md +4 -3
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +4 -3
- package/templates/.agents/skills/block-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/cancel-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/check-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/check-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/close-codescan/SKILL.en.md +3 -3
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +3 -3
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/code-task/SKILL.en.md +8 -5
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +9 -6
- package/templates/.agents/skills/commit/SKILL.en.md +30 -10
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +6 -7
- package/templates/.agents/skills/commit/config/verify.json +1 -1
- package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +3 -3
- package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +3 -3
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +2 -2
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +2 -2
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +7 -6
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +7 -6
- package/templates/.agents/skills/complete-manual-validation/config/verify.en.json +1 -1
- package/templates/.agents/skills/complete-manual-validation/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +1 -1
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +1 -1
- package/templates/.agents/skills/complete-task/SKILL.en.md +13 -13
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +13 -13
- package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +2 -2
- package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +2 -2
- package/templates/.agents/skills/create-pr/SKILL.en.md +9 -11
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +9 -11
- package/templates/.agents/skills/create-pr/reference/change-report.en.md +9 -4
- package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +9 -4
- package/templates/.agents/skills/create-pr/scripts/change-report.mjs +203 -0
- package/templates/.agents/skills/create-release-note/SKILL.en.md +5 -6
- package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +5 -6
- package/templates/.agents/skills/create-task/SKILL.en.md +2 -1
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +2 -1
- package/templates/.agents/skills/import-codescan/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/import-issue/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/init-labels/SKILL.en.md +9 -10
- package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +9 -10
- package/templates/.agents/skills/init-labels/scripts/init-labels.github.sh +57 -1
- package/templates/.agents/skills/init-labels/scripts/init-labels.sh +27 -1
- package/templates/.agents/skills/init-milestones/SKILL.en.md +3 -5
- package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +3 -5
- package/templates/.agents/skills/plan-task/SKILL.en.md +4 -3
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +4 -3
- package/templates/.agents/skills/restore-task/SKILL.en.md +1 -1
- package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/review-analysis/SKILL.en.md +8 -5
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +8 -5
- package/templates/.agents/skills/review-analysis/config/verify.en.json +1 -0
- package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +18 -0
- package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +18 -0
- package/templates/.agents/skills/review-code/SKILL.en.md +11 -8
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +11 -8
- package/templates/.agents/skills/review-code/config/verify.en.json +1 -0
- package/templates/.agents/skills/review-code/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/review-code/reference/migration-risks.en.md +2 -1
- package/templates/.agents/skills/review-code/reference/migration-risks.zh-CN.md +2 -1
- package/templates/.agents/skills/review-code/reference/output-templates.en.md +19 -1
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +19 -1
- package/templates/.agents/skills/review-code/reference/report-template.en.md +4 -2
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +4 -2
- package/templates/.agents/skills/review-plan/SKILL.en.md +8 -5
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +8 -5
- package/templates/.agents/skills/review-plan/config/verify.en.json +1 -0
- package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/review-plan/reference/output-templates.en.md +18 -0
- package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +18 -0
- package/templates/.agents/skills/review-pr/SKILL.en.md +1 -0
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +1 -0
- package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +2 -2
- package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +2 -2
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +5 -0
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +5 -0
- package/templates/.agents/skills/run-task/SKILL.en.md +5 -1
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +5 -1
- package/templates/.agents/skills/update-agent-infra/SKILL.en.md +2 -2
- package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +144 -109
- package/templates/.agents/skills/watch-pr/SKILL.en.md +5 -5
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +5 -5
- package/templates/.agents/templates/task.en.md +6 -2
- package/templates/.agents/templates/task.zh-CN.md +6 -2
- package/templates/.agents/workflows/bug-fix.en.yaml +9 -8
- package/templates/.agents/workflows/bug-fix.zh-CN.yaml +9 -8
- package/templates/.agents/workflows/feature-development.en.yaml +9 -8
- package/templates/.agents/workflows/feature-development.zh-CN.yaml +9 -8
- package/templates/.agents/workflows/refactoring.en.yaml +9 -8
- package/templates/.agents/workflows/refactoring.zh-CN.yaml +9 -8
- package/templates/.claude/commands/analyze-task.en.md +1 -1
- package/templates/.claude/commands/analyze-task.zh-CN.md +1 -1
- package/templates/.claude/commands/block-task.en.md +1 -1
- package/templates/.claude/commands/block-task.zh-CN.md +1 -1
- package/templates/.claude/commands/cancel-task.en.md +1 -1
- package/templates/.claude/commands/cancel-task.zh-CN.md +1 -1
- package/templates/.claude/commands/check-task.en.md +1 -1
- package/templates/.claude/commands/check-task.zh-CN.md +1 -1
- package/templates/.claude/commands/code-task.en.md +1 -1
- package/templates/.claude/commands/code-task.zh-CN.md +1 -1
- package/templates/.claude/commands/commit.en.md +1 -1
- package/templates/.claude/commands/commit.zh-CN.md +1 -1
- package/templates/.claude/commands/complete-manual-validation.en.md +1 -1
- package/templates/.claude/commands/complete-manual-validation.zh-CN.md +1 -1
- package/templates/.claude/commands/complete-task.en.md +1 -1
- package/templates/.claude/commands/complete-task.zh-CN.md +1 -1
- package/templates/.claude/commands/create-pr.en.md +1 -1
- package/templates/.claude/commands/create-pr.zh-CN.md +1 -1
- package/templates/.claude/commands/plan-task.en.md +1 -1
- package/templates/.claude/commands/plan-task.zh-CN.md +1 -1
- package/templates/.claude/commands/review-analysis.en.md +1 -1
- package/templates/.claude/commands/review-analysis.zh-CN.md +1 -1
- package/templates/.claude/commands/review-code.en.md +1 -1
- package/templates/.claude/commands/review-code.zh-CN.md +1 -1
- package/templates/.claude/commands/review-plan.en.md +1 -1
- package/templates/.claude/commands/review-plan.zh-CN.md +1 -1
- package/templates/.claude/commands/run-manual-validation.en.md +1 -1
- package/templates/.claude/commands/run-manual-validation.zh-CN.md +1 -1
- package/templates/.claude/commands/run-task.en.md +1 -1
- package/templates/.claude/commands/run-task.zh-CN.md +1 -1
- package/templates/.claude/commands/watch-pr.en.md +1 -1
- package/templates/.claude/commands/watch-pr.zh-CN.md +1 -1
- package/templates/{.trae/skills → .traecli/commands}/update-agent-infra.en.md +0 -1
- package/templates/{.trae/skills → .traecli/commands}/update-agent-infra.zh-CN.md +0 -1
- package/dist/lib/builtin-tuis.js +0 -40
- package/lib/builtin-tuis.ts +0 -56
- package/templates/.agents/rules/create-issue.github.en.md +0 -14
- package/templates/.agents/rules/create-issue.github.zh-CN.md +0 -27
- package/templates/.agents/rules/issue-pr-commands.github.en.md +0 -34
- package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +0 -49
- package/templates/.agents/rules/issue-sync.github.en.md +0 -40
- package/templates/.agents/rules/issue-sync.github.zh-CN.md +0 -76
- package/templates/.agents/rules/label-milestone-setup.github.en.md +0 -60
- package/templates/.agents/rules/label-milestone-setup.github.zh-CN.md +0 -60
- package/templates/.agents/rules/milestone-inference.github.en.md +0 -15
- package/templates/.agents/rules/milestone-inference.github.zh-CN.md +0 -27
- package/templates/.agents/rules/pr-checks-commands.github.en.md +0 -18
- package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +0 -34
- package/templates/.agents/rules/pr-sync.github.en.md +0 -43
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +0 -69
- package/templates/.agents/rules/release-commands.github.en.md +0 -38
- package/templates/.agents/rules/release-commands.github.zh-CN.md +0 -38
- package/templates/.agents/rules/security-alerts.github.en.md +0 -43
- package/templates/.agents/rules/security-alerts.github.zh-CN.md +0 -43
|
@@ -10,14 +10,15 @@ const AGENT_CLIENTS_SCHEMA = {
|
|
|
10
10
|
maxItems: AGENT_CLIENT_IDS.length,
|
|
11
11
|
uniqueItems: true,
|
|
12
12
|
description: 'Canonical Agent Client configuration. Object ID completeness and uniqueness are enforced by the runtime normalizer.',
|
|
13
|
-
|
|
13
|
+
additionalItems: false,
|
|
14
|
+
items: AGENT_CLIENT_IDS.map((id) => ({
|
|
14
15
|
type: 'object',
|
|
15
16
|
additionalProperties: false,
|
|
16
17
|
required: ['id', 'enabled', 'installInSandbox'],
|
|
17
18
|
properties: {
|
|
18
19
|
id: {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const: id,
|
|
21
|
+
type: 'string'
|
|
21
22
|
},
|
|
22
23
|
enabled: {
|
|
23
24
|
type: 'boolean'
|
|
@@ -35,7 +36,7 @@ const AGENT_CLIENTS_SCHEMA = {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
}
|
|
39
|
+
}))
|
|
39
40
|
},
|
|
40
41
|
customTUIs: {
|
|
41
42
|
type: 'array',
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
// Active AI collaborator short tokens — the write-side whitelist for the
|
|
2
2
|
// activity log. Migrated from lib/task/commands/log.ts so that the write-side
|
|
3
|
-
// internal commands and the rendering side share one definition.
|
|
4
|
-
// Gemini tokens remain read-only and are handled by classifyAgent below.
|
|
3
|
+
// internal commands and the rendering side share one definition.
|
|
5
4
|
export const KNOWN_AI_AGENTS = new Set(['claude', 'codex', 'antigravity', 'opencode', 'cursor', 'traecli']);
|
|
6
|
-
// Long name -> short name mapping
|
|
7
|
-
//
|
|
8
|
-
// client. `gemini-cli` is intentionally not writable.
|
|
5
|
+
// Long name -> short name mapping: `claude-code` reuses the existing
|
|
6
|
+
// orchestration precedent, and `antigravity-cli` is the active client.
|
|
9
7
|
export const AGENT_LONG_NAMES = {
|
|
10
8
|
'claude-code': 'claude',
|
|
11
9
|
'antigravity-cli': 'antigravity'
|
|
12
10
|
};
|
|
13
11
|
export const AGENT_USAGE_HINT = "agent must be a short token (claude/codex/antigravity/opencode/cursor/traecli), " +
|
|
14
12
|
"a long name (claude-code -> claude, antigravity-cli -> antigravity), or 'human'";
|
|
15
|
-
// Read-side historical compatibility for activity-log rendering: `gemini` and
|
|
16
|
-
// `gemini-cli` stay recognizable when displaying old logs, but are never
|
|
17
|
-
// accepted by normalizeAgentToken (write side).
|
|
18
|
-
const READ_KNOWN_AI_AGENTS = new Set([...KNOWN_AI_AGENTS, 'gemini']);
|
|
19
|
-
const READ_AGENT_LONG_NAMES = {
|
|
20
|
-
...AGENT_LONG_NAMES,
|
|
21
|
-
'gemini-cli': 'gemini'
|
|
22
|
-
};
|
|
23
13
|
// Strict write-side validation: the value must be exactly a short token, a
|
|
24
14
|
// long name, or 'human'; returns the normalized short token, or null when
|
|
25
15
|
// the value is not a recognized agent.
|
|
@@ -41,9 +31,9 @@ export function classifyAgent(raw) {
|
|
|
41
31
|
return { status: 'unknown', display: 'human' };
|
|
42
32
|
if (token === 'human')
|
|
43
33
|
return { status: 'human', display: 'human' };
|
|
44
|
-
if (
|
|
34
|
+
if (KNOWN_AI_AGENTS.has(token))
|
|
45
35
|
return { status: 'ai', display: token };
|
|
46
|
-
const short =
|
|
36
|
+
const short = AGENT_LONG_NAMES[token];
|
|
47
37
|
return short ? { status: 'ai', display: short } : { status: 'unknown', display: 'human' };
|
|
48
38
|
}
|
|
49
39
|
//# sourceMappingURL=tokens.js.map
|
package/dist/lib/decide.js
CHANGED
|
@@ -3,7 +3,7 @@ import { parseTaskScope } from './task/command-options.js';
|
|
|
3
3
|
import { applyHumanDecision } from './task/decision-intents.js';
|
|
4
4
|
import { canonicalTimestamp } from './task/write.js';
|
|
5
5
|
import { consumeHumanOverride, failureId } from './task/human-override.js';
|
|
6
|
-
import {
|
|
6
|
+
import { resolveTaskContext } from './task/resolve-ref.js';
|
|
7
7
|
import { TaskExecutionLockError, withTaskExecutionLock } from './task/task-execution-lock.js';
|
|
8
8
|
function parseDecisionParts(parts) {
|
|
9
9
|
const decision = [];
|
|
@@ -66,47 +66,33 @@ export async function decide(args, options = {}) {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
else if (arg.startsWith('--item=')) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return 1;
|
|
72
|
-
}
|
|
73
|
-
item = arg.slice('--item='.length);
|
|
74
|
-
if (item === '') {
|
|
75
|
-
process.stderr.write('Error: --item requires a value\n');
|
|
76
|
-
return 1;
|
|
77
|
-
}
|
|
69
|
+
process.stderr.write('Error: --item=... is not supported; use --item <selector> or -i <selector>\n');
|
|
70
|
+
return 1;
|
|
78
71
|
}
|
|
79
72
|
else
|
|
80
73
|
operands.push(arg);
|
|
81
74
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (item !== undefined) {
|
|
86
|
-
decisionParts = operands;
|
|
87
|
-
}
|
|
88
|
-
else if (!scope.explicit) {
|
|
89
|
-
[taskRef, selector, ...decisionParts] = operands;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
decisionParts = [];
|
|
93
|
-
}
|
|
75
|
+
const taskRef = scope.taskRef;
|
|
76
|
+
const selector = item;
|
|
77
|
+
const decisionParts = operands;
|
|
94
78
|
if (!selector || decisionParts.length === 0) {
|
|
95
|
-
process.stderr.write('Usage: ai decide [--task <ref>] --item <ordinal|ledger-id>
|
|
79
|
+
process.stderr.write('Usage: ai decide [--task <ref> | -t <ref>] (--item <ordinal|ledger-id> | -i <ordinal|ledger-id>) [--needs-implementation true|false] <decision>\n');
|
|
96
80
|
return 1;
|
|
97
81
|
}
|
|
98
82
|
try {
|
|
99
83
|
const parsedDecision = parseDecisionParts(decisionParts);
|
|
100
84
|
const now = (options.now ?? canonicalTimestamp)();
|
|
85
|
+
const resolved = resolveTaskContext(taskRef, { repoRoot: options.repoRoot });
|
|
86
|
+
if (!resolved.ok)
|
|
87
|
+
throw new Error(resolved.message);
|
|
101
88
|
const request = {
|
|
102
|
-
taskRef, selector, decision: parsedDecision.decision,
|
|
89
|
+
taskRef: resolved.taskId, selector, decision: parsedDecision.decision,
|
|
103
90
|
needsImplementation: parsedDecision.needsImplementation
|
|
104
91
|
};
|
|
105
92
|
const writeOptions = {
|
|
106
|
-
repoRoot:
|
|
93
|
+
repoRoot: resolved.repoRoot,
|
|
107
94
|
metadataProvider: () => ({ timestamp: now, agentInfraVersion: options.version ?? VERSION })
|
|
108
95
|
};
|
|
109
|
-
const resolved = taskRef ? resolveTaskRef(taskRef, { repoRoot: options.repoRoot }) : null;
|
|
110
96
|
let result;
|
|
111
97
|
const execute = () => {
|
|
112
98
|
let current = applyHumanDecision(request, writeOptions);
|
|
@@ -115,7 +101,7 @@ export async function decide(args, options = {}) {
|
|
|
115
101
|
if (!parsedDecision.overrideTarget || !parsedDecision.overrideScope)
|
|
116
102
|
throw new Error('override ticket requires --override-target and --override-scope');
|
|
117
103
|
const consumed = consumeHumanOverride({
|
|
118
|
-
taskRef: resolved
|
|
104
|
+
taskRef: resolved.taskId,
|
|
119
105
|
ticketId: parsedDecision.overrideTicket,
|
|
120
106
|
failureId: failureId('decision-intent', current.error?.code ?? 'TASK_STATE_MISMATCH'),
|
|
121
107
|
target: parsedDecision.overrideTarget,
|
|
@@ -134,9 +120,7 @@ export async function decide(args, options = {}) {
|
|
|
134
120
|
throw new Error(consumed.error.message);
|
|
135
121
|
return current;
|
|
136
122
|
};
|
|
137
|
-
result = resolved
|
|
138
|
-
? withTaskExecutionLock(resolved.repoRoot, resolved.taskId, 'task-decision', execute)
|
|
139
|
-
: execute();
|
|
123
|
+
result = withTaskExecutionLock(resolved.repoRoot, resolved.taskId, 'task-decision', execute);
|
|
140
124
|
if (result.error)
|
|
141
125
|
throw new Error(result.error.message);
|
|
142
126
|
return 0;
|
package/dist/lib/defaults.json
CHANGED
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
"task": {
|
|
49
49
|
"shortIdLength": 2
|
|
50
50
|
},
|
|
51
|
+
"delivery": {
|
|
52
|
+
"remote": "origin",
|
|
53
|
+
"baseRef": "main"
|
|
54
|
+
},
|
|
51
55
|
"labels": {
|
|
52
56
|
"in": {}
|
|
53
57
|
},
|
|
@@ -90,6 +94,10 @@
|
|
|
90
94
|
],
|
|
91
95
|
"ejected": [],
|
|
92
96
|
"retiredManaged": [
|
|
97
|
+
{
|
|
98
|
+
"path": ".trae/skills/",
|
|
99
|
+
"templateHashes": []
|
|
100
|
+
},
|
|
93
101
|
{
|
|
94
102
|
"path": ".agents/workspace/README.md",
|
|
95
103
|
"templateHashes": [
|
package/dist/lib/git/workflow.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
const defaultRunner = (args, cwd) => {
|
|
5
6
|
const result = spawnSync('git', [...args], { cwd, encoding: 'utf8' });
|
|
@@ -108,6 +109,47 @@ function commitExplicitPaths(input, runner = defaultRunner) {
|
|
|
108
109
|
return { status: 'failed', changed: false, snapshot: after.snapshot, operations: [{ name: 'commit', status: 'failed', message: commit.stderr.trim() }], error: { code: 'GIT_COMMIT_FAILED', message: commit.stderr.trim() } };
|
|
109
110
|
return { status: 'applied', changed: true, snapshot: after.snapshot, operations: [{ name: 'stage', status: 'applied' }, { name: 'commit', status: 'applied' }], error: null };
|
|
110
111
|
}
|
|
112
|
+
function previewCommitTree(input) {
|
|
113
|
+
const invalid = validatePaths(input.paths);
|
|
114
|
+
if (invalid)
|
|
115
|
+
return { status: 'failed', tree: null, error: { code: 'GIT_COMMIT_INPUT_INVALID', message: invalid } };
|
|
116
|
+
const before = inspectGitWorkflow(input.cwd);
|
|
117
|
+
if (!before.snapshot)
|
|
118
|
+
return { status: 'failed', tree: null, error: { code: 'GIT_INSPECT_FAILED', message: 'Unable to inspect Git repository' } };
|
|
119
|
+
if (before.snapshot.head !== input.expectedHead) {
|
|
120
|
+
return { status: 'failed', tree: null, error: { code: 'GIT_HEAD_MISMATCH', message: `Expected HEAD ${input.expectedHead}, received ${before.snapshot.head}` } };
|
|
121
|
+
}
|
|
122
|
+
const selected = new Set(input.paths);
|
|
123
|
+
const unrelatedStaged = before.snapshot.staged.filter((candidate) => !selected.has(candidate));
|
|
124
|
+
if (unrelatedStaged.length > 0) {
|
|
125
|
+
return { status: 'failed', tree: null, error: { code: 'GIT_STAGED_SCOPE_MISMATCH', message: `Unrelated staged paths: ${unrelatedStaged.join(', ')}` } };
|
|
126
|
+
}
|
|
127
|
+
const temporaryDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-infra-preview-index-'));
|
|
128
|
+
const indexFile = path.join(temporaryDirectory, 'index');
|
|
129
|
+
const temporaryRunner = (args, cwd) => {
|
|
130
|
+
const result = spawnSync('git', [...args], {
|
|
131
|
+
cwd,
|
|
132
|
+
env: { ...process.env, GIT_INDEX_FILE: indexFile },
|
|
133
|
+
encoding: 'utf8'
|
|
134
|
+
});
|
|
135
|
+
return { status: result.status, stdout: result.stdout ?? '', stderr: result.stderr ?? '' };
|
|
136
|
+
};
|
|
137
|
+
try {
|
|
138
|
+
const read = run(temporaryRunner, input.cwd, ['read-tree', input.expectedHead]);
|
|
139
|
+
if (read.status !== 0)
|
|
140
|
+
return { status: 'failed', tree: null, error: { code: 'GIT_PREVIEW_FAILED', message: read.stderr.trim() || 'Unable to prepare a temporary Git index' } };
|
|
141
|
+
const stage = run(temporaryRunner, input.cwd, ['add', '-A', '--', ...input.paths]);
|
|
142
|
+
if (stage.status !== 0)
|
|
143
|
+
return { status: 'failed', tree: null, error: { code: 'GIT_PREVIEW_FAILED', message: stage.stderr.trim() || 'Unable to stage the requested paths in a temporary index' } };
|
|
144
|
+
const tree = value(temporaryRunner, input.cwd, ['write-tree']);
|
|
145
|
+
if (!tree)
|
|
146
|
+
return { status: 'failed', tree: null, error: { code: 'GIT_PREVIEW_FAILED', message: 'Unable to write the temporary Git tree' } };
|
|
147
|
+
return { status: 'planned', tree, error: null };
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
fs.rmSync(temporaryDirectory, { recursive: true, force: true });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
111
153
|
function pushGitRefs(input, runner = defaultRunner) {
|
|
112
154
|
if (!input.remote || input.refs.length === 0)
|
|
113
155
|
return { status: 'failed', changed: false, snapshot: inspectGitWorkflow(input.cwd, runner).snapshot, operations: [], error: { code: 'GIT_PUSH_INPUT_INVALID', message: 'Remote and refs are required' } };
|
|
@@ -185,5 +227,5 @@ function pushRebasedBranch(input, runner = defaultRunner) {
|
|
|
185
227
|
}
|
|
186
228
|
return { status: 'applied', changed: true, snapshot: inspectGitWorkflow(input.cwd, runner).snapshot, operations: [{ name: 'push-rebased', status: 'applied', ref: input.branch }], error: null };
|
|
187
229
|
}
|
|
188
|
-
export { commitExplicitPaths, inspectGitWorkflow, pushGitRefs, pushRebasedBranch };
|
|
230
|
+
export { commitExplicitPaths, inspectGitWorkflow, previewCommitTree, pushGitRefs, pushRebasedBranch };
|
|
189
231
|
//# sourceMappingURL=workflow.js.map
|
package/dist/lib/init.js
CHANGED
|
@@ -71,7 +71,7 @@ async function cmdInit() {
|
|
|
71
71
|
// check existing config
|
|
72
72
|
if (fs.existsSync(configPath)) {
|
|
73
73
|
err('This project already has agent-infra configuration.');
|
|
74
|
-
err('Use /update-agent-infra in your AI TUI to
|
|
74
|
+
err('Use /update-agent-infra in your AI TUI to sync project files.');
|
|
75
75
|
process.exitCode = 1;
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
@@ -175,6 +175,7 @@ async function cmdInit() {
|
|
|
175
175
|
templateVersion: VERSION,
|
|
176
176
|
sandbox: structuredClone(defaults.sandbox),
|
|
177
177
|
task: structuredClone(defaults.task),
|
|
178
|
+
delivery: structuredClone(defaults.delivery),
|
|
178
179
|
labels: structuredClone(defaults.labels),
|
|
179
180
|
files: { managed: [], merged: [], ejected: [] },
|
|
180
181
|
agentClients: serializeAgentClients(defaultState)
|
|
@@ -214,7 +215,7 @@ async function cmdInit() {
|
|
|
214
215
|
console.log('');
|
|
215
216
|
ok('Project initialized successfully!');
|
|
216
217
|
console.log('');
|
|
217
|
-
console.log(' If this init used npx, install agent-infra persistently before update or validation:');
|
|
218
|
+
console.log(' If this init used npx, install agent-infra persistently before ai update or validation:');
|
|
218
219
|
console.log(' npm install -g @fitlab-ai/agent-infra');
|
|
219
220
|
console.log('');
|
|
220
221
|
if (workflowPlan.nextSteps.length === 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
-
import { inspectGitWorkflow, pushRebasedBranch } from '../git/workflow.js';
|
|
2
|
+
import { inspectGitWorkflow, previewCommitTree, pushRebasedBranch } from '../git/workflow.js';
|
|
3
3
|
import { compareReviewTrees, snapshotReview } from '../git/review-snapshot.js';
|
|
4
4
|
import { resolvePostReviewGlobs } from '../task/review-fingerprint.js';
|
|
5
5
|
import { executeCommitOperation } from '../task/commit-operation.js';
|
|
@@ -26,6 +26,13 @@ function gitWorkflow(args = []) {
|
|
|
26
26
|
const input = inputIndex >= 0 && rest[inputIndex + 1] ? JSON.parse(fs.readFileSync(rest[inputIndex + 1], 'utf8')) : null;
|
|
27
27
|
result = input ? pushRebasedBranch({ cwd: cwd ?? process.cwd(), ...input }) : { status: 'failed', changed: false, error: { code: 'GIT_INPUT_REQUIRED', message: '--input JSON file is required' } };
|
|
28
28
|
}
|
|
29
|
+
else if (action === 'preview-tree') {
|
|
30
|
+
const inputIndex = rest.indexOf('--input');
|
|
31
|
+
const input = inputIndex >= 0 && rest[inputIndex + 1] ? JSON.parse(fs.readFileSync(rest[inputIndex + 1], 'utf8')) : null;
|
|
32
|
+
result = input
|
|
33
|
+
? previewCommitTree({ cwd: cwd ?? process.cwd(), paths: input.paths, expectedHead: input.expectedHead })
|
|
34
|
+
: { status: 'failed', changed: false, error: { code: 'GIT_INPUT_REQUIRED', message: '--input JSON file is required' } };
|
|
35
|
+
}
|
|
29
36
|
else if (action === 'snapshot' || action === 'compare-trees') {
|
|
30
37
|
const inputIndex = rest.indexOf('--input');
|
|
31
38
|
const input = inputIndex >= 0 && rest[inputIndex + 1] ? JSON.parse(fs.readFileSync(rest[inputIndex + 1], 'utf8')) : null;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { normalizeAgentToken, AGENT_USAGE_HINT } from '../agent-clients/tokens.js';
|
|
4
|
-
import { bindPlatformPullRequest, createPlatformPullRequest, inspectPlatformPullRequest, resolveExternalPullRequest, syncPlatformPullRequest } from '../platform/pull-requests.js';
|
|
4
|
+
import { bindPlatformPullRequest, createPlatformPullRequest, inspectPlatformPullRequest, resolveExternalPullRequest, skipPlatformPullRequestFact, syncPlatformPullRequest } from '../platform/pull-requests.js';
|
|
5
5
|
import { summaryContext, syncPullRequestSummary } from '../platform/pr-summary.js';
|
|
6
6
|
const USAGE = `Usage: agent-infra-internal platform-pr inspect <task-ref> [--cwd <path>]
|
|
7
7
|
agent-infra-internal platform-pr resolve-external <task-ref> --agent <agent> [--pr <N>] [--dry-run] [--cwd <path>]
|
|
8
8
|
agent-infra-internal platform-pr create <task-ref> --agent <agent> --base <branch> --head <branch> --title-file <path|-> --body-file <path|-> [--draft] [--dry-run] [--cwd <path>]
|
|
9
9
|
agent-infra-internal platform-pr bind <task-ref> --pr <N> --agent <agent> [--dry-run] [--cwd <path>]
|
|
10
|
+
agent-infra-internal platform-pr skip <task-ref> --agent <agent> [--dry-run] [--cwd <path>]
|
|
10
11
|
agent-infra-internal platform-pr sync <task-ref> --agent <agent> [--metadata] [--closing-issue] --result <pr_created|pr_reused|no_op> [--dry-run] [--cwd <path>]
|
|
11
12
|
agent-infra-internal platform-pr summary-context <task-ref> [--cwd <path>]
|
|
12
13
|
agent-infra-internal platform-pr summary-sync <task-ref> --agent <agent> --body-file <path|-> --result <pr_created|pr_reused|no_op> [--dry-run] [--cwd <path>]
|
|
@@ -58,7 +59,7 @@ function platformPr(args = []) {
|
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
61
|
const operation = args[0];
|
|
61
|
-
if (!operation || !['inspect', 'resolve-external', 'create', 'bind', 'sync', 'summary-context', 'summary-sync'].includes(operation)) {
|
|
62
|
+
if (!operation || !['inspect', 'resolve-external', 'create', 'bind', 'skip', 'sync', 'summary-context', 'summary-sync'].includes(operation)) {
|
|
62
63
|
fail('a valid operation is required');
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
@@ -79,6 +80,7 @@ function platformPr(args = []) {
|
|
|
79
80
|
'resolve-external': ['cwd', 'agent', 'pr', 'dryRun'],
|
|
80
81
|
create: ['cwd', 'agent', 'base', 'head', 'titleFile', 'bodyFile', 'draft', 'dryRun'],
|
|
81
82
|
bind: ['cwd', 'agent', 'pr', 'dryRun'],
|
|
83
|
+
skip: ['cwd', 'agent', 'dryRun'],
|
|
82
84
|
sync: ['cwd', 'agent', 'metadata', 'closingIssue', 'result', 'dryRun'],
|
|
83
85
|
'summary-context': ['cwd'],
|
|
84
86
|
'summary-sync': ['cwd', 'agent', 'bodyFile', 'result', 'dryRun']
|
|
@@ -106,6 +108,10 @@ function platformPr(args = []) {
|
|
|
106
108
|
return;
|
|
107
109
|
}
|
|
108
110
|
values.agent = agent;
|
|
111
|
+
if (operation === 'skip') {
|
|
112
|
+
finish(skipPlatformPullRequestFact(taskRef, { cwd, agent, dryRun: values.dryRun === true }));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
109
115
|
const primaryResult = values.result === undefined ? undefined : values.result;
|
|
110
116
|
if (primaryResult !== undefined && !['pr_created', 'pr_reused', 'no_op'].includes(primaryResult)) {
|
|
111
117
|
fail('--result must be pr_created, pr_reused, or no_op');
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { normalizeAgentToken, AGENT_USAGE_HINT } from '../agent-clients/tokens.js';
|
|
3
|
+
import { deliverTaskBranch } from '../task/delivery.js';
|
|
4
|
+
const USAGE = `Usage: agent-infra-internal task-delivery <task-ref> deliver --agent <agent> [--remote <name>] [--base <branch>] [--dry-run] [--cwd <path>]\n`;
|
|
5
|
+
function taskDelivery(args = []) {
|
|
6
|
+
const taskRef = args[0];
|
|
7
|
+
const operation = args[1];
|
|
8
|
+
if (!taskRef || operation !== 'deliver') {
|
|
9
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'DELIVERY_PAYLOAD_INVALID', message: 'task ref and deliver operation are required' } })}\n`);
|
|
10
|
+
process.stderr.write(USAGE);
|
|
11
|
+
process.exitCode = 1;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
let agent = '';
|
|
15
|
+
let remote;
|
|
16
|
+
let baseRef;
|
|
17
|
+
let cwd = process.cwd();
|
|
18
|
+
let dryRun = false;
|
|
19
|
+
for (let index = 2; index < args.length; index += 1) {
|
|
20
|
+
const flag = args[index];
|
|
21
|
+
if (flag === '--dry-run') {
|
|
22
|
+
dryRun = true;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const value = args[++index];
|
|
26
|
+
if (value === undefined || value.startsWith('--')) {
|
|
27
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'DELIVERY_PAYLOAD_INVALID', message: `${flag} requires a value` } })}\n`);
|
|
28
|
+
process.exitCode = 1;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (flag === '--agent')
|
|
32
|
+
agent = value;
|
|
33
|
+
else if (flag === '--remote')
|
|
34
|
+
remote = value;
|
|
35
|
+
else if (flag === '--base')
|
|
36
|
+
baseRef = value;
|
|
37
|
+
else if (flag === '--cwd')
|
|
38
|
+
cwd = path.resolve(value);
|
|
39
|
+
else {
|
|
40
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'DELIVERY_PAYLOAD_INVALID', message: `unknown option '${flag}'` } })}\n`);
|
|
41
|
+
process.exitCode = 1;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const normalized = normalizeAgentToken(agent);
|
|
46
|
+
if (!normalized) {
|
|
47
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'DELIVERY_PAYLOAD_INVALID', message: `invalid --agent '${agent}': ${AGENT_USAGE_HINT}` } })}\n`);
|
|
48
|
+
process.exitCode = 1;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const result = deliverTaskBranch(taskRef, { repoRoot: cwd, agent: normalized, remote, baseRef, dryRun });
|
|
52
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
53
|
+
if (result.status === 'failed')
|
|
54
|
+
process.exitCode = 1;
|
|
55
|
+
if (result.status === 'blocked')
|
|
56
|
+
process.exitCode = 2;
|
|
57
|
+
}
|
|
58
|
+
export { taskDelivery };
|
|
59
|
+
//# sourceMappingURL=task-delivery.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createDirectHostExecutionContext, dispatchTaskControlOperation, parseTaskControlOperation } from '../task/control-authority.js';
|
|
2
2
|
import { applyTaskFinalization } from '../task/finalization.js';
|
|
3
3
|
import { detectRepoRoot, resolveTaskRef } from '../task/resolve-ref.js';
|
|
4
|
-
import { verifyTaskEvent } from '../task/verification.js';
|
|
5
4
|
const USAGE = 'Usage: agent-infra-internal task-finalization <N | TASK-id> complete --agent <agent>\n';
|
|
6
5
|
function envelope(status, changed, accepted, result, error) {
|
|
7
6
|
return `${JSON.stringify({ version: 1, status, changed, accepted, result, error })}\n`;
|
|
@@ -15,18 +14,25 @@ function fail(message) {
|
|
|
15
14
|
process.stderr.write(USAGE);
|
|
16
15
|
process.exitCode = 1;
|
|
17
16
|
}
|
|
17
|
+
function parseFailure(error) {
|
|
18
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
19
|
+
return message.replace(/^TASK_CONTROL_OPERATION_INVALID: /u, '');
|
|
20
|
+
}
|
|
18
21
|
function taskFinalization(args = []) {
|
|
19
22
|
if (args[0] === '--help' || args[0] === '-h') {
|
|
20
23
|
process.stdout.write(USAGE);
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
let operation;
|
|
27
|
+
try {
|
|
28
|
+
operation = parseTaskControlOperation('task-finalization', args);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
fail(parseFailure(error));
|
|
25
32
|
return;
|
|
26
33
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
fail(`invalid --agent: ${AGENT_USAGE_HINT}`);
|
|
34
|
+
if (operation.family !== 'task-finalization') {
|
|
35
|
+
fail('finalization operation is invalid');
|
|
30
36
|
return;
|
|
31
37
|
}
|
|
32
38
|
let repoRoot;
|
|
@@ -39,14 +45,18 @@ function taskFinalization(args = []) {
|
|
|
39
45
|
process.exitCode = 1;
|
|
40
46
|
return;
|
|
41
47
|
}
|
|
42
|
-
const resolved = resolveTaskRef(
|
|
48
|
+
const resolved = resolveTaskRef(operation.request.taskRef, { repoRoot });
|
|
43
49
|
if (!resolved.ok) {
|
|
44
50
|
const detail = { code: resolved.code, message: resolved.message, retryable: false };
|
|
45
51
|
process.stdout.write(envelope('failed', false, true, null, detail));
|
|
46
52
|
process.exitCode = 1;
|
|
47
53
|
return;
|
|
48
54
|
}
|
|
49
|
-
const
|
|
55
|
+
const boundOperation = {
|
|
56
|
+
...operation,
|
|
57
|
+
request: { ...operation.request, taskRef: resolved.taskId }
|
|
58
|
+
};
|
|
59
|
+
const result = dispatchTaskControlOperation(createDirectHostExecutionContext({ repoRoot }), boundOperation);
|
|
50
60
|
process.stdout.write(envelope(result.status, result.changed, true, result, result.error));
|
|
51
61
|
process.exitCode = exitCode(result.status);
|
|
52
62
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { applyLedgerIntent } from '../task/ledger-intents.js';
|
|
3
3
|
import { consumeHumanOverride, failureId, overrideDryRunConflict } from '../task/human-override.js';
|
|
4
|
-
import { isReviewStage,
|
|
4
|
+
import { LEDGER_SECTION_MISSING_CODE, LEDGER_SECTION_MISSING_MESSAGE, isReviewStage, parseLedgerDocument, summarizeLedgerStage, validateLedgerRows } from '../task/ledger.js';
|
|
5
5
|
import { resolveTaskRef } from '../task/resolve-ref.js';
|
|
6
6
|
import { TaskExecutionLockError, withTaskExecutionLock } from '../task/task-execution-lock.js';
|
|
7
7
|
const USAGE = `Usage: agent-infra-internal task-ledger <task-ref> <intent> [intent flags] [--dry-run]\n\nIntents: finding-upsert, finding-respond, finding-review, decision-next-id, decision-upsert, stage-status\n`;
|
|
@@ -110,7 +110,13 @@ function taskLedger(args = []) {
|
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
try {
|
|
113
|
-
const
|
|
113
|
+
const ledger = parseLedgerDocument(fs.readFileSync(resolved.taskMdPath, 'utf8'));
|
|
114
|
+
if (!ledger.present) {
|
|
115
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, taskId: resolved.taskId, error: { code: LEDGER_SECTION_MISSING_CODE, message: LEDGER_SECTION_MISSING_MESSAGE } })}\n`);
|
|
116
|
+
process.exitCode = 1;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const rows = ledger.rows;
|
|
114
120
|
const invalid = validateLedgerRows(rows);
|
|
115
121
|
if (invalid) {
|
|
116
122
|
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, taskId: resolved.taskId, error: invalid })}\n`);
|
|
@@ -1,76 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { applyTaskLifecycle, lifecycleIntentCatalog } from '../task/lifecycle.js';
|
|
1
|
+
import { createDirectHostExecutionContext, dispatchTaskControlOperation, parseTaskControlOperation } from '../task/control-authority.js';
|
|
2
|
+
import { lifecycleIntentCatalog } from '../task/lifecycle.js';
|
|
4
3
|
import { detectRepoRoot, resolveTaskRef } from '../task/resolve-ref.js';
|
|
5
|
-
import { TaskExecutionLockError, withTaskExecutionLock } from '../task/task-execution-lock.js';
|
|
6
4
|
const USAGE = `Usage: agent-infra-internal task-lifecycle <N | TASK-id> <intent> --agent <agent> [intent flags] [--dry-run]\n\nIntents: ${lifecycleIntentCatalog.join(', ')}\nOverride: --override-ticket <ticket> --override-target <target> --override-scope <scope>\n`;
|
|
7
|
-
const FLAGS = {
|
|
8
|
-
'--agent': 'agent', '--reason': 'reason', '--unblock-condition': 'unblockCondition',
|
|
9
|
-
'--note': 'note', '--alert-number': 'alertNumber', '--staging-dir': 'stagingDir',
|
|
10
|
-
'--issue-number': 'issueNumber', '--override-ticket': 'overrideTicket',
|
|
11
|
-
'--override-target': 'overrideTarget', '--override-scope': 'overrideScope'
|
|
12
|
-
};
|
|
13
5
|
function usageFailure(message) {
|
|
14
6
|
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'LIFECYCLE_PAYLOAD_INVALID', message } })}\n`);
|
|
15
7
|
process.stderr.write(USAGE);
|
|
16
8
|
process.exitCode = 1;
|
|
17
9
|
}
|
|
10
|
+
function parseFailure(error) {
|
|
11
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
12
|
+
return message.replace(/^TASK_CONTROL_OPERATION_INVALID: /u, '');
|
|
13
|
+
}
|
|
18
14
|
function taskLifecycle(args = []) {
|
|
19
15
|
if (args[0] === '--help' || args[0] === '-h') {
|
|
20
16
|
process.stdout.write(USAGE);
|
|
21
17
|
return;
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
const values = { taskRef: args[0], intent: args[1], agent: '' };
|
|
28
|
-
const seen = new Set();
|
|
29
|
-
for (let index = 2; index < args.length; index += 1) {
|
|
30
|
-
const flag = args[index];
|
|
31
|
-
if (flag === '--dry-run') {
|
|
32
|
-
if (seen.has(flag)) {
|
|
33
|
-
usageFailure(`duplicate option '${flag}'`);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
seen.add(flag);
|
|
37
|
-
values.dryRun = true;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
const key = FLAGS[flag];
|
|
41
|
-
if (!key) {
|
|
42
|
-
usageFailure(`unknown option '${flag}'`);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (seen.has(flag)) {
|
|
46
|
-
usageFailure(`duplicate option '${flag}'`);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const value = args[++index];
|
|
50
|
-
if (value === undefined || value.startsWith('--')) {
|
|
51
|
-
usageFailure(`option '${flag}' requires a value`);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
seen.add(flag);
|
|
55
|
-
values[key] = key === 'alertNumber' || key === 'issueNumber' ? Number(value) : value;
|
|
19
|
+
let operation;
|
|
20
|
+
try {
|
|
21
|
+
operation = parseTaskControlOperation('task-lifecycle', args);
|
|
56
22
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
usageFailure(`invalid --agent '${values.agent}': ${AGENT_USAGE_HINT}`);
|
|
23
|
+
catch (error) {
|
|
24
|
+
usageFailure(parseFailure(error));
|
|
60
25
|
return;
|
|
61
26
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (dryRunConflict) {
|
|
65
|
-
usageFailure(dryRunConflict.message);
|
|
27
|
+
if (operation.family !== 'task-lifecycle') {
|
|
28
|
+
usageFailure('lifecycle operation is invalid');
|
|
66
29
|
return;
|
|
67
30
|
}
|
|
31
|
+
const request = operation.request;
|
|
68
32
|
let repoRoot;
|
|
69
|
-
|
|
70
|
-
if (values.intent === 'restore') {
|
|
71
|
-
// restore's precondition is that the task does NOT exist locally yet (it only lives
|
|
72
|
-
// in a staging dir), so resolveTaskRef's existence check is inapplicable here; identity
|
|
73
|
-
// is guaranteed by applyTaskLifecycle's own full-TASK-id check plus staging validation.
|
|
33
|
+
if (request.intent === 'restore') {
|
|
74
34
|
try {
|
|
75
35
|
repoRoot = detectRepoRoot();
|
|
76
36
|
}
|
|
@@ -79,53 +39,17 @@ function taskLifecycle(args = []) {
|
|
|
79
39
|
process.exitCode = 1;
|
|
80
40
|
return;
|
|
81
41
|
}
|
|
82
|
-
taskId = String(values.taskRef);
|
|
83
42
|
}
|
|
84
43
|
else {
|
|
85
|
-
const resolved = resolveTaskRef(
|
|
44
|
+
const resolved = resolveTaskRef(request.taskRef);
|
|
86
45
|
if (!resolved.ok) {
|
|
87
46
|
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: resolved.code, message: resolved.message } })}\n`);
|
|
88
47
|
process.exitCode = 1;
|
|
89
48
|
return;
|
|
90
49
|
}
|
|
91
50
|
repoRoot = resolved.repoRoot;
|
|
92
|
-
taskId = resolved.taskId;
|
|
93
|
-
}
|
|
94
|
-
let result;
|
|
95
|
-
try {
|
|
96
|
-
result = withTaskExecutionLock(repoRoot, taskId, `task-lifecycle.${String(values.intent)}`, () => {
|
|
97
|
-
const lifecycleResult = applyTaskLifecycle(values);
|
|
98
|
-
if (lifecycleResult.status !== 'failed' || !values.overrideTicket)
|
|
99
|
-
return lifecycleResult;
|
|
100
|
-
if (!values.overrideTarget || !values.overrideScope) {
|
|
101
|
-
return {
|
|
102
|
-
...lifecycleResult,
|
|
103
|
-
error: { code: 'OVERRIDE_PAYLOAD_INVALID', message: 'override ticket requires --override-target and --override-scope' }
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
const override = consumeHumanOverride({
|
|
107
|
-
taskRef: String(values.taskRef),
|
|
108
|
-
ticketId: String(values.overrideTicket),
|
|
109
|
-
failureId: failureId('lifecycle.apply', lifecycleResult.error?.code ?? 'LIFECYCLE_FAILED'),
|
|
110
|
-
target: String(values.overrideTarget),
|
|
111
|
-
scope: String(values.overrideScope),
|
|
112
|
-
intent: String(values.intent),
|
|
113
|
-
...(values.alertNumber ? { alertNumber: Number(values.alertNumber) } : {}),
|
|
114
|
-
...(values.issueNumber ? { issueNumber: Number(values.issueNumber) } : {}),
|
|
115
|
-
...(values.stagingDir ? { stagingDir: String(values.stagingDir) } : {})
|
|
116
|
-
});
|
|
117
|
-
if (override.status === 'failed')
|
|
118
|
-
return { ...lifecycleResult, humanOverride: override };
|
|
119
|
-
return { ...lifecycleResult, ...override, humanOverride: override, error: null };
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
if (!(error instanceof TaskExecutionLockError))
|
|
124
|
-
throw error;
|
|
125
|
-
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: error.code, message: error.message } })}\n`);
|
|
126
|
-
process.exitCode = 1;
|
|
127
|
-
return;
|
|
128
51
|
}
|
|
52
|
+
const result = dispatchTaskControlOperation(createDirectHostExecutionContext({ repoRoot }), operation);
|
|
129
53
|
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
130
54
|
if (result.status === 'failed')
|
|
131
55
|
process.exitCode = 1;
|