@fitlab-ai/agent-infra 0.8.5 → 0.9.1
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 +6 -1
- package/README.zh-CN.md +5 -1
- package/bin/cli.ts +2 -2
- package/dist/bin/cli.js +2 -2
- package/dist/bin/internal-cli.js +103 -0
- package/dist/lib/decide.js +81 -90
- package/dist/lib/defaults.json +1 -0
- package/dist/lib/git/review-snapshot.js +79 -0
- package/dist/lib/git/workflow.js +101 -0
- package/dist/lib/internal/git-workflow.js +42 -0
- package/dist/lib/internal/platform-checks.js +119 -0
- package/dist/lib/internal/platform-comment.js +129 -0
- package/dist/lib/internal/platform-context.js +46 -0
- package/dist/lib/internal/platform-issue.js +142 -0
- package/dist/lib/internal/platform-pr.js +146 -0
- package/dist/lib/internal/platform-release-notes.js +53 -0
- package/dist/lib/internal/release-workflow.js +320 -0
- package/dist/lib/internal/task-artifact.js +67 -0
- package/dist/lib/internal/task-context.js +43 -0
- package/dist/lib/internal/task-event.js +70 -0
- package/dist/lib/internal/task-ledger.js +114 -0
- package/dist/lib/internal/task-lifecycle.js +58 -0
- package/dist/lib/internal/task-short-id.js +83 -0
- package/dist/lib/internal/task-snapshot.js +47 -0
- package/dist/lib/internal/task-verify.js +50 -0
- package/dist/lib/internal/task-warning.js +74 -0
- package/dist/lib/platform/adapters.js +14 -0
- package/dist/lib/platform/context.js +146 -0
- package/dist/lib/platform/github-client.js +124 -0
- package/dist/lib/platform/github-release-notes.js +96 -0
- package/dist/lib/platform/issue-comments.js +409 -0
- package/dist/lib/platform/issue-metadata.js +183 -0
- package/dist/lib/platform/issues.js +619 -0
- package/dist/lib/platform/merged-pr-equivalence.js +54 -0
- package/dist/lib/platform/metadata-labels.js +28 -0
- package/dist/lib/platform/pr-checks.js +216 -0
- package/dist/lib/platform/pr-summary.js +88 -0
- package/dist/lib/platform/pull-request-metadata.js +38 -0
- package/dist/lib/platform/pull-requests.js +340 -0
- package/dist/lib/platform/release-notes.js +143 -0
- package/dist/lib/platform/releases.js +82 -0
- package/dist/lib/platform/types.js +22 -0
- package/dist/lib/platform/verification-required.js +102 -0
- package/dist/lib/platform/verification-sync.js +1014 -0
- package/dist/lib/platform/verification.js +6 -0
- package/dist/lib/release/channels.js +31 -0
- package/dist/lib/release/workflow.js +32 -0
- package/dist/lib/render.js +3 -2
- package/dist/lib/run/index.js +24 -7
- package/dist/lib/sandbox/build-proxy.js +63 -0
- package/dist/lib/sandbox/capture.js +25 -3
- package/dist/lib/sandbox/commands/create.js +93 -31
- package/dist/lib/sandbox/commands/enter.js +34 -11
- package/dist/lib/sandbox/commands/list-running.js +10 -8
- package/dist/lib/sandbox/commands/rebuild.js +24 -7
- package/dist/lib/sandbox/commands/show.js +2 -2
- package/dist/lib/sandbox/commands/start.js +53 -15
- package/dist/lib/sandbox/image-build.js +2 -1
- package/dist/lib/sandbox/index.js +6 -6
- package/dist/lib/sandbox/mounts.js +36 -0
- package/dist/lib/sandbox/recovery.js +562 -0
- package/dist/lib/sandbox/runtimes/ai-tools.dockerfile +24 -3
- package/dist/lib/sandbox/runtimes/base.dockerfile +8 -1
- package/dist/lib/sandbox/runtimes/java17.dockerfile +8 -1
- package/dist/lib/sandbox/runtimes/java21.dockerfile +8 -1
- package/dist/lib/sandbox/runtimes/node20.dockerfile +8 -1
- package/dist/lib/sandbox/runtimes/node22.dockerfile +8 -1
- package/dist/lib/sandbox/runtimes/python3.dockerfile +8 -1
- package/dist/lib/sandbox/shell.js +2 -1
- package/dist/lib/sandbox/task-resolver.js +5 -1
- package/dist/lib/sandbox/tools.js +19 -0
- package/dist/lib/server/protocol.js +5 -5
- package/dist/lib/task/activity-log.js +61 -0
- package/dist/lib/task/artifact-lifecycle.js +427 -0
- package/dist/lib/task/command-options.js +30 -0
- package/dist/lib/task/commands/cat.js +36 -6
- package/dist/lib/task/commands/decisions.js +80 -46
- package/dist/lib/task/commands/files.js +21 -7
- package/dist/lib/task/commands/grep.js +55 -7
- package/dist/lib/task/commands/issue-body.js +33 -19
- package/dist/lib/task/commands/log.js +27 -70
- package/dist/lib/task/commands/show.js +20 -7
- package/dist/lib/task/commands/status.js +18 -8
- package/dist/lib/task/decision-intents.js +154 -0
- package/dist/lib/task/decision-items.js +53 -0
- package/dist/lib/task/events.js +318 -0
- package/dist/lib/task/frontmatter.js +159 -1
- package/dist/lib/task/implementation-inputs.js +117 -0
- package/dist/lib/task/index.js +12 -9
- package/dist/lib/task/issue-form.js +21 -6
- package/dist/lib/task/ledger-intents.js +185 -0
- package/dist/lib/task/ledger.js +65 -35
- package/dist/lib/task/lifecycle.js +484 -0
- package/dist/lib/task/resolve-ref.js +152 -32
- package/dist/lib/task/review-artifacts.js +101 -0
- package/dist/lib/task/review-fingerprint.js +55 -0
- package/dist/lib/task/sections.js +358 -4
- package/dist/lib/task/short-id.js +292 -7
- package/dist/lib/task/snapshot.js +95 -0
- package/dist/lib/task/verification-checks.js +8 -0
- package/dist/lib/task/verification-config.js +14 -0
- package/dist/lib/task/verification-engine.js +923 -0
- package/dist/lib/task/verification-review.js +3 -0
- package/dist/lib/task/verification-types.js +2 -0
- package/dist/lib/task/verification.js +113 -0
- package/dist/lib/task/workflow-warning-intents.js +131 -0
- package/dist/lib/task/workflow-warnings.js +10 -78
- package/dist/lib/task/write.js +241 -0
- package/lib/decide.ts +57 -97
- package/lib/defaults.json +1 -0
- package/lib/git/review-snapshot.ts +73 -0
- package/lib/git/workflow.ts +101 -0
- package/lib/internal/git-workflow.ts +37 -0
- package/lib/internal/platform-checks.ts +101 -0
- package/lib/internal/platform-comment.ts +99 -0
- package/lib/internal/platform-context.ts +33 -0
- package/lib/internal/platform-issue.ts +116 -0
- package/lib/internal/platform-pr.ts +119 -0
- package/lib/internal/platform-release-notes.ts +55 -0
- package/lib/internal/release-workflow.ts +288 -0
- package/lib/internal/task-artifact.ts +47 -0
- package/lib/internal/task-context.ts +35 -0
- package/lib/internal/task-event.ts +51 -0
- package/lib/internal/task-ledger.ts +86 -0
- package/lib/internal/task-lifecycle.ts +41 -0
- package/lib/internal/task-short-id.ts +55 -0
- package/lib/internal/task-snapshot.ts +32 -0
- package/lib/internal/task-verify.ts +33 -0
- package/lib/internal/task-warning.ts +50 -0
- package/lib/platform/adapters.ts +30 -0
- package/lib/platform/context.ts +164 -0
- package/lib/platform/github-client.ts +146 -0
- package/lib/platform/github-release-notes.ts +132 -0
- package/lib/platform/issue-comments.ts +479 -0
- package/lib/platform/issue-metadata.ts +250 -0
- package/lib/platform/issues.ts +693 -0
- package/lib/platform/merged-pr-equivalence.ts +70 -0
- package/lib/platform/metadata-labels.ts +33 -0
- package/lib/platform/pr-checks.ts +247 -0
- package/lib/platform/pr-summary.ts +90 -0
- package/lib/platform/pull-request-metadata.ts +69 -0
- package/lib/platform/pull-requests.ts +386 -0
- package/lib/platform/release-notes.ts +167 -0
- package/lib/platform/releases.ts +71 -0
- package/lib/platform/types.ts +74 -0
- package/lib/platform/verification-required.ts +109 -0
- package/{runtime/platform-adapters/platform-sync.github.js → lib/platform/verification-sync.ts} +198 -367
- package/lib/platform/verification.ts +11 -0
- package/lib/release/channels.ts +30 -0
- package/lib/release/workflow.ts +31 -0
- package/lib/render.ts +3 -2
- package/lib/run/index.ts +25 -7
- package/lib/sandbox/build-proxy.ts +94 -0
- package/lib/sandbox/capture.ts +29 -3
- package/lib/sandbox/commands/create.ts +120 -36
- package/lib/sandbox/commands/enter.ts +38 -11
- package/lib/sandbox/commands/list-running.ts +10 -8
- package/lib/sandbox/commands/rebuild.ts +29 -7
- package/lib/sandbox/commands/show.ts +2 -2
- package/lib/sandbox/commands/start.ts +50 -16
- package/lib/sandbox/image-build.ts +4 -1
- package/lib/sandbox/index.ts +6 -6
- package/lib/sandbox/mounts.ts +55 -0
- package/lib/sandbox/recovery.ts +828 -0
- package/lib/sandbox/runtimes/ai-tools.dockerfile +24 -3
- package/lib/sandbox/runtimes/base.dockerfile +8 -1
- package/lib/sandbox/runtimes/java17.dockerfile +8 -1
- package/lib/sandbox/runtimes/java21.dockerfile +8 -1
- package/lib/sandbox/runtimes/node20.dockerfile +8 -1
- package/lib/sandbox/runtimes/node22.dockerfile +8 -1
- package/lib/sandbox/runtimes/python3.dockerfile +8 -1
- package/lib/sandbox/shell.ts +3 -1
- package/lib/sandbox/task-resolver.ts +5 -1
- package/lib/sandbox/tools.ts +31 -0
- package/lib/server/protocol.ts +5 -5
- package/lib/task/activity-log.ts +62 -0
- package/lib/task/artifact-lifecycle.ts +484 -0
- package/lib/task/command-options.ts +32 -0
- package/lib/task/commands/cat.ts +22 -9
- package/lib/task/commands/decisions.ts +49 -47
- package/lib/task/commands/files.ts +14 -6
- package/lib/task/commands/grep.ts +34 -7
- package/lib/task/commands/issue-body.ts +26 -21
- package/lib/task/commands/log.ts +17 -70
- package/lib/task/commands/show.ts +14 -6
- package/lib/task/commands/status.ts +17 -7
- package/lib/task/decision-intents.ts +163 -0
- package/lib/task/decision-items.ts +64 -0
- package/lib/task/events.ts +320 -0
- package/lib/task/frontmatter.ts +202 -2
- package/lib/task/implementation-inputs.ts +137 -0
- package/lib/task/index.ts +12 -9
- package/lib/task/issue-form.ts +24 -6
- package/lib/task/ledger-intents.ts +201 -0
- package/lib/task/ledger.ts +77 -31
- package/lib/task/lifecycle.ts +458 -0
- package/lib/task/resolve-ref.ts +197 -36
- package/{templates/.agents/scripts/lib/review-artifacts.js → lib/task/review-artifacts.ts} +11 -12
- package/{templates/.agents/scripts/lib/post-review-commit.js → lib/task/review-fingerprint.ts} +26 -12
- package/lib/task/sections.ts +486 -4
- package/lib/task/short-id.ts +403 -9
- package/lib/task/snapshot.ts +143 -0
- package/lib/task/verification-checks.ts +9 -0
- package/lib/task/verification-config.ts +20 -0
- package/{templates/.agents/scripts/validate-artifact.js → lib/task/verification-engine.ts} +230 -421
- package/lib/task/verification-review.ts +10 -0
- package/lib/task/verification-types.ts +29 -0
- package/lib/task/verification.ts +156 -0
- package/lib/task/workflow-warning-intents.ts +142 -0
- package/lib/task/workflow-warnings.ts +10 -78
- package/lib/task/write.ts +468 -0
- package/package.json +4 -2
- package/templates/.agents/README.en.md +4 -3
- package/templates/.agents/README.zh-CN.md +4 -3
- package/templates/.agents/rules/README.en.md +6 -5
- package/templates/.agents/rules/README.zh-CN.md +6 -5
- package/templates/.agents/rules/create-issue.en.md +1 -1
- package/templates/.agents/rules/create-issue.github.en.md +5 -184
- package/templates/.agents/rules/create-issue.github.zh-CN.md +12 -178
- package/templates/.agents/rules/create-issue.zh-CN.md +1 -1
- package/templates/.agents/rules/human-decision-context.en.md +36 -0
- package/templates/.agents/rules/human-decision-context.zh-CN.md +36 -0
- package/templates/.agents/rules/issue-fields.github.en.md +4 -148
- package/templates/.agents/rules/issue-fields.github.zh-CN.md +9 -144
- package/templates/.agents/rules/issue-pr-commands.en.md +43 -3
- package/templates/.agents/rules/issue-pr-commands.github.en.md +15 -220
- package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +23 -213
- package/templates/.agents/rules/issue-pr-commands.zh-CN.md +45 -3
- package/templates/.agents/rules/issue-sync.en.md +1 -1
- package/templates/.agents/rules/issue-sync.github.en.md +14 -301
- package/templates/.agents/rules/issue-sync.github.zh-CN.md +36 -287
- package/templates/.agents/rules/issue-sync.zh-CN.md +1 -1
- package/templates/.agents/rules/milestone-inference.en.md +1 -1
- package/templates/.agents/rules/milestone-inference.github.en.md +7 -119
- package/templates/.agents/rules/milestone-inference.github.zh-CN.md +8 -108
- package/templates/.agents/rules/milestone-inference.zh-CN.md +1 -1
- package/templates/.agents/rules/next-step-output.en.md +12 -11
- package/templates/.agents/rules/next-step-output.zh-CN.md +12 -11
- package/templates/.agents/rules/no-mid-flow-questions.en.md +3 -3
- package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +3 -3
- package/templates/.agents/rules/pr-checks-commands.en.md +16 -3
- package/templates/.agents/rules/pr-checks-commands.github.en.md +10 -54
- package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +19 -47
- package/templates/.agents/rules/pr-checks-commands.zh-CN.md +30 -3
- package/templates/.agents/rules/pr-sync.en.md +30 -3
- package/templates/.agents/rules/pr-sync.github.en.md +12 -115
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +26 -104
- package/templates/.agents/rules/pr-sync.zh-CN.md +43 -3
- package/templates/.agents/rules/release-commands.en.md +2 -2
- package/templates/.agents/rules/release-commands.github.en.md +10 -40
- package/templates/.agents/rules/release-commands.github.zh-CN.md +9 -39
- package/templates/.agents/rules/release-commands.zh-CN.md +2 -2
- package/templates/.agents/rules/review-handshake.en.md +10 -6
- package/templates/.agents/rules/review-handshake.zh-CN.md +10 -6
- package/templates/.agents/rules/task-management.en.md +11 -2
- package/templates/.agents/rules/task-management.zh-CN.md +11 -3
- package/templates/.agents/rules/task-short-id.en.md +25 -29
- package/templates/.agents/rules/task-short-id.zh-CN.md +20 -23
- package/templates/.agents/rules/testing-discipline.en.md +20 -2
- package/templates/.agents/rules/testing-discipline.zh-CN.md +20 -2
- package/templates/.agents/scripts/lib/agent-infra-package.js +1 -9
- package/templates/.agents/scripts/task-short-id.js +71 -533
- package/templates/.agents/skills/analyze-task/SKILL.en.md +26 -56
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +30 -60
- package/templates/.agents/skills/analyze-task/config/verify.en.json +1 -3
- package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +1 -3
- package/templates/.agents/skills/block-task/SKILL.en.md +21 -47
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +23 -47
- package/templates/.agents/skills/block-task/config/verify.json +1 -2
- package/templates/.agents/skills/cancel-task/SKILL.en.md +16 -45
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +16 -45
- package/templates/.agents/skills/cancel-task/config/verify.json +1 -2
- package/templates/.agents/skills/check-task/SKILL.en.md +6 -3
- package/templates/.agents/skills/check-task/SKILL.zh-CN.md +6 -3
- package/templates/.agents/skills/close-codescan/SKILL.en.md +6 -24
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +6 -24
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +6 -24
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +6 -24
- package/templates/.agents/skills/code-task/SKILL.en.md +22 -35
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +28 -44
- package/templates/.agents/skills/code-task/config/verify.en.json +3 -3
- package/templates/.agents/skills/code-task/config/verify.zh-CN.json +3 -3
- package/templates/.agents/skills/code-task/reference/dual-mode.en.md +13 -9
- package/templates/.agents/skills/code-task/reference/dual-mode.zh-CN.md +13 -9
- package/templates/.agents/skills/code-task/reference/fix-mode.en.md +1 -1
- package/templates/.agents/skills/code-task/reference/fix-mode.zh-CN.md +1 -1
- package/templates/.agents/skills/code-task/reference/report-template.en.md +11 -1
- package/templates/.agents/skills/code-task/reference/report-template.zh-CN.md +11 -1
- package/templates/.agents/skills/commit/SKILL.en.md +13 -11
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +13 -11
- package/templates/.agents/skills/commit/config/verify.json +1 -2
- package/templates/.agents/skills/commit/reference/commit-message.en.md +1 -11
- package/templates/.agents/skills/commit/reference/commit-message.zh-CN.md +1 -11
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +4 -8
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +4 -8
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +6 -18
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +5 -17
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +13 -0
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +13 -0
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +13 -36
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +13 -36
- package/templates/.agents/skills/complete-manual-validation/config/verify.en.json +1 -3
- package/templates/.agents/skills/complete-manual-validation/config/verify.zh-CN.json +1 -3
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +10 -54
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +10 -79
- package/templates/.agents/skills/complete-task/SKILL.en.md +59 -63
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +59 -63
- package/templates/.agents/skills/complete-task/config/verify.en.json +10 -7
- package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +10 -7
- package/templates/.agents/skills/create-pr/SKILL.en.md +19 -44
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +19 -43
- package/templates/.agents/skills/create-pr/config/verify.json +1 -2
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +8 -12
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +7 -11
- package/templates/.agents/skills/create-release-note/SKILL.en.md +17 -38
- package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +16 -37
- package/templates/.agents/skills/create-task/SKILL.en.md +16 -13
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +16 -13
- package/templates/.agents/skills/create-task/config/verify.json +1 -2
- package/templates/.agents/skills/create-task/reference/context-capture.en.md +29 -0
- package/templates/.agents/skills/create-task/reference/context-capture.zh-CN.md +29 -0
- package/templates/.agents/skills/import-codescan/SKILL.en.md +2 -2
- package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/import-codescan/config/verify.json +1 -2
- package/templates/.agents/skills/import-dependabot/SKILL.en.md +2 -2
- package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/import-dependabot/config/verify.json +1 -2
- package/templates/.agents/skills/import-issue/SKILL.en.md +9 -13
- package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +10 -14
- package/templates/.agents/skills/import-issue/config/verify.json +1 -2
- package/templates/.agents/skills/plan-task/SKILL.en.md +17 -42
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +22 -49
- package/templates/.agents/skills/plan-task/config/verify.en.json +1 -3
- package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +1 -3
- package/templates/.agents/skills/post-release/SKILL.en.md +11 -81
- package/templates/.agents/skills/post-release/SKILL.zh-CN.md +8 -78
- 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 -163
- package/templates/.agents/skills/release/SKILL.zh-CN.md +15 -162
- package/templates/.agents/skills/restore-task/SKILL.en.md +11 -29
- package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +11 -29
- package/templates/.agents/skills/restore-task/config/verify.json +1 -2
- package/templates/.agents/skills/review-analysis/SKILL.en.md +13 -25
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +13 -33
- package/templates/.agents/skills/review-analysis/config/verify.en.json +3 -4
- package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +3 -4
- package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +9 -12
- package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +9 -12
- package/templates/.agents/skills/review-analysis/reference/report-template.en.md +9 -2
- package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +9 -2
- package/templates/.agents/skills/review-analysis/reference/review-criteria.en.md +7 -0
- package/templates/.agents/skills/review-analysis/reference/review-criteria.zh-CN.md +7 -0
- package/templates/.agents/skills/review-code/SKILL.en.md +22 -36
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +23 -41
- package/templates/.agents/skills/review-code/config/verify.en.json +3 -4
- package/templates/.agents/skills/review-code/config/verify.zh-CN.json +3 -4
- package/templates/.agents/skills/review-code/reference/output-templates.en.md +56 -18
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +56 -18
- package/templates/.agents/skills/review-code/reference/report-template.en.md +11 -4
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +11 -4
- package/templates/.agents/skills/review-code/reference/review-criteria.en.md +7 -0
- package/templates/.agents/skills/review-code/reference/review-criteria.zh-CN.md +7 -0
- package/templates/.agents/skills/review-plan/SKILL.en.md +13 -25
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +13 -33
- package/templates/.agents/skills/review-plan/config/verify.en.json +3 -4
- package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +3 -4
- package/templates/.agents/skills/review-plan/reference/output-templates.en.md +9 -12
- package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +9 -12
- package/templates/.agents/skills/review-plan/reference/report-template.en.md +9 -2
- package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +9 -2
- package/templates/.agents/skills/review-plan/reference/review-criteria.en.md +7 -0
- package/templates/.agents/skills/review-plan/reference/review-criteria.zh-CN.md +7 -0
- package/templates/.agents/skills/update-agent-infra/SKILL.en.md +1 -2
- package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +1 -2
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +3 -15
- package/templates/.agents/skills/watch-pr/SKILL.en.md +24 -14
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +25 -15
- package/templates/.agents/skills/watch-pr/config/verify.json +1 -2
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +2 -2
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +2 -2
- package/templates/.agents/templates/task.en.md +24 -1
- package/templates/.agents/templates/task.zh-CN.md +24 -1
- 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 -0
- package/templates/.claude/commands/commit.zh-CN.md +1 -0
- 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/watch-pr.en.md +1 -1
- package/templates/.claude/commands/watch-pr.zh-CN.md +1 -1
- package/templates/.gemini/commands/_project_/analyze-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/analyze-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/block-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/block-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/cancel-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/cancel-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/check-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/check-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/code-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/code-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/commit.en.toml +4 -0
- package/templates/.gemini/commands/_project_/commit.zh-CN.toml +4 -0
- package/templates/.gemini/commands/_project_/complete-manual-validation.en.toml +2 -0
- package/templates/.gemini/commands/_project_/complete-manual-validation.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/complete-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/complete-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/create-pr.en.toml +2 -0
- package/templates/.gemini/commands/_project_/create-pr.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/plan-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/plan-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/review-analysis.en.toml +2 -0
- package/templates/.gemini/commands/_project_/review-analysis.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/review-code.en.toml +2 -0
- package/templates/.gemini/commands/_project_/review-code.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/review-plan.en.toml +2 -0
- package/templates/.gemini/commands/_project_/review-plan.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/watch-pr.en.toml +2 -0
- package/templates/.gemini/commands/_project_/watch-pr.zh-CN.toml +2 -0
- package/templates/.git-hooks/check-large-files.cjs +92 -0
- package/templates/.git-hooks/check-version-format.sh +5 -1
- package/templates/.git-hooks/pre-commit +1 -0
- package/templates/.opencode/commands/analyze-task.en.md +1 -1
- package/templates/.opencode/commands/analyze-task.zh-CN.md +1 -1
- package/templates/.opencode/commands/check-task.en.md +1 -1
- package/templates/.opencode/commands/check-task.zh-CN.md +1 -1
- package/templates/.opencode/commands/code-task.en.md +1 -1
- package/templates/.opencode/commands/code-task.zh-CN.md +1 -1
- package/templates/.opencode/commands/commit.en.md +2 -0
- package/templates/.opencode/commands/commit.zh-CN.md +2 -0
- package/templates/.opencode/commands/complete-task.en.md +1 -1
- package/templates/.opencode/commands/complete-task.zh-CN.md +1 -1
- package/templates/.opencode/commands/plan-task.en.md +1 -1
- package/templates/.opencode/commands/plan-task.zh-CN.md +1 -1
- package/templates/.opencode/commands/review-analysis.en.md +1 -1
- package/templates/.opencode/commands/review-analysis.zh-CN.md +1 -1
- package/templates/.opencode/commands/review-code.en.md +1 -1
- package/templates/.opencode/commands/review-code.zh-CN.md +1 -1
- package/templates/.opencode/commands/review-plan.en.md +1 -1
- package/templates/.opencode/commands/review-plan.zh-CN.md +1 -1
- package/templates/.agents/scripts/platform-adapters/platform-sync.github.js +0 -40
- package/templates/.agents/scripts/platform-adapters/platform-sync.js +0 -13
- package/templates/.agents/scripts/review-diff-fingerprint.js +0 -170
- package/templates/.agents/scripts/workflow-warnings.js +0 -290
- package/templates/.agents/skills/code-task/scripts/detect-mode.js +0 -257
- package/templates/.agents/skills/release/scripts/manage-milestones.github.sh +0 -80
- package/templates/.agents/skills/release/scripts/manage-milestones.sh +0 -6
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { applyTaskLifecycle, lifecycleIntentCatalog } from '../task/lifecycle.js';
|
|
2
|
+
const USAGE = `Usage: agent-infra-internal task-lifecycle <N | TASK-id> <intent> --agent <agent> [intent flags] [--dry-run]\n\nIntents: ${lifecycleIntentCatalog.join(', ')}\n`;
|
|
3
|
+
const FLAGS = {
|
|
4
|
+
'--agent': 'agent', '--reason': 'reason', '--unblock-condition': 'unblockCondition',
|
|
5
|
+
'--note': 'note', '--alert-number': 'alertNumber', '--staging-dir': 'stagingDir',
|
|
6
|
+
'--issue-number': 'issueNumber'
|
|
7
|
+
};
|
|
8
|
+
function usageFailure(message) {
|
|
9
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'LIFECYCLE_PAYLOAD_INVALID', message } })}\n`);
|
|
10
|
+
process.stderr.write(USAGE);
|
|
11
|
+
process.exitCode = 1;
|
|
12
|
+
}
|
|
13
|
+
function taskLifecycle(args = []) {
|
|
14
|
+
if (args[0] === '--help' || args[0] === '-h') {
|
|
15
|
+
process.stdout.write(USAGE);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (args.length < 2) {
|
|
19
|
+
usageFailure('task ref and intent are required');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const values = { taskRef: args[0], intent: args[1], agent: '' };
|
|
23
|
+
const seen = new Set();
|
|
24
|
+
for (let index = 2; index < args.length; index += 1) {
|
|
25
|
+
const flag = args[index];
|
|
26
|
+
if (flag === '--dry-run') {
|
|
27
|
+
if (seen.has(flag)) {
|
|
28
|
+
usageFailure(`duplicate option '${flag}'`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
seen.add(flag);
|
|
32
|
+
values.dryRun = true;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const key = FLAGS[flag];
|
|
36
|
+
if (!key) {
|
|
37
|
+
usageFailure(`unknown option '${flag}'`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (seen.has(flag)) {
|
|
41
|
+
usageFailure(`duplicate option '${flag}'`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const value = args[++index];
|
|
45
|
+
if (value === undefined || value.startsWith('--')) {
|
|
46
|
+
usageFailure(`option '${flag}' requires a value`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
seen.add(flag);
|
|
50
|
+
values[key] = key === 'alertNumber' || key === 'issueNumber' ? Number(value) : value;
|
|
51
|
+
}
|
|
52
|
+
const result = applyTaskLifecycle(values);
|
|
53
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
54
|
+
if (result.status === 'failed')
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
}
|
|
57
|
+
export { taskLifecycle };
|
|
58
|
+
//# sourceMappingURL=task-lifecycle.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { detectRepoRoot } from '../task/resolve-ref.js';
|
|
3
|
+
import { configuredShortIdLength, executeShortIdCommand } from '../task/short-id.js';
|
|
4
|
+
const USAGE = `Usage: agent-infra-internal task-short-id <alloc|release|resolve|list> [argument] [--active-dir <path>] [--short-id-length <N>] [--verify]\n`;
|
|
5
|
+
function failure(message) {
|
|
6
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, output: '', error: { code: 'SHORT_ID_PAYLOAD_INVALID', message } })}\n`);
|
|
7
|
+
process.stderr.write(USAGE);
|
|
8
|
+
process.exitCode = 1;
|
|
9
|
+
}
|
|
10
|
+
function taskShortId(args = []) {
|
|
11
|
+
if (args[0] === '--help' || args[0] === '-h') {
|
|
12
|
+
process.stdout.write(USAGE);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const operation = args[0];
|
|
16
|
+
if (!operation || !['alloc', 'release', 'resolve', 'list'].includes(operation)) {
|
|
17
|
+
failure('a valid short-id operation is required');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const positional = [];
|
|
21
|
+
let activeDir = null;
|
|
22
|
+
let shortIdLength = null;
|
|
23
|
+
let verify = false;
|
|
24
|
+
const seen = new Set();
|
|
25
|
+
for (let index = 1; index < args.length; index += 1) {
|
|
26
|
+
const value = args[index];
|
|
27
|
+
if (value === '--verify') {
|
|
28
|
+
if (seen.has(value)) {
|
|
29
|
+
failure(`duplicate option '${value}'`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
seen.add(value);
|
|
33
|
+
verify = true;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (value === '--active-dir' || value === '--short-id-length') {
|
|
37
|
+
if (seen.has(value)) {
|
|
38
|
+
failure(`duplicate option '${value}'`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const optionValue = args[++index];
|
|
42
|
+
if (optionValue === undefined || optionValue.startsWith('--')) {
|
|
43
|
+
failure(`option '${value}' requires a value`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
seen.add(value);
|
|
47
|
+
if (value === '--active-dir')
|
|
48
|
+
activeDir = path.resolve(optionValue);
|
|
49
|
+
else
|
|
50
|
+
shortIdLength = Number(optionValue);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (value.startsWith('--')) {
|
|
54
|
+
failure(`unknown option '${value}'`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
positional.push(value);
|
|
58
|
+
}
|
|
59
|
+
if (positional.length > (operation === 'list' ? 0 : 1)) {
|
|
60
|
+
failure('too many positional arguments');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
let repoRoot = null;
|
|
64
|
+
try {
|
|
65
|
+
repoRoot = detectRepoRoot();
|
|
66
|
+
}
|
|
67
|
+
catch { /* custom active-dir mode */ }
|
|
68
|
+
const resolvedActiveDir = activeDir ?? (repoRoot ? path.join(repoRoot, '.agents', 'workspace', 'active') : null);
|
|
69
|
+
if (!resolvedActiveDir) {
|
|
70
|
+
failure('cannot determine active task directory');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const width = shortIdLength ?? (repoRoot ? configuredShortIdLength(repoRoot) : 2);
|
|
74
|
+
const result = executeShortIdCommand({
|
|
75
|
+
operation: operation,
|
|
76
|
+
argument: positional[0], activeDir: resolvedActiveDir, shortIdLength: width, verify
|
|
77
|
+
});
|
|
78
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
79
|
+
if (result.status === 'failed')
|
|
80
|
+
process.exitCode = 1;
|
|
81
|
+
}
|
|
82
|
+
export { taskShortId };
|
|
83
|
+
//# sourceMappingURL=task-short-id.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { collectTaskSnapshot } from '../task/snapshot.js';
|
|
2
|
+
const USAGE = 'Usage: agent-infra-internal task-snapshot <N | TASK-id> [--format json|text]\n';
|
|
3
|
+
function fail(message) {
|
|
4
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'SNAPSHOT_PAYLOAD_INVALID', message } })}\n`);
|
|
5
|
+
process.stderr.write(USAGE);
|
|
6
|
+
process.exitCode = 1;
|
|
7
|
+
}
|
|
8
|
+
function taskSnapshot(args = []) {
|
|
9
|
+
if (args[0] === '--help' || args[0] === '-h') {
|
|
10
|
+
process.stdout.write(USAGE);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (!args[0] || args[0].startsWith('--')) {
|
|
14
|
+
fail('task ref is required');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let format = 'json';
|
|
18
|
+
let seenFormat = false;
|
|
19
|
+
for (let index = 1; index < args.length; index += 1) {
|
|
20
|
+
const flag = args[index];
|
|
21
|
+
if (flag !== '--format') {
|
|
22
|
+
fail(`unknown option '${flag}'`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (seenFormat) {
|
|
26
|
+
fail("duplicate option '--format'");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const value = args[++index];
|
|
30
|
+
if (value !== 'json' && value !== 'text') {
|
|
31
|
+
fail("option '--format' requires 'json' or 'text'");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
seenFormat = true;
|
|
35
|
+
format = value;
|
|
36
|
+
}
|
|
37
|
+
const result = collectTaskSnapshot(args[0]);
|
|
38
|
+
if (format === 'text') {
|
|
39
|
+
process.stdout.write(result.status === 'ready' ? `${result.evidence}\n` : `Snapshot failed: ${result.error?.code} - ${result.error?.message}\n`);
|
|
40
|
+
}
|
|
41
|
+
else
|
|
42
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
43
|
+
if (result.status === 'failed')
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
}
|
|
46
|
+
export { taskSnapshot };
|
|
47
|
+
//# sourceMappingURL=task-snapshot.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { renderTaskVerification, verifyTaskEvent } from '../task/verification.js';
|
|
2
|
+
const USAGE = 'Usage: agent-infra-internal task-verify <N | TASK-id> <verification-event> [--artifact <canonical.md>] [--format json|text]\n';
|
|
3
|
+
function fail(message) {
|
|
4
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'VERIFY_PAYLOAD_INVALID', message } })}\n`);
|
|
5
|
+
process.stderr.write(USAGE);
|
|
6
|
+
process.exitCode = 1;
|
|
7
|
+
}
|
|
8
|
+
function taskVerify(args = []) {
|
|
9
|
+
if (args[0] === '--help' || args[0] === '-h') {
|
|
10
|
+
process.stdout.write(USAGE);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (!args[0] || !args[1] || args[0].startsWith('--') || args[1].startsWith('--')) {
|
|
14
|
+
fail('task ref and verification event are required');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let artifact;
|
|
18
|
+
let format = 'json';
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
for (let index = 2; index < args.length; index += 1) {
|
|
21
|
+
const flag = args[index];
|
|
22
|
+
if (flag !== '--artifact' && flag !== '--format') {
|
|
23
|
+
fail(`unknown option '${flag}'`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (seen.has(flag)) {
|
|
27
|
+
fail(`duplicate option '${flag}'`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const value = args[++index];
|
|
31
|
+
if (!value || value.startsWith('--')) {
|
|
32
|
+
fail(`option '${flag}' requires a value`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
seen.add(flag);
|
|
36
|
+
if (flag === '--artifact')
|
|
37
|
+
artifact = value;
|
|
38
|
+
else if (value === 'json' || value === 'text')
|
|
39
|
+
format = value;
|
|
40
|
+
else {
|
|
41
|
+
fail("option '--format' requires 'json' or 'text'");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const result = verifyTaskEvent({ taskRef: args[0], event: args[1], ...(artifact ? { artifact } : {}) });
|
|
46
|
+
process.stdout.write(format === 'text' ? renderTaskVerification(result) : `${JSON.stringify(result)}\n`);
|
|
47
|
+
process.exitCode = result.status === 'pass' ? 0 : result.status === 'blocked' ? 2 : 1;
|
|
48
|
+
}
|
|
49
|
+
export { taskVerify };
|
|
50
|
+
//# sourceMappingURL=task-verify.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { applyWorkflowWarningIntent } from '../task/workflow-warning-intents.js';
|
|
2
|
+
const USAGE = `Usage: agent-infra-internal task-warning <task-ref> <add|set-status|list> [intent flags] [--dry-run]\n`;
|
|
3
|
+
const FLAGS = {
|
|
4
|
+
'--step': 'step', '--severity': 'severity', '--code': 'code', '--target': 'target',
|
|
5
|
+
'--message': 'message', '--action': 'action', '--id': 'id', '--status': 'status', '--resolution': 'resolution'
|
|
6
|
+
};
|
|
7
|
+
function usageFailure(message) {
|
|
8
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'WARNING_PAYLOAD_INVALID', message } })}\n`);
|
|
9
|
+
process.stderr.write(USAGE);
|
|
10
|
+
process.exitCode = 1;
|
|
11
|
+
}
|
|
12
|
+
function taskWarning(args = []) {
|
|
13
|
+
if (args[0] === '--help' || args[0] === '-h') {
|
|
14
|
+
process.stdout.write(USAGE);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const [taskRef, kind] = args;
|
|
18
|
+
if (!taskRef || !kind || !['add', 'set-status', 'list'].includes(kind)) {
|
|
19
|
+
usageFailure('task ref and a valid intent are required');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const values = { kind, taskRef };
|
|
23
|
+
const seen = new Set();
|
|
24
|
+
for (let index = 2; index < args.length; index += 1) {
|
|
25
|
+
const flag = args[index];
|
|
26
|
+
if (flag === '--dry-run') {
|
|
27
|
+
if (seen.has(flag)) {
|
|
28
|
+
usageFailure(`duplicate option '${flag}'`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
seen.add(flag);
|
|
32
|
+
values.dryRun = true;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const key = FLAGS[flag];
|
|
36
|
+
if (!key) {
|
|
37
|
+
usageFailure(`unknown option '${flag}'`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (seen.has(flag)) {
|
|
41
|
+
usageFailure(`duplicate option '${flag}'`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const value = args[++index];
|
|
45
|
+
if (value === undefined || value.startsWith('--')) {
|
|
46
|
+
usageFailure(`option '${flag}' requires a value`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
seen.add(flag);
|
|
50
|
+
values[key] = value;
|
|
51
|
+
}
|
|
52
|
+
const required = {
|
|
53
|
+
add: ['step', 'severity', 'code', 'target', 'message', 'action'],
|
|
54
|
+
'set-status': ['id', 'status', 'resolution'], list: []
|
|
55
|
+
};
|
|
56
|
+
const optional = kind === 'list' ? ['status'] : [];
|
|
57
|
+
const allowed = new Set(['kind', 'taskRef', 'dryRun', ...required[kind], ...optional]);
|
|
58
|
+
const unexpected = Object.keys(values).find((key) => !allowed.has(key));
|
|
59
|
+
const missing = required[kind].find((key) => values[key] === undefined);
|
|
60
|
+
if (unexpected) {
|
|
61
|
+
usageFailure(`${kind} does not accept '${unexpected}'`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (missing) {
|
|
65
|
+
usageFailure(`${kind} requires '${missing}'`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const result = applyWorkflowWarningIntent(values);
|
|
69
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
70
|
+
if (result.status === 'failed')
|
|
71
|
+
process.exitCode = 1;
|
|
72
|
+
}
|
|
73
|
+
export { taskWarning };
|
|
74
|
+
//# sourceMappingURL=task-warning.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const adapters = new Map();
|
|
2
|
+
function registerPlatformAdapter(adapter) {
|
|
3
|
+
if (!adapter.type.trim())
|
|
4
|
+
throw new Error('Platform adapter type is required');
|
|
5
|
+
adapters.set(adapter.type, adapter);
|
|
6
|
+
}
|
|
7
|
+
function getPlatformAdapter(type) {
|
|
8
|
+
return type ? adapters.get(type) ?? null : null;
|
|
9
|
+
}
|
|
10
|
+
function listPlatformAdapters() {
|
|
11
|
+
return [...adapters.keys()].sort();
|
|
12
|
+
}
|
|
13
|
+
export { getPlatformAdapter, listPlatformAdapters, registerPlatformAdapter };
|
|
14
|
+
//# sourceMappingURL=adapters.js.map
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
import { getPlatformAdapter, registerPlatformAdapter } from './adapters.js';
|
|
6
|
+
import { createGitHubClient, MINIMUM_GITHUB_CLI_VERSION } from './github-client.js';
|
|
7
|
+
import { platformResult } from './types.js';
|
|
8
|
+
function findRepoRoot(cwd) {
|
|
9
|
+
try {
|
|
10
|
+
return execFileSync('git', ['rev-parse', '--show-toplevel'], {
|
|
11
|
+
cwd, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe']
|
|
12
|
+
}).trim();
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return cwd;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function parseGitHubRemote(remote) {
|
|
19
|
+
const trimmed = remote.trim().replace(/\.git$/, '');
|
|
20
|
+
const match = trimmed.match(/^(?:https?:\/\/github\.com\/|ssh:\/\/(?:git@)?github\.com\/|git@github\.com:)([^/\s]+\/[^/\s]+)$/i);
|
|
21
|
+
return match?.[1] || null;
|
|
22
|
+
}
|
|
23
|
+
function defaultGitRemote(cwd) {
|
|
24
|
+
try {
|
|
25
|
+
return execFileSync('git', ['remote', 'get-url', 'origin'], {
|
|
26
|
+
cwd, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe']
|
|
27
|
+
}).trim();
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function readPlatformType(repoRoot) {
|
|
34
|
+
try {
|
|
35
|
+
const config = JSON.parse(fs.readFileSync(path.join(repoRoot, '.agents', '.airc.json'), 'utf8'));
|
|
36
|
+
return typeof config?.platform?.type === 'string' ? config.platform.type : null;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function failure(error, repo) {
|
|
43
|
+
const blocked = error.retryable || error.code === 'AUTH_REQUIRED' || error.code === 'PLATFORM_DEPENDENCY_MISSING';
|
|
44
|
+
return platformResult(blocked ? 'blocked' : 'failed', {
|
|
45
|
+
platform: { type: 'github', repository: repo, currentUser: null }, error
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function resolveGitHubContext(options) {
|
|
49
|
+
const { cwd } = options;
|
|
50
|
+
const platform = 'github';
|
|
51
|
+
const client = options.client || createGitHubClient();
|
|
52
|
+
const version = client.version({ cwd });
|
|
53
|
+
if (!version.ok)
|
|
54
|
+
return failure(version.error, null);
|
|
55
|
+
if (!semver.gte(version.value, MINIMUM_GITHUB_CLI_VERSION)) {
|
|
56
|
+
return failure({
|
|
57
|
+
code: 'GH_CLI_VERSION_UNSUPPORTED',
|
|
58
|
+
message: `GitHub CLI ${version.value} is unsupported; install gh >= ${MINIMUM_GITHUB_CLI_VERSION}`,
|
|
59
|
+
retryable: false
|
|
60
|
+
}, null);
|
|
61
|
+
}
|
|
62
|
+
const remote = (options.gitRemote || defaultGitRemote)(cwd);
|
|
63
|
+
if (!remote) {
|
|
64
|
+
return platformResult('no-op', {
|
|
65
|
+
platform: { type: platform, repository: null, currentUser: null },
|
|
66
|
+
error: { code: 'REMOTE_MISSING', message: 'Git origin remote is not configured', retryable: false }
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const ownerRepo = parseGitHubRemote(remote);
|
|
70
|
+
if (!ownerRepo) {
|
|
71
|
+
const nonGitHub = !/github\.com/i.test(remote);
|
|
72
|
+
return platformResult(nonGitHub ? 'no-op' : 'failed', {
|
|
73
|
+
platform: { type: platform, repository: null, currentUser: null },
|
|
74
|
+
error: {
|
|
75
|
+
code: nonGitHub ? 'PLATFORM_UNSUPPORTED' : 'REMOTE_INVALID',
|
|
76
|
+
message: `Unable to parse GitHub owner/repo from '${remote}'`,
|
|
77
|
+
retryable: false
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const repository = client.json(['api', `repos/${ownerRepo}`], { cwd });
|
|
82
|
+
if (!repository.ok)
|
|
83
|
+
return failure(repository.error, null);
|
|
84
|
+
const repositoryValue = repository.value;
|
|
85
|
+
const upstream = repositoryValue?.fork ? repositoryValue.parent?.full_name : repositoryValue?.full_name;
|
|
86
|
+
if (!upstream) {
|
|
87
|
+
return platformResult('blocked', {
|
|
88
|
+
platform: { type: platform, repository: null, currentUser: null },
|
|
89
|
+
error: { code: 'UPSTREAM_UNRESOLVED', message: 'Unable to resolve the upstream repository', retryable: false }
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const user = client.json(['api', 'user'], { cwd });
|
|
93
|
+
if (!user.ok)
|
|
94
|
+
return failure(user.error, upstream);
|
|
95
|
+
const userValue = user.value;
|
|
96
|
+
const permissions = client.json(['api', `repos/${upstream}`], { cwd });
|
|
97
|
+
if (!permissions.ok)
|
|
98
|
+
return failure(permissions.error, upstream);
|
|
99
|
+
const permissionValue = permissions.value;
|
|
100
|
+
const values = permissionValue?.permissions || {};
|
|
101
|
+
const capabilities = {
|
|
102
|
+
authenticated: Boolean(userValue?.login),
|
|
103
|
+
comment: Boolean(userValue?.login),
|
|
104
|
+
triage: Boolean(values.triage || values.push || values.admin),
|
|
105
|
+
push: Boolean(values.push || values.admin),
|
|
106
|
+
admin: Boolean(values.admin)
|
|
107
|
+
};
|
|
108
|
+
const status = Object.values(capabilities).every(Boolean) ? 'no-op' : 'degraded';
|
|
109
|
+
return platformResult(status, {
|
|
110
|
+
changed: false,
|
|
111
|
+
platform: { type: platform, repository: upstream, currentUser: userValue?.login || null },
|
|
112
|
+
resource: { kind: 'repository', number: null },
|
|
113
|
+
capabilities,
|
|
114
|
+
operations: [{ name: 'resolve', status: 'no-op', reasonCode: null }]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
registerPlatformAdapter({
|
|
118
|
+
type: 'github',
|
|
119
|
+
resolveContext(options) {
|
|
120
|
+
return resolveGitHubContext(options);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
registerPlatformAdapter({
|
|
124
|
+
type: 'none',
|
|
125
|
+
resolveContext() {
|
|
126
|
+
return platformResult('no-op', {
|
|
127
|
+
platform: { type: 'none', repository: null, currentUser: null },
|
|
128
|
+
operations: [{ name: 'resolve', status: 'no-op', reasonCode: 'PLATFORM_DISABLED' }]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
function resolvePlatformContext(options = {}) {
|
|
133
|
+
const cwd = path.resolve(options.cwd || process.cwd());
|
|
134
|
+
const repoRoot = findRepoRoot(cwd);
|
|
135
|
+
const platform = options.platformType ?? readPlatformType(repoRoot);
|
|
136
|
+
const adapter = getPlatformAdapter(platform);
|
|
137
|
+
if (!adapter) {
|
|
138
|
+
return platformResult('no-op', {
|
|
139
|
+
platform: { type: platform, repository: null, currentUser: null },
|
|
140
|
+
error: { code: 'PLATFORM_UNSUPPORTED', message: `Platform '${platform || 'none'}' has no registered adapter`, retryable: false }
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return adapter.resolveContext({ cwd, gitRemote: options.gitRemote, client: options.client });
|
|
144
|
+
}
|
|
145
|
+
export { parseGitHubRemote, resolvePlatformContext };
|
|
146
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import spawn from 'cross-spawn';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
const MINIMUM_GITHUB_CLI_VERSION = '2.16.0';
|
|
5
|
+
function defaultRunner(args, options) {
|
|
6
|
+
const command = process.env.AGENT_INFRA_GH_BIN || 'gh';
|
|
7
|
+
let prefix = [];
|
|
8
|
+
try {
|
|
9
|
+
prefix = JSON.parse(process.env.AGENT_INFRA_GH_ARGS_JSON || '[]');
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
prefix = [];
|
|
13
|
+
}
|
|
14
|
+
const result = spawn.sync(command, [...prefix, ...args], {
|
|
15
|
+
cwd: options.cwd,
|
|
16
|
+
encoding: 'utf8',
|
|
17
|
+
env: process.env,
|
|
18
|
+
input: options.input,
|
|
19
|
+
shell: false
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
status: result.status,
|
|
23
|
+
stdout: String(result.stdout || ''),
|
|
24
|
+
stderr: String(result.stderr || ''),
|
|
25
|
+
error: result.error
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function retryDelaysFromEnvironment() {
|
|
29
|
+
const raw = process.env.AGENT_INFRA_PLATFORM_RETRY_DELAYS_MS;
|
|
30
|
+
if (!raw)
|
|
31
|
+
return [3000, 10000];
|
|
32
|
+
return raw.split(',').map(Number).filter((value) => Number.isFinite(value) && value >= 0);
|
|
33
|
+
}
|
|
34
|
+
function defaultSleep(delayMs) {
|
|
35
|
+
if (delayMs <= 0)
|
|
36
|
+
return;
|
|
37
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, delayMs);
|
|
38
|
+
}
|
|
39
|
+
function classifyGitHubFailure(result) {
|
|
40
|
+
const detail = `${result.stderr}\n${result.stdout}\n${result.error?.message || ''}`.trim();
|
|
41
|
+
const lower = detail.toLowerCase();
|
|
42
|
+
if (/\b401\b|bad credentials|authentication required|not logged into/.test(lower)) {
|
|
43
|
+
return { code: 'AUTH_REQUIRED', message: detail || 'GitHub authentication is required', retryable: false };
|
|
44
|
+
}
|
|
45
|
+
if (/\b429\b|rate limit|secondary rate|\b5\d\d\b|timeout|timed out|econnreset|enotfound|dns|tls|socket|network/.test(lower)) {
|
|
46
|
+
return { code: 'NETWORK_TRANSIENT', message: detail || 'GitHub request failed temporarily', retryable: true };
|
|
47
|
+
}
|
|
48
|
+
if (/\b403\b|resource not accessible|permission denied/.test(lower)) {
|
|
49
|
+
return { code: 'PERMISSION_DENIED', message: detail || 'GitHub permission denied', retryable: false };
|
|
50
|
+
}
|
|
51
|
+
if (/\b404\b/.test(lower)) {
|
|
52
|
+
return { code: 'RESOURCE_NOT_FOUND', message: detail || 'GitHub resource not found', retryable: false };
|
|
53
|
+
}
|
|
54
|
+
if (/\b422\b|validation failed/.test(lower)) {
|
|
55
|
+
return { code: 'PLATFORM_REQUEST_INVALID', message: detail || 'GitHub rejected the request', retryable: false };
|
|
56
|
+
}
|
|
57
|
+
if (result.error && 'code' in result.error && result.error.code === 'ENOENT') {
|
|
58
|
+
return { code: 'PLATFORM_DEPENDENCY_MISSING', message: detail || 'GitHub CLI is unavailable', retryable: false };
|
|
59
|
+
}
|
|
60
|
+
return { code: 'PLATFORM_REQUEST_FAILED', message: detail || 'GitHub request failed', retryable: false };
|
|
61
|
+
}
|
|
62
|
+
function createGitHubClient(options = {}) {
|
|
63
|
+
const runner = options.runner || defaultRunner;
|
|
64
|
+
const delays = options.retryDelaysMs || retryDelaysFromEnvironment();
|
|
65
|
+
const sleep = options.sleep || defaultSleep;
|
|
66
|
+
function run(args, request = {}) {
|
|
67
|
+
const method = request.method || 'GET';
|
|
68
|
+
const retryableMethod = method === 'GET' || method === 'PATCH';
|
|
69
|
+
let attempt = 0;
|
|
70
|
+
while (true) {
|
|
71
|
+
const result = runner(args, request);
|
|
72
|
+
if (result.status === 0)
|
|
73
|
+
return { ok: true, value: result.stdout };
|
|
74
|
+
const error = classifyGitHubFailure(result);
|
|
75
|
+
if (!retryableMethod || !error.retryable)
|
|
76
|
+
return { ok: false, error };
|
|
77
|
+
if (attempt >= delays.length) {
|
|
78
|
+
return {
|
|
79
|
+
ok: false,
|
|
80
|
+
error: error.code === 'NETWORK_TRANSIENT'
|
|
81
|
+
? { ...error, code: 'NETWORK_RETRY_EXHAUSTED', message: `${error.message} (retry exhausted)` }
|
|
82
|
+
: error
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
sleep(delays[attempt]);
|
|
86
|
+
attempt += 1;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
version(request = {}) {
|
|
91
|
+
const result = runner(['--version'], request);
|
|
92
|
+
if (result.status !== 0)
|
|
93
|
+
return { ok: false, error: classifyGitHubFailure(result) };
|
|
94
|
+
const version = result.stdout.match(/^gh version (\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(?:\s|$)/m)?.[1];
|
|
95
|
+
if (!version || !semver.valid(version)) {
|
|
96
|
+
return {
|
|
97
|
+
ok: false,
|
|
98
|
+
error: { code: 'GH_CLI_VERSION_INVALID', message: 'GitHub CLI returned an invalid version', retryable: false }
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return { ok: true, value: version };
|
|
102
|
+
},
|
|
103
|
+
text(args, request = {}) {
|
|
104
|
+
const result = run(args, request);
|
|
105
|
+
return result.ok ? { ok: true, value: result.value.trim() } : result;
|
|
106
|
+
},
|
|
107
|
+
json(args, request = {}) {
|
|
108
|
+
const result = run(args, request);
|
|
109
|
+
if (!result.ok)
|
|
110
|
+
return result;
|
|
111
|
+
try {
|
|
112
|
+
return { ok: true, value: JSON.parse(result.value || 'null') };
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return {
|
|
116
|
+
ok: false,
|
|
117
|
+
error: { code: 'INVALID_PLATFORM_RESPONSE', message: 'GitHub returned invalid JSON', retryable: true }
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export { classifyGitHubFailure, createGitHubClient, MINIMUM_GITHUB_CLI_VERSION };
|
|
124
|
+
//# sourceMappingURL=github-client.js.map
|