@giamme/forge 0.17.0 → 0.18.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 +24 -0
- package/SKILL.md +16 -3
- package/VERSION +1 -1
- package/docs/artifacts.md +8 -0
- package/docs/commands.md +70 -6
- package/docs/dataset.md +5 -0
- package/docs/decomposed-runs.md +8 -0
- package/docs/forge-ui.md +23 -2
- package/docs/memory.md +2 -0
- package/docs/safety.md +8 -0
- package/forge +24 -1
- package/package.json +1 -1
- package/references/dataset.md +19 -0
- package/references/decompose.md +134 -1
- package/references/solo.md +2 -1
- package/references/ui.md +5 -2
- package/scripts/forge-artifact.sh +14 -0
- package/scripts/forge-brief.py +132 -0
- package/scripts/forge-compare.py +11 -1
- package/scripts/forge-config.py +176 -9
- package/scripts/forge-contract.py +46 -3
- package/scripts/forge-control.py +86 -13
- package/scripts/forge-dispatch.sh +14 -10
- package/scripts/forge-du.py +167 -0
- package/scripts/forge-lib-adopt.sh +1 -0
- package/scripts/forge-lib-plans.sh +5 -2
- package/scripts/forge-lib-review.sh +29 -1
- package/scripts/forge-metrics.sh +7 -3
- package/scripts/forge-parallel-options.sh +4 -0
- package/scripts/forge-parallel.sh +503 -9
- package/scripts/forge-prompt.py +120 -0
- package/scripts/forge-retro.py +115 -0
- package/scripts/forge-runs-compact.py +443 -0
- package/scripts/forge-runs-rm.py +2 -0
- package/scripts/forge-runs.py +18 -3
- package/scripts/forge-schedule.py +279 -4
- package/scripts/forge-shadow.py +7 -1
- package/scripts/forge-solo.sh +2 -0
- package/scripts/forge-summarize.py +698 -0
- package/scripts/forge-ui-options.sh +10 -0
- package/scripts/forge_brief/__init__.py +587 -0
- package/scripts/forge_brief/answers.py +459 -0
- package/scripts/forge_dataset/__init__.py +10 -0
- package/scripts/forge_dataset/export.py +18 -4
- package/scripts/forge_dataset/facts.py +6 -4
- package/scripts/forge_dataset/harvest.py +40 -6
- package/scripts/forge_dataset/history.py +5 -3
- package/scripts/forge_decide/__init__.py +11 -1
- package/scripts/forge_locations.py +366 -0
- package/scripts/forge_registry.py +19 -0
- package/scripts/forge_retro/__init__.py +417 -0
- package/scripts/forge_retro/issues.py +1193 -0
- package/scripts/forge_retro/report.py +671 -0
- package/scripts/forge_side/__init__.py +477 -0
- package/scripts/forge_storage.py +515 -0
- package/ui/README.md +68 -8
- package/ui/docs/api.md +205 -17
- package/ui/forge_ui/control.py +92 -11
- package/ui/forge_ui/export.py +24 -5
- package/ui/forge_ui/links.py +337 -0
- package/ui/forge_ui/models.py +57 -4
- package/ui/forge_ui/projects.py +4 -1
- package/ui/forge_ui/reader.py +661 -30
- package/ui/forge_ui/static/app.js +86 -4
- package/ui/forge_ui/static/briefview.js +302 -0
- package/ui/forge_ui/static/checksview.js +6 -2
- package/ui/forge_ui/static/controls.js +5 -0
- package/ui/forge_ui/static/index.html +3 -0
- package/ui/forge_ui/static/panel.js +268 -2
- package/ui/forge_ui/static/runmodel.js +13 -1
- package/ui/forge_ui/static/storageview.js +271 -0
- package/ui/forge_ui/static/style.css +99 -3
- package/ui/forge_ui/static/worktreesview.js +3 -3
- package/ui/forge_ui/storage.py +136 -0
- package/ui/forge_ui/transcripts.py +35 -10
- package/ui/forge_ui/worktrees.py +154 -13
|
@@ -80,6 +80,7 @@ window.ForgeApp = (() => {
|
|
|
80
80
|
if (/^#\/settings\/?$/.test(hash)) return { key: null, sel: null, settings: true };
|
|
81
81
|
const pj = hash.match(/^#\/projects(?:\/([0-9a-f]{8})(?:\/(runs|findings|memories))?)?\/?$/);
|
|
82
82
|
if (pj) return { key: null, sel: null, projects: { id: pj[1] || null, tab: pj[2] || 'runs' } };
|
|
83
|
+
if (/^#\/disk\/?$/.test(hash)) return { key: null, sel: null, disk: true };
|
|
83
84
|
const w = hash.match(/^#\/worktrees(?:\/(repo|runs)\/([^/]+))?\/?$/);
|
|
84
85
|
if (w) return { key: null, sel: null, worktrees: { repo: w[1] === 'repo' ? decodeURIComponent(w[2]) : '', run: w[1] === 'runs' ? decodeURIComponent(w[2]) : '' } };
|
|
85
86
|
const m = hash.match(/^#\/runs\/([^/]+)(\/.*)?$/);
|
|
@@ -570,6 +571,20 @@ window.ForgeApp = (() => {
|
|
|
570
571
|
});
|
|
571
572
|
}
|
|
572
573
|
|
|
574
|
+
/* ---------- what forge takes on disk (#/disk) ---------- */
|
|
575
|
+
// It reads /api/storage itself, when opened and while a measurement runs: never on the page's poll.
|
|
576
|
+
function renderDisk() {
|
|
577
|
+
const main = $('main');
|
|
578
|
+
if (main.dataset.view === 'disk' && state.diskView) return;
|
|
579
|
+
setView(main, 'disk'); delete main.dataset.run;
|
|
580
|
+
main.replaceChildren();
|
|
581
|
+
const v = el('section', undefined, 'worktrees-view disk-view'); v.id = 'disk-view'; main.append(v);
|
|
582
|
+
state.diskView = window.ForgeStorage.render(v, {
|
|
583
|
+
runHref: path => { const r = list(state.runs).find(x => x.path === path); return r ? '#/runs/' + encodeURIComponent(r.key) : null; },
|
|
584
|
+
tablePrefs: id => state.tablePrefs[id], saveTablePrefs: (id, p) => { state.tablePrefs = { ...state.tablePrefs, [id]: p }; store.set('tables', state.tablePrefs); },
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
|
|
573
588
|
/* ---------- each repository's runs, findings and memories (#/projects) ---------- */
|
|
574
589
|
function renderProjects() {
|
|
575
590
|
const main = $('main'), p = state.projects;
|
|
@@ -835,6 +850,9 @@ window.ForgeApp = (() => {
|
|
|
835
850
|
return [
|
|
836
851
|
{ id: 'id', label: 'ID', mono: true, value: t => t.id, cell: t => link(t.id, run.key, { kind: 'task', id: t.id }) },
|
|
837
852
|
{ id: 'title', label: 'Title', value: t => t.title },
|
|
853
|
+
// the one-sentence summary, only while the run's summaries are on (#133 B): the column is not there otherwise
|
|
854
|
+
...(summariesOn(run) ? [{ id: 'summary', label: 'Summary', title: 'The one-sentence summary of each task (summaries are on for this run)', cls: 'sum-col',
|
|
855
|
+
value: t => t.summary && t.summary.sentence || null, cell: t => t.summary && t.summary.sentence || '—' }] : []),
|
|
838
856
|
{ id: 'difficulty', label: 'Difficulty', value: t => DIFF_RANK[t.difficulty] ?? null, cell: t => display(t.difficulty) },
|
|
839
857
|
{ id: 'wave', label: 'Wave', value: t => Number.isFinite(Number(t.wave)) && t.wave !== null && t.wave !== '' ? Number(t.wave) : null, cell: t => display(t.wave) },
|
|
840
858
|
{ id: 'status', label: 'Status', value: t => RM.taskStatus(t), cell: t => chip(RM.statusText(t), RM.taskStatus(t)) },
|
|
@@ -878,6 +896,43 @@ window.ForgeApp = (() => {
|
|
|
878
896
|
scoped(host, run.key + ':');
|
|
879
897
|
}));
|
|
880
898
|
}
|
|
899
|
+
// The run's summary switch above its tasks (#133 B): `forge control set summaries on|off`, asked in controls.js's words
|
|
900
|
+
// and sent through the page's write path, with the model shown when on. A page that cannot write shows the state alone.
|
|
901
|
+
// Built once per run and per writability, then updated in place, so a poll never takes the keyboard off its keys.
|
|
902
|
+
const summariesOn = run => !!run.summaries && run.summaries.mode === 'on';
|
|
903
|
+
let summaryWritable = false;
|
|
904
|
+
function askWritable() {
|
|
905
|
+
if (SNAP || !window.ForgeUI || !window.ForgeUI.controlsEnabled) return;
|
|
906
|
+
window.ForgeUI.controlsEnabled().then(on => {
|
|
907
|
+
if (!!on === summaryWritable) return;
|
|
908
|
+
summaryWritable = !!on;
|
|
909
|
+
const cur = state.cache.get(state.key)?.data;
|
|
910
|
+
if (cur) renderSummarySwitch(cur);
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
function renderSummarySwitch(run) {
|
|
914
|
+
const host = $('run-summaries'); if (!host) return;
|
|
915
|
+
host.hidden = run.kind === 'solo' || !window.ForgePanel; // a solo run has one task and no switch
|
|
916
|
+
if (host.hidden) return;
|
|
917
|
+
askWritable();
|
|
918
|
+
const mode = summariesOn(run) ? 'on' : 'off', key = run.key;
|
|
919
|
+
const shape = `${key}|${summaryWritable ? 'write' : 'read'}`;
|
|
920
|
+
if (host.dataset.shape !== shape) {
|
|
921
|
+
host.dataset.shape = shape;
|
|
922
|
+
const kids = [el('span', 'Summaries:', 'plate')];
|
|
923
|
+
if (summaryWritable) {
|
|
924
|
+
kids.push(window.ForgePanel.summaryBank([['off', 'Off'], ['on', 'On']], mode,
|
|
925
|
+
value => window.ForgePanel.changeSummaries(host.querySelector('.sum-msgs'), null, key, { input: value }, () => loadRun(key)),
|
|
926
|
+
'Summaries for this run'));
|
|
927
|
+
} else kids.push(el('span', undefined, 'sum-state'));
|
|
928
|
+
kids.push(el('span', undefined, 'sum-model'), el('div', undefined, 'sum-msgs'));
|
|
929
|
+
host.replaceChildren(...kids);
|
|
930
|
+
}
|
|
931
|
+
for (const b of host.querySelectorAll('.sum-bank button')) b.setAttribute('aria-pressed', String(b.dataset.value === mode));
|
|
932
|
+
const word = host.querySelector('.sum-state');
|
|
933
|
+
if (word) word.textContent = mode;
|
|
934
|
+
host.querySelector('.sum-model').replaceChildren(...(mode === 'on' && run.summaries.model ? [window.ForgeIcons.modelPlate(run.summaries.model)] : []));
|
|
935
|
+
}
|
|
881
936
|
function renderInspector(run) {
|
|
882
937
|
const host = $('inspector'); if (!host || !window.ForgePanel) return;
|
|
883
938
|
const sel = state.sel || (run.kind === 'solo' ? { kind: 'task', id: list(run.tasks)[0]?.id } : null);
|
|
@@ -886,6 +941,7 @@ window.ForgeApp = (() => {
|
|
|
886
941
|
run, sel, now: now(),
|
|
887
942
|
fetchJSON: path => fetchJSON(path).then(r => r.data),
|
|
888
943
|
rerender: () => { const r = state.cache.get(state.key)?.data; if (r) renderInspector(r); },
|
|
944
|
+
refresh: () => loadRun(run.key), // a change made here shows at once, not at the next poll
|
|
889
945
|
hash: s => hashFor(run.key, s), onSelect: s => select(s), diffHash: spec => diffHash(run.key, spec),
|
|
890
946
|
convoHash: (s, event) => convoHash(run.key, s, event),
|
|
891
947
|
onFractal: (id, data) => { if (state.stage && state.stage.setFractal) state.stage.setFractal(id, data); },
|
|
@@ -1005,17 +1061,39 @@ window.ForgeApp = (() => {
|
|
|
1005
1061
|
const strip = el('div', undefined, 'strip-wrap'); strip.id = 'strip'; view.append(strip);
|
|
1006
1062
|
const diff = el('section', undefined, 'diff-view'); diff.id = 'diff-view'; diff.hidden = true; diff.tabIndex = -1; view.append(diff);
|
|
1007
1063
|
const box = el('section', undefined, 'module tasks-module'); box.setAttribute('aria-label', 'Tasks'); box.dataset.overlay = '';
|
|
1064
|
+
const questions = el('div', undefined, 'run-questions'); questions.id = 'run-questions'; questions.hidden = true; // open brief questions (#135)
|
|
1065
|
+
questions.setAttribute('aria-label', 'Open questions');
|
|
1066
|
+
const switchRow = el('div', undefined, 'tasks-switch'); switchRow.id = 'run-summaries'; switchRow.hidden = true; // the summaries switch (#133 B)
|
|
1008
1067
|
const tasks = el('div', undefined, 'run-tasks'); tasks.id = 'run-tasks';
|
|
1009
|
-
box.append(Shell.head('tasks', 'Tasks', ''), tasks, Shell.splitter('tasks'));
|
|
1068
|
+
box.append(Shell.head('tasks', 'Tasks', ''), questions, switchRow, tasks, Shell.splitter('tasks'));
|
|
1010
1069
|
view.append(box);
|
|
1011
1070
|
}
|
|
1012
1071
|
document.body.classList.toggle('no-tasks', run.kind === 'solo');
|
|
1013
1072
|
ensureStage();
|
|
1014
1073
|
renderHeader(run);
|
|
1015
1074
|
renderRunBody(run);
|
|
1075
|
+
renderSummarySwitch(run);
|
|
1076
|
+
renderQuestions(run);
|
|
1016
1077
|
renderTable(run);
|
|
1017
1078
|
announce(run);
|
|
1018
1079
|
}
|
|
1080
|
+
// Open brief questions (#135), flagged first and then by the schedule projection. Hidden with the tasks module
|
|
1081
|
+
// when that panel is folded, and hidden entirely when brief is off or nothing is still open.
|
|
1082
|
+
function renderQuestions(run) {
|
|
1083
|
+
const host = $('run-questions');
|
|
1084
|
+
if (!host) return;
|
|
1085
|
+
const show = run.kind !== 'solo' && run.brief && window.ForgeBrief;
|
|
1086
|
+
if (!show) { host.hidden = true; host.replaceChildren(); return; }
|
|
1087
|
+
const open = window.ForgeBrief.openQuestions(run);
|
|
1088
|
+
if (!open.length) { host.hidden = true; host.replaceChildren(); return; }
|
|
1089
|
+
host.hidden = false;
|
|
1090
|
+
const clock = now();
|
|
1091
|
+
const projections = RM.projectSchedule(run, { now: clock });
|
|
1092
|
+
preserve(host, () => window.ForgeBrief.renderList(host, {
|
|
1093
|
+
run, projections, now: clock,
|
|
1094
|
+
href: id => hashFor(run.key, { kind: 'task', id }),
|
|
1095
|
+
}));
|
|
1096
|
+
}
|
|
1019
1097
|
function renderMain() {
|
|
1020
1098
|
document.body.classList.toggle('cloud-mode', !!state.cloud);
|
|
1021
1099
|
if (!state.key) document.body.classList.remove('no-tasks');
|
|
@@ -1023,6 +1101,7 @@ window.ForgeApp = (() => {
|
|
|
1023
1101
|
if (state.models) { renderModels(); return; }
|
|
1024
1102
|
if (state.settings) { renderSettings(); return; }
|
|
1025
1103
|
if (state.worktrees) { renderWorktrees(); return; }
|
|
1104
|
+
if (state.disk) { renderDisk(); return; }
|
|
1026
1105
|
if (state.projects) { renderProjects(); return; }
|
|
1027
1106
|
if (state.key && state.findingsPage) { renderFindings(); return; }
|
|
1028
1107
|
if (!state.key) { renderMap(); return; }
|
|
@@ -1081,7 +1160,7 @@ window.ForgeApp = (() => {
|
|
|
1081
1160
|
if (state.cloud) renderCloud();
|
|
1082
1161
|
else if (state.settings) state.settingsView?.poll(); // the picker follows the run list; the page stays
|
|
1083
1162
|
else if (state.projects) state.projectsView?.poll();
|
|
1084
|
-
else if (!state.key && !state.models && !state.worktrees) renderMap({ rebuildBar: $('map-filters') ? !$('map-filters').contains(document.activeElement) : true });
|
|
1163
|
+
else if (!state.key && !state.models && !state.worktrees && !state.disk) renderMap({ rebuildBar: $('map-filters') ? !$('map-filters').contains(document.activeElement) : true });
|
|
1085
1164
|
}, 'Could not refresh runs');
|
|
1086
1165
|
}
|
|
1087
1166
|
function loadRun(key) {
|
|
@@ -1118,6 +1197,7 @@ window.ForgeApp = (() => {
|
|
|
1118
1197
|
state.models = !!parsed.models;
|
|
1119
1198
|
state.settings = !!parsed.settings && !!window.ForgeSettings && !SNAP;
|
|
1120
1199
|
state.worktrees = parsed.worktrees && window.ForgeWorktrees && !SNAP ? parsed.worktrees : null;
|
|
1200
|
+
state.disk = !!parsed.disk && !!window.ForgeStorage && !SNAP;
|
|
1121
1201
|
state.projects = parsed.projects && window.ForgeProjects && !SNAP ? parsed.projects : null;
|
|
1122
1202
|
if (parsed.key) state.lastKey = parsed.key;
|
|
1123
1203
|
state.findingsPage = !!parsed.findings && !!window.ForgeFindings;
|
|
@@ -1128,7 +1208,7 @@ window.ForgeApp = (() => {
|
|
|
1128
1208
|
document.body.classList.toggle('cloud-mode', !!state.cloud);
|
|
1129
1209
|
if (!state.key) document.body.classList.remove('no-tasks');
|
|
1130
1210
|
for (const a of document.querySelectorAll('.topbar .top-link')) {
|
|
1131
|
-
const here = a.getAttribute('href') === (state.cloud ? '#/cloud' : state.models ? '#/models' : state.settings ? '#/settings' : state.worktrees ? '#/worktrees' : state.projects ? '#/projects' : !state.key ? '#/' : null);
|
|
1211
|
+
const here = a.getAttribute('href') === (state.cloud ? '#/cloud' : state.models ? '#/models' : state.settings ? '#/settings' : state.worktrees ? '#/worktrees' : state.disk ? '#/disk' : state.projects ? '#/projects' : !state.key ? '#/' : null);
|
|
1132
1212
|
if (here) a.setAttribute('aria-current', 'page'); else a.removeAttribute('aria-current');
|
|
1133
1213
|
}
|
|
1134
1214
|
renderErrors();
|
|
@@ -1137,6 +1217,7 @@ window.ForgeApp = (() => {
|
|
|
1137
1217
|
if (state.models) { renderModels(); loadModels(); return; }
|
|
1138
1218
|
if (state.settings) { renderSettings(); return; }
|
|
1139
1219
|
if (state.worktrees) { renderWorktrees(); return; }
|
|
1220
|
+
if (state.disk) { renderDisk(); return; }
|
|
1140
1221
|
if (state.projects) { renderProjects(); return; }
|
|
1141
1222
|
if (state.key && state.findingsPage) { renderFindings(); return; }
|
|
1142
1223
|
if (!state.key) { renderMap(); return; }
|
|
@@ -1186,7 +1267,8 @@ window.ForgeApp = (() => {
|
|
|
1186
1267
|
{ id: 'cmd:map', label: 'Open the map of all runs', sub: 'the front page', ids: ['map', 'home'], href: '#/' },
|
|
1187
1268
|
{ id: 'cmd:models', label: 'Open the model leaderboard', sub: 'pass rates, retries, time and tokens per model', ids: ['models', 'leaderboard'], href: '#/models' },
|
|
1188
1269
|
...(window.ForgeProjects ? [{ id: 'cmd:projects', label: 'Open the projects', sub: 'each repository\'s runs, findings and memories', ids: ['projects', 'repos', 'memory', 'findings'], href: '#/projects' }] : []),
|
|
1189
|
-
...(window.ForgeWorktrees ? [{ id: 'cmd:worktrees', label: 'Open the worktrees', sub: 'every worktree forge created, its state and the command that removes it', ids: ['worktrees', 'cleanup'
|
|
1270
|
+
...(window.ForgeWorktrees ? [{ id: 'cmd:worktrees', label: 'Open the worktrees', sub: 'every worktree forge created, its state and the command that removes it', ids: ['worktrees', 'cleanup'], href: '#/worktrees' }] : []),
|
|
1271
|
+
...(window.ForgeStorage ? [{ id: 'cmd:disk', label: 'Open the disk report', sub: 'what forge takes on disk and the command that takes each part back', ids: ['disk', 'space', 'du', 'compact', 'cleanup'], href: '#/disk' }] : []),
|
|
1190
1272
|
...(window.ForgeSettings ? [{ id: 'cmd:settings', label: 'Open the settings', sub: 'model registry, Jev, and the .forge files of a repository', ids: ['settings', 'config', 'verify', 'jev'], href: '#/settings' }] : []),
|
|
1191
1273
|
{ id: 'cmd:notify', label: 'Notifications', sub: 'what finished or failed, and browser notifications', ids: ['alerts', 'bell'], action: () => window.ForgeNotify && window.ForgeNotify.open() },
|
|
1192
1274
|
{ id: 'cmd:dim', label: state.dim === '3d' ? 'Switch to 2D' : 'Switch to 3D', sub: state.dim === '3d' ? 'graphs and charts, no WebGL' : 'loads three.js from cdn.jsdelivr.net', ids: ['2d', '3d'],
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/* forge-ui brief questions (#135): a task's questions in the inspector, and the run's open questions.
|
|
2
|
+
window.ForgeBrief, and a CommonJS module under node:test. The pure helpers (openQuestions, orderQuestions,
|
|
3
|
+
startLine) are tested in ui/tests/js/briefview.test.js. Question text, answers and the late-answer notice
|
|
4
|
+
are untrusted: they only ever enter the page as text.
|
|
5
|
+
Ordering is flagged (must answer) first, then by the projected start from projectSchedule. A task with no
|
|
6
|
+
finite start is last. Wave numbers are a preview and are never a sort key. */
|
|
7
|
+
(function (root, factory) {
|
|
8
|
+
'use strict';
|
|
9
|
+
const api = factory(root);
|
|
10
|
+
if (typeof module === 'object' && module.exports) module.exports = api;
|
|
11
|
+
else root.ForgeBrief = api;
|
|
12
|
+
})(typeof self !== 'undefined' ? self : this, function (root) {
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const list = v => Array.isArray(v) ? v : [];
|
|
16
|
+
const num = v => typeof v === 'number' && Number.isFinite(v) ? v : null;
|
|
17
|
+
const notices = new Map(); // run\ntask\nqid → the late answer's stdout
|
|
18
|
+
|
|
19
|
+
function el(tag, text, className) {
|
|
20
|
+
const node = root.document.createElement(tag);
|
|
21
|
+
if (text !== undefined) node.textContent = text === null || text === undefined ? '' : String(text);
|
|
22
|
+
if (className) node.className = className;
|
|
23
|
+
return node;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function noticeKey(run, task, question) {
|
|
27
|
+
return String(run && run.key) + '\n' + String(task && task.id) + '\n' + String(question && question.id);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Open task questions, in task order. Parked questions are wider than the task and are not listed here.
|
|
31
|
+
function openQuestions(run) {
|
|
32
|
+
const items = [];
|
|
33
|
+
for (const task of list(run && run.tasks)) {
|
|
34
|
+
const brief = task && task.brief;
|
|
35
|
+
if (!brief || typeof brief !== 'object') continue;
|
|
36
|
+
for (const question of list(brief.questions)) {
|
|
37
|
+
if (!question || typeof question !== 'object' || question.state !== 'open') continue;
|
|
38
|
+
items.push({ task, question });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return items;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function projectionStart(projections, task) {
|
|
45
|
+
if (!projections || !task) return null;
|
|
46
|
+
const row = projections[task.id];
|
|
47
|
+
if (!row || typeof row !== 'object') return null;
|
|
48
|
+
return num(row.start);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Flagged first, then the earliest finite projected start. No start (missing, or not a finite number) sorts
|
|
52
|
+
// last inside its group. The original index breaks ties, so equal starts keep the order they were given.
|
|
53
|
+
function orderQuestions(items, projections) {
|
|
54
|
+
const rows = list(items).map((item, index) => ({ item, index }));
|
|
55
|
+
rows.sort((a, b) => {
|
|
56
|
+
const fa = a.item && a.item.question && a.item.question.must_answer === true ? 0 : 1;
|
|
57
|
+
const fb = b.item && b.item.question && b.item.question.must_answer === true ? 0 : 1;
|
|
58
|
+
if (fa !== fb) return fa - fb;
|
|
59
|
+
const sa = projectionStart(projections, a.item && a.item.task);
|
|
60
|
+
const sb = projectionStart(projections, b.item && b.item.task);
|
|
61
|
+
if (sa === null && sb !== null) return 1;
|
|
62
|
+
if (sa !== null && sb === null) return -1;
|
|
63
|
+
if (sa !== null && sb !== null && sa !== sb) return sa - sb;
|
|
64
|
+
return a.index - b.index;
|
|
65
|
+
});
|
|
66
|
+
return rows.map(row => row.item);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// A wait, rounded to a phrase. Under 45s is "about now"; otherwise the nearest minute, then hours.
|
|
70
|
+
function aboutText(seconds) {
|
|
71
|
+
const s = Math.max(0, num(seconds) === null ? 0 : seconds);
|
|
72
|
+
if (s < 45) return 'about now';
|
|
73
|
+
const minutes = Math.round(s / 60);
|
|
74
|
+
if (minutes <= 1) return 'about 1 min';
|
|
75
|
+
if (minutes < 60) return 'about ' + minutes + ' min';
|
|
76
|
+
const hours = Math.floor(minutes / 60), rest = minutes % 60;
|
|
77
|
+
return rest ? 'about ' + hours + ' h ' + rest + ' min' : 'about ' + hours + ' h';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function namesPhrase(deps) {
|
|
81
|
+
const names = list(deps).map(id => String(id));
|
|
82
|
+
if (names.length <= 1) return names[0] || '';
|
|
83
|
+
if (names.length === 2) return names[0] + ' and ' + names[1];
|
|
84
|
+
return names.slice(0, -1).join(', ') + ' and ' + names[names.length - 1];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// "starts after A and B merge, about 40 min". No finite start → null. No clock → the wait is about now.
|
|
88
|
+
// A task that has started (any status but PENDING or BLOCKED) says so instead: its projected start is in
|
|
89
|
+
// the past, and an answer now is a late one.
|
|
90
|
+
function startLine(spec) {
|
|
91
|
+
spec = spec || {};
|
|
92
|
+
const status = typeof spec.status === 'string' ? spec.status : '';
|
|
93
|
+
if (status === 'RUNNING') return 'running now';
|
|
94
|
+
if (status && status !== 'PENDING' && status !== 'BLOCKED') return 'already started';
|
|
95
|
+
const start = num(spec.start);
|
|
96
|
+
if (start === null) return null;
|
|
97
|
+
const clock = num(spec.now);
|
|
98
|
+
const about = aboutText(clock === null ? 0 : start - clock);
|
|
99
|
+
const deps = list(spec.deps);
|
|
100
|
+
if (!deps.length) return about === 'about now' ? 'starts about now' : 'starts in ' + about;
|
|
101
|
+
const verb = deps.length === 1 ? 'merges' : 'merge';
|
|
102
|
+
return 'starts after ' + namesPhrase(deps) + ' ' + verb + ', ' + about;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Deps that have not merged yet, including an id the run does not know. PASS is still ahead of the merge.
|
|
106
|
+
function waitingDeps(task, tasks) {
|
|
107
|
+
const byId = new Map(list(tasks).map(item => [item && item.id, item]));
|
|
108
|
+
return list(task && task.deps).filter(id => {
|
|
109
|
+
const dep = byId.get(id);
|
|
110
|
+
return !dep || dep.status !== 'MERGED';
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function flags(question) {
|
|
115
|
+
const row = el('div', undefined, 'brief-flags');
|
|
116
|
+
if (question && question.must_answer === true) row.append(el('span', 'must answer', 'tag'));
|
|
117
|
+
if (question && question.possibly_stale === true) row.append(el('span', 'possibly stale', 'tag'));
|
|
118
|
+
return row.childElementCount ? row : null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function noticeNode(text) {
|
|
122
|
+
const pre = el('pre', text, 'brief-notice');
|
|
123
|
+
pre.setAttribute('role', 'status');
|
|
124
|
+
return pre;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function paintNotice(box, text) {
|
|
128
|
+
const card = box && box.parentElement;
|
|
129
|
+
if (!card) return;
|
|
130
|
+
const node = noticeNode(text);
|
|
131
|
+
const old = card.querySelector(':scope > .brief-notice');
|
|
132
|
+
if (old) old.replaceWith(node);
|
|
133
|
+
else card.insertBefore(node, box);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function clearNotice(box) {
|
|
137
|
+
const old = box && box.parentElement && box.parentElement.querySelector(':scope > .brief-notice');
|
|
138
|
+
if (old) old.remove();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function answerBox(ctx, task, question) {
|
|
142
|
+
const run = ctx.run || {};
|
|
143
|
+
const box = el('div', undefined, 'brief-box');
|
|
144
|
+
box.dataset.hold = 'brief:' + run.key + ':' + task.id + ':' + question.id;
|
|
145
|
+
const field = el('textarea');
|
|
146
|
+
field.setAttribute('aria-label', 'Answer');
|
|
147
|
+
field.maxLength = 4096;
|
|
148
|
+
field.rows = 3;
|
|
149
|
+
field.autocomplete = 'off';
|
|
150
|
+
const send = el('button', 'Send', 'brief-send');
|
|
151
|
+
send.type = 'button';
|
|
152
|
+
const msgs = el('div', undefined, 'brief-msgs');
|
|
153
|
+
const mark = () => { box.dataset.editing = '1'; };
|
|
154
|
+
field.addEventListener('focus', mark);
|
|
155
|
+
field.addEventListener('input', mark);
|
|
156
|
+
field.addEventListener('blur', () => {
|
|
157
|
+
if (box.dataset.busy) return;
|
|
158
|
+
if (!field.value.trim()) delete box.dataset.editing;
|
|
159
|
+
});
|
|
160
|
+
send.addEventListener('click', () => sendAnswer(box, field, send, msgs, ctx, task, question));
|
|
161
|
+
box.append(field, send, msgs);
|
|
162
|
+
return box;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async function sendAnswer(box, field, send, msgs, ctx, task, question) {
|
|
166
|
+
if (box.dataset.busy) return;
|
|
167
|
+
const answer = field.value.trim();
|
|
168
|
+
const ui = root.ForgeUI;
|
|
169
|
+
if (!answer) {
|
|
170
|
+
if (ui) ui.outcome(msgs, { ok: false, status: 400, error: 'invalid', detail: 'the answer is empty' });
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
box.dataset.editing = '1';
|
|
174
|
+
box.dataset.busy = '1';
|
|
175
|
+
box.setAttribute('aria-busy', 'true');
|
|
176
|
+
send.disabled = true;
|
|
177
|
+
const run = ctx.run || {};
|
|
178
|
+
const path = '/api/runs/' + encodeURIComponent(run.key) + '/tasks/' + encodeURIComponent(task.id) + '/brief/' + encodeURIComponent(question.id);
|
|
179
|
+
let res = { ok: false, error: 'unavailable', detail: 'this page cannot send' };
|
|
180
|
+
try {
|
|
181
|
+
if (ui && ui.post) res = await ui.post(path, { answer });
|
|
182
|
+
} catch (_) {
|
|
183
|
+
res = { ok: false, error: 'failed', detail: 'could not send the answer' };
|
|
184
|
+
}
|
|
185
|
+
if (!box.isConnected) return;
|
|
186
|
+
delete box.dataset.busy;
|
|
187
|
+
box.removeAttribute('aria-busy');
|
|
188
|
+
send.disabled = false;
|
|
189
|
+
const data = res && res.data;
|
|
190
|
+
const output = data && typeof data.output === 'string' ? data.output : '';
|
|
191
|
+
if (res && res.ok && data && data.exit === 0) {
|
|
192
|
+
const key = noticeKey(run, task, question);
|
|
193
|
+
if (output.includes('forge control add')) {
|
|
194
|
+
notices.set(key, output);
|
|
195
|
+
paintNotice(box, output);
|
|
196
|
+
} else {
|
|
197
|
+
notices.delete(key);
|
|
198
|
+
clearNotice(box);
|
|
199
|
+
}
|
|
200
|
+
delete box.dataset.editing; // the redraw shows the recorded answer, not this draft
|
|
201
|
+
if (ctx.refresh) ctx.refresh();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (ui && ui.outcome) ui.outcome(msgs, res);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function questionCard(question, ctx, task, parked) {
|
|
208
|
+
const li = el('li', undefined, 'brief-q');
|
|
209
|
+
if (question.id) li.dataset.qid = String(question.id);
|
|
210
|
+
li.append(el('p', typeof question.text === 'string' && question.text ? question.text : '—', 'brief-text'));
|
|
211
|
+
if (typeof question.why === 'string' && question.why) li.append(el('p', question.why, 'brief-why muted'));
|
|
212
|
+
const options = list(question.options).filter(item => typeof item === 'string' && item);
|
|
213
|
+
if (options.length) li.append(el('p', options.join(' · '), 'brief-options'));
|
|
214
|
+
if (typeof question.default === 'string' && question.default) li.append(el('p', 'if unanswered: ' + question.default, 'brief-default muted'));
|
|
215
|
+
const marks = flags(question);
|
|
216
|
+
if (marks) li.append(marks);
|
|
217
|
+
if (!parked && typeof question.answer === 'string' && question.answer) li.append(el('p', 'Answer: ' + question.answer, 'brief-got'));
|
|
218
|
+
if (parked && typeof question.scope === 'string' && question.scope) li.append(el('p', 'scope: ' + question.scope, 'brief-scope muted'));
|
|
219
|
+
if (!parked) {
|
|
220
|
+
const note = notices.get(noticeKey(ctx && ctx.run, task, question));
|
|
221
|
+
const box = answerBox(ctx, task, question);
|
|
222
|
+
if (note) li.append(noticeNode(note));
|
|
223
|
+
li.append(box);
|
|
224
|
+
}
|
|
225
|
+
return li;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Drop the answer boxes once the page knows it cannot write. The promise is cached, so a redraw settles at once.
|
|
229
|
+
function settleControls(section) {
|
|
230
|
+
const ui = root.ForgeUI;
|
|
231
|
+
const drop = () => {
|
|
232
|
+
if (!section.isConnected) return;
|
|
233
|
+
for (const box of section.querySelectorAll('.brief-box')) box.remove();
|
|
234
|
+
section.dataset.controls = 'off';
|
|
235
|
+
};
|
|
236
|
+
if (!ui || !ui.controlsEnabled) { drop(); return; }
|
|
237
|
+
ui.controlsEnabled().then(on => {
|
|
238
|
+
if (!section.isConnected) return;
|
|
239
|
+
if (!on) drop();
|
|
240
|
+
else section.dataset.controls = 'on';
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// The inspector section. Nothing when this task has no brief. Parked questions stay collapsed, with no answer box.
|
|
245
|
+
function taskSection(host, ctx, task) {
|
|
246
|
+
const brief = task && task.brief;
|
|
247
|
+
if (!host || !brief || typeof brief !== 'object') return null;
|
|
248
|
+
const section = el('section', undefined, 'insp-section brief-section');
|
|
249
|
+
section.append(el('h3', 'Questions'));
|
|
250
|
+
const questions = list(brief.questions).filter(item => item && typeof item === 'object');
|
|
251
|
+
const parked = list(brief.parked).filter(item => item && typeof item === 'object');
|
|
252
|
+
if (!questions.length && !parked.length) section.append(el('p', 'No questions.', 'muted'));
|
|
253
|
+
if (questions.length) {
|
|
254
|
+
const ul = el('ul', undefined, 'brief-questions');
|
|
255
|
+
for (const question of questions) ul.append(questionCard(question, ctx, task, false));
|
|
256
|
+
section.append(ul);
|
|
257
|
+
}
|
|
258
|
+
if (parked.length) {
|
|
259
|
+
const details = el('details', undefined, 'brief-parked');
|
|
260
|
+
details.dataset.keep = 'brief-parked:' + task.id;
|
|
261
|
+
const ul = el('ul', undefined, 'brief-questions');
|
|
262
|
+
for (const question of parked) ul.append(questionCard(question, ctx, task, true));
|
|
263
|
+
details.append(el('summary', 'Parked (wider scope)'), ul);
|
|
264
|
+
section.append(details);
|
|
265
|
+
}
|
|
266
|
+
host.append(section);
|
|
267
|
+
settleControls(section);
|
|
268
|
+
return section;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// The run's open questions. `href(taskId)` is the link that opens that task's inspector.
|
|
272
|
+
function renderList(host, spec) {
|
|
273
|
+
spec = spec || {};
|
|
274
|
+
if (!host) return;
|
|
275
|
+
host.replaceChildren();
|
|
276
|
+
const run = spec.run;
|
|
277
|
+
const open = orderQuestions(openQuestions(run), spec.projections);
|
|
278
|
+
if (!open.length) return;
|
|
279
|
+
const head = el('p', undefined, 'brief-list-head');
|
|
280
|
+
head.append(el('span', 'Questions', 'plate'), el('span', String(open.length), 'module-count'));
|
|
281
|
+
const ul = el('ul', undefined, 'brief-list');
|
|
282
|
+
ul.dataset.scroll = 'brief-list';
|
|
283
|
+
for (const item of open) {
|
|
284
|
+
const task = item.task, question = item.question;
|
|
285
|
+
const li = el('li');
|
|
286
|
+
const link = el('a', undefined, 'brief-open');
|
|
287
|
+
link.href = typeof spec.href === 'function' ? spec.href(task.id) : '#';
|
|
288
|
+
const top = el('span', undefined, 'brief-open-top');
|
|
289
|
+
top.append(el('span', task.id, 'mono brief-open-task'), el('span', typeof question.text === 'string' && question.text ? question.text : '—', 'brief-open-text'));
|
|
290
|
+
link.append(top);
|
|
291
|
+
const marks = flags(question);
|
|
292
|
+
if (marks) link.append(marks);
|
|
293
|
+
const when = startLine({ deps: waitingDeps(task, run && run.tasks), start: projectionStart(spec.projections, task), now: spec.now, status: task.status });
|
|
294
|
+
if (when) link.append(el('span', when, 'brief-when'));
|
|
295
|
+
li.append(link);
|
|
296
|
+
ul.append(li);
|
|
297
|
+
}
|
|
298
|
+
host.append(head, ul);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return { openQuestions, orderQuestions, startLine, renderList, taskSection };
|
|
302
|
+
});
|
|
@@ -83,6 +83,10 @@
|
|
|
83
83
|
if (w.kind === 'slot') return { ...out, text: `no free slot: ${num(w.running) ?? '?'} of ${num(w.max_parallel) ?? '?'} running` };
|
|
84
84
|
if (w.kind === 'drained') return { ...out, text: 'drained: nothing new starts until the run resumes' };
|
|
85
85
|
if (w.kind === 'stopping') return { ...out, text: w.mode === 'now' ? 'the run is stopping now' : 'the run stops once its running tasks end' };
|
|
86
|
+
if (w.kind === 'brief') {
|
|
87
|
+
const asked = ids(w.questions);
|
|
88
|
+
return { ...out, text: asked.length ? `waits for your answer to ${asked.join(', ')}` : 'waits for its brief questions to be written' };
|
|
89
|
+
}
|
|
86
90
|
if (w.kind === 'next') return { ...out, text: "starts at the scheduler's next turn" };
|
|
87
91
|
if (w.kind === 'infra') {
|
|
88
92
|
const cause = RM.causeLabel(w.class);
|
|
@@ -98,7 +102,7 @@
|
|
|
98
102
|
return null;
|
|
99
103
|
}
|
|
100
104
|
// The Now column's order: running, then what starts soonest, then what waits on others, then what is held
|
|
101
|
-
const RANK = { running: 0, next: 1, slot: 2, overlap: 2, deps: 3, infra: 4, drained: 5, stopping: 5, escalation: 6 };
|
|
105
|
+
const RANK = { running: 0, next: 1, slot: 2, overlap: 2, brief: 2, deps: 3, infra: 4, drained: 5, stopping: 5, escalation: 6 };
|
|
102
106
|
function nowRank(task) {
|
|
103
107
|
if (task && task.now) return RANK.running;
|
|
104
108
|
const w = task && task.waiting;
|
|
@@ -142,7 +146,7 @@
|
|
|
142
146
|
if (!s || s.live !== true) return null;
|
|
143
147
|
const tasks = list(run.tasks), count = kind => tasks.filter(t => t.waiting && t.waiting.kind === kind).length;
|
|
144
148
|
const state = s.stopping ? (s.stopping === 'now' ? 'stopping now' : 'stopping once its running tasks end') : s.drained ? 'drained: nothing new starts' : 'dispatching';
|
|
145
|
-
const waiting = [['deps', 'on dependencies'], ['overlap', 'on shared files'], ['slot', 'for a free slot'], ['infra', 'paused'],
|
|
149
|
+
const waiting = [['deps', 'on dependencies'], ['overlap', 'on shared files'], ['slot', 'for a free slot'], ['brief', 'for your answer'], ['infra', 'paused'],
|
|
146
150
|
['next', 'next'], ['escalation', 'stopped by the retry policy']]
|
|
147
151
|
.map(([kind, label]) => [count(kind), label]).filter(([n]) => n).map(([n, label]) => `${n} ${label}`);
|
|
148
152
|
const rows = [['Scheduler', state], ['Running', String(tasks.filter(t => t.status === 'RUNNING').length) + (num(s.max_parallel) !== null ? ` of ${s.max_parallel} slots` : '')]];
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
'max-parallel': { label: 'Max parallel', run: 'at the next dispatch', planOnly: true, live: true },
|
|
30
30
|
'infra-backoff': { label: 'Infra backoff', run: 'at the next infrastructure wait', planOnly: true },
|
|
31
31
|
'escalate-effort': { label: 'Effort step', run: 'at the next retry decision', planOnly: true },
|
|
32
|
+
'summaries': { label: 'Summaries', run: "at each task's next change", task: 'at its next change' },
|
|
32
33
|
};
|
|
33
34
|
const BACKOFF_FORMS = 'exp:<base>[,<cap>], linear:<start>,<step>[,<cap>] or list:<a>,<b>,… (seconds)';
|
|
34
35
|
// A task status after which "Retry now" applies (or the policy stopped it).
|
|
@@ -94,6 +95,10 @@
|
|
|
94
95
|
if (key === 'max-parallel') {
|
|
95
96
|
return /^[0-9]{1,2}$/.test(text) && Number(text) >= 1 && Number(text) <= 64 ? { ok: true, value: String(Number(text)) } : bad('a whole number, 1 to 64');
|
|
96
97
|
}
|
|
98
|
+
if (key === 'summaries') {
|
|
99
|
+
return text === 'on' || text === 'off' || (task && text === 'inherit') ? { ok: true, value: text }
|
|
100
|
+
: bad(task ? 'on, off or inherit' : 'on or off');
|
|
101
|
+
}
|
|
97
102
|
if (key === 'escalate-effort') return text === 'on' || text === 'off' ? { ok: true, value: text } : bad('on or off');
|
|
98
103
|
if (key === 'infra-backoff') {
|
|
99
104
|
// The shape itself is the CLI's to check; here only what can never be one. "default" drops the setting.
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
<script src="controls.js" defer></script>
|
|
28
28
|
<script src="verifyview.js" defer></script>
|
|
29
29
|
<script src="checksview.js" defer></script>
|
|
30
|
+
<script src="briefview.js" defer></script>
|
|
30
31
|
<script src="panel.js" defer></script>
|
|
31
32
|
<script src="diffview.js" defer></script>
|
|
32
33
|
<script src="convo.js" defer></script>
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
<script src="leaderboard.js" defer></script>
|
|
37
38
|
<script src="findingsview.js" defer></script>
|
|
38
39
|
<script src="worktreesview.js" defer></script>
|
|
40
|
+
<script src="storageview.js" defer></script>
|
|
39
41
|
<script src="projectsview.js" defer></script>
|
|
40
42
|
<script src="rundelete.js" defer></script>
|
|
41
43
|
<script src="settings.js" defer></script>
|
|
@@ -53,6 +55,7 @@
|
|
|
53
55
|
<a class="top-link" href="#/projects">Projects</a>
|
|
54
56
|
<a class="top-link" href="#/models">Models</a>
|
|
55
57
|
<a class="top-link" href="#/worktrees">Worktrees</a>
|
|
58
|
+
<a class="top-link" href="#/disk">Disk</a>
|
|
56
59
|
<a class="top-link" href="#/settings">Settings</a>
|
|
57
60
|
</nav>
|
|
58
61
|
<button class="top-search" type="button" data-jump title="Jump to a run, task, project, model or command (/)"><span class="top-search-label"><span>Search</span></span> <kbd>Ctrl K</kbd></button>
|