@fitlab-ai/agent-infra 0.9.2 → 0.9.4
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 +12 -9
- package/README.zh-CN.md +12 -9
- package/bin/cli.ts +12 -0
- package/dist/bin/cli.js +14 -0
- package/dist/bin/internal-cli.js +134 -108
- package/dist/lib/agent-clients/adapter.js +137 -4
- package/dist/lib/agent-clients/adapters/antigravity-cli.js +64 -0
- package/dist/lib/{sandbox/credentials.js → agent-clients/adapters/claude-code-credentials.js} +4 -14
- package/dist/lib/agent-clients/adapters/claude-code-refresh.js +85 -0
- package/dist/lib/agent-clients/adapters/claude-code-sandbox.js +247 -0
- package/dist/lib/agent-clients/adapters/claude-code.js +27 -4
- package/dist/lib/agent-clients/adapters/codex.js +9 -0
- package/dist/lib/agent-clients/adapters/index.js +2 -2
- package/dist/lib/agent-clients/adapters/opencode-sandbox.js +108 -0
- package/dist/lib/agent-clients/adapters/opencode.js +24 -3
- package/dist/lib/agent-clients/adapters/runtimes/claude-code.dockerfile +65 -0
- package/dist/lib/agent-clients/config.js +42 -4
- package/dist/lib/agent-clients/next-steps.js +11 -2
- package/dist/lib/agent-clients/reconcile.js +2 -1
- package/dist/lib/agent-clients/registry.js +16 -2
- package/dist/lib/agent-clients/schema.js +18 -0
- package/dist/lib/agent-clients/tokens.js +49 -0
- package/dist/lib/agent-clients/types.js +1 -1
- package/dist/lib/defaults.json +1 -1
- package/dist/lib/git/workflow.js +54 -1
- package/dist/lib/internal/agent-client.js +61 -4
- package/dist/lib/internal/git-workflow.js +6 -1
- package/dist/lib/internal/platform-checks.js +3 -3
- package/dist/lib/internal/platform-comment.js +29 -2
- package/dist/lib/internal/platform-issue.js +7 -0
- package/dist/lib/internal/platform-pr-review.js +132 -0
- package/dist/lib/internal/platform-pr.js +20 -2
- package/dist/lib/internal/platform-release-notes.js +52 -16
- package/dist/lib/internal/pr-review-grade.js +140 -0
- package/dist/lib/internal/release-workflow.js +13 -6
- package/dist/lib/internal/sandbox-control.js +24 -0
- package/dist/lib/internal/task-activity.js +105 -0
- package/dist/lib/internal/task-event.js +17 -1
- package/dist/lib/internal/task-ledger.js +12 -3
- package/dist/lib/internal/task-lifecycle.js +26 -1
- package/dist/lib/internal/task-orchestration.js +167 -18
- package/dist/lib/internal/task-review.js +8 -3
- package/dist/lib/platform/adapters.js +8 -1
- package/dist/lib/platform/completion-backfill.js +122 -0
- package/dist/lib/platform/github-client.js +19 -2
- package/dist/lib/platform/issue-comments.js +3 -2
- package/dist/lib/platform/merged-pr-equivalence.js +115 -5
- package/dist/lib/platform/pr-checks.js +65 -42
- package/dist/lib/platform/pr-review.js +166 -0
- package/dist/lib/platform/pull-requests.js +371 -4
- package/dist/lib/platform/release-notes.js +85 -3
- package/dist/lib/platform/releases.js +13 -5
- package/dist/lib/pr-review/evidence-grading.js +229 -0
- package/dist/lib/process-data/index.js +239 -0
- package/dist/lib/process-data/normalize.js +198 -0
- package/dist/lib/process-data/privacy.js +33 -0
- package/dist/lib/process-data/reconcile.js +95 -0
- package/dist/lib/process-data/repair.js +58 -0
- package/dist/lib/process-data/sources.js +345 -0
- package/dist/lib/process-data/store.js +282 -0
- package/dist/lib/process-data/types.js +2 -0
- package/dist/lib/run/index.js +4 -3
- package/dist/lib/run/tui.js +10 -13
- package/dist/lib/sandbox/agent-client-reconciler.js +26 -2
- package/dist/lib/sandbox/capture.js +7 -2
- package/dist/lib/sandbox/commands/create.js +109 -248
- package/dist/lib/sandbox/commands/enter.js +15 -47
- package/dist/lib/sandbox/commands/list-running.js +16 -6
- package/dist/lib/sandbox/commands/ls.js +10 -6
- package/dist/lib/sandbox/commands/rebuild.js +4 -3
- package/dist/lib/sandbox/commands/refresh.js +4 -84
- package/dist/lib/sandbox/commands/rm.js +24 -3
- package/dist/lib/sandbox/commands/show.js +13 -4
- package/dist/lib/sandbox/commands/start.js +7 -4
- package/dist/lib/sandbox/config.js +2 -0
- package/dist/lib/sandbox/constants.js +6 -0
- package/dist/lib/sandbox/control/client.js +44 -0
- package/dist/lib/sandbox/control/protocol.js +35 -0
- package/dist/lib/sandbox/control/server.js +109 -0
- package/dist/lib/sandbox/dockerfile.js +36 -13
- package/dist/lib/sandbox/mounts.js +17 -4
- package/dist/lib/sandbox/recovery.js +128 -5
- package/dist/lib/sandbox/redaction.js +12 -0
- package/dist/lib/sandbox/runtimes/base.dockerfile +24 -74
- package/dist/lib/sandbox/workspace-identity.js +95 -0
- package/dist/lib/sandbox/workspace-view.js +103 -0
- package/dist/lib/task/activity-intent.js +307 -0
- package/dist/lib/task/artifact-lifecycle.js +2 -1
- package/dist/lib/task/commands/log.js +15 -14
- package/dist/lib/task/commit-finalization.js +267 -0
- package/dist/lib/task/commit-intent.js +165 -0
- package/dist/lib/task/decision-intents.js +31 -17
- package/dist/lib/task/delegation-receipts.js +25 -4
- package/dist/lib/task/events.js +67 -28
- package/dist/lib/task/finalization-artifacts.js +35 -0
- package/dist/lib/task/implementation-inputs.js +54 -7
- package/dist/lib/task/ledger-intents.js +35 -1
- package/dist/lib/task/lifecycle-execution.js +46 -0
- package/dist/lib/task/orchestration.js +753 -54
- package/dist/lib/task/resolve-ref.js +41 -1
- package/dist/lib/task/review-finalization.js +29 -9
- package/dist/lib/task/task-execution-lock.js +231 -0
- package/dist/lib/task/verification-checks.js +1 -1
- package/dist/lib/task/verification-engine.js +218 -2
- package/dist/lib/task/verification.js +4 -3
- package/dist/lib/task/workspace-snapshot.js +17 -5
- package/lib/agent-clients/adapter.ts +201 -4
- package/lib/agent-clients/adapters/antigravity-cli.ts +65 -0
- package/lib/{sandbox/credentials.ts → agent-clients/adapters/claude-code-credentials.ts} +3 -18
- package/lib/agent-clients/adapters/claude-code-refresh.ts +128 -0
- package/lib/agent-clients/adapters/claude-code-sandbox.ts +295 -0
- package/lib/agent-clients/adapters/claude-code.ts +31 -4
- package/lib/agent-clients/adapters/codex.ts +9 -0
- package/lib/agent-clients/adapters/index.ts +2 -2
- package/lib/agent-clients/adapters/opencode-sandbox.ts +136 -0
- package/lib/agent-clients/adapters/opencode.ts +27 -3
- package/lib/agent-clients/adapters/runtimes/claude-code.dockerfile +65 -0
- package/lib/agent-clients/config.ts +49 -4
- package/lib/agent-clients/next-steps.ts +15 -2
- package/lib/agent-clients/reconcile.ts +2 -1
- package/lib/agent-clients/registry.ts +19 -1
- package/lib/agent-clients/schema.ts +18 -0
- package/lib/agent-clients/tokens.ts +53 -0
- package/lib/agent-clients/types.ts +15 -1
- package/lib/defaults.json +1 -1
- package/lib/git/workflow.ts +66 -2
- package/lib/internal/agent-client.ts +59 -4
- package/lib/internal/git-workflow.ts +5 -1
- package/lib/internal/platform-checks.ts +4 -4
- package/lib/internal/platform-comment.ts +17 -2
- package/lib/internal/platform-issue.ts +4 -0
- package/lib/internal/platform-pr-review.ts +104 -0
- package/lib/internal/platform-pr.ts +14 -1
- package/lib/internal/platform-release-notes.ts +59 -16
- package/lib/internal/pr-review-grade.ts +130 -0
- package/lib/internal/release-workflow.ts +13 -6
- package/lib/internal/sandbox-control.ts +24 -0
- package/lib/internal/task-activity.ts +91 -0
- package/lib/internal/task-event.ts +9 -1
- package/lib/internal/task-ledger.ts +12 -3
- package/lib/internal/task-lifecycle.ts +26 -1
- package/lib/internal/task-orchestration.ts +123 -14
- package/lib/internal/task-review.ts +8 -3
- package/lib/platform/adapters.ts +29 -2
- package/lib/platform/completion-backfill.ts +134 -0
- package/lib/platform/github-client.ts +20 -2
- package/lib/platform/issue-comments.ts +3 -2
- package/lib/platform/merged-pr-equivalence.ts +127 -5
- package/lib/platform/pr-checks.ts +73 -46
- package/lib/platform/pr-review.ts +201 -0
- package/lib/platform/pull-requests.ts +444 -3
- package/lib/platform/release-notes.ts +100 -4
- package/lib/platform/releases.ts +16 -4
- package/lib/pr-review/evidence-grading.ts +318 -0
- package/lib/process-data/index.ts +224 -0
- package/lib/process-data/normalize.ts +202 -0
- package/lib/process-data/privacy.ts +41 -0
- package/lib/process-data/reconcile.ts +110 -0
- package/lib/process-data/repair.ts +64 -0
- package/lib/process-data/sources.ts +354 -0
- package/lib/process-data/store.ts +315 -0
- package/lib/process-data/types.ts +135 -0
- package/lib/run/index.ts +5 -3
- package/lib/run/tui.ts +14 -12
- package/lib/sandbox/agent-client-reconciler.ts +44 -2
- package/lib/sandbox/capture.ts +9 -2
- package/lib/sandbox/commands/create.ts +126 -280
- package/lib/sandbox/commands/enter.ts +13 -59
- package/lib/sandbox/commands/list-running.ts +23 -6
- package/lib/sandbox/commands/ls.ts +22 -6
- package/lib/sandbox/commands/rebuild.ts +4 -3
- package/lib/sandbox/commands/refresh.ts +4 -126
- package/lib/sandbox/commands/rm.ts +24 -3
- package/lib/sandbox/commands/show.ts +30 -4
- package/lib/sandbox/commands/start.ts +6 -4
- package/lib/sandbox/config.ts +4 -0
- package/lib/sandbox/constants.ts +8 -0
- package/lib/sandbox/control/client.ts +55 -0
- package/lib/sandbox/control/protocol.ts +75 -0
- package/lib/sandbox/control/server.ts +117 -0
- package/lib/sandbox/dockerfile.ts +66 -13
- package/lib/sandbox/mounts.ts +24 -4
- package/lib/sandbox/recovery.ts +163 -6
- package/lib/sandbox/redaction.ts +14 -0
- package/lib/sandbox/runtimes/base.dockerfile +24 -74
- package/lib/sandbox/tool-types.ts +16 -0
- package/lib/sandbox/workspace-identity.ts +123 -0
- package/lib/sandbox/workspace-view.ts +143 -0
- package/lib/server/server.schema.json +2 -2
- package/lib/task/activity-intent.ts +417 -0
- package/lib/task/artifact-lifecycle.ts +2 -1
- package/lib/task/commands/log.ts +15 -14
- package/lib/task/commit-finalization.ts +356 -0
- package/lib/task/commit-intent.ts +230 -0
- package/lib/task/decision-intents.ts +32 -12
- package/lib/task/delegation-receipts.ts +34 -5
- package/lib/task/events.ts +75 -30
- package/lib/task/finalization-artifacts.ts +58 -0
- package/lib/task/implementation-inputs.ts +62 -8
- package/lib/task/ledger-intents.ts +43 -3
- package/lib/task/lifecycle-execution.ts +106 -0
- package/lib/task/orchestration.ts +1019 -72
- package/lib/task/resolve-ref.ts +46 -1
- package/lib/task/review-finalization.ts +40 -9
- package/lib/task/task-execution-lock.ts +296 -0
- package/lib/task/verification-checks.ts +1 -1
- package/lib/task/verification-engine.ts +249 -2
- package/lib/task/verification.ts +5 -3
- package/lib/task/workspace-snapshot.ts +26 -5
- package/package.json +3 -3
- package/templates/.agents/QUICKSTART.en.md +25 -8
- package/templates/.agents/QUICKSTART.zh-CN.md +25 -8
- package/templates/.agents/README.en.md +10 -7
- package/templates/.agents/README.zh-CN.md +10 -7
- package/templates/.agents/hooks/lifecycle-delegation.js +15 -4
- package/templates/.agents/rules/README.en.md +1 -1
- package/templates/.agents/rules/README.zh-CN.md +1 -1
- package/templates/.agents/rules/create-issue.github.en.md +4 -2
- package/templates/.agents/rules/create-issue.github.zh-CN.md +4 -2
- package/templates/.agents/rules/human-decision-context.en.md +11 -2
- package/templates/.agents/rules/human-decision-context.zh-CN.md +11 -2
- package/templates/.agents/rules/issue-fields.github.en.md +3 -1
- package/templates/.agents/rules/issue-fields.github.zh-CN.md +3 -1
- package/templates/.agents/rules/issue-pr-commands.en.md +5 -3
- package/templates/.agents/rules/issue-pr-commands.github.en.md +5 -3
- package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +5 -3
- package/templates/.agents/rules/issue-pr-commands.zh-CN.md +5 -3
- package/templates/.agents/rules/issue-sync.github.en.md +7 -3
- package/templates/.agents/rules/issue-sync.github.zh-CN.md +8 -4
- package/templates/.agents/rules/lifecycle-orchestration.en.md +5 -2
- package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +5 -2
- package/templates/.agents/rules/milestone-inference.github.en.md +4 -2
- package/templates/.agents/rules/milestone-inference.github.zh-CN.md +4 -2
- package/templates/.agents/rules/next-step-output.en.md +3 -1
- package/templates/.agents/rules/next-step-output.zh-CN.md +3 -1
- package/templates/.agents/rules/no-mid-flow-questions.en.md +17 -0
- package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +17 -0
- package/templates/.agents/rules/pr-checks-commands.en.md +3 -3
- package/templates/.agents/rules/pr-checks-commands.github.en.md +2 -2
- package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +3 -3
- package/templates/.agents/rules/pr-checks-commands.zh-CN.md +3 -3
- package/templates/.agents/rules/pr-sync.en.md +3 -1
- package/templates/.agents/rules/pr-sync.github.en.md +11 -1
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +11 -1
- package/templates/.agents/rules/pr-sync.zh-CN.md +3 -1
- package/templates/.agents/rules/release-commands.en.md +1 -1
- package/templates/.agents/rules/release-commands.github.en.md +12 -2
- package/templates/.agents/rules/release-commands.github.zh-CN.md +12 -2
- package/templates/.agents/rules/release-commands.zh-CN.md +1 -1
- package/templates/.agents/rules/review-handshake.zh-CN.md +1 -1
- package/templates/.agents/rules/task-management.en.md +13 -0
- package/templates/.agents/rules/task-management.zh-CN.md +13 -0
- package/templates/.agents/skills/analyze-task/SKILL.en.md +10 -7
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +10 -7
- package/templates/.agents/skills/block-task/SKILL.en.md +7 -5
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +7 -5
- package/templates/.agents/skills/cancel-task/SKILL.en.md +6 -4
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +6 -4
- package/templates/.agents/skills/close-codescan/SKILL.en.md +3 -1
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +3 -1
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +3 -1
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +3 -1
- package/templates/.agents/skills/code-task/SKILL.en.md +10 -7
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +12 -9
- package/templates/.agents/skills/commit/SKILL.en.md +23 -11
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +29 -11
- package/templates/.agents/skills/commit/reference/commit-message.en.md +1 -1
- package/templates/.agents/skills/commit/reference/commit-message.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +49 -0
- package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +55 -0
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +4 -4
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +4 -4
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +6 -4
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +6 -4
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +1 -1
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +1 -1
- package/templates/.agents/skills/complete-task/SKILL.en.md +22 -7
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +22 -7
- package/templates/.agents/skills/complete-task/config/verify.en.json +1 -0
- package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +17 -0
- package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +17 -0
- package/templates/.agents/skills/create-pr/SKILL.en.md +7 -5
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +7 -5
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +1 -1
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +1 -1
- package/templates/.agents/skills/create-release-note/SKILL.en.md +17 -16
- package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +17 -16
- package/templates/.agents/skills/create-task/SKILL.en.md +5 -3
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +5 -3
- package/templates/.agents/skills/create-task/reference/context-capture.en.md +34 -0
- package/templates/.agents/skills/create-task/reference/context-capture.zh-CN.md +34 -0
- package/templates/.agents/skills/import-issue/SKILL.en.md +5 -3
- package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +5 -3
- package/templates/.agents/skills/plan-task/SKILL.en.md +8 -5
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +8 -5
- package/templates/.agents/skills/post-release/SKILL.en.md +2 -0
- package/templates/.agents/skills/post-release/SKILL.zh-CN.md +2 -0
- package/templates/.agents/skills/release/SKILL.en.md +16 -10
- package/templates/.agents/skills/release/SKILL.zh-CN.md +16 -10
- package/templates/.agents/skills/restore-task/SKILL.en.md +4 -1
- package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +4 -1
- package/templates/.agents/skills/review-analysis/SKILL.en.md +7 -4
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +7 -4
- 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/reference/output-templates.en.md +1 -1
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +1 -1
- package/templates/.agents/skills/review-plan/SKILL.en.md +7 -4
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +7 -4
- package/templates/.agents/skills/review-pr/SKILL.en.md +186 -0
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +186 -0
- package/templates/.agents/skills/review-pr/config/verify.en.json +37 -0
- package/templates/.agents/skills/review-pr/config/verify.zh-CN.json +37 -0
- package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +65 -0
- package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +65 -0
- package/templates/.agents/skills/review-pr/reference/output-guidance.en.md +18 -0
- package/templates/.agents/skills/review-pr/reference/output-guidance.zh-CN.md +18 -0
- package/templates/.agents/skills/review-pr/reference/report-template.en.md +85 -0
- package/templates/.agents/skills/review-pr/reference/report-template.zh-CN.md +85 -0
- package/templates/.agents/skills/run-task/SKILL.en.md +8 -8
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +8 -8
- package/templates/.agents/skills/run-task/config/verify.en.json +2 -1
- package/templates/.agents/skills/run-task/config/verify.zh-CN.json +2 -1
- package/templates/.agents/skills/run-task/reference/host-validation.en.md +20 -0
- package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +20 -0
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +98 -107
- package/templates/.agents/skills/watch-pr/SKILL.en.md +13 -13
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +13 -13
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +27 -6
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +26 -5
- package/templates/.agents/templates/task.en.md +2 -2
- package/templates/.agents/templates/task.zh-CN.md +2 -2
- package/templates/.agents/workflows/bug-fix.en.yaml +3 -3
- package/templates/.agents/workflows/bug-fix.zh-CN.yaml +3 -3
- package/templates/.agents/workflows/code-review.en.yaml +1 -1
- package/templates/.agents/workflows/code-review.zh-CN.yaml +1 -1
- package/templates/.agents/workflows/feature-development.en.yaml +4 -4
- package/templates/.agents/workflows/feature-development.zh-CN.yaml +4 -4
- package/templates/.agents/workflows/refactoring.en.yaml +3 -3
- package/templates/.agents/workflows/refactoring.zh-CN.yaml +3 -3
- package/templates/.claude/commands/post-release.en.md +1 -0
- package/templates/.claude/commands/post-release.zh-CN.md +1 -0
- package/templates/.claude/commands/review-pr.en.md +8 -0
- package/templates/.claude/commands/review-pr.zh-CN.md +8 -0
- package/templates/.claude/commands/watch-pr.en.md +1 -1
- package/templates/.claude/commands/watch-pr.zh-CN.md +1 -1
- package/templates/.claude/rules/tool-preferences.en.md +20 -0
- package/templates/.claude/rules/tool-preferences.zh-CN.md +20 -0
- package/templates/.opencode/commands/post-release.en.md +2 -0
- package/templates/.opencode/commands/post-release.zh-CN.md +2 -0
- package/templates/.opencode/commands/review-pr.en.md +11 -0
- package/templates/.opencode/commands/review-pr.zh-CN.md +11 -0
- package/templates/.opencode/commands/watch-pr.en.md +1 -1
- package/templates/.opencode/commands/watch-pr.zh-CN.md +1 -1
- package/dist/lib/agent-clients/adapters/gemini-cli.js +0 -64
- package/lib/agent-clients/adapters/gemini-cli.ts +0 -65
- package/templates/.gemini/commands/_project_/analyze-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/analyze-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/archive-tasks.en.toml +0 -10
- package/templates/.gemini/commands/_project_/archive-tasks.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/block-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/block-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/cancel-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/cancel-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/check-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/check-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/close-codescan.en.toml +0 -8
- package/templates/.gemini/commands/_project_/close-codescan.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/close-dependabot.en.toml +0 -8
- package/templates/.gemini/commands/_project_/close-dependabot.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/code-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/code-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/commit.en.toml +0 -10
- package/templates/.gemini/commands/_project_/commit.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-manual-validation.en.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-manual-validation.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/create-pr.en.toml +0 -10
- package/templates/.gemini/commands/_project_/create-pr.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/create-release-note.en.toml +0 -8
- package/templates/.gemini/commands/_project_/create-release-note.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/create-task.en.toml +0 -8
- package/templates/.gemini/commands/_project_/create-task.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/import-codescan.en.toml +0 -8
- package/templates/.gemini/commands/_project_/import-codescan.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/import-dependabot.en.toml +0 -8
- package/templates/.gemini/commands/_project_/import-dependabot.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/import-issue.en.toml +0 -8
- package/templates/.gemini/commands/_project_/import-issue.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/init-labels.en.toml +0 -8
- package/templates/.gemini/commands/_project_/init-labels.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/init-milestones.en.toml +0 -10
- package/templates/.gemini/commands/_project_/init-milestones.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/plan-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/plan-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/post-release.en.toml +0 -6
- package/templates/.gemini/commands/_project_/post-release.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/refine-title.en.toml +0 -8
- package/templates/.gemini/commands/_project_/refine-title.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/release.en.toml +0 -8
- package/templates/.gemini/commands/_project_/release.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/restore-task.en.toml +0 -8
- package/templates/.gemini/commands/_project_/restore-task.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/review-analysis.en.toml +0 -10
- package/templates/.gemini/commands/_project_/review-analysis.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/review-code.en.toml +0 -10
- package/templates/.gemini/commands/_project_/review-code.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/review-plan.en.toml +0 -10
- package/templates/.gemini/commands/_project_/review-plan.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/run-task.en.toml +0 -8
- package/templates/.gemini/commands/_project_/run-task.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/test-integration.en.toml +0 -6
- package/templates/.gemini/commands/_project_/test-integration.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/test.en.toml +0 -6
- package/templates/.gemini/commands/_project_/test.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/update-agent-infra.en.toml +0 -6
- package/templates/.gemini/commands/_project_/update-agent-infra.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/upgrade-dependency.en.toml +0 -8
- package/templates/.gemini/commands/_project_/upgrade-dependency.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/watch-pr.en.toml +0 -10
- package/templates/.gemini/commands/_project_/watch-pr.zh-CN.toml +0 -10
- package/templates/.gemini/settings.json +0 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { inspectPlatformPullRequestByNumber } from '../platform/pull-requests.ts';
|
|
5
|
+
import { listPrReviews, publishPrReview } from '../platform/pr-review.ts';
|
|
6
|
+
import type { PrReviewEvent } from '../platform/pr-review.ts';
|
|
7
|
+
import type { PlatformResult } from '../platform/types.ts';
|
|
8
|
+
|
|
9
|
+
const USAGE = `Usage: agent-infra-internal platform-pr-review inspect --pr <N> [--cwd <path>]
|
|
10
|
+
agent-infra-internal platform-pr-review list --pr <N> [--cwd <path>]
|
|
11
|
+
agent-infra-internal platform-pr-review publish --pr <N> --scope <taskId|pr{N}> --round <N> --commit <sha> --event <COMMENT|APPROVE|REQUEST_CHANGES> --body-file <path|-> [--dry-run] [--cwd <path>]
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
const BOOLEAN_FLAGS = new Set(['--dry-run']);
|
|
15
|
+
const VALUE_FLAGS = new Set(['--cwd', '--pr', '--scope', '--round', '--commit', '--event', '--body-file']);
|
|
16
|
+
|
|
17
|
+
function key(flag: string): string {
|
|
18
|
+
return flag.slice(2).replace(/-([a-z])/g, (_, letter: string) => letter.toUpperCase());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function fail(message: string): void {
|
|
22
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'PR_REVIEW_PAYLOAD_INVALID', message } })}\n`);
|
|
23
|
+
process.stderr.write(USAGE);
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function finish(output: PlatformResult): void {
|
|
28
|
+
process.stdout.write(`${JSON.stringify(output)}\n`);
|
|
29
|
+
if (output.status === 'failed') process.exitCode = 1;
|
|
30
|
+
if (output.status === 'blocked') process.exitCode = 2;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function parse(args: string[], start: number) {
|
|
34
|
+
const values: Record<string, string | boolean> = {};
|
|
35
|
+
const seen = new Set<string>();
|
|
36
|
+
for (let index = start; index < args.length; index += 1) {
|
|
37
|
+
const flag = args[index]!;
|
|
38
|
+
if (!BOOLEAN_FLAGS.has(flag) && !VALUE_FLAGS.has(flag)) return { values, error: `unknown option '${flag}'` };
|
|
39
|
+
if (seen.has(flag)) return { values, error: `duplicate option '${flag}'` };
|
|
40
|
+
seen.add(flag);
|
|
41
|
+
if (BOOLEAN_FLAGS.has(flag)) { values[key(flag)] = true; continue; }
|
|
42
|
+
const value = args[++index];
|
|
43
|
+
if (value === undefined || value.startsWith('--')) return { values, error: `option '${flag}' requires a value` };
|
|
44
|
+
values[key(flag)] = value;
|
|
45
|
+
}
|
|
46
|
+
return { values };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function readBodyFile(value: string, cwd: string): string {
|
|
50
|
+
return value === '-' ? fs.readFileSync(0, 'utf8') : fs.readFileSync(path.resolve(cwd, value), 'utf8');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function platformPrReview(args: string[] = []): void {
|
|
54
|
+
if (args[0] === '--help' || args[0] === '-h') { process.stdout.write(USAGE); return; }
|
|
55
|
+
const operation = args[0];
|
|
56
|
+
if (!operation || !['inspect', 'list', 'publish'].includes(operation)) { fail('a valid operation is required'); return; }
|
|
57
|
+
const parsed = parse(args, 1);
|
|
58
|
+
if (parsed.error) { fail(parsed.error); return; }
|
|
59
|
+
const values = parsed.values;
|
|
60
|
+
const cwd = path.resolve(typeof values.cwd === 'string' ? values.cwd : process.cwd());
|
|
61
|
+
const allowed: Record<string, string[]> = {
|
|
62
|
+
inspect: ['cwd', 'pr'],
|
|
63
|
+
list: ['cwd', 'pr'],
|
|
64
|
+
publish: ['cwd', 'pr', 'scope', 'round', 'commit', 'event', 'bodyFile', 'dryRun']
|
|
65
|
+
};
|
|
66
|
+
const unexpected = Object.keys(values).find((name) => !allowed[operation]!.includes(name));
|
|
67
|
+
if (unexpected) { fail(`${operation} does not accept --${unexpected}`); return; }
|
|
68
|
+
const pr = Number(values.pr);
|
|
69
|
+
if (!Number.isInteger(pr) || pr <= 0) { fail(`${operation} requires a positive --pr`); return; }
|
|
70
|
+
if (operation === 'inspect') {
|
|
71
|
+
finish(inspectPlatformPullRequestByNumber(pr, { cwd }));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (operation === 'list') {
|
|
75
|
+
finish(listPrReviews(pr, { cwd }));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const scope = typeof values.scope === 'string' ? values.scope : '';
|
|
79
|
+
const round = Number(values.round);
|
|
80
|
+
const commit = typeof values.commit === 'string' ? values.commit : '';
|
|
81
|
+
const event = values.event as string;
|
|
82
|
+
if (!scope || !/^(?:pr\d+|TASK-\d{8}-\d{6})$/.test(scope)) { fail('publish requires --scope <taskId|pr{N}>'); return; }
|
|
83
|
+
if (!Number.isInteger(round) || round <= 0) { fail('publish requires a positive --round'); return; }
|
|
84
|
+
if (!/^[0-9a-f]{7,40}$/i.test(commit)) { fail('publish requires --commit <sha>'); return; }
|
|
85
|
+
if (!['COMMENT', 'APPROVE', 'REQUEST_CHANGES'].includes(event)) { fail('publish requires --event <COMMENT|APPROVE|REQUEST_CHANGES>'); return; }
|
|
86
|
+
if (typeof values.bodyFile !== 'string') { fail('publish requires --body-file'); return; }
|
|
87
|
+
let body: string;
|
|
88
|
+
try {
|
|
89
|
+
body = readBodyFile(values.bodyFile, cwd);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
fail(`unable to read body file: ${error instanceof Error ? error.message : String(error)}`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
finish(publishPrReview({
|
|
95
|
+
cwd,
|
|
96
|
+
prNumber: pr,
|
|
97
|
+
identity: { scope, round, commitSha: commit },
|
|
98
|
+
event: event as PrReviewEvent,
|
|
99
|
+
body,
|
|
100
|
+
dryRun: values.dryRun === true
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { platformPrReview };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
+
import { normalizeAgentToken, AGENT_USAGE_HINT } from '../agent-clients/tokens.ts';
|
|
4
5
|
import {
|
|
5
6
|
bindPlatformPullRequest,
|
|
6
7
|
createPlatformPullRequest,
|
|
7
8
|
inspectPlatformPullRequest,
|
|
9
|
+
resolveExternalPullRequest,
|
|
8
10
|
syncPlatformPullRequest
|
|
9
11
|
} from '../platform/pull-requests.ts';
|
|
10
12
|
import type { PullRequestResult } from '../platform/pull-requests.ts';
|
|
@@ -12,6 +14,7 @@ import { summaryContext, syncPullRequestSummary } from '../platform/pr-summary.t
|
|
|
12
14
|
import type { PlatformResult } from '../platform/types.ts';
|
|
13
15
|
|
|
14
16
|
const USAGE = `Usage: agent-infra-internal platform-pr inspect <task-ref> [--cwd <path>]
|
|
17
|
+
agent-infra-internal platform-pr resolve-external <task-ref> --agent <agent> [--pr <N>] [--dry-run] [--cwd <path>]
|
|
15
18
|
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>]
|
|
16
19
|
agent-infra-internal platform-pr bind <task-ref> --pr <N> --agent <agent> [--dry-run] [--cwd <path>]
|
|
17
20
|
agent-infra-internal platform-pr sync <task-ref> --agent <agent> [--metadata] [--closing-issue] [--dry-run] [--cwd <path>]
|
|
@@ -61,7 +64,7 @@ function readFile(value: string, cwd: string): string {
|
|
|
61
64
|
function platformPr(args: string[] = []): void {
|
|
62
65
|
if (args[0] === '--help' || args[0] === '-h') { process.stdout.write(USAGE); return; }
|
|
63
66
|
const operation = args[0];
|
|
64
|
-
if (!operation || !['inspect', 'create', 'bind', 'sync', 'summary-context', 'summary-sync'].includes(operation)) { fail('a valid operation is required'); return; }
|
|
67
|
+
if (!operation || !['inspect', 'resolve-external', 'create', 'bind', 'sync', 'summary-context', 'summary-sync'].includes(operation)) { fail('a valid operation is required'); return; }
|
|
65
68
|
const taskRef = args[1];
|
|
66
69
|
if (!taskRef || taskRef.startsWith('--')) { fail(`${operation} requires a task ref`); return; }
|
|
67
70
|
const parsed = parse(args, 2);
|
|
@@ -70,6 +73,7 @@ function platformPr(args: string[] = []): void {
|
|
|
70
73
|
const cwd = path.resolve(typeof values.cwd === 'string' ? values.cwd : process.cwd());
|
|
71
74
|
const allowed: Record<string, string[]> = {
|
|
72
75
|
inspect: ['cwd'],
|
|
76
|
+
'resolve-external': ['cwd', 'agent', 'pr', 'dryRun'],
|
|
73
77
|
create: ['cwd', 'agent', 'base', 'head', 'titleFile', 'bodyFile', 'draft', 'dryRun'],
|
|
74
78
|
bind: ['cwd', 'agent', 'pr', 'dryRun'],
|
|
75
79
|
sync: ['cwd', 'agent', 'metadata', 'closingIssue', 'dryRun'],
|
|
@@ -81,6 +85,15 @@ function platformPr(args: string[] = []): void {
|
|
|
81
85
|
if (operation === 'inspect') { finish(inspectPlatformPullRequest(taskRef, { cwd })); return; }
|
|
82
86
|
if (operation === 'summary-context') { finish(summaryContext(taskRef, { cwd })); return; }
|
|
83
87
|
if (typeof values.agent !== 'string' || !values.agent) { fail(`${operation} requires --agent`); return; }
|
|
88
|
+
const agent = normalizeAgentToken(values.agent);
|
|
89
|
+
if (!agent) { fail(`invalid --agent '${values.agent}': ${AGENT_USAGE_HINT}`); return; }
|
|
90
|
+
values.agent = agent;
|
|
91
|
+
if (operation === 'resolve-external') {
|
|
92
|
+
const pr = values.pr === undefined ? undefined : Number(values.pr);
|
|
93
|
+
if (pr !== undefined && (!Number.isInteger(pr) || pr <= 0)) { fail('resolve-external requires a positive --pr'); return; }
|
|
94
|
+
finish(resolveExternalPullRequest(taskRef, { cwd, agent: values.agent, pr, dryRun: values.dryRun === true }));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
84
97
|
if (operation === 'bind') {
|
|
85
98
|
const pr = Number(values.pr);
|
|
86
99
|
if (!Number.isInteger(pr) || pr <= 0) { fail('bind requires a positive --pr'); return; }
|
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
-
import { publishReleaseNotes, releaseNoteContext } from '../platform/release-notes.ts';
|
|
4
|
+
import { publishReleaseNotes, releaseNoteContext, stageReleaseNotes } from '../platform/release-notes.ts';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
type ParsedOptions = Readonly<{ values: ReadonlyMap<string, string>; switches: ReadonlySet<string> }>;
|
|
7
|
+
|
|
8
|
+
function parseOptions(
|
|
9
|
+
args: string[],
|
|
10
|
+
valueFlags: readonly string[],
|
|
11
|
+
switchFlags: readonly string[] = []
|
|
12
|
+
): ParsedOptions | null {
|
|
13
|
+
const values = new Map<string, string>();
|
|
14
|
+
const switches = new Set<string>();
|
|
15
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
16
|
+
const flag = args[index]!;
|
|
17
|
+
if (values.has(flag) || switches.has(flag)) return null;
|
|
18
|
+
if (switchFlags.includes(flag)) {
|
|
19
|
+
switches.add(flag);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (!valueFlags.includes(flag)) return null;
|
|
23
|
+
const value = args[++index];
|
|
24
|
+
if (!value || value.startsWith('--')) return null;
|
|
25
|
+
values.set(flag, value);
|
|
26
|
+
}
|
|
27
|
+
return { values, switches };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function invalidInput(message: string) {
|
|
31
|
+
return { status: 'failed', changed: false, error: { code: 'RELEASE_NOTES_INPUT_INVALID', message, retryable: false } };
|
|
9
32
|
}
|
|
10
33
|
|
|
11
34
|
function finish(result: { status: string; [key: string]: unknown }): void {
|
|
@@ -15,21 +38,40 @@ function finish(result: { status: string; [key: string]: unknown }): void {
|
|
|
15
38
|
|
|
16
39
|
function platformReleaseNotes(args: string[] = []): void {
|
|
17
40
|
const [action, ...rest] = args;
|
|
18
|
-
const cwd = path.resolve(option(rest, '--cwd') || process.cwd());
|
|
19
41
|
if (action === 'context') {
|
|
20
|
-
const
|
|
42
|
+
const parsed = parseOptions(rest, ['--cwd', '--history-limit', '--from-tag', '--to-tag', '--branch']);
|
|
43
|
+
if (!parsed) return finish(invalidInput('invalid context options'));
|
|
44
|
+
const cwd = path.resolve(parsed.values.get('--cwd') || process.cwd());
|
|
45
|
+
const historyRaw = parsed.values.get('--history-limit') ?? null;
|
|
21
46
|
finish(releaseNoteContext({
|
|
22
|
-
fromTag:
|
|
23
|
-
toTag:
|
|
24
|
-
branch:
|
|
47
|
+
fromTag: parsed.values.get('--from-tag') || '',
|
|
48
|
+
toTag: parsed.values.get('--to-tag') || '',
|
|
49
|
+
branch: parsed.values.get('--branch') || '',
|
|
25
50
|
historyLimit: historyRaw === null ? undefined : Number(historyRaw)
|
|
26
51
|
}, { cwd }));
|
|
27
52
|
return;
|
|
28
53
|
}
|
|
54
|
+
if (action === 'stage') {
|
|
55
|
+
const parsed = parseOptions(rest, ['--cwd', '--notes-file']);
|
|
56
|
+
if (!parsed) return finish(invalidInput('invalid stage options'));
|
|
57
|
+
const notesFile = parsed.values.get('--notes-file');
|
|
58
|
+
if (!notesFile) return finish(invalidInput('notes-file is required'));
|
|
59
|
+
finish(stageReleaseNotes(
|
|
60
|
+
{ notesFile },
|
|
61
|
+
{ cwd: path.resolve(parsed.values.get('--cwd') || process.cwd()) }
|
|
62
|
+
));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
29
65
|
if (action === 'publish') {
|
|
30
|
-
const
|
|
66
|
+
const parsed = parseOptions(
|
|
67
|
+
rest,
|
|
68
|
+
['--cwd', '--notes-file', '--tag', '--title', '--expected-sha256'],
|
|
69
|
+
['--dry-run']
|
|
70
|
+
);
|
|
71
|
+
if (!parsed) return finish(invalidInput('invalid publish options'));
|
|
72
|
+
const notesPath = parsed.values.get('--notes-file');
|
|
31
73
|
if (!notesPath) {
|
|
32
|
-
finish(
|
|
74
|
+
finish(invalidInput('notes-file is required'));
|
|
33
75
|
return;
|
|
34
76
|
}
|
|
35
77
|
let resolvedNotesPath = notesPath;
|
|
@@ -39,17 +81,18 @@ function platformReleaseNotes(args: string[] = []): void {
|
|
|
39
81
|
}
|
|
40
82
|
try {
|
|
41
83
|
finish(publishReleaseNotes({
|
|
42
|
-
tag:
|
|
43
|
-
title:
|
|
84
|
+
tag: parsed.values.get('--tag') || '',
|
|
85
|
+
title: parsed.values.get('--title') || parsed.values.get('--tag') || '',
|
|
44
86
|
notesFile: resolvedNotesPath,
|
|
45
|
-
|
|
46
|
-
|
|
87
|
+
expectedSha256: parsed.values.get('--expected-sha256') || '',
|
|
88
|
+
dryRun: parsed.switches.has('--dry-run')
|
|
89
|
+
}, { cwd: path.resolve(parsed.values.get('--cwd') || process.cwd()) }));
|
|
47
90
|
} finally {
|
|
48
91
|
if (notesPath === '-') fs.rmSync(resolvedNotesPath, { force: true });
|
|
49
92
|
}
|
|
50
93
|
return;
|
|
51
94
|
}
|
|
52
|
-
finish(
|
|
95
|
+
finish(invalidInput('Usage: platform-release-notes context|stage|publish'));
|
|
53
96
|
}
|
|
54
97
|
|
|
55
98
|
export { platformReleaseNotes };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
collectHostCandidates,
|
|
6
|
+
decide,
|
|
7
|
+
deriveTaskIssueMatches,
|
|
8
|
+
extractClosingIssueNumbers,
|
|
9
|
+
resolveHostFromCandidates
|
|
10
|
+
} from '../pr-review/evidence-grading.ts';
|
|
11
|
+
import type { DecisionRecord, HostResolution } from '../pr-review/evidence-grading.ts';
|
|
12
|
+
import { inspectPlatformPullRequestByNumber } from '../platform/pull-requests.ts';
|
|
13
|
+
import { verifyInProcess } from '../task/verification-engine.ts';
|
|
14
|
+
|
|
15
|
+
const USAGE = `Usage: agent-infra-internal pr-review-grade decide --input-file <path|-> [--cwd <path>]
|
|
16
|
+
agent-infra-internal pr-review-grade resolve-host --pr <N> [--cwd <path>]
|
|
17
|
+
agent-infra-internal pr-review-grade verify-artifact --artifact-file <path> [--cwd <path>]
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
function fail(message: string): void {
|
|
21
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'PR_REVIEW_GRADE_INVALID', message } })}\n`);
|
|
22
|
+
process.stderr.write(USAGE);
|
|
23
|
+
process.exitCode = 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function finish(result: unknown, exitCode = 0): void {
|
|
27
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
28
|
+
if (exitCode !== 0) process.exitCode = exitCode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parseFlags(args: string[], start: number): { values: Record<string, string | boolean>; error?: string } {
|
|
32
|
+
const values: Record<string, string | boolean> = {};
|
|
33
|
+
const seen = new Set<string>();
|
|
34
|
+
for (let index = start; index < args.length; index += 1) {
|
|
35
|
+
const flag = args[index]!;
|
|
36
|
+
if (!['--input-file', '--artifact-file', '--cwd', '--pr'].includes(flag)) {
|
|
37
|
+
return { values, error: `unknown option '${flag}'` };
|
|
38
|
+
}
|
|
39
|
+
if (seen.has(flag)) return { values, error: `duplicate option '${flag}'` };
|
|
40
|
+
seen.add(flag);
|
|
41
|
+
const value = args[++index];
|
|
42
|
+
if (value === undefined || value.startsWith('--')) return { values, error: `option '${flag}' requires a value` };
|
|
43
|
+
values[flag.slice(2).replace(/-([a-z])/g, (_, letter: string) => letter.toUpperCase())] = value;
|
|
44
|
+
}
|
|
45
|
+
return { values };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function readInput(value: string, cwd: string): string {
|
|
49
|
+
return value === '-' ? fs.readFileSync(0, 'utf8') : fs.readFileSync(path.resolve(cwd, value), 'utf8');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function prReviewGrade(args: string[] = []): void {
|
|
53
|
+
if (args[0] === '--help' || args[0] === '-h') { process.stdout.write(USAGE); return; }
|
|
54
|
+
const operation = args[0];
|
|
55
|
+
if (!operation || !['decide', 'resolve-host', 'verify-artifact'].includes(operation)) { fail('a valid operation is required'); return; }
|
|
56
|
+
const parsed = parseFlags(args, 1);
|
|
57
|
+
if (parsed.error) { fail(parsed.error); return; }
|
|
58
|
+
const values = parsed.values;
|
|
59
|
+
const cwd = path.resolve(typeof values.cwd === 'string' ? values.cwd : process.cwd());
|
|
60
|
+
const allowed: Record<string, string[]> = {
|
|
61
|
+
decide: ['cwd', 'inputFile'],
|
|
62
|
+
'resolve-host': ['cwd', 'pr'],
|
|
63
|
+
'verify-artifact': ['cwd', 'artifactFile']
|
|
64
|
+
};
|
|
65
|
+
const unexpected = Object.keys(values).find((key) => !allowed[operation]!.includes(key));
|
|
66
|
+
if (unexpected) { fail(`${operation} does not accept '--${unexpected}'`); return; }
|
|
67
|
+
|
|
68
|
+
if (operation === 'decide') {
|
|
69
|
+
if (typeof values.inputFile !== 'string') { fail('decide requires --input-file'); return; }
|
|
70
|
+
let input: unknown;
|
|
71
|
+
try {
|
|
72
|
+
input = JSON.parse(readInput(values.inputFile, cwd));
|
|
73
|
+
} catch (error) {
|
|
74
|
+
fail(`unable to read decide input: ${error instanceof Error ? error.message : String(error)}`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const record: DecisionRecord = decide(input as Parameters<typeof decide>[0]);
|
|
79
|
+
finish(record);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
const code = error && typeof error === 'object' && 'code' in error ? String(error.code) : 'DECIDE_FAILED';
|
|
82
|
+
finish({ status: 'failed', changed: false, error: { code, message: error instanceof Error ? error.message : String(error) } }, 1);
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (operation === 'resolve-host') {
|
|
88
|
+
const pr = Number(values.pr);
|
|
89
|
+
if (!Number.isInteger(pr) || pr <= 0) { fail('resolve-host requires a positive --pr'); return; }
|
|
90
|
+
const inspected = inspectPlatformPullRequestByNumber(pr, { cwd });
|
|
91
|
+
if (!inspected.pullRequest) {
|
|
92
|
+
finish({
|
|
93
|
+
status: 'failed', changed: false, host: null, candidates: [], closingIssues: [],
|
|
94
|
+
error: inspected.error ?? { code: 'PR_INSPECTION_INVALID', message: 'unable to inspect the pull request', retryable: false }
|
|
95
|
+
}, inspected.status === 'blocked' ? 2 : 1);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const closingIssues = extractClosingIssueNumbers(inspected.pullRequest.body);
|
|
99
|
+
const candidates = collectHostCandidates({ prNumber: pr, closingIssues, workspaceRoot: cwd });
|
|
100
|
+
const host: HostResolution = resolveHostFromCandidates(candidates);
|
|
101
|
+
finish({
|
|
102
|
+
status: 'ok', changed: false,
|
|
103
|
+
pr: { number: pr, baseSha: inspected.pullRequest.base.sha, headSha: inspected.pullRequest.head.sha, state: inspected.pullRequest.state },
|
|
104
|
+
closingIssues, candidates, host,
|
|
105
|
+
taskIssueMatches: deriveTaskIssueMatches(host, closingIssues), error: null
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (typeof values.artifactFile !== 'string') { fail('verify-artifact requires --artifact-file'); return; }
|
|
111
|
+
const artifactPath = path.resolve(cwd, values.artifactFile);
|
|
112
|
+
let result: Record<string, unknown>;
|
|
113
|
+
try {
|
|
114
|
+
result = verifyInProcess({
|
|
115
|
+
mode: 'checks',
|
|
116
|
+
skillName: 'review-pr',
|
|
117
|
+
taskDir: path.dirname(artifactPath),
|
|
118
|
+
artifactFile: path.basename(artifactPath),
|
|
119
|
+
checks: ['artifact'],
|
|
120
|
+
repositoryRoot: cwd
|
|
121
|
+
}) as Record<string, unknown>;
|
|
122
|
+
} catch (error) {
|
|
123
|
+
finish({ status: 'failed', changed: false, error: { code: 'VERIFY_ARTIFACT_INVALID', message: error instanceof Error ? error.message : String(error) } }, 1);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const status = result.status as 'pass' | 'fail' | 'blocked';
|
|
127
|
+
finish(result, ({ pass: 0, fail: 1, blocked: 2 } as const)[status]);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { prReviewGrade };
|
|
@@ -150,9 +150,10 @@ function runOptionalDemo(cwd: string, run: CommandRunner = command): DemoResult
|
|
|
150
150
|
return { status: 'recorded', reasonCode: null, message: null, outputPath };
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
function git(cwd: string, args: string[], run: CommandRunner = command): string | null {
|
|
153
|
+
function git(cwd: string, args: string[], run: CommandRunner = command, trim = true): string | null {
|
|
154
154
|
const result = run(cwd, 'git', args);
|
|
155
|
-
|
|
155
|
+
const stdout = String(result.stdout);
|
|
156
|
+
return result.status === 0 ? (trim ? stdout.trim() : stdout) : null;
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
function inspectLocalReleaseFacts(cwd: string, version: string, run: CommandRunner = command) {
|
|
@@ -228,9 +229,15 @@ async function inspectFacts(cwd: string, version: string): Promise<ReleaseFacts>
|
|
|
228
229
|
};
|
|
229
230
|
}
|
|
230
231
|
|
|
231
|
-
function
|
|
232
|
-
const
|
|
233
|
-
|
|
232
|
+
function parsePorcelainPath(record: string): string {
|
|
233
|
+
const match = /^.. (.+)$/.exec(record);
|
|
234
|
+
if (!match) throw new Error('Invalid git status --porcelain=v1 record');
|
|
235
|
+
return match[1]!;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function changedPaths(cwd: string, run: CommandRunner = command): string[] {
|
|
239
|
+
const output = git(cwd, ['status', '--porcelain=v1'], run, false) || '';
|
|
240
|
+
return output.split(/\r?\n/).filter(Boolean).map(parsePorcelainPath).filter((value, index, all) => all.indexOf(value) === index);
|
|
234
241
|
}
|
|
235
242
|
|
|
236
243
|
function updateReleaseMetadata(cwd: string, version: string): void {
|
|
@@ -336,5 +343,5 @@ async function releaseWorkflow(args: string[] = []): Promise<void> {
|
|
|
336
343
|
process.stdout.write(`${JSON.stringify({ ...pushed, demo, snapshot: releaseSnapshot(version, await inspectFacts(cwd, version)) })}\n`); process.exitCode = pushed.status === 'failed' ? 1 : pushed.status === 'degraded' ? 2 : 0;
|
|
337
344
|
}
|
|
338
345
|
|
|
339
|
-
export { computeDemoInputDigest, inspectFacts, inspectLocalReleaseFacts, inspectPostWorktree, releaseSmokeStatus, releaseWorkflow, runOptionalDemo };
|
|
346
|
+
export { changedPaths, computeDemoInputDigest, inspectFacts, inspectLocalReleaseFacts, inspectPostWorktree, releaseSmokeStatus, releaseWorkflow, runOptionalDemo };
|
|
340
347
|
export type { CommandRunner, DemoResult };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { requestSandboxControl } from '../sandbox/control/client.ts';
|
|
2
|
+
import { serveSandboxControl } from '../sandbox/control/server.ts';
|
|
3
|
+
|
|
4
|
+
function sandboxControl(args: string[]): void {
|
|
5
|
+
const [operation, ...rest] = args;
|
|
6
|
+
if (operation === 'serve') {
|
|
7
|
+
const manifestIndex = rest.indexOf('--manifest');
|
|
8
|
+
const manifest = manifestIndex >= 0 ? rest[manifestIndex + 1] : undefined;
|
|
9
|
+
if (!manifest) throw new Error('sandbox-control serve requires --manifest');
|
|
10
|
+
serveSandboxControl(manifest);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (operation === 'client') {
|
|
14
|
+
const [family = '', ...commandArgs] = rest;
|
|
15
|
+
const response = requestSandboxControl({ family, args: commandArgs });
|
|
16
|
+
process.stdout.write(response.stdout);
|
|
17
|
+
process.stderr.write(response.stderr);
|
|
18
|
+
process.exitCode = response.exitCode;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
throw new Error('Usage: agent-infra-internal sandbox-control serve --manifest <path> | client <family> [args...]');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { sandboxControl };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyPrReviewActivityIntent,
|
|
3
|
+
inspectPrReviewActivity
|
|
4
|
+
} from '../task/activity-intent.ts';
|
|
5
|
+
import type {
|
|
6
|
+
PrReviewActivityIntent,
|
|
7
|
+
PrReviewInspectIntent
|
|
8
|
+
} from '../task/activity-intent.ts';
|
|
9
|
+
|
|
10
|
+
const USAGE = `Usage: agent-infra-internal task-activity <task-ref> pr-review-inspect
|
|
11
|
+
agent-infra-internal task-activity <task-ref> pr-review-start --agent <agent> --artifact <canonical.md> --head <40hex> [--dry-run]
|
|
12
|
+
agent-infra-internal task-activity <task-ref> pr-review-complete --agent <agent> --artifact <canonical.md> --head <40hex> --verdict <approved|changes-requested|commented> --blockers <N> --major <N> --minor <N> [--dry-run]
|
|
13
|
+
agent-infra-internal task-activity <task-ref> pr-review-terminate --agent <agent> --artifact <canonical.md> --head <40hex> --outcome <aborted|superseded> --reason <single-line> [--dry-run]
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const OPERATIONS = new Set(['pr-review-inspect', 'pr-review-start', 'pr-review-complete', 'pr-review-terminate']);
|
|
17
|
+
const FLAGS: Record<string, string> = {
|
|
18
|
+
'--agent': 'agent',
|
|
19
|
+
'--artifact': 'artifact',
|
|
20
|
+
'--head': 'head',
|
|
21
|
+
'--verdict': 'verdict',
|
|
22
|
+
'--blockers': 'blockers',
|
|
23
|
+
'--major': 'major',
|
|
24
|
+
'--minor': 'minor',
|
|
25
|
+
'--outcome': 'outcome',
|
|
26
|
+
'--reason': 'reason'
|
|
27
|
+
};
|
|
28
|
+
const COMMON = ['agent', 'artifact', 'head'] as const;
|
|
29
|
+
const ALLOWED: Record<string, ReadonlySet<string>> = {
|
|
30
|
+
'pr-review-inspect': new Set(['kind', 'taskRef']),
|
|
31
|
+
'pr-review-start': new Set(['kind', 'taskRef', 'agent', 'artifact', 'head', 'dryRun']),
|
|
32
|
+
'pr-review-complete': new Set(['kind', 'taskRef', 'agent', 'artifact', 'head', 'verdict', 'blockers', 'major', 'minor', 'dryRun']),
|
|
33
|
+
'pr-review-terminate': new Set(['kind', 'taskRef', 'agent', 'artifact', 'head', 'outcome', 'reason', 'dryRun'])
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function usageFailure(message: string): void {
|
|
37
|
+
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'ACTIVITY_PAYLOAD_INVALID', message } })}\n`);
|
|
38
|
+
process.stderr.write(USAGE);
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function taskActivity(args: string[] = []): void {
|
|
43
|
+
if (args[0] === '--help' || args[0] === '-h') { process.stdout.write(USAGE); return; }
|
|
44
|
+
const [taskRef, kind] = args;
|
|
45
|
+
if (!taskRef || taskRef.startsWith('--') || !kind || !OPERATIONS.has(kind)) {
|
|
46
|
+
usageFailure('task ref and a supported PR review intent are required');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const values: Record<string, unknown> = { kind, taskRef };
|
|
50
|
+
const seen = new Set<string>();
|
|
51
|
+
for (let index = 2; index < args.length; index += 1) {
|
|
52
|
+
const flag = args[index]!;
|
|
53
|
+
if (flag === '--dry-run') {
|
|
54
|
+
if (seen.has(flag)) { usageFailure(`duplicate option '${flag}'`); return; }
|
|
55
|
+
seen.add(flag);
|
|
56
|
+
values.dryRun = true;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const key = FLAGS[flag];
|
|
60
|
+
if (!key) { usageFailure(`unknown option '${flag}'`); return; }
|
|
61
|
+
if (seen.has(flag)) { usageFailure(`duplicate option '${flag}'`); return; }
|
|
62
|
+
const value = args[++index];
|
|
63
|
+
if (value === undefined || value.startsWith('--')) { usageFailure(`option '${flag}' requires a value`); return; }
|
|
64
|
+
seen.add(flag);
|
|
65
|
+
values[key] = ['blockers', 'major', 'minor'].includes(key) ? Number(value) : value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const allowed = ALLOWED[kind]!;
|
|
69
|
+
const unexpected = Object.keys(values).find((key) => !allowed.has(key));
|
|
70
|
+
if (unexpected) { usageFailure(`${kind} does not accept '${unexpected}'`); return; }
|
|
71
|
+
if (kind === 'pr-review-inspect') {
|
|
72
|
+
const result = inspectPrReviewActivity(values as PrReviewInspectIntent);
|
|
73
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
74
|
+
if (result.status === 'failed') process.exitCode = 1;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
for (const key of COMMON) {
|
|
78
|
+
if (values[key] === undefined) { usageFailure(`${kind} requires '${key}'`); return; }
|
|
79
|
+
}
|
|
80
|
+
const operationRequired = kind === 'pr-review-complete'
|
|
81
|
+
? ['verdict', 'blockers', 'major', 'minor']
|
|
82
|
+
: kind === 'pr-review-terminate' ? ['outcome', 'reason'] : [];
|
|
83
|
+
for (const key of operationRequired) {
|
|
84
|
+
if (values[key] === undefined) { usageFailure(`${kind} requires '${key}'`); return; }
|
|
85
|
+
}
|
|
86
|
+
const result = applyPrReviewActivityIntent(values as PrReviewActivityIntent);
|
|
87
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
88
|
+
if (result.status === 'failed') process.exitCode = 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { taskActivity };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { normalizeAgentToken, AGENT_USAGE_HINT } from '../agent-clients/tokens.ts';
|
|
1
2
|
import { applyTaskEvent, eventCatalog } from '../task/events.ts';
|
|
2
3
|
import type { TaskEventRequest, Verdict } from '../task/events.ts';
|
|
3
4
|
|
|
4
|
-
const USAGE = `Usage: agent-infra-internal task-event <N | TASK-id> <event> --agent <agent> [event options] [--dry-run]
|
|
5
|
+
const USAGE = `Usage: agent-infra-internal task-event <N | TASK-id> <event> --agent <agent> [event options] [--orchestrated] [--dry-run]
|
|
5
6
|
|
|
6
7
|
Apply one closed-set task lifecycle event and print a structured JSON result.
|
|
7
8
|
Events: ${eventCatalog.join(', ')}
|
|
@@ -29,6 +30,10 @@ function taskEvent(args: string[] = []): void {
|
|
|
29
30
|
const seen = new Set<string>();
|
|
30
31
|
for (let index = 2; index < args.length; index += 1) {
|
|
31
32
|
const flag = args[index]!;
|
|
33
|
+
if (flag === '--orchestrated') {
|
|
34
|
+
if (seen.has(flag)) { usageFailure(`duplicate option '${flag}'`); return; }
|
|
35
|
+
seen.add(flag); request.orchestrated = true; continue;
|
|
36
|
+
}
|
|
32
37
|
if (flag === '--dry-run') {
|
|
33
38
|
if (seen.has(flag)) { usageFailure(`duplicate option '${flag}'`); return; }
|
|
34
39
|
seen.add(flag); request.dryRun = true; continue;
|
|
@@ -43,6 +48,9 @@ function taskEvent(args: string[] = []): void {
|
|
|
43
48
|
else if (key === 'verdict') request.verdict = value as Verdict;
|
|
44
49
|
else (request as Record<string, unknown>)[key] = value;
|
|
45
50
|
}
|
|
51
|
+
const agent = normalizeAgentToken(String(request.agent ?? ''));
|
|
52
|
+
if (!agent) { usageFailure(`invalid --agent '${request.agent}': ${AGENT_USAGE_HINT}`); return; }
|
|
53
|
+
request.agent = agent;
|
|
46
54
|
const result = applyTaskEvent(request);
|
|
47
55
|
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
48
56
|
if (result.status === 'failed') process.exitCode = 1;
|
|
@@ -9,9 +9,10 @@ const USAGE = `Usage: agent-infra-internal task-ledger <task-ref> <intent> [inte
|
|
|
9
9
|
const FLAGS: Record<string, string> = {
|
|
10
10
|
'--stage': 'stage', '--review-artifact': 'reviewArtifact', '--ordinal': 'ordinal',
|
|
11
11
|
'--severity': 'severity', '--evidence': 'evidence', '--id': 'id', '--round': 'round',
|
|
12
|
-
'--status': 'status', '--artifact': 'artifact'
|
|
12
|
+
'--status': 'status', '--artifact': 'artifact', '--needs-implementation': 'needsImplementation'
|
|
13
13
|
};
|
|
14
14
|
const NUMERIC = new Set(['ordinal', 'round']);
|
|
15
|
+
const BOOLEAN = new Set(['needsImplementation']);
|
|
15
16
|
|
|
16
17
|
function usageFailure(message: string): void {
|
|
17
18
|
process.stdout.write(`${JSON.stringify({ status: 'failed', changed: false, error: { code: 'LEDGER_PAYLOAD_INVALID', message } })}\n`);
|
|
@@ -39,7 +40,11 @@ function taskLedger(args: string[] = []): void {
|
|
|
39
40
|
if (seen.has(flag)) { usageFailure(`duplicate option '${flag}'`); return; }
|
|
40
41
|
const value = args[++index];
|
|
41
42
|
if (value === undefined || value.startsWith('--')) { usageFailure(`option '${flag}' requires a value`); return; }
|
|
42
|
-
|
|
43
|
+
if (BOOLEAN.has(key) && value !== 'true' && value !== 'false') {
|
|
44
|
+
usageFailure(`option '${flag}' must be true or false`); return;
|
|
45
|
+
}
|
|
46
|
+
seen.add(flag);
|
|
47
|
+
values[key] = NUMERIC.has(key) ? Number(value) : BOOLEAN.has(key) ? value === 'true' : value;
|
|
43
48
|
}
|
|
44
49
|
const required: Record<string, string[]> = {
|
|
45
50
|
'finding-upsert': ['stage', 'reviewArtifact', 'ordinal', 'severity', 'evidence'],
|
|
@@ -49,7 +54,11 @@ function taskLedger(args: string[] = []): void {
|
|
|
49
54
|
'decision-upsert': ['id', 'stage', 'artifact'],
|
|
50
55
|
'stage-status': ['stage']
|
|
51
56
|
};
|
|
52
|
-
const
|
|
57
|
+
const optional: Record<string, string[]> = {
|
|
58
|
+
'finding-review': ['needsImplementation'],
|
|
59
|
+
'decision-upsert': ['needsImplementation']
|
|
60
|
+
};
|
|
61
|
+
const allowed = new Set(['kind', 'taskRef', 'dryRun', ...required[kind]!, ...(optional[kind] ?? [])]);
|
|
53
62
|
const unexpected = Object.keys(values).find((key) => !allowed.has(key));
|
|
54
63
|
const missing = required[kind]!.find((key) => values[key] === undefined);
|
|
55
64
|
if (unexpected) { usageFailure(`${kind} does not accept '${unexpected}'`); return; }
|