@fitlab-ai/agent-infra 0.9.12 → 0.9.14
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 +11 -11
- package/README.zh-CN.md +11 -11
- package/bin/cli.ts +26 -9
- package/dist/bin/cli.js +173 -157
- package/dist/bin/internal-cli.js +66 -40
- package/dist/lib/agent-client.js +5 -0
- package/dist/lib/agent-clients/next-steps.js +6 -1
- package/dist/lib/decide.js +3 -3
- package/dist/lib/internal/agent-client.js +5 -2
- package/dist/lib/internal/cli-route-inventory.js +152 -0
- package/dist/lib/internal/codex-lifecycle.js +9 -6
- package/dist/lib/internal/codex-sandbox-controller.js +8 -2
- package/dist/lib/internal/git-workflow.js +10 -6
- package/dist/lib/internal/platform-checks.js +19 -7
- package/dist/lib/internal/platform-comment.js +25 -13
- package/dist/lib/internal/platform-context.js +6 -3
- package/dist/lib/internal/platform-issue.js +20 -13
- package/dist/lib/internal/platform-metadata.js +88 -0
- package/dist/lib/internal/platform-pr-review.js +26 -13
- package/dist/lib/internal/platform-pr.js +84 -31
- package/dist/lib/internal/platform-release-notes.js +9 -6
- package/dist/lib/internal/platform-security.js +93 -0
- package/dist/lib/internal/pr-review-grade.js +25 -12
- package/dist/lib/internal/release-workflow.js +23 -9
- package/dist/lib/internal/sandbox-control.js +50 -7
- package/dist/lib/internal/task-activity.js +16 -7
- package/dist/lib/internal/task-artifact.js +235 -24
- package/dist/lib/internal/task-context.js +4 -1
- package/dist/lib/internal/task-create.js +50 -17
- package/dist/lib/internal/task-delivery.js +4 -1
- package/dist/lib/internal/task-event.js +10 -4
- package/dist/lib/internal/task-finalization.js +6 -3
- package/dist/lib/internal/task-invalidation.js +63 -0
- package/dist/lib/internal/task-ledger.js +20 -6
- package/dist/lib/internal/task-lifecycle.js +6 -3
- package/dist/lib/internal/task-operation-registry.js +421 -0
- package/dist/lib/internal/task-orchestration.js +12 -0
- package/dist/lib/internal/task-override.js +14 -7
- package/dist/lib/internal/task-qualification.js +90 -0
- package/dist/lib/internal/task-review.js +7 -4
- 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 +7 -2
- package/dist/lib/internal/task-verify.js +11 -7
- package/dist/lib/internal/task-warning.js +11 -4
- package/dist/lib/platform/adapters.js +1 -3
- package/dist/lib/platform/change-request-git-evidence.js +27 -7
- package/dist/lib/platform/comment-safety.js +226 -0
- package/dist/lib/platform/completion-backfill.js +6 -5
- package/dist/lib/platform/context.js +70 -130
- package/dist/lib/platform/github-client.js +1 -1
- package/dist/lib/platform/github-provider.js +1130 -0
- package/dist/lib/platform/in-label-sync.js +143 -0
- package/dist/lib/platform/issue-comments.js +237 -72
- package/dist/lib/platform/issues.js +335 -189
- package/dist/lib/platform/metadata-labels.js +6 -2
- package/dist/lib/platform/none-provider.js +28 -0
- package/dist/lib/platform/pr-change-report.js +545 -0
- package/dist/lib/platform/pr-checks.js +119 -104
- package/dist/lib/platform/pr-review.js +88 -72
- package/dist/lib/platform/pr-summary.js +541 -50
- package/dist/lib/platform/provider-bridge.js +45 -0
- package/dist/lib/platform/provider-contract.d.ts +553 -0
- package/dist/lib/platform/provider-contract.js +99 -0
- package/dist/lib/platform/provider-loader.js +251 -0
- package/dist/lib/platform/provider-validation.js +577 -0
- package/dist/lib/platform/pull-request-metadata.js +8 -6
- package/dist/lib/platform/pull-requests.js +734 -543
- package/dist/lib/platform/release-notes.js +78 -55
- package/dist/lib/platform/releases.js +79 -50
- package/dist/lib/platform/repository-metadata.js +377 -0
- package/dist/lib/platform/resource-identity.d.ts +26 -0
- package/dist/lib/platform/resource-identity.js +92 -0
- package/dist/lib/platform/security-alerts.js +155 -0
- package/dist/lib/platform/task-identities.js +31 -0
- package/dist/lib/platform/verification-required.js +11 -12
- package/dist/lib/platform/verification-sync.js +129 -248
- package/dist/lib/pr-review/evidence-grading.js +19 -6
- package/dist/lib/process-data/index.js +7 -0
- package/dist/lib/run/index.js +68 -23
- package/dist/lib/sandbox/commands/control-status.js +22 -0
- package/dist/lib/sandbox/commands/create.js +32 -6
- package/dist/lib/sandbox/commands/ls.js +5 -0
- package/dist/lib/sandbox/commands/rm.js +827 -120
- package/dist/lib/sandbox/commands/show.js +16 -0
- package/dist/lib/sandbox/control/client.js +174 -19
- 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 +151 -16
- package/dist/lib/sandbox/control/lifecycle.js +621 -127
- package/dist/lib/sandbox/control/native-file-lock.js +177 -0
- package/dist/lib/sandbox/control/protocol.js +77 -0
- package/dist/lib/sandbox/control/server.js +677 -34
- package/dist/lib/sandbox/control/state.js +209 -4
- package/dist/lib/sandbox/control/task-view.js +183 -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 +5 -0
- package/dist/lib/sandbox/recovery.js +21 -1
- package/dist/lib/sandbox/workspace-view.js +2 -1
- package/dist/lib/sandbox/worktree-safety.js +4 -1
- package/dist/lib/server/index.js +8 -0
- package/dist/lib/server/protocol.js +38 -1
- package/dist/lib/task/activity-log.js +8 -1
- package/dist/lib/task/artifact-lifecycle.js +75 -18
- package/dist/lib/task/artifact-operations.js +520 -0
- package/dist/lib/task/artifact-repair-intent.js +59 -0
- package/dist/lib/task/artifact-schema.js +135 -0
- package/dist/lib/task/capabilities.js +310 -0
- package/dist/lib/task/commands/status.js +32 -0
- package/dist/lib/task/commit-operation.js +12 -1
- package/dist/lib/task/control-authority.js +12 -5
- package/dist/lib/task/create-service.js +111 -12
- package/dist/lib/task/create.js +25 -0
- package/dist/lib/task/current-contract.js +5 -1
- package/dist/lib/task/decision-details.js +1 -1
- package/dist/lib/task/events.js +416 -17
- package/dist/lib/task/finalization.js +37 -13
- package/dist/lib/task/human-override.js +58 -36
- package/dist/lib/task/index.js +11 -3
- package/dist/lib/task/invalidation-command.js +86 -0
- package/dist/lib/task/invalidation.js +260 -0
- package/dist/lib/task/ledger-intents.js +37 -0
- package/dist/lib/task/local-artifact-finalization.js +299 -0
- package/dist/lib/task/orchestration.js +240 -144
- package/dist/lib/task/pr-delivery-fact.js +102 -101
- package/dist/lib/task/qualification-audit.js +490 -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 +22 -23
- package/dist/lib/task/review-finalization.js +121 -4
- package/dist/lib/task/review-fingerprint.js +24 -2
- package/dist/lib/task/rework-intent.js +138 -0
- package/dist/lib/task/sections.js +6 -4
- package/dist/lib/task/skill-scope.js +23 -0
- package/dist/lib/task/task-execution-lock.js +27 -17
- package/dist/lib/task/verification-config.js +11 -0
- package/dist/lib/task/verification-engine.js +93 -16
- package/dist/lib/task/verification.js +3 -3
- package/dist/lib/task/workflow-warning-intents.js +1 -1
- package/dist/lib/task/write.js +11 -0
- package/dist/lib/version.js +11 -1
- package/dist/lifecycle-build-manifest.json +3 -3
- package/lib/agent-client.ts +9 -0
- package/lib/agent-clients/next-steps.ts +6 -1
- package/lib/decide.ts +3 -3
- package/lib/init.ts +1 -1
- package/lib/internal/agent-client.ts +4 -2
- package/lib/internal/cli-route-inventory.ts +140 -0
- package/lib/internal/codex-lifecycle.ts +8 -6
- package/lib/internal/codex-sandbox-controller.ts +7 -2
- package/lib/internal/git-workflow.ts +9 -6
- package/lib/internal/platform-checks.ts +14 -6
- package/lib/internal/platform-comment.ts +20 -12
- package/lib/internal/platform-context.ts +5 -3
- package/lib/internal/platform-issue.ts +17 -11
- package/lib/internal/platform-metadata.ts +70 -0
- package/lib/internal/platform-pr-review.ts +23 -12
- package/lib/internal/platform-pr.ts +65 -27
- package/lib/internal/platform-release-notes.ts +8 -6
- package/lib/internal/platform-security.ts +83 -0
- package/lib/internal/pr-review-grade.ts +20 -11
- package/lib/internal/release-workflow.ts +21 -9
- package/lib/internal/sandbox-control.ts +44 -6
- package/lib/internal/task-activity.ts +15 -7
- package/lib/internal/task-artifact.ts +204 -22
- package/lib/internal/task-context.ts +3 -1
- package/lib/internal/task-create.ts +78 -17
- package/lib/internal/task-delivery.ts +3 -1
- package/lib/internal/task-event.ts +9 -4
- package/lib/internal/task-finalization.ts +6 -4
- package/lib/internal/task-invalidation.ts +41 -0
- package/lib/internal/task-ledger.ts +21 -8
- package/lib/internal/task-lifecycle.ts +5 -3
- package/lib/internal/task-operation-registry.ts +482 -0
- package/lib/internal/task-orchestration.ts +12 -0
- package/lib/internal/task-override.ts +15 -9
- package/lib/internal/task-qualification.ts +61 -0
- package/lib/internal/task-review.ts +6 -4
- package/lib/internal/task-short-id.ts +10 -1
- package/lib/internal/task-snapshot.ts +3 -1
- package/lib/internal/task-validate.ts +6 -2
- package/lib/internal/task-verify.ts +10 -7
- package/lib/internal/task-warning.ts +10 -4
- package/lib/platform/adapters.ts +3 -2
- package/lib/platform/change-request-git-evidence.ts +36 -9
- package/lib/platform/comment-safety.ts +250 -0
- package/lib/platform/completion-backfill.ts +9 -8
- package/lib/platform/context.ts +97 -134
- package/lib/platform/github-client.ts +2 -2
- package/lib/platform/github-provider.ts +1132 -0
- package/lib/platform/in-label-sync.ts +208 -0
- package/lib/platform/issue-comments.ts +255 -80
- package/lib/platform/issues.ts +344 -174
- package/lib/platform/metadata-labels.ts +5 -2
- package/lib/platform/none-provider.ts +35 -0
- package/lib/platform/pr-change-report.ts +639 -0
- package/lib/platform/pr-checks.ts +126 -106
- package/lib/platform/pr-review.ts +88 -85
- package/lib/platform/pr-summary.ts +581 -53
- package/lib/platform/provider-bridge.ts +82 -0
- package/lib/platform/provider-contract.ts +611 -0
- package/lib/platform/provider-loader.ts +307 -0
- package/lib/platform/provider-validation.ts +611 -0
- package/lib/platform/pull-request-metadata.ts +10 -7
- package/lib/platform/pull-requests.ts +781 -550
- package/lib/platform/release-notes.ts +76 -59
- package/lib/platform/releases.ts +77 -43
- package/lib/platform/repository-metadata.ts +453 -0
- package/lib/platform/resource-identity.ts +121 -0
- package/lib/platform/security-alerts.ts +191 -0
- package/lib/platform/task-identities.ts +40 -0
- package/lib/platform/types.ts +4 -2
- package/lib/platform/verification-required.ts +11 -13
- package/lib/platform/verification-sync.ts +128 -304
- package/lib/pr-review/evidence-grading.ts +25 -8
- package/lib/process-data/index.ts +7 -0
- package/lib/run/index.ts +62 -22
- package/lib/sandbox/commands/control-status.ts +26 -0
- package/lib/sandbox/commands/create.ts +46 -6
- package/lib/sandbox/commands/ls.ts +7 -0
- package/lib/sandbox/commands/rm.ts +1000 -87
- package/lib/sandbox/commands/show.ts +16 -0
- package/lib/sandbox/control/client.ts +203 -19
- package/lib/sandbox/control/completed-reentry.ts +98 -0
- package/lib/sandbox/control/container-identity.ts +27 -43
- package/lib/sandbox/control/executor.ts +180 -15
- package/lib/sandbox/control/lifecycle.ts +629 -17
- package/lib/sandbox/control/native-file-lock.ts +209 -0
- package/lib/sandbox/control/protocol.ts +118 -2
- package/lib/sandbox/control/server.ts +724 -34
- package/lib/sandbox/control/state.ts +257 -4
- package/lib/sandbox/control/task-view.ts +240 -0
- package/lib/sandbox/engines/authority.ts +365 -0
- package/lib/sandbox/engines/docker-exact-discovery.ts +132 -0
- package/lib/sandbox/index.ts +7 -0
- package/lib/sandbox/recovery.ts +21 -1
- package/lib/sandbox/workspace-view.ts +9 -3
- package/lib/sandbox/worktree-safety.ts +4 -1
- package/lib/server/index.ts +10 -0
- package/lib/server/protocol.ts +36 -1
- package/lib/task/activity-log.ts +8 -0
- package/lib/task/artifact-lifecycle.ts +70 -22
- package/lib/task/artifact-operations.ts +626 -0
- package/lib/task/artifact-repair-intent.ts +71 -0
- package/lib/task/artifact-schema.ts +192 -0
- package/lib/task/capabilities.ts +331 -0
- package/lib/task/commands/status.ts +38 -0
- package/lib/task/commit-operation.ts +12 -1
- package/lib/task/control-authority.ts +22 -9
- package/lib/task/create-service.ts +139 -14
- package/lib/task/create.ts +27 -0
- package/lib/task/current-contract.ts +6 -1
- package/lib/task/decision-details.ts +6 -2
- package/lib/task/events.ts +392 -16
- package/lib/task/finalization.ts +50 -14
- package/lib/task/human-override.ts +70 -46
- package/lib/task/index.ts +16 -3
- package/lib/task/invalidation-command.ts +86 -0
- package/lib/task/invalidation.ts +332 -0
- package/lib/task/ledger-intents.ts +35 -1
- package/lib/task/local-artifact-finalization.ts +432 -0
- package/lib/task/orchestration.ts +223 -133
- package/lib/task/pr-delivery-fact.ts +131 -148
- package/lib/task/qualification-audit.ts +599 -0
- package/lib/task/qualification-confirmation.ts +117 -0
- package/lib/task/qualification-intents.ts +150 -0
- package/lib/task/review-artifacts.ts +21 -22
- package/lib/task/review-finalization.ts +133 -4
- package/lib/task/review-fingerprint.ts +23 -2
- package/lib/task/rework-intent.ts +165 -0
- package/lib/task/sections.ts +6 -4
- package/lib/task/skill-scope.ts +24 -0
- package/lib/task/task-execution-lock.ts +23 -14
- package/lib/task/verification-config.ts +12 -0
- package/lib/task/verification-engine.ts +103 -17
- package/lib/task/verification.ts +4 -4
- package/lib/task/workflow-warning-intents.ts +1 -1
- package/lib/task/write.ts +19 -0
- package/lib/update.ts +1 -1
- package/lib/version.ts +15 -1
- package/package.json +12 -1
- package/templates/.agents/rules/README.en.md +3 -1
- package/templates/.agents/rules/README.zh-CN.md +3 -1
- 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/issue-pr-commands.en.md +1 -1
- package/templates/.agents/rules/issue-pr-commands.zh-CN.md +1 -1
- package/templates/.agents/rules/issue-sync.en.md +2 -0
- package/templates/.agents/rules/issue-sync.zh-CN.md +2 -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 +13 -2
- package/templates/.agents/rules/local-artifact-repair.zh-CN.md +13 -2
- package/templates/.agents/rules/pr-sync.en.md +10 -4
- package/templates/.agents/rules/pr-sync.zh-CN.md +17 -4
- 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/task-short-id.en.md +1 -4
- package/templates/.agents/rules/task-short-id.zh-CN.md +1 -3
- package/templates/.agents/skills/analyze-task/SKILL.en.md +28 -5
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +29 -5
- 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/check-task/SKILL.en.md +16 -37
- package/templates/.agents/skills/check-task/SKILL.zh-CN.md +16 -37
- 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 +41 -9
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +43 -11
- package/templates/.agents/skills/code-task/config/verify.en.json +6 -14
- package/templates/.agents/skills/code-task/config/verify.zh-CN.json +6 -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/commit/reference/issue-metadata-sync.en.md +2 -0
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +2 -0
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +3 -3
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +3 -3
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +10 -4
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +10 -4
- package/templates/.agents/skills/complete-manual-validation/reference/report-template.en.md +2 -0
- package/templates/.agents/skills/complete-manual-validation/reference/report-template.zh-CN.md +2 -0
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +4 -3
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +4 -3
- package/templates/.agents/skills/complete-task/SKILL.en.md +26 -21
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +25 -21
- package/templates/.agents/skills/create-pr/SKILL.en.md +7 -6
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +7 -7
- package/templates/.agents/skills/create-pr/config/verify.json +1 -0
- package/templates/.agents/skills/create-pr/reference/change-report.en.md +16 -4
- package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +16 -4
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +5 -3
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +5 -3
- package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +1 -1
- package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +1 -1
- package/templates/.agents/skills/create-pr/scripts/change-report.mjs +3 -0
- 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 +27 -4
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +26 -4
- 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/review-analysis/SKILL.en.md +17 -4
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +17 -4
- 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 +18 -5
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +18 -5
- 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 +17 -4
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +17 -4
- 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 +9 -3
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +9 -3
- package/templates/.agents/skills/run-manual-validation/reference/report-template.en.md +3 -1
- package/templates/.agents/skills/run-manual-validation/reference/report-template.zh-CN.md +3 -1
- package/templates/.agents/skills/test/SKILL.en.md +13 -2
- package/templates/.agents/skills/test/SKILL.zh-CN.md +13 -2
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +14 -0
- package/templates/.agents/skills/watch-pr/SKILL.en.md +2 -2
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +6 -0
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +6 -0
- package/templates/.agents/templates/task.en.md +24 -1
- package/templates/.agents/templates/task.zh-CN.md +24 -1
- package/templates/.github/workflows/pr-label.yml +7 -26
- 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,71 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import type { ArtifactSchemaFamily } from './artifact-schema.ts';
|
|
5
|
+
|
|
6
|
+
type ArtifactRepairIntent = Readonly<{
|
|
7
|
+
version: 1;
|
|
8
|
+
taskId: string;
|
|
9
|
+
family: ArtifactSchemaFamily;
|
|
10
|
+
artifact: string;
|
|
11
|
+
state: 'awaiting-repair' | 'passed' | 'consumed';
|
|
12
|
+
baselineSemanticDigest: string | null;
|
|
13
|
+
artifactSha256: string;
|
|
14
|
+
semanticDigest: string;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
function intentRoot(repoRoot: string): string {
|
|
18
|
+
return path.join(repoRoot, '.agents', 'workspace', '.local-artifact-finalization-intents');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function intentPath(repoRoot: string, taskId: string, family: ArtifactSchemaFamily, artifact: string): string {
|
|
22
|
+
return path.join(intentRoot(repoRoot), `${taskId}-${family}-${artifact}.json`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isArtifactRepairIntent(value: unknown): value is ArtifactRepairIntent {
|
|
26
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
|
|
27
|
+
const intent = value as Record<string, unknown>;
|
|
28
|
+
return intent.version === 1
|
|
29
|
+
&& typeof intent.taskId === 'string' && /^TASK-\d{8}-\d{6}$/.test(intent.taskId)
|
|
30
|
+
&& typeof intent.family === 'string' && ['analysis', 'review-analysis', 'plan', 'review-plan', 'code', 'review-code'].includes(intent.family)
|
|
31
|
+
&& typeof intent.artifact === 'string' && intent.artifact.length > 0
|
|
32
|
+
&& ['awaiting-repair', 'passed', 'consumed'].includes(String(intent.state))
|
|
33
|
+
&& (intent.baselineSemanticDigest === null || (typeof intent.baselineSemanticDigest === 'string' && /^[a-f0-9]{64}$/.test(intent.baselineSemanticDigest)))
|
|
34
|
+
&& typeof intent.artifactSha256 === 'string' && /^[a-f0-9]{64}$/.test(intent.artifactSha256)
|
|
35
|
+
&& typeof intent.semanticDigest === 'string' && /^[a-f0-9]{64}$/.test(intent.semanticDigest)
|
|
36
|
+
&& (intent.state === 'awaiting-repair' ? intent.baselineSemanticDigest === intent.semanticDigest : true);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function readArtifactRepairIntent(
|
|
40
|
+
repoRoot: string,
|
|
41
|
+
taskId: string,
|
|
42
|
+
family: ArtifactSchemaFamily,
|
|
43
|
+
artifact: string
|
|
44
|
+
): ArtifactRepairIntent | null {
|
|
45
|
+
const target = intentPath(repoRoot, taskId, family, artifact);
|
|
46
|
+
if (!fs.existsSync(target)) return null;
|
|
47
|
+
let value: unknown;
|
|
48
|
+
try { value = JSON.parse(fs.readFileSync(target, 'utf8')) as unknown; }
|
|
49
|
+
catch (error) { throw new Error(`ARTIFACT_REPAIR_INTENT_INVALID: ${String(error)}`); }
|
|
50
|
+
if (!isArtifactRepairIntent(value) || value.taskId !== taskId || value.family !== family || value.artifact !== artifact) {
|
|
51
|
+
throw new Error('ARTIFACT_REPAIR_INTENT_INVALID: repair provenance schema is invalid');
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function writeArtifactRepairIntent(repoRoot: string, value: ArtifactRepairIntent): void {
|
|
57
|
+
if (!isArtifactRepairIntent(value)) throw new Error('ARTIFACT_REPAIR_INTENT_INVALID: repair provenance schema is invalid');
|
|
58
|
+
const directory = intentRoot(repoRoot);
|
|
59
|
+
fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
60
|
+
const target = intentPath(repoRoot, value.taskId, value.family, value.artifact);
|
|
61
|
+
const temporary = `${target}.${process.pid}.${Date.now()}.tmp`;
|
|
62
|
+
fs.writeFileSync(temporary, `${JSON.stringify(value)}\n`, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
|
|
63
|
+
try { fs.renameSync(temporary, target); }
|
|
64
|
+
catch (error) {
|
|
65
|
+
try { fs.unlinkSync(temporary); } catch { /* preserve primary error */ }
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { readArtifactRepairIntent, writeArtifactRepairIntent };
|
|
71
|
+
export type { ArtifactRepairIntent };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
type ArtifactFamily =
|
|
2
|
+
| 'analysis'
|
|
3
|
+
| 'review-analysis'
|
|
4
|
+
| 'plan'
|
|
5
|
+
| 'review-plan'
|
|
6
|
+
| 'code'
|
|
7
|
+
| 'review-code'
|
|
8
|
+
| 'manual-validation'
|
|
9
|
+
| 'validation-run'
|
|
10
|
+
| 'pr-review';
|
|
11
|
+
|
|
12
|
+
type ArtifactSchemaFamily = Exclude<ArtifactFamily, 'manual-validation' | 'validation-run' | 'pr-review'>;
|
|
13
|
+
type ArtifactLocale = 'zh-CN' | 'en';
|
|
14
|
+
type ArtifactSection = Readonly<{
|
|
15
|
+
id: string;
|
|
16
|
+
order: number;
|
|
17
|
+
headings: Readonly<{ zh: string; en: string }>;
|
|
18
|
+
marker: string;
|
|
19
|
+
}>;
|
|
20
|
+
type ArtifactSchema = Readonly<{
|
|
21
|
+
family: ArtifactSchemaFamily;
|
|
22
|
+
title: Readonly<{ zh: string; en: string }>;
|
|
23
|
+
sections: readonly ArtifactSection[];
|
|
24
|
+
requiredPatterns: readonly string[];
|
|
25
|
+
}>;
|
|
26
|
+
type ArtifactSkeletonInput = Readonly<{
|
|
27
|
+
taskId: string;
|
|
28
|
+
family: ArtifactSchemaFamily;
|
|
29
|
+
artifact: string;
|
|
30
|
+
locale?: ArtifactLocale;
|
|
31
|
+
}>;
|
|
32
|
+
|
|
33
|
+
type ArtifactFamilySpec = Readonly<{
|
|
34
|
+
family: ArtifactFamily;
|
|
35
|
+
sectionAliases: readonly [string, string];
|
|
36
|
+
heading: string;
|
|
37
|
+
labels: readonly [string, string];
|
|
38
|
+
}>;
|
|
39
|
+
|
|
40
|
+
const ARTIFACT_FAMILY_CATALOG = [
|
|
41
|
+
{ family: 'analysis', sectionAliases: ['分析', 'Analysis'], heading: '分析', labels: ['需求分析报告', 'Requirements Analysis'] },
|
|
42
|
+
{ family: 'review-analysis', sectionAliases: ['审查反馈', 'Review Feedback'], heading: '审查反馈', labels: ['需求分析审查', 'Analysis Review'] },
|
|
43
|
+
{ family: 'plan', sectionAliases: ['设计', 'Design'], heading: '设计', labels: ['技术方案', 'Technical Plan'] },
|
|
44
|
+
{ family: 'review-plan', sectionAliases: ['审查反馈', 'Review Feedback'], heading: '审查反馈', labels: ['技术方案审查', 'Plan Review'] },
|
|
45
|
+
{ family: 'code', sectionAliases: ['实现备注', 'Implementation Notes'], heading: '实现备注', labels: ['实现报告', 'Implementation Report'] },
|
|
46
|
+
{ family: 'review-code', sectionAliases: ['审查反馈', 'Review Feedback'], heading: '审查反馈', labels: ['代码审查', 'Code Review'] },
|
|
47
|
+
{ family: 'manual-validation', sectionAliases: ['实现备注', 'Implementation Notes'], heading: '实现备注', labels: ['人工验证', 'Manual Validation'] },
|
|
48
|
+
{ family: 'validation-run', sectionAliases: ['实现备注', 'Implementation Notes'], heading: '实现备注', labels: ['验证运行证据', 'Validation Run Evidence'] },
|
|
49
|
+
{ family: 'pr-review', sectionAliases: ['审查反馈', 'Review Feedback'], heading: '审查反馈', labels: ['PR 审查报告', 'PR Review Report'] }
|
|
50
|
+
] as const satisfies readonly ArtifactFamilySpec[];
|
|
51
|
+
|
|
52
|
+
const LOCAL_SECTIONS = {
|
|
53
|
+
analysis: [
|
|
54
|
+
['source', '需求来源', 'Requirements Source'],
|
|
55
|
+
['understanding', '需求理解', 'Requirements Understanding'],
|
|
56
|
+
['files', '相关文件', 'Related Files'],
|
|
57
|
+
['impact', '影响评估', 'Impact Assessment'],
|
|
58
|
+
['risks', '技术风险', 'Technical Risks'],
|
|
59
|
+
['effort', '工作量和复杂度评估', 'Effort and Complexity Assessment'],
|
|
60
|
+
['state-check', '状态核对', 'State Check']
|
|
61
|
+
],
|
|
62
|
+
plan: [
|
|
63
|
+
['understanding', '问题理解', 'Problem Understanding'],
|
|
64
|
+
['constraints', '约束条件', 'Constraints'],
|
|
65
|
+
['options', '方案对比', 'Options Comparison'],
|
|
66
|
+
['approach', '技术方法', 'Technical Approach'],
|
|
67
|
+
['steps', '实施步骤', 'Implementation Steps'],
|
|
68
|
+
['files', '文件清单', 'File List'],
|
|
69
|
+
['verification', '验证策略', 'Verification Strategy'],
|
|
70
|
+
['state-check', '状态核对', 'State Check']
|
|
71
|
+
],
|
|
72
|
+
code: [
|
|
73
|
+
['input', '实现输入', 'Implementation Input'],
|
|
74
|
+
['files', '变更文件', 'Changed Files'],
|
|
75
|
+
['key-code', '关键代码说明', 'Key Code Notes'],
|
|
76
|
+
['tests', '测试结果', 'Test Results'],
|
|
77
|
+
['deviations', '与方案的差异', 'Differences from Plan'],
|
|
78
|
+
['review-focus', '供审查关注的内容', 'Review Focus'],
|
|
79
|
+
['state-check', '状态核对', 'State Check'],
|
|
80
|
+
['evidence', '证据原文', 'Raw Evidence']
|
|
81
|
+
],
|
|
82
|
+
'review-analysis': [
|
|
83
|
+
['summary', '审查摘要', 'Review Summary'],
|
|
84
|
+
['coverage', '检视覆盖声明', 'Inspection Coverage'],
|
|
85
|
+
['specialized-coverage', '需求分析专项覆盖', 'Requirements Analysis Coverage'],
|
|
86
|
+
['traceability', '追踪矩阵', 'Traceability Matrix'],
|
|
87
|
+
['issues', '问题清单', 'Findings'],
|
|
88
|
+
['non-blocking', '非阻塞建议', 'Non-blocking Suggestions'],
|
|
89
|
+
['manual-validation', '人工校验项', 'Manual Validation Items'],
|
|
90
|
+
['conclusion', '结论与建议', 'Conclusion and Recommendation'],
|
|
91
|
+
['state-check', '状态核对', 'State Check'],
|
|
92
|
+
['evidence', '证据原文', 'Raw Evidence'],
|
|
93
|
+
['self-critique', '自我质疑', 'Self-critique'],
|
|
94
|
+
['ledger-writeback', '审查分歧账本回写', 'Review Disagreement Ledger Write-back']
|
|
95
|
+
],
|
|
96
|
+
'review-plan': [
|
|
97
|
+
['summary', '审查摘要', 'Review Summary'],
|
|
98
|
+
['coverage', '检视覆盖声明', 'Inspection Coverage'],
|
|
99
|
+
['specialized-coverage', '技术方案架构覆盖', 'Technical Plan Architecture Coverage'],
|
|
100
|
+
['traceability', '追踪矩阵', 'Traceability Matrix'],
|
|
101
|
+
['issues', '问题清单', 'Findings'],
|
|
102
|
+
['non-blocking', '非阻塞建议', 'Non-blocking Suggestions'],
|
|
103
|
+
['manual-validation', '人工校验项', 'Manual Validation Items'],
|
|
104
|
+
['conclusion', '结论与建议', 'Conclusion and Recommendation'],
|
|
105
|
+
['state-check', '状态核对', 'State Check'],
|
|
106
|
+
['evidence', '证据原文', 'Raw Evidence'],
|
|
107
|
+
['self-critique', '自我质疑', 'Self-critique'],
|
|
108
|
+
['ledger-writeback', '审查分歧账本回写', 'Review Disagreement Ledger Write-back']
|
|
109
|
+
],
|
|
110
|
+
'review-code': [
|
|
111
|
+
['summary', '审查摘要', 'Review Summary'],
|
|
112
|
+
['coverage', '检视覆盖声明', 'Inspection Coverage'],
|
|
113
|
+
['specialized-coverage', '代码实现专项覆盖', 'Code Implementation Coverage'],
|
|
114
|
+
['traceability', '追踪矩阵', 'Traceability Matrix'],
|
|
115
|
+
['issues', '问题清单', 'Findings'],
|
|
116
|
+
['non-blocking', '非阻塞建议', 'Non-blocking Suggestions'],
|
|
117
|
+
['manual-validation', '人工校验项', 'Manual Validation Items'],
|
|
118
|
+
['conclusion', '结论与建议', 'Conclusion and Recommendation'],
|
|
119
|
+
['state-check', '状态核对', 'State Check'],
|
|
120
|
+
['evidence', '证据原文', 'Raw Evidence'],
|
|
121
|
+
['self-critique', '自我质疑', 'Self-critique'],
|
|
122
|
+
['ledger-writeback', '审查分歧账本回写', 'Review Disagreement Ledger Write-back']
|
|
123
|
+
]
|
|
124
|
+
} as const;
|
|
125
|
+
|
|
126
|
+
function buildSections(family: ArtifactSchemaFamily): readonly ArtifactSection[] {
|
|
127
|
+
return LOCAL_SECTIONS[family].map(([id, zh, en], index) => ({
|
|
128
|
+
id,
|
|
129
|
+
order: index + 1,
|
|
130
|
+
headings: { zh, en },
|
|
131
|
+
marker: `artifact-section:${family}:${id}`
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const ARTIFACT_SCHEMAS: readonly ArtifactSchema[] = [
|
|
136
|
+
{ family: 'analysis', title: { zh: '需求分析报告', en: 'Requirements Analysis' }, sections: buildSections('analysis'), requiredPatterns: ['^\\$ '] },
|
|
137
|
+
{ family: 'review-analysis', title: { zh: '需求分析审查报告', en: 'Analysis Review Report' }, sections: buildSections('review-analysis'), requiredPatterns: ['^### (?:审查决定|Approval Decision)$', '^\\$ '] },
|
|
138
|
+
{ family: 'plan', title: { zh: '技术方案', en: 'Technical Plan' }, sections: buildSections('plan'), requiredPatterns: ['^\\$ '] },
|
|
139
|
+
{ family: 'review-plan', title: { zh: '技术方案审查报告', en: 'Plan Review Report' }, sections: buildSections('review-plan'), requiredPatterns: ['^### (?:审查决定|Approval Decision)$', '^\\$ '] },
|
|
140
|
+
{ family: 'code', title: { zh: '实现报告', en: 'Implementation Report' }, sections: buildSections('code'), requiredPatterns: ['^\\$ '] },
|
|
141
|
+
{ family: 'review-code', title: { zh: '代码审查报告', en: 'Code Review Report' }, sections: buildSections('review-code'), requiredPatterns: [
|
|
142
|
+
'^### (?:审查决定|Approval Decision)$',
|
|
143
|
+
'^\\$ ',
|
|
144
|
+
'^- \\*\\*(?:总体结论|Overall Verdict)\\*\\*[::]\\s*(?:通过|需要修改|拒绝|Approved|Changes Requested|Rejected)\\s*$',
|
|
145
|
+
'^- \\*\\*(?:审查基线提交|Review Baseline Commit)\\*\\*[::]\\s*\\S',
|
|
146
|
+
'^- \\*\\*(?:审查差异基线|Reviewed Diff Base)\\*\\*[::]\\s*[0-9a-f]{40,64}\\s*$',
|
|
147
|
+
'^- \\*\\*(?:审查差异指纹|Reviewed Diff Fingerprint)\\*\\*[::]\\s*sha256:[0-9a-f]{64}\\s*$',
|
|
148
|
+
'^- \\*\\*(?:审查快照树|Reviewed Snapshot Tree)\\*\\*[::]\\s*[0-9a-f]{40,64}\\s*$'
|
|
149
|
+
] }
|
|
150
|
+
];
|
|
151
|
+
|
|
152
|
+
function getArtifactSchema(family: string): ArtifactSchema | null {
|
|
153
|
+
return ARTIFACT_SCHEMAS.find((schema) => schema.family === family) ?? null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function renderArtifactSkeleton(input: ArtifactSkeletonInput): string {
|
|
157
|
+
const schema = getArtifactSchema(input.family);
|
|
158
|
+
if (!schema) throw new Error(`unknown artifact schema family '${input.family}'`);
|
|
159
|
+
const locale = input.locale ?? 'zh-CN';
|
|
160
|
+
const roundMatch = input.artifact.match(/-r(\d+)\.md$/);
|
|
161
|
+
const round = roundMatch ? Number(roundMatch[1]) : 1;
|
|
162
|
+
const title = schema.title[locale === 'en' ? 'en' : 'zh'];
|
|
163
|
+
const headings = locale === 'en' ? 'en' : 'zh';
|
|
164
|
+
const lines = [
|
|
165
|
+
`<!-- artifact-context:${input.taskId}:${input.family}:${round} -->`,
|
|
166
|
+
`# ${title}`,
|
|
167
|
+
''
|
|
168
|
+
];
|
|
169
|
+
for (const section of schema.sections) {
|
|
170
|
+
lines.push(`## ${section.headings[headings]}`);
|
|
171
|
+
lines.push(`<!-- ${section.marker} -->`);
|
|
172
|
+
lines.push('<!-- artifact-slot:empty -->');
|
|
173
|
+
lines.push('');
|
|
174
|
+
}
|
|
175
|
+
return `${lines.join('\n').trimEnd()}\n`;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export {
|
|
179
|
+
ARTIFACT_FAMILY_CATALOG,
|
|
180
|
+
ARTIFACT_SCHEMAS,
|
|
181
|
+
getArtifactSchema,
|
|
182
|
+
renderArtifactSkeleton
|
|
183
|
+
};
|
|
184
|
+
export type {
|
|
185
|
+
ArtifactFamily,
|
|
186
|
+
ArtifactFamilySpec,
|
|
187
|
+
ArtifactLocale,
|
|
188
|
+
ArtifactSchema,
|
|
189
|
+
ArtifactSchemaFamily,
|
|
190
|
+
ArtifactSection,
|
|
191
|
+
ArtifactSkeletonInput
|
|
192
|
+
};
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import type { InvalidationDocument } from './invalidation.ts';
|
|
5
|
+
import { invalidationBlocks, isArtifactInvalidated, parseInvalidationDocument } from './invalidation.ts';
|
|
6
|
+
import { receiptForOutput } from './artifact-receipts.ts';
|
|
7
|
+
import { parseTypedTaskFrontmatter } from './frontmatter.ts';
|
|
8
|
+
import { parseLedgerDocument, summarizeLedgerStage, validateLedgerRows } from './ledger.ts';
|
|
9
|
+
import { parseReviewSummary, resolveCanonicalVerdict } from './review-artifacts.ts';
|
|
10
|
+
import { parseReworkIntentDocument } from './rework-intent.ts';
|
|
11
|
+
import type { ReworkIntent } from './rework-intent.ts';
|
|
12
|
+
import { sha256File } from './artifact-receipts.ts';
|
|
13
|
+
import { hasOpenLifecycleExecution } from './activity-log.ts';
|
|
14
|
+
import { parseQualificationAudit, parseTaskQualification } from './qualification-audit.ts';
|
|
15
|
+
import type { QualificationAudit, TaskQualification } from './qualification-audit.ts';
|
|
16
|
+
|
|
17
|
+
const ARTIFACT_AUDIT_FAMILIES = new Set(['analysis', 'review-analysis', 'plan', 'review-plan', 'code', 'review-code']);
|
|
18
|
+
|
|
19
|
+
type LifecycleAction =
|
|
20
|
+
| 'analysis' | 'review-analysis' | 'plan' | 'review-plan'
|
|
21
|
+
| 'code' | 'review-code' | 'manual-validation' | 'validation-run';
|
|
22
|
+
type TriggerInitiator = 'human' | 'model' | 'orchestrator';
|
|
23
|
+
type TriggerReason = 'user-request' | 'new-requirement' | 'upstream-fact-doubt' | 'review-finding' | 'retry' | 'validation-rerun';
|
|
24
|
+
type ExplicitTrigger = {
|
|
25
|
+
initiator: TriggerInitiator;
|
|
26
|
+
requestId: string;
|
|
27
|
+
requestedAction: LifecycleAction;
|
|
28
|
+
reasonCode: TriggerReason;
|
|
29
|
+
sourceFinding?: string;
|
|
30
|
+
sourceArtifact?: string;
|
|
31
|
+
sourceSha256?: string;
|
|
32
|
+
implementationInput?: string;
|
|
33
|
+
/** False marks the ordinary recommended workflow event; it is not an authorization fact. */
|
|
34
|
+
explicitRequest?: boolean;
|
|
35
|
+
};
|
|
36
|
+
type LifecycleFacts = {
|
|
37
|
+
taskState: string;
|
|
38
|
+
currentStep: string;
|
|
39
|
+
artifacts: Partial<Record<LifecycleAction, readonly string[]>>;
|
|
40
|
+
staleArtifacts?: Partial<Record<LifecycleAction, readonly string[]>>;
|
|
41
|
+
reviewedInputs?: Partial<Record<'review-analysis' | 'review-plan' | 'review-code', string>>;
|
|
42
|
+
artifactHashes: Readonly<Record<string, string>>;
|
|
43
|
+
reviews: Partial<Record<'review-analysis' | 'review-plan' | 'review-code', 'approved' | 'changes-requested' | 'rejected'>>;
|
|
44
|
+
invalidation: InvalidationDocument;
|
|
45
|
+
reworkIntents?: readonly ReworkIntent[];
|
|
46
|
+
unresolvedLedger: Record<'analysis' | 'plan' | 'code', number>;
|
|
47
|
+
executionBusy: boolean;
|
|
48
|
+
recommendedAction?: LifecycleAction | null;
|
|
49
|
+
qualificationStale?: boolean;
|
|
50
|
+
qualificationStaleArtifacts?: readonly string[];
|
|
51
|
+
};
|
|
52
|
+
type CapabilityResult = {
|
|
53
|
+
allowed: boolean;
|
|
54
|
+
reasonCode: string;
|
|
55
|
+
evidence: readonly string[];
|
|
56
|
+
};
|
|
57
|
+
type LifecycleRecommendation = {
|
|
58
|
+
action: LifecycleAction | null;
|
|
59
|
+
reasonCode: string;
|
|
60
|
+
evidence: readonly string[];
|
|
61
|
+
};
|
|
62
|
+
type LifecycleFactsResult =
|
|
63
|
+
| { ok: true; facts: LifecycleFacts }
|
|
64
|
+
| { ok: false; code: 'TASK_CAPABILITY_FACTS_INVALID'; message: string };
|
|
65
|
+
|
|
66
|
+
const REASONS = new Set<TriggerReason>([
|
|
67
|
+
'user-request', 'new-requirement', 'upstream-fact-doubt', 'review-finding', 'retry', 'validation-rerun'
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
function deny(reasonCode: string, ...evidence: string[]): CapabilityResult {
|
|
71
|
+
return { allowed: false, reasonCode, evidence };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function allow(...evidence: string[]): CapabilityResult {
|
|
75
|
+
return { allowed: true, reasonCode: 'CAPABILITY_ALLOWED', evidence };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function hasArtifact(facts: LifecycleFacts, action: LifecycleAction): boolean {
|
|
79
|
+
return (facts.artifacts[action]?.length ?? 0) > 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function canStart(action: LifecycleAction, facts: LifecycleFacts, trigger: ExplicitTrigger): CapabilityResult {
|
|
83
|
+
if (!trigger || trigger.requestedAction !== action) return deny('TRIGGER_ACTION_MISMATCH', `requested=${trigger?.requestedAction ?? 'missing'}`);
|
|
84
|
+
if (!trigger.requestId || !trigger.requestId.trim()) return deny('TRIGGER_REQUEST_ID_REQUIRED');
|
|
85
|
+
if (!REASONS.has(trigger.reasonCode)) return deny('TRIGGER_REASON_INVALID');
|
|
86
|
+
if (trigger.sourceArtifact && !trigger.sourceSha256) return deny('SOURCE_ARTIFACT_HASH_REQUIRED');
|
|
87
|
+
if (trigger.sourceSha256 && !trigger.sourceArtifact) return deny('SOURCE_ARTIFACT_REQUIRED');
|
|
88
|
+
if (trigger.sourceArtifact && trigger.sourceSha256) {
|
|
89
|
+
const actual = facts.artifactHashes[trigger.sourceArtifact];
|
|
90
|
+
if (!actual) return deny('SOURCE_ARTIFACT_MISSING', trigger.sourceArtifact);
|
|
91
|
+
if (actual !== trigger.sourceSha256) return deny('SOURCE_ARTIFACT_HASH_MISMATCH', trigger.sourceArtifact);
|
|
92
|
+
}
|
|
93
|
+
if (facts.taskState !== 'active') return deny('TASK_NOT_ACTIVE', `state=${facts.taskState}`);
|
|
94
|
+
if (invalidationBlocks(facts.invalidation)) return deny('INVALIDATION_INCOMPLETE');
|
|
95
|
+
if (facts.qualificationStale && facts.recommendedAction !== action) {
|
|
96
|
+
return deny('QUALIFICATION_STALE', ...(facts.qualificationStaleArtifacts ?? ['qualification audit is stale']));
|
|
97
|
+
}
|
|
98
|
+
if (facts.executionBusy) return deny('EXECUTION_BUSY');
|
|
99
|
+
|
|
100
|
+
const implicit = trigger.explicitRequest === false;
|
|
101
|
+
if (action === 'analysis') {
|
|
102
|
+
if (!implicit || hasArtifact(facts, 'analysis') || facts.recommendedAction === 'analysis') return allow('analysis-capability');
|
|
103
|
+
return deny('ANALYSIS_REQUEST_REQUIRES_EXPLICIT_TRIGGER');
|
|
104
|
+
}
|
|
105
|
+
if (action === 'review-analysis') {
|
|
106
|
+
return hasArtifact(facts, 'analysis') ? allow('analysis-artifact') : deny('ANALYSIS_ARTIFACT_REQUIRED');
|
|
107
|
+
}
|
|
108
|
+
if (action === 'plan') {
|
|
109
|
+
if (!hasArtifact(facts, 'review-analysis')) return deny('ANALYSIS_REVIEW_REQUIRED');
|
|
110
|
+
if (!reviewMatchesLatest(facts, 'analysis', 'review-analysis')) return deny('ANALYSIS_REVIEW_NOT_LATEST');
|
|
111
|
+
if (facts.reviews['review-analysis'] !== 'approved') return deny('ANALYSIS_REVIEW_NOT_APPROVED');
|
|
112
|
+
if (facts.unresolvedLedger.analysis > 0) return deny('ANALYSIS_LEDGER_BLOCKED', `unresolved=${facts.unresolvedLedger.analysis}`);
|
|
113
|
+
return allow('analysis-review-approved');
|
|
114
|
+
}
|
|
115
|
+
if (action === 'review-plan') {
|
|
116
|
+
return hasArtifact(facts, 'plan') ? allow('plan-artifact') : deny('PLAN_ARTIFACT_REQUIRED');
|
|
117
|
+
}
|
|
118
|
+
if (action === 'code') {
|
|
119
|
+
if (trigger.implementationInput) {
|
|
120
|
+
if (!hasArtifact(facts, 'review-code')) return deny('CODE_REVIEW_REQUIRED');
|
|
121
|
+
if (!reviewMatchesLatest(facts, 'code', 'review-code')) return deny('CODE_REVIEW_NOT_LATEST');
|
|
122
|
+
if (facts.reviews['review-code'] !== 'approved') return deny('CODE_REVIEW_NOT_APPROVED');
|
|
123
|
+
return allow('implementation-input');
|
|
124
|
+
}
|
|
125
|
+
if (!hasArtifact(facts, 'review-plan')) return deny('PLAN_REVIEW_REQUIRED');
|
|
126
|
+
if (!reviewMatchesLatest(facts, 'plan', 'review-plan')) return deny('PLAN_REVIEW_NOT_LATEST');
|
|
127
|
+
if (facts.reviews['review-plan'] !== 'approved') return deny('PLAN_REVIEW_NOT_APPROVED');
|
|
128
|
+
if (facts.unresolvedLedger.plan > 0) return deny('PLAN_LEDGER_BLOCKED', `unresolved=${facts.unresolvedLedger.plan}`);
|
|
129
|
+
return allow('plan-review-approved');
|
|
130
|
+
}
|
|
131
|
+
if (action === 'review-code') {
|
|
132
|
+
return hasArtifact(facts, 'code') ? allow('code-artifact') : deny('CODE_ARTIFACT_REQUIRED');
|
|
133
|
+
}
|
|
134
|
+
if (action === 'manual-validation' || action === 'validation-run') {
|
|
135
|
+
if (!hasArtifact(facts, 'review-code')) return deny('CODE_REVIEW_REQUIRED');
|
|
136
|
+
if (!reviewMatchesLatest(facts, 'code', 'review-code')) return deny('CODE_REVIEW_NOT_LATEST');
|
|
137
|
+
if (facts.reviews['review-code'] !== 'approved') return deny('CODE_REVIEW_NOT_APPROVED');
|
|
138
|
+
if (facts.unresolvedLedger.code > 0) return deny('CODE_LEDGER_BLOCKED', `unresolved=${facts.unresolvedLedger.code}`);
|
|
139
|
+
return allow('code-review-approved');
|
|
140
|
+
}
|
|
141
|
+
return deny('CAPABILITY_ACTION_UNKNOWN');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function artifactRound(name: string): number {
|
|
145
|
+
const match = /-r(\d+)\.md$/.exec(name);
|
|
146
|
+
return match ? Number(match[1]) : 1;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function latestArtifact(names: readonly string[]): string | null {
|
|
150
|
+
return [...names].sort((left, right) => artifactRound(right) - artifactRound(left) || left.localeCompare(right))[0] ?? null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function reviewedInputName(content: string, expectedFamily: 'analysis' | 'plan' | 'code'): string | null {
|
|
154
|
+
const header = content.split(/\r?\n/).findIndex((line) => /\*\*(?:审查输入|Review Input)\*\*[::]/.test(line));
|
|
155
|
+
if (header < 0) return null;
|
|
156
|
+
const referenceBlock = content.split(/\r?\n/).slice(header, header + 12).join('\n');
|
|
157
|
+
const expected = new RegExp('`' + expectedFamily + '(?:-r[2-9]|-r[1-9]\\d+)?\\.md`');
|
|
158
|
+
return expected.exec(referenceBlock)?.[0].slice(1, -1) ?? null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function reviewMatchesLatest(facts: LifecycleFacts, source: 'analysis' | 'plan' | 'code', review: 'review-analysis' | 'review-plan' | 'review-code'): boolean {
|
|
162
|
+
const latestSource = latestArtifact(facts.artifacts[source] ?? []);
|
|
163
|
+
return Boolean(latestSource && facts.reviewedInputs?.[review] === latestSource);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function qualificationCandidateSnapshotMatches(
|
|
167
|
+
audit: QualificationAudit,
|
|
168
|
+
qualification: TaskQualification
|
|
169
|
+
): boolean {
|
|
170
|
+
const current = new Map(qualification.candidates.map((candidate) => [candidate.candidateId, candidate]));
|
|
171
|
+
return audit.candidateQualifications.length === current.size && audit.candidateQualifications.every((row) => {
|
|
172
|
+
const candidate = current.get(row.candidateId);
|
|
173
|
+
return Boolean(candidate && candidate.status === row.status && candidate.impact === row.impact
|
|
174
|
+
&& candidate.evidence === row.evidence && candidate.constraintIds.join(',') === row.constraintIds.join(','));
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const QUALIFICATION_RECOVERY_ORDER: ReadonlyArray<{ action: LifecycleAction; pattern: RegExp }> = [
|
|
179
|
+
{ action: 'analysis', pattern: /^analysis(?:-r\d+)?\.md$/ },
|
|
180
|
+
{ action: 'review-analysis', pattern: /^review-analysis(?:-r\d+)?\.md$/ },
|
|
181
|
+
{ action: 'plan', pattern: /^plan(?:-r\d+)?\.md$/ },
|
|
182
|
+
{ action: 'review-plan', pattern: /^review-plan(?:-r\d+)?\.md$/ },
|
|
183
|
+
{ action: 'code', pattern: /^code(?:-r\d+)?\.md$/ },
|
|
184
|
+
{ action: 'review-code', pattern: /^review-code(?:-r\d+)?\.md$/ }
|
|
185
|
+
];
|
|
186
|
+
|
|
187
|
+
function qualificationRecoveryAction(facts: LifecycleFacts): LifecycleAction | null {
|
|
188
|
+
const stale = facts.qualificationStaleArtifacts ?? [];
|
|
189
|
+
return QUALIFICATION_RECOVERY_ORDER.find(({ pattern }) => stale.some((name) => pattern.test(name)))?.action ?? null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function recommendNext(facts: LifecycleFacts): LifecycleRecommendation {
|
|
193
|
+
if (invalidationBlocks(facts.invalidation)) return { action: null, reasonCode: 'INVALIDATION_INCOMPLETE', evidence: ['reconcile task invalidation before routing'] };
|
|
194
|
+
if (facts.qualificationStale) {
|
|
195
|
+
const action = qualificationRecoveryAction(facts);
|
|
196
|
+
return {
|
|
197
|
+
action,
|
|
198
|
+
reasonCode: 'QUALIFICATION_RECOVERY_REQUIRED',
|
|
199
|
+
evidence: facts.qualificationStaleArtifacts ?? ['qualification audit is stale']
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const pendingIntent = (facts.reworkIntents ?? []).find((intent) => intent.status === 'pending');
|
|
203
|
+
if (pendingIntent) return { action: pendingIntent.target, reasonCode: 'REWORK_INTENT_PENDING', evidence: [pendingIntent.intentId, pendingIntent.findingId] };
|
|
204
|
+
if (!hasArtifact(facts, 'analysis')) return { action: 'analysis', reasonCode: 'ANALYSIS_ARTIFACT_MISSING', evidence: ['analysis artifact is absent'] };
|
|
205
|
+
if (!hasArtifact(facts, 'review-analysis') || !reviewMatchesLatest(facts, 'analysis', 'review-analysis')) {
|
|
206
|
+
return { action: 'review-analysis', reasonCode: 'ANALYSIS_REVIEW_MISSING', evidence: ['analysis review does not bind the latest analysis artifact'] };
|
|
207
|
+
}
|
|
208
|
+
if (facts.reviews['review-analysis'] !== 'approved' || facts.unresolvedLedger.analysis > 0) {
|
|
209
|
+
return { action: 'analysis', reasonCode: 'ANALYSIS_REWORK_REQUIRED', evidence: ['analysis review or ledger is not clear'] };
|
|
210
|
+
}
|
|
211
|
+
if (!hasArtifact(facts, 'plan')) return { action: 'plan', reasonCode: 'PLAN_ARTIFACT_MISSING', evidence: ['plan artifact is absent'] };
|
|
212
|
+
if (!hasArtifact(facts, 'review-plan') || !reviewMatchesLatest(facts, 'plan', 'review-plan')) {
|
|
213
|
+
return { action: 'review-plan', reasonCode: 'PLAN_REVIEW_MISSING', evidence: ['plan review does not bind the latest plan artifact'] };
|
|
214
|
+
}
|
|
215
|
+
if (facts.reviews['review-plan'] !== 'approved' || facts.unresolvedLedger.plan > 0) {
|
|
216
|
+
return { action: 'plan', reasonCode: 'PLAN_REWORK_REQUIRED', evidence: ['plan review or ledger is not clear'] };
|
|
217
|
+
}
|
|
218
|
+
if (!hasArtifact(facts, 'code')) return { action: 'code', reasonCode: 'CODE_ARTIFACT_MISSING', evidence: ['code artifact is absent'] };
|
|
219
|
+
if (!hasArtifact(facts, 'review-code') || !reviewMatchesLatest(facts, 'code', 'review-code')) {
|
|
220
|
+
return { action: 'review-code', reasonCode: 'CODE_REVIEW_MISSING', evidence: ['code review does not bind the latest code artifact'] };
|
|
221
|
+
}
|
|
222
|
+
if (facts.reviews['review-code'] !== 'approved') {
|
|
223
|
+
return { action: 'code', reasonCode: 'CODE_REWORK_REQUIRED', evidence: ['code review or ledger is not clear'] };
|
|
224
|
+
}
|
|
225
|
+
return { action: null, reasonCode: 'LIFECYCLE_REVIEWED', evidence: ['latest code review is approved'] };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function buildLifecycleFacts(taskDir: string, content: string, taskState = 'active', executionBusy = false): LifecycleFactsResult {
|
|
229
|
+
try {
|
|
230
|
+
const metadata = parseTypedTaskFrontmatter(content);
|
|
231
|
+
const invalidation = parseInvalidationDocument(content);
|
|
232
|
+
if (!invalidation.ok) return { ok: false, code: 'TASK_CAPABILITY_FACTS_INVALID', message: invalidation.message };
|
|
233
|
+
const rework = parseReworkIntentDocument(content);
|
|
234
|
+
if (!rework.ok) return { ok: false, code: 'TASK_CAPABILITY_FACTS_INVALID', message: rework.message };
|
|
235
|
+
const ledger = parseLedgerDocument(content);
|
|
236
|
+
if (ledger.present) {
|
|
237
|
+
const invalid = validateLedgerRows(ledger.rows);
|
|
238
|
+
if (invalid) return { ok: false, code: 'TASK_CAPABILITY_FACTS_INVALID', message: invalid.message };
|
|
239
|
+
}
|
|
240
|
+
const files = fs.readdirSync(taskDir).filter((name) => {
|
|
241
|
+
if (!name.endsWith('.md')) return false;
|
|
242
|
+
const stat = fs.lstatSync(path.join(taskDir, name));
|
|
243
|
+
return stat.isFile() && !stat.isSymbolicLink();
|
|
244
|
+
});
|
|
245
|
+
const artifactFamilies = {
|
|
246
|
+
analysis: /^analysis(?:-r\d+)?\.md$/,
|
|
247
|
+
'review-analysis': /^review-analysis(?:-r\d+)?\.md$/,
|
|
248
|
+
plan: /^plan(?:-r\d+)?\.md$/,
|
|
249
|
+
'review-plan': /^review-plan(?:-r\d+)?\.md$/,
|
|
250
|
+
code: /^code(?:-r\d+)?\.md$/,
|
|
251
|
+
'review-code': /^review-code(?:-r\d+)?\.md$/
|
|
252
|
+
} as const;
|
|
253
|
+
const familyFor = (name: string): keyof typeof artifactFamilies | null =>
|
|
254
|
+
(Object.keys(artifactFamilies) as Array<keyof typeof artifactFamilies>)
|
|
255
|
+
.find((family) => artifactFamilies[family].test(name)) ?? null;
|
|
256
|
+
const activeFiles = files.filter((name) => {
|
|
257
|
+
const family = familyFor(name);
|
|
258
|
+
return !family || !isArtifactInvalidated(invalidation.document, family, name);
|
|
259
|
+
});
|
|
260
|
+
const artifactHashes: Record<string, string> = {};
|
|
261
|
+
for (const name of activeFiles) artifactHashes[name] = sha256File(path.join(taskDir, name));
|
|
262
|
+
const artifacts: Partial<Record<LifecycleAction, readonly string[]>> = Object.fromEntries(
|
|
263
|
+
(Object.keys(artifactFamilies) as Array<keyof typeof artifactFamilies>).map((family) => [
|
|
264
|
+
family, activeFiles.filter((name) => artifactFamilies[family].test(name))
|
|
265
|
+
])
|
|
266
|
+
) as Partial<Record<LifecycleAction, readonly string[]>>;
|
|
267
|
+
const staleArtifacts: Partial<Record<LifecycleAction, readonly string[]>> = Object.fromEntries(
|
|
268
|
+
(Object.keys(artifactFamilies) as Array<keyof typeof artifactFamilies>).map((family) => [
|
|
269
|
+
family, files.filter((name) => artifactFamilies[family].test(name) && isArtifactInvalidated(invalidation.document, family, name))
|
|
270
|
+
])
|
|
271
|
+
) as Partial<Record<LifecycleAction, readonly string[]>>;
|
|
272
|
+
const qualification = parseTaskQualification(content);
|
|
273
|
+
if (!qualification.ok) return { ok: false, code: 'TASK_CAPABILITY_FACTS_INVALID', message: qualification.message };
|
|
274
|
+
const qualificationStaleArtifacts: string[] = [];
|
|
275
|
+
if (qualification.qualification.present) {
|
|
276
|
+
const constraints = new Map(qualification.qualification.constraints.map((row) => [row.constraintId, row.digest]));
|
|
277
|
+
for (const family of Object.keys(artifactFamilies) as Array<keyof typeof artifactFamilies>) {
|
|
278
|
+
if (!ARTIFACT_AUDIT_FAMILIES.has(family)) continue;
|
|
279
|
+
const name = latestArtifact(artifacts[family] ?? []);
|
|
280
|
+
if (!name) continue;
|
|
281
|
+
let auditContent: string;
|
|
282
|
+
try { auditContent = fs.readFileSync(path.join(taskDir, name), 'utf8'); }
|
|
283
|
+
catch { qualificationStaleArtifacts.push(name); continue; }
|
|
284
|
+
const audit = parseQualificationAudit(auditContent);
|
|
285
|
+
if (!audit.ok || !audit.audit.present || !audit.audit.snapshot) { qualificationStaleArtifacts.push(name); continue; }
|
|
286
|
+
const constraintsChanged = audit.audit.constraintDependencies.some((dependency) => constraints.get(dependency.constraintId) !== dependency.constraintDigest);
|
|
287
|
+
const taskInputChanged = audit.audit.snapshot.taskInputDigest !== qualification.qualification.taskInputDigest;
|
|
288
|
+
if (audit.audit.snapshot.nonConstraintInputDigest !== qualification.qualification.nonConstraintInputDigest
|
|
289
|
+
|| constraintsChanged
|
|
290
|
+
|| (taskInputChanged && !constraintsChanged)
|
|
291
|
+
|| (taskInputChanged && !qualificationCandidateSnapshotMatches(audit.audit, qualification.qualification))) qualificationStaleArtifacts.push(name);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const reviews: LifecycleFacts['reviews'] = {};
|
|
295
|
+
const reviewedInputs: NonNullable<LifecycleFacts['reviewedInputs']> = {};
|
|
296
|
+
for (const family of ['review-analysis', 'review-plan', 'review-code'] as const) {
|
|
297
|
+
const latest = latestArtifact(artifacts[family] ?? []);
|
|
298
|
+
if (!latest) continue;
|
|
299
|
+
const reviewContent = fs.readFileSync(path.join(taskDir, latest), 'utf8');
|
|
300
|
+
const expectedFamily = family === 'review-analysis' ? 'analysis' : family === 'review-plan' ? 'plan' : 'code';
|
|
301
|
+
const input = reviewedInputName(reviewContent, expectedFamily);
|
|
302
|
+
const receipt = input ? receiptForOutput(content, latest) : null;
|
|
303
|
+
if (input && receipt?.input === input && artifactHashes[input] === receipt.inputSha256) reviewedInputs[family] = input;
|
|
304
|
+
const parsed = parseReviewSummary(reviewContent);
|
|
305
|
+
if (!parsed.ok) continue;
|
|
306
|
+
const verdict = resolveCanonicalVerdict(parsed.summary);
|
|
307
|
+
if (verdict.ok) reviews[family] = verdict.verdict === 'Approved' ? 'approved' : verdict.verdict === 'Changes Requested' ? 'changes-requested' : 'rejected';
|
|
308
|
+
}
|
|
309
|
+
const unresolvedLedger = { analysis: 0, plan: 0, code: 0 };
|
|
310
|
+
if (ledger.present) {
|
|
311
|
+
for (const stage of ['analysis', 'plan', 'code'] as const) unresolvedLedger[stage] = summarizeLedgerStage(ledger.rows, stage).unresolved.length;
|
|
312
|
+
}
|
|
313
|
+
const facts: LifecycleFacts = {
|
|
314
|
+
taskState, currentStep: String(metadata.current_step ?? ''), artifacts, reviews,
|
|
315
|
+
staleArtifacts, reviewedInputs, artifactHashes,
|
|
316
|
+
invalidation: invalidation.document, reworkIntents: rework.intents,
|
|
317
|
+
unresolvedLedger,
|
|
318
|
+
executionBusy: executionBusy || hasOpenLifecycleExecution(content),
|
|
319
|
+
recommendedAction: null,
|
|
320
|
+
qualificationStale: qualificationStaleArtifacts.length > 0,
|
|
321
|
+
qualificationStaleArtifacts
|
|
322
|
+
};
|
|
323
|
+
facts.recommendedAction = recommendNext(facts).action;
|
|
324
|
+
return { ok: true, facts };
|
|
325
|
+
} catch (error) {
|
|
326
|
+
return { ok: false, code: 'TASK_CAPABILITY_FACTS_INVALID', message: error instanceof Error ? error.message : String(error) };
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export { buildLifecycleFacts, canStart, recommendNext };
|
|
331
|
+
export type { CapabilityResult, ExplicitTrigger, LifecycleAction, LifecycleFacts, LifecycleFactsResult, LifecycleRecommendation, TriggerInitiator, TriggerReason };
|