@tea-agent/loop-agent 0.26.0 → 0.26.1
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/CHANGELOG.md +1032 -1020
- package/README.md +8 -3
- package/bin/loop-agent.js +21 -21
- package/dist/cli/command-definitions.js +25 -10
- package/dist/cli/help.js +4 -3
- package/dist/cli/program.js +43 -17
- package/dist/commands/cursor-prompt.js +6 -6
- package/dist/commands/import-prd.js +7 -2
- package/dist/commands/init.js +7 -5
- package/dist/commands/loop-benchmark.js +11 -11
- package/dist/commands/pi-reuse-benchmark.js +16 -16
- package/dist/commands/task-source-prepare.js +468 -0
- package/dist/executors/dag-pi-executor.js +40 -5
- package/dist/executors/shell-write-guard.js +161 -25
- package/dist/sidecars/cursor-prompt/executor.js +1 -1
- package/dist/task/source-prepare/build-draft.js +215 -0
- package/dist/task/source-prepare/completeness.js +195 -0
- package/dist/task/source-prepare/index.js +7 -0
- package/dist/task/source-prepare/parse-intent.js +373 -0
- package/dist/task/source-prepare/path-policy.js +197 -0
- package/dist/task/source-prepare/prepare.js +506 -0
- package/dist/task/source-prepare/reference-integrity.js +274 -0
- package/dist/task/source-prepare/types.js +7 -0
- package/dist/worker/observe/static/copy.js +67 -67
- package/dist/worker/observe/static/dag-layout.d.ts +31 -31
- package/dist/worker/observe/static/dag-layout.js +83 -83
- package/dist/worker/observe/static/dom.js +220 -220
- package/dist/worker/observe/static/relations.js +133 -133
- package/dist/worker/observe/static/router.js +93 -93
- package/dist/worker/observe/static/run-processing.js +148 -148
- package/dist/worker/observe/static/views/batch.js +227 -227
- package/dist/worker/observe/static/views/dag-graph.js +172 -172
- package/dist/worker/observe/static/views/failures.js +143 -143
- package/dist/worker/observe/static/views/feature.js +492 -492
- package/dist/worker/observe/static/views/run.js +453 -453
- package/dist/worker/observe/static/views/shell.js +7 -7
- package/dist/worker/observe/static/views/timeline.js +163 -163
- package/dist/workflows/dag/canvas-observer.js +275 -275
- package/docs/skills/README.md +7 -7
- package/docs/templates/adr.md +60 -60
- package/docs/templates/agent-dag-authority-surface-audit.prompt.md +94 -94
- package/docs/templates/agent-dag-decision-envelope.schema.json +213 -213
- package/docs/templates/agent-dag-decision-gate.prompt.md +246 -246
- package/docs/templates/agent-dag-process-supervisor.prompt.md +98 -98
- package/docs/templates/agent-dag-report.schema.json +473 -473
- package/docs/templates/agent-dag-review-verdict.prompt.md +68 -68
- package/docs/templates/backend-test-result.schema.json +99 -99
- package/docs/templates/feature-spec.md +53 -53
- package/docs/templates/frontend-design-contract.md +42 -42
- package/docs/templates/frontend-eval/fixtures/failures/01-type-build-error.md +17 -17
- package/docs/templates/frontend-eval/fixtures/failures/02-unit-component-test-fail.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/03-fixture-schema-drift.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/04-missing-loading-empty-error-state.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/05-forbidden-write-writeset-expansion.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/06-unapproved-dependency-add.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/07-mock-production-on.md +21 -21
- package/docs/templates/frontend-eval/fixtures/functional/01-simple-component-style.md +29 -29
- package/docs/templates/frontend-eval/fixtures/functional/02-form-validation.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/03-list-detail-page.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/04-api-mock.md +29 -29
- package/docs/templates/frontend-eval/fixtures/functional/05-permission-auth-gated-ui.md +27 -27
- package/docs/templates/frontend-eval/fixtures/functional/06-ssr-server-client-boundary.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/07-shared-public-component-api.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/08-pure-local-no-remote.md +27 -27
- package/docs/templates/frontend-eval/metrics.md +138 -138
- package/docs/templates/frontend-eval/smoke-targets.md +53 -53
- package/docs/templates/frontend-task-constraints.md +35 -35
- package/docs/templates/frontend-task-requirement.md +70 -70
- package/docs/templates/init-evolution-review.md +35 -35
- package/docs/templates/init-managed-agents.md +10 -5
- package/docs/templates/interactive-ui-round2-experiment.md +66 -66
- package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -118
- package/docs/templates/knowledge-sync-dag.json +178 -178
- package/docs/templates/knowledge-sync-draft.schema.json +71 -71
- package/docs/templates/product-line/closeout.yaml +9 -9
- package/docs/templates/product-line/design.md +13 -13
- package/docs/templates/product-line/links.md +10 -10
- package/docs/templates/product-line/requirement.md +17 -17
- package/docs/templates/product-line/test-plan.md +7 -7
- package/docs/templates/production-readiness-checklist.md +57 -57
- package/docs/templates/project-start-checklist.md +9 -9
- package/docs/templates/qa-report.md +48 -48
- package/docs/templates/sprint-contract.md +29 -29
- package/docs/templates/worker-dogfood-evidence.md +80 -80
- package/docs/templates/worker-dogfood-setup.md +68 -68
- package/package.json +1 -1
- package/scripts/kb-bootstrap-init-skeleton.sh +0 -0
- package/scripts/kb-graph-incremental-prepare.mjs +386 -386
- package/scripts/kb-graph-materialize.mjs +105 -105
- package/scripts/kb-graph-promote.mjs +164 -164
- package/scripts/kb-query.mjs +554 -554
- package/skills/ai-engineering-context/SKILL.md +48 -48
- package/skills/analyze-product-dependencies/SKILL.md +67 -67
- package/skills/analyze-product-dependencies/agents/openai.yaml +4 -4
- package/skills/analyze-product-dependencies/references/api-documentation-schema.md +30 -30
- package/skills/analyze-product-dependencies/references/dependency-analysis-schema.md +28 -28
- package/skills/analyze-product-dependencies/references/example.md +76 -76
- package/skills/analyze-product-dependencies/references/forward-test-cases.md +35 -35
- package/skills/analyze-product-dependencies/references/input-contract.md +11 -11
- package/skills/analyze-product-dependencies/references/scouting-rules.md +61 -61
- package/skills/analyze-product-dependencies/scripts/test-validators.mjs +267 -267
- package/skills/analyze-product-dependencies/scripts/validate-api-documentation.mjs +101 -101
- package/skills/analyze-product-dependencies/scripts/validate-dependency-analysis.mjs +142 -142
- package/skills/analyze-product-dependencies/scripts/validate-product-requirement-input.mjs +76 -76
- package/skills/analyze-product-dependencies/scripts/validation-helpers.mjs +146 -146
- package/skills/analyze-product-requirements/SKILL.md +90 -90
- package/skills/analyze-product-requirements/agents/openai.yaml +4 -4
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +91 -91
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +56 -56
- package/skills/analyze-product-requirements/references/example.md +86 -86
- package/skills/analyze-product-requirements/references/forward-test-cases.md +66 -66
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +32 -32
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +33 -33
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +35 -35
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +193 -193
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +69 -69
- package/skills/analyze-product-requirements/scripts/validate-product-requirement.mjs +97 -97
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +98 -98
- package/skills/analyze-product-requirements/scripts/validation-helpers.mjs +156 -156
- package/skills/browser-tools/browser-content.js +103 -103
- package/skills/browser-tools/browser-cookies.js +35 -35
- package/skills/browser-tools/browser-eval.js +53 -53
- package/skills/browser-tools/browser-hn-scraper.js +108 -108
- package/skills/browser-tools/browser-nav.js +44 -44
- package/skills/browser-tools/browser-pick.js +162 -162
- package/skills/browser-tools/browser-screenshot.js +34 -34
- package/skills/browser-tools/browser-start.js +86 -86
- package/skills/browser-tools/package-lock.json +2556 -2556
- package/skills/browser-tools/package.json +19 -19
- package/skills/code-review-core/SKILL.md +20 -20
- package/skills/codebase-scout/SKILL.md +19 -19
- package/skills/grill-me/SKILL.md +10 -10
- package/skills/loop-agent/SKILL.md +5 -2
- package/skills/loop-agent/references/README.md +67 -67
- package/skills/loop-agent/references/command-reference.md +17 -15
- package/skills/loop-agent/references/docs-converge.md +126 -126
- package/skills/loop-agent/references/harness-policy.md +3 -4
- package/skills/loop-agent/references/learned/README.md +21 -21
- package/skills/loop-agent/references/long-running-loop.md +57 -57
- package/skills/loop-agent/references/one-shot-runs.md +85 -85
- package/skills/loop-agent/references/pi-prompt.md +23 -23
- package/skills/loop-agent/references/pi-subagent-assisted-mode.md +84 -84
- package/skills/loop-agent/references/post-implementation-and-patterns.md +1 -1
- package/skills/loop-agent/references/source-and-plan-practice.md +3 -2
- package/skills/loop-agent/references/task-workflow.md +7 -5
- package/skills/playwright-cli/SKILL.md +420 -420
- package/skills/playwright-cli/references/element-attributes.md +23 -23
- package/skills/playwright-cli/references/playwright-tests.md +39 -39
- package/skills/playwright-cli/references/request-mocking.md +87 -87
- package/skills/playwright-cli/references/running-code.md +241 -241
- package/skills/playwright-cli/references/session-management.md +225 -225
- package/skills/playwright-cli/references/storage-state.md +275 -275
- package/skills/playwright-cli/references/test-generation.md +433 -433
- package/skills/playwright-cli/references/tracing.md +139 -139
- package/skills/playwright-cli/references/video-recording.md +143 -143
- package/skills/requesting-code-review/SKILL.md +101 -101
- package/skills/requesting-code-review/code-reviewer.md +168 -168
- package/skills/systematic-debugging/CREATION-LOG.md +119 -119
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -158
- package/skills/systematic-debugging/condition-based-waiting.md +115 -115
- package/skills/systematic-debugging/defense-in-depth.md +122 -122
- package/skills/systematic-debugging/find-polluter.sh +63 -63
- package/skills/systematic-debugging/root-cause-tracing.md +169 -169
- package/skills/systematic-debugging/test-academic.md +14 -14
- package/skills/systematic-debugging/test-pressure-1.md +58 -58
- package/skills/systematic-debugging/test-pressure-2.md +68 -68
- package/skills/systematic-debugging/test-pressure-3.md +69 -69
- package/skills/using-git-worktrees/SKILL.md +215 -215
- package/skills/verification-before-completion/SKILL.md +154 -154
- package/skills/webapp-testing/SKILL.md +19 -19
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
/** DAG dependency graph rendering (Observe UI R5). */
|
|
2
|
-
import { layoutDag } from "../dag-layout.js";
|
|
3
|
-
import { el } from "../dom.js";
|
|
4
|
-
import {
|
|
5
|
-
statusLabel,
|
|
6
|
-
statusSymbol,
|
|
7
|
-
formatMs,
|
|
8
|
-
truncateText,
|
|
9
|
-
} from "../format.js";
|
|
10
|
-
import {
|
|
11
|
-
uiState,
|
|
12
|
-
dagGraphViewportStates,
|
|
13
|
-
updateDagGraphViewportState,
|
|
14
|
-
} from "../state.js";
|
|
15
|
-
import { selectDagNode } from "./dag-inspector.js";
|
|
16
|
-
|
|
17
|
-
export function svgEl(tag, attrs = {}) {
|
|
18
|
-
const node = document.createElementNS("http://www.w3.org/2000/svg", tag);
|
|
19
|
-
for (const [key, value] of Object.entries(attrs))
|
|
20
|
-
node.setAttribute(key, String(value));
|
|
21
|
-
return node;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function renderDagGraph(dag, dagRunId, existingWrap = null) {
|
|
25
|
-
const nodes = dag.nodes ?? [];
|
|
26
|
-
const edges = dag.edges ?? [];
|
|
27
|
-
const layout = layoutDag(nodes, edges, dag.ranks ?? []);
|
|
28
|
-
const wrap = existingWrap ?? el("div", "dag-graph-wrap");
|
|
29
|
-
if (existingWrap) {
|
|
30
|
-
// reuse-dag-graph-wrap: replace children while keeping wrap identity.
|
|
31
|
-
while (wrap.firstChild) wrap.removeChild(wrap.firstChild);
|
|
32
|
-
}
|
|
33
|
-
const toolbar = el("div", "dag-graph-toolbar");
|
|
34
|
-
toolbar.appendChild(
|
|
35
|
-
el(
|
|
36
|
-
"span",
|
|
37
|
-
"dag-graph-summary",
|
|
38
|
-
`${nodes.length} 节点 · ${layout.edges.length} 条依赖`,
|
|
39
|
-
),
|
|
40
|
-
);
|
|
41
|
-
const reset = el("button", "dag-graph-reset", "重置视图");
|
|
42
|
-
toolbar.appendChild(reset);
|
|
43
|
-
wrap.appendChild(toolbar);
|
|
44
|
-
if (edges.length === 0)
|
|
45
|
-
wrap.appendChild(
|
|
46
|
-
el(
|
|
47
|
-
"p",
|
|
48
|
-
"dag-graph-fallback",
|
|
49
|
-
"该运行没有可用依赖数据;图按并行层级展示,节点表格仍保留完整数据。",
|
|
50
|
-
),
|
|
51
|
-
);
|
|
52
|
-
const viewport = el("div", "dag-graph-viewport");
|
|
53
|
-
viewport.dataset.dagRunId = dagRunId;
|
|
54
|
-
const svg = svgEl("svg", {
|
|
55
|
-
class: "dag-graph",
|
|
56
|
-
viewBox: `0 0 ${layout.width} ${layout.height}`,
|
|
57
|
-
width: layout.width,
|
|
58
|
-
height: layout.height,
|
|
59
|
-
role: "img",
|
|
60
|
-
"aria-label": `DAG 依赖图,共 ${nodes.length} 个节点`,
|
|
61
|
-
});
|
|
62
|
-
const defs = svgEl("defs");
|
|
63
|
-
const marker = svgEl("marker", {
|
|
64
|
-
id: "dag-arrow",
|
|
65
|
-
viewBox: "0 0 10 10",
|
|
66
|
-
refX: 9,
|
|
67
|
-
refY: 5,
|
|
68
|
-
markerWidth: 7,
|
|
69
|
-
markerHeight: 7,
|
|
70
|
-
orient: "auto-start-reverse",
|
|
71
|
-
});
|
|
72
|
-
marker.appendChild(svgEl("path", { d: "M 0 0 L 10 5 L 0 10 z" }));
|
|
73
|
-
defs.appendChild(marker);
|
|
74
|
-
svg.appendChild(defs);
|
|
75
|
-
const related = new Set([uiState.selectedDagNodeId]);
|
|
76
|
-
for (const edge of layout.edges)
|
|
77
|
-
if (
|
|
78
|
-
edge.from === uiState.selectedDagNodeId ||
|
|
79
|
-
edge.to === uiState.selectedDagNodeId
|
|
80
|
-
) {
|
|
81
|
-
related.add(edge.from);
|
|
82
|
-
related.add(edge.to);
|
|
83
|
-
}
|
|
84
|
-
for (const edge of layout.edges) {
|
|
85
|
-
const path = svgEl("path", {
|
|
86
|
-
d: edge.path,
|
|
87
|
-
class: `dag-edge${uiState.selectedDagNodeId && (!related.has(edge.from) || !related.has(edge.to)) ? " dag-dimmed" : ""}`,
|
|
88
|
-
"marker-end": "url(#dag-arrow)",
|
|
89
|
-
});
|
|
90
|
-
path.appendChild(svgEl("title"));
|
|
91
|
-
path.firstChild.textContent = `${edge.from} → ${edge.to}`;
|
|
92
|
-
svg.appendChild(path);
|
|
93
|
-
}
|
|
94
|
-
const byId = Object.fromEntries(nodes.map((node) => [node.nodeId, node]));
|
|
95
|
-
for (const position of layout.nodes) {
|
|
96
|
-
const node = byId[position.nodeId] ?? { nodeId: position.nodeId };
|
|
97
|
-
const status = (node.status ?? "unknown").toLowerCase();
|
|
98
|
-
const group = svgEl("g", {
|
|
99
|
-
transform: `translate(${position.x} ${position.y})`,
|
|
100
|
-
class: `dag-graph-node status-${status}${node.nodeId === uiState.selectedDagNodeId ? " selected" : ""}${uiState.selectedDagNodeId && !related.has(node.nodeId) ? " dag-dimmed" : ""}`,
|
|
101
|
-
tabindex: 0,
|
|
102
|
-
role: "button",
|
|
103
|
-
"aria-label": `${node.nodeId},状态 ${status}`,
|
|
104
|
-
});
|
|
105
|
-
group.appendChild(
|
|
106
|
-
svgEl("rect", { width: position.width, height: position.height, rx: 10 }),
|
|
107
|
-
);
|
|
108
|
-
const title = svgEl("title");
|
|
109
|
-
title.textContent = `${node.nodeId}\n${node.executor ?? "未知执行器"}\n${status}`;
|
|
110
|
-
group.appendChild(title);
|
|
111
|
-
const label = svgEl("text", { x: 14, y: 26, class: "dag-node-label" });
|
|
112
|
-
label.textContent = truncateText(node.label ?? node.nodeId, 26);
|
|
113
|
-
group.appendChild(label);
|
|
114
|
-
const executor = svgEl("text", { x: 14, y: 50, class: "dag-node-meta" });
|
|
115
|
-
executor.textContent = `◈ ${node.executor ?? "unknown"}`;
|
|
116
|
-
group.appendChild(executor);
|
|
117
|
-
const state = svgEl("text", { x: 14, y: 74, class: "dag-node-status" });
|
|
118
|
-
state.textContent = `${statusSymbol(status)} ${statusLabel(node.status)} · ${formatMs(node.durationMs)}`;
|
|
119
|
-
group.appendChild(state);
|
|
120
|
-
const activate = () => selectDagNode(dagRunId, node.nodeId);
|
|
121
|
-
group.addEventListener("click", activate);
|
|
122
|
-
group.addEventListener("keydown", (event) => {
|
|
123
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
124
|
-
event.preventDefault();
|
|
125
|
-
activate();
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
svg.appendChild(group);
|
|
129
|
-
}
|
|
130
|
-
viewport.appendChild(svg);
|
|
131
|
-
wrap.appendChild(viewport);
|
|
132
|
-
const graphViewportState =
|
|
133
|
-
dagGraphViewportStates.get(dagRunId) ??
|
|
134
|
-
(uiState.dagGraphViewportState?.dagRunId === dagRunId
|
|
135
|
-
? uiState.dagGraphViewportState
|
|
136
|
-
: null);
|
|
137
|
-
viewport.addEventListener(
|
|
138
|
-
"scroll",
|
|
139
|
-
() => {
|
|
140
|
-
uiState.dagGraphViewportState = updateDagGraphViewportState(
|
|
141
|
-
uiState.dagGraphViewportState,
|
|
142
|
-
dagRunId,
|
|
143
|
-
viewport.scrollLeft,
|
|
144
|
-
viewport.scrollTop,
|
|
145
|
-
);
|
|
146
|
-
dagGraphViewportStates.set(dagRunId, uiState.dagGraphViewportState);
|
|
147
|
-
},
|
|
148
|
-
{ passive: true },
|
|
149
|
-
);
|
|
150
|
-
if (graphViewportState) {
|
|
151
|
-
const restoreViewport = () => {
|
|
152
|
-
viewport.scrollLeft = graphViewportState.scrollLeft;
|
|
153
|
-
viewport.scrollTop = graphViewportState.scrollTop;
|
|
154
|
-
};
|
|
155
|
-
if (typeof requestAnimationFrame === "function") {
|
|
156
|
-
requestAnimationFrame(restoreViewport);
|
|
157
|
-
} else {
|
|
158
|
-
restoreViewport();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
reset.addEventListener("click", () => {
|
|
162
|
-
uiState.dagGraphViewportState = updateDagGraphViewportState(
|
|
163
|
-
uiState.dagGraphViewportState,
|
|
164
|
-
dagRunId,
|
|
165
|
-
0,
|
|
166
|
-
0,
|
|
167
|
-
);
|
|
168
|
-
dagGraphViewportStates.set(dagRunId, uiState.dagGraphViewportState);
|
|
169
|
-
viewport.scrollTo({ left: 0, top: 0, behavior: "smooth" });
|
|
170
|
-
});
|
|
171
|
-
return wrap;
|
|
172
|
-
}
|
|
1
|
+
/** DAG dependency graph rendering (Observe UI R5). */
|
|
2
|
+
import { layoutDag } from "../dag-layout.js";
|
|
3
|
+
import { el } from "../dom.js";
|
|
4
|
+
import {
|
|
5
|
+
statusLabel,
|
|
6
|
+
statusSymbol,
|
|
7
|
+
formatMs,
|
|
8
|
+
truncateText,
|
|
9
|
+
} from "../format.js";
|
|
10
|
+
import {
|
|
11
|
+
uiState,
|
|
12
|
+
dagGraphViewportStates,
|
|
13
|
+
updateDagGraphViewportState,
|
|
14
|
+
} from "../state.js";
|
|
15
|
+
import { selectDagNode } from "./dag-inspector.js";
|
|
16
|
+
|
|
17
|
+
export function svgEl(tag, attrs = {}) {
|
|
18
|
+
const node = document.createElementNS("http://www.w3.org/2000/svg", tag);
|
|
19
|
+
for (const [key, value] of Object.entries(attrs))
|
|
20
|
+
node.setAttribute(key, String(value));
|
|
21
|
+
return node;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function renderDagGraph(dag, dagRunId, existingWrap = null) {
|
|
25
|
+
const nodes = dag.nodes ?? [];
|
|
26
|
+
const edges = dag.edges ?? [];
|
|
27
|
+
const layout = layoutDag(nodes, edges, dag.ranks ?? []);
|
|
28
|
+
const wrap = existingWrap ?? el("div", "dag-graph-wrap");
|
|
29
|
+
if (existingWrap) {
|
|
30
|
+
// reuse-dag-graph-wrap: replace children while keeping wrap identity.
|
|
31
|
+
while (wrap.firstChild) wrap.removeChild(wrap.firstChild);
|
|
32
|
+
}
|
|
33
|
+
const toolbar = el("div", "dag-graph-toolbar");
|
|
34
|
+
toolbar.appendChild(
|
|
35
|
+
el(
|
|
36
|
+
"span",
|
|
37
|
+
"dag-graph-summary",
|
|
38
|
+
`${nodes.length} 节点 · ${layout.edges.length} 条依赖`,
|
|
39
|
+
),
|
|
40
|
+
);
|
|
41
|
+
const reset = el("button", "dag-graph-reset", "重置视图");
|
|
42
|
+
toolbar.appendChild(reset);
|
|
43
|
+
wrap.appendChild(toolbar);
|
|
44
|
+
if (edges.length === 0)
|
|
45
|
+
wrap.appendChild(
|
|
46
|
+
el(
|
|
47
|
+
"p",
|
|
48
|
+
"dag-graph-fallback",
|
|
49
|
+
"该运行没有可用依赖数据;图按并行层级展示,节点表格仍保留完整数据。",
|
|
50
|
+
),
|
|
51
|
+
);
|
|
52
|
+
const viewport = el("div", "dag-graph-viewport");
|
|
53
|
+
viewport.dataset.dagRunId = dagRunId;
|
|
54
|
+
const svg = svgEl("svg", {
|
|
55
|
+
class: "dag-graph",
|
|
56
|
+
viewBox: `0 0 ${layout.width} ${layout.height}`,
|
|
57
|
+
width: layout.width,
|
|
58
|
+
height: layout.height,
|
|
59
|
+
role: "img",
|
|
60
|
+
"aria-label": `DAG 依赖图,共 ${nodes.length} 个节点`,
|
|
61
|
+
});
|
|
62
|
+
const defs = svgEl("defs");
|
|
63
|
+
const marker = svgEl("marker", {
|
|
64
|
+
id: "dag-arrow",
|
|
65
|
+
viewBox: "0 0 10 10",
|
|
66
|
+
refX: 9,
|
|
67
|
+
refY: 5,
|
|
68
|
+
markerWidth: 7,
|
|
69
|
+
markerHeight: 7,
|
|
70
|
+
orient: "auto-start-reverse",
|
|
71
|
+
});
|
|
72
|
+
marker.appendChild(svgEl("path", { d: "M 0 0 L 10 5 L 0 10 z" }));
|
|
73
|
+
defs.appendChild(marker);
|
|
74
|
+
svg.appendChild(defs);
|
|
75
|
+
const related = new Set([uiState.selectedDagNodeId]);
|
|
76
|
+
for (const edge of layout.edges)
|
|
77
|
+
if (
|
|
78
|
+
edge.from === uiState.selectedDagNodeId ||
|
|
79
|
+
edge.to === uiState.selectedDagNodeId
|
|
80
|
+
) {
|
|
81
|
+
related.add(edge.from);
|
|
82
|
+
related.add(edge.to);
|
|
83
|
+
}
|
|
84
|
+
for (const edge of layout.edges) {
|
|
85
|
+
const path = svgEl("path", {
|
|
86
|
+
d: edge.path,
|
|
87
|
+
class: `dag-edge${uiState.selectedDagNodeId && (!related.has(edge.from) || !related.has(edge.to)) ? " dag-dimmed" : ""}`,
|
|
88
|
+
"marker-end": "url(#dag-arrow)",
|
|
89
|
+
});
|
|
90
|
+
path.appendChild(svgEl("title"));
|
|
91
|
+
path.firstChild.textContent = `${edge.from} → ${edge.to}`;
|
|
92
|
+
svg.appendChild(path);
|
|
93
|
+
}
|
|
94
|
+
const byId = Object.fromEntries(nodes.map((node) => [node.nodeId, node]));
|
|
95
|
+
for (const position of layout.nodes) {
|
|
96
|
+
const node = byId[position.nodeId] ?? { nodeId: position.nodeId };
|
|
97
|
+
const status = (node.status ?? "unknown").toLowerCase();
|
|
98
|
+
const group = svgEl("g", {
|
|
99
|
+
transform: `translate(${position.x} ${position.y})`,
|
|
100
|
+
class: `dag-graph-node status-${status}${node.nodeId === uiState.selectedDagNodeId ? " selected" : ""}${uiState.selectedDagNodeId && !related.has(node.nodeId) ? " dag-dimmed" : ""}`,
|
|
101
|
+
tabindex: 0,
|
|
102
|
+
role: "button",
|
|
103
|
+
"aria-label": `${node.nodeId},状态 ${status}`,
|
|
104
|
+
});
|
|
105
|
+
group.appendChild(
|
|
106
|
+
svgEl("rect", { width: position.width, height: position.height, rx: 10 }),
|
|
107
|
+
);
|
|
108
|
+
const title = svgEl("title");
|
|
109
|
+
title.textContent = `${node.nodeId}\n${node.executor ?? "未知执行器"}\n${status}`;
|
|
110
|
+
group.appendChild(title);
|
|
111
|
+
const label = svgEl("text", { x: 14, y: 26, class: "dag-node-label" });
|
|
112
|
+
label.textContent = truncateText(node.label ?? node.nodeId, 26);
|
|
113
|
+
group.appendChild(label);
|
|
114
|
+
const executor = svgEl("text", { x: 14, y: 50, class: "dag-node-meta" });
|
|
115
|
+
executor.textContent = `◈ ${node.executor ?? "unknown"}`;
|
|
116
|
+
group.appendChild(executor);
|
|
117
|
+
const state = svgEl("text", { x: 14, y: 74, class: "dag-node-status" });
|
|
118
|
+
state.textContent = `${statusSymbol(status)} ${statusLabel(node.status)} · ${formatMs(node.durationMs)}`;
|
|
119
|
+
group.appendChild(state);
|
|
120
|
+
const activate = () => selectDagNode(dagRunId, node.nodeId);
|
|
121
|
+
group.addEventListener("click", activate);
|
|
122
|
+
group.addEventListener("keydown", (event) => {
|
|
123
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
activate();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
svg.appendChild(group);
|
|
129
|
+
}
|
|
130
|
+
viewport.appendChild(svg);
|
|
131
|
+
wrap.appendChild(viewport);
|
|
132
|
+
const graphViewportState =
|
|
133
|
+
dagGraphViewportStates.get(dagRunId) ??
|
|
134
|
+
(uiState.dagGraphViewportState?.dagRunId === dagRunId
|
|
135
|
+
? uiState.dagGraphViewportState
|
|
136
|
+
: null);
|
|
137
|
+
viewport.addEventListener(
|
|
138
|
+
"scroll",
|
|
139
|
+
() => {
|
|
140
|
+
uiState.dagGraphViewportState = updateDagGraphViewportState(
|
|
141
|
+
uiState.dagGraphViewportState,
|
|
142
|
+
dagRunId,
|
|
143
|
+
viewport.scrollLeft,
|
|
144
|
+
viewport.scrollTop,
|
|
145
|
+
);
|
|
146
|
+
dagGraphViewportStates.set(dagRunId, uiState.dagGraphViewportState);
|
|
147
|
+
},
|
|
148
|
+
{ passive: true },
|
|
149
|
+
);
|
|
150
|
+
if (graphViewportState) {
|
|
151
|
+
const restoreViewport = () => {
|
|
152
|
+
viewport.scrollLeft = graphViewportState.scrollLeft;
|
|
153
|
+
viewport.scrollTop = graphViewportState.scrollTop;
|
|
154
|
+
};
|
|
155
|
+
if (typeof requestAnimationFrame === "function") {
|
|
156
|
+
requestAnimationFrame(restoreViewport);
|
|
157
|
+
} else {
|
|
158
|
+
restoreViewport();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
reset.addEventListener("click", () => {
|
|
162
|
+
uiState.dagGraphViewportState = updateDagGraphViewportState(
|
|
163
|
+
uiState.dagGraphViewportState,
|
|
164
|
+
dagRunId,
|
|
165
|
+
0,
|
|
166
|
+
0,
|
|
167
|
+
);
|
|
168
|
+
dagGraphViewportStates.set(dagRunId, uiState.dagGraphViewportState);
|
|
169
|
+
viewport.scrollTo({ left: 0, top: 0, behavior: "smooth" });
|
|
170
|
+
});
|
|
171
|
+
return wrap;
|
|
172
|
+
}
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
/** Observe UI view module (R5). */
|
|
2
|
-
import {
|
|
3
|
-
UI_TEXT,
|
|
4
|
-
LIVENESS_LABELS,
|
|
5
|
-
ARTIFACT_LABELS,
|
|
6
|
-
ARTIFACT_KEYS,
|
|
7
|
-
STEP_LABELS,
|
|
8
|
-
STEP_ORDER,
|
|
9
|
-
DAG_INSPECTOR_DEFAULT_WIDTH,
|
|
10
|
-
DAG_INSPECTOR_MIN_WIDTH,
|
|
11
|
-
DAG_INSPECTOR_MAX_WIDTH,
|
|
12
|
-
DAG_INSPECTOR_RIGHT_OFFSET,
|
|
13
|
-
DAG_INSPECTOR_VIEWPORT_MARGIN,
|
|
14
|
-
DAG_INSPECTOR_KEYBOARD_STEP,
|
|
15
|
-
TERMINAL_RUN_STATUSES,
|
|
16
|
-
DAG_EFFECTIVE_STATUS_LABELS,
|
|
17
|
-
STATUS_LABELS,
|
|
18
|
-
} from "../constants.js";
|
|
19
|
-
import { clearNode, el, metaGrid, buildTable } from "../dom.js";
|
|
20
|
-
import {
|
|
21
|
-
badge,
|
|
22
|
-
badgeClass,
|
|
23
|
-
statusLabel,
|
|
24
|
-
formatTs,
|
|
25
|
-
formatMs,
|
|
26
|
-
formatDuration,
|
|
27
|
-
formatAgo,
|
|
28
|
-
dagStatusBadge,
|
|
29
|
-
livenessBadge,
|
|
30
|
-
displayDurationMs,
|
|
31
|
-
derivedDurationMs,
|
|
32
|
-
summaryText,
|
|
33
|
-
truncateText,
|
|
34
|
-
repoBaseName,
|
|
35
|
-
parseMarkdownBlocks,
|
|
36
|
-
markdownLinkHref,
|
|
37
|
-
} from "../format.js";
|
|
38
|
-
import { parseRoute, navigate, buildHashPath } from "../router.js";
|
|
39
|
-
import { fetchJson, artifactUrl, parseArtifactPreviewResponse } from "../api.js";
|
|
40
|
-
import {
|
|
41
|
-
objectRouteLink,
|
|
42
|
-
findFeatureInSnapshot,
|
|
43
|
-
featureLookupState,
|
|
44
|
-
buildObjectRelations,
|
|
45
|
-
renderObjectRelationBar,
|
|
46
|
-
} from "../relations.js";
|
|
47
|
-
import { copyText, renderRecommendedCommand } from "../copy.js";
|
|
48
|
-
import {
|
|
49
|
-
isPageVisible,
|
|
50
|
-
detailPollDelay,
|
|
51
|
-
dashboardPollDelay,
|
|
52
|
-
captureDagGraphViewportState,
|
|
53
|
-
updateDagGraphViewportState,
|
|
54
|
-
updateDagTimelineViewportState,
|
|
55
|
-
renderViewState,
|
|
56
|
-
mountViewState,
|
|
57
|
-
} from "../state.js";
|
|
58
|
-
import { uiState } from "../state.js";
|
|
59
|
-
import { sortPoolTasks } from "../format-pool.js";
|
|
60
|
-
import {
|
|
61
|
-
dagMetaVisibility,
|
|
62
|
-
isDagRunActive,
|
|
63
|
-
dashboardVisibleFeatures,
|
|
64
|
-
findDagForRun,
|
|
65
|
-
} from "../dag-model.js";
|
|
66
|
-
import { layoutDag } from "../dag-layout.js";
|
|
67
|
-
import { showView, setBreadcrumb, updateHeaderRefresh } from "../shell-chrome.js";
|
|
68
|
-
import { artifactLink } from "../kpi.js";
|
|
69
|
-
|
|
70
|
-
export async function renderFailures() {
|
|
71
|
-
showView("failures");
|
|
72
|
-
setBreadcrumb([
|
|
73
|
-
{ label: UI_TEXT.dashboard, href: "#/" },
|
|
74
|
-
{ label: UI_TEXT.failures },
|
|
75
|
-
]);
|
|
76
|
-
|
|
77
|
-
const listEl = document.getElementById("failures-list");
|
|
78
|
-
const emptyEl = document.getElementById("failures-empty");
|
|
79
|
-
clearNode(listEl);
|
|
80
|
-
if (emptyEl) {
|
|
81
|
-
emptyEl.hidden = true;
|
|
82
|
-
clearNode(emptyEl);
|
|
83
|
-
}
|
|
84
|
-
if (listEl) mountViewState(listEl, "loading", "加载失败收件箱…");
|
|
85
|
-
|
|
86
|
-
const snapshot = await fetchJson("/api/snapshot");
|
|
87
|
-
if (!snapshot) {
|
|
88
|
-
if (listEl) mountViewState(listEl, "error", "无法加载 snapshot。");
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
uiState.lastSnapshot = snapshot;
|
|
92
|
-
updateHeaderRefresh(snapshot.generatedAt);
|
|
93
|
-
|
|
94
|
-
const tasks = (snapshot.tasks ?? []).filter(
|
|
95
|
-
(task) =>
|
|
96
|
-
task.status === "failed" ||
|
|
97
|
-
task.status === "blocked" ||
|
|
98
|
-
task.status === "stale" ||
|
|
99
|
-
task.liveness === "stale",
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
if (tasks.length === 0) {
|
|
103
|
-
clearNode(listEl);
|
|
104
|
-
if (emptyEl) {
|
|
105
|
-
emptyEl.hidden = false;
|
|
106
|
-
mountViewState(emptyEl, "empty", "当前没有失败或阻塞的 Task。");
|
|
107
|
-
} else {
|
|
108
|
-
mountViewState(listEl, "empty", "当前没有失败或阻塞的 Task。");
|
|
109
|
-
}
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (emptyEl) emptyEl.hidden = true;
|
|
113
|
-
clearNode(listEl);
|
|
114
|
-
|
|
115
|
-
const refs = (task) => task.artifactRefs ?? {};
|
|
116
|
-
const rows = tasks.map((task) => ({
|
|
117
|
-
className: `row-${task.status}`,
|
|
118
|
-
onClick: task.workerRunId
|
|
119
|
-
? () => navigate(`/run/${encodeURIComponent(task.workerRunId)}`)
|
|
120
|
-
: undefined,
|
|
121
|
-
cells: [
|
|
122
|
-
task.taskId ?? "—",
|
|
123
|
-
task.featureId ?? "—",
|
|
124
|
-
badge(task.status),
|
|
125
|
-
task.failureCategory ?? "—",
|
|
126
|
-
task.recommendedFollowUp ?? "—",
|
|
127
|
-
(() => {
|
|
128
|
-
const links = el("div", "artifact-links");
|
|
129
|
-
const r = refs(task);
|
|
130
|
-
links.appendChild(artifactLink("报告", r.reportMarkdown));
|
|
131
|
-
links.appendChild(document.createTextNode(" "));
|
|
132
|
-
links.appendChild(artifactLink("诊断", r.doctorMarkdown));
|
|
133
|
-
links.appendChild(document.createTextNode(" "));
|
|
134
|
-
links.appendChild(artifactLink("收尾方案", r.closeoutDraft));
|
|
135
|
-
return links;
|
|
136
|
-
})(),
|
|
137
|
-
],
|
|
138
|
-
}));
|
|
139
|
-
listEl.appendChild(
|
|
140
|
-
buildTable(["Task ID", "功能", "状态", "分类", "建议跟进", "产物"], rows),
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
1
|
+
/** Observe UI view module (R5). */
|
|
2
|
+
import {
|
|
3
|
+
UI_TEXT,
|
|
4
|
+
LIVENESS_LABELS,
|
|
5
|
+
ARTIFACT_LABELS,
|
|
6
|
+
ARTIFACT_KEYS,
|
|
7
|
+
STEP_LABELS,
|
|
8
|
+
STEP_ORDER,
|
|
9
|
+
DAG_INSPECTOR_DEFAULT_WIDTH,
|
|
10
|
+
DAG_INSPECTOR_MIN_WIDTH,
|
|
11
|
+
DAG_INSPECTOR_MAX_WIDTH,
|
|
12
|
+
DAG_INSPECTOR_RIGHT_OFFSET,
|
|
13
|
+
DAG_INSPECTOR_VIEWPORT_MARGIN,
|
|
14
|
+
DAG_INSPECTOR_KEYBOARD_STEP,
|
|
15
|
+
TERMINAL_RUN_STATUSES,
|
|
16
|
+
DAG_EFFECTIVE_STATUS_LABELS,
|
|
17
|
+
STATUS_LABELS,
|
|
18
|
+
} from "../constants.js";
|
|
19
|
+
import { clearNode, el, metaGrid, buildTable } from "../dom.js";
|
|
20
|
+
import {
|
|
21
|
+
badge,
|
|
22
|
+
badgeClass,
|
|
23
|
+
statusLabel,
|
|
24
|
+
formatTs,
|
|
25
|
+
formatMs,
|
|
26
|
+
formatDuration,
|
|
27
|
+
formatAgo,
|
|
28
|
+
dagStatusBadge,
|
|
29
|
+
livenessBadge,
|
|
30
|
+
displayDurationMs,
|
|
31
|
+
derivedDurationMs,
|
|
32
|
+
summaryText,
|
|
33
|
+
truncateText,
|
|
34
|
+
repoBaseName,
|
|
35
|
+
parseMarkdownBlocks,
|
|
36
|
+
markdownLinkHref,
|
|
37
|
+
} from "../format.js";
|
|
38
|
+
import { parseRoute, navigate, buildHashPath } from "../router.js";
|
|
39
|
+
import { fetchJson, artifactUrl, parseArtifactPreviewResponse } from "../api.js";
|
|
40
|
+
import {
|
|
41
|
+
objectRouteLink,
|
|
42
|
+
findFeatureInSnapshot,
|
|
43
|
+
featureLookupState,
|
|
44
|
+
buildObjectRelations,
|
|
45
|
+
renderObjectRelationBar,
|
|
46
|
+
} from "../relations.js";
|
|
47
|
+
import { copyText, renderRecommendedCommand } from "../copy.js";
|
|
48
|
+
import {
|
|
49
|
+
isPageVisible,
|
|
50
|
+
detailPollDelay,
|
|
51
|
+
dashboardPollDelay,
|
|
52
|
+
captureDagGraphViewportState,
|
|
53
|
+
updateDagGraphViewportState,
|
|
54
|
+
updateDagTimelineViewportState,
|
|
55
|
+
renderViewState,
|
|
56
|
+
mountViewState,
|
|
57
|
+
} from "../state.js";
|
|
58
|
+
import { uiState } from "../state.js";
|
|
59
|
+
import { sortPoolTasks } from "../format-pool.js";
|
|
60
|
+
import {
|
|
61
|
+
dagMetaVisibility,
|
|
62
|
+
isDagRunActive,
|
|
63
|
+
dashboardVisibleFeatures,
|
|
64
|
+
findDagForRun,
|
|
65
|
+
} from "../dag-model.js";
|
|
66
|
+
import { layoutDag } from "../dag-layout.js";
|
|
67
|
+
import { showView, setBreadcrumb, updateHeaderRefresh } from "../shell-chrome.js";
|
|
68
|
+
import { artifactLink } from "../kpi.js";
|
|
69
|
+
|
|
70
|
+
export async function renderFailures() {
|
|
71
|
+
showView("failures");
|
|
72
|
+
setBreadcrumb([
|
|
73
|
+
{ label: UI_TEXT.dashboard, href: "#/" },
|
|
74
|
+
{ label: UI_TEXT.failures },
|
|
75
|
+
]);
|
|
76
|
+
|
|
77
|
+
const listEl = document.getElementById("failures-list");
|
|
78
|
+
const emptyEl = document.getElementById("failures-empty");
|
|
79
|
+
clearNode(listEl);
|
|
80
|
+
if (emptyEl) {
|
|
81
|
+
emptyEl.hidden = true;
|
|
82
|
+
clearNode(emptyEl);
|
|
83
|
+
}
|
|
84
|
+
if (listEl) mountViewState(listEl, "loading", "加载失败收件箱…");
|
|
85
|
+
|
|
86
|
+
const snapshot = await fetchJson("/api/snapshot");
|
|
87
|
+
if (!snapshot) {
|
|
88
|
+
if (listEl) mountViewState(listEl, "error", "无法加载 snapshot。");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
uiState.lastSnapshot = snapshot;
|
|
92
|
+
updateHeaderRefresh(snapshot.generatedAt);
|
|
93
|
+
|
|
94
|
+
const tasks = (snapshot.tasks ?? []).filter(
|
|
95
|
+
(task) =>
|
|
96
|
+
task.status === "failed" ||
|
|
97
|
+
task.status === "blocked" ||
|
|
98
|
+
task.status === "stale" ||
|
|
99
|
+
task.liveness === "stale",
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (tasks.length === 0) {
|
|
103
|
+
clearNode(listEl);
|
|
104
|
+
if (emptyEl) {
|
|
105
|
+
emptyEl.hidden = false;
|
|
106
|
+
mountViewState(emptyEl, "empty", "当前没有失败或阻塞的 Task。");
|
|
107
|
+
} else {
|
|
108
|
+
mountViewState(listEl, "empty", "当前没有失败或阻塞的 Task。");
|
|
109
|
+
}
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (emptyEl) emptyEl.hidden = true;
|
|
113
|
+
clearNode(listEl);
|
|
114
|
+
|
|
115
|
+
const refs = (task) => task.artifactRefs ?? {};
|
|
116
|
+
const rows = tasks.map((task) => ({
|
|
117
|
+
className: `row-${task.status}`,
|
|
118
|
+
onClick: task.workerRunId
|
|
119
|
+
? () => navigate(`/run/${encodeURIComponent(task.workerRunId)}`)
|
|
120
|
+
: undefined,
|
|
121
|
+
cells: [
|
|
122
|
+
task.taskId ?? "—",
|
|
123
|
+
task.featureId ?? "—",
|
|
124
|
+
badge(task.status),
|
|
125
|
+
task.failureCategory ?? "—",
|
|
126
|
+
task.recommendedFollowUp ?? "—",
|
|
127
|
+
(() => {
|
|
128
|
+
const links = el("div", "artifact-links");
|
|
129
|
+
const r = refs(task);
|
|
130
|
+
links.appendChild(artifactLink("报告", r.reportMarkdown));
|
|
131
|
+
links.appendChild(document.createTextNode(" "));
|
|
132
|
+
links.appendChild(artifactLink("诊断", r.doctorMarkdown));
|
|
133
|
+
links.appendChild(document.createTextNode(" "));
|
|
134
|
+
links.appendChild(artifactLink("收尾方案", r.closeoutDraft));
|
|
135
|
+
return links;
|
|
136
|
+
})(),
|
|
137
|
+
],
|
|
138
|
+
}));
|
|
139
|
+
listEl.appendChild(
|
|
140
|
+
buildTable(["Task ID", "功能", "状态", "分类", "建议跟进", "产物"], rows),
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|