@giamme/forge 0.14.1 → 0.16.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 (81) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/SKILL.md +47 -14
  3. package/VERSION +1 -1
  4. package/docs/artifacts.md +1 -1
  5. package/docs/commands.md +302 -9
  6. package/docs/forge-ui.md +14 -0
  7. package/docs/memory.md +22 -0
  8. package/docs/models.md +53 -0
  9. package/docs/reviews.md +7 -0
  10. package/forge +11 -0
  11. package/package.json +1 -1
  12. package/references/dataset.md +16 -4
  13. package/references/decompose.md +154 -9
  14. package/references/harnesses.md +21 -1
  15. package/references/planning.md +59 -0
  16. package/references/solo.md +5 -1
  17. package/references/ui.md +48 -1
  18. package/scripts/forge-artifact.sh +53 -0
  19. package/scripts/forge-compare.py +6 -3
  20. package/scripts/forge-config.py +531 -4
  21. package/scripts/forge-contract.py +55 -8
  22. package/scripts/forge-control.py +0 -2
  23. package/scripts/forge-dispatch.sh +84 -14
  24. package/scripts/forge-fail-first.py +3 -1
  25. package/scripts/forge-guard.py +247 -8
  26. package/scripts/forge-issues.py +12 -0
  27. package/scripts/forge-lib-adopt.sh +260 -0
  28. package/scripts/forge-lib-attribute.sh +10 -2
  29. package/scripts/forge-lib-plans.sh +35 -6
  30. package/scripts/forge-lib-review.sh +13 -5
  31. package/scripts/forge-lib-task.sh +138 -5
  32. package/scripts/forge-memory.sh +41 -4
  33. package/scripts/forge-metrics.sh +7 -0
  34. package/scripts/forge-parallel-options.sh +12 -6
  35. package/scripts/forge-parallel.sh +659 -32
  36. package/scripts/forge-plan-check.py +591 -8
  37. package/scripts/forge-planner.py +480 -0
  38. package/scripts/forge-route.py +16 -2
  39. package/scripts/forge-runs-rm.py +23 -7
  40. package/scripts/forge-runtime.py +111 -2
  41. package/scripts/forge-schedule.py +5 -2
  42. package/scripts/forge-shadow.py +53 -7
  43. package/scripts/forge-solo.sh +87 -7
  44. package/scripts/forge_dataset/cli.py +26 -0
  45. package/scripts/forge_dataset/efforts.py +215 -0
  46. package/scripts/forge_dataset/export.py +1 -0
  47. package/scripts/forge_dataset/harvest.py +55 -0
  48. package/scripts/forge_dataset/history.py +126 -0
  49. package/scripts/forge_dataset/worktrees.py +95 -0
  50. package/scripts/forge_decide/__init__.py +19 -1
  51. package/scripts/forge_decide/builtin_profiles.json +25 -0
  52. package/scripts/forge_decide/cli.py +12 -0
  53. package/scripts/forge_decide/profiles.py +866 -0
  54. package/scripts/forge_decide/resolve.py +38 -6
  55. package/scripts/forge_memory_list.py +153 -0
  56. package/scripts/forge_worktrees.py +88 -0
  57. package/ui/README.md +31 -0
  58. package/ui/docs/api.md +168 -12
  59. package/ui/forge_ui/__init__.py +14 -1
  60. package/ui/forge_ui/__main__.py +1 -1
  61. package/ui/forge_ui/control.py +250 -12
  62. package/ui/forge_ui/executions.py +28 -8
  63. package/ui/forge_ui/findings.py +7 -0
  64. package/ui/forge_ui/models.py +60 -1
  65. package/ui/forge_ui/projects.py +571 -0
  66. package/ui/forge_ui/reader.py +48 -8
  67. package/ui/forge_ui/static/app.js +99 -21
  68. package/ui/forge_ui/static/cloudui.js +6 -2
  69. package/ui/forge_ui/static/convo.js +1 -1
  70. package/ui/forge_ui/static/diffview.js +2 -2
  71. package/ui/forge_ui/static/files.js +1 -1
  72. package/ui/forge_ui/static/index.html +5 -1
  73. package/ui/forge_ui/static/leaderboard.js +5 -1
  74. package/ui/forge_ui/static/modelstats.js +25 -1
  75. package/ui/forge_ui/static/panel.js +47 -4
  76. package/ui/forge_ui/static/projectsview.js +372 -0
  77. package/ui/forge_ui/static/settings.js +924 -29
  78. package/ui/forge_ui/static/style.css +116 -3
  79. package/ui/forge_ui/static/uikit.js +94 -1
  80. package/ui/forge_ui/static/worktreesview.js +250 -0
  81. package/ui/forge_ui/worktrees.py +570 -0
@@ -769,14 +769,30 @@ def _max_attempts(reader):
769
769
 
770
770
 
771
771
  def _grant(choice):
772
- """The N of a retry=N choice, however many digits it has; 0 for any other choice."""
773
- match = re.fullmatch(r'retry=([0-9]+)', choice)
772
+ """The N of a retry=N choice (`retry=N dwarf=<spec>` too), however many digits it has; 0 for any other choice."""
773
+ match = re.match(r'retry=([0-9]+)(?: |$)', choice)
774
774
  try:
775
775
  return int(match.group(1)) if match else 0
776
776
  except ValueError: # more digits than Python reads as an int: a reader must not raise over one bad row
777
777
  return 0
778
778
 
779
779
 
780
+ def _adoptions(reader):
781
+ """One row per range `adopt` brought in (adoptions.tsv: epoch, base, tip, verdict, approved, spec, review, reason)."""
782
+ result = []
783
+ for label, row in reader.rows('adoptions.tsv', 8):
784
+ try:
785
+ at = float(row[0])
786
+ if not math.isfinite(at):
787
+ raise ValueError()
788
+ except (ValueError, OverflowError):
789
+ reader.warn(label, 'invalid epoch')
790
+ continue
791
+ result.append(dict(at=at, base=row[1], tip=row[2], verdict=row[3], approved=row[4] == '1', spec=_nullable(row[5]),
792
+ review=_nullable(row[6]), reason=_nullable('\t'.join(row[7:]))))
793
+ return result
794
+
795
+
780
796
  def _attempt_cap(max_attempts, decisions):
