@fitlab-ai/agent-infra 0.9.13 → 0.9.15
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 -0
- package/README.zh-CN.md +10 -0
- package/bin/cli.ts +26 -9
- package/bin/internal-cli.sh +45 -0
- package/dist/bin/cli.js +173 -157
- package/dist/bin/internal-cli.js +126 -42
- package/dist/lib/agent-client.js +5 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/capability-store.js +165 -27
- package/dist/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.js +3 -2
- package/dist/lib/defaults.json +103 -103
- package/dist/lib/fs/durable-write.js +37 -0
- package/dist/lib/fs/file-lock.js +111 -0
- package/dist/lib/host-control/audit.js +19 -0
- package/dist/lib/host-control/client.js +142 -0
- package/dist/lib/host-control/command.js +49 -0
- package/dist/lib/host-control/path.js +160 -0
- package/dist/lib/host-control/secure-fs.js +140 -0
- package/dist/lib/host-control/server.js +159 -0
- package/dist/lib/host-control/service.js +112 -0
- package/dist/lib/init.js +11 -2
- package/dist/lib/internal/agent-client.js +5 -2
- package/dist/lib/internal/cli-route-inventory.js +154 -0
- package/dist/lib/internal/codex-lifecycle.js +15 -12
- package/dist/lib/internal/codex-sandbox-controller.js +8 -2
- package/dist/lib/internal/demo-promotion.js +322 -0
- package/dist/lib/internal/demo-transcript.js +454 -0
- package/dist/lib/internal/git-workflow.js +10 -6
- package/dist/lib/internal/host-control.js +28 -0
- package/dist/lib/internal/manual-validation.js +322 -0
- package/dist/lib/internal/platform-checks.js +16 -4
- package/dist/lib/internal/platform-comment.js +16 -4
- package/dist/lib/internal/platform-context.js +4 -1
- package/dist/lib/internal/platform-issue.js +12 -4
- package/dist/lib/internal/platform-metadata.js +88 -0
- package/dist/lib/internal/platform-pr-review.js +16 -3
- package/dist/lib/internal/platform-pr.js +42 -14
- package/dist/lib/internal/platform-release-notes.js +6 -3
- package/dist/lib/internal/platform-security.js +93 -0
- package/dist/lib/internal/pr-review-grade.js +14 -3
- package/dist/lib/internal/release-workflow.js +82 -89
- package/dist/lib/internal/sandbox-control.js +171 -7
- package/dist/lib/internal/task-activity.js +13 -4
- package/dist/lib/internal/task-artifact.js +19 -107
- package/dist/lib/internal/task-context.js +4 -1
- package/dist/lib/internal/task-create.js +48 -14
- package/dist/lib/internal/task-delivery.js +4 -1
- package/dist/lib/internal/task-event.js +38 -35
- package/dist/lib/internal/task-finalization.js +4 -1
- package/dist/lib/internal/task-invalidation.js +4 -1
- package/dist/lib/internal/task-ledger.js +12 -1
- package/dist/lib/internal/task-lifecycle.js +4 -1
- package/dist/lib/internal/task-operation-registry.js +519 -0
- package/dist/lib/internal/task-orchestration.js +12 -0
- package/dist/lib/internal/task-override.js +10 -3
- package/dist/lib/internal/task-qualification.js +90 -0
- package/dist/lib/internal/task-review.js +10 -52
- package/dist/lib/internal/task-short-id.js +11 -1
- package/dist/lib/internal/task-snapshot.js +4 -1
- package/dist/lib/internal/task-validate.js +37 -12
- package/dist/lib/internal/task-verify.js +5 -1
- package/dist/lib/internal/task-warning.js +8 -1
- package/dist/lib/owned-path.js +33 -0
- package/dist/lib/platform/check-status.js +11 -0
- package/dist/lib/platform/comment-safety.js +229 -0
- package/dist/lib/platform/completion-backfill.js +1 -1
- package/dist/lib/platform/github-data.js +241 -0
- package/dist/lib/platform/github-provider.js +248 -26
- package/dist/lib/platform/issue-comments.js +146 -34
- package/dist/lib/platform/issues.js +1 -179
- package/dist/lib/platform/pr-change-report.js +6 -12
- package/dist/lib/platform/pr-checks.js +12 -65
- package/dist/lib/platform/pr-summary.js +83 -10
- package/dist/lib/platform/provider-contract.d.ts +67 -1
- package/dist/lib/platform/provider-contract.js +6 -2
- package/dist/lib/platform/provider-validation.js +76 -3
- package/dist/lib/platform/pull-requests.js +117 -275
- package/dist/lib/platform/repository-metadata.js +377 -0
- package/dist/lib/platform/security-alerts.js +155 -0
- package/dist/lib/platform/snapshots.js +2 -0
- package/dist/lib/platform/verification-sync.js +154 -162
- package/dist/lib/process-data/index.js +7 -0
- package/dist/lib/release/workflow.js +1 -1
- package/dist/lib/run/index.js +5 -0
- package/dist/lib/sandbox/commands/control-status.js +22 -0
- package/dist/lib/sandbox/commands/create.js +39 -8
- package/dist/lib/sandbox/commands/ls.js +5 -0
- package/dist/lib/sandbox/commands/rm.js +3 -807
- package/dist/lib/sandbox/commands/show.js +16 -0
- package/dist/lib/sandbox/control/audit.js +203 -0
- package/dist/lib/sandbox/control/client.js +125 -12
- package/dist/lib/sandbox/control/completed-reentry.js +85 -0
- package/dist/lib/sandbox/control/container-identity.js +28 -31
- package/dist/lib/sandbox/control/executor.js +233 -34
- package/dist/lib/sandbox/control/finalization-response.js +27 -0
- package/dist/lib/sandbox/control/identity-sentinel.js +107 -0
- package/dist/lib/sandbox/control/lifecycle.js +656 -128
- package/dist/lib/sandbox/control/native-file-lock.js +85 -0
- package/dist/lib/sandbox/control/protocol.js +55 -4
- package/dist/lib/sandbox/control/server.js +720 -79
- package/dist/lib/sandbox/control/state.js +63 -3
- package/dist/lib/sandbox/control/task-view.js +183 -0
- package/dist/lib/sandbox/control/task-workflow.js +74 -0
- package/dist/lib/sandbox/control/workflow-executor.js +99 -0
- package/dist/lib/sandbox/engines/authority.js +289 -0
- package/dist/lib/sandbox/engines/docker-exact-discovery.js +97 -0
- package/dist/lib/sandbox/index.js +7 -2
- package/dist/lib/sandbox/recovery.js +49 -5
- package/dist/lib/sandbox/removal.js +1717 -0
- package/dist/lib/sandbox/task-cleanup.js +217 -0
- package/dist/lib/sandbox/workspace-view.js +15 -15
- package/dist/lib/sandbox/worktree-safety.js +4 -1
- package/dist/lib/server/index.js +8 -0
- package/dist/lib/task/activity-intent.js +2 -1
- package/dist/lib/task/activity-log.js +30 -24
- package/dist/lib/task/artifact-command.js +101 -0
- package/dist/lib/task/artifact-lifecycle.js +71 -40
- package/dist/lib/task/artifact-name.js +36 -0
- package/dist/lib/task/artifact-operations.js +474 -0
- package/dist/lib/task/artifact-receipts.js +3 -15
- package/dist/lib/task/artifact-repair-intent.js +130 -0
- package/dist/lib/task/artifact-schema.js +127 -0
- package/dist/lib/task/capabilities.js +83 -19
- package/dist/lib/task/codex-orchestration.js +71 -25
- package/dist/lib/task/commit-identity.js +28 -0
- package/dist/lib/task/commit-operation.js +2 -16
- package/dist/lib/task/control-authority.js +375 -5
- package/dist/lib/task/control-recovery.js +128 -0
- package/dist/lib/task/create-service.js +103 -4
- package/dist/lib/task/create.js +80 -2
- package/dist/lib/task/decision-details.js +2 -46
- package/dist/lib/task/events.js +306 -76
- package/dist/lib/task/finalization-state.js +9 -0
- package/dist/lib/task/human-override.js +3 -6
- package/dist/lib/task/implementation-inputs.js +3 -3
- package/dist/lib/task/index.js +11 -3
- package/dist/lib/task/intermediate-cleanup.js +383 -0
- package/dist/lib/task/invalidation.js +18 -65
- package/dist/lib/task/ledger-intents.js +7 -22
- package/dist/lib/task/ledger.js +1 -3
- package/dist/lib/task/lifecycle.js +19 -1
- package/dist/lib/task/local-artifact-finalization.js +190 -290
- package/dist/lib/task/manual-validation-completion.js +26 -0
- package/dist/lib/task/manual-validation-evidence.js +130 -0
- package/dist/lib/task/manual-validation-receipt.js +101 -0
- package/dist/lib/task/manual-validation-shared.js +40 -0
- package/dist/lib/task/manual-validation-transaction.js +243 -0
- package/dist/lib/task/markdown.js +47 -0
- package/dist/lib/task/orchestration.js +206 -69
- package/dist/lib/task/qualification-audit.js +476 -0
- package/dist/lib/task/qualification-confirmation.js +109 -0
- package/dist/lib/task/qualification-intents.js +148 -0
- package/dist/lib/task/review-artifacts.js +23 -40
- package/dist/lib/task/review-command.js +25 -0
- package/dist/lib/task/review-finalization.js +146 -97
- package/dist/lib/task/review-fingerprint.js +2 -2
- package/dist/lib/task/sections.js +34 -54
- package/dist/lib/task/verification-config.js +11 -0
- package/dist/lib/task/verification-engine.js +170 -327
- package/dist/lib/task/verification.js +1 -1
- package/dist/lib/task/workflow-command.js +17 -0
- package/dist/lib/task/workflow-warning-intents.js +0 -16
- package/dist/lib/task/workflow-warnings.js +28 -2
- package/dist/lib/update.js +2 -0
- package/dist/lifecycle-build-manifest.json +3 -3
- package/lib/agent-client.ts +9 -0
- package/lib/agent-clients/adapters/codex-lifecycle/capability-store.ts +223 -33
- package/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.ts +3 -2
- package/lib/fs/durable-write.ts +29 -0
- package/lib/fs/file-lock.ts +113 -0
- package/lib/host-control/audit.ts +22 -0
- package/lib/host-control/client.ts +172 -0
- package/lib/host-control/command.ts +60 -0
- package/lib/host-control/path.ts +167 -0
- package/lib/host-control/secure-fs.ts +135 -0
- package/lib/host-control/server.ts +180 -0
- package/lib/host-control/service.ts +133 -0
- package/lib/init.ts +15 -2
- package/lib/internal/agent-client.ts +4 -2
- package/lib/internal/cli-route-inventory.ts +142 -0
- package/lib/internal/codex-lifecycle.ts +14 -12
- package/lib/internal/codex-sandbox-controller.ts +7 -2
- package/lib/internal/demo-promotion.ts +354 -0
- package/lib/internal/demo-transcript.ts +419 -0
- package/lib/internal/git-workflow.ts +9 -6
- package/lib/internal/host-control.ts +28 -0
- package/lib/internal/manual-validation.ts +306 -0
- package/lib/internal/platform-checks.ts +12 -4
- package/lib/internal/platform-comment.ts +12 -4
- package/lib/internal/platform-context.ts +3 -1
- package/lib/internal/platform-issue.ts +11 -4
- package/lib/internal/platform-metadata.ts +70 -0
- package/lib/internal/platform-pr-review.ts +14 -3
- package/lib/internal/platform-pr.ts +38 -14
- package/lib/internal/platform-release-notes.ts +5 -3
- package/lib/internal/platform-security.ts +83 -0
- package/lib/internal/pr-review-grade.ts +10 -3
- package/lib/internal/release-workflow.ts +91 -87
- package/lib/internal/sandbox-control.ts +181 -6
- package/lib/internal/task-activity.ts +12 -4
- package/lib/internal/task-artifact.ts +15 -79
- package/lib/internal/task-context.ts +3 -1
- package/lib/internal/task-create.ts +76 -15
- package/lib/internal/task-delivery.ts +3 -1
- package/lib/internal/task-event.ts +21 -10
- package/lib/internal/task-finalization.ts +3 -1
- package/lib/internal/task-invalidation.ts +3 -1
- package/lib/internal/task-ledger.ts +11 -1
- package/lib/internal/task-lifecycle.ts +3 -1
- package/lib/internal/task-operation-registry.ts +590 -0
- package/lib/internal/task-orchestration.ts +12 -0
- package/lib/internal/task-override.ts +9 -3
- package/lib/internal/task-qualification.ts +61 -0
- package/lib/internal/task-review.ts +7 -50
- package/lib/internal/task-short-id.ts +10 -1
- package/lib/internal/task-snapshot.ts +3 -1
- package/lib/internal/task-validate.ts +32 -12
- package/lib/internal/task-verify.ts +4 -1
- package/lib/internal/task-warning.ts +7 -1
- package/lib/owned-path.ts +26 -0
- package/lib/platform/check-status.ts +9 -0
- package/lib/platform/comment-safety.ts +255 -0
- package/lib/platform/completion-backfill.ts +1 -1
- package/lib/platform/github-data.ts +322 -0
- package/lib/platform/github-provider.ts +244 -27
- package/lib/platform/issue-comments.ts +159 -35
- package/lib/platform/issues.ts +4 -245
- package/lib/platform/pr-change-report.ts +6 -12
- package/lib/platform/pr-checks.ts +13 -77
- package/lib/platform/pr-summary.ts +88 -11
- package/lib/platform/provider-contract.ts +78 -3
- package/lib/platform/provider-validation.ts +85 -3
- package/lib/platform/pull-requests.ts +129 -348
- package/lib/platform/repository-metadata.ts +453 -0
- package/lib/platform/security-alerts.ts +191 -0
- package/lib/platform/snapshots.ts +53 -0
- package/lib/platform/verification-sync.ts +171 -177
- package/lib/process-data/index.ts +7 -0
- package/lib/release/workflow.ts +3 -3
- package/lib/run/index.ts +5 -0
- package/lib/sandbox/commands/control-status.ts +26 -0
- package/lib/sandbox/commands/create.ts +53 -12
- package/lib/sandbox/commands/ls.ts +7 -0
- package/lib/sandbox/commands/rm.ts +3 -996
- package/lib/sandbox/commands/show.ts +16 -0
- package/lib/sandbox/control/audit.ts +253 -0
- package/lib/sandbox/control/client.ts +150 -13
- package/lib/sandbox/control/completed-reentry.ts +98 -0
- package/lib/sandbox/control/container-identity.ts +27 -43
- package/lib/sandbox/control/executor.ts +262 -37
- package/lib/sandbox/control/finalization-response.ts +29 -0
- package/lib/sandbox/control/identity-sentinel.ts +137 -0
- package/lib/sandbox/control/lifecycle.ts +672 -18
- package/lib/sandbox/control/native-file-lock.ts +108 -0
- package/lib/sandbox/control/protocol.ts +80 -8
- package/lib/sandbox/control/server.ts +779 -82
- package/lib/sandbox/control/state.ts +84 -3
- package/lib/sandbox/control/task-view.ts +240 -0
- package/lib/sandbox/control/task-workflow.ts +95 -0
- package/lib/sandbox/control/workflow-executor.ts +102 -0
- package/lib/sandbox/engines/authority.ts +365 -0
- package/lib/sandbox/engines/docker-exact-discovery.ts +132 -0
- package/lib/sandbox/index.ts +9 -2
- package/lib/sandbox/recovery.ts +49 -6
- package/lib/sandbox/removal.ts +2144 -0
- package/lib/sandbox/task-cleanup.ts +209 -0
- package/lib/sandbox/workspace-view.ts +26 -18
- package/lib/sandbox/worktree-safety.ts +4 -1
- package/lib/server/index.ts +10 -0
- package/lib/task/activity-intent.ts +2 -2
- package/lib/task/activity-log.ts +27 -19
- package/lib/task/artifact-command.ts +104 -0
- package/lib/task/artifact-lifecycle.ts +66 -39
- package/lib/task/artifact-name.ts +55 -0
- package/lib/task/artifact-operations.ts +580 -0
- package/lib/task/artifact-receipts.ts +3 -14
- package/lib/task/artifact-repair-intent.ts +152 -0
- package/lib/task/artifact-schema.ts +163 -0
- package/lib/task/capabilities.ts +82 -22
- package/lib/task/codex-orchestration.ts +85 -24
- package/lib/task/commit-identity.ts +31 -0
- package/lib/task/commit-operation.ts +2 -16
- package/lib/task/control-authority.ts +513 -6
- package/lib/task/control-recovery.ts +174 -0
- package/lib/task/create-service.ts +131 -6
- package/lib/task/create.ts +83 -1
- package/lib/task/decision-details.ts +3 -71
- package/lib/task/events.ts +292 -75
- package/lib/task/finalization-state.ts +11 -0
- package/lib/task/human-override.ts +3 -8
- package/lib/task/implementation-inputs.ts +3 -3
- package/lib/task/index.ts +16 -3
- package/lib/task/intermediate-cleanup.ts +455 -0
- package/lib/task/invalidation.ts +18 -62
- package/lib/task/ledger-intents.ts +7 -24
- package/lib/task/ledger.ts +1 -3
- package/lib/task/lifecycle.ts +17 -1
- package/lib/task/local-artifact-finalization.ts +223 -388
- package/lib/task/manual-validation-completion.ts +40 -0
- package/lib/task/manual-validation-evidence.ts +209 -0
- package/lib/task/manual-validation-receipt.ts +152 -0
- package/lib/task/manual-validation-shared.ts +50 -0
- package/lib/task/manual-validation-transaction.ts +304 -0
- package/lib/task/markdown.ts +70 -0
- package/lib/task/orchestration.ts +191 -68
- package/lib/task/qualification-audit.ts +588 -0
- package/lib/task/qualification-confirmation.ts +117 -0
- package/lib/task/qualification-intents.ts +150 -0
- package/lib/task/review-artifacts.ts +21 -41
- package/lib/task/review-command.ts +23 -0
- package/lib/task/review-finalization.ts +154 -153
- package/lib/task/review-fingerprint.ts +2 -2
- package/lib/task/sections.ts +33 -52
- package/lib/task/verification-config.ts +12 -0
- package/lib/task/verification-engine.ts +165 -370
- package/lib/task/verification-types.ts +17 -0
- package/lib/task/verification.ts +1 -1
- package/lib/task/workflow-command.ts +18 -0
- package/lib/task/workflow-warning-intents.ts +0 -13
- package/lib/task/workflow-warnings.ts +21 -2
- package/lib/update.ts +6 -0
- package/package.json +7 -2
- package/templates/.agents/hooks/lifecycle-delegation.js +6 -6
- package/templates/.agents/rules/README.en.md +2 -0
- package/templates/.agents/rules/README.zh-CN.md +2 -0
- package/templates/.agents/rules/decision-qualification.en.md +22 -0
- package/templates/.agents/rules/decision-qualification.zh-CN.md +22 -0
- package/templates/.agents/rules/evidence-reporting.en.md +28 -0
- package/templates/.agents/rules/evidence-reporting.zh-CN.md +28 -0
- package/templates/.agents/rules/label-milestone-setup.en.md +7 -7
- package/templates/.agents/rules/label-milestone-setup.zh-CN.md +7 -7
- package/templates/.agents/rules/local-artifact-repair.en.md +5 -1
- package/templates/.agents/rules/local-artifact-repair.zh-CN.md +5 -1
- package/templates/.agents/rules/security-alerts.en.md +8 -8
- package/templates/.agents/rules/security-alerts.zh-CN.md +8 -8
- package/templates/.agents/rules/testing-discipline.en.md +2 -0
- package/templates/.agents/rules/testing-discipline.zh-CN.md +2 -0
- package/templates/.agents/scripts/package.json +3 -0
- package/templates/.agents/skills/analyze-task/SKILL.en.md +15 -2
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +19 -2
- package/templates/.agents/skills/analyze-task/config/verify.en.json +1 -12
- package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +1 -12
- package/templates/.agents/skills/close-codescan/SKILL.en.md +2 -2
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +2 -2
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/code-task/SKILL.en.md +14 -1
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +14 -1
- package/templates/.agents/skills/code-task/config/verify.en.json +5 -14
- package/templates/.agents/skills/code-task/config/verify.zh-CN.json +5 -14
- package/templates/.agents/skills/code-task/reference/code-rules.en.md +5 -4
- package/templates/.agents/skills/code-task/reference/code-rules.zh-CN.md +5 -4
- package/templates/.agents/skills/code-task/reference/dual-mode.en.md +1 -1
- package/templates/.agents/skills/code-task/reference/dual-mode.zh-CN.md +1 -1
- package/templates/.agents/skills/code-task/reference/fix-mode.en.md +3 -1
- package/templates/.agents/skills/code-task/reference/fix-mode.zh-CN.md +3 -1
- package/templates/.agents/skills/code-task/reference/report-template.en.md +42 -15
- package/templates/.agents/skills/code-task/reference/report-template.zh-CN.md +39 -12
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +37 -21
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +37 -21
- package/templates/.agents/skills/complete-manual-validation/config/verify.en.json +1 -1
- package/templates/.agents/skills/complete-manual-validation/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/complete-manual-validation/reference/report-template.en.md +4 -0
- package/templates/.agents/skills/complete-manual-validation/reference/report-template.zh-CN.md +4 -0
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +16 -7
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +16 -7
- package/templates/.agents/skills/complete-task/SKILL.en.md +10 -23
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +10 -23
- package/templates/.agents/skills/create-task/SKILL.en.md +8 -0
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +7 -0
- package/templates/.agents/skills/import-codescan/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.en.md +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/init-labels/SKILL.en.md +8 -8
- package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +8 -8
- package/templates/.agents/skills/init-milestones/SKILL.en.md +9 -11
- package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +9 -11
- package/templates/.agents/skills/plan-task/SKILL.en.md +14 -1
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +16 -1
- package/templates/.agents/skills/plan-task/config/verify.en.json +4 -14
- package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +4 -14
- package/templates/.agents/skills/release/SKILL.en.md +7 -3
- package/templates/.agents/skills/release/SKILL.zh-CN.md +7 -3
- package/templates/.agents/skills/review-analysis/SKILL.en.md +14 -1
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +14 -1
- package/templates/.agents/skills/review-analysis/config/verify.en.json +1 -18
- package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +1 -18
- package/templates/.agents/skills/review-analysis/reference/report-template.en.md +50 -23
- package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +45 -18
- package/templates/.agents/skills/review-code/SKILL.en.md +14 -1
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +14 -1
- package/templates/.agents/skills/review-code/config/verify.en.json +1 -23
- package/templates/.agents/skills/review-code/config/verify.zh-CN.json +1 -23
- package/templates/.agents/skills/review-code/reference/report-template.en.md +49 -22
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +45 -18
- package/templates/.agents/skills/review-plan/SKILL.en.md +14 -1
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +14 -1
- package/templates/.agents/skills/review-plan/config/verify.en.json +1 -18
- package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +1 -18
- package/templates/.agents/skills/review-plan/reference/report-template.en.md +49 -22
- package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +45 -18
- package/templates/.agents/skills/review-pr/SKILL.en.md +5 -1
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +5 -1
- package/templates/.agents/skills/review-pr/reference/report-template.en.md +4 -3
- package/templates/.agents/skills/review-pr/reference/report-template.zh-CN.md +4 -3
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +25 -4
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +25 -4
- package/templates/.agents/skills/run-manual-validation/reference/discovery-and-execution.en.md +4 -1
- package/templates/.agents/skills/run-manual-validation/reference/discovery-and-execution.zh-CN.md +4 -1
- package/templates/.agents/skills/run-manual-validation/reference/report-template.en.md +5 -1
- package/templates/.agents/skills/run-manual-validation/reference/report-template.zh-CN.md +5 -1
- package/templates/.agents/skills/run-task/SKILL.en.md +1 -1
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/test/SKILL.en.md +29 -7
- package/templates/.agents/skills/test/SKILL.zh-CN.md +29 -7
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +14 -0
- package/templates/.agents/templates/task.en.md +6 -0
- package/templates/.agents/templates/task.zh-CN.md +6 -0
- package/templates/.claude/commands/run-manual-validation.en.md +1 -1
- package/templates/.claude/commands/run-manual-validation.zh-CN.md +1 -1
- package/dist/lib/platform/adapters.js +0 -56
- package/lib/platform/adapters.ts +0 -197
- package/templates/.agents/scripts/security-alerts.github.sh +0 -151
- package/templates/.agents/scripts/security-alerts.sh +0 -31
- package/templates/.agents/skills/init-labels/scripts/init-labels.github.sh +0 -146
- package/templates/.agents/skills/init-labels/scripts/init-labels.sh +0 -32
- package/templates/.agents/skills/init-milestones/scripts/init-milestones.github.sh +0 -294
- package/templates/.agents/skills/init-milestones/scripts/init-milestones.sh +0 -6
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import net from 'node:net';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
HOST_CONTROL_DIRECTORY_MODE,
|
|
7
|
+
HOST_CONTROL_SOCKET_MODE,
|
|
8
|
+
ensureHostControlWorkerToken,
|
|
9
|
+
inspectHostControlEndpoint,
|
|
10
|
+
prepareHostControlDirectory,
|
|
11
|
+
removeHostControlWorkerToken,
|
|
12
|
+
resolveHostControlEndpoint
|
|
13
|
+
} from './path.ts';
|
|
14
|
+
import {
|
|
15
|
+
HOST_CONTROL_MAX_REQUEST_BYTES,
|
|
16
|
+
validateHostControlRequest,
|
|
17
|
+
type HostControlRequest,
|
|
18
|
+
type HostControlResponse
|
|
19
|
+
} from './client.ts';
|
|
20
|
+
import { acquireFileLock } from '../fs/file-lock.ts';
|
|
21
|
+
import { appendHostControlAudit } from './audit.ts';
|
|
22
|
+
|
|
23
|
+
export type HostControlDispatch = (request: HostControlRequest) => Promise<{ stdout: string; stderr: string; exitCode: number }>;
|
|
24
|
+
|
|
25
|
+
export type HostControlAudit = Readonly<{
|
|
26
|
+
requestId: string;
|
|
27
|
+
taskId: string | null;
|
|
28
|
+
operation: string;
|
|
29
|
+
scope: string;
|
|
30
|
+
phase: 'accepted' | 'completed' | 'rejected';
|
|
31
|
+
outcome: string;
|
|
32
|
+
authorityKind: 'host-broker';
|
|
33
|
+
transportKind: 'host-fixed-transport';
|
|
34
|
+
identityDigest: string;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export type HostControlServerOptions = Readonly<{
|
|
38
|
+
endpoint?: string;
|
|
39
|
+
dispatch: HostControlDispatch;
|
|
40
|
+
audit?: (entry: HostControlAudit) => void;
|
|
41
|
+
}>;
|
|
42
|
+
|
|
43
|
+
function auditFor(request: HostControlRequest, phase: HostControlAudit['phase'], outcome: string): HostControlAudit {
|
|
44
|
+
return {
|
|
45
|
+
requestId: request.id,
|
|
46
|
+
taskId: request.taskId,
|
|
47
|
+
operation: request.operation,
|
|
48
|
+
scope: request.scope,
|
|
49
|
+
phase,
|
|
50
|
+
outcome,
|
|
51
|
+
authorityKind: 'host-broker',
|
|
52
|
+
transportKind: 'host-fixed-transport',
|
|
53
|
+
identityDigest: createHash('sha256').update(`${request.taskId ?? '-'}\0${request.generation ?? '-'}`, 'utf8').digest('hex')
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function failedResponse(id: string, status: 'rejected' | 'unknown', code: string, message: string): HostControlResponse {
|
|
58
|
+
const error = { code, message };
|
|
59
|
+
const stdout = `${JSON.stringify({ status: 'failed', changed: status === 'rejected' ? false : null, error })}\n`;
|
|
60
|
+
return { version: 1, id, status, exitCode: 1, stdout, stderr: '', error };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function handleConnection(socket: net.Socket, options: HostControlServerOptions): Promise<void> {
|
|
64
|
+
await new Promise<void>((resolve) => {
|
|
65
|
+
let input = '';
|
|
66
|
+
let completed = false;
|
|
67
|
+
let processing = false;
|
|
68
|
+
socket.setEncoding('utf8');
|
|
69
|
+
// A disconnected caller does not cancel an already dispatched domain operation.
|
|
70
|
+
socket.on('error', () => socket.destroy());
|
|
71
|
+
socket.on('close', () => { if (!processing) resolve(); });
|
|
72
|
+
socket.on('end', () => { if (!processing) socket.end(); });
|
|
73
|
+
const finish = (value: HostControlResponse): void => {
|
|
74
|
+
if (completed || socket.destroyed) return;
|
|
75
|
+
completed = true;
|
|
76
|
+
socket.end(`${JSON.stringify(value)}\n`);
|
|
77
|
+
};
|
|
78
|
+
socket.on('data', async (chunk: string) => {
|
|
79
|
+
if (completed || processing) return;
|
|
80
|
+
input += chunk;
|
|
81
|
+
if (Buffer.byteLength(input, 'utf8') > HOST_CONTROL_MAX_REQUEST_BYTES) {
|
|
82
|
+
finish(failedResponse('invalid', 'rejected', 'HOST_CONTROL_REQUEST_TOO_LARGE', 'request exceeds the control limit'));
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const newline = input.indexOf('\n');
|
|
86
|
+
if (newline < 0) return;
|
|
87
|
+
const raw = input.slice(0, newline);
|
|
88
|
+
let request: HostControlRequest;
|
|
89
|
+
try { request = validateHostControlRequest(JSON.parse(raw)); }
|
|
90
|
+
catch (error) {
|
|
91
|
+
finish(failedResponse('invalid', 'rejected', 'HOST_CONTROL_REQUEST_INVALID', error instanceof Error ? error.message : String(error)));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
processing = true;
|
|
95
|
+
let started = false;
|
|
96
|
+
try {
|
|
97
|
+
options.audit?.(auditFor(request, 'accepted', 'in-progress'));
|
|
98
|
+
started = true;
|
|
99
|
+
const result = await options.dispatch(request);
|
|
100
|
+
options.audit?.(auditFor(request, 'completed', result.exitCode === 0 ? 'success' : 'failure'));
|
|
101
|
+
finish({ version: 1, id: request.id, status: 'completed', ...result, error: null });
|
|
102
|
+
} catch (error) {
|
|
103
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
104
|
+
const code = /^([A-Z][A-Z0-9_]+)/u.exec(message)?.[1] ?? 'HOST_CONTROL_DISPATCH_FAILED';
|
|
105
|
+
const status = started ? 'unknown' : 'rejected';
|
|
106
|
+
try { options.audit?.(auditFor(request, started ? 'completed' : 'rejected', status)); }
|
|
107
|
+
catch { /* Return the uncertainty even when the audit sink is unavailable. */ }
|
|
108
|
+
finish(failedResponse(request.id, status, code, message));
|
|
109
|
+
} finally {
|
|
110
|
+
resolve();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type RunningHostControlServer = Readonly<{
|
|
117
|
+
endpoint: string;
|
|
118
|
+
server: net.Server;
|
|
119
|
+
close: () => Promise<void>;
|
|
120
|
+
}>;
|
|
121
|
+
|
|
122
|
+
export async function startHostControlServer(options: HostControlServerOptions): Promise<RunningHostControlServer> {
|
|
123
|
+
const endpoint = options.endpoint ?? resolveHostControlEndpoint();
|
|
124
|
+
const audit = options.audit ?? ((entry: HostControlAudit) => appendHostControlAudit(endpoint, entry));
|
|
125
|
+
prepareHostControlDirectory(endpoint);
|
|
126
|
+
const lock = acquireFileLock(`${endpoint}.lock`);
|
|
127
|
+
let server: net.Server | undefined;
|
|
128
|
+
try {
|
|
129
|
+
ensureHostControlWorkerToken(endpoint);
|
|
130
|
+
try {
|
|
131
|
+
const existing = fs.lstatSync(endpoint);
|
|
132
|
+
if (existing.isSymbolicLink() || !existing.isSocket()) throw new Error('HOST_CONTROL_ENDPOINT_INVALID');
|
|
133
|
+
fs.unlinkSync(endpoint);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
|
|
136
|
+
}
|
|
137
|
+
const connections = new Set<Promise<void>>();
|
|
138
|
+
server = net.createServer({ allowHalfOpen: true }, (socket) => {
|
|
139
|
+
const connection = handleConnection(socket, { ...options, audit });
|
|
140
|
+
connections.add(connection);
|
|
141
|
+
void connection.finally(() => connections.delete(connection));
|
|
142
|
+
});
|
|
143
|
+
const listeningServer = server;
|
|
144
|
+
await new Promise<void>((resolve, reject) => {
|
|
145
|
+
listeningServer.once('error', reject);
|
|
146
|
+
listeningServer.listen(endpoint, () => { listeningServer.off('error', reject); resolve(); });
|
|
147
|
+
});
|
|
148
|
+
fs.chmodSync(endpoint, HOST_CONTROL_SOCKET_MODE);
|
|
149
|
+
const inspection = inspectHostControlEndpoint(endpoint, { uid: process.getuid?.() });
|
|
150
|
+
if (!inspection.ok) {
|
|
151
|
+
await new Promise<void>((resolve) => listeningServer.close(() => resolve()));
|
|
152
|
+
removeHostControlWorkerToken(endpoint);
|
|
153
|
+
throw new Error(inspection.code ?? 'HOST_CONTROL_ENDPOINT_INVALID');
|
|
154
|
+
}
|
|
155
|
+
let closing: Promise<void> | undefined;
|
|
156
|
+
return {
|
|
157
|
+
endpoint,
|
|
158
|
+
server,
|
|
159
|
+
close: () => closing ??= (async () => {
|
|
160
|
+
try {
|
|
161
|
+
await new Promise<void>((resolve) => listeningServer.close(() => resolve()));
|
|
162
|
+
await Promise.all(connections);
|
|
163
|
+
await fs.promises.rm(endpoint, { force: true });
|
|
164
|
+
removeHostControlWorkerToken(endpoint);
|
|
165
|
+
} finally { lock.release(); }
|
|
166
|
+
})()
|
|
167
|
+
};
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (server?.listening) await new Promise<void>((resolve) => server!.close(() => resolve()));
|
|
170
|
+
lock.release();
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export async function serveHostControl(options: HostControlServerOptions, signal?: AbortSignal): Promise<void> {
|
|
176
|
+
const running = await startHostControlServer(options);
|
|
177
|
+
if (!signal) return;
|
|
178
|
+
if (signal.aborted) { await running.close(); return; }
|
|
179
|
+
await new Promise<void>((resolve) => signal.addEventListener('abort', () => { void running.close().then(resolve); }, { once: true }));
|
|
180
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
inspectHostControlEndpoint,
|
|
8
|
+
resolveHostControlEndpoint,
|
|
9
|
+
type HostControlPlatform
|
|
10
|
+
} from './path.ts';
|
|
11
|
+
import { serveHostControl, startHostControlServer, type HostControlDispatch, type RunningHostControlServer } from './server.ts';
|
|
12
|
+
|
|
13
|
+
export type HostControlServiceOptions = Readonly<{
|
|
14
|
+
platform?: HostControlPlatform;
|
|
15
|
+
uid?: number;
|
|
16
|
+
username?: string;
|
|
17
|
+
endpoint?: string;
|
|
18
|
+
dispatch: HostControlDispatch;
|
|
19
|
+
audit?: Parameters<typeof startHostControlServer>[0]['audit'];
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
export type HostControlServicePlatform = 'linux' | 'darwin' | 'unsupported';
|
|
23
|
+
|
|
24
|
+
function servicePlatform(): HostControlServicePlatform {
|
|
25
|
+
if (process.platform === 'linux' || process.platform === 'darwin') return process.platform;
|
|
26
|
+
return 'unsupported';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function serviceEntryPoint(): string {
|
|
30
|
+
const compiled = fileURLToPath(new URL('../../bin/internal-cli.js', import.meta.url));
|
|
31
|
+
if (fs.existsSync(compiled)) return fs.realpathSync.native(compiled);
|
|
32
|
+
const candidate = process.argv[1];
|
|
33
|
+
if (candidate && fs.existsSync(candidate)) return fs.realpathSync.native(candidate);
|
|
34
|
+
return fs.realpathSync.native(fileURLToPath(new URL('../../bin/internal-cli.ts', import.meta.url)));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function xml(value: string): string {
|
|
38
|
+
return value.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function systemdArgument(value: string): string {
|
|
42
|
+
const escaped = value.replace(/[\\"]/g, '\\$&')
|
|
43
|
+
.replace(/[\x00-\x1f\x7f]/g, (character) => `\\x${character.charCodeAt(0).toString(16).padStart(2, '0')}`)
|
|
44
|
+
.replaceAll('%', '%%');
|
|
45
|
+
return `"${escaped}"`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function servicePaths(platform: HostControlServicePlatform = servicePlatform()): Readonly<{ unit?: string; plist?: string }> {
|
|
49
|
+
if (platform === 'linux') return { unit: path.join(os.homedir(), '.config', 'systemd', 'user', 'agent-infra-host-control.service') };
|
|
50
|
+
if (platform === 'darwin') return { plist: path.join(os.homedir(), 'Library', 'LaunchAgents', 'com.fitlab-ai.agent-infra.host-control.plist') };
|
|
51
|
+
throw new Error('HOST_CONTROL_UNSUPPORTED_PLATFORM');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function installHostControlService(platform: HostControlServicePlatform = servicePlatform()): string {
|
|
55
|
+
const paths = servicePaths(platform);
|
|
56
|
+
const entry = serviceEntryPoint();
|
|
57
|
+
if (paths.unit) {
|
|
58
|
+
// mkdir only applies mode to directories it creates, and this one usually
|
|
59
|
+
// already exists, so restate the intended mode explicitly.
|
|
60
|
+
fs.mkdirSync(path.dirname(paths.unit), { recursive: true, mode: 0o700 });
|
|
61
|
+
fs.chmodSync(path.dirname(paths.unit), 0o700);
|
|
62
|
+
fs.writeFileSync(paths.unit, [
|
|
63
|
+
'[Unit]',
|
|
64
|
+
'Description=agent-infra host-control service',
|
|
65
|
+
'',
|
|
66
|
+
'[Service]',
|
|
67
|
+
// The ':' executable prefix disables environment expansion for literal paths.
|
|
68
|
+
`ExecStart=${systemdArgument(`:${process.execPath}`)} ${systemdArgument(entry)} host-control serve`,
|
|
69
|
+
'Restart=on-failure',
|
|
70
|
+
'NoNewPrivileges=true',
|
|
71
|
+
// Workers receive host paths, including working directories and inputs under /tmp.
|
|
72
|
+
'PrivateTmp=false',
|
|
73
|
+
'',
|
|
74
|
+
'[Install]',
|
|
75
|
+
'WantedBy=default.target',
|
|
76
|
+
''
|
|
77
|
+
].join('\n'), { mode: 0o600 });
|
|
78
|
+
fs.chmodSync(paths.unit, 0o600);
|
|
79
|
+
return paths.unit;
|
|
80
|
+
}
|
|
81
|
+
const plist = paths.plist!;
|
|
82
|
+
fs.mkdirSync(path.dirname(plist), { recursive: true, mode: 0o700 });
|
|
83
|
+
fs.chmodSync(path.dirname(plist), 0o700);
|
|
84
|
+
const argumentsXml = [process.execPath, entry, 'host-control', 'serve']
|
|
85
|
+
.map((argument) => ` <string>${xml(argument)}</string>`)
|
|
86
|
+
.join('\n');
|
|
87
|
+
fs.writeFileSync(plist, [
|
|
88
|
+
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
89
|
+
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
|
|
90
|
+
'<plist version="1.0">',
|
|
91
|
+
'<dict>',
|
|
92
|
+
' <key>Label</key>',
|
|
93
|
+
' <string>com.fitlab-ai.agent-infra.host-control</string>',
|
|
94
|
+
' <key>ProgramArguments</key>',
|
|
95
|
+
' <array>',
|
|
96
|
+
argumentsXml,
|
|
97
|
+
' </array>',
|
|
98
|
+
' <key>RunAtLoad</key>',
|
|
99
|
+
' <true/>',
|
|
100
|
+
' <key>KeepAlive</key>',
|
|
101
|
+
' <true/>',
|
|
102
|
+
'</dict>',
|
|
103
|
+
'</plist>',
|
|
104
|
+
''
|
|
105
|
+
].join('\n'), { mode: 0o600 });
|
|
106
|
+
fs.chmodSync(plist, 0o600);
|
|
107
|
+
return plist;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function uninstallHostControlService(platform: HostControlServicePlatform = servicePlatform()): string {
|
|
111
|
+
const paths = servicePaths(platform);
|
|
112
|
+
const target = paths.unit ?? paths.plist!;
|
|
113
|
+
fs.rmSync(target, { force: true });
|
|
114
|
+
return target;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function hostControlServiceEndpoint(options: Pick<HostControlServiceOptions, 'platform' | 'uid' | 'username' | 'endpoint'> = {}): string {
|
|
118
|
+
return options.endpoint ?? resolveHostControlEndpoint(options);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function startHostControlService(options: HostControlServiceOptions): Promise<RunningHostControlServer> {
|
|
122
|
+
return startHostControlServer({ endpoint: hostControlServiceEndpoint(options), dispatch: options.dispatch, ...(options.audit ? { audit: options.audit } : {}) });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function serveHostControlService(options: HostControlServiceOptions, signal?: AbortSignal): Promise<void> {
|
|
126
|
+
await serveHostControl({ endpoint: hostControlServiceEndpoint(options), dispatch: options.dispatch, ...(options.audit ? { audit: options.audit } : {}) }, signal);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function hostControlServiceStatus(options: Pick<HostControlServiceOptions, 'platform' | 'uid' | 'username' | 'endpoint'> = {}): Readonly<{ endpoint: string; available: boolean; code: string | null }> {
|
|
130
|
+
const endpoint = hostControlServiceEndpoint(options);
|
|
131
|
+
const result = inspectHostControlEndpoint(endpoint, { uid: options.uid ?? process.getuid?.() });
|
|
132
|
+
return { endpoint, available: result.ok, code: result.code };
|
|
133
|
+
}
|
package/lib/init.ts
CHANGED
|
@@ -61,6 +61,7 @@ const PLATFORM_DEFAULT_ENGINES = Object.freeze({
|
|
|
61
61
|
darwin: 'colima',
|
|
62
62
|
win32: 'wsl2'
|
|
63
63
|
});
|
|
64
|
+
const DEMO_PLATFORM_ENV = 'AGENT_INFRA_DEMO_PLATFORM';
|
|
64
65
|
|
|
65
66
|
function detectProjectName(): string {
|
|
66
67
|
try {
|
|
@@ -88,6 +89,12 @@ function detectOrgName(): string {
|
|
|
88
89
|
return '';
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
function resolveInitPlatform(): NodeJS.Platform {
|
|
93
|
+
const override = process.env[DEMO_PLATFORM_ENV];
|
|
94
|
+
if (override === 'linux' || override === 'darwin' || override === 'win32') return override;
|
|
95
|
+
return platform();
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
const VALID_NAME_RE = /^[a-zA-Z0-9_.@-]+$/;
|
|
92
99
|
|
|
93
100
|
function parseLocalSources(input: string): SourceEntry[] {
|
|
@@ -160,7 +167,7 @@ async function cmdInit(): Promise<void> {
|
|
|
160
167
|
return;
|
|
161
168
|
}
|
|
162
169
|
|
|
163
|
-
const currentPlatform =
|
|
170
|
+
const currentPlatform = resolveInitPlatform();
|
|
164
171
|
const defaultEngine = PLATFORM_DEFAULT_ENGINES[currentPlatform as keyof typeof PLATFORM_DEFAULT_ENGINES];
|
|
165
172
|
const engineChoices = enginesForPlatform(currentPlatform).sort((left, right) => {
|
|
166
173
|
if (left === defaultEngine) return -1;
|
|
@@ -288,6 +295,12 @@ async function cmdInit(): Promise<void> {
|
|
|
288
295
|
replacements
|
|
289
296
|
);
|
|
290
297
|
ok('Installed .agents/scripts/lib/agent-infra-package.js');
|
|
298
|
+
renderFile(
|
|
299
|
+
path.join(templateDir, '.agents', 'scripts', 'package.json'),
|
|
300
|
+
path.join('.agents', 'scripts', 'package.json'),
|
|
301
|
+
replacements
|
|
302
|
+
);
|
|
303
|
+
ok('Installed .agents/scripts/package.json');
|
|
291
304
|
|
|
292
305
|
const reconcileResult = applyAgentClientReconciliation(workflowPlan);
|
|
293
306
|
for (const target of reconcileResult.applied) ok(`Installed ${target}`);
|
|
@@ -317,4 +330,4 @@ async function cmdInit(): Promise<void> {
|
|
|
317
330
|
}
|
|
318
331
|
}
|
|
319
332
|
|
|
320
|
-
export { cmdInit };
|
|
333
|
+
export { cmdInit, resolveInitPlatform };
|
|
@@ -9,6 +9,7 @@ import { normalizeCustomTUIs } from '../agent-clients/custom-tuis.ts';
|
|
|
9
9
|
import { renderNextStepCommands } from '../agent-clients/next-steps.ts';
|
|
10
10
|
import { getAgentClientModelSelection } from '../agent-clients/registry.ts';
|
|
11
11
|
import { isAgentClientId } from '../agent-clients/types.ts';
|
|
12
|
+
import { ensureInternalHandlerRoute, internalHandlerRoute } from './cli-route-inventory.ts';
|
|
12
13
|
|
|
13
14
|
const USAGE = 'Usage: agent-infra-internal agent-client <next-steps|model-selection> [options]\n';
|
|
14
15
|
|
|
@@ -35,7 +36,7 @@ function parseArgs(args: string[]): ParsedArgs | null {
|
|
|
35
36
|
process.stdout.write(USAGE);
|
|
36
37
|
return null;
|
|
37
38
|
}
|
|
38
|
-
if (args[0]
|
|
39
|
+
if (!internalHandlerRoute('agent-client', 'next-steps', args[0] ?? '')) {
|
|
39
40
|
failure('AGENT_CLIENT_PAYLOAD_INVALID', "operation must be 'next-steps'");
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
@@ -84,7 +85,8 @@ function parseArgs(args: string[]): ParsedArgs | null {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
function agentClient(args: string[] = []): void {
|
|
87
|
-
if (
|
|
88
|
+
if (!ensureInternalHandlerRoute('agent-client', args)) return;
|
|
89
|
+
if (internalHandlerRoute('agent-client', 'model-selection', args[0] ?? '')) {
|
|
88
90
|
const values: Record<string, string> = {};
|
|
89
91
|
const seen = new Set<string>();
|
|
90
92
|
for (let index = 1; index < args.length; index += 1) {
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export const PUBLIC_CLI_COMMAND_ALIASES = Object.freeze({
|
|
2
|
+
'': 'help',
|
|
3
|
+
s: 'sandbox',
|
|
4
|
+
t: 'task',
|
|
5
|
+
'--version': 'version',
|
|
6
|
+
'-v': 'version'
|
|
7
|
+
} as const);
|
|
8
|
+
|
|
9
|
+
export const PUBLIC_CLI_SELECTOR_ALIASES = Object.freeze({
|
|
10
|
+
task: Object.freeze({ d: 'decisions' })
|
|
11
|
+
} as const);
|
|
12
|
+
|
|
13
|
+
export const PUBLIC_CLI_ROUTE_SELECTORS = Object.freeze({
|
|
14
|
+
'agent-client': ['list', 'status', 'enable', 'disable', 'configure'],
|
|
15
|
+
cp: ['cp'],
|
|
16
|
+
data: ['capture', 'verify', 'audit', 'repair', 'export'],
|
|
17
|
+
decide: ['decide'],
|
|
18
|
+
help: ['help'],
|
|
19
|
+
init: ['init'],
|
|
20
|
+
merge: ['merge'],
|
|
21
|
+
run: ['create-task', 'task-skill', 'recreate'],
|
|
22
|
+
sandbox: ['create', 'exec', 'ls', 'show', 'prune', 'rebuild', 'refresh', 'rm', 'start', 'vm'],
|
|
23
|
+
server: ['start', 'stop', 'status', 'logs', '__daemon'],
|
|
24
|
+
task: ['cat', 'decisions', 'files', 'grep', 'issue-body', 'log', 'ls', 'show', 'status'],
|
|
25
|
+
sync: ['sync'],
|
|
26
|
+
update: ['update'],
|
|
27
|
+
version: ['version']
|
|
28
|
+
} as const);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The selector definitions consumed by every internal handler. Keep this
|
|
32
|
+
* module free of handler imports so the pre-import task-view guard remains
|
|
33
|
+
* effective.
|
|
34
|
+
*/
|
|
35
|
+
export const INTERNAL_HANDLER_ROUTE_SELECTORS = Object.freeze({
|
|
36
|
+
'task-create': ['input'],
|
|
37
|
+
'task-qualification': ['proposal', 'confirm', 'supersede', 'revoke'],
|
|
38
|
+
'sandbox-control': ['serve', 'execute', 'recover', 'client'],
|
|
39
|
+
'host-control': ['serve', 'status', 'install', 'uninstall'],
|
|
40
|
+
'agent-client': ['next-steps', 'model-selection'],
|
|
41
|
+
'codex-lifecycle': ['preflight', 'capability-arm', 'hook-event', 'resolve-start', 'resolve-stop', 'consume'],
|
|
42
|
+
'codex-sandbox-controller': ['verify-context', 'run'],
|
|
43
|
+
'git-workflow': ['inspect', 'preview-tree', 'snapshot', 'compare-trees', 'commit', 'push-rebased'],
|
|
44
|
+
'task-delivery': ['deliver'],
|
|
45
|
+
'release-workflow': ['inspect', 'prepare', 'publish', 'post-prepare', 'post-publish'],
|
|
46
|
+
'platform-release-notes': ['context', 'stage', 'publish'],
|
|
47
|
+
'platform-security': ['read', 'dismiss'],
|
|
48
|
+
'platform-metadata': ['init-labels', 'init-milestones'],
|
|
49
|
+
'platform-context': ['resolve'],
|
|
50
|
+
'platform-comment': ['list', 'owner', 'backfill', 'sync'],
|
|
51
|
+
'platform-issue': ['inspect', 'create', 'bind', 'sync'],
|
|
52
|
+
'platform-pr': ['inspect', 'summary-context', 'resolve-external', 'create', 'bind', 'skip', 'sync', 'change-report', 'summary-sync', 'sync-in-labels'],
|
|
53
|
+
'platform-pr-review': ['inspect', 'list', 'publish-pr', 'publish-task'],
|
|
54
|
+
'pr-review-grade': ['decide', 'resolve-host', 'verify-artifact'],
|
|
55
|
+
'platform-checks': ['inspect', 'watch', 'resolve-run', 'logs'],
|
|
56
|
+
'task-context': ['resolve'],
|
|
57
|
+
'task-ledger': ['decision-next-id', 'stage-status', 'finding-upsert', 'finding-respond', 'finding-review', 'decision-upsert', 'rework-intent-upsert'],
|
|
58
|
+
'task-warning': ['list', 'add', 'set-status'],
|
|
59
|
+
'task-activity': ['pr-review-inspect', 'pr-review-start', 'pr-review-complete', 'pr-review-terminate'],
|
|
60
|
+
'task-artifact': ['inspect', 'init', 'repair', 'finalize-local'],
|
|
61
|
+
'task-orchestration': ['status', 'progress'],
|
|
62
|
+
'task-review': ['finalize-summary'],
|
|
63
|
+
'task-event': ['event'],
|
|
64
|
+
'task-invalidation': ['reconcile'],
|
|
65
|
+
'task-override': ['diagnose', 'issue', 'consume'],
|
|
66
|
+
'task-lifecycle': ['intent'],
|
|
67
|
+
'task-finalization': ['complete'],
|
|
68
|
+
'task-short-id': ['list', 'list-verify', 'alloc', 'release', 'resolve'],
|
|
69
|
+
'task-snapshot': ['snapshot'],
|
|
70
|
+
'task-verify': ['event'],
|
|
71
|
+
'task-validate': ['snapshot', 'inplace'],
|
|
72
|
+
'manual-validation': ['transaction']
|
|
73
|
+
} as const);
|
|
74
|
+
|
|
75
|
+
export const INTERNAL_CLI_ROUTE_SELECTORS = INTERNAL_HANDLER_ROUTE_SELECTORS;
|
|
76
|
+
|
|
77
|
+
function first(args: readonly string[]): string {
|
|
78
|
+
return args[0] ?? '';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function optionValue(args: readonly string[], name: string): string | undefined {
|
|
82
|
+
const index = args.indexOf(name);
|
|
83
|
+
if (index >= 0) return args[index + 1];
|
|
84
|
+
const prefix = `${name}=`;
|
|
85
|
+
return args.find((arg) => arg.startsWith(prefix))?.slice(prefix.length);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function internalRouteSelector(command: string, args: readonly string[]): string {
|
|
89
|
+
if (command === 'sandbox-control') return first(args);
|
|
90
|
+
if (command === 'task-create') return 'input';
|
|
91
|
+
if (command === 'task-qualification') return args[1] ?? '';
|
|
92
|
+
if (command === 'task-lifecycle') return args[1] ? 'intent' : '';
|
|
93
|
+
if (command === 'task-finalization') return args[1] === 'complete' ? 'complete' : '';
|
|
94
|
+
if (command === 'task-event') return args[1] ? 'event' : '';
|
|
95
|
+
if (command === 'task-verify') return args[0] && args[1] ? 'event' : '';
|
|
96
|
+
if (command === 'task-snapshot') return 'snapshot';
|
|
97
|
+
if (command === 'task-validate') return optionValue(args, '--scope') ?? 'snapshot';
|
|
98
|
+
if (command === 'task-short-id') return first(args) === 'list' && args.includes('--verify') ? 'list-verify' : first(args);
|
|
99
|
+
if (command === 'task-orchestration') return args[1] === 'status' ? 'status' : args[1] ? 'progress' : '';
|
|
100
|
+
if (command === 'task-review') return args[1] ?? '';
|
|
101
|
+
if (command === 'task-invalidation') return args[1] ?? '';
|
|
102
|
+
if (command === 'task-override') return args[1] ?? '';
|
|
103
|
+
if (command === 'task-artifact') return args[1] ?? '';
|
|
104
|
+
if (command === 'platform-pr-review' && first(args) === 'publish') {
|
|
105
|
+
const scope = optionValue(args, '--scope') ?? '';
|
|
106
|
+
return /^TASK-\d{8}-\d{6}$/u.test(scope) ? 'publish-task' : /^pr\d+$/u.test(scope) ? 'publish-pr' : '';
|
|
107
|
+
}
|
|
108
|
+
if (['task-ledger', 'task-warning', 'task-activity'].includes(command)) return args[1] ?? '';
|
|
109
|
+
if (command === 'task-delivery') return args[1] ?? '';
|
|
110
|
+
if (command === 'task-context') return first(args);
|
|
111
|
+
return first(args);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function isInternalHandlerRoute(command: string, args: readonly string[]): boolean {
|
|
115
|
+
if (args[0] === '--help' || args[0] === '-h') return true;
|
|
116
|
+
const selector = internalRouteSelector(command, args);
|
|
117
|
+
const selectors = INTERNAL_HANDLER_ROUTE_SELECTORS[command as keyof typeof INTERNAL_HANDLER_ROUTE_SELECTORS];
|
|
118
|
+
return Boolean(selector && selectors?.some((candidate) => candidate === selector));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Marks a selector at the handler's actual dispatch branch.
|
|
123
|
+
*
|
|
124
|
+
* The call is intentionally side-effect free so the top-level task-view guard
|
|
125
|
+
* can still run before a handler module is imported. Route coverage tests read
|
|
126
|
+
* these branch markers independently from the pre-import inventory.
|
|
127
|
+
*/
|
|
128
|
+
export function internalHandlerRoute(command: string, selector: string, actualSelector: string): boolean {
|
|
129
|
+
return command.length > 0 && selector === actualSelector;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function ensureInternalHandlerRoute(command: string, args: readonly string[]): boolean {
|
|
133
|
+
if (isInternalHandlerRoute(command, args)) return true;
|
|
134
|
+
const selector = internalRouteSelector(command, args);
|
|
135
|
+
process.stdout.write(`${JSON.stringify({
|
|
136
|
+
status: 'failed',
|
|
137
|
+
changed: false,
|
|
138
|
+
error: { code: 'INTERNAL_ROUTE_UNREGISTERED', message: `operation '${command} ${selector || first(args)}' is not registered` }
|
|
139
|
+
})}\n`);
|
|
140
|
+
process.exitCode = 1;
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
sealCodexOrchestrationDelegation,
|
|
23
23
|
sealCodexParentDelegation
|
|
24
24
|
} from '../task/codex-orchestration.ts';
|
|
25
|
+
import { ensureInternalHandlerRoute, internalHandlerRoute } from './cli-route-inventory.ts';
|
|
25
26
|
|
|
26
27
|
const USAGE = 'Usage: agent-infra-internal codex-lifecycle <capability-arm|hook-event|resolve-start|resolve-stop|preflight|consume> [options]\n';
|
|
27
28
|
const MANAGED_AGENT = /^agent-infra-lifecycle-(executor|reviewer)$/;
|
|
@@ -162,10 +163,11 @@ function payloadText(payload: unknown, key: string): string {
|
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
async function codexLifecycle(args: string[] = []): Promise<void> {
|
|
166
|
+
if (!ensureInternalHandlerRoute('codex-lifecycle', args)) return;
|
|
165
167
|
const parsed = parse(args);
|
|
166
168
|
if (!parsed || process.exitCode) return;
|
|
167
169
|
try {
|
|
168
|
-
if (
|
|
170
|
+
if (internalHandlerRoute('codex-lifecycle', 'preflight', parsed.operation)) {
|
|
169
171
|
const format = parsed.values['--format'] ?? 'json';
|
|
170
172
|
if (!['text', 'json'].includes(format)) throw new Error("format must be 'text' or 'json'");
|
|
171
173
|
const runtimeFields = [
|
|
@@ -188,7 +190,7 @@ async function codexLifecycle(args: string[] = []): Promise<void> {
|
|
|
188
190
|
return;
|
|
189
191
|
}
|
|
190
192
|
|
|
191
|
-
if (
|
|
193
|
+
if (internalHandlerRoute('codex-lifecycle', 'capability-arm', parsed.operation)) {
|
|
192
194
|
const taskId = parsed.values['--task-id'];
|
|
193
195
|
if (!taskId) throw new Error('capability-arm requires --task-id');
|
|
194
196
|
const resolved = resolveTaskRef(taskId, { repoRoot: process.cwd() });
|
|
@@ -201,7 +203,7 @@ async function codexLifecycle(args: string[] = []): Promise<void> {
|
|
|
201
203
|
output({
|
|
202
204
|
status: 'armed',
|
|
203
205
|
changed: true,
|
|
204
|
-
|
|
206
|
+
capabilityRef: armed.capabilityRef,
|
|
205
207
|
marker: armed.marker,
|
|
206
208
|
expiresAt: armed.expiresAt,
|
|
207
209
|
buildIdentity: armed.buildIdentity,
|
|
@@ -211,7 +213,7 @@ async function codexLifecycle(args: string[] = []): Promise<void> {
|
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
const store = createCodexLifecycleStore({ cliVersion: cliVersion() });
|
|
214
|
-
if (
|
|
216
|
+
if (internalHandlerRoute('codex-lifecycle', 'hook-event', parsed.operation)) {
|
|
215
217
|
const phase = parsed.values['--event'];
|
|
216
218
|
if (!phase || !['pre-tool', 'subagent-start', 'post-tool', 'subagent-stop'].includes(phase)) {
|
|
217
219
|
throw new Error('hook-event requires a known --event');
|
|
@@ -221,12 +223,12 @@ async function codexLifecycle(args: string[] = []): Promise<void> {
|
|
|
221
223
|
}
|
|
222
224
|
const payload = await readStdin();
|
|
223
225
|
if (phase === 'post-tool') {
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
226
|
+
const capabilityRef = payloadText(payload, 'capabilityRef');
|
|
227
|
+
if (capabilityRef) {
|
|
226
228
|
const capabilityStore = createCodexCapabilityStore();
|
|
227
|
-
const armed = capabilityStore.
|
|
228
|
-
const capability =
|
|
229
|
-
|
|
229
|
+
const armed = capabilityStore.inspectReference(capabilityRef);
|
|
230
|
+
const capability = capabilityStore.attestByReference({
|
|
231
|
+
capabilityRef,
|
|
230
232
|
sessionId: payloadText(payload, 'sessionId'),
|
|
231
233
|
turnId: payloadText(payload, 'turnId'),
|
|
232
234
|
toolUseId: payloadText(payload, 'toolUseId'),
|
|
@@ -348,7 +350,7 @@ async function codexLifecycle(args: string[] = []): Promise<void> {
|
|
|
348
350
|
|
|
349
351
|
const childThreadId = parsed.values['--child-id'];
|
|
350
352
|
if (!childThreadId) throw new Error(`operation '${parsed.operation}' requires --child-id`);
|
|
351
|
-
if (
|
|
353
|
+
if (internalHandlerRoute('codex-lifecycle', 'resolve-start', parsed.operation)) {
|
|
352
354
|
if (store.read(childThreadId).state.spawn?.hookDefinitionHash !== hookDefinitionHash()) {
|
|
353
355
|
throw new Error('Codex lifecycle hook definition hash is stale');
|
|
354
356
|
}
|
|
@@ -360,7 +362,7 @@ async function codexLifecycle(args: string[] = []): Promise<void> {
|
|
|
360
362
|
if (latest.state.status !== 'start-ready') process.exitCode = 1;
|
|
361
363
|
return;
|
|
362
364
|
}
|
|
363
|
-
if (
|
|
365
|
+
if (internalHandlerRoute('codex-lifecycle', 'resolve-stop', parsed.operation)) {
|
|
364
366
|
const stopTurnId = store.read(childThreadId).state.stop?.turnId;
|
|
365
367
|
if (!stopTurnId) throw new Error('Codex lifecycle stop hook is not available');
|
|
366
368
|
const terminal = await resolveCodexTerminal(childThreadId, stopTurnId);
|
|
@@ -371,7 +373,7 @@ async function codexLifecycle(args: string[] = []): Promise<void> {
|
|
|
371
373
|
output({ status: latest.state.status, changed: true, evidence: latest.state.stopEvidence, diagnostics: [], error: latest.state.error });
|
|
372
374
|
return;
|
|
373
375
|
}
|
|
374
|
-
if (
|
|
376
|
+
if (internalHandlerRoute('codex-lifecycle', 'consume', parsed.operation)) {
|
|
375
377
|
const consumer = parsed.values['--consumer'];
|
|
376
378
|
if (!consumer) throw new Error('consume requires --consumer');
|
|
377
379
|
const consumed = store.consume(childThreadId, consumer, hookDefinitionHash());
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
runCodexSandboxController,
|
|
3
3
|
verifyCodexSandboxControllerContextWithWarnings
|
|
4
4
|
} from '../agent-clients/adapters/codex-lifecycle/sandbox-controller.ts';
|
|
5
|
+
import { ensureInternalHandlerRoute, internalHandlerRoute } from './cli-route-inventory.ts';
|
|
5
6
|
|
|
6
7
|
const USAGE = 'Usage: agent-infra-internal codex-sandbox-controller <run|verify-context> [options]\n';
|
|
7
8
|
|
|
@@ -20,7 +21,10 @@ function parse(args: string[]): Readonly<{ operation: string; values: Readonly<R
|
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
22
23
|
const operation = args[0];
|
|
23
|
-
if (!operation || ![
|
|
24
|
+
if (!operation || ![
|
|
25
|
+
internalHandlerRoute('codex-sandbox-controller', 'run', operation),
|
|
26
|
+
internalHandlerRoute('codex-sandbox-controller', 'verify-context', operation)
|
|
27
|
+
].some(Boolean)) {
|
|
24
28
|
process.stderr.write(USAGE);
|
|
25
29
|
fail('CODEX_SANDBOX_CONTROLLER_PAYLOAD_INVALID', 'operation must be run or verify-context', 2);
|
|
26
30
|
return null;
|
|
@@ -51,10 +55,11 @@ function parse(args: string[]): Readonly<{ operation: string; values: Readonly<R
|
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
async function codexSandboxController(args: string[] = []): Promise<void> {
|
|
58
|
+
if (!ensureInternalHandlerRoute('codex-sandbox-controller', args)) return;
|
|
54
59
|
const parsed = parse(args);
|
|
55
60
|
if (!parsed || process.exitCode) return;
|
|
56
61
|
try {
|
|
57
|
-
if (
|
|
62
|
+
if (internalHandlerRoute('codex-sandbox-controller', 'verify-context', parsed.operation)) {
|
|
58
63
|
const contextPath = parsed.values['--context']
|
|
59
64
|
?? process.env.AGENT_INFRA_CODEX_CONTROLLER_CONTEXT;
|
|
60
65
|
if (!contextPath) throw new Error('CODEX_SANDBOX_CONTROLLER_CONTEXT_MISSING');
|