@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.
Files changed (93) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +1 -0
  3. package/SKILL.md +19 -2
  4. package/VERSION +1 -1
  5. package/docs/artifacts.md +25 -1
  6. package/docs/commands.md +217 -18
  7. package/docs/decomposed-runs.md +114 -1
  8. package/docs/development.md +2 -1
  9. package/docs/forge-ui.md +138 -18
  10. package/docs/memory.md +25 -4
  11. package/docs/models.md +8 -0
  12. package/docs/reviews.md +122 -0
  13. package/forge +26 -3
  14. package/package.json +2 -1
  15. package/references/dataset.md +20 -1
  16. package/references/decompose.md +641 -41
  17. package/references/harnesses.md +18 -3
  18. package/references/memory.md +30 -5
  19. package/references/planning.md +43 -14
  20. package/references/ui.md +53 -6
  21. package/registry.tsv +8 -3
  22. package/scripts/forge-brief.py +88 -3
  23. package/scripts/forge-compare.py +4 -3
  24. package/scripts/forge-contract.py +202 -27
  25. package/scripts/forge-control.py +117 -5
  26. package/scripts/forge-dispatch.sh +34 -5
  27. package/scripts/forge-findings.py +675 -0
  28. package/scripts/forge-group.py +496 -0
  29. package/scripts/forge-groups.py +89 -0
  30. package/scripts/forge-handoff.py +1128 -0
  31. package/scripts/forge-issues.py +228 -97
  32. package/scripts/forge-lib-group.sh +641 -0
  33. package/scripts/forge-lib-plans.sh +339 -3
  34. package/scripts/forge-lib-task.sh +197 -4
  35. package/scripts/forge-memory.sh +711 -17
  36. package/scripts/forge-parallel.sh +721 -38
  37. package/scripts/forge-planner.py +104 -8
  38. package/scripts/forge-route.py +190 -12
  39. package/scripts/forge-runs.py +9 -5
  40. package/scripts/forge-schedule.py +417 -52
  41. package/scripts/forge-solo.sh +2 -0
  42. package/scripts/forge-sweep.py +199 -44
  43. package/scripts/forge-worktrees.py +243 -0
  44. package/scripts/forge_brief/__init__.py +294 -50
  45. package/scripts/forge_brief/answers.py +58 -11
  46. package/scripts/forge_brief/proposals.py +1630 -0
  47. package/scripts/forge_dataset/efforts.py +4 -3
  48. package/scripts/forge_dataset/export.py +24 -12
  49. package/scripts/forge_dataset/facts.py +5 -3
  50. package/scripts/forge_dataset/forecast.py +8 -18
  51. package/scripts/forge_dataset/harvest.py +204 -9
  52. package/scripts/forge_dataset/history.py +11 -6
  53. package/scripts/forge_dataset/importer.py +65 -1
  54. package/scripts/forge_dataset/names.py +66 -0
  55. package/scripts/forge_dataset/reviewers.py +5 -2
  56. package/scripts/forge_dataset/risk.py +6 -3
  57. package/scripts/forge_dataset/routing.py +6 -1
  58. package/scripts/forge_findings/__init__.py +17 -0
  59. package/scripts/forge_findings/apply.py +441 -0
  60. package/scripts/forge_findings/status.py +43 -0
  61. package/scripts/forge_findings/store.py +583 -0
  62. package/scripts/forge_findings/tags.py +53 -0
  63. package/scripts/forge_findings/triage.py +603 -0
  64. package/scripts/forge_groups/__init__.py +308 -0
  65. package/scripts/forge_groups/attribute.py +289 -0
  66. package/scripts/forge_groups/review.py +286 -0
  67. package/scripts/forge_identity.py +327 -0
  68. package/scripts/forge_memory_list.py +7 -3
  69. package/scripts/forge_owner.py +152 -0
  70. package/scripts/forge_side/__init__.py +228 -38
  71. package/ui/docs/api.md +303 -29
  72. package/ui/forge_ui/control.py +1018 -6
  73. package/ui/forge_ui/executions.py +8 -1
  74. package/ui/forge_ui/export.py +31 -4
  75. package/ui/forge_ui/groups.py +264 -0
  76. package/ui/forge_ui/models.py +70 -8
  77. package/ui/forge_ui/projects.py +209 -22
  78. package/ui/forge_ui/reader.py +262 -19
  79. package/ui/forge_ui/server.py +4 -0
  80. package/ui/forge_ui/static/app.js +93 -13
  81. package/ui/forge_ui/static/briefview.js +350 -47
  82. package/ui/forge_ui/static/diffview.js +86 -1
  83. package/ui/forge_ui/static/findingsactions.js +201 -0
  84. package/ui/forge_ui/static/groupsview.js +332 -0
  85. package/ui/forge_ui/static/index.html +3 -0
  86. package/ui/forge_ui/static/panel.js +127 -7
  87. package/ui/forge_ui/static/projectsview.js +764 -30
  88. package/ui/forge_ui/static/runmodel.js +14 -3
  89. package/ui/forge_ui/static/storageview.js +91 -10
  90. package/ui/forge_ui/static/style.css +138 -5
  91. package/ui/forge_ui/static/triageview.js +423 -0
  92. package/ui/forge_ui/static/worktreesview.js +233 -12
  93. package/ui/forge_ui/storage.py +14 -0
