@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.
Files changed (78) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +1 -0
  3. package/SKILL.md +16 -2
  4. package/VERSION +1 -1
  5. package/docs/artifacts.md +25 -1
  6. package/docs/commands.md +81 -14
  7. package/docs/decomposed-runs.md +114 -1
  8. package/docs/development.md +2 -1
  9. package/docs/forge-ui.md +84 -15
  10. package/docs/memory.md +25 -4
  11. package/docs/models.md +8 -0
  12. package/docs/reviews.md +122 -0
  13. package/forge +20 -3
  14. package/package.json +2 -1
  15. package/references/dataset.md +20 -1
  16. package/references/decompose.md +621 -33
  17. package/references/harnesses.md +18 -3
  18. package/references/planning.md +43 -14
  19. package/references/ui.md +53 -6
  20. package/registry.tsv +8 -3
  21. package/scripts/forge-brief.py +88 -3
  22. package/scripts/forge-compare.py +4 -3
  23. package/scripts/forge-contract.py +202 -27
  24. package/scripts/forge-control.py +117 -5
  25. package/scripts/forge-dispatch.sh +34 -5
  26. package/scripts/forge-group.py +496 -0
  27. package/scripts/forge-groups.py +89 -0
  28. package/scripts/forge-handoff.py +1128 -0
  29. package/scripts/forge-lib-group.sh +641 -0
  30. package/scripts/forge-lib-plans.sh +339 -3
  31. package/scripts/forge-lib-task.sh +197 -4
  32. package/scripts/forge-memory.sh +245 -3
  33. package/scripts/forge-parallel.sh +715 -34
  34. package/scripts/forge-planner.py +104 -8
  35. package/scripts/forge-route.py +190 -12
  36. package/scripts/forge-runs.py +9 -5
  37. package/scripts/forge-schedule.py +354 -45
  38. package/scripts/forge-solo.sh +2 -0
  39. package/scripts/forge-worktrees.py +243 -0
  40. package/scripts/forge_brief/__init__.py +294 -50
  41. package/scripts/forge_brief/answers.py +58 -11
  42. package/scripts/forge_brief/proposals.py +1630 -0
  43. package/scripts/forge_dataset/efforts.py +4 -3
  44. package/scripts/forge_dataset/export.py +24 -12
  45. package/scripts/forge_dataset/facts.py +5 -3
  46. package/scripts/forge_dataset/forecast.py +8 -18
  47. package/scripts/forge_dataset/harvest.py +204 -9
  48. package/scripts/forge_dataset/history.py +11 -6
  49. package/scripts/forge_dataset/importer.py +65 -1
  50. package/scripts/forge_dataset/names.py +66 -0
  51. package/scripts/forge_dataset/reviewers.py +5 -2
  52. package/scripts/forge_dataset/risk.py +6 -3
  53. package/scripts/forge_dataset/routing.py +6 -1
  54. package/scripts/forge_groups/__init__.py +308 -0
  55. package/scripts/forge_groups/attribute.py +289 -0
  56. package/scripts/forge_groups/review.py +286 -0
  57. package/scripts/forge_owner.py +152 -0
  58. package/scripts/forge_side/__init__.py +12 -7
  59. package/ui/docs/api.md +173 -17
  60. package/ui/forge_ui/control.py +361 -2
  61. package/ui/forge_ui/executions.py +8 -1
  62. package/ui/forge_ui/export.py +31 -4
  63. package/ui/forge_ui/groups.py +264 -0
  64. package/ui/forge_ui/models.py +70 -8
  65. package/ui/forge_ui/reader.py +262 -19
  66. package/ui/forge_ui/server.py +4 -0
  67. package/ui/forge_ui/static/app.js +93 -13
  68. package/ui/forge_ui/static/briefview.js +350 -47
  69. package/ui/forge_ui/static/diffview.js +86 -1
  70. package/ui/forge_ui/static/groupsview.js +332 -0
  71. package/ui/forge_ui/static/index.html +1 -0
  72. package/ui/forge_ui/static/panel.js +127 -7
  73. package/ui/forge_ui/static/projectsview.js +189 -10
  74. package/ui/forge_ui/static/runmodel.js +14 -3
  75. package/ui/forge_ui/static/storageview.js +91 -10
  76. package/ui/forge_ui/static/style.css +79 -5
  77. package/ui/forge_ui/static/worktreesview.js +233 -12
  78. package/ui/forge_ui/storage.py +14 -0
