@giamme/forge 0.15.0 → 0.17.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 +48 -0
- package/VERSION +1 -1
- package/docs/artifacts.md +1 -1
- package/docs/commands.md +14 -3
- package/docs/dataset.md +8 -0
- package/docs/forge-ui.md +14 -0
- package/docs/memory.md +22 -0
- package/docs/reviews.md +22 -1
- package/forge +11 -0
- package/package.json +1 -1
- package/references/dataset.md +129 -7
- package/references/decision-models.md +15 -2
- package/references/decompose.md +95 -13
- package/references/harnesses.md +4 -1
- package/references/planning.md +3 -2
- package/references/solo.md +5 -1
- package/references/ui.md +10 -1
- package/scripts/forge-artifact.sh +53 -0
- package/scripts/forge-contract.py +107 -9
- package/scripts/forge-control.py +0 -2
- package/scripts/forge-dispatch.sh +28 -12
- package/scripts/forge-fail-first.py +3 -1
- package/scripts/forge-guard.py +247 -8
- package/scripts/forge-issues.py +16 -3
- package/scripts/forge-ledger.py +3 -1
- package/scripts/forge-lib-adopt.sh +266 -0
- package/scripts/forge-lib-attribute.sh +10 -2
- package/scripts/forge-lib-plans.sh +16 -4
- package/scripts/forge-lib-review.sh +8 -2
- package/scripts/forge-lib-task.sh +19 -5
- package/scripts/forge-memory.sh +41 -4
- package/scripts/forge-metrics.sh +29 -0
- package/scripts/forge-parallel.sh +99 -14
- package/scripts/forge-plan-check.py +25 -2
- package/scripts/forge-planner.py +20 -6
- package/scripts/forge-route.py +16 -2
- package/scripts/forge-runs-rm.py +23 -7
- package/scripts/forge-runtime.py +25 -2
- package/scripts/forge-schedule.py +5 -2
- package/scripts/forge-shadow.py +30 -9
- package/scripts/forge-solo.sh +6 -0
- package/scripts/forge-sweep.py +25 -10
- package/scripts/forge_dataset/cli.py +99 -0
- package/scripts/forge_dataset/export.py +1 -0
- package/scripts/forge_dataset/facts.py +278 -0
- package/scripts/forge_dataset/harvest.py +27 -3
- package/scripts/forge_dataset/history.py +126 -0
- package/scripts/forge_dataset/outcomes.py +206 -58
- package/scripts/forge_dataset/pairs.py +174 -0
- package/scripts/forge_dataset/risk.py +108 -0
- package/scripts/forge_dataset/tiers.py +427 -0
- package/scripts/forge_dataset/worktrees.py +95 -0
- package/scripts/forge_decide/cli.py +23 -2
- package/scripts/forge_decide/labels.py +30 -6
- package/scripts/forge_decide/replay.py +10 -4
- package/scripts/forge_memory_list.py +153 -0
- package/scripts/forge_worktrees.py +88 -0
- package/ui/README.md +31 -0
- package/ui/docs/api.md +92 -6
- package/ui/forge_ui/__init__.py +14 -1
- package/ui/forge_ui/__main__.py +1 -1
- package/ui/forge_ui/control.py +77 -0
- package/ui/forge_ui/export.py +9 -2
- package/ui/forge_ui/findings.py +11 -2
- package/ui/forge_ui/projects.py +571 -0
- package/ui/forge_ui/reader.py +96 -9
- package/ui/forge_ui/server.py +8 -0
- package/ui/forge_ui/static/app.js +105 -22
- package/ui/forge_ui/static/cloudui.js +6 -2
- package/ui/forge_ui/static/convo.js +1 -1
- package/ui/forge_ui/static/diffview.js +9 -5
- package/ui/forge_ui/static/files.js +1 -1
- package/ui/forge_ui/static/index.html +5 -1
- package/ui/forge_ui/static/panel.js +69 -2
- package/ui/forge_ui/static/projectsview.js +372 -0
- package/ui/forge_ui/static/settings.js +136 -4
- package/ui/forge_ui/static/style.css +94 -3
- package/ui/forge_ui/static/uikit.js +94 -1
- package/ui/forge_ui/static/worktreesview.js +250 -0
- package/ui/forge_ui/worktrees.py +570 -0
package/ui/forge_ui/reader.py
CHANGED
|
@@ -769,14 +769,38 @@ 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.
|
|
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
|
+
_ADOPT_NAME = re.compile(r'adopt-[0-9]+-[0-9]+')
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
def _adoptions(reader):
|
|
784
|
+
"""One row per range `adopt` brought in (adoptions.tsv: epoch, base, tip, verdict, approved, spec, review, reason).
|
|
785
|
+
`findings` summarizes its review's reply and `diff` says the range's diff is there to open (#131); both are
|
|
786
|
+
None or False when `review` does not name an adopt-<epoch>-<pid> dir of the run."""
|
|
787
|
+
result = []
|
|
788
|
+
for label, row in reader.rows('adoptions.tsv', 8):
|
|
789
|
+
try:
|
|
790
|
+
at = float(row[0])
|
|
791
|
+
if not math.isfinite(at):
|
|
792
|
+
raise ValueError()
|
|
793
|
+
except (ValueError, OverflowError):
|
|
794
|
+
reader.warn(label, 'invalid epoch')
|
|
795
|
+
continue
|
|
796
|
+
name = row[6] if _ADOPT_NAME.fullmatch(row[6] or '') and reader.exists(row[6]) else None
|
|
797
|
+
result.append(dict(at=at, base=row[1], tip=row[2], verdict=row[3], approved=row[4] == '1', spec=_nullable(row[5]),
|
|
798
|
+
review=_nullable(row[6]), reason=_nullable('\t'.join(row[7:])),
|
|
799
|
+
findings=executions.qa_result(reader, name + '/qa.last')[1] if name else None,
|
|
800
|
+
diff=bool(name) and reader.exists(name + '/range.diff')))
|
|
801
|
+
return result
|
|
802
|
+
|
|
803
|
+
|
|
780
804
|
def _attempt_cap(max_attempts, decisions):
|
|
781
805
|
"""A task's attempt cap: max_attempts plus the N of each retry=N decision. None when max_attempts is 0 (no cap)."""
|
|
782
806
|
if max_attempts == 0:
|
|
@@ -1483,7 +1507,7 @@ def _solo_detail(reader, source):
|
|
|
1483
1507
|
gate=_gate(reader, 'qa.gate'), known_issues=_nonempty(reader, 'known_issues.md'),
|
|
1484
1508
|
fail_first=_fail_first(reader, 'failfirst.json'), pre_review=None,
|
|
1485
1509
|
now=_now(reader, '', execs) if status == 'RUNNING' else None, waiting=None, sweep=None, swept=[])
|
|
1486
|
-
result.update(timeline=_timeline(execs, [], []), integration=None, final_review=None, final_reviews=[],
|
|
1510
|
+
result.update(timeline=_timeline(execs, [], []), integration=None, final_review=None, final_reviews=[], adoptions=[],
|
|
1487
1511
|
deferrals=[], findings_available=findings.available(), fractal=fractal.summary(reader),
|
|
1488
1512
|
scheduler=None, sweep=None)
|
|
1489
1513
|
result.update(tasks=[task], warnings=reader.warnings, truncated=reader.truncated, updated=reader.updated)
|
|
@@ -1582,6 +1606,7 @@ def detail(path, source='plan') -> dict:
|
|
|
1582
1606
|
_stamp_review(summary, accepted, merges)
|
|
1583
1607
|
result['final_review'] = reviews[0] if reviews else None
|
|
1584
1608
|
result['final_reviews'] = reviews
|
|
1609
|
+
result['adoptions'] = _adoptions(reader)
|
|
1585
1610
|
result['deferrals'] = [line.strip() for line in (reader.text('deferrals.txt') or '').splitlines() if line.strip()]
|
|
1586
1611
|
result['findings_available'] = findings.available()
|
|
1587
1612
|
result['fractal'] = fractal.summary(reader)
|
|
@@ -1607,7 +1632,7 @@ def _plan_task(reader, tasks, task_id):
|
|
|
1607
1632
|
|
|
1608
1633
|
def _review(kind, item, text):
|
|
1609
1634
|
return dict(kind=kind, execution=item['id'], attempt=item['attempt'], spec=(item['model'] or {}).get('spec'),
|
|
1610
|
-
verdict=item['verdict'], state=item['state'], findings=findings.listing(text))
|
|
1635
|
+
verdict=item['verdict'], state=item['state'], findings=findings.listing(text), tests=findings.tests(text))
|
|
1611
1636
|
|
|
1612
1637
|
|
|
1613
1638
|
def task_detail(path, task_id, source='plan'):
|
|
@@ -1642,12 +1667,14 @@ def task_detail(path, task_id, source='plan'):
|
|
|
1642
1667
|
# The reply in the task dir is normally the copy of the last review; only an unmatched one is listed.
|
|
1643
1668
|
if live is not None and live not in seen:
|
|
1644
1669
|
reviews.append(dict(kind='primary', execution=None, attempt=attempt, spec=spec, verdict=_verdict(live),
|
|
1645
|
-
state='done', findings=findings.listing(live)))
|
|
1670
|
+
state='done', findings=findings.listing(live), tests=findings.tests(live)))
|
|
1646
1671
|
for entry, items, sub in shadows:
|
|
1647
1672
|
run = items[-1] if items else None
|
|
1673
|
+
shadow_text = reader.text(sub + '/qa.last')
|
|
1648
1674
|
reviews.append(dict(kind='shadow', execution=entry['execution'], attempt=entry['attempt'],
|
|
1649
1675
|
spec=entry['spec'] if isinstance(entry['spec'], str) else None, verdict=entry['verdict'],
|
|
1650
|
-
state=run['state'] if run else None, findings=findings.listing(
|
|
1676
|
+
state=run['state'] if run else None, findings=findings.listing(shadow_text),
|
|
1677
|
+
tests=findings.tests(shadow_text)))
|
|
1651
1678
|
return dict(run=run_key(reader.path), id=task_id, texts=texts, gate=_gate(reader, base + 'qa.gate'),
|
|
1652
1679
|
reviews=reviews, truncated=reader.truncated, warnings=reader.warnings)
|
|
1653
1680
|
|
|
@@ -1890,10 +1917,64 @@ def final_review_detail(path, name, source='plan'):
|
|
|
1890
1917
|
qa_input=reader.excerpt(rel + '/qa.input', 40000, 20000, 'qa_input'),
|
|
1891
1918
|
qa_last=reader.clip(qa_last, 20000, 8000, 'qa_last'),
|
|
1892
1919
|
known_issues=reader.excerpt(rel + '/known_issues.md', 20000, 8000, 'known_issues'),
|
|
1893
|
-
findings=findings.listing(qa_last),
|
|
1920
|
+
findings=findings.listing(qa_last), tests=findings.tests(qa_last),
|
|
1921
|
+
truncated=reader.truncated, warnings=reader.warnings)
|
|
1894
1922
|
return result
|
|
1895
1923
|
|
|
1896
1924
|
|
|
1925
|
+
def _adoption(reader, name):
|
|
1926
|
+
"""The adoptions.tsv row of adopt-<epoch>-<pid> `name`, or None."""
|
|
1927
|
+
if _kind(reader.path) != 'plan' or not _ADOPT_NAME.fullmatch(name or ''):
|
|
1928
|
+
return None
|
|
1929
|
+
return next((row for row in _adoptions(reader) if row['review'] == name), None) if reader.exists(name) else None
|
|
1930
|
+
|
|
1931
|
+
|
|
1932
|
+
def adoption_detail(path, name, source='plan'):
|
|
1933
|
+
"""AdoptionDetail of a range `adopt` brought in (#131): its row, what its reviewer read and said, the findings
|
|
1934
|
+
and what was kept; None when the run adopted nothing under that name."""
|
|
1935
|
+
reader = _Read(path)
|
|
1936
|
+
row = _adoption(reader, name)
|
|
1937
|
+
if row is None:
|
|
1938
|
+
return None
|
|
1939
|
+
qa_last = reader.text(name + '/qa.last')
|
|
1940
|
+
execs = executions.scan(reader, name + '/attempts', False, ('qa',))
|
|
1941
|
+
run = execs[-1] if execs else None
|
|
1942
|
+
threshold = reader.word(name + '/qa_threshold')
|
|
1943
|
+
return dict(name=name, adoption=row, verdict=reader.word(name + '/verdict') or row['verdict'],
|
|
1944
|
+
threshold=None if threshold in (None, 'none') else threshold, gate=_gate(reader, name + '/qa.gate'),
|
|
1945
|
+
started=run['started'] if run else None, ended=run['ended'] if run else None,
|
|
1946
|
+
duration_s=run['duration_s'] if run else None,
|
|
1947
|
+
qa_input=reader.excerpt(name + '/qa.input', 40000, 20000, 'qa_input'),
|
|
1948
|
+
qa_last=reader.clip(qa_last, 20000, 8000, 'qa_last'),
|
|
1949
|
+
known_issues=reader.excerpt(name + '/known_issues.md', 20000, 8000, 'known_issues'),
|
|
1950
|
+
findings=findings.listing(qa_last), tests=findings.tests(qa_last), diff=row['diff'],
|
|
1951
|
+
truncated=reader.truncated, warnings=reader.warnings)
|
|
1952
|
+
|
|
1953
|
+
|
|
1954
|
+
def adoption_diff(path, name, source='plan'):
|
|
1955
|
+
"""DiffDetail of an adopted range: its range.diff, else the ```diff fence of its review's prompt, with the
|
|
1956
|
+
review's findings pinned; None when the run adopted nothing under that name."""
|
|
1957
|
+
reader = _Read(path)
|
|
1958
|
+
row = _adoption(reader, name)
|
|
1959
|
+
if row is None:
|
|
1960
|
+
return None
|
|
1961
|
+
loaded = rel = None
|
|
1962
|
+
for rel, fence in ((name + '/range.diff', False), (name + '/qa.input', True)):
|
|
1963
|
+
if os.path.lexists(reader.path / rel):
|
|
1964
|
+
loaded = diffs.load(reader, rel, fence)
|
|
1965
|
+
if loaded is not None:
|
|
1966
|
+
break
|
|
1967
|
+
key = run_key(reader.path)
|
|
1968
|
+
info = _regular(reader, name + '/range.diff')
|
|
1969
|
+
sources = [dict(id=name, label='range.diff' if info else 'reviewed diff', kind='adoption', verdict=row['verdict'],
|
|
1970
|
+
bytes=info.st_size if info else None, url=_url(key, 'adoptions', name, 'diff'))]
|
|
1971
|
+
origin = dict(kind='adoption', id=name, which='reviewed', execution=None, attempt=None,
|
|
1972
|
+
file=rel if loaded is not None else None)
|
|
1973
|
+
review = _diff_review('adoption', None, None, row['spec'], row['verdict'], name + '/qa.last', [])
|
|
1974
|
+
# adopt leaves the diff out of the prompt, and range.diff out of the dir, past the inline limit
|
|
1975
|
+
return _diff_detail(reader, key, origin, sources, loaded, _NOT_INLINED, [review])
|
|
1976
|
+
|
|
1977
|
+
|
|
1897
1978
|
# --- diffs: what a task changed and what each review read, its findings pinned -------------
|
|
1898
1979
|
|
|
1899
1980
|
_PLAN_DIFFS = (('current', 'changes.diff'), ('prev', 'changes.prev.diff'), ('committed', 'committed.diff'))
|
|
@@ -2024,7 +2105,7 @@ def _diff_detail(reader, key, origin, sources, loaded, reason, reviews):
|
|
|
2024
2105
|
for index, item in enumerate(findings.listing(text) or []):
|
|
2025
2106
|
found.append(dict(id=_finding_id(review, index), review={key: review[key] for key in ('kind', 'execution', 'attempt', 'spec')},
|
|
2026
2107
|
severity=item['severity'], status=item['status'], location=item['location'],
|
|
2027
|
-
summary=item['summary'], text=item['text']))
|
|
2108
|
+
summary=item['summary'], facts=item['facts'], text=item['text']))
|
|
2028
2109
|
return dict(run=key, source=origin, sources=sources, available=loaded is not None,
|
|
2029
2110
|
reason=None if loaded is not None else reason, bytes=loaded['bytes'] if loaded else None,
|
|
2030
2111
|
truncated=bool(loaded and loaded['truncated']), files=files, findings=diffs.pin(found, files),
|
|
@@ -2144,7 +2225,7 @@ def _finding_id(review, index):
|
|
|
2144
2225
|
def _findings_of(reader, review):
|
|
2145
2226
|
listed = findings.listing(reader.text(review['last'])) if review['last'] else None
|
|
2146
2227
|
return [dict(id=_finding_id(review, index), severity=item['severity'], status=item['status'],
|
|
2147
|
-
location=item['location'], summary=item['summary'])
|
|
2228
|
+
location=item['location'], summary=item['summary'], facts=item['facts'])
|
|
2148
2229
|
for index, item in enumerate(listed or [])]
|
|
2149
2230
|
|
|
2150
2231
|
|
|
@@ -2529,6 +2610,12 @@ class Catalog:
|
|
|
2529
2610
|
def final_review_diff(self, key, name):
|
|
2530
2611
|
return self._find(key, final_review_diff, name)
|
|
2531
2612
|
|
|
2613
|
+
def adoption(self, key, name):
|
|
2614
|
+
return self._find(key, adoption_detail, name)
|
|
2615
|
+
|
|
2616
|
+
def adoption_diff(self, key, name):
|
|
2617
|
+
return self._find(key, adoption_diff, name)
|
|
2618
|
+
|
|
2532
2619
|
def files(self, key):
|
|
2533
2620
|
return self._find(key, files_detail)
|
|
2534
2621
|
|
package/ui/forge_ui/server.py
CHANGED
|
@@ -45,6 +45,8 @@ _EXEC_CHECKS_PATH = re.compile(_EXEC_PATH.pattern + '/checks')
|
|
|
45
45
|
_TASK_CHECKS_PATH = re.compile(_TASK_PATH.pattern + '/checks')
|
|
46
46
|
_ENVIRONMENT_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/environment')
|
|
47
47
|
_REVIEW_DIFF_PATH = re.compile(_REVIEW_PATH.pattern + '/diff')
|
|
48
|
+
_ADOPTION_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/adoptions/(adopt-[0-9]+-[0-9]+)')
|
|
49
|
+
_ADOPTION_DIFF_PATH = re.compile(_ADOPTION_PATH.pattern + '/diff')
|
|
48
50
|
_FILES_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/files')
|
|
49
51
|
_FINDINGS_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/findings')
|
|
50
52
|
_EXPORT_PATH = re.compile(r'/api/runs/([0-9a-f]{12})/export')
|
|
@@ -144,6 +146,12 @@ def api_get(catalog, path):
|
|
|
144
146
|
match = _REVIEW_DIFF_PATH.fullmatch(path)
|
|
145
147
|
if match:
|
|
146
148
|
return catalog.final_review_diff(*match.groups())
|
|
149
|
+
match = _ADOPTION_PATH.fullmatch(path)
|
|
150
|
+
if match:
|
|
151
|
+
return catalog.adoption(*match.groups())
|
|
152
|
+
match = _ADOPTION_DIFF_PATH.fullmatch(path)
|
|
153
|
+
if match:
|
|
154
|
+
return catalog.adoption_diff(*match.groups())
|
|
147
155
|
match = _TRANSCRIPT_PATH.fullmatch(path)
|
|
148
156
|
if match:
|
|
149
157
|
return catalog.transcript(*match.groups())
|
|
@@ -51,16 +51,19 @@ window.ForgeApp = (() => {
|
|
|
51
51
|
if (sel.kind === 'task') return `${base}/tasks/${e(sel.id)}`;
|
|
52
52
|
if (sel.kind === 'execution') return sel.task ? `${base}/tasks/${e(sel.task)}/executions/${e(sel.exec)}` : `${base}/executions/${e(sel.exec)}`;
|
|
53
53
|
if (sel.kind === 'final') return `${base}/final-review${sel.name ? '/' + e(sel.name) : ''}`;
|
|
54
|
+
if (sel.kind === 'adoption') return `${base}/adoptions/${e(sel.name)}`;
|
|
54
55
|
if (sel.kind === 'verification') return `${base}/verification`;
|
|
55
56
|
if (sel.kind === 'integration') return `${base}/integration`;
|
|
56
57
|
if (sel.kind === 'fractal') return `${base}/tasks/${e(sel.task)}/fractal/${e(sel.node)}`;
|
|
57
58
|
return base;
|
|
58
59
|
}
|
|
59
|
-
// a diff: {kind: 'task', task, source, file} | {kind: 'final', name, file} | {kind: '
|
|
60
|
+
// a diff: {kind: 'task', task, source, file} | {kind: 'final', name, file} | {kind: 'adoption', name, file}
|
|
61
|
+
// | {kind: 'fractal', task, node, file},
|
|
60
62
|
// opened at a file, or at one finding (its id from /findings)
|
|
61
63
|
function diffHash(key, spec) {
|
|
62
64
|
const e = encodeURIComponent, base = '#/runs/' + e(key), file = spec.finding ? '/finding/' + e(spec.finding) : spec.file ? '/file/' + e(spec.file) : '';
|
|
63
65
|
if (spec.kind === 'final') return `${base}/final-review/${e(spec.name)}/diff${file}`;
|
|
66
|
+
if (spec.kind === 'adoption') return `${base}/adoptions/${e(spec.name)}/diff${file}`;
|
|
64
67
|
if (spec.kind === 'fractal') return `${base}/tasks/${e(spec.task)}/fractal/${e(spec.node)}/diff${file}`;
|
|
65
68
|
return `${base}/tasks/${e(spec.task)}/diff${spec.source && spec.source !== 'current' ? '/' + e(spec.source) : ''}${file}`;
|
|
66
69
|
}
|
|
@@ -75,6 +78,10 @@ window.ForgeApp = (() => {
|
|
|
75
78
|
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
79
|
if (/^#\/models\/?$/.test(hash)) return { key: null, sel: null, models: true };
|
|
77
80
|
if (/^#\/settings\/?$/.test(hash)) return { key: null, sel: null, settings: true };
|
|
81
|
+
const pj = hash.match(/^#\/projects(?:\/([0-9a-f]{8})(?:\/(runs|findings|memories))?)?\/?$/);
|
|
82
|
+
if (pj) return { key: null, sel: null, projects: { id: pj[1] || null, tab: pj[2] || 'runs' } };
|
|
83
|
+
const w = hash.match(/^#\/worktrees(?:\/(repo|runs)\/([^/]+))?\/?$/);
|
|
84
|
+
if (w) return { key: null, sel: null, worktrees: { repo: w[1] === 'repo' ? decodeURIComponent(w[2]) : '', run: w[1] === 'runs' ? decodeURIComponent(w[2]) : '' } };
|
|
78
85
|
const m = hash.match(/^#\/runs\/([^/]+)(\/.*)?$/);
|
|
79
86
|
if (!m) return { key: null, sel: null };
|
|
80
87
|
const d = decodeURIComponent, rest = m[2] || '';
|
|
@@ -83,6 +90,7 @@ window.ForgeApp = (() => {
|
|
|
83
90
|
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 } };
|
|
84
91
|
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 } };
|
|
85
92
|
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 } };
|
|
93
|
+
if ((r = rest.match(/^\/adoptions\/([^/]+)\/diff(?:\/finding\/([^/]+))?(?:\/file\/(.+?))?\/?$/))) return { key: d(m[1]), sel: { kind: 'adoption', name: d(r[1]) }, diff: { kind: 'adoption', name: d(r[1]), finding: r[2] ? d(r[2]) : null, file: r[3] ? d(r[3]) : null } };
|
|
86
94
|
if ((r = rest.match(/^\/(?:tasks\/([^/]+)\/)?executions\/([^/]+)\/conversation(?:\/event\/(\d{1,7}))?\/?$/))) {
|
|
87
95
|
const s = r[1] ? { kind: 'execution', task: d(r[1]), id: d(r[1]), exec: d(r[2]) } : { kind: 'execution', task: null, exec: d(r[2]) };
|
|
88
96
|
const run = s.task && state.cache.get(d(m[1]))?.data, t = run && list(run.tasks).find(x => x.id === s.task);
|
|
@@ -97,6 +105,7 @@ window.ForgeApp = (() => {
|
|
|
97
105
|
else if ((r = rest.match(/^\/tasks\/([^/]+)\/?$/))) sel = { kind: 'task', id: d(r[1]) };
|
|
98
106
|
else if ((r = rest.match(/^\/executions\/([^/]+)\/?$/))) sel = { kind: 'execution', task: null, exec: d(r[1]) };
|
|
99
107
|
else if ((r = rest.match(/^\/final-review(?:\/([^/]+))?\/?$/))) sel = { kind: 'final', name: r[1] ? d(r[1]) : null };
|
|
108
|
+
else if ((r = rest.match(/^\/adoptions\/([^/]+)\/?$/))) sel = { kind: 'adoption', name: d(r[1]) };
|
|
100
109
|
else if (/^\/verification\/?$/.test(rest)) sel = { kind: 'verification' };
|
|
101
110
|
else if (/^\/integration\/?$/.test(rest)) sel = { kind: 'integration' };
|
|
102
111
|
else if ((r = rest.match(/^\/tasks\/([^/]+)\/fractal\/([^/]+)\/?$/))) sel = { kind: 'fractal', task: d(r[1]), node: d(r[2]) };
|
|
@@ -168,7 +177,12 @@ window.ForgeApp = (() => {
|
|
|
168
177
|
return body;
|
|
169
178
|
}
|
|
170
179
|
// Restore disclosures, internal scroll and keyboard focus after changed data arrives.
|
|
171
|
-
|
|
180
|
+
// A live refresh waits for what the user is doing (#115). An export has no uikit.js and never refreshes: it just draws.
|
|
181
|
+
const guard = (region, draw) => { if (window.ForgeUI?.guard) window.ForgeUI.guard(region, draw); else draw(); };
|
|
182
|
+
const keepOpen = (region, draw) => { if (window.ForgeUI?.keepOpen) window.ForgeUI.keepOpen(region, draw); else draw(); };
|
|
183
|
+
const forget = region => { if (window.ForgeUI?.forget) window.ForgeUI.forget(region); };
|
|
184
|
+
function preserve(parent, build, options) { guard(parent, () => preserveNow(parent, build, options)); }
|
|
185
|
+
function preserveNow(parent, build, { restore = true } = {}) {
|
|
172
186
|
const open = new Map(Array.from(parent.querySelectorAll('details[data-keep]'), n => [n.dataset.keep, n.open]));
|
|
173
187
|
const scroll = new Map(Array.from(parent.querySelectorAll('[data-scroll]'), n => [n.dataset.scroll, [n.scrollLeft, n.scrollTop]]));
|
|
174
188
|
const active = parent.contains(document.activeElement) ? document.activeElement : null;
|
|
@@ -214,9 +228,11 @@ window.ForgeApp = (() => {
|
|
|
214
228
|
// The worktree is "leaf (branch)": the leaf truncates first, the branch keeps its place. The title is the full path
|
|
215
229
|
// and, on a second line, the full branch, since the branch can be truncated on screen.
|
|
216
230
|
// No worktree: the name span alone, as before.
|
|
217
|
-
function appendRepo(parent, run) {
|
|
231
|
+
function appendRepo(parent, run, linked) {
|
|
218
232
|
const label = RM.repoLabel(run);
|
|
219
|
-
const
|
|
233
|
+
const href = linked && !SNAP && window.ForgeProjects ? projectHref(RM.repoKey(run)) : null;
|
|
234
|
+
const name = el(href ? 'a' : 'span', label.name, 'repo');
|
|
235
|
+
if (href) { name.href = href; name.title = 'This repository\'s project: its runs, findings and memories'; name.classList.add('project-link'); }
|
|
220
236
|
if (!label.worktree) { parent.append(name); return; }
|
|
221
237
|
const line = el('span', undefined, 'repo-line');
|
|
222
238
|
const wt = el('span', undefined, 'muted repo-wt');
|
|
@@ -275,6 +291,7 @@ window.ForgeApp = (() => {
|
|
|
275
291
|
}
|
|
276
292
|
$('run-list').append(item);
|
|
277
293
|
}
|
|
294
|
+
markSelection(); // inside: a held draw runs later, with new nodes to mark
|
|
278
295
|
});
|
|
279
296
|
markSelection();
|
|
280
297
|
}
|
|
@@ -380,7 +397,10 @@ window.ForgeApp = (() => {
|
|
|
380
397
|
const wrap = el('div', undefined, 'map-cards');
|
|
381
398
|
for (const layer of A.layers) {
|
|
382
399
|
const g = el('section', undefined, 'map-repo');
|
|
383
|
-
|
|
400
|
+
const h = el('h3'), href = !SNAP && window.ForgeProjects ? projectHref(layer.repo) : null;
|
|
401
|
+
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); }
|
|
402
|
+
else h.textContent = layer.name;
|
|
403
|
+
g.append(h);
|
|
384
404
|
const grid = el('div', undefined, 'map-grid');
|
|
385
405
|
for (const m of A.modules.filter(x => x.layer === layer.id)) {
|
|
386
406
|
const r = m.run, card = link(undefined, r.key);
|
|
@@ -418,6 +438,10 @@ window.ForgeApp = (() => {
|
|
|
418
438
|
el('pre', 'forge ui open <run-dir>', 'cmd'),
|
|
419
439
|
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
440
|
}
|
|
441
|
+
function mapCount(info) {
|
|
442
|
+
const counter = $('map-view')?.querySelector('.map-head .map-count');
|
|
443
|
+
if (counter) counter.textContent = `${info.matches} of ${info.shown} shown runs match${info.hidden ? ` · ${info.hidden} older hidden` : ''}`;
|
|
444
|
+
}
|
|
421
445
|
function renderMap({ rebuildBar = true } = {}) {
|
|
422
446
|
const main = $('main');
|
|
423
447
|
if (state.listLoaded && !state.runs.length && !SNAP) { renderFirstRun(); return; }
|
|
@@ -449,10 +473,10 @@ window.ForgeApp = (() => {
|
|
|
449
473
|
info = state.stage.showAtlas(state.runs, state.mapFilter, { showAll: state.showAll });
|
|
450
474
|
$('map-cards').replaceChildren();
|
|
451
475
|
} else {
|
|
452
|
-
|
|
476
|
+
// The count is set with the cards, so a held draw brings its own when it runs.
|
|
477
|
+
preserve($('map-cards'), () => { const A = mapCards($('map-cards')); mapCount({ hidden: A.hidden, matches: A.matches, shown: A.modules.length, total: A.total }); });
|
|
453
478
|
}
|
|
454
|
-
|
|
455
|
-
if (info) counter.textContent = `${info.matches} of ${info.shown} shown runs match${info.hidden ? ` · ${info.hidden} older hidden` : ''}`;
|
|
479
|
+
if (info) mapCount(info);
|
|
456
480
|
}
|
|
457
481
|
|
|
458
482
|
/* ---------- the run cloud: every run in 3D, full screen ---------- */
|
|
@@ -494,12 +518,12 @@ window.ForgeApp = (() => {
|
|
|
494
518
|
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
519
|
return;
|
|
496
520
|
}
|
|
497
|
-
window.ForgeLeaderboard.render(host, state.modelsData, {
|
|
521
|
+
guard(host, () => window.ForgeLeaderboard.render(host, state.modelsData, {
|
|
498
522
|
runs: state.runs, prefs: state.modelsPrefs, now: () => Date.now() / 1000,
|
|
499
523
|
savePrefs: p => { state.modelsPrefs = p; store.set('models', p); },
|
|
500
524
|
tablePrefs: id => state.tablePrefs[id], saveTablePrefs: (id, p) => { state.tablePrefs = { ...state.tablePrefs, [id]: p }; store.set('tables', state.tablePrefs); },
|
|
501
525
|
modelHref: alias => '#/cloud/models/' + encodeURIComponent(alias), reviewerOutcomes: state.reviewerOutcomes,
|
|
502
|
-
});
|
|
526
|
+
}));
|
|
503
527
|
}
|
|
504
528
|
// How each reviewer's PASSed work held up (forge dataset reviewers). Advisory and optional: read once per
|
|
505
529
|
// change of the models data, and a failure (an export, no dataset) only leaves the column empty.
|
|
@@ -532,6 +556,35 @@ window.ForgeApp = (() => {
|
|
|
532
556
|
});
|
|
533
557
|
}
|
|
534
558
|
|
|
559
|
+
/* ---------- every worktree forge created (#/worktrees) ---------- */
|
|
560
|
+
// It reads /api/worktrees itself, when opened and at a slow interval: never on the page's poll.
|
|
561
|
+
function renderWorktrees() {
|
|
562
|
+
const main = $('main');
|
|
563
|
+
if (main.dataset.view === 'worktrees' && state.worktreesView) { state.worktreesView.setFilter(state.worktrees); return; }
|
|
564
|
+
setView(main, 'worktrees'); delete main.dataset.run;
|
|
565
|
+
main.replaceChildren();
|
|
566
|
+
const v = el('section', undefined, 'worktrees-view'); v.id = 'worktrees-view'; main.append(v);
|
|
567
|
+
state.worktreesView = window.ForgeWorktrees.render(v, {
|
|
568
|
+
filter: state.worktrees, runHref: key => '#/runs/' + encodeURIComponent(key),
|
|
569
|
+
tablePrefs: id => state.tablePrefs[id], saveTablePrefs: (id, p) => { state.tablePrefs = { ...state.tablePrefs, [id]: p }; store.set('tables', state.tablePrefs); },
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/* ---------- each repository's runs, findings and memories (#/projects) ---------- */
|
|
574
|
+
function renderProjects() {
|
|
575
|
+
const main = $('main'), p = state.projects;
|
|
576
|
+
if (main.dataset.view === 'projects' && state.projectsView) { state.projectsView.go(p.id, p.tab); return; }
|
|
577
|
+
setView(main, 'projects'); delete main.dataset.run;
|
|
578
|
+
main.replaceChildren();
|
|
579
|
+
const v = el('section', undefined, 'projects-view'); v.id = 'projects-view'; main.append(v);
|
|
580
|
+
state.projectsView = window.ForgeProjects.render(v, {
|
|
581
|
+
id: p.id, tab: p.tab, runHref: key => '#/runs/' + encodeURIComponent(key),
|
|
582
|
+
tablePrefs: id => state.tablePrefs[id], saveTablePrefs: (id, pr) => { state.tablePrefs = { ...state.tablePrefs, [id]: pr }; store.set('tables', state.tablePrefs); },
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
// a repository's project page: the id is the run cloud's (cloudmodel.js hashId of the repository root)
|
|
586
|
+
const projectHref = repo => window.ForgeCloudModel && repo ? '#/projects/' + window.ForgeCloudModel.hashId(String(repo)) : null;
|
|
587
|
+
|
|
535
588
|
/* ---------- a run's open findings (#/runs/<key>/findings) ---------- */
|
|
536
589
|
function renderFindings() {
|
|
537
590
|
const main = $('main');
|
|
@@ -654,6 +707,12 @@ window.ForgeApp = (() => {
|
|
|
654
707
|
rec.addEventListener('click', () => { Shell.toggle('insp', true); if (state.sel) select(null); });
|
|
655
708
|
acts.append(rec);
|
|
656
709
|
if (!SNAP && window.ForgeFindings) acts.append(findingsLink(state.key));
|
|
710
|
+
if (!SNAP && window.ForgeWorktrees && (state.cache.get(state.key)?.data || {}).kind !== 'solo') {
|
|
711
|
+
const wt = el('a', undefined, 'details-btn worktrees-link'); wt.href = '#/worktrees/runs/' + encodeURIComponent(state.key);
|
|
712
|
+
wt.title = 'This run\'s worktrees: what state each is in, and the command that removes it';
|
|
713
|
+
wt.append(icon('panel-right'), el('span', 'Worktrees'));
|
|
714
|
+
acts.append(wt);
|
|
715
|
+
}
|
|
657
716
|
if (!SNAP) {
|
|
658
717
|
const ex = el('button', undefined, 'export-btn'); ex.type = 'button'; ex.title = 'Download this run as one HTML file to share';
|
|
659
718
|
ex.append(icon('download'), el('span', 'Export…'));
|
|
@@ -747,7 +806,7 @@ window.ForgeApp = (() => {
|
|
|
747
806
|
const lamp = el('i', undefined, 'lamp st-' + LAMP[RM.runState(run)]);
|
|
748
807
|
const title = el('h2', String(run.goal || 'Untitled run').split('\n')[0]); title.title = run.goal || '';
|
|
749
808
|
const where = el('span', undefined, 'run-where'); where.title = `${run.repo || ''}\n${run.run_id || ''}`;
|
|
750
|
-
appendRepo(where, run);
|
|
809
|
+
appendRepo(where, run, true);
|
|
751
810
|
where.append(el('span', run.run_id, 'mono'));
|
|
752
811
|
if (solo) where.append(document.createTextNode(' · solo run'));
|
|
753
812
|
// the describer: each state's count, the wall time so far, and how long since anything moved
|
|
@@ -804,7 +863,8 @@ window.ForgeApp = (() => {
|
|
|
804
863
|
const tools = box && box.querySelector('.module-tools');
|
|
805
864
|
let slot = tools && tools.querySelector('.dt-tools');
|
|
806
865
|
if (tools && !slot) { slot = el('span', undefined, 'dt-tools'); tools.prepend(slot); }
|
|
807
|
-
|
|
866
|
+
// The table's column button lives in `slot`, outside `host`, and a redraw replaces it: both count as in use.
|
|
867
|
+
guard(slot || host, () => preserve(host, () => {
|
|
808
868
|
if (run.kind === 'solo') { if (slot) slot.replaceChildren(); return; }
|
|
809
869
|
if (!list(run.tasks).length) { if (slot) slot.replaceChildren(); host.append(el('p', 'This run has no tasks yet.', 'empty')); return; }
|
|
810
870
|
Table.render(host, {
|
|
@@ -816,7 +876,7 @@ window.ForgeApp = (() => {
|
|
|
816
876
|
}),
|
|
817
877
|
});
|
|
818
878
|
scoped(host, run.key + ':');
|
|
819
|
-
});
|
|
879
|
+
}));
|
|
820
880
|
}
|
|
821
881
|
function renderInspector(run) {
|
|
822
882
|
const host = $('inspector'); if (!host || !window.ForgePanel) return;
|
|
@@ -850,14 +910,14 @@ window.ForgeApp = (() => {
|
|
|
850
910
|
const host = $('strip'); if (!host) return;
|
|
851
911
|
const show = state.mode === 'exec' && run.kind !== 'solo';
|
|
852
912
|
host.hidden = !show;
|
|
853
|
-
if (show) window.ForgeGantt.strip(host, run, { now: now(), replay: state.replay }); else host.replaceChildren();
|
|
913
|
+
guard(host, () => { if (show) window.ForgeGantt.strip(host, run, { now: now(), replay: state.replay }); else host.replaceChildren(); });
|
|
854
914
|
}
|
|
855
915
|
// Files: which task touched which file, in the stage's place (the inspector stays beside it)
|
|
856
916
|
function renderFiles(run) {
|
|
857
917
|
const host = $('files-view'), view = $('run-view'); if (!host || !view) return;
|
|
858
918
|
const open = state.mode === 'files' && !!window.ForgeFiles;
|
|
859
919
|
view.classList.toggle('files-open', open); host.hidden = !open;
|
|
860
|
-
if (!open) { host.filesSig = ''; return; }
|
|
920
|
+
if (!open) { host.filesSig = ''; forget(host); return; }
|
|
861
921
|
const c = state.files.get(run.key);
|
|
862
922
|
if (!c || c.updated !== run.updated) loadFiles(run);
|
|
863
923
|
if (!c || !c.data) {
|
|
@@ -868,9 +928,9 @@ window.ForgeApp = (() => {
|
|
|
868
928
|
const sig = JSON.stringify([c.at, state.sel]);
|
|
869
929
|
if (host.filesSig === sig) return; // a poll that changed nothing here redraws nothing
|
|
870
930
|
host.filesSig = sig;
|
|
871
|
-
window.ForgeFiles.render(host, c.data, { run, sel: state.sel, onSelectTask: id => select({ kind: 'task', id }),
|
|
931
|
+
guard(host, () => keepOpen(host, () => window.ForgeFiles.render(host, c.data, { run, sel: state.sel, onSelectTask: id => select({ kind: 'task', id }),
|
|
872
932
|
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); } });
|
|
933
|
+
prefs: state.filesPrefs, savePrefs: p => { state.filesPrefs = p; store.set('files', p); } })));
|
|
874
934
|
}
|
|
875
935
|
// every review's findings of the run, for the stage's marks: read again when the run changes
|
|
876
936
|
function syncFindings(run) {
|
|
@@ -893,7 +953,8 @@ window.ForgeApp = (() => {
|
|
|
893
953
|
const host = $('diff-view'), view = $('run-view'); if (!host || !view) return;
|
|
894
954
|
const kind = state.convo && window.ForgeConvo ? 'convo' : state.diff && window.ForgeDiff ? 'diff' : null;
|
|
895
955
|
view.classList.toggle('diff-open', !!kind); host.hidden = !kind;
|
|
896
|
-
|
|
956
|
+
// What was held for the view being left would draw it over what replaced it.
|
|
957
|
+
if (host.dataset.kind !== (kind || '')) { forget(host); host.replaceChildren(); host.diffSig = ''; host.convoFrame = null; host.dataset.kind = kind || ''; }
|
|
897
958
|
if (!kind) return;
|
|
898
959
|
const rerender = () => { const r = state.cache.get(state.key)?.data; if (r) renderDiff(r); };
|
|
899
960
|
if (kind === 'convo') {
|
|
@@ -903,8 +964,9 @@ window.ForgeApp = (() => {
|
|
|
903
964
|
fetchJSON: path => fetchJSON(path).then(r => r.data), rerender, diffHash: spec => diffHash(run.key, spec), closeHref: hashFor(run.key, state.sel) });
|
|
904
965
|
return;
|
|
905
966
|
}
|
|
906
|
-
|
|
907
|
-
|
|
967
|
+
const spec = state.diff; // this draw's, whenever a hold lets it run
|
|
968
|
+
guard(host, () => keepOpen(host, () => window.ForgeDiff.render(host, { run, spec, fetchJSON: path => fetchJSON(path).then(r => r.data), rerender,
|
|
969
|
+
href: spec => diffHash(run.key, spec), closeHref: hashFor(run.key, state.sel) })));
|
|
908
970
|
}
|
|
909
971
|
function renderRunBody(run) {
|
|
910
972
|
renderDiff(run);
|
|
@@ -960,6 +1022,8 @@ window.ForgeApp = (() => {
|
|
|
960
1022
|
if (state.cloud) { renderCloud(); return; }
|
|
961
1023
|
if (state.models) { renderModels(); return; }
|
|
962
1024
|
if (state.settings) { renderSettings(); return; }
|
|
1025
|
+
if (state.worktrees) { renderWorktrees(); return; }
|
|
1026
|
+
if (state.projects) { renderProjects(); return; }
|
|
963
1027
|
if (state.key && state.findingsPage) { renderFindings(); return; }
|
|
964
1028
|
if (!state.key) { renderMap(); return; }
|
|
965
1029
|
const cached = state.cache.get(state.key);
|
|
@@ -1016,7 +1080,8 @@ window.ForgeApp = (() => {
|
|
|
1016
1080
|
renderList();
|
|
1017
1081
|
if (state.cloud) renderCloud();
|
|
1018
1082
|
else if (state.settings) state.settingsView?.poll(); // the picker follows the run list; the page stays
|
|
1019
|
-
else if (
|
|
1083
|
+
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 });
|
|
1020
1085
|
}, 'Could not refresh runs');
|
|
1021
1086
|
}
|
|
1022
1087
|
function loadRun(key) {
|
|
@@ -1052,6 +1117,8 @@ window.ForgeApp = (() => {
|
|
|
1052
1117
|
state.cloud = parsed.cloud || null;
|
|
1053
1118
|
state.models = !!parsed.models;
|
|
1054
1119
|
state.settings = !!parsed.settings && !!window.ForgeSettings && !SNAP;
|
|
1120
|
+
state.worktrees = parsed.worktrees && window.ForgeWorktrees && !SNAP ? parsed.worktrees : null;
|
|
1121
|
+
state.projects = parsed.projects && window.ForgeProjects && !SNAP ? parsed.projects : null;
|
|
1055
1122
|
if (parsed.key) state.lastKey = parsed.key;
|
|
1056
1123
|
state.findingsPage = !!parsed.findings && !!window.ForgeFindings;
|
|
1057
1124
|
if (state.cloud && state.cloud.model) { // a model's runs: the cloud, filtered to it
|
|
@@ -1061,7 +1128,7 @@ window.ForgeApp = (() => {
|
|
|
1061
1128
|
document.body.classList.toggle('cloud-mode', !!state.cloud);
|
|
1062
1129
|
if (!state.key) document.body.classList.remove('no-tasks');
|
|
1063
1130
|
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);
|
|
1131
|
+
const here = a.getAttribute('href') === (state.cloud ? '#/cloud' : state.models ? '#/models' : state.settings ? '#/settings' : state.worktrees ? '#/worktrees' : state.projects ? '#/projects' : !state.key ? '#/' : null);
|
|
1065
1132
|
if (here) a.setAttribute('aria-current', 'page'); else a.removeAttribute('aria-current');
|
|
1066
1133
|
}
|
|
1067
1134
|
renderErrors();
|
|
@@ -1069,6 +1136,8 @@ window.ForgeApp = (() => {
|
|
|
1069
1136
|
if (state.cloud) { renderCloud(); return; }
|
|
1070
1137
|
if (state.models) { renderModels(); loadModels(); return; }
|
|
1071
1138
|
if (state.settings) { renderSettings(); return; }
|
|
1139
|
+
if (state.worktrees) { renderWorktrees(); return; }
|
|
1140
|
+
if (state.projects) { renderProjects(); return; }
|
|
1072
1141
|
if (state.key && state.findingsPage) { renderFindings(); return; }
|
|
1073
1142
|
if (!state.key) { renderMap(); return; }
|
|
1074
1143
|
const cached = state.cache.get(state.key);
|
|
@@ -1116,6 +1185,8 @@ window.ForgeApp = (() => {
|
|
|
1116
1185
|
{ id: 'cmd:cloud', label: 'Open the run cloud', sub: 'every run in 3D, grouped by project', ids: ['cloud'], href: '#/cloud' },
|
|
1117
1186
|
{ id: 'cmd:map', label: 'Open the map of all runs', sub: 'the front page', ids: ['map', 'home'], href: '#/' },
|
|
1118
1187
|
{ id: 'cmd:models', label: 'Open the model leaderboard', sub: 'pass rates, retries, time and tokens per model', ids: ['models', 'leaderboard'], href: '#/models' },
|
|
1188
|
+
...(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', 'disk'], href: '#/worktrees' }] : []),
|
|
1119
1190
|
...(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
1191
|
{ id: 'cmd:notify', label: 'Notifications', sub: 'what finished or failed, and browser notifications', ids: ['alerts', 'bell'], action: () => window.ForgeNotify && window.ForgeNotify.open() },
|
|
1121
1192
|
{ 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 +1261,15 @@ window.ForgeApp = (() => {
|
|
|
1190
1261
|
// window.ForgeUI is uikit.js's shared helpers; the page's own handles (state, refresh) join it, where the browser
|
|
1191
1262
|
// tests and ui/tools/readme_media.py read them.
|
|
1192
1263
|
window.ForgeUI = Object.assign(window.ForgeUI || {}, window.ForgeApp);
|
|
1264
|
+
// #113: the version of the server answering, beside the logo. An export has no server, so no label; nor when it is unknown.
|
|
1265
|
+
(function brandVersion() {
|
|
1266
|
+
const label = document.getElementById('brand-version');
|
|
1267
|
+
if (!label || !window.ForgeUI.get || document.getElementById('forge-snapshot')) return;
|
|
1268
|
+
window.ForgeUI.get('/api/health').then(res => {
|
|
1269
|
+
const version = res.ok && typeof res.data.version === 'string' ? res.data.version : '';
|
|
1270
|
+
if (!version) return;
|
|
1271
|
+
label.textContent = 'v' + version;
|
|
1272
|
+
label.title = typeof res.data.build === 'string' ? 'forge ' + version + ', build ' + res.data.build.slice(0, 12) : 'forge ' + version;
|
|
1273
|
+
label.hidden = false;
|
|
1274
|
+
});
|
|
1275
|
+
})();
|
|
@@ -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
|
-
|
|
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);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* forge-ui diff viewer: a task's diff (current, previous, committed, or exactly what one reviewer read), a final
|
|
2
|
-
review's combined diff or a Fractal node's candidate, with each review finding shown under the line it points
|
|
2
|
+
review's combined diff, an adopted range or a Fractal node's candidate, with each review finding shown under the line it points
|
|
3
3
|
at. Defines window.ForgeDiff.render(host, ctx). All API values enter the DOM as text.
|
|
4
|
-
ctx = { run, spec: {kind: 'task'|'final'|'fractal', task, source, file, name, node, finding}, fetchJSON(path),
|
|
4
|
+
ctx = { run, spec: {kind: 'task'|'final'|'adoption'|'fractal', task, source, file, name, node, finding}, fetchJSON(path),
|
|
5
5
|
rerender(), href(spec) → hash, closeHref }. */
|
|
6
6
|
window.ForgeDiff = (() => {
|
|
7
7
|
'use strict';
|
|
@@ -23,6 +23,7 @@ window.ForgeDiff = (() => {
|
|
|
23
23
|
function urlFor(run, spec) {
|
|
24
24
|
const base = `/api/runs/${enc(run.key)}`;
|
|
25
25
|
if (spec.kind === 'final') return `${base}/final-reviews/${enc(spec.name)}/diff`;
|
|
26
|
+
if (spec.kind === 'adoption') return `${base}/adoptions/${enc(spec.name)}/diff`;
|
|
26
27
|
if (spec.kind === 'fractal') return `${base}/tasks/${enc(spec.task)}/fractal/nodes/${enc(spec.node)}/diff`;
|
|
27
28
|
const src = spec.source || 'current';
|
|
28
29
|
if (TASK_FILES.has(src)) return `${base}/tasks/${enc(spec.task)}/diff${src === 'current' ? '' : '/' + src}`;
|
|
@@ -54,9 +55,12 @@ window.ForgeDiff = (() => {
|
|
|
54
55
|
const r = f.review || {};
|
|
55
56
|
head.append(el('span', `${r.kind || 'review'}${r.attempt != null ? ' · attempt ' + r.attempt : ''}${r.spec ? ' · ' + r.spec : ''}`, 'muted'));
|
|
56
57
|
if (where) head.append(el('span', where, 'mono muted'));
|
|
58
|
+
// #119: the reviewer's own reach, origin and evidence, recorded in shadow (they decide nothing)
|
|
59
|
+
const facts = Object.entries(f.facts || {}).filter(([, v]) => v).map(([k, v]) => `${k} ${v}`);
|
|
60
|
+
if (facts.length) { const t = el('span', facts.join(' · '), 'muted diff-finding-facts'); t.title = "The reviewer's own facts about this finding; they do not change what blocks"; head.append(t); }
|
|
57
61
|
box.append(head, el('p', said(f)));
|
|
58
62
|
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); }
|
|
63
|
+
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
64
|
return box;
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -128,7 +132,7 @@ window.ForgeDiff = (() => {
|
|
|
128
132
|
host.replaceChildren();
|
|
129
133
|
const D = entry.data;
|
|
130
134
|
const top = el('div', undefined, 'diff-top');
|
|
131
|
-
const what = spec.kind === 'final' ? 'Final review' : spec.kind === 'fractal' ? `${spec.task} · Fractal node ${spec.node}` : spec.task === 'solo' && run.kind === 'solo' ? 'Solo run' : `Task ${spec.task}`;
|
|
135
|
+
const what = spec.kind === 'final' ? 'Final review' : spec.kind === 'adoption' ? `Adopted range · ${spec.name}` : spec.kind === 'fractal' ? `${spec.task} · Fractal node ${spec.node}` : spec.task === 'solo' && run.kind === 'solo' ? 'Solo run' : `Task ${spec.task}`;
|
|
132
136
|
const title = el('h2'); title.append(el('span', 'Diff · ', 'muted'), document.createTextNode(what)); top.append(title);
|
|
133
137
|
const close = el('a', undefined, 'diff-close button'); close.href = ctx.closeHref;
|
|
134
138
|
if (window.ForgeIcons) close.append(window.ForgeIcons.icon('close'));
|
|
@@ -193,7 +197,7 @@ window.ForgeDiff = (() => {
|
|
|
193
197
|
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
198
|
main.append(ls);
|
|
195
199
|
}
|
|
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); }
|
|
200
|
+
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
201
|
if (files.length || loose.length) body.append(nav); else body.classList.add('no-files');
|
|
198
202
|
body.append(main); host.append(body);
|
|
199
203
|
|