@giamme/forge 0.18.0 → 0.19.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/CHANGELOG.md +33 -0
- package/README.md +1 -0
- package/SKILL.md +16 -2
- package/VERSION +1 -1
- package/docs/artifacts.md +25 -1
- package/docs/commands.md +81 -14
- package/docs/decomposed-runs.md +114 -1
- package/docs/development.md +2 -1
- package/docs/forge-ui.md +84 -15
- package/docs/memory.md +25 -4
- package/docs/models.md +8 -0
- package/docs/reviews.md +122 -0
- package/forge +20 -3
- package/package.json +2 -1
- package/references/dataset.md +20 -1
- package/references/decompose.md +621 -33
- package/references/harnesses.md +18 -3
- package/references/planning.md +43 -14
- package/references/ui.md +53 -6
- package/registry.tsv +8 -3
- package/scripts/forge-brief.py +88 -3
- package/scripts/forge-compare.py +4 -3
- package/scripts/forge-contract.py +202 -27
- package/scripts/forge-control.py +117 -5
- package/scripts/forge-dispatch.sh +34 -5
- package/scripts/forge-group.py +496 -0
- package/scripts/forge-groups.py +89 -0
- package/scripts/forge-handoff.py +1128 -0
- package/scripts/forge-lib-group.sh +641 -0
- package/scripts/forge-lib-plans.sh +339 -3
- package/scripts/forge-lib-task.sh +197 -4
- package/scripts/forge-memory.sh +245 -3
- package/scripts/forge-parallel.sh +715 -34
- package/scripts/forge-planner.py +104 -8
- package/scripts/forge-route.py +190 -12
- package/scripts/forge-runs.py +9 -5
- package/scripts/forge-schedule.py +354 -45
- package/scripts/forge-solo.sh +2 -0
- package/scripts/forge-worktrees.py +243 -0
- package/scripts/forge_brief/__init__.py +294 -50
- package/scripts/forge_brief/answers.py +58 -11
- package/scripts/forge_brief/proposals.py +1630 -0
- package/scripts/forge_dataset/efforts.py +4 -3
- package/scripts/forge_dataset/export.py +24 -12
- package/scripts/forge_dataset/facts.py +5 -3
- package/scripts/forge_dataset/forecast.py +8 -18
- package/scripts/forge_dataset/harvest.py +204 -9
- package/scripts/forge_dataset/history.py +11 -6
- package/scripts/forge_dataset/importer.py +65 -1
- package/scripts/forge_dataset/names.py +66 -0
- package/scripts/forge_dataset/reviewers.py +5 -2
- package/scripts/forge_dataset/risk.py +6 -3
- package/scripts/forge_dataset/routing.py +6 -1
- package/scripts/forge_groups/__init__.py +308 -0
- package/scripts/forge_groups/attribute.py +289 -0
- package/scripts/forge_groups/review.py +286 -0
- package/scripts/forge_owner.py +152 -0
- package/scripts/forge_side/__init__.py +12 -7
- package/ui/docs/api.md +173 -17
- package/ui/forge_ui/control.py +361 -2
- package/ui/forge_ui/executions.py +8 -1
- package/ui/forge_ui/export.py +31 -4
- package/ui/forge_ui/groups.py +264 -0
- package/ui/forge_ui/models.py +70 -8
- package/ui/forge_ui/reader.py +262 -19
- package/ui/forge_ui/server.py +4 -0
- package/ui/forge_ui/static/app.js +93 -13
- package/ui/forge_ui/static/briefview.js +350 -47
- package/ui/forge_ui/static/diffview.js +86 -1
- package/ui/forge_ui/static/groupsview.js +332 -0
- package/ui/forge_ui/static/index.html +1 -0
- package/ui/forge_ui/static/panel.js +127 -7
- package/ui/forge_ui/static/projectsview.js +189 -10
- package/ui/forge_ui/static/runmodel.js +14 -3
- package/ui/forge_ui/static/storageview.js +91 -10
- package/ui/forge_ui/static/style.css +79 -5
- package/ui/forge_ui/static/worktreesview.js +233 -12
- package/ui/forge_ui/storage.py +14 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/* forge-ui groups (#140, #136): the run page's groups block and the group page.
|
|
2
|
+
window.ForgeGroups, and a CommonJS module under node:test.
|
|
3
|
+
Run data only ever enters the page as text. The group page reads
|
|
4
|
+
GET /api/runs/<key>/groups/<gid> and draws it; it never runs a command.
|
|
5
|
+
The pure helpers are tested in ui/tests/js/groupsview.test.js.
|
|
6
|
+
summary(run, ctx) is the run-page block, or null when the run has no groups.
|
|
7
|
+
ctx for the block: { groupHref(id), taskHref(id) }.
|
|
8
|
+
ctx for the page: { key, gid, run, plan, back, taskHref(id), transcriptHref(execution), fetchJSON(path) }. */
|
|
9
|
+
(function (root, factory) {
|
|
10
|
+
'use strict';
|
|
11
|
+
const api = factory(root);
|
|
12
|
+
if (typeof module === 'object' && module.exports) module.exports = api;
|
|
13
|
+
else root.ForgeGroups = api;
|
|
14
|
+
})(typeof self !== 'undefined' ? self : this, function (root) {
|
|
15
|
+
'use strict';
|
|
16
|
+
|
|
17
|
+
const list = v => Array.isArray(v) ? v : [];
|
|
18
|
+
// REVIEWING is a review in flight: the same amber lamp as a running task. The other words match task lamps.
|
|
19
|
+
const GROUP_LAMP = {
|
|
20
|
+
PASS: 'pass', FAIL: 'fail', NEEDS_DECISION: 'needs_decision', REVIEWING: 'running', WAITING: 'waiting',
|
|
21
|
+
UNKNOWN: 'unknown', CONFLICT: 'conflict', INFRA: 'infra', TIMEOUT: 'timeout', ERROR: 'error',
|
|
22
|
+
INVALIDATED: 'invalidated', INTERRUPTED: 'interrupted',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function env() {
|
|
26
|
+
return (typeof globalThis !== 'undefined' && globalThis) || root;
|
|
27
|
+
}
|
|
28
|
+
function doc() {
|
|
29
|
+
const g = env();
|
|
30
|
+
if (g && g.document && g.document.createElement) return g.document;
|
|
31
|
+
if (root && root.document && root.document.createElement) return root.document;
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
function el(tag, text, className) {
|
|
35
|
+
const node = doc().createElement(tag);
|
|
36
|
+
if (text !== undefined && text !== null) node.textContent = String(text);
|
|
37
|
+
if (className) node.className = className;
|
|
38
|
+
return node;
|
|
39
|
+
}
|
|
40
|
+
function runModel() {
|
|
41
|
+
if (root && root.ForgeRunModel) return root.ForgeRunModel;
|
|
42
|
+
const g = env();
|
|
43
|
+
return (g && g.ForgeRunModel) || null;
|
|
44
|
+
}
|
|
45
|
+
function icons() {
|
|
46
|
+
if (root && root.ForgeIcons) return root.ForgeIcons;
|
|
47
|
+
const g = env();
|
|
48
|
+
return (g && g.ForgeIcons) || null;
|
|
49
|
+
}
|
|
50
|
+
// A shell word, copied from the inspector: a path with a space is quoted, a safe path is left as it is.
|
|
51
|
+
function shellWord(s) {
|
|
52
|
+
const text = String(s);
|
|
53
|
+
return /^[\w@%+=:,./-]+$/.test(text) ? text : "'" + text.replace(/'/g, "'\\''") + "'";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function scopeText(review) {
|
|
57
|
+
return review === 'group' ? 'one review' : 'per-task review';
|
|
58
|
+
}
|
|
59
|
+
function lampOf(status) {
|
|
60
|
+
if (status && GROUP_LAMP[status]) return GROUP_LAMP[status];
|
|
61
|
+
const word = String(status || '').toLowerCase();
|
|
62
|
+
return /^[a-z0-9_]+$/.test(word) ? word : 'unknown';
|
|
63
|
+
}
|
|
64
|
+
function statusChip(status) {
|
|
65
|
+
return el('span', status || '—', 'chip st-' + lampOf(status));
|
|
66
|
+
}
|
|
67
|
+
function reviewerNode(qa) {
|
|
68
|
+
if (!qa) return el('span', '—', 'muted');
|
|
69
|
+
const plate = icons();
|
|
70
|
+
if (plate && plate.modelPlate) return plate.modelPlate(qa);
|
|
71
|
+
return el('span', String(qa), 'mono');
|
|
72
|
+
}
|
|
73
|
+
function taskById(run, id) {
|
|
74
|
+
return list(run && run.tasks).find(task => task && task.id === id) || null;
|
|
75
|
+
}
|
|
76
|
+
function memberStatus(run, id) {
|
|
77
|
+
const task = taskById(run, id);
|
|
78
|
+
if (!task) return 'unknown';
|
|
79
|
+
const model = runModel();
|
|
80
|
+
if (model && model.taskStatus) return String(model.taskStatus(task)).toLowerCase();
|
|
81
|
+
return String(task.status || 'pending').toLowerCase();
|
|
82
|
+
}
|
|
83
|
+
function memberChip(id, run, href) {
|
|
84
|
+
const node = href ? el('a', String(id), 'chip st-' + memberStatus(run, id)) : el('span', String(id), 'chip st-' + memberStatus(run, id));
|
|
85
|
+
if (href) node.href = href;
|
|
86
|
+
return node;
|
|
87
|
+
}
|
|
88
|
+
function membersRow(ids, run, hrefFor) {
|
|
89
|
+
const row = el('div', undefined, 'group-members');
|
|
90
|
+
const members = list(ids);
|
|
91
|
+
if (!members.length) { row.append(el('span', 'no members', 'muted')); return row; }
|
|
92
|
+
for (const id of members) row.append(memberChip(id, run, hrefFor ? hrefFor(id) : null));
|
|
93
|
+
return row;
|
|
94
|
+
}
|
|
95
|
+
function implicatedText(ids) {
|
|
96
|
+
const names = list(ids);
|
|
97
|
+
return names.length ? 'implicated ' + names.join(', ') : 'implicated none';
|
|
98
|
+
}
|
|
99
|
+
function rowTitle(group, href) {
|
|
100
|
+
const text = group.title || group.id || '';
|
|
101
|
+
if (group.review === 'group' && href) {
|
|
102
|
+
const link = el('a', text, 'group-title');
|
|
103
|
+
link.href = href;
|
|
104
|
+
return link;
|
|
105
|
+
}
|
|
106
|
+
return el('span', text, 'group-title');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// The run page's groups block. Nothing when the run has no groups, so that page stays as it was.
|
|
110
|
+
function summary(run, ctx) {
|
|
111
|
+
const groups = run && run.groups;
|
|
112
|
+
if (!Array.isArray(groups) || !groups.length) return null;
|
|
113
|
+
ctx = ctx || {};
|
|
114
|
+
const block = el('div', undefined, 'groups-block');
|
|
115
|
+
const head = el('div', undefined, 'module-head');
|
|
116
|
+
head.append(el('h2', 'Groups', 'module-title'), el('span', String(groups.length), 'module-count'));
|
|
117
|
+
const rows = el('div', undefined, 'group-rows');
|
|
118
|
+
for (const group of groups) {
|
|
119
|
+
if (!group || typeof group !== 'object') continue;
|
|
120
|
+
rows.append(groupRow(group, run, ctx));
|
|
121
|
+
}
|
|
122
|
+
block.append(head, rows);
|
|
123
|
+
return block;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function groupRow(group, run, ctx) {
|
|
127
|
+
const row = el('article', undefined, 'group-row');
|
|
128
|
+
row.append(rowTitle(group, ctx.groupHref ? ctx.groupHref(group.id) : null));
|
|
129
|
+
row.append(el('p', group.goal ? String(group.goal) : '(no goal)', 'group-goal'));
|
|
130
|
+
const meta = el('div', undefined, 'group-meta');
|
|
131
|
+
meta.append(el('span', scopeText(group.review), 'group-scope'), reviewerNode(group.qa));
|
|
132
|
+
row.append(meta);
|
|
133
|
+
row.append(membersRow(group.members, run, ctx.taskHref));
|
|
134
|
+
if (group.review === 'group') {
|
|
135
|
+
const state = el('p', undefined, 'group-state');
|
|
136
|
+
if (group.status) state.append(statusChip(group.status));
|
|
137
|
+
else state.append(el('span', 'no status', 'muted'));
|
|
138
|
+
state.append(el('span', group.round == null ? 'round —' : 'round ' + group.round, 'group-round'));
|
|
139
|
+
state.append(el('span', implicatedText(group.implicated), 'group-implicated'));
|
|
140
|
+
row.append(state);
|
|
141
|
+
}
|
|
142
|
+
return row;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// `forge group retry <plan> <gid> --tasks …`. Copyable text: the page does not run it.
|
|
146
|
+
function decisionCommand(group, plan) {
|
|
147
|
+
const path = plan ? shellWord(plan) : '<plan>';
|
|
148
|
+
const gid = shellWord(group && group.id ? group.id : '');
|
|
149
|
+
const members = list(group && group.members).map(id => String(id)).filter(Boolean);
|
|
150
|
+
const tasks = members.length ? shellWord(members.join(',')) : '…';
|
|
151
|
+
return 'forge group retry ' + path + ' ' + gid + ' --tasks ' + tasks;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// The attribution table. A finding is highlighted when it is flagged ambiguous or listed in attribution.ambiguous.
|
|
155
|
+
function findingsTable(attribution) {
|
|
156
|
+
const findings = attribution && Array.isArray(attribution.findings) ? attribution.findings : null;
|
|
157
|
+
if (!findings || !findings.length) return el('p', 'No findings.', 'muted');
|
|
158
|
+
const ambiguous = new Set(list(attribution.ambiguous));
|
|
159
|
+
const table = el('table', undefined, 'group-findings');
|
|
160
|
+
const headRow = el('tr');
|
|
161
|
+
for (const label of ['Severity', 'Status', 'File', 'Tasks', 'Blocking', 'Ambiguous']) headRow.append(el('th', label));
|
|
162
|
+
const head = el('thead');
|
|
163
|
+
head.append(headRow);
|
|
164
|
+
const body = el('tbody');
|
|
165
|
+
for (const finding of findings) {
|
|
166
|
+
if (!finding || typeof finding !== 'object') continue;
|
|
167
|
+
const flagged = finding.ambiguous === true || ambiguous.has(finding.n);
|
|
168
|
+
const tr = el('tr', undefined, flagged ? 'group-ambiguous' : '');
|
|
169
|
+
const file = finding.file ? (finding.line == null ? String(finding.file) : String(finding.file) + ':' + finding.line) : '—';
|
|
170
|
+
const tasks = list(finding.tasks);
|
|
171
|
+
const cells = [
|
|
172
|
+
[finding.severity || '—', ''],
|
|
173
|
+
[finding.status || '—', ''],
|
|
174
|
+
[file, 'mono'],
|
|
175
|
+
[tasks.length ? tasks.join(', ') : '—', ''],
|
|
176
|
+
[finding.blocking ? 'yes' : 'no', finding.blocking ? 'group-blocking' : ''],
|
|
177
|
+
[flagged ? 'yes' : 'no', ''],
|
|
178
|
+
];
|
|
179
|
+
for (const [text, className] of cells) tr.append(el('td', text, className || undefined));
|
|
180
|
+
body.append(tr);
|
|
181
|
+
}
|
|
182
|
+
table.append(head, body);
|
|
183
|
+
return table;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function decisionSection(group, plan) {
|
|
187
|
+
if (!group || group.status !== 'NEEDS_DECISION') return null;
|
|
188
|
+
const section = el('section', undefined, 'group-section group-decision');
|
|
189
|
+
section.append(el('h2', 'Decision', 'plate'));
|
|
190
|
+
section.append(el('p', group.decision ? String(group.decision) : 'No decision recorded.', group.decision ? '' : 'muted'));
|
|
191
|
+
section.append(el('pre', decisionCommand(group, plan), 'group-cmd'));
|
|
192
|
+
return section;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function roundsSection(group) {
|
|
196
|
+
const section = el('section', undefined, 'group-section group-rounds');
|
|
197
|
+
section.append(el('h2', 'Rounds', 'plate'));
|
|
198
|
+
const rounds = list(group.rounds);
|
|
199
|
+
if (!rounds.length) { section.append(el('p', 'No rounds.', 'muted')); return section; }
|
|
200
|
+
const byRound = new Map(list(group.members_by_round).filter(bucket => bucket && typeof bucket === 'object').map(bucket => [bucket.round, list(bucket.members)]));
|
|
201
|
+
for (const round of rounds) {
|
|
202
|
+
if (!round || typeof round !== 'object') continue;
|
|
203
|
+
const article = el('article', undefined, 'group-round-row');
|
|
204
|
+
article.append(el('h3', 'Round ' + round.round));
|
|
205
|
+
const meta = el('p', undefined, 'group-meta');
|
|
206
|
+
if (round.status) meta.append(statusChip(round.status));
|
|
207
|
+
meta.append(reviewerNode(round.reviewer));
|
|
208
|
+
meta.append(el('span', implicatedText(round.implicated), 'group-implicated'));
|
|
209
|
+
if (round.epoch != null && Number.isFinite(Number(round.epoch))) {
|
|
210
|
+
const when = new Date(Number(round.epoch) * 1000);
|
|
211
|
+
if (!Number.isNaN(when.getTime())) meta.append(el('span', when.toLocaleString(), 'muted'));
|
|
212
|
+
}
|
|
213
|
+
article.append(meta);
|
|
214
|
+
const members = byRound.get(round.round) || [];
|
|
215
|
+
if (members.length) {
|
|
216
|
+
const line = el('p', undefined, 'group-round-members mono');
|
|
217
|
+
line.textContent = members.map(member => {
|
|
218
|
+
if (!member || typeof member !== 'object') return '';
|
|
219
|
+
const attempt = member.attempt == null ? '' : ' attempt ' + member.attempt;
|
|
220
|
+
const commit = member.commit ? ' ' + member.commit : '';
|
|
221
|
+
return (member.task || '—') + commit + attempt;
|
|
222
|
+
}).filter(Boolean).join(', ');
|
|
223
|
+
article.append(line);
|
|
224
|
+
}
|
|
225
|
+
section.append(article);
|
|
226
|
+
}
|
|
227
|
+
return section;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function textSection(title, value, empty, className) {
|
|
231
|
+
const section = el('section', undefined, 'group-section ' + className);
|
|
232
|
+
section.append(el('h2', title, 'plate'));
|
|
233
|
+
if (value == null || value === '') section.append(el('p', empty, 'muted'));
|
|
234
|
+
else section.append(el('pre', String(value)));
|
|
235
|
+
return section;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function transcriptSection(group, ctx) {
|
|
239
|
+
const section = el('section', undefined, 'group-section group-transcript');
|
|
240
|
+
section.append(el('h2', 'Review transcript', 'plate'));
|
|
241
|
+
const execution = group && group.execution;
|
|
242
|
+
const href = execution && execution.id && ctx.transcriptHref ? ctx.transcriptHref(execution) : null;
|
|
243
|
+
if (!href) { section.append(el('p', 'No review transcript.', 'muted')); return section; }
|
|
244
|
+
const link = el('a', 'Review transcript', 'diff-link');
|
|
245
|
+
link.href = href;
|
|
246
|
+
section.append(link);
|
|
247
|
+
return section;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function pageHeader(group, ctx) {
|
|
251
|
+
const head = el('header', undefined, 'group-head');
|
|
252
|
+
const back = el('a', 'Back to the run', 'group-back');
|
|
253
|
+
back.href = ctx.back || '#/';
|
|
254
|
+
const title = el('h1', group.title || group.id || '', 'group-title');
|
|
255
|
+
head.append(back, title, el('p', group.goal ? String(group.goal) : '(no goal)', 'group-goal'));
|
|
256
|
+
const meta = el('div', undefined, 'group-meta');
|
|
257
|
+
meta.append(el('span', scopeText(group.review), 'group-scope'), reviewerNode(group.qa));
|
|
258
|
+
if (group.review === 'group') {
|
|
259
|
+
if (group.status) meta.append(statusChip(group.status));
|
|
260
|
+
else meta.append(el('span', 'no status', 'muted'));
|
|
261
|
+
meta.append(el('span', group.round == null ? 'round —' : 'round ' + group.round, 'group-round'));
|
|
262
|
+
meta.append(el('span', implicatedText(group.implicated), 'group-implicated'));
|
|
263
|
+
}
|
|
264
|
+
head.append(meta, membersRow(group.members, ctx.run, ctx.taskHref));
|
|
265
|
+
return head;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// The group page, from one group payload. Synchronous, so a test can read it without a fetch.
|
|
269
|
+
function pageView(group, ctx) {
|
|
270
|
+
ctx = ctx || {};
|
|
271
|
+
const page = el('div', undefined, 'group-page');
|
|
272
|
+
if (!group || typeof group !== 'object') {
|
|
273
|
+
page.append(el('p', 'This group is not in the run.', 'empty'));
|
|
274
|
+
return page;
|
|
275
|
+
}
|
|
276
|
+
page.append(pageHeader(group, ctx));
|
|
277
|
+
const decision = decisionSection(group, ctx.plan);
|
|
278
|
+
if (decision) page.append(decision);
|
|
279
|
+
const findings = el('section', undefined, 'group-section group-findings-section');
|
|
280
|
+
findings.append(el('h2', 'Findings', 'plate'));
|
|
281
|
+
// attribution.json is kept across rounds (the next prompt quotes it): a round that left no review has
|
|
282
|
+
// none of its own, so the table is an earlier round's and says so.
|
|
283
|
+
const attribution = group.attribution;
|
|
284
|
+
if (attribution && Number.isInteger(attribution.round) && Number.isInteger(group.round) && attribution.round !== group.round) {
|
|
285
|
+
findings.append(el('p', 'From round ' + attribution.round + ': round ' + group.round + ' has no attributed findings.', 'muted group-stale'));
|
|
286
|
+
}
|
|
287
|
+
findings.append(findingsTable(attribution));
|
|
288
|
+
page.append(findings, roundsSection(group));
|
|
289
|
+
page.append(textSection('Known issues', group.known_issues, 'None.', 'group-known'));
|
|
290
|
+
page.append(textSection('Review', group.qa_last, 'No review yet.', 'group-review'));
|
|
291
|
+
page.append(transcriptSection(group, ctx));
|
|
292
|
+
return page;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// A task's `group <id>` chip. Null when the task is in no group.
|
|
296
|
+
function taskChip(gid, href) {
|
|
297
|
+
if (!gid) return null;
|
|
298
|
+
const link = el('a', 'group ' + gid, 'group-chip');
|
|
299
|
+
if (href) link.href = href;
|
|
300
|
+
return link;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Fetch the group and draw it. A poll that still has the same run skips the fetch.
|
|
304
|
+
// A newer navigation (host._groupsSeq) drops a response that arrived late.
|
|
305
|
+
function render(host, ctx) {
|
|
306
|
+
ctx = ctx || {};
|
|
307
|
+
if (!ctx.run) {
|
|
308
|
+
host.replaceChildren(el('p', 'Loading the group…', 'empty'));
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const token = String(ctx.key) + '\n' + String(ctx.gid) + '\n' + String(ctx.run.updated);
|
|
312
|
+
if (host._groupsToken === token && host.childElementCount) return;
|
|
313
|
+
const seq = (host._groupsSeq = (host._groupsSeq || 0) + 1);
|
|
314
|
+
const same = host.dataset && host.dataset.group === String(ctx.gid) && host.dataset.run === String(ctx.key) && host._groupsData;
|
|
315
|
+
if (!same) host.replaceChildren(el('p', 'Loading the group…', 'empty'));
|
|
316
|
+
const path = '/api/runs/' + encodeURIComponent(ctx.key) + '/groups/' + encodeURIComponent(ctx.gid);
|
|
317
|
+
Promise.resolve().then(() => ctx.fetchJSON(path)).then(data => {
|
|
318
|
+
if (host.isConnected === false || host._groupsSeq !== seq) return;
|
|
319
|
+
host._groupsToken = token;
|
|
320
|
+
host._groupsData = data;
|
|
321
|
+
if (host.dataset) { host.dataset.group = String(ctx.gid); host.dataset.run = String(ctx.key); }
|
|
322
|
+
host.replaceChildren(pageView(data, ctx));
|
|
323
|
+
}, error => {
|
|
324
|
+
if (host.isConnected === false || host._groupsSeq !== seq) return;
|
|
325
|
+
host._groupsToken = '';
|
|
326
|
+
const missing = error && error.status === 404;
|
|
327
|
+
host.replaceChildren(el('p', missing ? 'This group is not in the run.' : 'Could not load this group.', 'empty'));
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return { summary, findingsTable, decisionCommand, taskChip, pageView, render, scopeText };
|
|
332
|
+
});
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
<script src="verifyview.js" defer></script>
|
|
29
29
|
<script src="checksview.js" defer></script>
|
|
30
30
|
<script src="briefview.js" defer></script>
|
|
31
|
+
<script src="groupsview.js" defer></script>
|
|
31
32
|
<script src="panel.js" defer></script>
|
|
32
33
|
<script src="diffview.js" defer></script>
|
|
33
34
|
<script src="convo.js" defer></script>
|
|
@@ -12,7 +12,7 @@ window.ForgePanel = (() => {
|
|
|
12
12
|
const num = v => typeof v === 'number' && Number.isFinite(v) ? v : null;
|
|
13
13
|
const display = v => v === null || v === undefined || v === '' ? '—' : typeof v === 'object' ? JSON.stringify(v, null, 2) : String(v);
|
|
14
14
|
const STATUSES = new Set(['merged', 'pass', 'running', 'pending', 'fail', 'error', 'infra', 'timeout', 'unknown', 'invalidated', 'blocked',
|
|
15
|
-
'interrupted', 'nochanges', 'conflict', 'accepted', 'none', 'outdated', 'needs_input', 'needs_decision', 'waiting']);
|
|
15
|
+
'interrupted', 'nochanges', 'conflict', 'accepted', 'none', 'outdated', 'needs_input', 'needs_decision', 'waiting', 'implemented']);
|
|
16
16
|
const cache = new Map(); // path → {data, error, at}
|
|
17
17
|
const shownText = new Map(); // task id → which header text is open (prompt, approach, criteria)
|
|
18
18
|
function el(tag, text, className) {
|
|
@@ -89,8 +89,9 @@ window.ForgePanel = (() => {
|
|
|
89
89
|
const s = section(host, 'Controls');
|
|
90
90
|
muted(s, 'Read-only: this page cannot change the run.');
|
|
91
91
|
}
|
|
92
|
-
// A task that stopped NEEDS_INPUT: the question it asked, and the command that answers it.
|
|
93
|
-
//
|
|
92
|
+
// A task that stopped NEEDS_INPUT: the question it asked, and the command that answers it. The copy stays in
|
|
93
|
+
// every mode. When controls are on, a plan (not a solo run) can send the answer from here: that post is not
|
|
94
|
+
// destructive, so it needs no confirm. A solo run still shows only the question.
|
|
94
95
|
const shellWord = s => /^[\w@%+=:,./-]+$/.test(s) ? s : "'" + String(s).replace(/'/g, "'\\''") + "'";
|
|
95
96
|
// An INFRA task: why its dispatch stopped (the cause, the stage, the model it ran on), when its limit resets, and
|
|
96
97
|
// whether the user must act: the reader's answer from forge's cause table (after the run too), else a live
|
|
@@ -118,6 +119,94 @@ window.ForgePanel = (() => {
|
|
|
118
119
|
const line = el('div', undefined, 'waiting-cmd');
|
|
119
120
|
line.append(el('pre', text, 'cmd'), copy);
|
|
120
121
|
s.append(line);
|
|
122
|
+
const U = window.ForgeUI;
|
|
123
|
+
if (!U || !U.controlsEnabled) return;
|
|
124
|
+
// In the tree before controlsEnabled answers, with data-hold. A poll rebuilds this inspector
|
|
125
|
+
// through controls.js hold(), which only puts back a [data-hold][data-editing] node that the
|
|
126
|
+
// new tree already contains. Appending the box from the promise leaves the draft behind.
|
|
127
|
+
const box = answerField(ctx, task, U);
|
|
128
|
+
s.append(box);
|
|
129
|
+
U.controlsEnabled().then(on => {
|
|
130
|
+
if (!s.isConnected || on) return;
|
|
131
|
+
dropHold(s, 'answer:');
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// The draft of one waiting task. data-editing is set while the field is in use, so hold() keeps
|
|
135
|
+
// this node (its text and its focus) instead of the empty one the next draw builds.
|
|
136
|
+
function answerField(ctx, task, U) {
|
|
137
|
+
const run = ctx.run || {};
|
|
138
|
+
const box = el('div', undefined, 'waiting-cmd');
|
|
139
|
+
box.dataset.hold = 'answer:' + run.key + ':' + task.id;
|
|
140
|
+
const field = el('textarea');
|
|
141
|
+
field.setAttribute('aria-label', 'Answer');
|
|
142
|
+
field.rows = 3;
|
|
143
|
+
field.maxLength = 8000;
|
|
144
|
+
field.autocomplete = 'off';
|
|
145
|
+
const send = el('button', 'Send answer'); send.type = 'button';
|
|
146
|
+
const msgs = el('div');
|
|
147
|
+
const mark = () => { box.dataset.editing = '1'; };
|
|
148
|
+
field.addEventListener('focus', mark);
|
|
149
|
+
field.addEventListener('input', mark);
|
|
150
|
+
field.addEventListener('blur', () => {
|
|
151
|
+
if (box.dataset.busy) return;
|
|
152
|
+
if (!String(field.value || '').trim()) delete box.dataset.editing;
|
|
153
|
+
});
|
|
154
|
+
send.addEventListener('click', () => { sendWaitingAnswer(box, field, send, msgs, ctx, task, U); });
|
|
155
|
+
box.append(field, send, msgs);
|
|
156
|
+
return box;
|
|
157
|
+
}
|
|
158
|
+
function dropHold(root, prefix) {
|
|
159
|
+
const pending = [root];
|
|
160
|
+
while (pending.length) {
|
|
161
|
+
const node = pending.pop();
|
|
162
|
+
for (const child of [...(node.children || [])]) {
|
|
163
|
+
if (child.dataset && String(child.dataset.hold || '').startsWith(prefix)) child.remove();
|
|
164
|
+
else pending.push(child);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// What the answer endpoint means for the page. `live` is the scheduler's word; anything else is the error
|
|
169
|
+
// sentence outcomeText already uses for every other write.
|
|
170
|
+
function answerLive(answer) {
|
|
171
|
+
if (!answer || typeof answer !== 'object' || answer.ok === false) return null;
|
|
172
|
+
const data = answer.data && typeof answer.data === 'object' ? answer.data : answer;
|
|
173
|
+
if (data.live === true) return true;
|
|
174
|
+
if (data.live === false) return false;
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
function answerOutcome(answer) {
|
|
178
|
+
const live = answerLive(answer);
|
|
179
|
+
if (live === true) return 'Queued: the running scheduler resumes the task';
|
|
180
|
+
if (live === false) return 'Prepared: the next run dispatches the task';
|
|
181
|
+
const say = window.ForgeUI && window.ForgeUI.outcomeText;
|
|
182
|
+
if (typeof say === 'function') return say(answer).text;
|
|
183
|
+
const r = answer || {};
|
|
184
|
+
return r.detail || r.error || 'failed';
|
|
185
|
+
}
|
|
186
|
+
async function sendWaitingAnswer(box, field, send, msgs, ctx, task, U) {
|
|
187
|
+
if (box.dataset.busy) return;
|
|
188
|
+
const text = String(field.value || '').trim();
|
|
189
|
+
if (!text) {
|
|
190
|
+
if (U && U.outcome) U.outcome(msgs, { ok: false, status: 400, error: 'invalid', detail: 'the answer is empty' });
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
box.dataset.editing = '1';
|
|
194
|
+
box.dataset.busy = '1';
|
|
195
|
+
send.disabled = true;
|
|
196
|
+
const run = ctx.run || {};
|
|
197
|
+
const path = '/api/runs/' + encodeURIComponent(run.key) + '/tasks/' + encodeURIComponent(task.id) + '/answer';
|
|
198
|
+
let res = { ok: false, error: 'unavailable', detail: 'this page cannot send' };
|
|
199
|
+
try {
|
|
200
|
+
if (U && U.post) res = await U.post(path, { text });
|
|
201
|
+
} catch (_) {
|
|
202
|
+
res = { ok: false, error: 'failed', detail: 'could not send' };
|
|
203
|
+
}
|
|
204
|
+
if (!box.isConnected) return;
|
|
205
|
+
delete box.dataset.busy;
|
|
206
|
+
send.disabled = false;
|
|
207
|
+
if (!U || !U.outcome) return;
|
|
208
|
+
if (res && res.ok) U.outcome(msgs, res, answerOutcome(res));
|
|
209
|
+
else U.outcome(msgs, res);
|
|
121
210
|
}
|
|
122
211
|
// A task that stopped NEEDS_DECISION: why the retry policy stopped it, its attempts against the cap, the ledger of its
|
|
123
212
|
// reviews, and the decision text, which holds the commands to run. forge-ui shows the commands and never runs them.
|
|
@@ -364,6 +453,26 @@ window.ForgePanel = (() => {
|
|
|
364
453
|
if (!solo) details(host, 'Waves', list(run.waves).map((ids, i) => `${i + 1}: ${list(ids).join(', ')}`).join('\n') || '—', 'waves');
|
|
365
454
|
if (run.verification && run.verification.log_tail != null) details(host, 'Verification output', run.verification.log_tail, 'verification-output');
|
|
366
455
|
}
|
|
456
|
+
// `after` is the predecessor; `followed_by` the plans that name this run. Run ids read as the
|
|
457
|
+
// other ids on the page (mono). The hash is the other run's page, the same shape app.js uses.
|
|
458
|
+
function chainRows(run) {
|
|
459
|
+
const rows = [];
|
|
460
|
+
const prev = run.after;
|
|
461
|
+
if (prev && typeof prev === 'object') {
|
|
462
|
+
const label = prev.run_id || prev.key;
|
|
463
|
+
if (label) rows.push(['After', link(label, '#/runs/' + encodeURIComponent(prev.key)), true]);
|
|
464
|
+
}
|
|
465
|
+
const next = list(run.followed_by).filter(item => item && (item.run_id || item.key));
|
|
466
|
+
if (next.length) {
|
|
467
|
+
const span = el('span');
|
|
468
|
+
next.forEach((item, i) => {
|
|
469
|
+
if (i) span.append(document.createTextNode(', '));
|
|
470
|
+
span.append(link(item.run_id || item.key, '#/runs/' + encodeURIComponent(item.key)));
|
|
471
|
+
});
|
|
472
|
+
rows.push(['Followed by', span, true]);
|
|
473
|
+
}
|
|
474
|
+
return rows;
|
|
475
|
+
}
|
|
367
476
|
function runView(host, ctx) {
|
|
368
477
|
const run = ctx.run, now = ctx.now;
|
|
369
478
|
const tr = RM.timeRange(run, now);
|
|
@@ -385,10 +494,13 @@ window.ForgePanel = (() => {
|
|
|
385
494
|
}
|
|
386
495
|
const f = section(host, 'Finish');
|
|
387
496
|
const F = RM.finishState(run);
|
|
497
|
+
// A chained plan: the one it starts from, and the ones that start from it. Each links to that
|
|
498
|
+
// run's page. A run in neither chain keeps this block as it was.
|
|
499
|
+
const chain = chainRows(run);
|
|
388
500
|
if (run.kind === 'solo') {
|
|
389
501
|
const soloTask = list(run.tasks)[0];
|
|
390
502
|
const verdict = soloTask ? RM.taskVerdict(soloTask) : { text: null, status: 'unknown' };
|
|
391
|
-
fields(f, [['Verdict', chip(verdict.text, verdict.status)]]);
|
|
503
|
+
fields(f, [['Verdict', chip(verdict.text, verdict.status)], ...chain]);
|
|
392
504
|
}
|
|
393
505
|
else {
|
|
394
506
|
const finalSel = { kind: 'final' }, openFinal = () => ctx.onSelect(finalSel);
|
|
@@ -400,7 +512,7 @@ window.ForgePanel = (() => {
|
|
|
400
512
|
} else finalValue = link(F.final.status === 'NONE' ? 'not requested' : F.final.status, ctx.hash(finalSel), openFinal);
|
|
401
513
|
fields(f, [['Integration', link(`${F.integration.merged}/${F.integration.total} merged`, ctx.hash({ kind: 'integration' }), () => ctx.onSelect({ kind: 'integration' }))],
|
|
402
514
|
['Verification', link(F.verification.status, ctx.hash({ kind: 'verification' }), () => ctx.onSelect({ kind: 'verification' }))],
|
|
403
|
-
['Final review', finalValue]]);
|
|
515
|
+
['Final review', finalValue], ...chain]);
|
|
404
516
|
const attribution = RM.attributionLine(run.attribution);
|
|
405
517
|
if (attribution) f.append(el('p', attribution, 'warn'));
|
|
406
518
|
if (F.final.status === 'OUTDATED') muted(f, RM.reviewSinceLine(F.final));
|
|
@@ -703,10 +815,18 @@ window.ForgePanel = (() => {
|
|
|
703
815
|
const chips = el('div', undefined, 'chips');
|
|
704
816
|
if (RM.taskStatus(task) === 'ACCEPTED') chips.append(acceptedChip(task));
|
|
705
817
|
else {
|
|
706
|
-
chips.append(
|
|
818
|
+
chips.append(chip(RM.statusText(task), String(RM.taskStatus(task)).toLowerCase()));
|
|
707
819
|
if (task.accepted === true) chips.append(acceptedChip(task));
|
|
708
820
|
else if (task.verdict) chips.append(chip('review ' + task.verdict, task.verdict.toLowerCase()));
|
|
709
821
|
}
|
|
822
|
+
if (task.group && window.ForgeGroups) {
|
|
823
|
+
const group = window.ForgeGroups.taskChip(task.group, ctx.hash({ kind: 'group', id: task.group }));
|
|
824
|
+
if (group) chips.append(group);
|
|
825
|
+
}
|
|
826
|
+
if (window.ForgeBrief && window.ForgeBrief.affectedBadge) {
|
|
827
|
+
const affected = window.ForgeBrief.affectedBadge(task);
|
|
828
|
+
if (affected) chips.append(affected);
|
|
829
|
+
}
|
|
710
830
|
if (task.explored) chips.append(el('span', '* explored', 'tag'));
|
|
711
831
|
head.append(chips);
|
|
712
832
|
const dl = diffLink(ctx, solo ? 'View the diff →' : 'View its diff, findings pinned to their lines →', { kind: 'task', task: task.id, source: 'current' }); if (dl) head.append(dl);
|
|
@@ -1123,6 +1243,6 @@ window.ForgePanel = (() => {
|
|
|
1123
1243
|
if (sel.kind === 'fractal') return fractalNodeView(host, ctx, sel);
|
|
1124
1244
|
return runView(host, ctx);
|
|
1125
1245
|
}
|
|
1126
|
-
return { render, cache, trailLine, reasonText, linkModel, headerActions, summaryBank, changeSummaries };
|
|
1246
|
+
return { render, cache, trailLine, reasonText, linkModel, headerActions, summaryBank, changeSummaries, answerOutcome };
|
|
1127
1247
|
})();
|
|
1128
1248
|
if (typeof module === 'object' && module.exports) module.exports = window.ForgePanel;
|