@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
package/dist/lib/task/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PUBLIC_CLI_ROUTE_SELECTORS, PUBLIC_CLI_SELECTOR_ALIASES } from '../internal/cli-route-inventory.js';
|
|
1
2
|
const USAGE = `Usage: ai task <command> [options]
|
|
2
3
|
|
|
3
4
|
Commands:
|
|
@@ -30,6 +31,7 @@ Examples:
|
|
|
30
31
|
ai task status --task 11
|
|
31
32
|
|
|
32
33
|
Run 'ai task <command> --help' for details.`;
|
|
34
|
+
const TASK_OPERATIONS = PUBLIC_CLI_ROUTE_SELECTORS.task;
|
|
33
35
|
export async function runTask(args) {
|
|
34
36
|
const [subcommand, ...rest] = args;
|
|
35
37
|
if (!subcommand) {
|
|
@@ -41,14 +43,20 @@ export async function runTask(args) {
|
|
|
41
43
|
process.stdout.write(`${USAGE}\n`);
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
const routeSelector = PUBLIC_CLI_SELECTOR_ALIASES.task[subcommand] ?? subcommand;
|
|
47
|
+
if (!TASK_OPERATIONS.includes(routeSelector)) {
|
|
48
|
+
process.stderr.write(`Unknown task command: ${subcommand}\n\n`);
|
|
49
|
+
process.stdout.write(`${USAGE}\n`);
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
switch (routeSelector) {
|
|
45
54
|
case 'cat': {
|
|
46
55
|
const { cat } = await import('./commands/cat.js');
|
|
47
56
|
cat(rest);
|
|
48
57
|
break;
|
|
49
58
|
}
|
|
50
|
-
case 'decisions':
|
|
51
|
-
case 'd': {
|
|
59
|
+
case 'decisions': {
|
|
52
60
|
const { decisions } = await import('./commands/decisions.js');
|
|
53
61
|
decisions(rest);
|
|
54
62
|
break;
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { inspectOwnedPath } from '../owned-path.js';
|
|
2
|
+
import { taskFinalizationReceiptState } from './finalization-state.js';
|
|
3
|
+
import { withTaskExecutionLock } from './task-execution-lock.js';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { checkpointCommitMatches } from './commit-identity.js';
|
|
7
|
+
import { readCheckpointIntent } from './commit-intent.js';
|
|
8
|
+
import { parseTaskFrontmatter } from './frontmatter.js';
|
|
9
|
+
import { readTaskFinalizationReceipt } from './finalization.js';
|
|
10
|
+
import { readLocalArtifactFinalizationIntent, semanticDigest, sha256Content } from './local-artifact-finalization.js';
|
|
11
|
+
import { parseArtifactName } from './artifact-name.js';
|
|
12
|
+
import { enumerateAllTaskDirs } from './resolve-ref.js';
|
|
13
|
+
const TASK_ID_RE = /^TASK-\d{8}-\d{6}$/;
|
|
14
|
+
const LOCAL_INTENT_RE = /^(TASK-\d{8}-\d{6})-(analysis|plan|code)-(.+\.md)\.json$/;
|
|
15
|
+
const COMMIT_INTENT_RE = /^(TASK-\d{8}-\d{6})\.json$/;
|
|
16
|
+
const AUXILIARY_ROOTS = [
|
|
17
|
+
'.local-artifact-finalization-intents',
|
|
18
|
+
'.task-commit-intents'
|
|
19
|
+
];
|
|
20
|
+
function auxiliaryRoot(repoRoot, name) {
|
|
21
|
+
return path.join(repoRoot, '.agents', 'workspace', name);
|
|
22
|
+
}
|
|
23
|
+
function taskRoot(repoRoot) {
|
|
24
|
+
return path.join(repoRoot, '.agents', 'workspace');
|
|
25
|
+
}
|
|
26
|
+
function fileIdentity(stat) {
|
|
27
|
+
return {
|
|
28
|
+
dev: String(stat.dev),
|
|
29
|
+
ino: String(stat.ino),
|
|
30
|
+
size: stat.size,
|
|
31
|
+
mtimeMs: stat.mtimeMs
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function sameFileIdentity(left, right) {
|
|
35
|
+
return left.dev === right.dev && left.ino === right.ino
|
|
36
|
+
&& left.size === right.size && left.mtimeMs === right.mtimeMs;
|
|
37
|
+
}
|
|
38
|
+
function errorCode(error) {
|
|
39
|
+
const code = error?.code;
|
|
40
|
+
return typeof code === 'string' ? code : null;
|
|
41
|
+
}
|
|
42
|
+
function safeLstat(root, target, expect) {
|
|
43
|
+
const stat = inspectOwnedPath(root, target, expect);
|
|
44
|
+
return stat ? fileIdentity(stat) : null;
|
|
45
|
+
}
|
|
46
|
+
function inspectTaskRecords(repoRoot, taskIds) {
|
|
47
|
+
const records = new Map();
|
|
48
|
+
for (const entry of enumerateAllTaskDirs(repoRoot)) {
|
|
49
|
+
if (taskIds && !taskIds.has(entry.taskId))
|
|
50
|
+
continue;
|
|
51
|
+
const taskMdPath = path.join(entry.taskDir, 'task.md');
|
|
52
|
+
if (safeLstat(taskRoot(repoRoot), taskMdPath, 'file') === null)
|
|
53
|
+
continue;
|
|
54
|
+
const content = fs.readFileSync(taskMdPath, 'utf8');
|
|
55
|
+
records.set(entry.taskId, {
|
|
56
|
+
taskId: entry.taskId,
|
|
57
|
+
taskDir: entry.taskDir,
|
|
58
|
+
state: entry.state,
|
|
59
|
+
frontmatter: parseTaskFrontmatter(content)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return records;
|
|
63
|
+
}
|
|
64
|
+
function item(kind, taskId, filePath, disposition, reason, identity = null) {
|
|
65
|
+
return { kind, taskId, path: path.resolve(filePath), disposition, reason, identity };
|
|
66
|
+
}
|
|
67
|
+
function taskGate(task) {
|
|
68
|
+
if (!task)
|
|
69
|
+
return 'TASK_NOT_FOUND';
|
|
70
|
+
if (task.state !== 'completed' && task.state !== 'archive')
|
|
71
|
+
return 'TASK_STATE_PROTECTED';
|
|
72
|
+
if (task.frontmatter.id !== task.taskId || task.frontmatter.status !== 'completed')
|
|
73
|
+
return 'TASK_STATE_PROTECTED';
|
|
74
|
+
if (!task.frontmatter.branch)
|
|
75
|
+
return 'TASK_IDENTITY_INVALID';
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
function receiptGate(repoRoot, task, options) {
|
|
79
|
+
let receipt;
|
|
80
|
+
try {
|
|
81
|
+
receipt = readTaskFinalizationReceipt(repoRoot, task.taskId);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return 'FINALIZATION_RECEIPT_INVALID';
|
|
85
|
+
}
|
|
86
|
+
if (!receipt)
|
|
87
|
+
return 'FINALIZATION_RECEIPT_MISSING';
|
|
88
|
+
const state = taskFinalizationReceiptState(receipt);
|
|
89
|
+
if (state === 'pending')
|
|
90
|
+
return 'FINALIZATION_RECEIPT_PENDING';
|
|
91
|
+
if (state === 'unresolved')
|
|
92
|
+
return 'LFAI_RETRY_OR_WARNING_OPEN';
|
|
93
|
+
if (receipt.controlBinding) {
|
|
94
|
+
const evidence = options.controlBindingEvidence?.(task.taskId, receipt.controlBinding);
|
|
95
|
+
if (evidence !== 'terminal' && !(options.preflight && evidence === 'pending'))
|
|
96
|
+
return 'CONTROL_BINDING_MISMATCH';
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
function canonicalLocalIntentPath(taskId, family, artifact) {
|
|
101
|
+
return `${taskId}-${family}-${artifact}.json`;
|
|
102
|
+
}
|
|
103
|
+
function localIntentCandidate(repoRoot, task, filePath, taskId, family, artifact, identity, options) {
|
|
104
|
+
const protectedReason = taskGate(task);
|
|
105
|
+
if (protectedReason)
|
|
106
|
+
return item('LFAI-CONSUMED', taskId, filePath, 'protected', protectedReason, identity);
|
|
107
|
+
if (path.basename(filePath) !== canonicalLocalIntentPath(taskId, family, artifact)
|
|
108
|
+
|| !parseArtifactName(artifact)?.family || parseArtifactName(artifact).family !== family) {
|
|
109
|
+
return item('LFAI-CONSUMED', taskId, filePath, 'protected', 'PATH_IDENTITY_MISMATCH', identity);
|
|
110
|
+
}
|
|
111
|
+
let intent;
|
|
112
|
+
try {
|
|
113
|
+
intent = readLocalArtifactFinalizationIntent(repoRoot, taskId, family, artifact);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return item('LFAI-CONSUMED', taskId, filePath, 'protected', 'LFAI_SCHEMA_INVALID', identity);
|
|
117
|
+
}
|
|
118
|
+
if (!intent || intent.state !== 'consumed') {
|
|
119
|
+
return item('LFAI-CONSUMED', taskId, filePath, 'protected', 'LFAI_STATE_PROTECTED', identity);
|
|
120
|
+
}
|
|
121
|
+
const artifactPath = path.join(task.taskDir, artifact);
|
|
122
|
+
if (safeLstat(task.taskDir, artifactPath, 'file') === null) {
|
|
123
|
+
return item('LFAI-CONSUMED', taskId, filePath, 'protected', 'ARTIFACT_IDENTITY_MISMATCH', identity);
|
|
124
|
+
}
|
|
125
|
+
let content;
|
|
126
|
+
try {
|
|
127
|
+
content = fs.readFileSync(artifactPath, 'utf8');
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return item('LFAI-CONSUMED', taskId, filePath, 'protected', 'ARTIFACT_UNREADABLE', identity);
|
|
131
|
+
}
|
|
132
|
+
if (intent.artifactSha256 !== sha256Content(content) || intent.semanticDigest !== semanticDigest(content)) {
|
|
133
|
+
return item('LFAI-CONSUMED', taskId, filePath, 'protected', 'ARTIFACT_DIGEST_MISMATCH', identity);
|
|
134
|
+
}
|
|
135
|
+
const receiptReason = receiptGate(repoRoot, task, options);
|
|
136
|
+
if (receiptReason)
|
|
137
|
+
return item('LFAI-CONSUMED', taskId, filePath, 'protected', receiptReason, identity);
|
|
138
|
+
return item('LFAI-CONSUMED', taskId, filePath, 'planned', 'LFAI_CONSUMED_AND_VERIFIED', identity);
|
|
139
|
+
}
|
|
140
|
+
function commitIntentCandidate(repoRoot, task, filePath, taskId, identity, options) {
|
|
141
|
+
const protectedReason = taskGate(task);
|
|
142
|
+
if (protectedReason)
|
|
143
|
+
return item('COMMIT-SYNCED', taskId, filePath, 'protected', protectedReason, identity);
|
|
144
|
+
let intent;
|
|
145
|
+
try {
|
|
146
|
+
intent = readCheckpointIntent(repoRoot, taskId);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return item('COMMIT-SYNCED', taskId, filePath, 'protected', 'COMMIT_INTENT_INVALID', identity);
|
|
150
|
+
}
|
|
151
|
+
if (!intent || intent.state !== 'synced' || intent.taskId !== taskId
|
|
152
|
+
|| intent.branch !== task.frontmatter.branch || !intent.committedHead
|
|
153
|
+
|| task.frontmatter.checkpoint_commit !== intent.committedHead
|
|
154
|
+
|| !checkpointCommitMatches(repoRoot, intent, intent.committedHead)) {
|
|
155
|
+
return item('COMMIT-SYNCED', taskId, filePath, 'protected', 'COMMIT_EVIDENCE_MISMATCH', identity);
|
|
156
|
+
}
|
|
157
|
+
const receiptReason = receiptGate(repoRoot, task, options);
|
|
158
|
+
if (receiptReason)
|
|
159
|
+
return item('COMMIT-SYNCED', taskId, filePath, 'protected', receiptReason, identity);
|
|
160
|
+
return item('COMMIT-SYNCED', taskId, filePath, 'planned', 'COMMIT_SYNCED_AND_VERIFIED', identity);
|
|
161
|
+
}
|
|
162
|
+
function readAuxiliaryCandidates(repoRoot, tasks, options) {
|
|
163
|
+
const candidates = [];
|
|
164
|
+
const selected = options.taskIds ? new Set(options.taskIds) : null;
|
|
165
|
+
for (const rootName of AUXILIARY_ROOTS) {
|
|
166
|
+
const root = auxiliaryRoot(repoRoot, rootName);
|
|
167
|
+
let rootIdentity;
|
|
168
|
+
try {
|
|
169
|
+
rootIdentity = safeLstat(taskRoot(repoRoot), root, 'directory');
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
rootIdentity = null;
|
|
173
|
+
}
|
|
174
|
+
if (rootIdentity === null) {
|
|
175
|
+
let stat = null;
|
|
176
|
+
try {
|
|
177
|
+
stat = fs.lstatSync(root);
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
stat = null;
|
|
181
|
+
}
|
|
182
|
+
if (stat?.isSymbolicLink())
|
|
183
|
+
candidates.push(item('AUXILIARY-UNKNOWN', null, root, 'protected', 'PATH_SYMLINK'));
|
|
184
|
+
else if (stat)
|
|
185
|
+
candidates.push(item('AUXILIARY-UNKNOWN', null, root, 'protected', 'PATH_IDENTITY_MISMATCH'));
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
let entries;
|
|
189
|
+
try {
|
|
190
|
+
entries = fs.readdirSync(root, { withFileTypes: true });
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
candidates.push(item('AUXILIARY-UNKNOWN', null, root, 'protected', 'AUXILIARY_ROOT_UNREADABLE', rootIdentity));
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
|
|
197
|
+
const filePath = path.join(root, entry.name);
|
|
198
|
+
if (entry.isSymbolicLink()) {
|
|
199
|
+
candidates.push(item('AUXILIARY-UNKNOWN', null, filePath, 'protected', 'PATH_SYMLINK'));
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
if (!entry.isFile()) {
|
|
203
|
+
candidates.push(item('AUXILIARY-UNKNOWN', null, filePath, 'protected', 'PATH_IDENTITY_MISMATCH'));
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const identity = safeLstat(root, filePath, 'file');
|
|
207
|
+
if (!identity) {
|
|
208
|
+
candidates.push(item('AUXILIARY-UNKNOWN', null, filePath, 'protected', 'PATH_IDENTITY_MISMATCH'));
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (rootName === '.local-artifact-finalization-intents') {
|
|
212
|
+
const match = LOCAL_INTENT_RE.exec(entry.name);
|
|
213
|
+
if (!match || (selected && !selected.has(match[1]))) {
|
|
214
|
+
if (!selected || !match)
|
|
215
|
+
candidates.push(item('AUXILIARY-UNKNOWN', null, filePath, 'protected', 'PATH_IDENTITY_MISMATCH', identity));
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
candidates.push(localIntentCandidate(repoRoot, tasks.get(match[1]), filePath, match[1], match[2], match[3], identity, options));
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
const match = COMMIT_INTENT_RE.exec(entry.name);
|
|
222
|
+
if (!match || (selected && !selected.has(match[1]))) {
|
|
223
|
+
if (!selected || !match)
|
|
224
|
+
candidates.push(item('AUXILIARY-UNKNOWN', null, filePath, 'protected', 'PATH_IDENTITY_MISMATCH', identity));
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
candidates.push(commitIntentCandidate(repoRoot, tasks.get(match[1]), filePath, match[1], identity, options));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (entries.length === 0) {
|
|
231
|
+
candidates.push(item('EMPTY-AUX-PARENT', null, root, 'planned', 'EMPTY_CANONICAL_AUXILIARY_ROOT', rootIdentity));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return candidates;
|
|
235
|
+
}
|
|
236
|
+
function buildIntermediateCleanupReport(items, dryRun = false, partial = false) {
|
|
237
|
+
const remaining = items.filter((candidate) => candidate.disposition !== 'deleted' && candidate.disposition !== 'skipped');
|
|
238
|
+
return {
|
|
239
|
+
status: dryRun ? 'dry-run' : partial || remaining.some((candidate) => candidate.disposition === 'failed') ? 'partial' : 'completed',
|
|
240
|
+
items,
|
|
241
|
+
remaining
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function scanInternal(repoRootInput, options) {
|
|
245
|
+
const repoRoot = path.resolve(repoRootInput);
|
|
246
|
+
if (safeLstat(path.dirname(repoRoot), repoRoot, 'directory') === null) {
|
|
247
|
+
throw new Error('INTERMEDIATE_CLEANUP_REPOSITORY_INVALID');
|
|
248
|
+
}
|
|
249
|
+
const selected = options.taskIds ? new Set(options.taskIds.filter((taskId) => TASK_ID_RE.test(taskId))) : undefined;
|
|
250
|
+
const tasks = inspectTaskRecords(repoRoot, selected);
|
|
251
|
+
return readAuxiliaryCandidates(repoRoot, tasks, options);
|
|
252
|
+
}
|
|
253
|
+
function scanIntermediateCleanup(repoRoot, options = {}) {
|
|
254
|
+
const candidates = scanInternal(repoRoot, options);
|
|
255
|
+
return buildIntermediateCleanupReport(candidates, true);
|
|
256
|
+
}
|
|
257
|
+
function removeCandidate(candidate) {
|
|
258
|
+
if (candidate.disposition !== 'planned')
|
|
259
|
+
return candidate;
|
|
260
|
+
const root = candidate.kind === 'EMPTY-AUX-PARENT'
|
|
261
|
+
? path.dirname(path.dirname(candidate.path))
|
|
262
|
+
: path.dirname(candidate.path);
|
|
263
|
+
const expected = candidate.identity;
|
|
264
|
+
if (!expected)
|
|
265
|
+
return { ...candidate, disposition: 'protected', reason: 'PATH_IDENTITY_MISSING' };
|
|
266
|
+
let raw;
|
|
267
|
+
try {
|
|
268
|
+
raw = fs.lstatSync(candidate.path);
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
if (errorCode(error) === 'ENOENT')
|
|
272
|
+
return { ...candidate, disposition: 'skipped', reason: 'ALREADY_GONE' };
|
|
273
|
+
return { ...candidate, disposition: 'failed', reason: 'CLEANUP_RECHECK_FAILED' };
|
|
274
|
+
}
|
|
275
|
+
if (raw.isSymbolicLink())
|
|
276
|
+
return { ...candidate, disposition: 'protected', reason: 'PATH_IDENTITY_CHANGED' };
|
|
277
|
+
const actual = safeLstat(root, candidate.path, candidate.kind === 'EMPTY-AUX-PARENT' ? 'directory' : 'file');
|
|
278
|
+
if (!actual)
|
|
279
|
+
return { ...candidate, disposition: 'protected', reason: 'PATH_IDENTITY_CHANGED' };
|
|
280
|
+
if (!sameFileIdentity(expected, actual))
|
|
281
|
+
return { ...candidate, disposition: 'protected', reason: 'PATH_IDENTITY_CHANGED' };
|
|
282
|
+
try {
|
|
283
|
+
if (candidate.kind === 'EMPTY-AUX-PARENT') {
|
|
284
|
+
if (fs.readdirSync(candidate.path).length !== 0)
|
|
285
|
+
return { ...candidate, disposition: 'protected', reason: 'AUXILIARY_ROOT_NOT_EMPTY' };
|
|
286
|
+
fs.rmdirSync(candidate.path);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
fs.unlinkSync(candidate.path);
|
|
290
|
+
}
|
|
291
|
+
return { ...candidate, disposition: 'deleted', reason: 'DELETED_AFTER_LOCKED_RECHECK' };
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
if (errorCode(error) === 'ENOENT')
|
|
295
|
+
return { ...candidate, disposition: 'skipped', reason: 'ALREADY_GONE' };
|
|
296
|
+
return { ...candidate, disposition: 'failed', reason: 'CLEANUP_DELETE_FAILED' };
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function intermediateCleanupKey(item) {
|
|
300
|
+
return `${item.kind}\0${item.path}`;
|
|
301
|
+
}
|
|
302
|
+
function cleanupIntermediateUnderRemovalCoordinator(repoRoot, options = {}) {
|
|
303
|
+
const scanOptions = {
|
|
304
|
+
...(options.taskIds === undefined ? {} : { taskIds: options.taskIds }),
|
|
305
|
+
...(options.controlBindingEvidence === undefined ? {} : { controlBindingEvidence: options.controlBindingEvidence })
|
|
306
|
+
};
|
|
307
|
+
const initial = scanIntermediateCleanup(repoRoot, scanOptions);
|
|
308
|
+
if (options.dryRun)
|
|
309
|
+
return initial;
|
|
310
|
+
const items = [...initial.items];
|
|
311
|
+
const lockedTaskIds = options.lockedTaskIds ?? new Set();
|
|
312
|
+
const byTask = new Map();
|
|
313
|
+
for (const [index, candidate] of items.entries()) {
|
|
314
|
+
if (!candidate.taskId || candidate.disposition !== 'planned')
|
|
315
|
+
continue;
|
|
316
|
+
const indexes = byTask.get(candidate.taskId) ?? [];
|
|
317
|
+
indexes.push(index);
|
|
318
|
+
byTask.set(candidate.taskId, indexes);
|
|
319
|
+
}
|
|
320
|
+
for (const taskId of [...byTask.keys()].sort()) {
|
|
321
|
+
const execute = () => {
|
|
322
|
+
const refreshed = scanIntermediateCleanup(repoRoot, {
|
|
323
|
+
...scanOptions,
|
|
324
|
+
taskIds: [taskId]
|
|
325
|
+
});
|
|
326
|
+
const refreshedByKey = new Map(refreshed.items.map((candidate) => [intermediateCleanupKey(candidate), candidate]));
|
|
327
|
+
for (const index of byTask.get(taskId) ?? []) {
|
|
328
|
+
const initialCandidate = items[index];
|
|
329
|
+
if (initialCandidate.disposition !== 'planned')
|
|
330
|
+
continue;
|
|
331
|
+
const current = refreshedByKey.get(intermediateCleanupKey(initialCandidate));
|
|
332
|
+
items[index] = current
|
|
333
|
+
? removeCandidate(current)
|
|
334
|
+
: { ...initialCandidate, disposition: 'protected', reason: 'CANDIDATE_NO_LONGER_ELIGIBLE' };
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
try {
|
|
338
|
+
if (lockedTaskIds.has(taskId))
|
|
339
|
+
execute();
|
|
340
|
+
else
|
|
341
|
+
withTaskExecutionLock(repoRoot, taskId, 'sandbox-removal', execute);
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
for (const index of byTask.get(taskId) ?? []) {
|
|
345
|
+
const candidate = items[index];
|
|
346
|
+
if (candidate.disposition === 'planned')
|
|
347
|
+
items[index] = { ...candidate, disposition: 'protected', reason: 'TASK_LOCK_BUSY' };
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
for (const [index, candidate] of items.entries()) {
|
|
352
|
+
if (candidate.taskId || candidate.disposition !== 'planned')
|
|
353
|
+
continue;
|
|
354
|
+
items[index] = removeCandidate(candidate);
|
|
355
|
+
}
|
|
356
|
+
const knownPaths = new Set(items.map((candidate) => intermediateCleanupKey(candidate)));
|
|
357
|
+
for (const candidate of scanIntermediateCleanup(repoRoot, scanOptions).items) {
|
|
358
|
+
if (candidate.kind !== 'EMPTY-AUX-PARENT' || candidate.disposition !== 'planned'
|
|
359
|
+
|| knownPaths.has(intermediateCleanupKey(candidate)))
|
|
360
|
+
continue;
|
|
361
|
+
items.push(removeCandidate(candidate));
|
|
362
|
+
}
|
|
363
|
+
return buildIntermediateCleanupReport(items);
|
|
364
|
+
}
|
|
365
|
+
function protectIntermediateCleanupReport(report, reason) {
|
|
366
|
+
const items = report.items.map((item) => item.disposition === 'planned'
|
|
367
|
+
? { ...item, disposition: 'protected', reason }
|
|
368
|
+
: item);
|
|
369
|
+
return buildIntermediateCleanupReport(items, false, true);
|
|
370
|
+
}
|
|
371
|
+
function mergeIntermediateCleanupReports(reports) {
|
|
372
|
+
const items = reports.flatMap((report) => report.items);
|
|
373
|
+
return buildIntermediateCleanupReport(items, false, reports.some((report) => report.status === 'partial'));
|
|
374
|
+
}
|
|
375
|
+
function formatIntermediateCleanupReport(report) {
|
|
376
|
+
return [
|
|
377
|
+
`remaining ${report.remaining.length} item(s)`,
|
|
378
|
+
...report.items.map((candidate) => (`${candidate.disposition} ${candidate.kind} ${candidate.path}`
|
|
379
|
+
+ ` (${candidate.taskId ?? 'unbound'}; ${candidate.reason})`))
|
|
380
|
+
];
|
|
381
|
+
}
|
|
382
|
+
export { formatIntermediateCleanupReport, cleanupIntermediateUnderRemovalCoordinator, protectIntermediateCleanupReport, mergeIntermediateCleanupReports, scanIntermediateCleanup };
|
|
383
|
+
//# sourceMappingURL=intermediate-cleanup.js.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import { findSectionRange, parseTable } from './sections.js';
|
|
3
|
+
import { scanVisibleMarkdown } from './markdown.js';
|
|
2
4
|
const INVALIDATION_HEADINGS = ['产物失效记录', 'Artifact Invalidation'];
|
|
3
5
|
const OPERATION_COLUMNS = [
|
|
4
6
|
'operation_id', 'source_family', 'source_artifact', 'source_round', 'source_sha256',
|
|
@@ -29,61 +31,14 @@ function createInvalidationOperation(source, targets = []) {
|
|
|
29
31
|
createdAt: source.createdAt, updatedAt: source.updatedAt, completedAt: '', error: ''
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
|
-
function
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const cells = [];
|
|
39
|
-
let start = 0;
|
|
40
|
-
let escaped = false;
|
|
41
|
-
for (let index = 0; index < inner.length; index += 1) {
|
|
42
|
-
const char = inner[index];
|
|
43
|
-
if (char === '|' && !escaped) {
|
|
44
|
-
cells.push(inner.slice(start, index));
|
|
45
|
-
start = index + 1;
|
|
46
|
-
}
|
|
47
|
-
escaped = char === '\\' && !escaped;
|
|
48
|
-
if (char !== '\\')
|
|
49
|
-
escaped = false;
|
|
50
|
-
}
|
|
51
|
-
cells.push(inner.slice(start));
|
|
52
|
-
return cells.map((cell) => cell.replace(/\\([\\|])/g, '$1').trim());
|
|
53
|
-
}
|
|
54
|
-
function isSeparator(cells, count) {
|
|
55
|
-
return cells.length === count && cells.every((cell) => /^:?-{3,}:?$/.test(cell));
|
|
56
|
-
}
|
|
57
|
-
function sectionBody(content) {
|
|
58
|
-
const heading = INVALIDATION_HEADINGS.map((value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
|
|
59
|
-
const match = new RegExp(`^##\\s+(${heading})\\s*$`, 'm').exec(content);
|
|
60
|
-
if (!match)
|
|
61
|
-
return null;
|
|
62
|
-
const start = (match.index ?? 0) + match[0].length;
|
|
63
|
-
const rest = content.slice(start);
|
|
64
|
-
const end = rest.search(/^##\s+/m);
|
|
65
|
-
return rest.slice(0, end < 0 ? rest.length : end);
|
|
66
|
-
}
|
|
67
|
-
function parseTable(body, heading, columns) {
|
|
68
|
-
const marker = new RegExp(`^###\\s+${heading}\\s*$`, 'm').exec(body);
|
|
69
|
-
if (!marker)
|
|
70
|
-
return null;
|
|
71
|
-
const start = (marker.index ?? 0) + marker[0].length;
|
|
72
|
-
const rest = body.slice(start);
|
|
73
|
-
const end = rest.search(/^###\s+/m);
|
|
74
|
-
const lines = rest.slice(0, end < 0 ? rest.length : end).split(/\r?\n/).filter((line) => line.trim());
|
|
75
|
-
const header = lines.length > 0 ? lineCells(lines[0]) : null;
|
|
76
|
-
const separator = lines.length > 1 ? lineCells(lines[1]) : null;
|
|
77
|
-
if (!header || !separator || header.length !== columns.length || !header.every((value, index) => value === columns[index]) || !isSeparator(separator, columns.length))
|
|
78
|
-
return false;
|
|
79
|
-
const rows = [];
|
|
80
|
-
for (const line of lines.slice(2)) {
|
|
81
|
-
const cells = lineCells(line);
|
|
82
|
-
if (!cells || cells.length !== columns.length)
|
|
83
|
-
return false;
|
|
84
|
-
rows.push(Object.fromEntries(columns.map((column, index) => [column, cells[index]])));
|
|
34
|
+
function parseInvalidationTable(body, heading, columns) {
|
|
35
|
+
const section = findSectionRange(body, [heading], 3);
|
|
36
|
+
const lines = scanVisibleMarkdown(body).lines.filter((line) => line.text.trim());
|
|
37
|
+
const table = parseTable(lines.map((line) => line.text).join('\n'), { sectionAliases: [heading], columns });
|
|
38
|
+
if (!section || !table || lines.filter((line) => line.start >= section.bodyStart && line.start < section.end).length !== table.rows.length + 2) {
|
|
39
|
+
throw new Error(`invalidation ${heading} section must contain only its canonical table`);
|
|
85
40
|
}
|
|
86
|
-
return rows;
|
|
41
|
+
return table.rows;
|
|
87
42
|
}
|
|
88
43
|
function required(value, field) {
|
|
89
44
|
if (!value)
|
|
@@ -102,16 +57,14 @@ function numberValue(value, field, allowZero = true) {
|
|
|
102
57
|
return parsed;
|
|
103
58
|
}
|
|
104
59
|
function parseInvalidationDocument(content) {
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
60
|
+
const section = findSectionRange(content, INVALIDATION_HEADINGS);
|
|
61
|
+
if (section === null)
|
|
107
62
|
return { ok: true, present: false, document: { operations: [], targets: [] } };
|
|
108
63
|
try {
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
const operations = operationRows.map((row) => ({
|
|
64
|
+
const body = content.slice(section.bodyStart, section.end);
|
|
65
|
+
const operationRows = parseInvalidationTable(body, 'Operations', OPERATION_COLUMNS);
|
|
66
|
+
const targetRows = parseInvalidationTable(body, 'Targets', TARGET_COLUMNS);
|
|
67
|
+
const operations = operationRows.map(({ values: row }) => ({
|
|
115
68
|
operationId: required(row.operation_id, 'operation_id'), sourceFamily: required(row.source_family, 'source_family'),
|
|
116
69
|
sourceArtifact: required(row.source_artifact, 'source_artifact'), sourceRound: numberValue(row.source_round, 'source_round', false),
|
|
117
70
|
sourceSha256: required(row.source_sha256, 'source_sha256'), status: status(row.status, 'operation status'),
|
|
@@ -119,7 +72,7 @@ function parseInvalidationDocument(content) {
|
|
|
119
72
|
createdAt: required(row.created_at, 'created_at'), updatedAt: required(row.updated_at, 'updated_at'),
|
|
120
73
|
completedAt: row.completed_at ?? '', error: row.error ?? ''
|
|
121
74
|
}));
|
|
122
|
-
const targets = targetRows.map((row) => ({
|
|
75
|
+
const targets = targetRows.map(({ values: row }) => ({
|
|
123
76
|
targetId: required(row.target_id, 'target_id'), operationId: required(row.operation_id, 'operation_id'),
|
|
124
77
|
targetKind: row.target_kind, targetFamily: required(row.target_family, 'target_family'),
|
|
125
78
|
targetArtifact: required(row.target_artifact, 'target_artifact'), targetRound: numberValue(row.target_round, 'target_round', false),
|
|
@@ -248,11 +201,11 @@ function isArtifactInvalidated(document, family, artifact) {
|
|
|
248
201
|
&& target.targetArtifact === artifact);
|
|
249
202
|
}
|
|
250
203
|
function invalidationMutation(content, document) {
|
|
251
|
-
const existing =
|
|
204
|
+
const existing = findSectionRange(content, INVALIDATION_HEADINGS);
|
|
252
205
|
return {
|
|
253
206
|
kind: 'section',
|
|
254
207
|
aliases: INVALIDATION_HEADINGS,
|
|
255
|
-
heading: existing
|
|
208
|
+
heading: existing?.heading ?? INVALIDATION_HEADINGS[0],
|
|
256
209
|
body: renderInvalidation(document)
|
|
257
210
|
};
|
|
258
211
|
}
|
|
@@ -2,6 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
4
|
import { declareImplementationInput, IMPLEMENTATION_INPUT_ALIASES, parseImplementationInputs, renderImplementationInputs } from './implementation-inputs.js';
|
|
5
|
+
import { parseArtifactName } from './artifact-name.js';
|
|
5
6
|
import { LEDGER_COLUMNS, LEDGER_HEADINGS, LEDGER_SECTION_MISSING_CODE, LEDGER_SECTION_MISSING_MESSAGE, nextHdId, parseLedgerDocument, validateLedgerRows } from './ledger.js';
|
|
6
7
|
import { resolveTaskRef } from './resolve-ref.js';
|
|
7
8
|
import { writeTask } from './write.js';
|
|
@@ -10,16 +11,6 @@ import { parseReworkIntentDocument, reworkIntentMutation, upsertReworkIntent } f
|
|
|
10
11
|
const PREFIX = { analysis: 'AN', plan: 'PL', code: 'CD' };
|
|
11
12
|
const RESPONSE = new Set(['accepted', 'adjusted', 'refuted', 'cannot-judge']);
|
|
12
13
|
const DISPOSITION = new Set(['confirmed', 'closed', 'open', 'needs-human-decision']);
|
|
13
|
-
const REVIEW_ARTIFACT = {
|
|
14
|
-
analysis: /^review-analysis(?:-r(?:[2-9]|[1-9]\d+))?\.md$/,
|
|
15
|
-
plan: /^review-plan(?:-r(?:[2-9]|[1-9]\d+))?\.md$/,
|
|
16
|
-
code: /^review-code(?:-r(?:[2-9]|[1-9]\d+))?\.md$/
|
|
17
|
-
};
|
|
18
|
-
const ARTIFACT = {
|
|
19
|
-
analysis: /^analysis(?:-r(?:[2-9]|[1-9]\d+))?\.md$/,
|
|
20
|
-
plan: /^plan(?:-r(?:[2-9]|[1-9]\d+))?\.md$/,
|
|
21
|
-
code: /^code(?:-r(?:[2-9]|[1-9]\d+))?\.md$/
|
|
22
|
-
};
|
|
23
14
|
function failed(intent, code, message, taskId = null, entityId = null) {
|
|
24
15
|
return { status: 'failed', changed: false, intent: intent.kind, taskId, entityId, before: null, after: null, operations: [], error: { code, message } };
|
|
25
16
|
}
|
|
@@ -52,10 +43,6 @@ function nextFindingId(rows, stage) {
|
|
|
52
43
|
}
|
|
53
44
|
return `${prefix}-${max + 1}`;
|
|
54
45
|
}
|
|
55
|
-
function reviewArtifactRound(reviewArtifact) {
|
|
56
|
-
const match = /-r([1-9]\d*)\.md$/.exec(reviewArtifact);
|
|
57
|
-
return match ? Number(match[1]) : 1;
|
|
58
|
-
}
|
|
59
46
|
function rowMutation(row) {
|
|
60
47
|
return {
|
|
61
48
|
kind: 'table-row', action: 'upsert', sectionAliases: LEDGER_HEADINGS,
|
|
@@ -63,9 +50,6 @@ function rowMutation(row) {
|
|
|
63
50
|
values: { stage: row.stage, round: row.round, severity: row.severity, status: row.status, evidence: row.evidence }
|
|
64
51
|
};
|
|
65
52
|
}
|
|
66
|
-
function ledgerSectionMutation(content) {
|
|
67
|
-
return [];
|
|
68
|
-
}
|
|
69
53
|
function implementationInputMutation(content, rows) {
|
|
70
54
|
const english = /^##\s+Activity Log\s*$/m.test(content);
|
|
71
55
|
return {
|
|
@@ -112,7 +96,7 @@ function applyLedgerIntent(intent, options = {}) {
|
|
|
112
96
|
if (!finding || finding.severity === 'decision')
|
|
113
97
|
return failed(intent, 'LEDGER_NOT_FOUND', `finding '${intent.findingId}' was not found`, resolved.taskId, intent.findingId);
|
|
114
98
|
const sourceFromEvidence = finding.evidence.split('#')[0];
|
|
115
|
-
if (sourceFromEvidence !== intent.sourceArtifact ||
|
|
99
|
+
if (sourceFromEvidence !== intent.sourceArtifact || parseArtifactName(intent.sourceArtifact)?.family !== `review-${finding.stage}`) {
|
|
116
100
|
return failed(intent, 'LEDGER_IDENTITY_CONFLICT', 'rework intent source artifact does not match finding evidence', resolved.taskId, intent.intentId);
|
|
117
101
|
}
|
|
118
102
|
try {
|
|
@@ -142,7 +126,8 @@ function applyLedgerIntent(intent, options = {}) {
|
|
|
142
126
|
let before = null;
|
|
143
127
|
let after;
|
|
144
128
|
if (intent.kind === 'finding-upsert') {
|
|
145
|
-
|
|
129
|
+
const identity = parseArtifactName(intent.reviewArtifact);
|
|
130
|
+
if (identity?.family !== `review-${intent.stage}` || !Number.isInteger(intent.ordinal) || intent.ordinal < 1 || !['blocker', 'major', 'minor'].includes(intent.severity)) {
|
|
146
131
|
return failed(intent, 'LEDGER_PAYLOAD_INVALID', 'finding identity, stage, ordinal, or severity is invalid', resolved.taskId);
|
|
147
132
|
}
|
|
148
133
|
const evidence = normalizedEvidence(intent.evidence);
|
|
@@ -162,13 +147,13 @@ function applyLedgerIntent(intent, options = {}) {
|
|
|
162
147
|
else {
|
|
163
148
|
const id = nextFindingId(rows, intent.stage);
|
|
164
149
|
after = {
|
|
165
|
-
id, stage: intent.stage, round: String(
|
|
150
|
+
id, stage: intent.stage, round: String(identity.round),
|
|
166
151
|
severity: intent.severity, status: 'open', evidence, sourceLine: -1
|
|
167
152
|
};
|
|
168
153
|
}
|
|
169
154
|
}
|
|
170
155
|
else if (intent.kind === 'decision-upsert') {
|
|
171
|
-
if (!/^HD-[1-9]\d*$/.test(intent.id) || !
|
|
156
|
+
if (!/^HD-[1-9]\d*$/.test(intent.id) || !['analysis', 'plan', 'code'].includes(intent.stage) || parseArtifactName(intent.artifact)?.family !== intent.stage) {
|
|
172
157
|
return failed(intent, 'LEDGER_PAYLOAD_INVALID', 'decision id, stage, or artifact is invalid', resolved.taskId, intent.id);
|
|
173
158
|
}
|
|
174
159
|
const evidence = `${intent.artifact}#${intent.id}`;
|
|
@@ -249,7 +234,7 @@ function applyLedgerIntent(intent, options = {}) {
|
|
|
249
234
|
}
|
|
250
235
|
const result = writeTask({
|
|
251
236
|
taskRef: intent.taskRef, expectedState: stateOverride ? resolved.state : 'active',
|
|
252
|
-
mutations: [
|
|
237
|
+
mutations: [rowMutation(after), ...(implementationMutation ? [implementationMutation] : [])],
|
|
253
238
|
dryRun: 'dryRun' in intent ? intent.dryRun : false
|
|
254
239
|
}, { ...options, taskLocation: { repoRoot: resolved.repoRoot, taskId: resolved.taskId, taskMdPath: resolved.taskMdPath, state: resolved.state } });
|
|
255
240
|
return mapWrite(intent, after.id, before, after, result);
|
package/dist/lib/task/ledger.js
CHANGED
|
@@ -17,9 +17,7 @@ const LEDGER_SECTION_MISSING_MESSAGE = 'review disagreement ledger section is mi
|
|
|
17
17
|
function isReviewStage(stage) {
|
|
18
18
|
return stage === 'analysis' || stage === 'plan' || stage === 'code';
|
|
19
19
|
}
|
|
20
|
-
// Parse
|
|
21
|
-
// header row (`| id | ... |`) and the `|---|` separator; ignores non-`|` lines.
|
|
22
|
-
// Rows with fewer than 6 columns are skipped (mirrors the JS gate parser).
|
|
20
|
+
// Parse ledger rows using the shared strict table structure contract.
|
|
23
21
|
function parseLedgerDocument(content) {
|
|
24
22
|
const table = parseTable(content, { sectionAliases: LEDGER_HEADINGS, columns: LEDGER_COLUMNS });
|
|
25
23
|
if (!table)
|