781
797
  """A task's attempt cap: max_attempts plus the N of each retry=N decision. None when max_attempts is 0 (no cap)."""
782
798
  if max_attempts == 0:
@@ -1437,12 +1453,31 @@ _SOLO_SETTINGS = ('explore', 'shadow_rate', 'shadow_qa', 'timeout', 'max_paralle
1437
1453
  'escalate_after', 'verify_retries', 'final_qa')
1438
1454
 
1439
1455
 
1456
+ def _frozen_profile(reader):
1457
+ """settings.profile from profile.json: the name and level the run froze, and the dotted keys a flag
1458
+ of the run replaced (`overridden`, a list, empty when none).
1459
+
1460
+ None when the file is absent, unreadable, or not a frozen profile. The rest of the file (body,
1461
+ shadowed, frozen_at) stays on disk; the page asks the profile endpoints for a live body."""
1462
+ name = 'profile.json'
1463
+ obj = reader.object(name)
1464
+ if obj is None:
1465
+ return None
1466
+ profile_name, level, overridden = obj.get('name'), obj.get('level'), obj.get('overridden')
1467
+ if not (isinstance(profile_name, str) and profile_name and isinstance(level, str) and level
1468
+ and isinstance(overridden, list) and all(isinstance(key, str) for key in overridden)):
1469
+ reader.warn(name, 'not a profile')
1470
+ return None
1471
+ return dict(name=profile_name, level=level, overridden=overridden)
1472
+
1473
+
1440
1474
  def _solo_detail(reader, source):
1441
1475
  result = _solo_summary(reader, source)
1442
1476
  status = next(iter(result['counts']))
1443
1477
  result['request'] = reader.cap(reader.text('request.md'), 'request')
1444
1478
  result['settings'] = dict.fromkeys(_SOLO_SETTINGS)
1445
1479
  result['settings']['qa_threshold'], result['settings']['qa_threshold_source'] = _threshold(reader)
1480
+ result['settings']['profile'] = _frozen_profile(reader)
1446
1481
  result['verification'] = None
1447
1482
  result['attribution'] = _attribution(reader)
1448
1483
  result['waves'] = [['solo']]
@@ -1464,7 +1499,7 @@ def _solo_detail(reader, source):
1464
1499
  gate=_gate(reader, 'qa.gate'), known_issues=_nonempty(reader, 'known_issues.md'),
1465
1500
  fail_first=_fail_first(reader, 'failfirst.json'), pre_review=None,
1466
1501
  now=_now(reader, '', execs) if status == 'RUNNING' else None, waiting=None, sweep=None, swept=[])
1467
- result.update(timeline=_timeline(execs, [], []), integration=None, final_review=None, final_reviews=[],
1502
+ result.update(timeline=_timeline(execs, [], []), integration=None, final_review=None, final_reviews=[], adoptions=[],
1468
1503
  deferrals=[], findings_available=findings.available(), fractal=fractal.summary(reader),
1469
1504
  scheduler=None, sweep=None)
1470
1505
  result.update(tasks=[task], warnings=reader.warnings, truncated=reader.truncated, updated=reader.updated)
@@ -1529,7 +1564,8 @@ def detail(path, source='plan') -> dict:
1529
1564
  max_parallel=reader.number('max_parallel', int),
1530
1565
  qa_threshold=threshold[0], qa_threshold_source=threshold[1],
1531
1566
  escalate_after=reader.number('escalate_after', int),
1532
- verify_retries=reader.number('verify_retries', int), final_qa=reader.line('final_qa'))
1567
+ verify_retries=reader.number('verify_retries', int), final_qa=reader.line('final_qa'),
1568
+ profile=_frozen_profile(reader))
1533
1569
  waves, wave_map = _waves(reader)
1534
1570
  result['waves'] = [waves.get(n, []) for n in range(1, max(waves, default=0) + 1)]
1535
1571
  branches = {row[0]: _nullable(row[2]) for _, row in reader.rows('results.tsv', 3)}
@@ -1562,6 +1598,7 @@ def detail(path, source='plan') -> dict:
1562
1598
  _stamp_review(summary, accepted, merges)
1563
1599
  result['final_review'] = reviews[0] if reviews else None
1564
1600
  result['final_reviews'] = reviews
1601
+ result['adoptions'] = _adoptions(reader)
1565
1602
  result['deferrals'] = [line.strip() for line in (reader.text('deferrals.txt') or '').splitlines() if line.strip()]
1566
1603
  result['findings_available'] = findings.available()
1567
1604
  result['fractal'] = fractal.summary(reader)
@@ -1587,7 +1624,7 @@ def _plan_task(reader, tasks, task_id):
1587
1624
 
1588
1625
  def _review(kind, item, text):
1589
1626
  return dict(kind=kind, execution=item['id'], attempt=item['attempt'], spec=(item['model'] or {}).get('spec'),
1590
- verdict=item['verdict'], state=item['state'], findings=findings.listing(text))
1627
+ verdict=item['verdict'], state=item['state'], findings=findings.listing(text), tests=findings.tests(text))
1591
1628
 
1592
1629
 
1593
1630
  def task_detail(path, task_id, source='plan'):
@@ -1622,12 +1659,14 @@ def task_detail(path, task_id, source='plan'):
1622
1659
  # The reply in the task dir is normally the copy of the last review; only an unmatched one is listed.
1623
1660
  if live is not None and live not in seen:
1624
1661
  reviews.append(dict(kind='primary', execution=None, attempt=attempt, spec=spec, verdict=_verdict(live),
1625
- state='done', findings=findings.listing(live)))
1662
+ state='done', findings=findings.listing(live), tests=findings.tests(live)))
1626
1663
  for entry, items, sub in shadows:
1627
1664
  run = items[-1] if items else None
