@tea-agent/loop-agent 0.9.0 → 0.10.0-alpha.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/AGENTS.md +8 -0
- package/CHANGELOG.md +92 -11
- package/README.md +69 -5
- package/dist/application/dag/args.js +4 -14
- package/dist/application/dag/generate-task-dag.js +32 -2
- package/dist/application/dag/run-dag.js +1 -27
- package/dist/application/dag/validate-dag.js +2 -2
- package/dist/application/loop/run-action.js +0 -4
- package/dist/cli/command-definitions.js +7 -11
- package/dist/cli/program.js +9 -21
- package/dist/commands/cursor-prompt.js +42 -82
- package/dist/commands/dag-approve.js +36 -0
- package/dist/commands/dag-reconcile-run.js +118 -0
- package/dist/commands/delegate.js +75 -77
- package/dist/commands/doctor.js +0 -18
- package/dist/commands/init.js +60 -40
- package/dist/commands/instructions.js +7 -10
- package/dist/commands/loop.js +4 -20
- package/dist/executors/config-core.js +0 -51
- package/dist/executors/dag-pi-executor.js +1 -1
- package/dist/executors/dag.js +0 -1
- package/dist/executors/index.js +0 -2
- package/dist/executors/model-routing.js +9 -9
- package/dist/executors/shell-executor.js +1 -1
- package/dist/governance/checks.js +6 -3
- package/dist/governance/manifest-types.js +33 -2
- package/dist/infrastructure/harness/loop-action-store.js +0 -3
- package/dist/records/harvest.js +2 -23
- package/dist/records/one-shot-runs.js +1 -1
- package/dist/shared/artifacts-core.js +24 -5
- package/dist/shared/output-truncation.js +37 -0
- package/dist/shared/package-metadata.js +353 -0
- package/dist/{executors/cursor-executor.js → sidecars/cursor-prompt/executor.js} +2 -42
- package/dist/sidecars/cursor-prompt/index.js +3 -0
- package/dist/sidecars/cursor-prompt/stream.js +121 -0
- package/dist/task/config-types.js +29 -12
- package/dist/task/delegate.js +9 -21
- package/dist/task/runtime.js +1 -2
- package/dist/worker/cli.js +243 -0
- package/dist/worker/closeout/apply.js +73 -0
- package/dist/worker/closeout/preview.js +30 -0
- package/dist/worker/delivery/final-verification.js +194 -0
- package/dist/worker/delivery/git-transaction.js +354 -0
- package/dist/worker/delivery/package.js +502 -0
- package/dist/worker/feature/decision-loader.js +68 -0
- package/dist/worker/feature/discover.js +14 -0
- package/dist/worker/feature/next-action.js +74 -0
- package/dist/worker/feature/reducer.js +133 -0
- package/dist/worker/feature/review.js +502 -0
- package/dist/worker/feature/run.js +365 -0
- package/dist/worker/feature/types.js +1 -0
- package/dist/worker/follow-up/approve.js +270 -0
- package/dist/worker/follow-up/factory.js +234 -0
- package/dist/worker/follow-up/paths.js +25 -0
- package/dist/worker/follow-up/policy.js +26 -0
- package/dist/worker/follow-up/schema.js +93 -0
- package/dist/worker/follow-up/store.js +96 -0
- package/dist/worker/loop-agent/loop-agent-client.js +329 -126
- package/dist/worker/metrics/projector.js +139 -0
- package/dist/worker/observability/read-model.js +282 -15
- package/dist/worker/observe/paths.js +17 -5
- package/dist/worker/observe/static/app.js +443 -61
- package/dist/worker/observe/static/index.html +3 -1
- package/dist/worker/observe/static/styles.css +85 -18
- package/dist/worker/pool/run-store.js +14 -2
- package/dist/worker/pool/validation.js +59 -0
- package/dist/worker/preflight.js +49 -1
- package/dist/worker/report/morning-report.js +41 -6
- package/dist/worker/run-task/run-task.js +23 -13
- package/dist/worker/runner/run-ready.js +89 -11
- package/dist/worker/task-spec/schema.js +0 -1
- package/dist/workflows/dag/convergence/controller.js +1 -1
- package/dist/workflows/dag/executor-registry.js +0 -2
- package/dist/workflows/dag/governance-profile.js +10 -0
- package/dist/workflows/dag/init-hybrid.js +601 -26
- package/dist/workflows/dag/lifecycle.js +146 -0
- package/dist/workflows/dag/node-execution.js +64 -7
- package/dist/workflows/dag/prompt.js +16 -0
- package/dist/workflows/dag/report.js +2 -0
- package/dist/workflows/dag/runner.js +176 -119
- package/dist/workflows/dag/scheduler.js +7 -2
- package/dist/workflows/dag/skill-snapshot.js +527 -0
- package/dist/workflows/dag/types.js +45 -9
- package/dist/workflows/dag/validate.js +5 -8
- package/dist/workflows/loop/actions/dag-action.js +0 -2
- package/dist/workflows/loop/actions/shared.js +1 -1
- package/dist/workflows/loop/actions.js +14 -31
- package/dist/workflows/loop/benchmark.js +1 -1
- package/dist/workflows/loop/index.js +1 -1
- package/dist/workflows/loop/policy/auto-policy.js +22 -14
- package/dist/workflows/loop/policy/path-patterns.js +13 -0
- package/docs/README.md +35 -16
- package/docs/agent-dag-recovery-playbook.md +1 -1
- package/docs/architecture/README.md +26 -0
- package/docs/architecture/dag-execution.md +134 -0
- package/docs/architecture/evolution.md +52 -0
- package/docs/architecture/facts-and-state.md +58 -0
- package/docs/architecture/runtime-boundaries.md +41 -15
- package/docs/architecture/system-overview.md +93 -0
- package/docs/architecture/worker-and-feature.md +81 -0
- package/docs/cursor-prompt-sidecar.md +36 -0
- package/docs/decisions/README.md +13 -1
- package/docs/design/README.md +39 -13
- package/docs/development-principles.md +1 -1
- package/docs/exec-plans/active/README.md +2 -2
- package/docs/exec-plans/completed/README.md +14 -1
- package/docs/feature-workflow.md +44 -4
- package/docs/init-surface.manifest.json +63 -1
- package/docs/loop-agent-harness.md +65 -3
- package/docs/progress/README.md +27 -0
- package/docs/reports/README.md +74 -8
- package/docs/skills/README.md +2 -1
- package/docs/skills/vetted-skill-registry.md +2 -1
- package/docs/templates/agent-dag-report.schema.json +4 -2
- package/docs/templates/agent-dag.base.json +0 -5
- package/docs/templates/agent-dag.final-verification.json +0 -5
- package/docs/templates/agent-dag.schema.json +1 -2
- package/docs/templates/agent-dag.supervised-implementation.json +1 -6
- package/docs/templates/backend-test-dag.generate-pytest.prompt.md +131 -0
- package/docs/templates/backend-test-dag.json +213 -0
- package/docs/templates/backend-test-dag.retrospect.prompt.md +128 -0
- package/docs/templates/backend-test-dag.review-cases.prompt.md +85 -0
- package/docs/templates/frontend-design-contract.md +33 -0
- package/docs/templates/frontend-task-constraints.md +25 -0
- package/docs/templates/frontend-task-requirement.md +61 -0
- package/docs/templates/harness.schema.json +8 -5
- package/docs/templates/hybrid-dag.json +1 -6
- package/docs/templates/init-evolution-review.md +4 -2
- package/docs/templates/interactive-ui-round2-experiment.md +1 -1
- package/docs/templates/product-line/task.yaml +0 -1
- package/docs/templates/worker-dogfood-evidence.md +28 -0
- package/docs/templates/worker-dogfood-setup.md +20 -0
- package/docs/verification-matrix.md +17 -0
- package/examples/decision-gate-agent-dag.json +87 -33
- package/examples/example-dag.json +0 -5
- package/examples/hybrid-loop-agent-dag.json +0 -5
- package/harness.json +6 -11
- package/package.json +22 -44
- package/scripts/check-product-line-docs.sh +10 -3
- package/skills/agent-worker/SKILL.md +37 -0
- package/skills/agent-worker/references/agent-worker-operator.md +43 -0
- package/skills/frontend-design-review/SKILL.md +59 -0
- package/skills/frontend-design-review/references/review-checklist.md +37 -0
- package/skills/frontend-implementation/SKILL.md +48 -0
- package/skills/frontend-implementation/references/code-standards.md +34 -0
- package/skills/frontend-implementation/references/design-spec.md +46 -0
- package/skills/frontend-implementation/references/node-contracts.md +32 -0
- package/skills/frontend-review/SKILL.md +53 -0
- package/skills/frontend-review/references/review-findings.md +42 -0
- package/skills/frontend-verification/SKILL.md +40 -0
- package/skills/frontend-verification/references/verification-checklist.md +56 -0
- package/skills/grill-me/SKILL.md +10 -0
- package/skills/grill-with-docs/SKILL.md +88 -0
- package/skills/grill-with-docs/adr-format.md +47 -0
- package/skills/grill-with-docs/context-format.md +60 -0
- package/skills/init-capability-evolution/SKILL.md +1 -0
- package/skills/loop-agent/SKILL.md +11 -9
- package/skills/loop-agent/references/command-reference.md +28 -15
- package/skills/loop-agent/references/docs-converge.md +126 -0
- package/skills/loop-agent/references/harness-policy.md +7 -7
- package/skills/loop-agent/references/hybrid-dag.md +13 -15
- package/skills/loop-agent/references/long-running-loop.md +4 -6
- package/skills/loop-agent/references/multi-worktree.md +6 -6
- package/skills/loop-agent/references/orchestrator-and-interventions.md +3 -3
- package/skills/loop-agent/references/pi-subagent-assisted-mode.md +14 -11
- package/skills/using-git-worktrees/SKILL.md +215 -0
- package/dist/commands/cursor-worker.js +0 -43
- package/dist/cursor-worker-entry.js +0 -8
- package/dist/executors/cursor-artifacts.js +0 -33
- package/dist/executors/cursor-execution-log.js +0 -81
- package/dist/executors/cursor-executor-artifacts.js +0 -134
- package/dist/executors/cursor-run.js +0 -115
- package/dist/executors/cursor-tool.js +0 -94
- package/dist/executors/cursor-worker-client.js +0 -223
- package/dist/executors/cursor-worker-protocol.js +0 -18
- package/dist/executors/cursor-worker-server.js +0 -54
- package/dist/executors/cursor-worker.js +0 -3
- package/dist/executors/cursor.js +0 -6
- package/dist/executors/dag-cursor-executor.js +0 -87
- package/dist/workflows/loop/actions/cursor-fix.js +0 -191
- package/dist/workflows/loop/policy/cursor-fix-policy.js +0 -31
- package/docs/cursor-executor-usage.md +0 -25
- package/docs/dynamic-workflow-dag-engine-roadmap.md +0 -1749
package/dist/task/delegate.js
CHANGED
|
@@ -9,31 +9,24 @@ import { getTaskPaths, loadTaskConfig } from './runtime.js';
|
|
|
9
9
|
import { copyDir } from '../records/harvest.js';
|
|
10
10
|
import { saveWorkflowState } from './state.js';
|
|
11
11
|
import { workflowStateSchema } from '../shared/types.js';
|
|
12
|
-
import { assertCursorExecutorAvailable, resolveTaskExecutor, validateCursorTaskPreflight } from '../executors/config-core.js';
|
|
13
|
-
import { resolveDelegateExecutionMode } from '../executors/cursor-execution-log.js';
|
|
14
12
|
/**
|
|
15
13
|
* Atomic delegation: validate source → check conflicts → create worktree →
|
|
16
14
|
* sync source → optionally symlink node_modules.
|
|
17
15
|
*
|
|
18
|
-
*
|
|
16
|
+
* Default is isolation only; callers may run Pi DAG via application use cases.
|
|
19
17
|
*/
|
|
20
18
|
export async function delegateTask(repoRoot, manifest, taskId, opts = {}) {
|
|
21
19
|
const symlinkEnabled = opts.symlinkNodeModules !== false;
|
|
22
20
|
await validateSourceMaterials(repoRoot, taskId);
|
|
23
|
-
|
|
21
|
+
await loadTaskConfig(repoRoot, taskId);
|
|
24
22
|
const effectiveManifest = manifest ?? (await loadHarnessManifest(repoRoot));
|
|
25
|
-
const executor = resolveTaskExecutor(taskConfig, opts.executor);
|
|
26
|
-
if (executor === 'cursor') {
|
|
27
|
-
assertCursorExecutorAvailable(effectiveManifest);
|
|
28
|
-
validateCursorTaskPreflight(taskConfig);
|
|
29
|
-
}
|
|
30
23
|
await validateNoConflicts(repoRoot, taskId, opts.branch);
|
|
31
24
|
const worktree = await createWorktree(repoRoot, effectiveManifest, {
|
|
32
25
|
taskId,
|
|
33
26
|
branch: opts.branch,
|
|
34
27
|
base: opts.base,
|
|
35
28
|
});
|
|
36
|
-
await syncSourceToWorktree(repoRoot, taskId, worktree.path
|
|
29
|
+
await syncSourceToWorktree(repoRoot, taskId, worktree.path);
|
|
37
30
|
let symlinkedNodeModules = false;
|
|
38
31
|
if (symlinkEnabled) {
|
|
39
32
|
symlinkedNodeModules = await setupNodeModulesSymlink(repoRoot, worktree.path);
|
|
@@ -46,13 +39,9 @@ export async function delegateTask(repoRoot, manifest, taskId, opts = {}) {
|
|
|
46
39
|
branch: worktree.branch,
|
|
47
40
|
baseBranch: worktree.base,
|
|
48
41
|
symlinkedNodeModules,
|
|
49
|
-
|
|
50
|
-
executionMode: resolveDelegateExecutionMode(executor),
|
|
42
|
+
executionMode: 'pi-worktree',
|
|
51
43
|
};
|
|
52
44
|
}
|
|
53
|
-
// ---------------------------------------------------------------------------
|
|
54
|
-
// Internal helpers
|
|
55
|
-
// ---------------------------------------------------------------------------
|
|
56
45
|
async function validateSourceMaterials(repoRoot, taskId) {
|
|
57
46
|
const { taskConfigPath, sourceDir } = getTaskPaths(repoRoot, taskId);
|
|
58
47
|
try {
|
|
@@ -96,7 +85,7 @@ async function validateNoConflicts(repoRoot, taskId, branch) {
|
|
|
96
85
|
console.error(`[delegate] warning: branch "${targetBranch}" already exists; will reuse it for the worktree.`);
|
|
97
86
|
}
|
|
98
87
|
}
|
|
99
|
-
async function syncSourceToWorktree(repoRoot, taskId, worktreePath
|
|
88
|
+
async function syncSourceToWorktree(repoRoot, taskId, worktreePath) {
|
|
100
89
|
const srcPaths = getTaskPaths(repoRoot, taskId);
|
|
101
90
|
const destPaths = getTaskPaths(worktreePath, taskId);
|
|
102
91
|
const destTaskDir = destPaths.taskDir;
|
|
@@ -106,16 +95,15 @@ async function syncSourceToWorktree(repoRoot, taskId, worktreePath, executor) {
|
|
|
106
95
|
await copyDir(srcPaths.sourceDir, destSourceDir);
|
|
107
96
|
const rawJson = await readFile(srcPaths.taskConfigPath, 'utf-8');
|
|
108
97
|
const parsedTaskConfig = JSON.parse(rawJson);
|
|
109
|
-
parsedTaskConfig.executor = executor;
|
|
110
98
|
await mkdir(path.dirname(destTaskConfigPath), { recursive: true });
|
|
111
99
|
await writeTaskConfig(worktreePath, taskId, parsedTaskConfig);
|
|
112
100
|
await mkdir(destPaths.logsDir, { recursive: true });
|
|
113
101
|
await initializeArtifacts(destTaskDir);
|
|
114
102
|
await initializeTaskLogStubs(worktreePath, taskId);
|
|
115
|
-
const state = await loadOrCreateWorkflowState(srcPaths.statePath, taskId
|
|
103
|
+
const state = await loadOrCreateWorkflowState(srcPaths.statePath, taskId);
|
|
116
104
|
await saveWorkflowState(destPaths.statePath, state);
|
|
117
105
|
}
|
|
118
|
-
async function loadOrCreateWorkflowState(statePath, taskId
|
|
106
|
+
async function loadOrCreateWorkflowState(statePath, taskId) {
|
|
119
107
|
try {
|
|
120
108
|
const raw = await readFile(statePath, 'utf-8');
|
|
121
109
|
return workflowStateSchema.parse(JSON.parse(raw));
|
|
@@ -129,8 +117,8 @@ async function loadOrCreateWorkflowState(statePath, taskId, executor) {
|
|
|
129
117
|
completedSteps: [],
|
|
130
118
|
lastUpdated: now,
|
|
131
119
|
executor: {
|
|
132
|
-
name:
|
|
133
|
-
mode:
|
|
120
|
+
name: 'pi',
|
|
121
|
+
mode: 'json',
|
|
134
122
|
},
|
|
135
123
|
artifacts: {
|
|
136
124
|
analysis: false,
|
package/dist/task/runtime.js
CHANGED
|
@@ -117,11 +117,10 @@ export async function createTask(repoRoot, taskId, title) {
|
|
|
117
117
|
stopOnHardVerifyPass: true,
|
|
118
118
|
pauseOnRegression: true,
|
|
119
119
|
},
|
|
120
|
-
|
|
120
|
+
loopAutoExecutionPolicy: 'off',
|
|
121
121
|
verifyEnv: 'clean',
|
|
122
122
|
maxGoalContinuationsPerRun: 5,
|
|
123
123
|
piSubagentMode: 'off',
|
|
124
|
-
executor: 'pi',
|
|
125
124
|
notes: '',
|
|
126
125
|
};
|
|
127
126
|
const state = {
|
package/dist/worker/cli.js
CHANGED
|
@@ -3,6 +3,7 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { Command } from "commander";
|
|
6
|
+
import { readPackageVersion } from "../shared/package-metadata.js";
|
|
6
7
|
import YAML from "yaml";
|
|
7
8
|
import { LoopAgentClient } from "./loop-agent/loop-agent-client.js";
|
|
8
9
|
import { resolveLoopAgentProfile } from "./profile-mapping.js";
|
|
@@ -17,17 +18,158 @@ import { getTaskPoolRoot, prepareTaskPoolRetry } from "./pool/run-store.js";
|
|
|
17
18
|
import { taskSpecSchema } from "./task-spec/schema.js";
|
|
18
19
|
import { validateTaskSpec } from "./task-spec/validate.js";
|
|
19
20
|
import { validateFeatureTaskGraph } from "./task-graph/validate.js";
|
|
21
|
+
import { renderFeatureReview, reviewFeature } from "./feature/review.js";
|
|
22
|
+
import { renderFeatureRun, runFeature } from "./feature/run.js";
|
|
23
|
+
import { draftFollowUpDecision } from "./follow-up/factory.js";
|
|
24
|
+
import { approveFollowUp } from "./follow-up/approve.js";
|
|
25
|
+
import { prepareFeatureDelivery } from "./delivery/package.js";
|
|
26
|
+
import { previewFeatureCloseout, renderCloseoutPreview } from "./closeout/preview.js";
|
|
27
|
+
import { applyFeatureCloseout } from "./closeout/apply.js";
|
|
28
|
+
import { projectMonthlyMetrics } from "./metrics/projector.js";
|
|
29
|
+
import { runFeatureFinalVerification } from "./delivery/final-verification.js";
|
|
20
30
|
export function buildAgentWorkerProgram() {
|
|
21
31
|
const program = new Command();
|
|
22
32
|
program
|
|
23
33
|
.name("agent-worker")
|
|
24
34
|
.description("Local product-line worker utilities for TaskSpec validation")
|
|
35
|
+
.version(readPackageVersion(path.dirname(path.dirname(path.dirname(fileURLToPath(import.meta.url))))) ?? "0.0.0", "-V, --version", "display version")
|
|
25
36
|
.showHelpAfterError()
|
|
26
37
|
.showSuggestionAfterError();
|
|
27
38
|
const task = program.command("task").description("TaskSpec utilities");
|
|
28
39
|
const batch = program.command("batch").description("Task Pool batch utilities");
|
|
29
40
|
const report = program.command("report").description("Task Pool reporting utilities");
|
|
30
41
|
const observe = program.command("observe").description("Observe UI server and snapshot utilities");
|
|
42
|
+
const feature = program.command("feature").description("Feature-level review and delivery workflow");
|
|
43
|
+
feature
|
|
44
|
+
.command("review")
|
|
45
|
+
.requiredOption("--feature-dir <dir>", "Feature directory containing acceptance.yaml and tasks/")
|
|
46
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
47
|
+
.option("--json", "Emit stable JSON instead of the human summary")
|
|
48
|
+
.description("Derive Feature status, blockers, acceptance coverage, and next action")
|
|
49
|
+
.action(async (options) => {
|
|
50
|
+
const result = await reviewFeature({
|
|
51
|
+
featureDir: path.resolve(options.featureDir),
|
|
52
|
+
repoRoot: path.resolve(options.repo),
|
|
53
|
+
});
|
|
54
|
+
process.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}\n` : renderFeatureReview(result));
|
|
55
|
+
});
|
|
56
|
+
feature
|
|
57
|
+
.command("run")
|
|
58
|
+
.requiredOption("--feature-dir <dir>", "Feature directory containing acceptance.yaml and tasks/")
|
|
59
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
60
|
+
.option("--dry-run", "Show validation, Ready tasks, steps, and expected artifacts without writes")
|
|
61
|
+
.option("--json", "Emit stable JSON instead of the human summary")
|
|
62
|
+
.option("--limit <count>", "Maximum Ready tasks (without checkpoint mode capped at 1)", "1")
|
|
63
|
+
.option("--git-mode <mode>", "Git mode: none or checkpoint", "none")
|
|
64
|
+
.option("--keep-failed-diff", "Keep a failed task diff and stop instead of restoring")
|
|
65
|
+
.option("--loop-agent-bin <bin>", "loop-agent binary", "loop-agent")
|
|
66
|
+
.option("--batch-run-id <id>", "Batch run id")
|
|
67
|
+
.option("--check-repo", "Run bash scripts/check-repo.sh during target repo preflight")
|
|
68
|
+
.option("--check-repo-command <command...>", "Override the check-repo preflight command")
|
|
69
|
+
.option("--quiet", "Suppress human-readable progress on stderr")
|
|
70
|
+
.option("--pi-model <model>", "Smoke override for pi executor nodes")
|
|
71
|
+
.option("--expected-controller-version <version>", "Exact expected controller version (fail before writes if mismatched)")
|
|
72
|
+
.option("--expected-controller-fingerprint <value>", "Exact expected controller fingerprint sha256:<hex> (fail before writes if mismatched)")
|
|
73
|
+
.description("Validate and advance one Ready Feature task through the existing Worker pipeline")
|
|
74
|
+
.action(async (options) => {
|
|
75
|
+
if (options.gitMode !== "none" && options.gitMode !== "checkpoint")
|
|
76
|
+
throw new Error("feature run --git-mode must be none or checkpoint");
|
|
77
|
+
if (options.keepFailedDiff && options.gitMode !== "checkpoint")
|
|
78
|
+
throw new Error("--keep-failed-diff requires --git-mode checkpoint");
|
|
79
|
+
const repoRoot = path.resolve(options.repo);
|
|
80
|
+
const batchRunId = options.batchRunId ?? buildBatchRunId(new Date());
|
|
81
|
+
const expectedIdentity = buildIdentityExpectation(options);
|
|
82
|
+
const client = new LoopAgentClient({
|
|
83
|
+
loopAgentBin: options.loopAgentBin,
|
|
84
|
+
artifactRoot: path.join(getTaskPoolRoot(repoRoot), "artifacts", batchRunId),
|
|
85
|
+
resolveIdentity: true,
|
|
86
|
+
});
|
|
87
|
+
let progress;
|
|
88
|
+
try {
|
|
89
|
+
progress = createCompositeProgressReporter({
|
|
90
|
+
quiet: options.quiet ?? options.dryRun ?? false,
|
|
91
|
+
eventStore: createRoutedWorkerEventStore(repoRoot),
|
|
92
|
+
context: { batchRunId },
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
progress = createProgressReporter({ quiet: options.quiet ?? options.dryRun ?? false });
|
|
97
|
+
}
|
|
98
|
+
const result = await runFeature({
|
|
99
|
+
featureDir: path.resolve(options.featureDir),
|
|
100
|
+
repoRoot,
|
|
101
|
+
client,
|
|
102
|
+
dryRun: options.dryRun ?? false,
|
|
103
|
+
limit: Number.parseInt(options.limit, 10),
|
|
104
|
+
batchRunId,
|
|
105
|
+
runCheckRepo: options.checkRepo ?? false,
|
|
106
|
+
...(options.checkRepoCommand ? { checkRepoCommand: options.checkRepoCommand } : {}),
|
|
107
|
+
progress,
|
|
108
|
+
...(options.piModel ? { piModel: options.piModel } : {}),
|
|
109
|
+
gitMode: options.gitMode === "checkpoint" ? "checkpoint" : "none",
|
|
110
|
+
keepFailedDiff: options.keepFailedDiff ?? false,
|
|
111
|
+
controllerIdentity: client.getIdentity(),
|
|
112
|
+
controllerExpectation: expectedIdentity,
|
|
113
|
+
});
|
|
114
|
+
process.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}\n` : renderFeatureRun(result));
|
|
115
|
+
if (result.status === "failed" || result.status === "needs-action")
|
|
116
|
+
process.exitCode = 1;
|
|
117
|
+
});
|
|
118
|
+
feature
|
|
119
|
+
.command("verify-final")
|
|
120
|
+
.requiredOption("--feature-dir <dir>", "Feature directory containing acceptance.yaml and tasks/")
|
|
121
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
122
|
+
.requiredOption("--task-id <id>", "Completed qa-execute TaskSpec to rerun as dedicated final verification")
|
|
123
|
+
.option("--loop-agent-bin <bin>", "loop-agent binary", "loop-agent")
|
|
124
|
+
.option("--json", "Emit stable JSON")
|
|
125
|
+
.option("--expected-controller-version <version>", "Exact expected controller version (fail before writes if mismatched)")
|
|
126
|
+
.option("--expected-controller-fingerprint <value>", "Exact expected controller fingerprint sha256:<hex> (fail before writes if mismatched)")
|
|
127
|
+
.description("Run an independent HEAD-bound final QA verification and project Delivery evidence")
|
|
128
|
+
.action(async (options) => {
|
|
129
|
+
const repoRoot = path.resolve(options.repo);
|
|
130
|
+
const client = new LoopAgentClient({ loopAgentBin: options.loopAgentBin, artifactRoot: path.join(getTaskPoolRoot(repoRoot), "artifacts", `final-verification-${Date.now()}`), resolveIdentity: true });
|
|
131
|
+
const result = await runFeatureFinalVerification({ featureDir: path.resolve(options.featureDir), repoRoot, taskId: options.taskId, client, controllerIdentity: client.getIdentity(), controllerExpectation: buildIdentityExpectation(options) });
|
|
132
|
+
process.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}\n` : `Feature: ${result.featureId}\nFinal verification: ${result.workerRunId}\nQA evidence: ${result.qaEvidencePath}\nFinal evidence: ${result.finalVerificationPath}\n`);
|
|
133
|
+
});
|
|
134
|
+
feature
|
|
135
|
+
.command("delivery")
|
|
136
|
+
.requiredOption("--feature-dir <dir>", "Feature directory containing acceptance.yaml and tasks/")
|
|
137
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
138
|
+
.requiredOption("--qa-evidence <path>", "Repo-local QA pass evidence")
|
|
139
|
+
.requiredOption("--final-verification <path>", "Repo-local fresh final verification evidence")
|
|
140
|
+
.option("--waivers <path>", "Repo-local acceptance waiver decisions JSON")
|
|
141
|
+
.option("--dry-run", "Validate and show the Delivery Package plan without writes")
|
|
142
|
+
.option("--json", "Emit stable JSON")
|
|
143
|
+
.description("Validate checkpointed Feature evidence and prepare a local Delivery Package")
|
|
144
|
+
.action(async (options) => {
|
|
145
|
+
const result = await prepareFeatureDelivery({
|
|
146
|
+
featureDir: path.resolve(options.featureDir), repoRoot: path.resolve(options.repo),
|
|
147
|
+
qaEvidencePath: options.qaEvidence, finalVerificationPath: options.finalVerification,
|
|
148
|
+
...(options.waivers ? { waiverPath: options.waivers } : {}), dryRun: options.dryRun ?? false,
|
|
149
|
+
});
|
|
150
|
+
process.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}\n` : `Feature: ${result.featureId}\nDelivery: ${result.status}\nArtifacts: ${Object.values(result.artifacts).join(", ")}\nBlockers: ${result.blockers.join("; ") || "none"}\n`);
|
|
151
|
+
if (result.status === "blocked")
|
|
152
|
+
process.exitCode = 1;
|
|
153
|
+
});
|
|
154
|
+
feature
|
|
155
|
+
.command("closeout")
|
|
156
|
+
.requiredOption("--feature-dir <dir>", "Feature directory containing acceptance.yaml and tasks/")
|
|
157
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
158
|
+
.option("--apply", "Apply Feature Closeout (reserved for M2-08)")
|
|
159
|
+
.option("--owner <owner>", "Closeout owner for apply")
|
|
160
|
+
.option("--json", "Emit stable JSON")
|
|
161
|
+
.description("Preview Feature Closeout gates without modifying the Feature Packet")
|
|
162
|
+
.action(async (options) => {
|
|
163
|
+
if (options.apply) {
|
|
164
|
+
const result = await applyFeatureCloseout({ featureDir: path.resolve(options.featureDir), repoRoot: path.resolve(options.repo), owner: options.owner ?? "" });
|
|
165
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const result = await previewFeatureCloseout({ featureDir: path.resolve(options.featureDir), repoRoot: path.resolve(options.repo) });
|
|
169
|
+
process.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}\n` : renderCloseoutPreview(result));
|
|
170
|
+
if (result.status === "blocked")
|
|
171
|
+
process.exitCode = 1;
|
|
172
|
+
});
|
|
31
173
|
task
|
|
32
174
|
.command("validate")
|
|
33
175
|
.argument("<task-yaml>", "TaskSpec YAML file")
|
|
@@ -74,6 +216,58 @@ export function buildAgentWorkerProgram() {
|
|
|
74
216
|
});
|
|
75
217
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
76
218
|
});
|
|
219
|
+
task
|
|
220
|
+
.command("draft-followup")
|
|
221
|
+
.argument("<task-id>", "Failed parent Task id")
|
|
222
|
+
.requiredOption("--worker-run-id <id>", "Failed Worker run id")
|
|
223
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
224
|
+
.requiredOption("--feature-dir <dir>", "Feature Packet directory")
|
|
225
|
+
.option("--json", "Emit JSON instead of the human summary")
|
|
226
|
+
.description("Create or reuse a classified Follow-up Task draft or human action card")
|
|
227
|
+
.action(async (taskId, options) => {
|
|
228
|
+
try {
|
|
229
|
+
const result = await draftFollowUpDecision({
|
|
230
|
+
repoRoot: path.resolve(options.repo),
|
|
231
|
+
featureDir: path.resolve(options.featureDir),
|
|
232
|
+
taskId,
|
|
233
|
+
workerRunId: options.workerRunId,
|
|
234
|
+
});
|
|
235
|
+
process.stdout.write(options.json
|
|
236
|
+
? `${JSON.stringify(result, null, 2)}\n`
|
|
237
|
+
: result.kind === "TaskDraft"
|
|
238
|
+
? `Follow-up: ${result.followUpId}\n结果: ${result.created ? "已生成任务草稿" : "复用现有任务草稿"}\n下一步: agent-worker feature approve-followup --feature-dir ${JSON.stringify(path.resolve(options.featureDir))} --followup-id ${result.followUpId} --repo ${JSON.stringify(path.resolve(options.repo))} --owner <owner>\n证据: ${result.draftPath}\n`
|
|
239
|
+
: `Follow-up: ${result.followUpId}\n结果: ${result.created ? "已生成人工行动卡" : "复用现有行动卡"}\n下一步: ${result.actionCard.command ?? result.actionCard.label}\n证据: ${result.draftPath}\n`);
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
handleFollowUpCliError(error, options.json ?? false, "draft-followup");
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
feature
|
|
246
|
+
.command("approve-followup")
|
|
247
|
+
.requiredOption("--feature-dir <dir>", "Feature Packet directory")
|
|
248
|
+
.requiredOption("--followup-id <id>", "Follow-up approval id")
|
|
249
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
250
|
+
.requiredOption("--owner <name>", "Human owner approving the Follow-up")
|
|
251
|
+
.option("--dry-run", "Validate baseline and show the transaction plan without writes")
|
|
252
|
+
.option("--json", "Emit JSON instead of the human summary")
|
|
253
|
+
.description("Approve a Follow-up and atomically add its TaskSpec to the Feature")
|
|
254
|
+
.action(async (options) => {
|
|
255
|
+
try {
|
|
256
|
+
const result = await approveFollowUp({
|
|
257
|
+
repoRoot: path.resolve(options.repo),
|
|
258
|
+
featureDir: path.resolve(options.featureDir),
|
|
259
|
+
followUpId: options.followupId,
|
|
260
|
+
owner: options.owner,
|
|
261
|
+
dryRun: options.dryRun ?? false,
|
|
262
|
+
});
|
|
263
|
+
process.stdout.write(options.json
|
|
264
|
+
? `${JSON.stringify(result, null, 2)}\n`
|
|
265
|
+
: `Follow-up: ${result.followUpId}\n结果: ${result.status === "planned" ? "批准事务预览通过" : result.idempotent ? "已批准(幂等复用)" : "已批准并进入 Ready"}\n下一步: agent-worker feature review --feature-dir ${JSON.stringify(path.resolve(options.featureDir))} --repo ${JSON.stringify(path.resolve(options.repo))}\n证据: ${result.approvalPath}\n`);
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
handleFollowUpCliError(error, options.json ?? false, "approve-followup");
|
|
269
|
+
}
|
|
270
|
+
});
|
|
77
271
|
batch
|
|
78
272
|
.command("run-ready")
|
|
79
273
|
.requiredOption("--feature-dir <dir>", "Feature directory containing tasks/task-graph.yaml")
|
|
@@ -85,13 +279,17 @@ export function buildAgentWorkerProgram() {
|
|
|
85
279
|
.option("--check-repo-command <command...>", "Override the check-repo preflight command")
|
|
86
280
|
.option("--quiet", "Suppress human-readable progress on stderr (JSON still goes to stdout)")
|
|
87
281
|
.option("--pi-model <model>", "Smoke override: force every pi executor node to this model (drops --strict-models)")
|
|
282
|
+
.option("--expected-controller-version <version>", "Exact expected controller version (fail before writes if mismatched)")
|
|
283
|
+
.option("--expected-controller-fingerprint <value>", "Exact expected controller fingerprint sha256:<hex> (fail before writes if mismatched)")
|
|
88
284
|
.description("Run ready TaskSpec tasks serially")
|
|
89
285
|
.action(async (options) => {
|
|
90
286
|
const repoRoot = path.resolve(options.repo);
|
|
91
287
|
const batchRunId = options.batchRunId ?? buildBatchRunId(new Date());
|
|
288
|
+
const expectedIdentity = buildIdentityExpectation(options);
|
|
92
289
|
const client = new LoopAgentClient({
|
|
93
290
|
loopAgentBin: options.loopAgentBin,
|
|
94
291
|
artifactRoot: path.join(getTaskPoolRoot(repoRoot), "artifacts", batchRunId),
|
|
292
|
+
resolveIdentity: true,
|
|
95
293
|
});
|
|
96
294
|
let progress;
|
|
97
295
|
try {
|
|
@@ -117,6 +315,8 @@ export function buildAgentWorkerProgram() {
|
|
|
117
315
|
: {}),
|
|
118
316
|
progress,
|
|
119
317
|
...(options.piModel ? { piModel: options.piModel } : {}),
|
|
318
|
+
controllerIdentity: client.getIdentity(),
|
|
319
|
+
controllerExpectation: expectedIdentity,
|
|
120
320
|
});
|
|
121
321
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
122
322
|
if (result.status !== "completed")
|
|
@@ -169,14 +369,57 @@ export function buildAgentWorkerProgram() {
|
|
|
169
369
|
});
|
|
170
370
|
process.stdout.write(`${JSON.stringify({ ok: true, outputPath }, null, 2)}\n`);
|
|
171
371
|
});
|
|
372
|
+
report
|
|
373
|
+
.command("metrics")
|
|
374
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
375
|
+
.requiredOption("--month <yyyy-mm>", "UTC reporting month")
|
|
376
|
+
.option("--json", "Emit the metrics JSON on stdout")
|
|
377
|
+
.description("Project monthly Feature delivery metrics to JSON and Markdown")
|
|
378
|
+
.action(async (options) => {
|
|
379
|
+
const result = await projectMonthlyMetrics({ repoRoot: path.resolve(options.repo), month: options.month });
|
|
380
|
+
process.stdout.write(options.json ? `${JSON.stringify(result.metrics, null, 2)}\n` : `${JSON.stringify({ ok: true, jsonPath: result.jsonPath, markdownPath: result.markdownPath }, null, 2)}\n`);
|
|
381
|
+
});
|
|
172
382
|
return program;
|
|
173
383
|
}
|
|
384
|
+
export function buildIdentityExpectation(options) {
|
|
385
|
+
if (options.expectedControllerVersion || options.expectedControllerFingerprint) {
|
|
386
|
+
const expectation = {};
|
|
387
|
+
if (options.expectedControllerVersion)
|
|
388
|
+
expectation.expectedVersion = options.expectedControllerVersion;
|
|
389
|
+
if (options.expectedControllerFingerprint)
|
|
390
|
+
expectation.expectedFingerprint = options.expectedControllerFingerprint;
|
|
391
|
+
return expectation;
|
|
392
|
+
}
|
|
393
|
+
return undefined;
|
|
394
|
+
}
|
|
174
395
|
export async function main(argv = process.argv) {
|
|
175
396
|
await buildAgentWorkerProgram().parseAsync(argv);
|
|
176
397
|
}
|
|
177
398
|
async function readTaskYaml(taskSpecPath) {
|
|
178
399
|
return YAML.parse(await readFile(taskSpecPath, "utf-8"));
|
|
179
400
|
}
|
|
401
|
+
function handleFollowUpCliError(error, json, action) {
|
|
402
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
403
|
+
if (!json)
|
|
404
|
+
throw error;
|
|
405
|
+
const code = detail.includes("only supports ProductBug")
|
|
406
|
+
? "unsupported-failure-category"
|
|
407
|
+
: detail.includes("baseline changed")
|
|
408
|
+
? "stale-feature-baseline"
|
|
409
|
+
: detail.includes("already exists") || detail.includes("collision")
|
|
410
|
+
? "follow-up-conflict"
|
|
411
|
+
: detail.includes("evidence") || detail.includes("draft hash")
|
|
412
|
+
? "follow-up-evidence-invalid"
|
|
413
|
+
: "follow-up-failed";
|
|
414
|
+
process.stdout.write(`${JSON.stringify({
|
|
415
|
+
schemaVersion: 1,
|
|
416
|
+
status: "failed",
|
|
417
|
+
action,
|
|
418
|
+
error: { code, message: detail },
|
|
419
|
+
nextAction: action === "draft-followup" ? "Inspect the failed Worker run and failure category." : "Regenerate and review the Follow-up draft before approving.",
|
|
420
|
+
}, null, 2)}\n`);
|
|
421
|
+
process.exitCode = 1;
|
|
422
|
+
}
|
|
180
423
|
function isDirectRun() {
|
|
181
424
|
const entry = process.argv[1];
|
|
182
425
|
if (!entry)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { readFile, realpath, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import YAML from "yaml";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { validateDeliveryPackage } from "../delivery/package.js";
|
|
7
|
+
import { validateFeatureTaskGraph } from "../task-graph/validate.js";
|
|
8
|
+
import { previewFeatureCloseout } from "./preview.js";
|
|
9
|
+
export const appliedFeatureCloseoutSchema = z.object({
|
|
10
|
+
schema_version: z.literal(1), feature_id: z.string().min(1), status: z.literal("success"), qa_verdict: z.literal("pass"), qa_evidence: z.array(z.string().min(1)).min(1),
|
|
11
|
+
delivery_manifest_ref: z.string().min(1), owner: z.string().min(1), decided_at: z.string().datetime(), appliedAt: z.string().datetime(), input_facts_hash: z.string().regex(/^[a-f0-9]{64}$/), summary: z.string().min(1),
|
|
12
|
+
}).strict();
|
|
13
|
+
export async function applyFeatureCloseout(input) {
|
|
14
|
+
if (!input.owner.trim())
|
|
15
|
+
throw new Error("feature closeout --apply requires a non-empty owner");
|
|
16
|
+
const repoRoot = await realpath(path.resolve(input.repoRoot));
|
|
17
|
+
const featureDir = await realpath(path.resolve(input.featureDir));
|
|
18
|
+
const relative = path.relative(repoRoot, featureDir);
|
|
19
|
+
if (!relative || relative.startsWith("..") || path.isAbsolute(relative))
|
|
20
|
+
throw new Error("Feature Packet must be inside the target repo");
|
|
21
|
+
const beforeValidation = await validateFeatureTaskGraph(featureDir);
|
|
22
|
+
if (!beforeValidation.ok)
|
|
23
|
+
throw new Error(`Feature Packet is invalid before closeout apply: ${beforeValidation.errors.map((error) => error.code).join(", ")}`);
|
|
24
|
+
const closeoutPath = path.join(featureDir, "closeout.yaml");
|
|
25
|
+
const deliveryPath = path.join(repoRoot, ".harness", "task-pool", "artifacts", "features", beforeValidation.featureId, "delivery", "delivery-manifest.json");
|
|
26
|
+
let previous;
|
|
27
|
+
let reusable;
|
|
28
|
+
try {
|
|
29
|
+
previous = await readFile(closeoutPath);
|
|
30
|
+
const existing = appliedFeatureCloseoutSchema.safeParse(YAML.parse(previous.toString("utf-8")));
|
|
31
|
+
if (existing.success)
|
|
32
|
+
reusable = existing.data;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (!isNotFound(error))
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
if (reusable && reusable.feature_id !== beforeValidation.featureId)
|
|
39
|
+
throw new Error(`existing Feature Closeout ownership mismatch: expected ${beforeValidation.featureId}, got ${reusable.feature_id}`);
|
|
40
|
+
const allowedDirtyPaths = reusable ? [path.relative(repoRoot, closeoutPath).replace(/\\/g, "/")] : undefined;
|
|
41
|
+
const preview = await previewFeatureCloseout({ featureDir, repoRoot, ...(input.now ? { now: input.now } : {}), ...(allowedDirtyPaths ? { allowedDirtyPaths } : {}) });
|
|
42
|
+
if (preview.status !== "ready")
|
|
43
|
+
throw new Error(`Feature Closeout gates are blocked: ${preview.gates.filter((gate) => !gate.passed).map((gate) => `${gate.id} (${gate.message})`).join(", ")}`);
|
|
44
|
+
const delivery = await validateDeliveryPackage({ featureDir, repoRoot, ...(input.now ? { now: input.now } : {}), ...(allowedDirtyPaths ? { allowedDirtyPaths } : {}) });
|
|
45
|
+
if (!delivery.valid || !delivery.manifest)
|
|
46
|
+
throw new Error(`Delivery Package is invalid: ${delivery.blockers.join("; ")}`);
|
|
47
|
+
const inputFactsHash = createHash("sha256").update(await readFile(deliveryPath)).digest("hex");
|
|
48
|
+
const appliedAt = (input.now ?? new Date()).toISOString();
|
|
49
|
+
if (reusable?.input_facts_hash === inputFactsHash)
|
|
50
|
+
return { schemaVersion: 1, featureId: beforeValidation.featureId, status: "reused", closeoutPath, owner: reusable.owner, appliedAt: reusable.appliedAt, inputFactsHash };
|
|
51
|
+
const record = appliedFeatureCloseoutSchema.parse({ schema_version: 1, feature_id: preview.featureId, status: "success", qa_verdict: "pass", qa_evidence: [delivery.manifest.qa.evidence.path, delivery.manifest.finalVerification.path], delivery_manifest_ref: path.relative(repoRoot, deliveryPath).replace(/\\/g, "/"), owner: input.owner.trim(), decided_at: appliedAt, appliedAt, input_facts_hash: inputFactsHash, summary: `Feature ${preview.featureId} passed tasks, QA, required AC, risk, final verification, and Delivery gates.` });
|
|
52
|
+
const temp = path.join(featureDir, `.closeout.${randomUUID()}.tmp`);
|
|
53
|
+
try {
|
|
54
|
+
await writeFile(temp, YAML.stringify(record), "utf-8");
|
|
55
|
+
await rename(temp, closeoutPath);
|
|
56
|
+
const after = await (input.validateAfterWrite ?? validateFeatureTaskGraph)(featureDir);
|
|
57
|
+
if (!after.ok)
|
|
58
|
+
throw new Error(`Feature Packet is invalid after closeout apply: ${after.errors.map((error) => error.code).join(", ")}`);
|
|
59
|
+
return { schemaVersion: 1, featureId: preview.featureId, status: "applied", closeoutPath, owner: record.owner, appliedAt, inputFactsHash };
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
await rm(temp, { force: true });
|
|
63
|
+
if (previous) {
|
|
64
|
+
const rollback = path.join(featureDir, `.closeout.${randomUUID()}.rollback`);
|
|
65
|
+
await writeFile(rollback, previous);
|
|
66
|
+
await rename(rollback, closeoutPath);
|
|
67
|
+
}
|
|
68
|
+
else
|
|
69
|
+
await rm(closeoutPath, { force: true });
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function isNotFound(error) { return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT"); }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { validateDeliveryPackage } from "../delivery/package.js";
|
|
3
|
+
import { reviewFeature } from "../feature/review.js";
|
|
4
|
+
import { getTaskPoolRoot } from "../pool/run-store.js";
|
|
5
|
+
import { validateFeatureTaskGraph } from "../task-graph/validate.js";
|
|
6
|
+
export async function previewFeatureCloseout(input) {
|
|
7
|
+
const featureDir = path.resolve(input.featureDir);
|
|
8
|
+
const repoRoot = path.resolve(input.repoRoot);
|
|
9
|
+
const validation = await validateFeatureTaskGraph(featureDir);
|
|
10
|
+
const model = await reviewFeature({ featureDir, repoRoot });
|
|
11
|
+
const manifestPath = path.join(getTaskPoolRoot(repoRoot), "artifacts", "features", validation.featureId, "delivery", "delivery-manifest.json");
|
|
12
|
+
const delivery = await validateDeliveryPackage({ featureDir, repoRoot, ...(input.now ? { now: input.now } : {}), ...(input.allowedDirtyPaths ? { allowedDirtyPaths: input.allowedDirtyPaths } : {}) });
|
|
13
|
+
const manifest = delivery.manifest;
|
|
14
|
+
const requiredIncomplete = model.acceptanceCoverage.filter((item) => item.required && !["covered", "waived"].includes(item.status));
|
|
15
|
+
const allTasksDone = model.tasks.length > 0 && model.tasks.every((task) => task.status === "Done");
|
|
16
|
+
const gates = [
|
|
17
|
+
{ id: "feature-validation", passed: validation.ok, message: validation.ok ? "Feature Packet is valid" : "Feature Packet validation failed", evidence: validation.errors.flatMap((error) => error.path ? [error.path] : []) },
|
|
18
|
+
{ id: "tasks-complete", passed: allTasksDone, message: allTasksDone ? "All development and QA tasks are Done" : "One or more required tasks are not Done", evidence: model.tasks.filter((task) => task.status !== "Done").map((task) => task.taskId) },
|
|
19
|
+
{ id: "qa-pass", passed: manifest?.qa.verdict === "passed", message: manifest?.qa.verdict === "passed" ? "QA verdict passed" : "QA pass evidence is missing", evidence: manifest ? [manifest.qa.evidence.path] : [] },
|
|
20
|
+
{ id: "required-ac", passed: requiredIncomplete.length === 0, message: requiredIncomplete.length === 0 ? "Required AC are covered or waived" : "Required AC coverage is incomplete", evidence: requiredIncomplete.map((item) => item.acId) },
|
|
21
|
+
{ id: "risk", passed: model.riskSummary.high === 0, message: model.riskSummary.high === 0 ? "No unresolved high risk" : "Unresolved high risk remains", evidence: model.blockingItems.filter((item) => item.failureCategory && ["RiskyChange", "ContractMismatch", "SpecUnclear", "NeedsHuman"].includes(item.failureCategory)).flatMap((item) => item.evidence) },
|
|
22
|
+
{ id: "final-verification", passed: Boolean(manifest?.finalVerification), message: manifest?.finalVerification ? "Final verification evidence is present" : "Final verification evidence is missing", evidence: manifest ? [manifest.finalVerification.path] : [] },
|
|
23
|
+
{ id: "delivery", passed: delivery.valid && model.evidence.delivery === manifestPath, message: delivery.valid && model.evidence.delivery === manifestPath ? "Delivery manifest and Git facts are valid" : `Delivery is invalid: ${delivery.blockers[0] ?? "missing manifest"}`, evidence: manifest ? [manifestPath] : [] },
|
|
24
|
+
];
|
|
25
|
+
const ready = gates.every((gate) => gate.passed);
|
|
26
|
+
return { schemaVersion: 1, featureId: validation.featureId, status: ready ? "ready" : "blocked", gates, nextAction: ready ? "Closeout gates are ready; retain this preview for human review until atomic --apply is implemented in M2-08" : "Resolve the first failed closeout gate and preview again" };
|
|
27
|
+
}
|
|
28
|
+
export function renderCloseoutPreview(preview) {
|
|
29
|
+
return [`Feature: ${preview.featureId}`, `Closeout: ${preview.status === "ready" ? "可应用" : "被阻止"}`, ...preview.gates.map((gate) => `${gate.passed ? "✓" : "✗"} ${gate.id}: ${gate.message}`), `下一步: ${preview.nextAction}`].join("\n") + "\n";
|
|
30
|
+
}
|