@@ -21,7 +21,7 @@ window.ForgeApp = (() => {
21
21
  settings: false, lastKey: null, settingsRun: null, settingsPickedAt: null, settingsView: null,
22
22
  models: false, modelsData: null, modelsText: null, modelsError: null, reviewerOutcomes: null, modelsPrefs: store.get('models', {}),
23
23
  files: new Map(), findingsCount: new Map(), filesPrefs: store.get('files', {}), runSort: store.get('run-sort', 'updated'), tablePrefs: store.get('tables', {}),
24
- findings: new Map() };
24
+ findings: new Map(), groupId: null };
25
25
  state.stageMode = state.mode === 'exec' ? 'exec' : 'plan'; // the stage's own mode, kept while Files is shown
26
26
  if (state.mode === 'files' && !window.ForgeFiles) state.mode = state.stageMode;
27
27
  const $ = id => document.getElementById(id);
@@ -49,6 +49,7 @@ window.ForgeApp = (() => {
49
49
  if (!sel) return base;
50
50
  const e = encodeURIComponent;
51
51
  if (sel.kind === 'task') return `${base}/tasks/${e(sel.id)}`;
52
+ if (sel.kind === 'group') return `${base}/group/${e(sel.id)}`;
52
53
  if (sel.kind === 'execution') return sel.task ? `${base}/tasks/${e(sel.task)}/executions/${e(sel.exec)}` : `${base}/executions/${e(sel.exec)}`;
53
54
  if (sel.kind === 'final') return `${base}/final-review${sel.name ? '/' + e(sel.name) : ''}`;
54
55
  if (sel.kind === 'adoption') return `${base}/adoptions/${e(sel.name)}`;
@@ -88,6 +89,7 @@ window.ForgeApp = (() => {
88
89
  const d = decodeURIComponent, rest = m[2] || '';
89
90
  if (/^\/findings\/?$/.test(rest)) return { key: d(m[1]), sel: null, findings: true };
90
91
  let sel = null, r;
92
+ if ((r = rest.match(/^\/group\/([^/]+)\/?$/))) return { key: d(m[1]), sel: null, group: d(r[1]) };
91
93
  if ((r = rest.match(/^\/tasks\/([^/]+)\/diff(?:\/(?!file\/|finding\/)([^/]+))?(?:\/finding\/([^/]+))?(?:\/file\/(.+?))?\/?$/))) return { key: d(m[1]), sel: { kind: 'task', id: d(r[1]) }, diff: { kind: 'task', task: d(r[1]), source: r[2] ? d(r[2]) : 'current', finding: r[3] ? d(r[3]) : null, file: r[4] ? d(r[4]) : null } };
92
94
  if ((r = rest.match(/^\/tasks\/([^/]+)\/fractal\/([^/]+)\/diff(?:\/file\/(.+?))?\/?$/))) return { key: d(m[1]), sel: { kind: 'task', id: d(r[1]) }, diff: { kind: 'fractal', task: d(r[1]), node: d(r[2]), file: r[3] ? d(r[3]) : null } };
93
95
  if ((r = rest.match(/^\/final-review\/([^/]+)\/diff(?:\/finding\/([^/]+))?(?:\/file\/(.+?))?\/?$/))) return { key: d(m[1]), sel: { kind: 'final', name: d(r[1]) }, diff: { kind: 'final', name: d(r[1]), finding: r[2] ? d(r[2]) : null, file: r[3] ? d(r[3]) : null } };
@@ -116,7 +118,7 @@ window.ForgeApp = (() => {
116
118
  function link(text, key, sel) { const a = el('a', text); a.href = hashFor(key, sel); return a; }
117
119
 
118
120
  const statuses = new Set(['merged', 'pass', 'running', 'pending', 'fail', 'error', 'infra',
119
- 'timeout', 'unknown', 'invalidated', 'blocked', 'interrupted', 'nochanges', 'conflict', 'accepted', 'outdated', 'needs_input', 'needs_decision']);
121
+ 'timeout', 'unknown', 'invalidated', 'blocked', 'interrupted', 'nochanges', 'conflict', 'accepted', 'outdated', 'needs_input', 'needs_decision', 'implemented']);
120
122
  function chip(value, cls) {
121
123
  const status = String(cls || value || 'unknown').toLowerCase();
122
124
  return el('span', value || '—', 'chip st-' + (statuses.has(status) ? status : 'unknown'));
@@ -580,7 +582,7 @@ window.ForgeApp = (() => {
580
582
  main.replaceChildren();
581
583
  const v = el('section', undefined, 'worktrees-view disk-view'); v.id = 'disk-view'; main.append(v);
582
584
  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; },
585
+ runHref: key => '#/runs/' + encodeURIComponent(key),
584
586
  tablePrefs: id => state.tablePrefs[id], saveTablePrefs: (id, p) => { state.tablePrefs = { ...state.tablePrefs, [id]: p }; store.set('tables', state.tablePrefs); },
585
587
  });
586
588
  }
@@ -826,7 +828,7 @@ window.ForgeApp = (() => {
826
828
  if (solo) where.append(document.createTextNode(' · solo run'));
827
829
  // the describer: each state's count, the wall time so far, and how long since anything moved
828
830
  const desc = el('span', undefined, 'describer');
829
- for (const [s, n] of Object.entries(run.counts || {})) { const d = el('span', undefined, 'desc-count'); d.append(el('i', undefined, 'lamp st-' + String(s).toLowerCase()), document.createTextNode(` ${s} ${n}`)); desc.append(d); }
831
+ for (const [s, n] of Object.entries(run.counts || {})) { const d = el('span', undefined, 'desc-count'); d.append(el('i', undefined, 'lamp st-' + String(s).toLowerCase()), document.createTextNode(` ${RM.statusLabel(s)} ${n}`)); desc.append(d); }
830
832
  const r = RM.timeRange(run, now());
831
833
  if (r) desc.append(el('span', `WALL ${RM.fmtDur(r.end - r.start)}`, 'dim'));
832
834
  const upd = el('span', relative(run.updated).replace(/^updated /, ''), 'dim updated'); upd.title = 'Last activity ' + time(run.updated);
@@ -850,12 +852,21 @@ window.ForgeApp = (() => {
850
852
  return [
851
853
  { id: 'id', label: 'ID', mono: true, value: t => t.id, cell: t => link(t.id, run.key, { kind: 'task', id: t.id }) },
852
854
  { id: 'title', label: 'Title', value: t => t.title },
855
+ // the task's group, only while this run has groups: a run without groups.tsv keeps the columns it had
856
+ ...(list(run.groups).length && window.ForgeGroups ? [{ id: 'group', label: 'Group', value: t => t.group || null,
857
+ cell: t => t.group ? window.ForgeGroups.taskChip(t.group, hashFor(run.key, { kind: 'group', id: t.group })) : '—' }] : []),
853
858
  // the one-sentence summary, only while the run's summaries are on (#133 B): the column is not there otherwise
854
859
  ...(summariesOn(run) ? [{ id: 'summary', label: 'Summary', title: 'The one-sentence summary of each task (summaries are on for this run)', cls: 'sum-col',
855
860
  value: t => t.summary && t.summary.sentence || null, cell: t => t.summary && t.summary.sentence || '—' }] : []),
856
861
  { id: 'difficulty', label: 'Difficulty', value: t => DIFF_RANK[t.difficulty] ?? null, cell: t => display(t.difficulty) },
857
862
  { 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) },
858
- { id: 'status', label: 'Status', value: t => RM.taskStatus(t), cell: t => chip(RM.statusText(t), RM.taskStatus(t)) },
863
+ { id: 'status', label: 'Status', value: t => RM.taskStatus(t), cell: t => {
864
+ const mark = window.ForgeBrief && window.ForgeBrief.affectedBadge && window.ForgeBrief.affectedBadge(t);
865
+ if (!mark) return chip(RM.statusText(t), RM.taskStatus(t));
866
+ const row = el('span', undefined, 'brief-affected-row');
867
+ row.append(chip(RM.statusText(t), RM.taskStatus(t)), mark);
868
+ return row;
869
+ } },
859
870
  ...(window.ForgeChecks ? [{ id: 'now', label: 'Now', title: 'What a running task is doing, or why one that is not running waits',
860
871
  value: t => window.ForgeChecks.nowRank(t), cell: t => window.ForgeChecks.cell(t, now(), { hash: s => hashFor(run.key, s) }) }] : []),
861
872
  { id: 'dwarf', label: 'Dwarf', value: t => t.dwarf, cell: t => window.ForgeIcons.modelPlate(t.dwarf) },
@@ -1067,6 +1078,13 @@ window.ForgeApp = (() => {
1067
1078
  const tasks = el('div', undefined, 'run-tasks'); tasks.id = 'run-tasks';
1068
1079
  box.append(Shell.head('tasks', 'Tasks', ''), questions, switchRow, tasks, Shell.splitter('tasks'));
1069
1080
  view.append(box);
1081
+ // After the tasks module. Hidden until the run has groups, so a run without them lays out as before.
1082
+ const groups = el('section', undefined, 'module groups-module');
1083
+ groups.id = 'run-groups'; groups.hidden = true; groups.setAttribute('aria-label', 'Groups');
1084
+ view.append(groups);
1085
+ view.style.setProperty('--groups-h', '0px');
1086
+ // A width change (the side panels, the window) can rewrap the rows; republish the height then.
1087
+ if (window.ResizeObserver) new ResizeObserver(() => syncGroupsHeight(groups, view)).observe(groups);
1070
1088
  }
1071
1089
  document.body.classList.toggle('no-tasks', run.kind === 'solo');
1072
1090
  ensureStage();
@@ -1075,23 +1093,70 @@ window.ForgeApp = (() => {
1075
1093
  renderSummarySwitch(run);
1076
1094
  renderQuestions(run);
1077
1095
  renderTable(run);
1096
+ renderGroups(run);
1078
1097
  announce(run);
1079
1098
  }
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.
1099
+ // The groups block. Nothing in the host, and the run grid unchanged, when summary() returns null.
1100
+ // --groups-h is the block's border box, so the immersive strip and stage padding sit above it.
1101
+ function syncGroupsHeight(host, view) {
1102
+ if (!host || !view) return;
1103
+ const shown = !host.hidden && host.getClientRects().length > 0;
1104
+ const next = (shown ? host.getBoundingClientRect().height : 0) + 'px';
1105
+ if (view.style.getPropertyValue('--groups-h') !== next) view.style.setProperty('--groups-h', next);
1106
+ }
1107
+ function renderGroups(run) {
1108
+ const host = $('run-groups'), view = $('run-view');
1109
+ if (!host || !view) return;
1110
+ const block = window.ForgeGroups && window.ForgeGroups.summary(run, {
1111
+ groupHref: id => hashFor(run.key, { kind: 'group', id }),
1112
+ taskHref: id => hashFor(run.key, { kind: 'task', id }),
1113
+ });
1114
+ host.hidden = !block;
1115
+ view.classList.toggle('has-groups', !!block);
1116
+ if (!block) { host.replaceChildren(); syncGroupsHeight(host, view); return; }
1117
+ preserve(host, () => { host.append(block); syncGroupsHeight(host, view); });
1118
+ }
1119
+ // #/runs/<key>/group/<gid>. The run stays cached; the group payload is fetched by the view.
1120
+ function renderGroup() {
1121
+ const main = $('main'), gid = state.groupId, run = state.cache.get(state.key)?.data;
1122
+ if (main.dataset.view !== 'group' || main.dataset.run !== state.key || main.dataset.group !== gid) {
1123
+ setView(main, 'group'); main.dataset.run = state.key; main.dataset.group = gid;
1124
+ main.replaceChildren();
1125
+ const view = el('section', undefined, 'group-view'); view.id = 'group-view'; main.append(view);
1126
+ }
1127
+ const host = $('group-view');
1128
+ if (!window.ForgeGroups) { host.replaceChildren(el('p', 'Groups are not available in this page.', 'empty')); return; }
1129
+ if (run) { host.dataset.run = state.key; host.dataset.group = gid; }
1130
+ window.ForgeGroups.render(host, {
1131
+ key: state.key, gid, run, plan: run && run.path, back: '#/runs/' + encodeURIComponent(state.key),
1132
+ taskHref: id => hashFor(state.key, { kind: 'task', id }),
1133
+ transcriptHref: execution => execution && execution.id ? convoHash(state.key, { kind: 'execution', exec: execution.id }) : null,
1134
+ fetchJSON: path => fetchJSON(path).then(r => r.data),
1135
+ });
1136
+ }
1137
+ // Open brief questions (#135), flagged first and then by the schedule projection, plus proposals (#136).
1138
+ // Hidden with the tasks module when that panel is folded, and hidden entirely when brief is off or there
1139
+ // is nothing to show. A proposal keeps the host open after every question is answered.
1082
1140
  function renderQuestions(run) {
1083
1141
  const host = $('run-questions');
1084
1142
  if (!host) return;
1085
1143
  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; }
1144
+ const open = show ? window.ForgeBrief.openQuestions(run) : [];
1145
+ const proposals = show ? list(run.proposals).filter(item => item && typeof item === 'object') : [];
1146
+ if (!open.length && !proposals.length) {
1147
+ host.hidden = true;
1148
+ host.replaceChildren();
1149
+ delete host.dataset.proposals;
1150
+ return;
1151
+ }
1089
1152
  host.hidden = false;
1153
+ host.setAttribute('aria-label', proposals.length ? 'Questions and proposals' : 'Open questions');
1090
1154
  const clock = now();
1091
1155
  const projections = RM.projectSchedule(run, { now: clock });
1092
1156
  preserve(host, () => window.ForgeBrief.renderList(host, {
1093
1157
  run, projections, now: clock,
1094
1158
  href: id => hashFor(run.key, { kind: 'task', id }),
1159
+ refresh: () => loadRun(run.key),
1095
1160
  }));
1096
1161
  }
1097
1162
  function renderMain() {
@@ -1104,6 +1169,7 @@ window.ForgeApp = (() => {
1104
1169
  if (state.disk) { renderDisk(); return; }
1105
1170
  if (state.projects) { renderProjects(); return; }
1106
1171
  if (state.key && state.findingsPage) { renderFindings(); return; }
1172
+ if (state.key && state.groupId) { renderGroup(); return; }
1107
1173
  if (!state.key) { renderMap(); return; }
1108
1174
  const cached = state.cache.get(state.key);
1109
1175
  if (cached) renderRun(cached.data);
@@ -1113,7 +1179,8 @@ window.ForgeApp = (() => {
1113
1179
  const prev = state.lastStatuses.get(run.key), cur = new Map(list(run.tasks).map(t => [t.id, t.status]));
1114
1180
  state.lastStatuses.set(run.key, cur);
1115
1181
  if (!prev || Date.now() - state.announced < 10000) return;
1116
- const changes = [...cur].filter(([id, s]) => prev.has(id) && prev.get(id) !== s).map(([id, s]) => `${id} ${prev.get(id).toLowerCase()} → ${s.toLowerCase()}`);
1182
+ const word = s => { const label = RM.statusLabel(s); return label === String(s) ? String(s).toLowerCase() : label; };
1183
+ const changes = [...cur].filter(([id, s]) => prev.has(id) && prev.get(id) !== s).map(([id, s]) => `${id} ${word(prev.get(id))} → ${word(s)}`);
1117
1184
  if (!changes.length) return;
1118
1185
  state.announced = Date.now();
1119
1186
  $('live').textContent = changes.slice(0, 5).join('; ');
@@ -1167,9 +1234,19 @@ window.ForgeApp = (() => {
1167
1234
  return request('/api/runs/' + encodeURIComponent(key), result => {
1168
1235
  const changed = state.cache.get(key)?.text !== result.text;
1169
1236
  state.cache.set(key, result);
1170
- if (state.key === key && changed && !state.findingsPage) renderRun(result.data);
1237
+ if (state.key === key && changed && !state.findingsPage) {
1238
+ if (state.groupId) renderGroup(); else renderRun(result.data);
1239
+ }
1171
1240
  }, 'Could not refresh run', error => {
1172
1241
  if (state.key !== key || state.cache.has(key) || state.findingsPage) return;
1242
+ if (state.groupId) {
1243
+ if (error.status === 404) state.errors.delete('/api/runs/' + encodeURIComponent(key));
1244
+ const host = $('group-view');
1245
+ if (host) host.replaceChildren(el('p', error.status === 404
1246
+ ? 'Waiting for this run to appear… checking again while this tab is visible. If its directory was removed, pick another run.'
1247
+ : 'Could not load this run. Select another run, or leave refresh enabled to retry.', 'empty'));
1248
+ return;
1249
+ }
1173
1250
  if (error.status === 404) state.errors.delete('/api/runs/' + encodeURIComponent(key));
1174
1251
  setView($('main'), 'waiting');
1175
1252
  $('main').replaceChildren(el('p', error.status === 404 ?
@@ -1184,7 +1261,8 @@ window.ForgeApp = (() => {
1184
1261
  history.replaceState(null, '', '#/runs/' + encodeURIComponent(SNAP.meta.key));
1185
1262
  parsed = parseHash(location.hash);
1186
1263
  }
1187
- const keyChanged = parsed.key !== state.key || (!!state.findingsPage && !parsed.findings); // the findings page replaced the run's DOM
1264
+ const leavingGroup = !!state.groupId && state.groupId !== (parsed.group || null);
1265
+ const keyChanged = parsed.key !== state.key || (!!state.findingsPage && !parsed.findings) || leavingGroup; // findings and the group page replace the run's DOM
1188
1266
  state.key = parsed.key;
1189
1267
  const selWas = JSON.stringify(state.sel || null);
1190
1268
  state.sel = parsed.sel;
@@ -1201,6 +1279,7 @@ window.ForgeApp = (() => {
1201
1279
  state.projects = parsed.projects && window.ForgeProjects && !SNAP ? parsed.projects : null;
1202
1280
  if (parsed.key) state.lastKey = parsed.key;
1203
1281
  state.findingsPage = !!parsed.findings && !!window.ForgeFindings;
1282
+ state.groupId = parsed.group && window.ForgeGroups ? parsed.group : null;
1204
1283
  if (state.cloud && state.cloud.model) { // a model's runs: the cloud, filtered to it
1205
1284
  cloudFilter({ models: { aliases: [state.cloud.model], role: 'any' } });
1206
1285
  history.replaceState(null, '', '#/cloud'); state.cloud.model = null;
@@ -1220,6 +1299,7 @@ window.ForgeApp = (() => {
1220
1299
  if (state.disk) { renderDisk(); return; }
1221
1300
  if (state.projects) { renderProjects(); return; }
1222
1301
  if (state.key && state.findingsPage) { renderFindings(); return; }
1302
+ if (state.key && state.groupId) { renderGroup(); loadRun(state.key); return; }
1223
1303
  if (!state.key) { renderMap(); return; }
1224
1304
  const cached = state.cache.get(state.key);
1225
1305
  if (cached) {