@fitlab-ai/agent-infra 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -9
- package/README.zh-CN.md +10 -9
- package/dist/bin/internal-cli.js +15 -0
- package/dist/lib/agent-clients/adapter.js +45 -2
- package/dist/lib/agent-clients/adapters/antigravity-cli.js +64 -0
- package/dist/lib/agent-clients/adapters/claude-code.js +10 -1
- 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.js +9 -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 +7 -1
- 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/task-activity.js +73 -0
- package/dist/lib/internal/task-event.js +17 -1
- package/dist/lib/internal/task-lifecycle.js +7 -0
- package/dist/lib/internal/task-orchestration.js +51 -6
- 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/issue-comments.js +3 -2
- package/dist/lib/platform/merged-pr-equivalence.js +115 -5
- package/dist/lib/platform/pr-checks.js +64 -41
- package/dist/lib/platform/pr-review.js +166 -0
- package/dist/lib/platform/pull-requests.js +324 -3
- package/dist/lib/platform/release-notes.js +85 -3
- package/dist/lib/pr-review/evidence-grading.js +229 -0
- package/dist/lib/run/tui.js +3 -5
- package/dist/lib/sandbox/commands/create.js +0 -20
- package/dist/lib/sandbox/commands/show.js +1 -1
- package/dist/lib/task/activity-intent.js +101 -0
- package/dist/lib/task/artifact-lifecycle.js +2 -1
- package/dist/lib/task/commands/log.js +15 -14
- package/dist/lib/task/delegation-receipts.js +23 -2
- package/dist/lib/task/events.js +67 -28
- package/dist/lib/task/finalization-artifacts.js +35 -0
- package/dist/lib/task/lifecycle-execution.js +46 -0
- package/dist/lib/task/orchestration.js +408 -44
- 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 +75 -2
- package/lib/agent-clients/adapters/antigravity-cli.ts +65 -0
- package/lib/agent-clients/adapters/claude-code.ts +10 -1
- package/lib/agent-clients/adapters/codex.ts +9 -0
- package/lib/agent-clients/adapters/index.ts +2 -2
- package/lib/agent-clients/adapters/opencode.ts +9 -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 +10 -0
- 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/task-activity.ts +55 -0
- package/lib/internal/task-event.ts +9 -1
- package/lib/internal/task-lifecycle.ts +4 -0
- package/lib/internal/task-orchestration.ts +45 -6
- 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/issue-comments.ts +3 -2
- package/lib/platform/merged-pr-equivalence.ts +127 -5
- package/lib/platform/pr-checks.ts +72 -45
- package/lib/platform/pr-review.ts +201 -0
- package/lib/platform/pull-requests.ts +395 -2
- package/lib/platform/release-notes.ts +100 -4
- package/lib/pr-review/evidence-grading.ts +318 -0
- package/lib/run/tui.ts +3 -4
- package/lib/sandbox/commands/create.ts +0 -20
- package/lib/sandbox/commands/show.ts +1 -1
- package/lib/server/server.schema.json +2 -2
- package/lib/task/activity-intent.ts +128 -0
- package/lib/task/artifact-lifecycle.ts +2 -1
- package/lib/task/commands/log.ts +15 -14
- package/lib/task/delegation-receipts.ts +32 -3
- package/lib/task/events.ts +75 -30
- package/lib/task/finalization-artifacts.ts +58 -0
- package/lib/task/lifecycle-execution.ts +106 -0
- package/lib/task/orchestration.ts +543 -64
- 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/create-issue.github.en.md +4 -2
- package/templates/.agents/rules/create-issue.github.zh-CN.md +4 -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 +2 -2
- package/templates/.agents/rules/pr-checks-commands.zh-CN.md +3 -3
- package/templates/.agents/rules/pr-sync.en.md +3 -1
- package/templates/.agents/rules/pr-sync.github.en.md +11 -1
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +11 -1
- package/templates/.agents/rules/pr-sync.zh-CN.md +3 -1
- package/templates/.agents/rules/release-commands.en.md +1 -1
- package/templates/.agents/rules/release-commands.github.en.md +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/task-management.en.md +11 -0
- package/templates/.agents/rules/task-management.zh-CN.md +11 -0
- package/templates/.agents/skills/analyze-task/SKILL.en.md +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 +9 -6
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +11 -8
- package/templates/.agents/skills/commit/SKILL.en.md +3 -1
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +3 -1
- package/templates/.agents/skills/commit/reference/commit-message.en.md +1 -1
- package/templates/.agents/skills/commit/reference/commit-message.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
- package/templates/.agents/skills/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 +21 -6
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +21 -6
- 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 +3 -1
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +3 -1
- 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/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 +9 -6
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +9 -6
- 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 +158 -0
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +158 -0
- package/templates/.agents/skills/review-pr/config/verify.en.json +37 -0
- package/templates/.agents/skills/review-pr/config/verify.zh-CN.json +37 -0
- package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +65 -0
- package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +65 -0
- package/templates/.agents/skills/review-pr/reference/output-guidance.en.md +18 -0
- package/templates/.agents/skills/review-pr/reference/output-guidance.zh-CN.md +18 -0
- package/templates/.agents/skills/review-pr/reference/report-template.en.md +85 -0
- package/templates/.agents/skills/review-pr/reference/report-template.zh-CN.md +85 -0
- package/templates/.agents/skills/run-task/SKILL.en.md +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 +35 -61
- 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 +1 -1
- package/templates/.agents/templates/task.zh-CN.md +1 -1
- package/templates/.agents/workflows/bug-fix.en.yaml +3 -3
- package/templates/.agents/workflows/bug-fix.zh-CN.yaml +3 -3
- package/templates/.agents/workflows/code-review.en.yaml +1 -1
- package/templates/.agents/workflows/code-review.zh-CN.yaml +1 -1
- package/templates/.agents/workflows/feature-development.en.yaml +4 -4
- package/templates/.agents/workflows/feature-development.zh-CN.yaml +4 -4
- package/templates/.agents/workflows/refactoring.en.yaml +3 -3
- package/templates/.agents/workflows/refactoring.zh-CN.yaml +3 -3
- package/templates/.claude/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/.gemini/commands/_project_/review-pr.en.toml +10 -0
- package/templates/.gemini/commands/_project_/review-pr.zh-CN.toml +10 -0
- package/templates/.opencode/commands/post-release.en.md +2 -0
- package/templates/.opencode/commands/post-release.zh-CN.md +2 -0
- package/templates/.opencode/commands/review-pr.en.md +11 -0
- package/templates/.opencode/commands/review-pr.zh-CN.md +11 -0
- package/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
|
@@ -7,12 +7,15 @@ import {
|
|
|
7
7
|
} from '../agent-clients/config.ts';
|
|
8
8
|
import { normalizeCustomTUIs } from '../agent-clients/custom-tuis.ts';
|
|
9
9
|
import { renderNextStepCommands } from '../agent-clients/next-steps.ts';
|
|
10
|
+
import { getAgentClientModelSelection } from '../agent-clients/registry.ts';
|
|
11
|
+
import { isAgentClientId } from '../agent-clients/types.ts';
|
|
10
12
|
|
|
11
|
-
const USAGE = 'Usage: agent-infra-internal agent-client next-steps
|
|
13
|
+
const USAGE = 'Usage: agent-infra-internal agent-client <next-steps|model-selection> [options]\n';
|
|
12
14
|
|
|
13
15
|
type ParsedArgs = Readonly<{
|
|
14
16
|
skillName: string;
|
|
15
17
|
taskRef?: string;
|
|
18
|
+
version?: string;
|
|
16
19
|
format: 'text' | 'json';
|
|
17
20
|
}>;
|
|
18
21
|
|
|
@@ -38,11 +41,12 @@ function parseArgs(args: string[]): ParsedArgs | null {
|
|
|
38
41
|
}
|
|
39
42
|
let skillName: string | undefined;
|
|
40
43
|
let taskRef: string | undefined;
|
|
44
|
+
let version: string | undefined;
|
|
41
45
|
let format: 'text' | 'json' = 'text';
|
|
42
46
|
const seen = new Set<string>();
|
|
43
47
|
for (let index = 1; index < args.length; index += 1) {
|
|
44
48
|
const flag = args[index]!;
|
|
45
|
-
if (!['--skill', '--task-ref', '--format'].includes(flag)) {
|
|
49
|
+
if (!['--skill', '--task-ref', '--version', '--format'].includes(flag)) {
|
|
46
50
|
failure('AGENT_CLIENT_PAYLOAD_INVALID', `unknown option '${flag}'`);
|
|
47
51
|
return null;
|
|
48
52
|
}
|
|
@@ -58,6 +62,7 @@ function parseArgs(args: string[]): ParsedArgs | null {
|
|
|
58
62
|
seen.add(flag);
|
|
59
63
|
if (flag === '--skill') skillName = value;
|
|
60
64
|
if (flag === '--task-ref') taskRef = value;
|
|
65
|
+
if (flag === '--version') version = value;
|
|
61
66
|
if (flag === '--format') {
|
|
62
67
|
if (value !== 'text' && value !== 'json') {
|
|
63
68
|
failure('AGENT_CLIENT_PAYLOAD_INVALID', "format must be 'text' or 'json'");
|
|
@@ -70,10 +75,59 @@ function parseArgs(args: string[]): ParsedArgs | null {
|
|
|
70
75
|
failure('AGENT_CLIENT_PAYLOAD_INVALID', "option '--skill' is required");
|
|
71
76
|
return null;
|
|
72
77
|
}
|
|
73
|
-
return {
|
|
78
|
+
return {
|
|
79
|
+
skillName,
|
|
80
|
+
...(taskRef ? { taskRef } : {}),
|
|
81
|
+
...(version ? { version } : {}),
|
|
82
|
+
format
|
|
83
|
+
};
|
|
74
84
|
}
|
|
75
85
|
|
|
76
86
|
function agentClient(args: string[] = []): void {
|
|
87
|
+
if (args[0] === 'model-selection') {
|
|
88
|
+
const values: Record<string, string> = {};
|
|
89
|
+
const seen = new Set<string>();
|
|
90
|
+
for (let index = 1; index < args.length; index += 1) {
|
|
91
|
+
const flag = args[index]!;
|
|
92
|
+
if (!['--client', '--format'].includes(flag) || seen.has(flag)) {
|
|
93
|
+
failure('AGENT_CLIENT_PAYLOAD_INVALID', `invalid or duplicate option '${flag}'`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const value = args[++index];
|
|
97
|
+
if (!value || value.startsWith('--')) {
|
|
98
|
+
failure('AGENT_CLIENT_PAYLOAD_INVALID', `option '${flag}' requires a value`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
seen.add(flag);
|
|
102
|
+
values[flag] = value;
|
|
103
|
+
}
|
|
104
|
+
const client = values['--client'];
|
|
105
|
+
const format = values['--format'] ?? 'text';
|
|
106
|
+
if (!isAgentClientId(client) || !['text', 'json'].includes(format)) {
|
|
107
|
+
failure('AGENT_CLIENT_PAYLOAD_INVALID', 'model-selection requires a known --client and text|json format');
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const context = getAgentClientModelSelection(client);
|
|
111
|
+
if (format === 'json') {
|
|
112
|
+
process.stdout.write(`${JSON.stringify({
|
|
113
|
+
status: 'resolved', changed: false, client, context, error: null
|
|
114
|
+
})}\n`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (context.kind === 'interactive-only') {
|
|
118
|
+
process.stdout.write(`Model selection: interactive-only\nCommand: ${context.command}\n${context.guidance}\n`);
|
|
119
|
+
} else {
|
|
120
|
+
process.stdout.write(`Model selection: ${context.completeness} catalog\nSource: ${context.source}\n`);
|
|
121
|
+
for (const model of context.models) {
|
|
122
|
+
const efforts = model.reasoningEfforts?.length
|
|
123
|
+
? ` (${model.reasoningEfforts.join(', ')})`
|
|
124
|
+
: '';
|
|
125
|
+
process.stdout.write(`- ${model.id}${efforts}\n`);
|
|
126
|
+
}
|
|
127
|
+
if (context.guidance) process.stdout.write(`${context.guidance}\n`);
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
77
131
|
const parsed = parseArgs(args);
|
|
78
132
|
if (!parsed || process.exitCode) return;
|
|
79
133
|
|
|
@@ -98,7 +152,8 @@ function agentClient(args: string[] = []): void {
|
|
|
98
152
|
state: clients.state,
|
|
99
153
|
customTUIs: custom.items,
|
|
100
154
|
skillName: parsed.skillName,
|
|
101
|
-
...(parsed.taskRef ? { taskRef: parsed.taskRef } : {})
|
|
155
|
+
...(parsed.taskRef ? { taskRef: parsed.taskRef } : {}),
|
|
156
|
+
...(parsed.version ? { version: parsed.version } : {})
|
|
102
157
|
});
|
|
103
158
|
if (parsed.format === 'json') {
|
|
104
159
|
process.stdout.write(`${JSON.stringify({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
-
import { commitExplicitPaths, inspectGitWorkflow, pushGitRefs } from '../git/workflow.ts';
|
|
2
|
+
import { commitExplicitPaths, inspectGitWorkflow, pushGitRefs, pushRebasedBranch } from '../git/workflow.ts';
|
|
3
3
|
import { compareReviewTrees, snapshotReview } from '../git/review-snapshot.ts';
|
|
4
4
|
import { resolvePostReviewGlobs } from '../task/review-fingerprint.ts';
|
|
5
5
|
|
|
@@ -23,6 +23,10 @@ function gitWorkflow(args: string[] = []): void {
|
|
|
23
23
|
const inputIndex = rest.indexOf('--input');
|
|
24
24
|
const input = inputIndex >= 0 && rest[inputIndex + 1] ? JSON.parse(fs.readFileSync(rest[inputIndex + 1]!, 'utf8')) : null;
|
|
25
25
|
result = input ? pushGitRefs({ cwd: cwd ?? process.cwd(), ...input }) : { status: 'failed', changed: false, error: { code: 'GIT_INPUT_REQUIRED', message: '--input JSON file is required' } };
|
|
26
|
+
} else if (action === 'push-rebased') {
|
|
27
|
+
const inputIndex = rest.indexOf('--input');
|
|
28
|
+
const input = inputIndex >= 0 && rest[inputIndex + 1] ? JSON.parse(fs.readFileSync(rest[inputIndex + 1]!, 'utf8')) : null;
|
|
29
|
+
result = input ? pushRebasedBranch({ cwd: cwd ?? process.cwd(), ...input }) : { status: 'failed', changed: false, error: { code: 'GIT_INPUT_REQUIRED', message: '--input JSON file is required' } };
|
|
26
30
|
} else if (action === 'snapshot' || action === 'compare-trees') {
|
|
27
31
|
const inputIndex = rest.indexOf('--input');
|
|
28
32
|
const input = inputIndex >= 0 && rest[inputIndex + 1] ? JSON.parse(fs.readFileSync(rest[inputIndex + 1]!, 'utf8')) : null;
|
|
@@ -2,9 +2,9 @@ import path from 'node:path';
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
fetchPlatformCheckLogs,
|
|
5
|
-
|
|
5
|
+
inspectPullRequestReadiness,
|
|
6
6
|
resolvePlatformCheckRun,
|
|
7
|
-
|
|
7
|
+
watchPullRequestReadiness
|
|
8
8
|
} from '../platform/pr-checks.ts';
|
|
9
9
|
import type { ChecksResult } from '../platform/pr-checks.ts';
|
|
10
10
|
|
|
@@ -70,7 +70,7 @@ async function platformChecks(args: string[] = []): Promise<void> {
|
|
|
70
70
|
};
|
|
71
71
|
const unexpected = Object.keys(values).find((name) => !allowed[operation]!.includes(name));
|
|
72
72
|
if (unexpected) { fail(`${operation} does not accept --${unexpected}`); return; }
|
|
73
|
-
if (operation === 'inspect') { finish(
|
|
73
|
+
if (operation === 'inspect') { finish(inspectPullRequestReadiness(taskRef, { cwd })); return; }
|
|
74
74
|
if (operation === 'resolve-run') {
|
|
75
75
|
if (!values.checkName) { fail('resolve-run requires --check-name'); return; }
|
|
76
76
|
finish(resolvePlatformCheckRun(taskRef, { cwd, checkName: values.checkName, detailsUrl: values.detailsUrl }));
|
|
@@ -91,7 +91,7 @@ async function platformChecks(args: string[] = []): Promise<void> {
|
|
|
91
91
|
process.once('SIGINT', abort);
|
|
92
92
|
process.once('SIGTERM', abort);
|
|
93
93
|
try {
|
|
94
|
-
finish(await
|
|
94
|
+
finish(await watchPullRequestReadiness(taskRef, { cwd, intervalSeconds, deadlineSeconds, signal: controller.signal }));
|
|
95
95
|
} finally {
|
|
96
96
|
process.removeListener('SIGINT', abort);
|
|
97
97
|
process.removeListener('SIGTERM', abort);
|
|
@@ -1,6 +1,7 @@
|
|
|
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
|
checkPlatformCommentOwner,
|
|
6
7
|
listPlatformComments,
|
|
@@ -8,9 +9,11 @@ import {
|
|
|
8
9
|
} from '../platform/issue-comments.ts';
|
|
9
10
|
import type { CommentKind } from '../platform/issue-comments.ts';
|
|
10
11
|
import type { PlatformResult } from '../platform/types.ts';
|
|
12
|
+
import { backfillCompletionComments } from '../platform/completion-backfill.ts';
|
|
11
13
|
|
|
12
14
|
const USAGE = `Usage: agent-infra-internal platform-comment list --issue <N> [--cwd <path>]
|
|
13
15
|
agent-infra-internal platform-comment owner <task-ref> [--cwd <path>]
|
|
16
|
+
agent-infra-internal platform-comment backfill <task-ref> --agent <agent> [--cwd <path>]
|
|
14
17
|
agent-infra-internal platform-comment sync <task-ref> --kind <kind> --agent <agent> [--artifact <file>] [--body-file <path|->] [--status-label <label>] [--backfill] [--cwd <path>]
|
|
15
18
|
`;
|
|
16
19
|
|
|
@@ -52,7 +55,7 @@ function readBodyFile(value: string, cwd: string): string {
|
|
|
52
55
|
function platformComment(args: string[] = []): void {
|
|
53
56
|
if (args[0] === '--help' || args[0] === '-h') { process.stdout.write(USAGE); return; }
|
|
54
57
|
const operation = args[0];
|
|
55
|
-
if (!operation || !['list', 'owner', 'sync'].includes(operation)) { fail('a valid operation is required'); return; }
|
|
58
|
+
if (!operation || !['list', 'owner', 'backfill', 'sync'].includes(operation)) { fail('a valid operation is required'); return; }
|
|
56
59
|
const hasTaskRef = operation !== 'list';
|
|
57
60
|
const taskRef = hasTaskRef ? args[1] : undefined;
|
|
58
61
|
if (hasTaskRef && (!taskRef || taskRef.startsWith('--'))) { fail(`${operation} requires a task ref`); return; }
|
|
@@ -73,10 +76,22 @@ function platformComment(args: string[] = []): void {
|
|
|
73
76
|
finish(checkPlatformCommentOwner(taskRef!, { cwd }));
|
|
74
77
|
return;
|
|
75
78
|
}
|
|
79
|
+
if (operation === 'backfill') {
|
|
80
|
+
const unexpected = Object.keys(parsed.values).find((key) => !['cwd', 'agent'].includes(key));
|
|
81
|
+
if (unexpected) { fail(`backfill does not accept '--${unexpected}'`); return; }
|
|
82
|
+
const agent = parsed.values.agent;
|
|
83
|
+
if (typeof agent !== 'string' || !agent) { fail('backfill requires --agent'); return; }
|
|
84
|
+
const normalizedAgent = normalizeAgentToken(agent);
|
|
85
|
+
if (!normalizedAgent) { fail(`invalid --agent '${agent}': ${AGENT_USAGE_HINT}`); return; }
|
|
86
|
+
finish(backfillCompletionComments(taskRef!, { cwd, agent: normalizedAgent }));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
76
89
|
const kind = parsed.values.kind;
|
|
77
90
|
const agent = parsed.values.agent;
|
|
78
91
|
if (!['task', 'artifact', 'summary', 'cancel'].includes(String(kind))) { fail('sync requires a valid --kind'); return; }
|
|
79
92
|
if (typeof agent !== 'string' || !agent) { fail('sync requires --agent'); return; }
|
|
93
|
+
const normalizedAgent = normalizeAgentToken(agent);
|
|
94
|
+
if (!normalizedAgent) { fail(`invalid --agent '${agent}': ${AGENT_USAGE_HINT}`); return; }
|
|
80
95
|
if (kind === 'artifact' && typeof parsed.values.artifact !== 'string') { fail('artifact sync requires --artifact'); return; }
|
|
81
96
|
if ((kind === 'summary' || kind === 'cancel') && typeof parsed.values.bodyFile !== 'string') { fail(`${kind} sync requires --body-file`); return; }
|
|
82
97
|
let body: string | undefined;
|
|
@@ -88,7 +103,7 @@ function platformComment(args: string[] = []): void {
|
|
|
88
103
|
}
|
|
89
104
|
finish(syncPlatformComment(taskRef!, {
|
|
90
105
|
kind: kind as CommentKind,
|
|
91
|
-
agent,
|
|
106
|
+
agent: normalizedAgent,
|
|
92
107
|
artifact: typeof parsed.values.artifact === 'string' ? parsed.values.artifact : undefined,
|
|
93
108
|
body,
|
|
94
109
|
backfill: parsed.values.backfill === true,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
|
|
3
|
+
import { normalizeAgentToken, AGENT_USAGE_HINT } from '../agent-clients/tokens.ts';
|
|
3
4
|
import {
|
|
4
5
|
bindPlatformIssue,
|
|
5
6
|
createPlatformIssue,
|
|
@@ -76,6 +77,9 @@ function platformIssue(args: string[] = []): void {
|
|
|
76
77
|
if (unexpected) { fail(`${operation} does not accept --${unexpected}`); return; }
|
|
77
78
|
if (operation === 'inspect') { finish(inspectPlatformIssue(taskRef, { cwd })); return; }
|
|
78
79
|
if (typeof values.agent !== 'string' || !values.agent) { fail(`${operation} requires --agent`); return; }
|
|
80
|
+
const agent = normalizeAgentToken(values.agent);
|
|
81
|
+
if (!agent) { fail(`invalid --agent '${values.agent}': ${AGENT_USAGE_HINT}`); return; }
|
|
82
|
+
values.agent = agent;
|
|
79
83
|
if (operation === 'create') {
|
|
80
84
|
finish(createPlatformIssue(taskRef, { cwd, agent: values.agent, dryRun: values.dryRun === true })); return;
|
|
81
85
|
}
|
|
@@ -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 };
|