@tea-agent/loop-agent 0.8.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 +10 -0
- package/CHANGELOG.md +101 -1
- package/README.md +69 -5
- package/dist/application/dag/args.js +13 -16
- 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 +75 -9
- 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/shared/reference-context.js +48 -22
- 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 +30 -13
- package/dist/task/delegate.js +9 -21
- package/dist/task/runtime.js +2 -3
- 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 +345 -101
- 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/routes.js +78 -20
- package/dist/worker/observe/server.js +8 -6
- package/dist/worker/observe/static/app.js +1045 -177
- package/dist/worker/observe/static/index.html +70 -43
- package/dist/worker/observe/static/styles.css +553 -610
- 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 -12
- 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 +21 -0
- 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 -5
- 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/scripts/check-task-pool-root.sh +1 -1
- 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/loop-agent/references/verification-and-failure-handling.md +8 -3
- 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
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export function projectNextAction(input, status) {
|
|
2
|
+
const featureArgs = `--feature-dir ${quote(input.featureDir)} --repo ${quote(input.repoRoot)}`;
|
|
3
|
+
const resolvedFailures = new Set(input.resolvedFailureTaskIds ?? []);
|
|
4
|
+
if (input.projectionWarnings.length > 0 || !input.validationOk) {
|
|
5
|
+
return {
|
|
6
|
+
kind: "repair_projection",
|
|
7
|
+
label: "修复 Feature Packet 或运行事实后重新审阅",
|
|
8
|
+
...(!input.validationOk
|
|
9
|
+
? { command: `agent-worker task validate-feature ${quote(input.featureDir)}` }
|
|
10
|
+
: {}),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const actionCard = input.actionCards?.[0];
|
|
14
|
+
if (actionCard) {
|
|
15
|
+
return { kind: actionCard.action, label: actionCard.label, ...(actionCard.command ? { command: actionCard.command } : {}) };
|
|
16
|
+
}
|
|
17
|
+
const highRisk = input.tasks.find((task) => ["RiskyChange", "ContractMismatch", "SpecUnclear", "NeedsHuman"].includes(task.failureCategory ?? "") && !resolvedFailures.has(task.taskId));
|
|
18
|
+
if (highRisk) {
|
|
19
|
+
return {
|
|
20
|
+
kind: "resolve_high_risk_gate",
|
|
21
|
+
label: `人工审查 ${highRisk.taskId} 的 ${highRisk.failureCategory} Gate`,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const pendingFollowUp = input.pendingFollowUps?.[0];
|
|
25
|
+
if (pendingFollowUp) {
|
|
26
|
+
return {
|
|
27
|
+
kind: "approve_followup",
|
|
28
|
+
label: `批准 ${pendingFollowUp.followUpId}`,
|
|
29
|
+
command: `agent-worker feature approve-followup --feature-dir ${quote(input.featureDir)} --followup-id ${quote(pendingFollowUp.followUpId)} --repo ${quote(input.repoRoot)} --owner <owner>`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const failed = input.tasks.find((task) => task.status === "Failed" && !resolvedFailures.has(task.taskId));
|
|
33
|
+
if (failed) {
|
|
34
|
+
if (failed.failureCategory === "EnvFailure") {
|
|
35
|
+
return {
|
|
36
|
+
kind: "retry_task",
|
|
37
|
+
label: `重试环境失败任务 ${failed.taskId}`,
|
|
38
|
+
command: `agent-worker task retry ${quote(failed.taskId)} --repo ${quote(input.repoRoot)}`,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
kind: "handle_failure",
|
|
43
|
+
label: `根据失败证据处理 ${failed.taskId};ProductBug 可生成并人工批准 Follow-up`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const blocked = input.tasks.find((task) => ["Blocked", "HumanReview", "Abandoned"].includes(task.status ?? ""));
|
|
47
|
+
if (blocked) {
|
|
48
|
+
return {
|
|
49
|
+
kind: "resolve_human_gate",
|
|
50
|
+
label: `处理 ${blocked.taskId} 的人工 Gate 或阻塞原因`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (status === "ready") {
|
|
54
|
+
return {
|
|
55
|
+
kind: "run_feature",
|
|
56
|
+
label: "执行当前 Ready tasks",
|
|
57
|
+
command: `agent-worker batch run-ready ${featureArgs}`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (status === "awaiting_qa") {
|
|
61
|
+
return { kind: "complete_qa", label: "补齐 QA verdict 与 required AC 证据" };
|
|
62
|
+
}
|
|
63
|
+
if (status === "deliverable") {
|
|
64
|
+
return {
|
|
65
|
+
kind: "prepare_closeout",
|
|
66
|
+
label: "预览 Feature Closeout gates",
|
|
67
|
+
command: `agent-worker feature closeout ${featureArgs}`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function quote(value) {
|
|
73
|
+
return JSON.stringify(value);
|
|
74
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { projectNextAction } from "./next-action.js";
|
|
2
|
+
const STATUS_LABELS = {
|
|
3
|
+
draft: "待准备",
|
|
4
|
+
ready: "可执行",
|
|
5
|
+
running: "执行中",
|
|
6
|
+
needs_action: "需处理",
|
|
7
|
+
awaiting_qa: "待验收",
|
|
8
|
+
deliverable: "可交付",
|
|
9
|
+
closed: "已关闭",
|
|
10
|
+
};
|
|
11
|
+
export function reduceFeature(input) {
|
|
12
|
+
const status = deriveStatus(input);
|
|
13
|
+
const readyTasks = input.tasks.filter((task) => isReady(task.taskId, input));
|
|
14
|
+
const blockingItems = [];
|
|
15
|
+
const resolvedFailures = new Set(input.resolvedFailureTaskIds ?? []);
|
|
16
|
+
for (const error of input.validationErrors) {
|
|
17
|
+
blockingItems.push({ type: "validation_error", message: error, evidence: [] });
|
|
18
|
+
}
|
|
19
|
+
for (const warning of input.projectionWarnings) {
|
|
20
|
+
blockingItems.push({ type: "projection_warning", message: warning, evidence: [] });
|
|
21
|
+
}
|
|
22
|
+
for (const followUp of input.pendingFollowUps ?? []) {
|
|
23
|
+
blockingItems.push({
|
|
24
|
+
type: "pending_follow_up",
|
|
25
|
+
taskId: followUp.parentTaskId,
|
|
26
|
+
followUpId: followUp.followUpId,
|
|
27
|
+
message: `${followUp.followUpId} is waiting for approval`,
|
|
28
|
+
evidence: [followUp.draftPath],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
for (const card of input.actionCards ?? []) {
|
|
32
|
+
blockingItems.push({ type: "follow_up_action", taskId: card.parentTaskId, followUpId: card.followUpId, message: card.label, evidence: [card.draftPath] });
|
|
33
|
+
}
|
|
34
|
+
for (const task of input.tasks.filter((item) => ["Failed", "Blocked", "HumanReview", "Abandoned"].includes(item.status ?? "") &&
|
|
35
|
+
!(item.status === "Failed" && resolvedFailures.has(item.taskId)))) {
|
|
36
|
+
blockingItems.push({
|
|
37
|
+
type: task.status === "Failed"
|
|
38
|
+
? "failed_task"
|
|
39
|
+
: task.status === "HumanReview"
|
|
40
|
+
? "human_gate"
|
|
41
|
+
: task.status === "Abandoned"
|
|
42
|
+
? "abandoned_task"
|
|
43
|
+
: "blocked_task",
|
|
44
|
+
taskId: task.taskId,
|
|
45
|
+
...(task.failureCategory ? { failureCategory: task.failureCategory } : {}),
|
|
46
|
+
message: `${task.taskId} is ${task.status}`,
|
|
47
|
+
evidence: task.failureEvidence ?? [],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const required = input.acceptance.filter((item) => item.required);
|
|
51
|
+
return {
|
|
52
|
+
schemaVersion: 1,
|
|
53
|
+
featureId: input.featureId,
|
|
54
|
+
status,
|
|
55
|
+
statusLabel: STATUS_LABELS[status],
|
|
56
|
+
summary: {
|
|
57
|
+
tasksTotal: input.tasks.length,
|
|
58
|
+
tasksSucceeded: input.tasks.filter((task) => task.status === "Done").length,
|
|
59
|
+
tasksFailed: input.tasks.filter((task) => task.status === "Failed").length,
|
|
60
|
+
tasksReady: readyTasks.length,
|
|
61
|
+
tasksBlocked: input.tasks.filter((task) => task.status === "Blocked").length,
|
|
62
|
+
requiredAcTotal: required.length,
|
|
63
|
+
requiredAcCovered: required.filter((item) => item.status === "covered" || item.status === "waived").length,
|
|
64
|
+
},
|
|
65
|
+
riskSummary: {
|
|
66
|
+
high: (input.delivery?.riskSummary?.high ?? 0) + input.tasks.filter((task) => ["RiskyChange", "ContractMismatch", "SpecUnclear", "NeedsHuman"].includes(task.failureCategory ?? "")).length,
|
|
67
|
+
medium: (input.delivery?.riskSummary?.medium ?? 0) + input.tasks.filter((task) => task.status === "Failed" && !["RiskyChange", "ContractMismatch", "SpecUnclear", "NeedsHuman"].includes(task.failureCategory ?? "")).length,
|
|
68
|
+
low: (input.delivery?.riskSummary?.low ?? 0) + input.tasks.filter((task) => task.status === "Blocked").length,
|
|
69
|
+
},
|
|
70
|
+
blockingItems,
|
|
71
|
+
followUps: {
|
|
72
|
+
pending: input.pendingFollowUps ?? [],
|
|
73
|
+
actionCards: input.actionCards ?? [],
|
|
74
|
+
resolvedFailureTaskIds: input.resolvedFailureTaskIds ?? [],
|
|
75
|
+
},
|
|
76
|
+
tasks: input.tasks.map((task) => ({
|
|
77
|
+
taskId: task.taskId,
|
|
78
|
+
type: task.type,
|
|
79
|
+
status: task.status ?? (isReady(task.taskId, input) ? "Ready" : "Draft"),
|
|
80
|
+
})),
|
|
81
|
+
acceptanceCoverage: input.acceptance,
|
|
82
|
+
nextAction: projectNextAction(input, status),
|
|
83
|
+
alternativeActions: [],
|
|
84
|
+
evidence: {
|
|
85
|
+
morningReport: input.morningReport ?? null,
|
|
86
|
+
observeSnapshot: input.observeSnapshot ?? null,
|
|
87
|
+
delivery: input.delivery?.path ?? null,
|
|
88
|
+
closeout: input.closeout?.path ?? null,
|
|
89
|
+
},
|
|
90
|
+
projectionWarnings: [...input.projectionWarnings],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function deriveStatus(input) {
|
|
94
|
+
if (!input.validationOk)
|
|
95
|
+
return "draft";
|
|
96
|
+
if (input.projectionWarnings.length > 0)
|
|
97
|
+
return "needs_action";
|
|
98
|
+
if ((input.pendingFollowUps?.length ?? 0) > 0)
|
|
99
|
+
return "needs_action";
|
|
100
|
+
if ((input.actionCards?.length ?? 0) > 0)
|
|
101
|
+
return "needs_action";
|
|
102
|
+
const requiredComplete = input.acceptance
|
|
103
|
+
.filter((item) => item.required)
|
|
104
|
+
.every((item) => item.status === "covered" || item.status === "waived");
|
|
105
|
+
const resolvedFailures = new Set(input.resolvedFailureTaskIds ?? []);
|
|
106
|
+
const allTasksDone = input.tasks.length > 0 && input.tasks.every((task) => task.status === "Done" || (task.status === "Failed" && resolvedFailures.has(task.taskId)));
|
|
107
|
+
if (input.closeout?.applied &&
|
|
108
|
+
input.closeout.valid &&
|
|
109
|
+
input.delivery?.valid &&
|
|
110
|
+
requiredComplete &&
|
|
111
|
+
allTasksDone)
|
|
112
|
+
return "closed";
|
|
113
|
+
if (input.tasks.some((task) => ["Failed", "Blocked", "HumanReview", "Abandoned"].includes(task.status ?? "") &&
|
|
114
|
+
!(task.status === "Failed" && (input.resolvedFailureTaskIds ?? []).includes(task.taskId)))) {
|
|
115
|
+
return "needs_action";
|
|
116
|
+
}
|
|
117
|
+
if (input.tasks.some((task) => ["Queued", "Running", "AgentCompleted", "VerificationRunning"].includes(task.status ?? "")))
|
|
118
|
+
return "running";
|
|
119
|
+
if (input.tasks.some((task) => isReady(task.taskId, input)))
|
|
120
|
+
return "ready";
|
|
121
|
+
if (allTasksDone && requiredComplete && input.delivery?.valid) {
|
|
122
|
+
return "deliverable";
|
|
123
|
+
}
|
|
124
|
+
if (allTasksDone)
|
|
125
|
+
return "awaiting_qa";
|
|
126
|
+
return "draft";
|
|
127
|
+
}
|
|
128
|
+
function isReady(taskId, input) {
|
|
129
|
+
const task = input.tasks.find((item) => item.taskId === taskId);
|
|
130
|
+
if (!task || task.status)
|
|
131
|
+
return task?.status === "Ready";
|
|
132
|
+
return task.dependsOn.every((dependencyId) => input.tasks.find((item) => item.taskId === dependencyId)?.status === "Done");
|
|
133
|
+
}
|