1665
+ shadow_text = reader.text(sub + '/qa.last')
1628
1666
  reviews.append(dict(kind='shadow', execution=entry['execution'], attempt=entry['attempt'],
1629
1667
  spec=entry['spec'] if isinstance(entry['spec'], str) else None, verdict=entry['verdict'],
1630
- state=run['state'] if run else None, findings=findings.listing(reader.text(sub + '/qa.last'))))
1668
+ state=run['state'] if run else None, findings=findings.listing(shadow_text),
1669
+ tests=findings.tests(shadow_text)))
1631
1670
  return dict(run=run_key(reader.path), id=task_id, texts=texts, gate=_gate(reader, base + 'qa.gate'),
1632
1671
  reviews=reviews, truncated=reader.truncated, warnings=reader.warnings)
1633
1672
 
@@ -1870,7 +1909,8 @@ def final_review_detail(path, name, source='plan'):
1870
1909
  qa_input=reader.excerpt(rel + '/qa.input', 40000, 20000, 'qa_input'),
1871
1910
  qa_last=reader.clip(qa_last, 20000, 8000, 'qa_last'),
1872
1911
  known_issues=reader.excerpt(rel + '/known_issues.md', 20000, 8000, 'known_issues'),
1873
- findings=findings.listing(qa_last), truncated=reader.truncated, warnings=reader.warnings)
1912
+ findings=findings.listing(qa_last), tests=findings.tests(qa_last),
1913
+ truncated=reader.truncated, warnings=reader.warnings)
1874
1914
  return result
1875
1915
 
1876
1916
 
