@fitlab-ai/agent-infra 0.9.14 → 0.10.0
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/internal-cli.sh +45 -0
- package/dist/bin/internal-cli.js +93 -30
- package/dist/lib/agent-clients/adapters/codex-lifecycle/capability-store.js +165 -27
- package/dist/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.js +9 -4
- package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +43 -3
- package/dist/lib/defaults.json +103 -103
- package/dist/lib/fs/durable-write.js +39 -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/cli-route-inventory.js +4 -2
- package/dist/lib/internal/codex-lifecycle.js +6 -6
- package/dist/lib/internal/demo-promotion.js +322 -0
- package/dist/lib/internal/demo-transcript.js +454 -0
- package/dist/lib/internal/host-control.js +28 -0
- package/dist/lib/internal/manual-validation.js +331 -0
- package/dist/lib/internal/platform-pr.js +18 -4
- package/dist/lib/internal/release-workflow.js +63 -84
- package/dist/lib/internal/sandbox-control.js +149 -2
- package/dist/lib/internal/task-artifact.js +16 -263
- package/dist/lib/internal/task-create.js +6 -5
- package/dist/lib/internal/task-event.js +37 -37
- package/dist/lib/internal/task-lifecycle.js +2 -2
- package/dist/lib/internal/task-operation-registry.js +101 -4
- package/dist/lib/internal/task-review.js +11 -56
- package/dist/lib/internal/task-validate.js +30 -10
- package/dist/lib/owned-path.js +33 -0
- package/dist/lib/platform/check-status.js +11 -0
- package/dist/lib/platform/comment-safety.js +4 -1
- 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 +15 -20
- package/dist/lib/platform/issue-comments.js +18 -12
- package/dist/lib/platform/issues.js +2 -180
- package/dist/lib/platform/pr-change-report.js +5 -4
- package/dist/lib/platform/pr-checks.js +12 -65
- package/dist/lib/platform/pr-summary.js +117 -33
- package/dist/lib/platform/pull-requests.js +5 -108
- package/dist/lib/platform/snapshots.js +2 -0
- package/dist/lib/platform/task-identities.js +2 -9
- package/dist/lib/platform/verification-sync.js +132 -143
- package/dist/lib/pr-review/evidence-grading.js +4 -8
- package/dist/lib/release/workflow.js +1 -1
- package/dist/lib/sandbox/commands/create.js +7 -2
- package/dist/lib/sandbox/commands/rm.js +19 -1511
- package/dist/lib/sandbox/control/audit.js +203 -0
- package/dist/lib/sandbox/control/client.js +93 -54
- package/dist/lib/sandbox/control/executor.js +129 -65
- 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 +36 -2
- package/dist/lib/sandbox/control/native-file-lock.js +6 -98
- package/dist/lib/sandbox/control/protocol.js +55 -4
- package/dist/lib/sandbox/control/server.js +518 -127
- package/dist/lib/sandbox/control/state.js +64 -0
- package/dist/lib/sandbox/control/task-workflow.js +74 -0
- package/dist/lib/sandbox/control/workflow-executor.js +89 -0
- package/dist/lib/sandbox/index.js +1 -2
- package/dist/lib/sandbox/recovery.js +28 -4
- package/dist/lib/sandbox/removal.js +822 -0
- package/dist/lib/sandbox/task-cleanup.js +217 -0
- package/dist/lib/sandbox/workspace-identity.js +17 -1
- package/dist/lib/sandbox/workspace-view.js +13 -14
- 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 +79 -0
- package/dist/lib/task/artifact-lifecycle.js +30 -28
- package/dist/lib/task/artifact-name.js +36 -0
- package/dist/lib/task/artifact-operations.js +29 -289
- package/dist/lib/task/artifact-receipts.js +3 -15
- package/dist/lib/task/artifact-recovery.js +430 -0
- package/dist/lib/task/artifact-repair-intent.js +134 -29
- package/dist/lib/task/artifact-schema.js +6 -14
- package/dist/lib/task/capabilities.js +12 -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 +33 -20
- package/dist/lib/task/control-authority.js +403 -6
- package/dist/lib/task/control-recovery.js +140 -0
- package/dist/lib/task/create-service.js +1 -8
- package/dist/lib/task/create.js +62 -9
- package/dist/lib/task/decision-details.js +2 -46
- package/dist/lib/task/delegation-receipts.js +64 -3
- package/dist/lib/task/events.js +275 -22
- package/dist/lib/task/finalization-state.js +9 -0
- package/dist/lib/task/human-override.js +8 -14
- package/dist/lib/task/implementation-inputs.js +3 -3
- package/dist/lib/task/intermediate-cleanup.js +441 -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-recovery.js +549 -0
- package/dist/lib/task/lifecycle.js +31 -4
- package/dist/lib/task/local-artifact-finalization.js +197 -197
- 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 +105 -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 +66 -19
- package/dist/lib/task/pr-delivery-fact.js +12 -56
- package/dist/lib/task/qualification-audit.js +20 -34
- package/dist/lib/task/recovery-warning.js +19 -0
- package/dist/lib/task/review-artifacts.js +2 -18
- package/dist/lib/task/review-command.js +26 -0
- package/dist/lib/task/review-finalization.js +175 -216
- package/dist/lib/task/review-fingerprint.js +2 -2
- package/dist/lib/task/sections.js +34 -56
- package/dist/lib/task/short-id.js +15 -7
- package/dist/lib/task/task-execution-lock.js +1 -1
- package/dist/lib/task/verification-engine.js +119 -337
- package/dist/lib/task/verification.js +1 -1
- package/dist/lib/task/workflow-command.js +16 -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/lib/version.js +1 -11
- package/dist/lifecycle-build-manifest.json +3 -3
- package/lib/agent-clients/adapters/codex-lifecycle/capability-store.ts +223 -33
- package/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.ts +10 -4
- package/lib/agent-clients/adapters/codex-lifecycle/store.ts +55 -3
- package/lib/fs/durable-write.ts +30 -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/cli-route-inventory.ts +4 -2
- package/lib/internal/codex-lifecycle.ts +6 -6
- package/lib/internal/demo-promotion.ts +354 -0
- package/lib/internal/demo-transcript.ts +419 -0
- package/lib/internal/host-control.ts +28 -0
- package/lib/internal/manual-validation.ts +315 -0
- package/lib/internal/platform-pr.ts +15 -4
- package/lib/internal/release-workflow.ts +74 -82
- package/lib/internal/sandbox-control.ts +162 -1
- package/lib/internal/task-artifact.ts +14 -217
- package/lib/internal/task-create.ts +5 -5
- package/lib/internal/task-event.ts +20 -11
- package/lib/internal/task-lifecycle.ts +4 -3
- package/lib/internal/task-operation-registry.ts +111 -4
- package/lib/internal/task-review.ts +9 -54
- package/lib/internal/task-validate.ts +26 -10
- package/lib/owned-path.ts +26 -0
- package/lib/platform/check-status.ts +9 -0
- package/lib/platform/comment-safety.ts +5 -0
- package/lib/platform/completion-backfill.ts +1 -1
- package/lib/platform/github-data.ts +322 -0
- package/lib/platform/github-provider.ts +15 -20
- package/lib/platform/issue-comments.ts +21 -14
- package/lib/platform/issues.ts +5 -246
- package/lib/platform/pr-change-report.ts +7 -5
- package/lib/platform/pr-checks.ts +13 -77
- package/lib/platform/pr-summary.ts +123 -35
- package/lib/platform/pull-requests.ts +6 -173
- package/lib/platform/snapshots.ts +53 -0
- package/lib/platform/task-identities.ts +3 -14
- package/lib/platform/verification-sync.ts +150 -156
- package/lib/pr-review/evidence-grading.ts +4 -9
- package/lib/release/workflow.ts +3 -3
- package/lib/sandbox/commands/create.ts +7 -6
- package/lib/sandbox/commands/rm.ts +21 -1895
- package/lib/sandbox/control/audit.ts +253 -0
- package/lib/sandbox/control/client.ts +109 -66
- package/lib/sandbox/control/executor.ts +134 -74
- package/lib/sandbox/control/finalization-response.ts +29 -0
- package/lib/sandbox/control/identity-sentinel.ts +137 -0
- package/lib/sandbox/control/lifecycle.ts +45 -3
- package/lib/sandbox/control/native-file-lock.ts +6 -107
- package/lib/sandbox/control/protocol.ts +80 -6
- package/lib/sandbox/control/server.ts +567 -132
- package/lib/sandbox/control/state.ts +86 -0
- package/lib/sandbox/control/task-workflow.ts +95 -0
- package/lib/sandbox/control/workflow-executor.ts +92 -0
- package/lib/sandbox/index.ts +1 -2
- package/lib/sandbox/recovery.ts +28 -5
- package/lib/sandbox/removal.ts +1142 -0
- package/lib/sandbox/task-cleanup.ts +209 -0
- package/lib/sandbox/workspace-identity.ts +19 -3
- package/lib/sandbox/workspace-view.ts +17 -15
- package/lib/task/activity-intent.ts +2 -2
- package/lib/task/activity-log.ts +27 -19
- package/lib/task/artifact-command.ts +85 -0
- package/lib/task/artifact-lifecycle.ts +31 -26
- package/lib/task/artifact-name.ts +55 -0
- package/lib/task/artifact-operations.ts +34 -310
- package/lib/task/artifact-receipts.ts +3 -14
- package/lib/task/artifact-recovery.ts +519 -0
- package/lib/task/artifact-repair-intent.ts +162 -33
- package/lib/task/artifact-schema.ts +5 -34
- package/lib/task/capabilities.ts +13 -22
- package/lib/task/codex-orchestration.ts +85 -24
- package/lib/task/commit-identity.ts +31 -0
- package/lib/task/commit-operation.ts +37 -20
- package/lib/task/control-authority.ts +540 -10
- package/lib/task/control-recovery.ts +186 -0
- package/lib/task/create-service.ts +1 -10
- package/lib/task/create.ts +63 -8
- package/lib/task/decision-details.ts +3 -71
- package/lib/task/delegation-receipts.ts +73 -2
- package/lib/task/events.ts +309 -24
- package/lib/task/finalization-state.ts +11 -0
- package/lib/task/human-override.ts +8 -16
- package/lib/task/implementation-inputs.ts +3 -3
- package/lib/task/intermediate-cleanup.ts +493 -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-recovery.ts +691 -0
- package/lib/task/lifecycle.ts +30 -5
- package/lib/task/local-artifact-finalization.ts +244 -234
- 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 +156 -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 +84 -19
- package/lib/task/pr-delivery-fact.ts +15 -62
- package/lib/task/qualification-audit.ts +22 -33
- package/lib/task/recovery-warning.ts +21 -0
- package/lib/task/review-artifacts.ts +1 -20
- package/lib/task/review-command.ts +24 -0
- package/lib/task/review-finalization.ts +183 -292
- package/lib/task/review-fingerprint.ts +2 -2
- package/lib/task/sections.ts +33 -54
- package/lib/task/short-id.ts +27 -5
- package/lib/task/task-execution-lock.ts +1 -1
- package/lib/task/verification-engine.ts +113 -383
- package/lib/task/verification-types.ts +15 -0
- package/lib/task/verification.ts +1 -1
- package/lib/task/workflow-command.ts +17 -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/lib/version.ts +1 -15
- package/package.json +6 -6
- package/templates/.agents/hooks/lifecycle-delegation.js +6 -6
- package/templates/.agents/rules/create-issue.en.md +1 -1
- package/templates/.agents/rules/create-issue.zh-CN.md +1 -1
- package/templates/.agents/rules/issue-sync.en.md +4 -2
- package/templates/.agents/rules/issue-sync.zh-CN.md +4 -3
- package/templates/.agents/rules/local-artifact-repair.en.md +46 -39
- package/templates/.agents/rules/local-artifact-repair.zh-CN.md +43 -36
- 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 +6 -6
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +6 -6
- package/templates/.agents/skills/analyze-task/config/verify.en.json +1 -1
- package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/block-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/block-task/config/verify.json +1 -1
- package/templates/.agents/skills/cancel-task/SKILL.en.md +3 -3
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/cancel-task/config/verify.json +1 -1
- package/templates/.agents/skills/code-task/SKILL.en.md +7 -7
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +7 -7
- package/templates/.agents/skills/code-task/config/verify.en.json +1 -1
- package/templates/.agents/skills/code-task/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +1 -1
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +33 -21
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +33 -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 +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 +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 +3 -3
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/complete-task/config/verify.en.json +2 -2
- package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +2 -2
- package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +1 -1
- package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +1 -1
- package/templates/.agents/skills/create-pr/SKILL.en.md +2 -2
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/create-pr/config/verify.json +1 -1
- package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +2 -2
- package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +2 -2
- package/templates/.agents/skills/create-task/SKILL.en.md +5 -5
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +5 -5
- package/templates/.agents/skills/create-task/config/verify.json +1 -1
- package/templates/.agents/skills/import-issue/SKILL.en.md +8 -8
- package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +8 -8
- package/templates/.agents/skills/import-issue/config/verify.json +2 -2
- package/templates/.agents/skills/plan-task/SKILL.en.md +4 -4
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/plan-task/config/verify.en.json +1 -1
- package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +1 -1
- 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/restore-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/restore-task/config/verify.json +1 -1
- package/templates/.agents/skills/review-analysis/SKILL.en.md +2 -2
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/review-analysis/config/verify.en.json +1 -1
- package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/review-analysis/reference/report-template.en.md +7 -7
- package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +6 -6
- package/templates/.agents/skills/review-code/SKILL.en.md +2 -2
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/review-code/config/verify.en.json +1 -1
- package/templates/.agents/skills/review-code/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/review-code/reference/report-template.en.md +12 -12
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +12 -12
- package/templates/.agents/skills/review-plan/SKILL.en.md +2 -2
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/review-plan/config/verify.en.json +1 -1
- package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/review-plan/reference/report-template.en.md +7 -7
- package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +7 -7
- package/templates/.agents/skills/review-pr/config/verify.en.json +1 -1
- package/templates/.agents/skills/review-pr/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +3 -3
- package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +3 -3
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +20 -3
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +20 -3
- package/templates/.agents/skills/run-manual-validation/config/verify.en.json +1 -1
- package/templates/.agents/skills/run-manual-validation/config/verify.zh-CN.json +1 -1
- 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 +2 -0
- package/templates/.agents/skills/run-manual-validation/reference/report-template.zh-CN.md +2 -0
- 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 +17 -6
- package/templates/.agents/skills/test/SKILL.zh-CN.md +17 -6
- package/templates/.agents/templates/task.en.md +1 -1
- package/templates/.agents/templates/task.zh-CN.md +1 -1
- package/templates/.claude/commands/import-issue.en.md +1 -1
- package/templates/.claude/commands/import-issue.zh-CN.md +1 -1
- package/templates/.claude/commands/restore-task.en.md +1 -1
- package/templates/.claude/commands/restore-task.zh-CN.md +1 -1
- 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
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
1
|
import { syncPlatformComment } from '../platform/issue-comments.js';
|
|
4
2
|
import { createPlatformIssue, syncPlatformIssue } from '../platform/issues.js';
|
|
5
3
|
import { VERSION } from '../version.js';
|
|
@@ -139,11 +137,6 @@ function platformOperations(prefix, operations) {
|
|
|
139
137
|
reasonCode: operation.reasonCode ?? null
|
|
140
138
|
}));
|
|
141
139
|
}
|
|
142
|
-
function issueFromTask(repoRoot, taskId) {
|
|
143
|
-
const content = fs.readFileSync(path.join(repoRoot, '.agents', 'workspace', 'active', taskId, 'task.md'), 'utf8');
|
|
144
|
-
const match = /^issue_number:\s*(\d+)\s*$/m.exec(content);
|
|
145
|
-
return match ? { number: Number(match[1]), url: '' } : null;
|
|
146
|
-
}
|
|
147
140
|
async function createTask(value, options) {
|
|
148
141
|
const dependencies = { ...DEFAULT_DEPENDENCIES, ...options.dependencies };
|
|
149
142
|
let candidate;
|
|
@@ -163,7 +156,7 @@ async function createTask(value, options) {
|
|
|
163
156
|
const operations = [{
|
|
164
157
|
name: 'task:local', status: local.status, reasonCode: null
|
|
165
158
|
}];
|
|
166
|
-
let issue =
|
|
159
|
+
let issue = null;
|
|
167
160
|
const created = await dependencies.createIssue(local.task.id, { cwd: options.repoRoot, agent: candidate.agent });
|
|
168
161
|
operations.push(...platformOperations('platform-create', created.operations));
|
|
169
162
|
if (created.issue)
|
package/dist/lib/task/create.js
CHANGED
|
@@ -6,7 +6,7 @@ import { loadShortIdByTaskId, mutateShortIdRegistry } from './short-id.js';
|
|
|
6
6
|
import { TaskExecutionLockError, withTaskExecutionLock } from './task-execution-lock.js';
|
|
7
7
|
import { readDeliveryDefaults, validateBaseRef, validateRemote } from './delivery-target.js';
|
|
8
8
|
import { buildUnboundFact, encodePrDeliveryFact } from './pr-delivery-fact.js';
|
|
9
|
-
import { CANDIDATE_COLUMNS, CONSTRAINT_COLUMNS } from './qualification-audit.js';
|
|
9
|
+
import { CANDIDATE_COLUMNS, CONSTRAINT_COLUMNS, parseTaskQualification } from './qualification-audit.js';
|
|
10
10
|
const AGENTS = ['claude', 'codex', 'antigravity', 'opencode', 'cursor'];
|
|
11
11
|
const TYPES = ['feature', 'bugfix', 'refactor', 'docs', 'chore'];
|
|
12
12
|
const PRIORITIES = ['Urgent', 'High', 'Medium', 'Low'];
|
|
@@ -150,12 +150,64 @@ function renderTable(columns, rows) {
|
|
|
150
150
|
...rows.map((row) => `| ${row.map(tableCell).join(' | ')} |`)
|
|
151
151
|
].join('\n');
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function escapeRegExp(value) {
|
|
154
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
155
|
+
}
|
|
156
|
+
function candidateIdFor(index) {
|
|
157
|
+
let value = index + 1;
|
|
158
|
+
let id = '';
|
|
159
|
+
while (value > 0) {
|
|
160
|
+
const remainder = (value - 1) % 26;
|
|
161
|
+
id = `${String.fromCharCode(65 + remainder)}${id}`;
|
|
162
|
+
value = Math.floor((value - 1) / 26);
|
|
163
|
+
}
|
|
164
|
+
return id;
|
|
165
|
+
}
|
|
166
|
+
function appendCanonicalRows(content, heading, columns, rows) {
|
|
154
167
|
if (rows.length === 0)
|
|
155
168
|
return content;
|
|
156
169
|
const table = renderTable(columns, rows);
|
|
157
|
-
const separator =
|
|
158
|
-
|
|
170
|
+
const [header, separator, ...rowLines] = table.split('\n');
|
|
171
|
+
const eol = content.includes('\r\n') ? '\r\n' : '\n';
|
|
172
|
+
const lines = content.split(/\r?\n/);
|
|
173
|
+
const headingPattern = new RegExp(`^###\\s+${escapeRegExp(heading)}\\s*$`);
|
|
174
|
+
const sectionStart = lines.findIndex((line) => headingPattern.test(line));
|
|
175
|
+
if (sectionStart < 0)
|
|
176
|
+
throw new Error(`TASK_CREATE_QUALIFICATION_INVALID: section '${heading}' is missing`);
|
|
177
|
+
let sectionEnd = lines.length;
|
|
178
|
+
for (let index = sectionStart + 1; index < lines.length; index += 1) {
|
|
179
|
+
if (/^#{2,3}\s+/.test(lines[index])) {
|
|
180
|
+
sectionEnd = index;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const matches = [];
|
|
185
|
+
for (let index = sectionStart + 1; index + 1 < sectionEnd; index += 1) {
|
|
186
|
+
if (lines[index].trim() === header && lines[index + 1].trim() === separator)
|
|
187
|
+
matches.push(index);
|
|
188
|
+
}
|
|
189
|
+
if (matches.length !== 1) {
|
|
190
|
+
throw new Error(`TASK_CREATE_QUALIFICATION_INVALID: section '${heading}' must contain exactly one canonical qualification table`);
|
|
191
|
+
}
|
|
192
|
+
lines.splice(matches[0] + 2, 0, ...rowLines);
|
|
193
|
+
return lines.join(eol);
|
|
194
|
+
}
|
|
195
|
+
function validateRenderedQualification(content, candidate) {
|
|
196
|
+
const parsed = parseTaskQualification(content);
|
|
197
|
+
if (!parsed.ok) {
|
|
198
|
+
throw new Error(`TASK_CREATE_QUALIFICATION_INVALID: ${parsed.code}: ${parsed.message}`);
|
|
199
|
+
}
|
|
200
|
+
if (!parsed.qualification.present) {
|
|
201
|
+
throw new Error('TASK_CREATE_QUALIFICATION_INVALID: rendered task qualification contract is missing');
|
|
202
|
+
}
|
|
203
|
+
const expectedConstraintIds = candidate.taskInput.constraints.map((_, index) => `C-${index + 1}`);
|
|
204
|
+
const expectedCandidateIds = candidate.taskInput.alternatives.map((_, index) => candidateIdFor(index));
|
|
205
|
+
const actualConstraintIds = parsed.qualification.constraints.map((row) => row.constraintId);
|
|
206
|
+
const actualCandidateIds = parsed.qualification.candidates.map((row) => row.candidateId);
|
|
207
|
+
if (JSON.stringify(actualConstraintIds) !== JSON.stringify(expectedConstraintIds)
|
|
208
|
+
|| JSON.stringify(actualCandidateIds) !== JSON.stringify(expectedCandidateIds)) {
|
|
209
|
+
throw new Error('TASK_CREATE_QUALIFICATION_INVALID: rendered task qualification rows do not match task input');
|
|
210
|
+
}
|
|
159
211
|
}
|
|
160
212
|
function replaceEmptySubsection(content, heading, items) {
|
|
161
213
|
if (items.length === 0)
|
|
@@ -202,11 +254,11 @@ function renderTask(params) {
|
|
|
202
254
|
for (const [heading, key] of sections)
|
|
203
255
|
content = replaceEmptySubsection(content, heading, candidate.taskInput[key]);
|
|
204
256
|
const constraintIds = candidate.taskInput.constraints.map((_, index) => `C-${index + 1}`);
|
|
205
|
-
content = appendCanonicalRows(content, CONSTRAINT_COLUMNS, candidate.taskInput.constraints.map((statement, index) => [
|
|
257
|
+
content = appendCanonicalRows(content, '约束', CONSTRAINT_COLUMNS, candidate.taskInput.constraints.map((statement, index) => [
|
|
206
258
|
constraintIds[index], statement, 'assumption', 'create-task', 'taskInput', 'create-task input', '', ''
|
|
207
259
|
]));
|
|
208
|
-
content = appendCanonicalRows(content, CANDIDATE_COLUMNS, candidate.taskInput.alternatives.map((statement, index) => [
|
|
209
|
-
|
|
260
|
+
content = appendCanonicalRows(content, '候选与否决方案', CANDIDATE_COLUMNS, candidate.taskInput.alternatives.map((statement, index) => [
|
|
261
|
+
candidateIdFor(index), statement, 'pending', constraintIds.join(','), 'requires qualification', 'create-task input'
|
|
210
262
|
]));
|
|
211
263
|
content = content.replace('- **关联 Issue**:#XXX', '- **关联 Issue**:N/A');
|
|
212
264
|
content = content.replace('- **关联 PR**:#XXX', '- **关联 PR**:N/A');
|
|
@@ -328,8 +380,6 @@ function createLocalTask(value, options) {
|
|
|
328
380
|
return withCreateLock(repoRoot, workspaceRoot, () => {
|
|
329
381
|
if (fs.existsSync(receipts))
|
|
330
382
|
assertRealDirectory(receipts, 'TASK_CREATE_RECEIPT_INVALID');
|
|
331
|
-
else
|
|
332
|
-
fs.mkdirSync(receipts, { mode: 0o700 });
|
|
333
383
|
const receiptPath = path.join(receipts, `${keyDigest}.json`);
|
|
334
384
|
if (fs.existsSync(receiptPath)) {
|
|
335
385
|
const stat = fs.lstatSync(receiptPath);
|
|
@@ -345,6 +395,7 @@ function createLocalTask(value, options) {
|
|
|
345
395
|
}
|
|
346
396
|
const recovered = recoverPublishedTask(activeRoot, repoRoot, keyDigest, candidateDigest);
|
|
347
397
|
if (recovered) {
|
|
398
|
+
ensureRealDirectory(receipts, 'TASK_CREATE_RECEIPT_INVALID');
|
|
348
399
|
writeReceipt(receiptPath, {
|
|
349
400
|
version: 1, candidateDigest, taskId: recovered.taskId, shortId: recovered.shortId, status: 'recovered'
|
|
350
401
|
});
|
|
@@ -366,6 +417,8 @@ function createLocalTask(value, options) {
|
|
|
366
417
|
template: fs.readFileSync(templatePath, 'utf8'), candidate, taskId, project: projectConfig.project, delivery: projectConfig.delivery, timestamp,
|
|
367
418
|
agentInfraVersion, keyDigest, candidateDigest
|
|
368
419
|
});
|
|
420
|
+
validateRenderedQualification(rendered, candidate);
|
|
421
|
+
ensureRealDirectory(receipts, 'TASK_CREATE_RECEIPT_INVALID');
|
|
369
422
|
const temporary = path.join(workspaceRoot, `.task-create.tmp.${process.pid}.${randomUUID()}`);
|
|
370
423
|
fs.mkdirSync(temporary, { mode: 0o700 });
|
|
371
424
|
fs.writeFileSync(path.join(temporary, 'task.md'), rendered, { flag: 'wx', mode: 0o600 });
|
|
@@ -1,51 +1,7 @@
|
|
|
1
|
+
import { scanVisibleMarkdown } from './markdown.js';
|
|
1
2
|
const DECISION_ID = /^(AN|PL|CD|HD)-[1-9]\d*(?=$|[\s::])/i;
|
|
2
|
-
const HEADING = /^ {0,3}(#{1,6})[ \t]+(.+?)\s*$/;
|
|
3
|
-
const FENCE_OPEN = /^ {0,3}(`{3,}|~{3,})(.*)$/;
|
|
4
|
-
const FENCE_CLOSE = /^ {0,3}(`{3,}|~{3,})\s*$/;
|
|
5
|
-
const ANCHOR = /^\s*<a\s+id=(['"])([^'"]+)\1\s*><\/a>\s*$/;
|
|
6
3
|
const FIELD = /^\s*[-*]\s+\*\*([^*]+)\*\*\s*[::]\s*/;
|
|
7
4
|
const OPTION_HEADING = /^(?:方案|Option)\s+[A-Z](?:\b|\s*[::])/i;
|
|
8
|
-
function sourceLines(content) {
|
|
9
|
-
const lines = [];
|
|
10
|
-
let start = 0;
|
|
11
|
-
while (start < content.length) {
|
|
12
|
-
const newline = content.indexOf('\n', start);
|
|
13
|
-
const end = newline === -1 ? content.length : newline;
|
|
14
|
-
lines.push({ start, end, text: content.slice(start, end).replace(/\r$/, '') });
|
|
15
|
-
start = newline === -1 ? content.length : newline + 1;
|
|
16
|
-
}
|
|
17
|
-
return lines;
|
|
18
|
-
}
|
|
19
|
-
function scanVisibleMarkdown(content) {
|
|
20
|
-
const lines = sourceLines(content);
|
|
21
|
-
const visible = [];
|
|
22
|
-
const headings = [];
|
|
23
|
-
const anchors = [];
|
|
24
|
-
let fence = null;
|
|
25
|
-
for (const line of lines) {
|
|
26
|
-
if (fence) {
|
|
27
|
-
const close = line.text.match(FENCE_CLOSE);
|
|
28
|
-
if (close && close[1][0] === fence.character && close[1].length >= fence.length)
|
|
29
|
-
fence = null;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const open = line.text.match(FENCE_OPEN);
|
|
33
|
-
const marker = open?.[1];
|
|
34
|
-
const info = open?.[2] ?? '';
|
|
35
|
-
if (marker && !(marker[0] === '`' && info.includes('`'))) {
|
|
36
|
-
fence = { character: marker[0], length: marker.length };
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
visible.push(line);
|
|
40
|
-
const heading = line.text.match(HEADING);
|
|
41
|
-
if (heading)
|
|
42
|
-
headings.push({ ...line, level: heading[1].length, text: heading[2].trim() });
|
|
43
|
-
const anchor = line.text.match(ANCHOR);
|
|
44
|
-
if (anchor)
|
|
45
|
-
anchors.push({ ...line, id: anchor[2] });
|
|
46
|
-
}
|
|
47
|
-
return { lines: visible, headings, anchors };
|
|
48
|
-
}
|
|
49
5
|
function parseDecisionDetailBlocks(content) {
|
|
50
6
|
const scanned = scanVisibleMarkdown(content);
|
|
51
7
|
const details = scanned.headings.filter((heading) => heading.level === 3 && DECISION_ID.test(heading.text));
|
|
@@ -214,5 +170,5 @@ function normalizeDecisionDetailForDisplay(block) {
|
|
|
214
170
|
ordered.push(byKey.get('implementation'));
|
|
215
171
|
return [body.slice(heading.start, heading.end).trim(), ...ordered].join('\n\n').trim();
|
|
216
172
|
}
|
|
217
|
-
export { inspectDecisionDetailDuplicates, normalizeDecisionDetailForDisplay, parseDecisionDetailBlocks, parseDecisionEvidence, resolveDecisionDetail
|
|
173
|
+
export { inspectDecisionDetailDuplicates, normalizeDecisionDetailForDisplay, parseDecisionDetailBlocks, parseDecisionEvidence, resolveDecisionDetail };
|
|
218
174
|
//# sourceMappingURL=decision-details.js.map
|
|
@@ -92,7 +92,8 @@ function hasCurrentCodexEvidence(receipt) {
|
|
|
92
92
|
const provenance = receipt.lifecycleProvenance;
|
|
93
93
|
if (!provenance)
|
|
94
94
|
return false;
|
|
95
|
-
const activated = ['activated', 'stage-completed', 'sealed', 'consumed'].includes(receipt.status)
|
|
95
|
+
const activated = ['activated', 'stage-completed', 'sealed', 'consumed'].includes(receipt.status)
|
|
96
|
+
|| (receipt.status === 'aborted' && receipt.activatedAt !== null);
|
|
96
97
|
if (!activated)
|
|
97
98
|
return receipt.hostEvidence === null;
|
|
98
99
|
const host = receipt.hostEvidence;
|
|
@@ -124,6 +125,12 @@ function hasCurrentCodexEvidence(receipt) {
|
|
|
124
125
|
&& host.consumer === receipt.id
|
|
125
126
|
&& exactText(host.consumedAt);
|
|
126
127
|
}
|
|
128
|
+
if (receipt.status === 'aborted') {
|
|
129
|
+
return Number.isSafeInteger(host.stopRevision)
|
|
130
|
+
&& host.stopRevision > host.startRevision
|
|
131
|
+
&& host.consumer === `lifecycle-recovery:${receipt.taskId}:${receipt.id}`
|
|
132
|
+
&& exactText(host.consumedAt);
|
|
133
|
+
}
|
|
127
134
|
return host.stopRevision === null && host.consumer === null && host.consumedAt === null;
|
|
128
135
|
}
|
|
129
136
|
const RECEIPT_KEYS = [
|
|
@@ -147,7 +154,8 @@ function hasStatusBoundEvidence(receipt) {
|
|
|
147
154
|
const dispatchComplete = dispatchFields.every((field) => field !== null);
|
|
148
155
|
if (!dispatchEmpty && !dispatchComplete)
|
|
149
156
|
return false;
|
|
150
|
-
const beforeActivation = ['prepared', '
|
|
157
|
+
const beforeActivation = ['prepared', 'expired'].includes(receipt.status)
|
|
158
|
+
|| (receipt.status === 'aborted' && receipt.activatedAt === null);
|
|
151
159
|
if (beforeActivation) {
|
|
152
160
|
return receipt.parentId === null
|
|
153
161
|
&& receipt.childId === null
|
|
@@ -181,6 +189,20 @@ function hasStatusBoundEvidence(receipt) {
|
|
|
181
189
|
&& receipt.sealedAt === null
|
|
182
190
|
&& receipt.consumedAt === null;
|
|
183
191
|
}
|
|
192
|
+
if (receipt.status === 'aborted') {
|
|
193
|
+
const host = receipt.hostEvidence;
|
|
194
|
+
return receipt.agent === null
|
|
195
|
+
&& receipt.afterFingerprint === null
|
|
196
|
+
&& receipt.changedPaths.length === 0
|
|
197
|
+
&& receipt.sealedAt === null
|
|
198
|
+
&& receipt.consumedAt === null
|
|
199
|
+
&& host !== null
|
|
200
|
+
&& host !== undefined
|
|
201
|
+
&& Number.isSafeInteger(host.stopRevision)
|
|
202
|
+
&& host.stopRevision > host.startRevision
|
|
203
|
+
&& host.consumer === `lifecycle-recovery:${receipt.taskId}:${receipt.id}`
|
|
204
|
+
&& exactText(host.consumedAt);
|
|
205
|
+
}
|
|
184
206
|
if (!exactText(receipt.agent)
|
|
185
207
|
|| normalizeAgentToken(receipt.agent) !== normalizeAgentToken(receipt.client))
|
|
186
208
|
return false;
|
|
@@ -429,6 +451,45 @@ function abortPreparedDelegation(receipt) {
|
|
|
429
451
|
receipt: Object.freeze({ ...receipt, status: 'aborted' })
|
|
430
452
|
};
|
|
431
453
|
}
|
|
454
|
+
function abortActivatedDelegation(receipt, event) {
|
|
455
|
+
if (receipt.status !== 'activated') {
|
|
456
|
+
return fail('DELEGATION_STATE_INVALID', `delegation ${receipt.id} is ${receipt.status}, expected activated`);
|
|
457
|
+
}
|
|
458
|
+
if (receipt.client !== 'codex'
|
|
459
|
+
|| !receipt.lifecycleProvenance
|
|
460
|
+
|| receipt.hostEvidence?.kind !== 'codex-lifecycle-v2'
|
|
461
|
+
|| typeof receipt.lifecycleProvenance.controllerInstanceDigest !== 'string'
|
|
462
|
+
|| typeof receipt.lifecycleProvenance.controlGeneration !== 'string'
|
|
463
|
+
|| typeof receipt.hostEvidence.controllerInstanceDigest !== 'string'
|
|
464
|
+
|| typeof receipt.hostEvidence.controlGeneration !== 'string') {
|
|
465
|
+
return fail('DELEGATION_RECOVERY_EVIDENCE_INVALID', 'activated delegation lacks the current Codex controller binding');
|
|
466
|
+
}
|
|
467
|
+
if (event.childId !== receipt.childId
|
|
468
|
+
|| !Number.isSafeInteger(event.stopRevision)
|
|
469
|
+
|| event.stopRevision <= receipt.hostEvidence.startRevision
|
|
470
|
+
|| event.consumer !== `lifecycle-recovery:${receipt.taskId}:${receipt.id}`
|
|
471
|
+
|| !exactText(event.consumedAt)) {
|
|
472
|
+
return fail('DELEGATION_RECOVERY_EVIDENCE_INVALID', 'recovery stop evidence does not match the activated delegation');
|
|
473
|
+
}
|
|
474
|
+
return {
|
|
475
|
+
ok: true,
|
|
476
|
+
receipt: Object.freeze({
|
|
477
|
+
...receipt,
|
|
478
|
+
status: 'aborted',
|
|
479
|
+
agent: null,
|
|
480
|
+
afterFingerprint: null,
|
|
481
|
+
changedPaths: Object.freeze([]),
|
|
482
|
+
sealedAt: null,
|
|
483
|
+
consumedAt: null,
|
|
484
|
+
hostEvidence: Object.freeze({
|
|
485
|
+
...receipt.hostEvidence,
|
|
486
|
+
stopRevision: event.stopRevision,
|
|
487
|
+
consumer: event.consumer,
|
|
488
|
+
consumedAt: event.consumedAt
|
|
489
|
+
})
|
|
490
|
+
})
|
|
491
|
+
};
|
|
492
|
+
}
|
|
432
493
|
function completeDelegationStage(receipt, event) {
|
|
433
494
|
if (receipt.status !== 'activated')
|
|
434
495
|
return fail('DELEGATION_STATE_INVALID', `delegation ${receipt.id} is ${receipt.status}, expected activated`);
|
|
@@ -494,5 +555,5 @@ function consumeDelegation(receipt, options = {}) {
|
|
|
494
555
|
consumedAt: (options.now ?? (() => new Date().toISOString()))()
|
|
495
556
|
}) };
|
|
496
557
|
}
|
|
497
|
-
export { activateDelegation, abortPreparedDelegation, completeDelegationStage, consumeDelegation, dispatchDelegation, foldBlankToNull, isDelegationReceipt, managedDelegationRole, prepareDelegation, sealDelegation };
|
|
558
|
+
export { activateDelegation, abortActivatedDelegation, abortPreparedDelegation, completeDelegationStage, consumeDelegation, dispatchDelegation, foldBlankToNull, isDelegationReceipt, managedDelegationRole, prepareDelegation, sealDelegation };
|
|
498
559
|
//# sourceMappingURL=delegation-receipts.js.map
|