@giamme/forge 0.18.0 → 0.20.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 +49 -0
- package/README.md +1 -0
- package/SKILL.md +19 -2
- package/VERSION +1 -1
- package/docs/artifacts.md +25 -1
- package/docs/commands.md +217 -18
- package/docs/decomposed-runs.md +114 -1
- package/docs/development.md +2 -1
- package/docs/forge-ui.md +138 -18
- package/docs/memory.md +25 -4
- package/docs/models.md +8 -0
- package/docs/reviews.md +122 -0
- package/forge +26 -3
- package/package.json +2 -1
- package/references/dataset.md +20 -1
- package/references/decompose.md +641 -41
- package/references/harnesses.md +18 -3
- package/references/memory.md +30 -5
- 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-findings.py +675 -0
- package/scripts/forge-group.py +496 -0
- package/scripts/forge-groups.py +89 -0
- package/scripts/forge-handoff.py +1128 -0
- package/scripts/forge-issues.py +228 -97
- 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 +711 -17
- package/scripts/forge-parallel.sh +721 -38
- 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 +417 -52
- package/scripts/forge-solo.sh +2 -0
- package/scripts/forge-sweep.py +199 -44
- 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_findings/__init__.py +17 -0
- package/scripts/forge_findings/apply.py +441 -0
- package/scripts/forge_findings/status.py +43 -0
- package/scripts/forge_findings/store.py +583 -0
- package/scripts/forge_findings/tags.py +53 -0
- package/scripts/forge_findings/triage.py +603 -0
- 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_identity.py +327 -0
- package/scripts/forge_memory_list.py +7 -3
- package/scripts/forge_owner.py +152 -0
- package/scripts/forge_side/__init__.py +228 -38
- package/ui/docs/api.md +303 -29
- package/ui/forge_ui/control.py +1018 -6
- 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/projects.py +209 -22
- 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/findingsactions.js +201 -0
- package/ui/forge_ui/static/groupsview.js +332 -0
- package/ui/forge_ui/static/index.html +3 -0
- package/ui/forge_ui/static/panel.js +127 -7
- package/ui/forge_ui/static/projectsview.js +764 -30
- 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 +138 -5
- package/ui/forge_ui/static/triageview.js +423 -0
- package/ui/forge_ui/static/worktreesview.js +233 -12
- package/ui/forge_ui/storage.py +14 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/* forge-ui finding actions (#161): the pure logic behind the Findings tab's write controls (window.ForgeFindingsActions,
|
|
2
|
+
and a CommonJS module under node:test). No DOM. Nothing is decided here that the server does not decide again: these
|
|
3
|
+
functions only build the request body of each op (or say why it cannot be built), build the `forge findings …` line
|
|
4
|
+
a read-only page offers to copy, and say what a selection allows.
|
|
5
|
+
A row is the Projects answer's finding row: `record_fp` is the record key (null when the row cannot be acted on),
|
|
6
|
+
`status` one of STATUSES, `tags` the effective tags, `record.tags` the stored ones, `fp` and `run` what `forge issues`
|
|
7
|
+
files by. Tested in ui/tests/js/findingsactions.test.js. */
|
|
8
|
+
(function (root, factory) {
|
|
9
|
+
'use strict';
|
|
10
|
+
const api = factory(root);
|
|
11
|
+
if (typeof module === 'object' && module.exports) module.exports = api;
|
|
12
|
+
else root.ForgeFindingsActions = api;
|
|
13
|
+
})(typeof self !== 'undefined' ? self : this, function () {
|
|
14
|
+
'use strict';
|
|
15
|
+
|
|
16
|
+
const list = v => Array.isArray(v) ? v : [];
|
|
17
|
+
const MAX_FPS = 200, MAX_FILE = 25, MAX_TAGS = 8, MAX_NOTE = 2000, MAX_REASON = 500, MAX_EDIT_TEXT = 4000, MAX_TITLE = 200, MAX_BODY = 20000;
|
|
18
|
+
const SEVERITIES = ['P0', 'P1', 'P2', 'P3'];
|
|
19
|
+
const OPEN_STATUSES = ['open', 'to-file'];
|
|
20
|
+
const OPS = ['fix', 'dismiss', 'reopen', 'to-file', 'dup', 'tag', 'note', 'edit'];
|
|
21
|
+
const SINGLE = ['dup', 'note', 'edit'];
|
|
22
|
+
const TAG_RE = /^[a-z][a-z0-9-]{0,23}$/, FP_RE = /^[0-9a-f]{12}$/, COMMIT_RE = /^[0-9a-f]{7,40}$/;
|
|
23
|
+
const CONTROL_RE = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/; // newline and tab are allowed, as the routes allow them
|
|
24
|
+
const PAST = { fix: 'marked fixed', dismiss: 'dismissed', reopen: 'reopened', 'to-file': 'marked to file', dup: 'marked duplicate', tag: 'tagged', note: 'noted', edit: 'edited' };
|
|
25
|
+
|
|
26
|
+
const str = v => typeof v === 'string' ? v : v == null ? '' : String(v);
|
|
27
|
+
const fail = error => ({ error });
|
|
28
|
+
|
|
29
|
+
/* ---------- rows ---------- */
|
|
30
|
+
const selectable = row => !!(row && typeof row.record_fp === 'string' && row.record_fp);
|
|
31
|
+
const isOpen = row => !!row && OPEN_STATUSES.includes(row.status);
|
|
32
|
+
// The tags a person stored on this row. With none stored the row shows the defaults forge derives from the path.
|
|
33
|
+
const storedTags = row => list(row && row.record && row.record.tags).filter(t => typeof t === 'string');
|
|
34
|
+
const tagsOf = row => list(row && row.tags).filter(t => typeof t === 'string');
|
|
35
|
+
const derivedTags = row => !!row && storedTags(row).length === 0;
|
|
36
|
+
function tagsIn(rows) { return Array.from(new Set(list(rows).flatMap(tagsOf))).sort(); }
|
|
37
|
+
function filterByTag(rows, tag) { return tag ? list(rows).filter(r => tagsOf(r).includes(tag)) : list(rows); }
|
|
38
|
+
|
|
39
|
+
/* ---------- the selection ---------- */
|
|
40
|
+
// The selected rows among `rows` (the rows the filters show), in row order, once each. `picked` is a Set of record_fp.
|
|
41
|
+
function selectedRows(rows, picked) {
|
|
42
|
+
const want = picked instanceof Set ? picked : new Set(list(picked)), seen = new Set(), out = [];
|
|
43
|
+
for (const row of list(rows)) {
|
|
44
|
+
if (!selectable(row) || !want.has(row.record_fp) || seen.has(row.record_fp)) continue;
|
|
45
|
+
seen.add(row.record_fp); out.push(row);
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
const fpsOf = rows => list(rows).filter(selectable).map(r => r.record_fp);
|
|
50
|
+
// Which actions a selection (rows already narrowed to the shown ones) allows. `why` says what holds them all back.
|
|
51
|
+
function allowed(selected) {
|
|
52
|
+
const rows = list(selected).filter(selectable), n = rows.length, many = n >= 1 && n <= MAX_FPS, one = n === 1;
|
|
53
|
+
const why = n > MAX_FPS ? `${n} selected: at most ${MAX_FPS} per action` : '';
|
|
54
|
+
return { count: n, why, fix: many, dismiss: many, reopen: many && rows.some(r => r.status !== 'open'), 'to-file': many, tag: many,
|
|
55
|
+
dup: one, note: one, edit: one, file: fileableFps(rows).length > 0 && fileRun(rows) !== null };
|
|
56
|
+
}
|
|
57
|
+
// The fingerprints "File selected" hands to forge issues: rows `forge issues` can file, still open, at most 25.
|
|
58
|
+
// `record_fp`, not `fp`: `fp` is the slug-less key rows collapse by, while `forge issues --only` matches the
|
|
59
|
+
// full fingerprint (with the repository slug), which is what `record_fp` holds.
|
|
60
|
+
function fileableFps(rows) {
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const r of list(rows)) {
|
|
63
|
+
if (out.length >= MAX_FILE) break;
|
|
64
|
+
if (r && r.fileable && isOpen(r) && selectable(r) && !out.includes(r.record_fp)) out.push(r.record_fp);
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
// The run `forge issues` reads for the filing: the first fileable selected row's.
|
|
69
|
+
function fileRun(rows) {
|
|
70
|
+
const row = list(rows).find(r => r && r.fileable && isOpen(r) && selectable(r) && r.run);
|
|
71
|
+
return row ? row.run : null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* ---------- tags ---------- */
|
|
75
|
+
// "a, b" → {tags, error}. Commas and spaces separate; each tag is a lowercase letter then up to 23 letters, digits or dashes.
|
|
76
|
+
function parseTags(text) {
|
|
77
|
+
const tags = Array.from(new Set(str(text).split(/[\s,]+/).filter(Boolean)));
|
|
78
|
+
if (!tags.length) return { tags: [], error: 'give at least one tag' };
|
|
79
|
+
if (tags.length > MAX_TAGS) return { tags: [], error: `at most ${MAX_TAGS} tags` };
|
|
80
|
+
const bad = tags.find(t => !TAG_RE.test(t));
|
|
81
|
+
if (bad !== undefined) return { tags: [], error: `"${bad}" is not a tag: a lowercase letter, then lowercase letters, digits or dashes, at most 24 characters` };
|
|
82
|
+
return { tags, error: null };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* ---------- bodies ---------- */
|
|
86
|
+
function checkText(value, name, limit, required) {
|
|
87
|
+
const text = str(value).trim();
|
|
88
|
+
if (!text) return required ? fail(`${name} is required`) : { text: null };
|
|
89
|
+
if (text.length > limit) return fail(`${name} is at most ${limit} characters`);
|
|
90
|
+
if (CONTROL_RE.test(text)) return fail(`${name} cannot hold control characters`);
|
|
91
|
+
return { text };
|
|
92
|
+
}
|
|
93
|
+
// The POST body of one op for these record fingerprints: {body} or {error}. `o` holds what the person typed.
|
|
94
|
+
function bodyFor(op, fps, o) {
|
|
95
|
+
o = o || {};
|
|
96
|
+
if (!OPS.includes(op)) return fail('unknown action');
|
|
97
|
+
const keys = Array.from(new Set(list(fps).filter(f => typeof f === 'string' && f)));
|
|
98
|
+
if (!keys.length) return fail('select a finding first');
|
|
99
|
+
if (SINGLE.includes(op) ? keys.length !== 1 : keys.length > MAX_FPS) return fail(SINGLE.includes(op) ? 'this action takes one finding' : `at most ${MAX_FPS} findings per action`);
|
|
100
|
+
const body = { fps: keys };
|
|
101
|
+
if (op === 'fix') {
|
|
102
|
+
const commit = str(o.commit).trim().toLowerCase(), reason = checkText(o.reason, 'the reason', MAX_REASON, false);
|
|
103
|
+
if (reason.error) return reason;
|
|
104
|
+
if (!commit && reason.text === null) return fail('give a commit or a reason');
|
|
105
|
+
if (commit) { if (!COMMIT_RE.test(commit)) return fail('a commit is 7 to 40 hexadecimal characters'); body.commit = commit; }
|
|
106
|
+
if (reason.text !== null) body.reason = reason.text;
|
|
107
|
+
} else if (op === 'dismiss') {
|
|
108
|
+
const reason = checkText(o.reason, 'the reason', MAX_REASON, true);
|
|
109
|
+
if (reason.error) return reason;
|
|
110
|
+
body.reason = reason.text;
|
|
111
|
+
} else if (op === 'to-file') {
|
|
112
|
+
const title = checkText(o.title, 'the title', MAX_TITLE, false), text = checkText(o.body, 'the body', MAX_BODY, false);
|
|
113
|
+
if (title.error) return title;
|
|
114
|
+
if (text.error) return text;
|
|
115
|
+
if (title.text !== null) body.title = title.text;
|
|
116
|
+
if (text.text !== null) body.body = text.text;
|
|
117
|
+
} else if (op === 'dup') {
|
|
118
|
+
const of = str(o.of).trim();
|
|
119
|
+
if (!FP_RE.test(of)) return fail('pick the finding it duplicates');
|
|
120
|
+
if (of === keys[0]) return fail('a finding cannot duplicate itself');
|
|
121
|
+
body.of = of;
|
|
122
|
+
} else if (op === 'tag') {
|
|
123
|
+
const parsed = Array.isArray(o.tags) ? parseTags(o.tags.join(' ')) : parseTags(o.tags);
|
|
124
|
+
if (parsed.error) return fail(parsed.error);
|
|
125
|
+
body.tags = parsed.tags; body.remove = !!o.remove;
|
|
126
|
+
} else if (op === 'note') {
|
|
127
|
+
const text = checkText(o.text, 'the note', MAX_NOTE, false); // empty text clears the note
|
|
128
|
+
if (text.error) return text;
|
|
129
|
+
body.text = text.text === null ? '' : text.text;
|
|
130
|
+
} else if (op === 'edit') {
|
|
131
|
+
const severity = str(o.severity).trim();
|
|
132
|
+
if (severity && !SEVERITIES.includes(severity)) return fail('the severity is P0, P1, P2 or P3');
|
|
133
|
+
if (!severity && (o.text === undefined || o.text === null)) return fail('give a severity or a text');
|
|
134
|
+
if (severity) body.severity = severity;
|
|
135
|
+
if (o.text !== undefined && o.text !== null) { // an empty text clears the edit
|
|
136
|
+
const text = str(o.text);
|
|
137
|
+
if (text.length > MAX_EDIT_TEXT) return fail(`the text is at most ${MAX_EDIT_TEXT} characters`);
|
|
138
|
+
body.text = text;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return { body };
|
|
142
|
+
}
|
|
143
|
+
const pathOf = (id, op) => '/api/projects/' + encodeURIComponent(id) + '/findings/' + op;
|
|
144
|
+
|
|
145
|
+
/* ---------- the copyable command ---------- */
|
|
146
|
+
// One argument for a POSIX shell: single quotes keep `$`, backticks and quotes literal. A safe word stays bare.
|
|
147
|
+
function shellQuote(value) {
|
|
148
|
+
const text = str(value);
|
|
149
|
+
if (text !== '' && /^[A-Za-z0-9_@%+=:,./-]+$/.test(text) && !text.startsWith('-')) return text;
|
|
150
|
+
return "'" + text.replace(/'/g, "'\\''") + "'";
|
|
151
|
+
}
|
|
152
|
+
// `--name VALUE`, or `--name=VALUE` when the value starts with "-" so the CLI does not read it as a flag.
|
|
153
|
+
const option = (name, value) => { const v = shellQuote(value); return str(value).startsWith('-') ? `--${name}=${v}` : `--${name} ${v}`; };
|
|
154
|
+
// `forge findings <op> REPO FP… …`. What the person has not typed stays a placeholder word (SHA, TEXT, FP, TAG).
|
|
155
|
+
function commandFor(op, repo, fps, o) {
|
|
156
|
+
o = o || {};
|
|
157
|
+
const head = ['forge findings', op, shellQuote(repo)].concat(list(fps).map(shellQuote));
|
|
158
|
+
const has = v => str(v).trim() !== '';
|
|
159
|
+
if (op === 'fix') {
|
|
160
|
+
if (has(o.commit)) head.push(option('commit', str(o.commit).trim()));
|
|
161
|
+
if (has(o.reason)) head.push(option('reason', str(o.reason).trim()));
|
|
162
|
+
if (!has(o.commit) && !has(o.reason)) head.push('--commit SHA');
|
|
163
|
+
} else if (op === 'dismiss') head.push(has(o.reason) ? option('reason', str(o.reason).trim()) : '--reason TEXT');
|
|
164
|
+
else if (op === 'to-file') { if (has(o.title)) head.push(option('title', str(o.title).trim())); if (has(o.body)) head.push('--body-file FILE'); }
|
|
165
|
+
else if (op === 'dup') head.push(has(o.of) ? option('of', str(o.of).trim()) : '--of FP');
|
|
166
|
+
else if (op === 'tag') {
|
|
167
|
+
const tags = Array.isArray(o.tags) ? o.tags : has(o.tags) ? parseTags(o.tags).tags : [];
|
|
168
|
+
head.push('--', ...(tags.length ? tags.map(shellQuote) : ['TAG']), o.remove ? '--remove' : '--add'); // `--` ends the fingerprints
|
|
169
|
+
} else if (op === 'note') { const text = o.text === undefined ? 'TEXT' : str(o.text).trim(); head.push(...(text.startsWith('-') ? ['--', shellQuote(text)] : [shellQuote(text)])); }
|
|
170
|
+
else if (op === 'edit') {
|
|
171
|
+
if (has(o.severity)) head.push(option('severity', str(o.severity).trim()));
|
|
172
|
+
if (o.text !== undefined && o.text !== null) head.push('--text-file FILE');
|
|
173
|
+
if (!has(o.severity) && (o.text === undefined || o.text === null)) head.push('--severity Pn');
|
|
174
|
+
}
|
|
175
|
+
return head.join(' ');
|
|
176
|
+
}
|
|
177
|
+
// The commands a read-only page offers for one row: [{op, label, command}].
|
|
178
|
+
const COMMAND_LABELS = { fix: 'Mark fixed', dismiss: 'Dismiss', reopen: 'Reopen', 'to-file': 'Mark to file', dup: 'Duplicate of…', tag: 'Add a tag', note: 'Note', edit: 'Edit' };
|
|
179
|
+
function commandsFor(repo, row) {
|
|
180
|
+
if (!selectable(row)) return [];
|
|
181
|
+
return OPS.filter(op => op !== 'reopen' || row.status !== 'open').map(op => ({ op, label: COMMAND_LABELS[op], command: commandFor(op, repo, [row.record_fp]) }));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* ---------- the confirm sentence ---------- */
|
|
185
|
+
const noun = n => `${n} finding${n === 1 ? '' : 's'}`;
|
|
186
|
+
function confirmText(op, count, body) {
|
|
187
|
+
const b = body || {}, n = noun(count);
|
|
188
|
+
if (op === 'fix') return `Mark ${n} fixed${b.commit ? ` by ${b.commit}` : ''}${b.reason ? `: ${b.reason}` : ''}?`;
|
|
189
|
+
if (op === 'dismiss') return `Dismiss ${n}: ${b.reason}?`;
|
|
190
|
+
if (op === 'reopen') return `Reopen ${n}?`;
|
|
191
|
+
if (op === 'to-file') return `Mark ${n} to file${b.title ? ` as "${b.title}"` : ''}?`;
|
|
192
|
+
if (op === 'dup') return `Mark ${n} a duplicate of ${b.of}?`;
|
|
193
|
+
if (op === 'tag') return `${b.remove ? 'Remove' : 'Add'} ${list(b.tags).join(', ')} ${b.remove ? 'from' : 'to'} ${n}?`;
|
|
194
|
+
if (op === 'note') return b.text ? `Set the note of ${n}?` : `Clear the note of ${n}?`;
|
|
195
|
+
if (op === 'edit') return `Edit ${n}${b.severity ? `: severity ${b.severity}` : ''}${b.text !== undefined ? ': replace the text' : ''}?`;
|
|
196
|
+
return `${op} ${n}?`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return { MAX_FPS, MAX_FILE, MAX_TAGS, OPS, SINGLE, PAST, OPEN_STATUSES, selectable, isOpen, storedTags, tagsOf, derivedTags, tagsIn, filterByTag, selectedRows, fpsOf,
|
|
200
|
+
allowed, fileableFps, fileRun, parseTags, bodyFor, pathOf, shellQuote, commandFor, commandsFor, confirmText };
|
|
201
|
+
});
|
|
@@ -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>
|
|
@@ -38,6 +39,8 @@
|
|
|
38
39
|
<script src="findingsview.js" defer></script>
|
|
39
40
|
<script src="worktreesview.js" defer></script>
|
|
40
41
|
<script src="storageview.js" defer></script>
|
|
42
|
+
<script src="findingsactions.js" defer></script>
|
|
43
|
+
<script src="triageview.js" defer></script>
|
|
41
44
|
<script src="projectsview.js" defer></script>
|
|
42
45
|
<script src="rundelete.js" defer></script>
|
|
43
46
|
<script src="settings.js" defer></script>
|