@@ -12,7 +12,7 @@ window.ForgePanel = (() => {
12
12
  const num = v => typeof v === 'number' && Number.isFinite(v) ? v : null;
13
13
  const display = v => v === null || v === undefined || v === '' ? '—' : typeof v === 'object' ? JSON.stringify(v, null, 2) : String(v);
14
14
  const STATUSES = new Set(['merged', 'pass', 'running', 'pending', 'fail', 'error', 'infra', 'timeout', 'unknown', 'invalidated', 'blocked',
15
- 'interrupted', 'nochanges', 'conflict', 'accepted', 'none', 'outdated', 'needs_input', 'needs_decision', 'waiting']);
15
+ 'interrupted', 'nochanges', 'conflict', 'accepted', 'none', 'outdated', 'needs_input', 'needs_decision', 'waiting', 'implemented']);
16
16
  const cache = new Map(); // path → {data, error, at}
17
17
  const shownText = new Map(); // task id → which header text is open (prompt, approach, criteria)
18
18
  function el(tag, text, className) {
@@ -89,8 +89,9 @@ window.ForgePanel = (() => {
89
89
  const s = section(host, 'Controls');
90
90
  muted(s, 'Read-only: this page cannot change the run.');
91
91
  }
92
- // A task that stopped NEEDS_INPUT: the question it asked, and the command that answers it. forge-ui shows the
93
- // command and never runs it; only the user's answer, passed to retry, resumes the task.
92
+ // A task that stopped NEEDS_INPUT: the question it asked, and the command that answers it. The copy stays in
93
+ // every mode. When controls are on, a plan (not a solo run) can send the answer from here: that post is not
94
+ // destructive, so it needs no confirm. A solo run still shows only the question.
94
95
  const shellWord = s => /^[\w@%+=:,./-]+$/.test(s) ? s : "'" + String(s).replace(/'/g, "'\\''") + "'";
95
96
  // An INFRA task: why its dispatch stopped (the cause, the stage, the model it ran on), when its limit resets, and
96
97
  // whether the user must act: the reader's answer from forge's cause table (after the run too), else a live
@@ -118,6 +119,94 @@ window.ForgePanel = (() => {
118
119
  const line = el('div', undefined, 'waiting-cmd');
119
120
  line.append(el('pre', text, 'cmd'), copy);
120
121
  s.append(line);
122
+ const U = window.ForgeUI;
123
+ if (!U || !U.controlsEnabled) return;
124
+ // In the tree before controlsEnabled answers, with data-hold. A poll rebuilds this inspector
125
+ // through controls.js hold(), which only puts back a [data-hold][data-editing] node that the
126
+ // new tree already contains. Appending the box from the promise leaves the draft behind.
127
+ const box = answerField(ctx, task, U);
128
+ s.append(box);
129
+ U.controlsEnabled().then(on => {
130
+ if (!s.isConnected || on) return;
131
+ dropHold(s, 'answer:');
132
+ });
133
+ }
134
+ // The draft of one waiting task. data-editing is set while the field is in use, so hold() keeps
135
+ // this node (its text and its focus) instead of the empty one the next draw builds.
136
+ function answerField(ctx, task, U) {
137
+ const run = ctx.run || {};
138
+ const box = el('div', undefined, 'waiting-cmd');
139
+ box.dataset.hold = 'answer:' + run.key + ':' + task.id;
140
+ const field = el('textarea');
141
+ field.setAttribute('aria-label', 'Answer');
142
+ field.rows = 3;
143
+ field.maxLength = 8000;
144
+ field.autocomplete = 'off';
145
+ const send = el('button', 'Send answer'); send.type = 'button';
146
+ const msgs = el('div');
147
+ const mark = () => { box.dataset.editing = '1'; };
148
+ field.addEventListener('focus', mark);
149
+ field.addEventListener('input', mark);
150
+ field.addEventListener('blur', () => {
151
+ if (box.dataset.busy) return;
152
+ if (!String(field.value || '').trim()) delete box.dataset.editing;
153
+ });
154
+ send.addEventListener('click', () => { sendWaitingAnswer(box, field, send, msgs, ctx, task, U); });
155
+ box.append(field, send, msgs);
156
+ return box;
157
+ }
158
+ function dropHold(root, prefix) {
159
+ const pending = [root];
160
+ while (pending.length) {
161
+ const node = pending.pop();
162
+ for (const child of [...(node.children || [])]) {
163
+ if (child.dataset && String(child.dataset.hold || '').startsWith(prefix)) child.remove();
164
+ else pending.push(child);
165
+ }
166
+ }
167
+ }
168
+ // What the answer endpoint means for the page. `live` is the scheduler's word; anything else is the error
169
+ // sentence outcomeText already uses for every other write.
170
+ function answerLive(answer) {
171
+ if (!answer || typeof answer !== 'object' || answer.ok === false) return null;
172
+ const data = answer.data && typeof answer.data === 'object' ? answer.data : answer;
173
+ if (data.live === true) return true;
174
+ if (data.live === false) return false;
175
+ return null;
176
+ }
177
+ function answerOutcome(answer) {
178
+ const live = answerLive(answer);
179
+ if (live === true) return 'Queued: the running scheduler resumes the task';
180
+ if (live === false) return 'Prepared: the next run dispatches the task';
181
+ const say = window.ForgeUI && window.ForgeUI.outcomeText;
182
+ if (typeof say === 'function') return say(answer).text;
183
+ const r = answer || {};
184
+ return r.detail || r.error || 'failed';
185
+ }
186
+ async function sendWaitingAnswer(box, field, send, msgs, ctx, task, U) {
187
+ if (box.dataset.busy) return;
188
+ const text = String(field.value || '').trim();
189
+ if (!text) {
190
+ if (U && U.outcome) U.outcome(msgs, { ok: false, status: 400, error: 'invalid', detail: 'the answer is empty' });
191
+ return;
192
+ }
193
+ box.dataset.editing = '1';
194
+ box.dataset.busy = '1';
195
+ send.disabled = true;
196
+ const run = ctx.run || {};
197
+ const path = '/api/runs/' + encodeURIComponent(run.key) + '/tasks/' + encodeURIComponent(task.id) + '/answer';
198
+ let res = { ok: false, error: 'unavailable', detail: 'this page cannot send' };
199
+ try {
200
+ if (U && U.post) res = await U.post(path, { text });
201
+ } catch (_) {
202
+ res = { ok: false, error: 'failed', detail: 'could not send' };
203
+ }
204
+ if (!box.isConnected) return;
205
+ delete box.dataset.busy;
206
+ send.disabled = false;
207
+ if (!U || !U.outcome) return;
208
+ if (res && res.ok) U.outcome(msgs, res, answerOutcome(res));
209
+ else U.outcome(msgs, res);
121
210
  }
122
211
  // A task that stopped NEEDS_DECISION: why the retry policy stopped it, its attempts against the cap, the ledger of its
123
212
  // reviews, and the decision text, which holds the commands to run. forge-ui shows the commands and never runs them.
@@ -364,6 +453,26 @@ window.ForgePanel = (() => {
364
453
  if (!solo) details(host, 'Waves', list(run.waves).map((ids, i) => `${i + 1}: ${list(ids).join(', ')}`).join('\n') || '—', 'waves');
365
454
  if (run.verification && run.verification.log_tail != null) details(host, 'Verification output', run.verification.log_tail, 'verification-output');
366
455
  }
456
+ // `after` is the predecessor; `followed_by` the plans that name this run. Run ids read as the
457
+ // other ids on the page (mono). The hash is the other run's page, the same shape app.js uses.
458
+ function chainRows(run) {
459
+ const rows = [];
460
+ const prev = run.after;
461
+ if (prev && typeof prev === 'object') {
462
+ const label = prev.run_id || prev.key;
463
+ if (label) rows.push(['After', link(label, '#/runs/' + encodeURIComponent(prev.key)), true]);
464
+ }
465
+ const next = list(run.followed_by).filter(item => item && (item.run_id || item.key));
466
+ if (next.length) {
467
+ const span = el('span');
468
+ next.forEach((item, i) => {
469
+ if (i) span.append(document.createTextNode(', '));
470
+ span.append(link(item.run_id || item.key, '#/runs/' + encodeURIComponent(item.key)));
471
+ });
472
+ rows.push(['Followed by', span, true]);
473
+ }
474
+ return rows;
475
+ }
367
476
  function runView(host, ctx) {
368
477
  const run = ctx.run, now = ctx.now;
369
478
  const tr = RM.timeRange(run, now);
@@ -385,10 +494,13 @@ window.ForgePanel = (() => {
385
494
  }
386
495
  const f = section(host, 'Finish');
387
496
  const F = RM.finishState(run);
497
+ // A chained plan: the one it starts from, and the ones that start from it. Each links to that
498
+ // run's page. A run in neither chain keeps this block as it was.
499
+ const chain = chainRows(run);
388
500
  if (run.kind === 'solo') {
389
501
  const soloTask = list(run.tasks)[0];
390
502
  const verdict = soloTask ? RM.taskVerdict(soloTask) : { text: null, status: 'unknown' };
391
- fields(f, [['Verdict', chip(verdict.text, verdict.status)]]);
503
+ fields(f, [['Verdict', chip(verdict.text, verdict.status)], ...chain]);
392
504
  }
393
505
  else {
394
506
  const finalSel = { kind: 'final' }, openFinal = () => ctx.onSelect(finalSel);
@@ -400,7 +512,7 @@ window.ForgePanel = (() => {
400
512
  } else finalValue = link(F.final.status === 'NONE' ? 'not requested' : F.final.status, ctx.hash(finalSel), openFinal);
401
513
  fields(f, [['Integration', link(`${F.integration.merged}/${F.integration.total} merged`, ctx.hash({ kind: 'integration' }), () => ctx.onSelect({ kind: 'integration' }))],
402
514
  ['Verification', link(F.verification.status, ctx.hash({ kind: 'verification' }), () => ctx.onSelect({ kind: 'verification' }))],
403
- ['Final review', finalValue]]);
515
+ ['Final review', finalValue], ...chain]);
404
516
  const attribution = RM.attributionLine(run.attribution);
405
517
  if (attribution) f.append(el('p', attribution, 'warn'));
406
518
  if (F.final.status === 'OUTDATED') muted(f, RM.reviewSinceLine(F.final));
@@ -703,10 +815,18 @@ window.ForgePanel = (() => {
703
815
  const chips = el('div', undefined, 'chips');
704
816
  if (RM.taskStatus(task) === 'ACCEPTED') chips.append(acceptedChip(task));
705
817
  else {
706
- chips.append(RM.taskStatus(task) === 'INFRA' ? chip(RM.statusText(task), 'infra') : chip(RM.taskStatus(task)));
818
+ chips.append(chip(RM.statusText(task), String(RM.taskStatus(task)).toLowerCase()));
707
819
  if (task.accepted === true) chips.append(acceptedChip(task));
708
820
  else if (task.verdict) chips.append(chip('review ' + task.verdict, task.verdict.toLowerCase()));
709
821
  }
822
+ if (task.group && window.ForgeGroups) {
823
+ const group = window.ForgeGroups.taskChip(task.group, ctx.hash({ kind: 'group', id: task.group }));
824
+ if (group) chips.append(group);
825
+ }
826
+ if (window.ForgeBrief && window.ForgeBrief.affectedBadge) {
827
+ const affected = window.ForgeBrief.affectedBadge(task);
828
+ if (affected) chips.append(affected);
829
+ }
710
830
  if (task.explored) chips.append(el('span', '* explored', 'tag'));
711
831
  head.append(chips);
712
832
  const dl = diffLink(ctx, solo ? 'View the diff →' : 'View its diff, findings pinned to their lines →', { kind: 'task', task: task.id, source: 'current' }); if (dl) head.append(dl);
@@ -1123,6 +1243,6 @@ window.ForgePanel = (() => {
1123
1243
  if (sel.kind === 'fractal') return fractalNodeView(host, ctx, sel);
1124
1244
  return runView(host, ctx);
1125
1245
  }
1126
- return { render, cache, trailLine, reasonText, linkModel, headerActions, summaryBank, changeSummaries };
1246
+ return { render, cache, trailLine, reasonText, linkModel, headerActions, summaryBank, changeSummaries, answerOutcome };
1127
1247
  })();
1128
1248
  if (typeof module === 'object' && module.exports) module.exports = window.ForgePanel;