@@ -75,6 +75,10 @@ window.ForgeApp = (() => {
75
75
  if (c) return { key: null, sel: null, cloud: { sel: c[1] === 'runs' ? decodeURIComponent(c[2]) : null, focus: c[1] === 'projects' ? decodeURIComponent(c[2]) : null, model: c[1] === 'models' ? decodeURIComponent(c[2]) : null } };
76
76
  if (/^#\/models\/?$/.test(hash)) return { key: null, sel: null, models: true };
77
77
  if (/^#\/settings\/?$/.test(hash)) return { key: null, sel: null, settings: true };
78
+ const pj = hash.match(/^#\/projects(?:\/([0-9a-f]{8})(?:\/(runs|findings|memories))?)?\/?$/);
79
+ if (pj) return { key: null, sel: null, projects: { id: pj[1] || null, tab: pj[2] || 'runs' } };
80
+ const w = hash.match(/^#\/worktrees(?:\/(repo|runs)\/([^/]+))?\/?$/);
81
+ if (w) return { key: null, sel: null, worktrees: { repo: w[1] === 'repo' ? decodeURIComponent(w[2]) : '', run: w[1] === 'runs' ? decodeURIComponent(w[2]) : '' } };
78
82
  const m = hash.match(/^#\/runs\/([^/]+)(\/.*)?$/);
79
83
  if (!m) return { key: null, sel: null };
80
84
  const d = decodeURIComponent, rest = m[2] || '';
@@ -168,7 +172,12 @@ window.ForgeApp = (() => {
168
172
  return body;
169
173
  }
170
174
  // Restore disclosures, internal scroll and keyboard focus after changed data arrives.
171
- function preserve(parent, build, { restore = true } = {}) {
175
+ // A live refresh waits for what the user is doing (#115). An export has no uikit.js and never refreshes: it just draws.
176
+ const guard = (region, draw) => { if (window.ForgeUI?.guard) window.ForgeUI.guard(region, draw); else draw(); };
177
+ const keepOpen = (region, draw) => { if (window.ForgeUI?.keepOpen) window.ForgeUI.keepOpen(region, draw); else draw(); };
178
+ const forget = region => { if (window.ForgeUI?.forget) window.ForgeUI.forget(region); };
179
+ function preserve(parent, build, options) { guard(parent, () => preserveNow(parent, build, options)); }
180
+ function preserveNow(parent, build, { restore = true } = {}) {
172
181
  const open = new Map(Array.from(parent.querySelectorAll('details[data-keep]'), n => [n.dataset.keep, n.open]));
173
182
  const scroll = new Map(Array.from(parent.querySelectorAll('[data-scroll]'), n => [n.dataset.scroll, [n.scrollLeft, n.scrollTop]]));
174
183
  const active = parent.contains(document.activeElement) ? document.activeElement : null;
@@ -214,9 +223,11 @@ window.ForgeApp = (() => {
214
223
  // The worktree is "leaf (branch)": the leaf truncates first, the branch keeps its place. The title is the full path
215
224
  // and, on a second line, the full branch, since the branch can be truncated on screen.
216
225
  // No worktree: the name span alone, as before.
217
- function appendRepo(parent, run) {
226
+ function appendRepo(parent, run, linked) {
218
227
  const label = RM.repoLabel(run);
219
- const name = el('span', label.name, 'repo');
228
+ const href = linked && !SNAP && window.ForgeProjects ? projectHref(RM.repoKey(run)) : null;
229
+ const name = el(href ? 'a' : 'span', label.name, 'repo');
230
+ if (href) { name.href = href; name.title = 'This repository\'s project: its runs, findings and memories'; name.classList.add('project-link'); }
220
231
  if (!label.worktree) { parent.append(name); return; }
221
232
  const line = el('span', undefined, 'repo-line');
222
233
  const wt = el('span', undefined, 'muted repo-wt');
@@ -275,6 +286,7 @@ window.ForgeApp = (() => {
275
286
  }
276
287
  $('run-list').append(item);
277
288
  }
289
+ markSelection(); // inside: a held draw runs later, with new nodes to mark
278
290
  });
279
291
  markSelection();
280
292
  }
@@ -380,7 +392,10 @@ window.ForgeApp = (() => {
380
392
  const wrap = el('div', undefined, 'map-cards');
381
393
  for (const layer of A.layers) {
382
394
  const g = el('section', undefined, 'map-repo');
383
- g.append(el('h3', layer.name));
395
+ const h = el('h3'), href = !SNAP && window.ForgeProjects ? projectHref(layer.repo) : null;
396
+ if (href) { const a = el('a', layer.name, 'project-link'); a.href = href; a.title = 'This repository\'s project: its runs, findings and memories'; h.append(a); }
397
+ else h.textContent = layer.name;
398
+ g.append(h);
384
399
  const grid = el('div', undefined, 'map-grid');
385
400
  for (const m of A.modules.filter(x => x.layer === layer.id)) {
386
401
  const r = m.run, card = link(undefined, r.key);
@@ -418,6 +433,10 @@ window.ForgeApp = (() => {
418
433
  el('pre', 'forge ui open <run-dir>', 'cmd'),
419
434
  el('p', 'A run dir is a plan or solo directory forge wrote. Runs register under $XDG_CONFIG_HOME/forge/runs/ (default ~/.config/forge/runs/); FORGE_RUN_REGISTRY=off turns that off.', 'muted'));
420
435
  }
436
+ function mapCount(info) {
437
+ const counter = $('map-view')?.querySelector('.map-head .map-count');
438
+ if (counter) counter.textContent = `${info.matches} of ${info.shown} shown runs match${info.hidden ? ` · ${info.hidden} older hidden` : ''}`;
439
+ }
421
440
  function renderMap({ rebuildBar = true } = {}) {
422
441
  const main = $('main');
423
442
  if (state.listLoaded && !state.runs.length && !SNAP) { renderFirstRun(); return; }
@@ -449,10 +468,10 @@ window.ForgeApp = (() => {
449
468
  info = state.stage.showAtlas(state.runs, state.mapFilter, { showAll: state.showAll });
450
469
  $('map-cards').replaceChildren();
451
470
  } else {
452
- preserve($('map-cards'), () => { const A = mapCards($('map-cards')); info = { hidden: A.hidden, matches: A.matches, shown: A.modules.length, total: A.total }; });
471
+ // The count is set with the cards, so a held draw brings its own when it runs.
472
+ preserve($('map-cards'), () => { const A = mapCards($('map-cards')); mapCount({ hidden: A.hidden, matches: A.matches, shown: A.modules.length, total: A.total }); });
453
473
  }
454
- const counter = $('map-view').querySelector('.map-head .map-count');
455
- if (info) counter.textContent = `${info.matches} of ${info.shown} shown runs match${info.hidden ? ` · ${info.hidden} older hidden` : ''}`;
474
+ if (info) mapCount(info);
456
475
  }
457
476
 
458
477
  /* ---------- the run cloud: every run in 3D, full screen ---------- */
@@ -494,12 +513,12 @@ window.ForgeApp = (() => {
494
513
  host.replaceChildren(el('h1', 'Models', 'module-title'), el('p', state.modelsError ? `Could not load the model results (${state.modelsError}).` : 'Reading every run\'s attempts and reviews…', state.modelsError ? 'warn' : 'muted'));
495
514
  return;
496
515
  }
497
- window.ForgeLeaderboard.render(host, state.modelsData, {
516
+ guard(host, () => window.ForgeLeaderboard.render(host, state.modelsData, {
498
517
  runs: state.runs, prefs: state.modelsPrefs, now: () => Date.now() / 1000,
499
518
  savePrefs: p => { state.modelsPrefs = p; store.set('models', p); },
500
519
  tablePrefs: id => state.tablePrefs[id], saveTablePrefs: (id, p) => { state.tablePrefs = { ...state.tablePrefs, [id]: p }; store.set('tables', state.tablePrefs); },
501
520
  modelHref: alias => '#/cloud/models/' + encodeURIComponent(alias), reviewerOutcomes: state.reviewerOutcomes,
502
- });
521
+ }));
503
522
  }
504
523
  // How each reviewer's PASSed work held up (forge dataset reviewers). Advisory and optional: read once per
505
524
  // change of the models data, and a failure (an export, no dataset) only leaves the column empty.
@@ -532,6 +551,35 @@ window.ForgeApp = (() => {
532
551
  });
533
552
  }
534
553
 
554
+ /* ---------- every worktree forge created (#/worktrees) ---------- */
555
+ // It reads /api/worktrees itself, when opened and at a slow interval: never on the page's poll.
556
+ function renderWorktrees() {
557
+ const main = $('main');
558
+ if (main.dataset.view === 'worktrees' && state.worktreesView) { state.worktreesView.setFilter(state.worktrees); return; }
559
+ setView(main, 'worktrees'); delete main.dataset.run;
560
+ main.replaceChildren();
561
+ const v = el('section', undefined, 'worktrees-view'); v.id = 'worktrees-view'; main.append(v);
562
+ state.worktreesView = window.ForgeWorktrees.render(v, {
563
+ filter: state.worktrees, runHref: key => '#/runs/' + encodeURIComponent(key),
564
+ tablePrefs: id => state.tablePrefs[id], saveTablePrefs: (id, p) => { state.tablePrefs = { ...state.tablePrefs, [id]: p }; store.set('tables', state.tablePrefs); },
565
+ });
566
+ }
567
+
568
+ /* ---------- each repository's runs, findings and memories (#/projects) ---------- */
569
+ function renderProjects() {
570
+ const main = $('main'), p = state.projects;
571
+ if (main.dataset.view === 'projects' && state.projectsView) { state.projectsView.go(p.id, p.tab); return; }
572
+ setView(main, 'projects'); delete main.dataset.run;
573
+ main.replaceChildren();
574
+ const v = el('section', undefined, 'projects-view'); v.id = 'projects-view'; main.append(v);
575
+ state.projectsView = window.ForgeProjects.render(v, {
576
+ id: p.id, tab: p.tab, runHref: key => '#/runs/' + encodeURIComponent(key),
577
+ tablePrefs: id => state.tablePrefs[id], saveTablePrefs: (id, pr) => { state.tablePrefs = { ...state.tablePrefs, [id]: pr }; store.set('tables', state.tablePrefs); },
578
+ });
579
+ }
580
+ // a repository's project page: the id is the run cloud's (cloudmodel.js hashId of the repository root)
581
+ const projectHref = repo => window.ForgeCloudModel && repo ? '#/projects/' + window.ForgeCloudModel.hashId(String(repo)) : null;
582
+
535
583
  /* ---------- a run's open findings (#/runs/<key>/findings) ---------- */
536
584
  function renderFindings() {
537
585
  const main = $('main');
@@ -654,6 +702,12 @@ window.ForgeApp = (() => {
654
702
  rec.addEventListener('click', () => { Shell.toggle('insp', true); if (state.sel) select(null); });
655
703
  acts.append(rec);
656
704
  if (!SNAP && window.ForgeFindings) acts.append(findingsLink(state.key));
705
+ if (!SNAP && window.ForgeWorktrees && (state.cache.get(state.key)?.data || {}).kind !== 'solo') {
706
+ const wt = el('a', undefined, 'details-btn worktrees-link'); wt.href = '#/worktrees/runs/' + encodeURIComponent(state.key);
707
+ wt.title = 'This run\'s worktrees: what state each is in, and the command that removes it';
708
+ wt.append(icon('panel-right'), el('span', 'Worktrees'));
709
+ acts.append(wt);
710
+ }
657
711
  if (!SNAP) {
658
712
  const ex = el('button', undefined, 'export-btn'); ex.type = 'button'; ex.title = 'Download this run as one HTML file to share';
659
713
  ex.append(icon('download'), el('span', 'Export…'));
@@ -747,7 +801,7 @@ window.ForgeApp = (() => {
747
801
  const lamp = el('i', undefined, 'lamp st-' + LAMP[RM.runState(run)]);
748
802
  const title = el('h2', String(run.goal || 'Untitled run').split('\n')[0]); title.title = run.goal || '';
749
803
  const where = el('span', undefined, 'run-where'); where.title = `${run.repo || ''}\n${run.run_id || ''}`;
750
- appendRepo(where, run);
804
+ appendRepo(where, run, true);
751
805
  where.append(el('span', run.run_id, 'mono'));
752
806
  if (solo) where.append(document.createTextNode(' · solo run'));
753
807
  // the describer: each state's count, the wall time so far, and how long since anything moved
@@ -804,7 +858,8 @@ window.ForgeApp = (() => {
804
858
  const tools = box && box.querySelector('.module-tools');
805
859
  let slot = tools && tools.querySelector('.dt-tools');
806
860
  if (tools && !slot) { slot = el('span', undefined, 'dt-tools'); tools.prepend(slot); }
807
- preserve(host, () => {
861
+ // The table's column button lives in `slot`, outside `host`, and a redraw replaces it: both count as in use.
862
+ guard(slot || host, () => preserve(host, () => {
808
863
  if (run.kind === 'solo') { if (slot) slot.replaceChildren(); return; }
809
864
  if (!list(run.tasks).length) { if (slot) slot.replaceChildren(); host.append(el('p', 'This run has no tasks yet.', 'empty')); return; }
810
865
  Table.render(host, {
@@ -816,7 +871,7 @@ window.ForgeApp = (() => {
816
871
  }),
817
872
  });
818
873
  scoped(host, run.key + ':');
819
- });
874
+ }));
820
875
  }
821
876
  function renderInspector(run) {
822
877
  const host = $('inspector'); if (!host || !window.ForgePanel) return;
@@ -850,14 +905,14 @@ window.ForgeApp = (() => {
850
905
  const host = $('strip'); if (!host) return;
851
906
  const show = state.mode === 'exec' && run.kind !== 'solo';
852
907
  host.hidden = !show;
853
- if (show) window.ForgeGantt.strip(host, run, { now: now(), replay: state.replay }); else host.replaceChildren();
908
+ guard(host, () => { if (show) window.ForgeGantt.strip(host, run, { now: now(), replay: state.replay }); else host.replaceChildren(); });
854
909
  }
855
910
  // Files: which task touched which file, in the stage's place (the inspector stays beside it)
856
911
  function renderFiles(run) {
857
912
  const host = $('files-view'), view = $('run-view'); if (!host || !view) return;
858
913
  const open = state.mode === 'files' && !!window.ForgeFiles;
859
914
  view.classList.toggle('files-open', open); host.hidden = !open;
860
- if (!open) { host.filesSig = ''; return; }
915
+ if (!open) { host.filesSig = ''; forget(host); return; }
861
916
  const c = state.files.get(run.key);
862
917
  if (!c || c.updated !== run.updated) loadFiles(run);
863
918
  if (!c || !c.data) {
@@ -868,9 +923,9 @@ window.ForgeApp = (() => {
868
923
  const sig = JSON.stringify([c.at, state.sel]);
869
924
  if (host.filesSig === sig) return; // a poll that changed nothing here redraws nothing
870
925
  host.filesSig = sig;
871
- window.ForgeFiles.render(host, c.data, { run, sel: state.sel, onSelectTask: id => select({ kind: 'task', id }),
926
+ guard(host, () => keepOpen(host, () => window.ForgeFiles.render(host, c.data, { run, sel: state.sel, onSelectTask: id => select({ kind: 'task', id }),
872
927
  diffHref: (task, path) => diffHash(run.key, { kind: 'task', task, source: 'current', file: path }),
873
- prefs: state.filesPrefs, savePrefs: p => { state.filesPrefs = p; store.set('files', p); } });
928
+ prefs: state.filesPrefs, savePrefs: p => { state.filesPrefs = p; store.set('files', p); } })));
874
929
  }
875
930
  // every review's findings of the run, for the stage's marks: read again when the run changes
876
931
  function syncFindings(run) {
@@ -893,7 +948,8 @@ window.ForgeApp = (() => {
893
948
  const host = $('diff-view'), view = $('run-view'); if (!host || !view) return;
894
949
  const kind = state.convo && window.ForgeConvo ? 'convo' : state.diff && window.ForgeDiff ? 'diff' : null;
895
950
  view.classList.toggle('diff-open', !!kind); host.hidden = !kind;
896
- if (host.dataset.kind !== (kind || '')) { host.replaceChildren(); host.diffSig = ''; host.convoFrame = null; host.dataset.kind = kind || ''; }
951
+ // What was held for the view being left would draw it over what replaced it.
952
+ if (host.dataset.kind !== (kind || '')) { forget(host); host.replaceChildren(); host.diffSig = ''; host.convoFrame = null; host.dataset.kind = kind || ''; }
897
953
  if (!kind) return;
898
954
  const rerender = () => { const r = state.cache.get(state.key)?.data; if (r) renderDiff(r); };
899
955
  if (kind === 'convo') {
@@ -903,8 +959,9 @@ window.ForgeApp = (() => {
903
959
  fetchJSON: path => fetchJSON(path).then(r => r.data), rerender, diffHash: spec => diffHash(run.key, spec), closeHref: hashFor(run.key, state.sel) });
904
960
  return;
905
961
  }
906
- window.ForgeDiff.render(host, { run, spec: state.diff, fetchJSON: path => fetchJSON(path).then(r => r.data), rerender,
907
- href: spec => diffHash(run.key, spec), closeHref: hashFor(run.key, state.sel) });
962
+ const spec = state.diff; // this draw's, whenever a hold lets it run
963
+ guard(host, () => keepOpen(host, () => window.ForgeDiff.render(host, { run, spec, fetchJSON: path => fetchJSON(path).then(r => r.data), rerender,
964
+ href: spec => diffHash(run.key, spec), closeHref: hashFor(run.key, state.sel) })));
908
965
  }
909
966
  function renderRunBody(run) {
910
967
  renderDiff(run);
@@ -960,6 +1017,8 @@ window.ForgeApp = (() => {
960
1017
  if (state.cloud) { renderCloud(); return; }
961
1018
  if (state.models) { renderModels(); return; }
962
1019
  if (state.settings) { renderSettings(); return; }
1020
+ if (state.worktrees) { renderWorktrees(); return; }
1021
+ if (state.projects) { renderProjects(); return; }
963
1022
  if (state.key && state.findingsPage) { renderFindings(); return; }
964
1023
  if (!state.key) { renderMap(); return; }
965
1024
  const cached = state.cache.get(state.key);
@@ -1016,7 +1075,8 @@ window.ForgeApp = (() => {
1016
1075
  renderList();
1017
1076
  if (state.cloud) renderCloud();
1018
1077
  else if (state.settings) state.settingsView?.poll(); // the picker follows the run list; the page stays
1019
- else if (!state.key && !state.models) renderMap({ rebuildBar: $('map-filters') ? !$('map-filters').contains(document.activeElement) : true });
1078
+ else if (state.projects) state.projectsView?.poll();
1079
+ else if (!state.key && !state.models && !state.worktrees) renderMap({ rebuildBar: $('map-filters') ? !$('map-filters').contains(document.activeElement) : true });
1020
1080
  }, 'Could not refresh runs');
1021
1081
  }
1022
1082
  function loadRun(key) {
@@ -1052,6 +1112,8 @@ window.ForgeApp = (() => {
1052
1112
  state.cloud = parsed.cloud || null;
1053
1113
  state.models = !!parsed.models;
1054
1114
  state.settings = !!parsed.settings && !!window.ForgeSettings && !SNAP;
1115
+ state.worktrees = parsed.worktrees && window.ForgeWorktrees && !SNAP ? parsed.worktrees : null;
1116
+ state.projects = parsed.projects && window.ForgeProjects && !SNAP ? parsed.projects : null;
1055
1117
  if (parsed.key) state.lastKey = parsed.key;
1056
1118
  state.findingsPage = !!parsed.findings && !!window.ForgeFindings;
1057
1119
  if (state.cloud && state.cloud.model) { // a model's runs: the cloud, filtered to it
@@ -1061,7 +1123,7 @@ window.ForgeApp = (() => {
1061
1123
  document.body.classList.toggle('cloud-mode', !!state.cloud);
1062
1124
  if (!state.key) document.body.classList.remove('no-tasks');
1063
1125
  for (const a of document.querySelectorAll('.topbar .top-link')) {
1064
- const here = a.getAttribute('href') === (state.cloud ? '#/cloud' : state.models ? '#/models' : state.settings ? '#/settings' : !state.key ? '#/' : null);
1126
+ const here = a.getAttribute('href') === (state.cloud ? '#/cloud' : state.models ? '#/models' : state.settings ? '#/settings' : state.worktrees ? '#/worktrees' : state.projects ? '#/projects' : !state.key ? '#/' : null);
1065
1127
  if (here) a.setAttribute('aria-current', 'page'); else a.removeAttribute('aria-current');
1066
1128
  }
1067
1129
  renderErrors();
@@ -1069,6 +1131,8 @@ window.ForgeApp = (() => {
1069
1131
  if (state.cloud) { renderCloud(); return; }
1070
1132
  if (state.models) { renderModels(); loadModels(); return; }
1071
1133
  if (state.settings) { renderSettings(); return; }
1134
+ if (state.worktrees) { renderWorktrees(); return; }
1135
+ if (state.projects) { renderProjects(); return; }
1072
1136
  if (state.key && state.findingsPage) { renderFindings(); return; }
1073
1137
  if (!state.key) { renderMap(); return; }
1074
1138
  const cached = state.cache.get(state.key);
@@ -1116,6 +1180,8 @@ window.ForgeApp = (() => {
1116
1180
  { id: 'cmd:cloud', label: 'Open the run cloud', sub: 'every run in 3D, grouped by project', ids: ['cloud'], href: '#/cloud' },
1117
1181
  { id: 'cmd:map', label: 'Open the map of all runs', sub: 'the front page', ids: ['map', 'home'], href: '#/' },
1118
1182
  { id: 'cmd:models', label: 'Open the model leaderboard', sub: 'pass rates, retries, time and tokens per model', ids: ['models', 'leaderboard'], href: '#/models' },
1183
+ ...(window.ForgeProjects ? [{ id: 'cmd:projects', label: 'Open the projects', sub: 'each repository\'s runs, findings and memories', ids: ['projects', 'repos', 'memory', 'findings'], href: '#/projects' }] : []),
1184
+ ...(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', 'disk'], href: '#/worktrees' }] : []),
1119
1185
  ...(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' }] : []),
1120
1186
  { id: 'cmd:notify', label: 'Notifications', sub: 'what finished or failed, and browser notifications', ids: ['alerts', 'bell'], action: () => window.ForgeNotify && window.ForgeNotify.open() },
1121
1187
  { 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'],
@@ -1190,3 +1256,15 @@ window.ForgeApp = (() => {
1190
1256
  // window.ForgeUI is uikit.js's shared helpers; the page's own handles (state, refresh) join it, where the browser
1191
1257
  // tests and ui/tools/readme_media.py read them.
1192
1258
  window.ForgeUI = Object.assign(window.ForgeUI || {}, window.ForgeApp);
1259
+ // #113: the version of the server answering, beside the logo. An export has no server, so no label; nor when it is unknown.
1260
+ (function brandVersion() {
1261
+ const label = document.getElementById('brand-version');
1262
+ if (!label || !window.ForgeUI.get || document.getElementById('forge-snapshot')) return;
1263
+ window.ForgeUI.get('/api/health').then(res => {
1264
+ const version = res.ok && typeof res.data.version === 'string' ? res.data.version : '';
1265
+ if (!version) return;
1266
+ label.textContent = 'v' + version;
1267
+ label.title = typeof res.data.build === 'string' ? 'forge ' + version + ', build ' + res.data.build.slice(0, 12) : 'forge ' + version;
1268
+ label.hidden = false;
1269
+ });
1270
+ })();
@@ -220,7 +220,10 @@ window.ForgeCloudUI = (() => {
220
220
  if (q) q.addEventListener('input', () => { const t = q.value.trim().toLowerCase(); for (const li of ul.children) li.hidden = !!t && !li.dataset.name.includes(t); });
221
221
  box.append(ul); return box;
222
222
  }
223
- function buildPanel(keep) {
223
+ // A live refresh waits for what the user is doing (#115). An export has no uikit.js and never refreshes.
224
+ const guard = (region, draw) => { if (window.ForgeUI?.guard) window.ForgeUI.guard(region, draw); else draw(); };
225
+ function buildPanel(keep) { guard(panel, () => buildPanelNow(keep)); }
226
+ function buildPanelNow(keep) {
224
227
  const active = keep && panel.contains(document.activeElement) ? document.activeElement.dataset.key : null, top = panel.scrollTop;
225
228
  const f = prefs.filter, O = CM.options(S.facts), P = CM.projects(S.runs);
226
229
  panel.replaceChildren();
@@ -331,7 +334,8 @@ window.ForgeCloudUI = (() => {
331
334
  }
332
335
 
333
336
  /* ---------- without 3D: the same filtered runs as a list ---------- */
334
- function renderList() {
337
+ function renderList() { guard(listHost, renderListNow); }
338
+ function renderListNow() {
335
339
  listHost.replaceChildren();
336
340
  const head = el('div', undefined, 'cloud-list-head');
337
341
  if (S.mode === 'failed') head.append(el('p', S.note || '3D view unavailable.', 'warn'));
@@ -279,7 +279,7 @@ window.ForgeConvo = (() => {
279
279
  const status = [];
280
280
  const ws = list(D.warnings);
281
281
  if (ws.length) status.push(el('p', ws[0], 'warn'));
282
- if (ws.length > 1) { const d = el('details', undefined, 'diff-warnings'); d.append(el('summary', `${ws.length - 1} more warning${ws.length === 2 ? '' : 's'}`), el('pre', ws.slice(1).join('\n'))); status.push(d); }
282
+ if (ws.length > 1) { const d = el('details', undefined, 'diff-warnings'); d.open = v.open.has('warnings'); d.addEventListener('toggle', () => { if (d.open) v.open.add('warnings'); else v.open.delete('warnings'); }); d.append(el('summary', `${ws.length - 1} more warning${ws.length === 2 ? '' : 's'}`), el('pre', ws.slice(1).join('\n'))); status.push(d); }
283
283
  if (D.format === 'text' && list(D.events).length) status.push(el('p', `${D.harness || 'This harness'} left plain text, not a stream of events: its log is shown as it is.`, 'muted'));
284
284
  if (!list(D.events).length) status.push(el('p', running ? 'Nothing logged yet: the agent has just started.' : D.source === 'none' ? 'No log was kept for this execution.' : 'Its log holds no conversation.', 'muted convo-empty'));
285
285
  f.status.replaceChildren(...status);
@@ -56,7 +56,7 @@ window.ForgeDiff = (() => {
56
56
  if (where) head.append(el('span', where, 'mono muted'));
57
57
  box.append(head, el('p', said(f)));
58
58
  const more = String(f.text || '').trim();
59
- if (more && more !== String(f.summary || '').trim()) { const d = el('details'); d.append(el('summary', 'Details'), el('pre', more)); box.append(d); }
59
+ if (more && more !== String(f.summary || '').trim()) { const d = el('details'); d.dataset.keep = `finding-${f.id ?? where ?? said(f)}`; d.append(el('summary', 'Details'), el('pre', more)); box.append(d); }
60
60
  return box;
61
61
  }
62
62
 
@@ -193,7 +193,7 @@ window.ForgeDiff = (() => {
193
193
  for (const p of loose) { const b = findingBox(p.f, `${p.f.location || 'no location'} · ${p.f.off_diff || 'not located'}`); b.id = 'diff-finding-' + p.i; b.tabIndex = -1; ls.append(b); }
194
194
  main.append(ls);
195
195
  }
196
- if (list(D.warnings).length) { const d = el('details', undefined, 'diff-warnings'); d.append(el('summary', `Reader warnings (${D.warnings.length})`), el('pre', D.warnings.join('\n'))); main.append(d); }
196
+ if (list(D.warnings).length) { const d = el('details', undefined, 'diff-warnings'); d.dataset.keep = 'diff-warnings'; d.append(el('summary', `Reader warnings (${D.warnings.length})`), el('pre', D.warnings.join('\n'))); main.append(d); }
197
197
  if (files.length || loose.length) body.append(nav); else body.classList.add('no-files');
198
198
  body.append(main); host.append(body);
199
199
 
@@ -743,7 +743,7 @@
743
743
  else if (rows.length - fold <= 4) s.append(items(rows));
744
744
  else {
745
745
  if (fold) s.append(items(rows.slice(0, fold)));
746
- const det = el('details', undefined, 'fm-more');
746
+ const det = el('details', undefined, 'fm-more'); det.dataset.keep = `fm-more-${title}`;
747
747
  det.append(el('summary', `${fmt(rows.length - fold)} ${more}`), items(rows.slice(fold)));
748
748
  s.append(det);
749
749
  }
@@ -35,6 +35,8 @@
35
35
  <script src="cloudui.js" defer></script>
36
36
  <script src="leaderboard.js" defer></script>
37
37
  <script src="findingsview.js" defer></script>
38
+ <script src="worktreesview.js" defer></script>
39
+ <script src="projectsview.js" defer></script>
38
40
  <script src="rundelete.js" defer></script>
39
41
  <script src="settings.js" defer></script>
40
42
  <script src="search.js" defer></script>
@@ -44,11 +46,13 @@
44
46
  <body data-shell="immersive" data-runs="open" data-insp="open" data-tasks="open">
45
47
  <script src="shell.js"></script>
46
48
  <header class="topbar">
47
- <a class="brand" href="#/" title="forge-ui · local run viewer"><span class="brand-plate">forge</span><span class="brand-sub">ui</span></a>
49
+ <a class="brand" href="#/" title="forge-ui · local run viewer"><span class="brand-plate">forge</span><span class="brand-sub">ui</span><span class="brand-version" id="brand-version" hidden></span></a>
48
50
  <nav class="desk-nav" aria-label="Views">
49
51
  <a class="top-link" href="#/">Map</a>
50
52
  <a class="top-link" href="#/cloud">Cloud</a>
53
+ <a class="top-link" href="#/projects">Projects</a>
51
54
  <a class="top-link" href="#/models">Models</a>
55
+ <a class="top-link" href="#/worktrees">Worktrees</a>
52
56
  <a class="top-link" href="#/settings">Settings</a>
53
57
  </nav>
54
58
  <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>
@@ -303,7 +303,11 @@ window.ForgeLeaderboard = (() => {
303
303
  const det = el('details', undefined, 'lb-diff'); det.open = prefs.open.includes(d);
304
304
  const sum = el('summary');
305
305
  sum.append(el('span', DIFF_LABEL[d], 'lb-diff-name'), el('span', `${plural(tasks, 'task')} · ${plural(rows.length, 'model')} · first-attempt pass ${n ? `${pct(k / n)} (${k}/${n})` : '—'}`, 'muted'));
306
- det.append(sum, implementerTable(rows, ctx, f.minN, `Implementers, ${DIFF_LABEL[d].toLowerCase()}`));
306
+ det.append(sum);
307
+ // The built-in profile's dwarf for this tier, under the summary. Nothing when the server sent none.
308
+ const rec = MS.recommendedLine(data && data.recommended, d, rows);
309
+ if (rec) det.append(el('p', rec, 'muted'));
310
+ det.append(implementerTable(rows, ctx, f.minN, `Implementers, ${DIFF_LABEL[d].toLowerCase()}`));
307
311
  det.addEventListener('toggle', () => {
308
312
  if (det.open === prefs.open.includes(d)) return;
309
313
  prefs.open = det.open ? prefs.open.concat(d) : prefs.open.filter(x => x !== d); save();
@@ -267,5 +267,29 @@
267
267
  return { state: 'rate', p: row.rate, lo: ci[0], hi: ci[1], ...base };
268
268
  }
269
269
 
270
- return { DIFFS, KINDS, SEVERITIES, DEFAULT_MIN_N, wilson, emptyFilter, normFilter, taskMatch, options, leaderboard, heldUp };
270
+ // The median model time as the recommendation's source writes times ("1.9 min"): minutes, one decimal.
271
+ function minutesText(s) {
272
+ s = num(s);
273
+ if (s === null) return '—';
274
+ const tenths = Math.round(Math.max(0, s) / 6);
275
+ const whole = Math.floor(tenths / 10), frac = tenths % 10;
276
+ return (frac ? whole + '.' + frac : String(whole)) + ' min';
277
+ }
278
+
279
+ // The line under a "By difficulty" tier. Null when `recommended` is absent or names no dwarf for `tier`
280
+ // (the page then shows nothing). `rows` are that tier's implementer rows: the alias's own median when
281
+ // it was measured there, otherwise the line says it has not run on the tier.
282
+ function recommendedLine(recommended, tier, rows) {
283
+ const rec = obj(recommended), dwarf = rec && obj(rec.dwarf);
284
+ const spec = dwarf && typeof dwarf[tier] === 'string' ? dwarf[tier] : '';
285
+ if (!spec) return null;
286
+ const profile = typeof rec.profile === 'string' ? rec.profile : '';
287
+ const source = typeof rec.source === 'string' ? rec.source : '';
288
+ const alias = spec.split(':')[0];
289
+ const row = alias ? list(rows).find(r => obj(r) && r.alias === alias) : null;
290
+ const tail = row ? 'your median model time ' + minutesText(row.medianModelS) : 'not run on this tier yet';
291
+ return `Recommended: ${spec} (built-in profile "${profile}", ${source}) · ${tail}`;
292
+ }
293
+
294
+ return { DIFFS, KINDS, SEVERITIES, DEFAULT_MIN_N, wilson, emptyFilter, normFilter, taskMatch, options, leaderboard, heldUp, recommendedLine };
271
295
  });