@giamme/forge 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +1 -0
- package/SKILL.md +16 -2
- package/VERSION +1 -1
- package/docs/artifacts.md +25 -1
- package/docs/commands.md +81 -14
- package/docs/decomposed-runs.md +114 -1
- package/docs/development.md +2 -1
- package/docs/forge-ui.md +84 -15
- package/docs/memory.md +25 -4
- package/docs/models.md +8 -0
- package/docs/reviews.md +122 -0
- package/forge +20 -3
- package/package.json +2 -1
- package/references/dataset.md +20 -1
- package/references/decompose.md +621 -33
- package/references/harnesses.md +18 -3
- package/references/planning.md +43 -14
- package/references/ui.md +53 -6
- package/registry.tsv +8 -3
- package/scripts/forge-brief.py +88 -3
- package/scripts/forge-compare.py +4 -3
- package/scripts/forge-contract.py +202 -27
- package/scripts/forge-control.py +117 -5
- package/scripts/forge-dispatch.sh +34 -5
- package/scripts/forge-group.py +496 -0
- package/scripts/forge-groups.py +89 -0
- package/scripts/forge-handoff.py +1128 -0
- package/scripts/forge-lib-group.sh +641 -0
- package/scripts/forge-lib-plans.sh +339 -3
- package/scripts/forge-lib-task.sh +197 -4
- package/scripts/forge-memory.sh +245 -3
- package/scripts/forge-parallel.sh +715 -34
- package/scripts/forge-planner.py +104 -8
- package/scripts/forge-route.py +190 -12
- package/scripts/forge-runs.py +9 -5
- package/scripts/forge-schedule.py +354 -45
- package/scripts/forge-solo.sh +2 -0
- package/scripts/forge-worktrees.py +243 -0
- package/scripts/forge_brief/__init__.py +294 -50
- package/scripts/forge_brief/answers.py +58 -11
- package/scripts/forge_brief/proposals.py +1630 -0
- package/scripts/forge_dataset/efforts.py +4 -3
- package/scripts/forge_dataset/export.py +24 -12
- package/scripts/forge_dataset/facts.py +5 -3
- package/scripts/forge_dataset/forecast.py +8 -18
- package/scripts/forge_dataset/harvest.py +204 -9
- package/scripts/forge_dataset/history.py +11 -6
- package/scripts/forge_dataset/importer.py +65 -1
- package/scripts/forge_dataset/names.py +66 -0
- package/scripts/forge_dataset/reviewers.py +5 -2
- package/scripts/forge_dataset/risk.py +6 -3
- package/scripts/forge_dataset/routing.py +6 -1
- package/scripts/forge_groups/__init__.py +308 -0
- package/scripts/forge_groups/attribute.py +289 -0
- package/scripts/forge_groups/review.py +286 -0
- package/scripts/forge_owner.py +152 -0
- package/scripts/forge_side/__init__.py +12 -7
- package/ui/docs/api.md +173 -17
- package/ui/forge_ui/control.py +361 -2
- package/ui/forge_ui/executions.py +8 -1
- package/ui/forge_ui/export.py +31 -4
- package/ui/forge_ui/groups.py +264 -0
- package/ui/forge_ui/models.py +70 -8
- package/ui/forge_ui/reader.py +262 -19
- package/ui/forge_ui/server.py +4 -0
- package/ui/forge_ui/static/app.js +93 -13
- package/ui/forge_ui/static/briefview.js +350 -47
- package/ui/forge_ui/static/diffview.js +86 -1
- package/ui/forge_ui/static/groupsview.js +332 -0
- package/ui/forge_ui/static/index.html +1 -0
- package/ui/forge_ui/static/panel.js +127 -7
- package/ui/forge_ui/static/projectsview.js +189 -10
- package/ui/forge_ui/static/runmodel.js +14 -3
- package/ui/forge_ui/static/storageview.js +91 -10
- package/ui/forge_ui/static/style.css +79 -5
- package/ui/forge_ui/static/worktreesview.js +233 -12
- package/ui/forge_ui/storage.py +14 -0
|
@@ -101,15 +101,16 @@
|
|
|
101
101
|
|
|
102
102
|
/* status: the lamp behind each forge state. One meaning each (--st; --st-lit on the 3D plate): four lamps, and the
|
|
103
103
|
waiting lamp for a task that waits for the user (NEEDS_INPUT, NEEDS_DECISION, and an integration that only waits for the user).
|
|
104
|
+
IMPLEMENTED waits for its group's review and uses that same waiting lamp.
|
|
104
105
|
A hollow lamp is that lamp's family but not its plain case: passed without a merge, stopped, failed outside the code,
|
|
105
106
|
an outdated review, waiting for you */
|
|
106
107
|
.st-merged, .st-pass, .st-accepted, .st-nochanges { --st: var(--lamp-green); --st-lit: var(--lit-green); }
|
|
107
108
|
.st-running, .st-interrupted { --st: var(--lamp-amber); --st-lit: var(--lit-amber); }
|
|
108
109
|
.st-pending, .st-none, .st-unknown, .st-invalidated, .st-outdated { --st: var(--lamp-off); --st-lit: var(--lamp-off); }
|
|
109
110
|
.st-fail, .st-error, .st-conflict, .st-infra, .st-timeout, .st-blocked, .st-bounced, .st-incomplete { --st: var(--lamp-red); --st-lit: var(--lit-red); }
|
|
110
|
-
.st-needs_input, .st-needs_decision, .st-waiting { --st: var(--lamp-wait); --st-lit: var(--lit-wait); }
|
|
111
|
+
.st-needs_input, .st-needs_decision, .st-waiting, .st-implemented { --st: var(--lamp-wait); --st-lit: var(--lit-wait); }
|
|
111
112
|
[class^="st-"], [class*=" st-"] { --st-fill: var(--st); --st-ring: var(--lamp-edge); }
|
|
112
|
-
.st-accepted, .st-nochanges, .st-interrupted, .st-infra, .st-timeout, .st-blocked, .st-outdated, .st-needs_input, .st-needs_decision, .st-waiting { --st-fill: transparent; --st-ring: var(--st); }
|
|
113
|
+
.st-accepted, .st-nochanges, .st-interrupted, .st-infra, .st-timeout, .st-blocked, .st-outdated, .st-needs_input, .st-needs_decision, .st-waiting, .st-implemented { --st-fill: transparent; --st-ring: var(--st); }
|
|
113
114
|
/* verification lanes: flaky passed on a rerun (amber, hollow), known passed with only baseline failures (green, hollow) */
|
|
114
115
|
.st-flaky { --st: var(--lamp-amber); --st-lit: var(--lit-amber); --st-fill: transparent; --st-ring: var(--st); }
|
|
115
116
|
.st-known { --st: var(--lamp-green); --st-lit: var(--lit-green); --st-fill: transparent; --st-ring: var(--st); }
|
|
@@ -172,6 +173,11 @@ a.chip, a.chip:hover { color: inherit; text-decoration: none; }
|
|
|
172
173
|
.sev-chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: var(--t-xs); white-space: nowrap; }
|
|
173
174
|
.sev-chip::before { content: ''; width: 9px; height: 9px; clip-path: var(--sev-shape, circle(30%)); background: var(--sev, var(--muted)); flex: none; }
|
|
174
175
|
.chip.sev-chip { font-family: var(--mono); font-weight: 600; letter-spacing: 0; text-transform: none; font-size: var(--t-xs); }
|
|
176
|
+
/* IMPLEMENTED's label is a phrase, so it keeps the waiting lamp and drops the status-word capitals */
|
|
177
|
+
.chip.st-implemented { text-transform: none; letter-spacing: 0; font-family: var(--font-ui); font-weight: 650; font-size: var(--t-xs); }
|
|
178
|
+
a.group-chip { display: inline-flex; align-items: center; padding: 0 6px; border: 1px solid var(--rule); border-radius: var(--r-small); background: var(--key); color: var(--ink);
|
|
179
|
+
font-family: var(--mono); font-weight: 600; font-size: var(--t-xs); letter-spacing: 0; text-transform: none; text-decoration: none; white-space: nowrap; }
|
|
180
|
+
a.group-chip:hover { text-decoration: underline; text-underline-offset: 2px; }
|
|
175
181
|
/* a model's name plate: the alias engraved, its effort beside it; the one way a model is shown */
|
|
176
182
|
.model-plate { display: inline-flex; align-items: stretch; vertical-align: middle; border: 1px solid var(--rule-2); border-radius: var(--r-small); overflow: hidden; white-space: nowrap; line-height: 1.55; }
|
|
177
183
|
.model-plate .mp-name { padding: 0 6px; background: var(--module-2); color: var(--ink); font-family: var(--font-plate); font-weight: 700; font-size: .857rem; letter-spacing: .06em; text-transform: uppercase; transition: background-color var(--relay); }
|
|
@@ -344,16 +350,25 @@ body.no-tasks .tasks-module { display: none; }
|
|
|
344
350
|
body[data-shell=workbench].no-tasks .run-view { grid-template-rows: auto minmax(0, 1fr) auto 0; }
|
|
345
351
|
body[data-shell=immersive] .sidebar { position: absolute; z-index: 4; left: var(--gap); top: var(--gap); bottom: var(--gap); width: var(--runs-w); box-shadow: var(--ply-1); }
|
|
346
352
|
body[data-shell=immersive][data-runs=closed] .sidebar { display: none; }
|
|
347
|
-
body[data-shell=immersive]:is([data-view=models], [data-view=findings], [data-view=settings], [data-view=worktrees], [data-view=disk], [data-view=projects], [data-view=waiting], [data-view=loading], [data-view=first-run]) #main { left: calc(var(--L) - var(--gap)); }
|
|
353
|
+
body[data-shell=immersive]:is([data-view=models], [data-view=findings], [data-view=settings], [data-view=worktrees], [data-view=disk], [data-view=projects], [data-view=waiting], [data-view=loading], [data-view=first-run], [data-view=group]) #main { left: calc(var(--L) - var(--gap)); }
|
|
348
354
|
body[data-shell=immersive] .stage-row, body[data-shell=immersive] .stage-col { position: absolute; inset: 0; }
|
|
349
355
|
body[data-shell=immersive] .stage-col .stage-slot { position: absolute; inset: 0; }
|
|
350
356
|
body[data-shell=immersive] .insp-module { position: absolute; z-index: 3; right: var(--gap); top: var(--gap); bottom: var(--gap); width: var(--insp-w); box-shadow: var(--ply-1); }
|
|
351
357
|
body[data-shell=immersive][data-insp=closed] .insp-module { display: none; }
|
|
352
358
|
body[data-shell=immersive] .run-header { position: absolute; z-index: 3; left: var(--L); top: var(--gap); width: min(1040px, calc(100% - var(--L) - var(--R))); box-shadow: var(--ply-1); }
|
|
353
359
|
body[data-shell=immersive] .tasks-module { position: absolute; z-index: 3; left: var(--L); right: var(--R); bottom: var(--gap); height: var(--tasks-h); box-shadow: var(--ply-1); }
|
|
360
|
+
body[data-shell=immersive] .groups-module:not([hidden]) { position: absolute; z-index: 3; left: var(--L); right: var(--R); bottom: var(--B); max-height: min(32vh, 240px); box-shadow: var(--ply-1); }
|
|
354
361
|
body[data-shell=immersive][data-tasks=closed] .tasks-module { height: auto; }
|
|
355
362
|
body[data-shell=immersive] .strip-wrap { position: absolute; z-index: 2; left: var(--L); right: var(--R); bottom: var(--B); }
|
|
356
363
|
body[data-shell=immersive] .stage-col .graph, body[data-shell=immersive] .stage-col .files-view { position: absolute; inset: 0; overflow: auto; padding: calc(var(--head-h, 132px) + 2 * var(--gap)) var(--R) calc(var(--B) + var(--gap)) var(--L); }
|
|
364
|
+
/* --groups-h is the groups block's used height, published from its border box. The strip, the stage
|
|
365
|
+
note and the 2D stage padding sit one gap above that block. Below 761px the modules stack in flow. */
|
|
366
|
+
@media (min-width: 761px) {
|
|
367
|
+
body[data-shell=immersive] .run-view.has-groups .strip-wrap { bottom: calc(var(--B) + var(--groups-h, 0px) + var(--gap)); }
|
|
368
|
+
body[data-shell=immersive] .run-view.has-groups .stage-col .graph,
|
|
369
|
+
body[data-shell=immersive] .run-view.has-groups .stage-col .files-view { padding-bottom: calc(var(--B) + var(--groups-h, 0px) + 2 * var(--gap)); }
|
|
370
|
+
body[data-shell=immersive] .run-view.has-groups .stage-note { bottom: calc(var(--B) + var(--groups-h, 0px) + var(--gap) + 60px); }
|
|
371
|
+
}
|
|
357
372
|
body[data-shell=immersive] .diff-view { position: absolute; z-index: 3; left: var(--L); right: var(--gap); top: var(--gap); bottom: var(--B); overflow: auto; padding: var(--s-4); box-shadow: var(--ply-1); }
|
|
358
373
|
body[data-shell=immersive] .run-view.diff-open .run-header { display: none; }
|
|
359
374
|
body[data-shell=immersive] .map-head-module { position: absolute; z-index: 3; left: var(--L); top: var(--gap); width: max-content; max-width: calc(100% - var(--L) - var(--gap)); box-shadow: var(--ply-1); }
|
|
@@ -388,6 +403,12 @@ body[data-shell=workbench] .insp-module .splitter.v { left: -5px; }
|
|
|
388
403
|
body[data-shell=workbench] .run-header { grid-area: head; border-radius: 0; border-width: 0 0 1px; }
|
|
389
404
|
body[data-shell=workbench] .strip-wrap { grid-area: strip; padding: var(--s-2) var(--s-3) 0; }
|
|
390
405
|
body[data-shell=workbench] .tasks-module { grid-area: tasks; position: relative; border-radius: 0; border-width: 1px 0 0; }
|
|
406
|
+
body[data-shell=workbench] .run-view.has-groups { grid-template-rows: auto minmax(0, 1fr) auto auto var(--tasks-h);
|
|
407
|
+
grid-template-areas: "head insp" "stage insp" "strip insp" "groups insp" "tasks insp"; }
|
|
408
|
+
body[data-shell=workbench][data-tasks=closed] .run-view.has-groups { grid-template-rows: auto minmax(0, 1fr) auto auto auto; }
|
|
409
|
+
body[data-shell=workbench] .groups-module { grid-area: groups; position: relative; border-radius: 0; border-width: 1px 0 0; max-height: min(32vh, 240px); }
|
|
410
|
+
body[data-shell=workbench] .run-view.diff-open.has-groups .diff-view { grid-area: 2 / 1 / 6 / 3; }
|
|
411
|
+
body[data-shell] .run-view.diff-open .groups-module { display: none; }
|
|
391
412
|
body[data-shell=workbench] .tasks-module .splitter.h { top: -5px; }
|
|
392
413
|
body[data-shell=workbench] .run-view.diff-open .diff-view { grid-area: 2 / 1 / 5 / 3; overflow: auto; padding: var(--s-4); border-radius: 0; border-width: 0; }
|
|
393
414
|
body[data-shell=workbench] .map-view { display: grid; grid-template-rows: auto minmax(0, 1fr); }
|
|
@@ -399,7 +420,7 @@ body[data-shell=workbench] .map-cards-host { overflow: auto; }
|
|
|
399
420
|
body[data-shell=workbench] .map-cards { padding: var(--s-4); }
|
|
400
421
|
|
|
401
422
|
/* content views: the leaderboard and the waiting pages */
|
|
402
|
-
body:is([data-view=models], [data-view=findings], [data-view=settings], [data-view=worktrees], [data-view=disk], [data-view=projects], [data-view=waiting], [data-view=loading], [data-view=first-run]) #main { padding: var(--s-6) var(--s-6) var(--s-8); }
|
|
423
|
+
body:is([data-view=models], [data-view=findings], [data-view=settings], [data-view=worktrees], [data-view=disk], [data-view=projects], [data-view=waiting], [data-view=loading], [data-view=first-run], [data-view=group]) #main { padding: var(--s-6) var(--s-6) var(--s-8); }
|
|
403
424
|
|
|
404
425
|
/* ---------- the stage: the panel the run is inlaid on ---------- */
|
|
405
426
|
.stage-slot { position: relative; background: var(--stage-bg); }
|
|
@@ -834,6 +855,26 @@ a.brief-open:hover { text-decoration: none; background: var(--module-2); }
|
|
|
834
855
|
.brief-q .brief-notice { margin: 0; }
|
|
835
856
|
.brief-parked { margin-top: var(--s-2); }
|
|
836
857
|
.brief-parked > .brief-questions { margin-top: var(--s-2); }
|
|
858
|
+
/* Grouped questions, proposals and affected badges (#136). The questions strip stays short until a
|
|
859
|
+
proposal is open; then it shares the tasks module with the table, which keeps a minimum of its own. */
|
|
860
|
+
.brief-group { display: grid; gap: 2px; margin: var(--s-2) 10px 0; }
|
|
861
|
+
.brief-group-title { margin: 0; font-size: var(--t-sm); }
|
|
862
|
+
.brief-goal { margin: 0; color: var(--muted); font-size: var(--t-xs); overflow-wrap: anywhere; }
|
|
863
|
+
.brief-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
|
|
864
|
+
.brief-actions input { flex: 1 1 12rem; min-width: 8rem; min-height: 28px; padding: 4px 8px; }
|
|
865
|
+
.brief-proposals { display: grid; gap: var(--s-2); align-content: start; padding: 6px 10px 10px; overflow: auto; min-height: 0; flex: 1 1 auto; }
|
|
866
|
+
.brief-proposal { display: grid; gap: 4px; padding: var(--s-2) 10px; border: 1px solid var(--rule); border-radius: var(--r-key); background: var(--module-2); }
|
|
867
|
+
.brief-proposal-top { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
|
|
868
|
+
.brief-summary, .brief-reason { margin: 0; overflow-wrap: anywhere; }
|
|
869
|
+
.brief-reason { color: var(--warn-ink); }
|
|
870
|
+
.brief-hash { font-size: var(--t-xs); overflow-wrap: anywhere; }
|
|
871
|
+
.brief-proposal .brief-notice { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
872
|
+
.brief-patch .diff-scroll, pre.brief-diff { max-height: 8rem; overflow: auto; }
|
|
873
|
+
pre.brief-diff { margin: 0; white-space: pre; }
|
|
874
|
+
.brief-proposal[aria-busy=true] { opacity: .7; }
|
|
875
|
+
.brief-affected-row { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
|
|
876
|
+
.run-questions[data-proposals] { flex: 1 1 auto; max-height: none; }
|
|
877
|
+
.tasks-module:has(.run-questions[data-proposals]:not([hidden])) .run-tasks { min-height: 5.5rem; }
|
|
837
878
|
|
|
838
879
|
/* ---------- tables ---------- */
|
|
839
880
|
.table-scroll { overflow: auto; max-width: 100%; border: 1px solid var(--rule); border-radius: var(--r-key); background: var(--module); }
|
|
@@ -1301,7 +1342,12 @@ dialog.export-dialog h2 { margin-bottom: var(--s-2); }
|
|
|
1301
1342
|
body[data-shell] .stage-col .stage-slot, body[data-shell] .map-view .stage-slot { position: relative; inset: auto; height: clamp(300px, 105vw, 62vh); border-radius: var(--r-module); overflow: hidden; }
|
|
1302
1343
|
body[data-shell] .run-view .stage-col .stage-slot { height: clamp(240px, 72vw, 62vh); } /* a run's plate is wide: no empty bands above and below it */
|
|
1303
1344
|
body[data-shell] .stage-col .graph, body[data-shell] .stage-col .files-view, body[data-shell] .map-cards { position: static; padding: 0; overflow: auto; }
|
|
1304
|
-
body[data-shell] :is(.run-header, .insp-module, .tasks-module, .diff-view, .map-head-module, .strip-wrap) { position: static; width: auto; max-width: none; height: auto; margin: 0; box-shadow: none; border-radius: var(--r-module); border-width: 1px; }
|
|
1345
|
+
body[data-shell] :is(.run-header, .insp-module, .tasks-module, .groups-module, .diff-view, .map-head-module, .strip-wrap) { position: static; width: auto; max-width: none; height: auto; margin: 0; box-shadow: none; border-radius: var(--r-module); border-width: 1px; }
|
|
1346
|
+
body[data-shell=immersive] .groups-module:not([hidden]),
|
|
1347
|
+
body[data-shell=workbench] .groups-module:not([hidden]) { position: static; inset: auto; left: auto; right: auto; bottom: auto; width: auto; max-width: none; height: auto; max-height: 60vh; margin: 0; box-shadow: none; border-radius: var(--r-module); border-width: 1px; }
|
|
1348
|
+
/* the desktop groups row is more specific than the stacked run view; drop it so a phone stays one column */
|
|
1349
|
+
body[data-shell=workbench] .run-view.has-groups,
|
|
1350
|
+
body[data-shell=workbench][data-tasks=closed] .run-view.has-groups { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: none; }
|
|
1305
1351
|
body[data-shell] .tasks-module .run-tasks { max-height: 60vh; }
|
|
1306
1352
|
body[data-shell] .stage-note { position: static; }
|
|
1307
1353
|
.stage-ctl { top: auto; bottom: var(--gap); right: var(--gap); translate: none; grid-auto-flow: column; }
|
|
@@ -1627,3 +1673,31 @@ dialog.set-guide::backdrop { background: light-dark(rgb(17 22 19 / .35), rgb(0 0
|
|
|
1627
1673
|
/* A held redraw that has lasted (#115) */
|
|
1628
1674
|
.live-held { position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: 30; display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border: 1px solid var(--rule); border-radius: var(--r-key); background: var(--module); color: var(--ink); box-shadow: var(--ply-2); font-size: var(--t-sm); }
|
|
1629
1675
|
.live-held[hidden] { display: none; }
|
|
1676
|
+
|
|
1677
|
+
/* ---------- groups: the run's groups block, and #/runs/<key>/group/<gid> ---------- */
|
|
1678
|
+
.groups-module { overflow: auto; }
|
|
1679
|
+
.groups-module[hidden] { display: none; }
|
|
1680
|
+
.groups-block { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
|
|
1681
|
+
.group-rows { min-height: 0; }
|
|
1682
|
+
.group-row { display: grid; gap: 2px 12px; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
|
|
1683
|
+
.group-row:last-child { border-bottom: 0; }
|
|
1684
|
+
.group-title { font-weight: 650; overflow-wrap: anywhere; }
|
|
1685
|
+
a.group-title { text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: 3px; }
|
|
1686
|
+
.group-goal { margin: 0; color: var(--muted); font-size: var(--t-sm); }
|
|
1687
|
+
.group-meta, .group-members, .group-state { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); font-size: var(--t-sm); }
|
|
1688
|
+
.group-state { margin: 0; }
|
|
1689
|
+
.group-round, .group-round-members { font-family: var(--mono); font-size: var(--t-xs); }
|
|
1690
|
+
.group-view { max-width: 1100px; }
|
|
1691
|
+
.group-page { display: grid; gap: var(--s-5); }
|
|
1692
|
+
.group-head { display: grid; gap: var(--s-2); }
|
|
1693
|
+
.group-head h1, .group-section h2, .group-round-row h3 { margin: 0; }
|
|
1694
|
+
.group-section { display: grid; gap: var(--s-2); }
|
|
1695
|
+
.group-findings { width: 100%; border-collapse: collapse; }
|
|
1696
|
+
.group-findings th, .group-findings td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--rule); vertical-align: baseline; font-size: var(--t-sm); overflow-wrap: anywhere; }
|
|
1697
|
+
.group-findings th { font-family: var(--font-plate); font-size: .786rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
|
|
1698
|
+
.group-ambiguous { background: var(--warn-wash); }
|
|
1699
|
+
.group-blocking { color: var(--lamp-red); font-weight: 700; }
|
|
1700
|
+
.group-cmd { margin: 0; }
|
|
1701
|
+
.group-round-row { display: grid; gap: 2px; padding-bottom: var(--s-2); border-bottom: 1px solid var(--rule); }
|
|
1702
|
+
.group-round-row:last-child { border-bottom: 0; padding-bottom: 0; }
|
|
1703
|
+
.group-members .chip { text-decoration: none; }
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
/* forge-ui Worktrees screen (#125): every worktree forge created, in any repository, with its state
|
|
2
|
-
that removes it
|
|
3
|
-
narrowed to one repository (#/worktrees/repo/<root>) or one run (#/worktrees/runs/<key>).
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/* forge-ui Worktrees screen (#125, removals #147): every worktree forge created, in any repository, with its state
|
|
2
|
+
and the command that removes it (window.ForgeWorktrees, and a CommonJS module under node:test). Route #/worktrees,
|
|
3
|
+
optionally narrowed to one repository (#/worktrees/repo/<root>) or one run (#/worktrees/runs/<key>).
|
|
4
|
+
With write controls the page removes worktrees through POST /api/worktrees/remove (`forge worktrees rm`): a dry run,
|
|
5
|
+
then a confirmation, then the real call. Under read-only, or with no token, it only copies the commands.
|
|
6
|
+
Paths, branches, reasons and commit subjects enter the page as text.
|
|
7
|
+
The pure helpers (filters, totals, sizes, which rows can be removed) are tested in ui/tests/js/worktreesview.test.js.
|
|
7
8
|
ctx = { filter?: {repo, run}, runHref(key), tablePrefs?(id), saveTablePrefs?(id, prefs) }. */
|
|
8
9
|
(function (root, factory) {
|
|
9
10
|
'use strict';
|
|
@@ -52,12 +53,78 @@
|
|
|
52
53
|
const repoName = p => typeof p === 'string' && p ? p.replace(/\/+$/, '').split('/').pop() : '—';
|
|
53
54
|
const label = status => LABEL[status] || status || '—';
|
|
54
55
|
|
|
56
|
+
// A removal is the command the server offers: failed or finished, or an unknown folder git has already dropped.
|
|
57
|
+
const BLOCK = {
|
|
58
|
+
in_use: 'its run is active',
|
|
59
|
+
dirty: 'uncommitted changes',
|
|
60
|
+
locked: 'locked by git',
|
|
61
|
+
needed: 'its run still needs it',
|
|
62
|
+
missing: 'already gone (prune)',
|
|
63
|
+
foreign: "not forge's",
|
|
64
|
+
removed: 'already removed',
|
|
65
|
+
unknown: 'not a leftover',
|
|
66
|
+
};
|
|
67
|
+
function removable(row) {
|
|
68
|
+
if (!row || typeof row !== 'object') return false;
|
|
69
|
+
if (row.status === 'failed' || row.status === 'finished') return true;
|
|
70
|
+
return row.status === 'unknown' && row.leftover === true;
|
|
71
|
+
}
|
|
72
|
+
function blockReason(row) {
|
|
73
|
+
if (!row || typeof row !== 'object' || removable(row)) return null;
|
|
74
|
+
if (Object.prototype.hasOwnProperty.call(BLOCK, row.status)) return BLOCK[row.status];
|
|
75
|
+
return row.status ? String(row.status) : 'cannot remove';
|
|
76
|
+
}
|
|
77
|
+
// Paths of the removable rows in the current filtered view, in that view's order.
|
|
78
|
+
function selectable(rows, filter) {
|
|
79
|
+
return filterRows(rows, filter).filter(removable).map(r => r.path).filter(p => typeof p === 'string');
|
|
80
|
+
}
|
|
81
|
+
function answerRows(answer) {
|
|
82
|
+
return list(answer && answer.rows).filter(r => r && typeof r === 'object');
|
|
83
|
+
}
|
|
84
|
+
function rowBit(r) {
|
|
85
|
+
const path = r.path == null ? '' : String(r.path);
|
|
86
|
+
const reason = r.reason == null || r.reason === '' ? '' : String(r.reason);
|
|
87
|
+
return reason ? path + ' (' + reason + ')' : path;
|
|
88
|
+
}
|
|
89
|
+
// One sentence for the dry run: how many would go, then each skip (and any failure) with its reason.
|
|
90
|
+
function summaryText(answer) {
|
|
91
|
+
const rows = answerRows(answer);
|
|
92
|
+
const n = rows.filter(r => r.status === 'would-remove').length;
|
|
93
|
+
let text = (n === 1 ? '1 worktree' : n + ' worktrees') + ' would be removed.';
|
|
94
|
+
const skipped = rows.filter(r => r.status === 'skipped');
|
|
95
|
+
const failed = rows.filter(r => r.status === 'failed');
|
|
96
|
+
if (skipped.length) text += ' Skipped: ' + skipped.map(rowBit).join('; ') + '.';
|
|
97
|
+
if (failed.length) text += ' Failed: ' + failed.map(rowBit).join('; ') + '.';
|
|
98
|
+
return text;
|
|
99
|
+
}
|
|
100
|
+
function resultLines(answer) {
|
|
101
|
+
return answerRows(answer).map(r => ({
|
|
102
|
+
path: r.path == null ? '' : String(r.path),
|
|
103
|
+
status: r.status == null ? '' : String(r.status),
|
|
104
|
+
reason: r.reason == null ? '' : String(r.reason),
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
// The line shown for one result row: "removed", "skipped (reason)", "failed (reason)".
|
|
108
|
+
function resultPhrase(line) {
|
|
109
|
+
const reason = line && line.reason ? ' (' + line.reason + ')' : '';
|
|
110
|
+
if (!line) return '';
|
|
111
|
+
if (line.status === 'removed') return 'removed';
|
|
112
|
+
if (line.status === 'skipped') return 'skipped' + reason;
|
|
113
|
+
if (line.status === 'failed') return 'failed' + reason;
|
|
114
|
+
return (line.status || '') + reason;
|
|
115
|
+
}
|
|
116
|
+
const confirmQuestion = n => 'Remove ' + n + ' worktrees?';
|
|
117
|
+
|
|
55
118
|
/* ---------- DOM ---------- */
|
|
56
119
|
function render(host, ctx) {
|
|
57
120
|
const UI = root.ForgeUI;
|
|
58
121
|
const el = (tag, text, cls) => UI.el(tag, text, cls);
|
|
59
122
|
const start = ctx.filter || {};
|
|
60
|
-
const s = { data: null, error: null, filter: { repo: start.repo || '', run: start.run || '', status: 'disk', kind: 'all' }, timer: null, seq: 0, loading: false
|
|
123
|
+
const s = { data: null, error: null, filter: { repo: start.repo || '', run: start.run || '', status: 'disk', kind: 'all' }, timer: null, seq: 0, loading: false,
|
|
124
|
+
controls: false, selected: new Set(), branches: false, busy: false };
|
|
125
|
+
// Table roots whose replaceWith remounts the select-all. ForgeTable keeps the root private and swaps it on redraw.
|
|
126
|
+
const armedTables = new WeakSet();
|
|
127
|
+
const LEDE_COPY = 'Every worktree forge created, in any repository it knows, with what state it is in and the command that removes it safely. Commands are only copied: this page runs nothing.';
|
|
61
128
|
|
|
62
129
|
const head = el('div', undefined, 'wt-head');
|
|
63
130
|
const refreshKey = el('button', 'Read again'); refreshKey.type = 'button';
|
|
@@ -65,7 +132,7 @@
|
|
|
65
132
|
refreshKey.addEventListener('click', () => load(true));
|
|
66
133
|
const stamp = el('span', '', 'muted wt-stamp');
|
|
67
134
|
head.append(el('h1', 'Worktrees', 'module-title'), refreshKey, stamp);
|
|
68
|
-
const lede = el('p',
|
|
135
|
+
const lede = el('p', LEDE_COPY, 'muted wt-lede');
|
|
69
136
|
const notes = el('div', undefined, 'wt-notes muted');
|
|
70
137
|
const sums = el('p', undefined, 'wt-totals'); sums.setAttribute('role', 'status');
|
|
71
138
|
const filters = el('div', undefined, 'wt-filters');
|
|
@@ -150,8 +217,32 @@
|
|
|
150
217
|
return box;
|
|
151
218
|
};
|
|
152
219
|
const pathCell = r => { const n = el('span', shortPath(r.path), 'mono'); n.title = r.path; return n; };
|
|
220
|
+
function selectCell(r) {
|
|
221
|
+
const wrap = el('span');
|
|
222
|
+
const box = el('input'); box.type = 'checkbox';
|
|
223
|
+
if (removable(r)) {
|
|
224
|
+
box.checked = s.selected.has(r.path);
|
|
225
|
+
box.disabled = s.busy;
|
|
226
|
+
box._path = r.path;
|
|
227
|
+
box.setAttribute('aria-label', 'Select ' + String(r.path));
|
|
228
|
+
box.addEventListener('change', () => {
|
|
229
|
+
if (box.checked) s.selected.add(r.path); else s.selected.delete(r.path);
|
|
230
|
+
syncSelectAll(); syncBar();
|
|
231
|
+
});
|
|
232
|
+
const go = el('button', 'Remove'); go.type = 'button'; go.disabled = s.busy;
|
|
233
|
+
go.addEventListener('click', () => removePaths([r.path]));
|
|
234
|
+
wrap.append(box, go);
|
|
235
|
+
} else {
|
|
236
|
+
const why = blockReason(r) || 'cannot remove';
|
|
237
|
+
box.disabled = true; box.title = why;
|
|
238
|
+
box.setAttribute('aria-label', why);
|
|
239
|
+
wrap.append(box, el('span', why, 'muted wt-note'));
|
|
240
|
+
}
|
|
241
|
+
return wrap;
|
|
242
|
+
}
|
|
243
|
+
const selectColumn = { id: 'select', label: 'Select', sortable: false, hideable: false, cls: 'wt-command-col', cell: selectCell };
|
|
153
244
|
const columns = [
|
|
154
|
-
{ id: 'status', label: 'Status', value: r => STATUSES.indexOf(r.status), cell: statusCell },
|
|
245
|
+
{ id: 'status', label: 'Status', hideable: false, value: r => STATUSES.indexOf(r.status), cell: statusCell },
|
|
155
246
|
{ id: 'run', label: 'Run', value: r => r.run_id, cell: runCell },
|
|
156
247
|
{ id: 'task', label: 'Task', value: r => r.task, mono: true, cell: r => r.task || (r.kind && r.kind !== 'task' ? r.kind : '—') },
|
|
157
248
|
{ id: 'command', label: 'Command', sortable: false, cls: 'wt-command-col', cell: commandCell },
|
|
@@ -197,20 +288,80 @@
|
|
|
197
288
|
}
|
|
198
289
|
groups.replaceChildren(d);
|
|
199
290
|
}
|
|
291
|
+
function shownPaths() { return selectable(list(s.data && s.data.rows), s.filter); }
|
|
292
|
+
function chosenPaths() { return shownPaths().filter(p => s.selected.has(p)); }
|
|
293
|
+
function pruneSelection() {
|
|
294
|
+
if (!s.data) return;
|
|
295
|
+
const live = new Set(selectable(s.data.rows, { status: 'all', kind: 'all' }));
|
|
296
|
+
for (const p of [...s.selected]) if (!live.has(p)) s.selected.delete(p);
|
|
297
|
+
}
|
|
298
|
+
function syncBar() {
|
|
299
|
+
if (!removeSel) return;
|
|
300
|
+
const n = chosenPaths().length;
|
|
301
|
+
removeSel.textContent = 'Remove selected (' + n + ')';
|
|
302
|
+
removeSel.disabled = n === 0 || s.busy;
|
|
303
|
+
if (branchesBox) branchesBox.disabled = s.busy;
|
|
304
|
+
for (const b of tableHost.querySelectorAll('tbody button')) if (b.textContent === 'Remove') b.disabled = s.busy;
|
|
305
|
+
}
|
|
306
|
+
function syncSelectAll() {
|
|
307
|
+
const box = tableHost.querySelector('th[data-col="select"] input');
|
|
308
|
+
if (!box) return;
|
|
309
|
+
const paths = shownPaths(), n = paths.filter(p => s.selected.has(p)).length;
|
|
310
|
+
box.indeterminate = n > 0 && n < paths.length;
|
|
311
|
+
box.checked = paths.length > 0 && n === paths.length;
|
|
312
|
+
box.disabled = paths.length === 0 || s.busy;
|
|
313
|
+
}
|
|
314
|
+
function mountSelectAll() {
|
|
315
|
+
const text = tableHost.querySelector('th[data-col="select"] .th-text');
|
|
316
|
+
if (!text) return;
|
|
317
|
+
const box = el('input'); box.type = 'checkbox';
|
|
318
|
+
box.setAttribute('aria-label', 'Select all removable worktrees');
|
|
319
|
+
box.addEventListener('dragstart', e => e.preventDefault());
|
|
320
|
+
box.addEventListener('change', () => {
|
|
321
|
+
const paths = shownPaths();
|
|
322
|
+
if (box.checked) for (const p of paths) s.selected.add(p);
|
|
323
|
+
else for (const p of paths) s.selected.delete(p);
|
|
324
|
+
for (const input of tableHost.querySelectorAll('tbody input')) {
|
|
325
|
+
if (typeof input._path === 'string' && paths.includes(input._path)) input.checked = s.selected.has(input._path);
|
|
326
|
+
}
|
|
327
|
+
syncSelectAll(); syncBar();
|
|
328
|
+
});
|
|
329
|
+
text.replaceChildren(box);
|
|
330
|
+
syncSelectAll();
|
|
331
|
+
}
|
|
332
|
+
// Sort, drag, Alt+arrow, the Columns menu and Reset all rebuild the header from `c.label` and swap the table root
|
|
333
|
+
// with replaceWith. Nothing tells us, so the box mounted after render would vanish until the next full draw.
|
|
334
|
+
function armRedraw(node) {
|
|
335
|
+
if (!node || armedTables.has(node) || typeof node.replaceWith !== 'function') return;
|
|
336
|
+
const orig = node.replaceWith;
|
|
337
|
+
armedTables.add(node);
|
|
338
|
+
node.replaceWith = function (...nodes) {
|
|
339
|
+
const out = orig.apply(this, nodes);
|
|
340
|
+
for (const next of nodes) armRedraw(next);
|
|
341
|
+
if (s.controls && host.isConnected) mountSelectAll();
|
|
342
|
+
return out;
|
|
343
|
+
};
|
|
344
|
+
}
|
|
200
345
|
function drawNow() {
|
|
346
|
+
pruneSelection();
|
|
201
347
|
syncFilters(); drawNotes();
|
|
202
348
|
const d = s.data;
|
|
203
349
|
if (!d) { tableHost.replaceChildren(el('p', s.error ? '' : 'Reading every repository\'s worktrees… the first read runs git status in each, so it can take a few seconds.', 'muted')); sums.replaceChildren(); return; }
|
|
204
350
|
const rows = filterRows(d.rows, s.filter);
|
|
205
351
|
drawTotals(rows);
|
|
206
352
|
UI.keepOpen(groups, drawGroups);
|
|
207
|
-
if (!rows.length) {
|
|
353
|
+
if (!rows.length) {
|
|
354
|
+
tableHost.replaceChildren(el('p', list(d.rows).length ? `No worktrees match these filters (${list(d.rows).length} hidden).` : 'forge has no worktrees on record.', 'muted'));
|
|
355
|
+
syncBar(); return;
|
|
356
|
+
}
|
|
208
357
|
const id = 'worktrees';
|
|
358
|
+
const cols = s.controls ? [selectColumn].concat(columns) : columns;
|
|
209
359
|
tableHost.replaceChildren();
|
|
210
|
-
root.ForgeTable.render(tableHost, { id, label: 'Worktrees', columns, rows, className: 'wt-grid', rowClass: r => 'wt-row-' + r.status,
|
|
360
|
+
const table = root.ForgeTable.render(tableHost, { id, label: 'Worktrees', columns: cols, rows, className: 'wt-grid', rowClass: r => 'wt-row-' + r.status,
|
|
211
361
|
// a cell cut short by its width says the whole of itself on hover
|
|
212
362
|
onRow: (_row, tr) => { for (const td of tr.children) if (!td.classList.contains('wt-command-col') && !td.title) td.title = td.textContent; },
|
|
213
363
|
prefs: ctx.tablePrefs ? ctx.tablePrefs(id) : null, savePrefs: p => ctx.saveTablePrefs && ctx.saveTablePrefs(id, p) });
|
|
364
|
+
if (s.controls) { armRedraw(table); mountSelectAll(); syncBar(); }
|
|
214
365
|
}
|
|
215
366
|
// A redraw never pulls a command out from under someone selecting or copying it (#115).
|
|
216
367
|
const draw = () => { if (UI.guard) UI.guard(host, drawNow); else drawNow(); };
|
|
@@ -234,8 +385,78 @@
|
|
|
234
385
|
const pending = s.data && s.data.sizes_pending > 0;
|
|
235
386
|
s.timer = setTimeout(() => { if (host.isConnected && document.visibilityState === 'visible') load(false); else schedule(); }, pending ? SIZE_POLL_MS : POLL_MS);
|
|
236
387
|
}
|
|
388
|
+
|
|
389
|
+
let branchesBox = null, removeSel = null, outcomeHost = null;
|
|
390
|
+
function showFailure(res) {
|
|
391
|
+
const text = res && res.status === 409 ? 'busy: another removal is running' : UI.outcomeText(res).text;
|
|
392
|
+
const line = el('p', text, 'warn'); line.setAttribute('role', 'status');
|
|
393
|
+
outcomeHost.replaceChildren(line);
|
|
394
|
+
}
|
|
395
|
+
function showLines(lines) {
|
|
396
|
+
const ul = el('ul');
|
|
397
|
+
for (const line of lines) {
|
|
398
|
+
const li = el('li');
|
|
399
|
+
li.append(el('span', line.path, 'mono'), el('span', ' ' + resultPhrase(line)));
|
|
400
|
+
ul.append(li);
|
|
401
|
+
}
|
|
402
|
+
outcomeHost.replaceChildren(ul);
|
|
403
|
+
}
|
|
404
|
+
// Nothing is removed on the first click: dry run, the summary, confirm, then the real call.
|
|
405
|
+
async function removePaths(paths) {
|
|
406
|
+
const wanted = list(paths).filter(p => typeof p === 'string' && p);
|
|
407
|
+
if (s.busy || !wanted.length || !outcomeHost) return;
|
|
408
|
+
const branches = !!s.branches;
|
|
409
|
+
const body = dryRun => ({ paths: wanted.slice(), branches, dry_run: dryRun });
|
|
410
|
+
s.busy = true; syncBar(); syncSelectAll();
|
|
411
|
+
try {
|
|
412
|
+
const dry = await UI.post('/api/worktrees/remove', body(true)) || { ok: false };
|
|
413
|
+
if (!host.isConnected) return;
|
|
414
|
+
if (!dry.ok) { showFailure(dry); return; }
|
|
415
|
+
const data = dry.data || {};
|
|
416
|
+
const n = answerRows(data).filter(r => r.status === 'would-remove').length;
|
|
417
|
+
outcomeHost.replaceChildren(el('p', summaryText(data)));
|
|
418
|
+
// Nothing would be removed: the summary is the answer. Do not ask, and do not send the real call.
|
|
419
|
+
if (n === 0) return;
|
|
420
|
+
const yes = await UI.confirmInline(outcomeHost, confirmQuestion(n), { danger: true });
|
|
421
|
+
if (!yes || !host.isConnected) return;
|
|
422
|
+
const real = await UI.post('/api/worktrees/remove', body(false)) || { ok: false };
|
|
423
|
+
if (!host.isConnected) return;
|
|
424
|
+
if (!real.ok) { showFailure(real); return; }
|
|
425
|
+
const lines = resultLines(real.data);
|
|
426
|
+
showLines(lines);
|
|
427
|
+
for (const line of lines) if (line.status === 'removed') s.selected.delete(line.path);
|
|
428
|
+
s.busy = false; // the refresh draws the checkboxes; they must not stay disabled
|
|
429
|
+
await load(true);
|
|
430
|
+
} finally {
|
|
431
|
+
s.busy = false;
|
|
432
|
+
if (host.isConnected) { syncBar(); syncSelectAll(); }
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function enableControls() {
|
|
436
|
+
if (s.controls) return;
|
|
437
|
+
const bar = el('div', undefined, 'wt-filters');
|
|
438
|
+
bar.setAttribute('role', 'group'); bar.setAttribute('aria-label', 'Remove worktrees');
|
|
439
|
+
branchesBox = el('input'); branchesBox.type = 'checkbox';
|
|
440
|
+
const branchesLabel = el('label');
|
|
441
|
+
branchesLabel.append(branchesBox, el('span', 'Delete merged branches too'));
|
|
442
|
+
branchesBox.addEventListener('change', () => { s.branches = branchesBox.checked; });
|
|
443
|
+
removeSel = el('button', 'Remove selected (0)'); removeSel.type = 'button'; removeSel.disabled = true;
|
|
444
|
+
removeSel.addEventListener('click', () => removePaths(chosenPaths()));
|
|
445
|
+
bar.append(branchesLabel, removeSel);
|
|
446
|
+
outcomeHost = el('div', undefined, 'wt-notes'); outcomeHost.setAttribute('role', 'status');
|
|
447
|
+
host.insertBefore(bar, tableHost);
|
|
448
|
+
host.insertBefore(outcomeHost, tableHost);
|
|
449
|
+
s.controls = true;
|
|
450
|
+
lede.textContent = 'Every worktree forge created, in any repository it knows, with what state it is in and the command that removes it safely. A removal runs through forge worktrees rm after a dry run and a confirmation. Commands can still be copied.';
|
|
451
|
+
}
|
|
452
|
+
|
|
237
453
|
drawNow();
|
|
238
454
|
load(false);
|
|
455
|
+
UI.controlsEnabled().then(on => {
|
|
456
|
+
if (!on || !host.isConnected) return;
|
|
457
|
+
enableControls();
|
|
458
|
+
draw();
|
|
459
|
+
});
|
|
239
460
|
return {
|
|
240
461
|
setFilter(f) {
|
|
241
462
|
const repo = (f && f.repo) || '', run = (f && f.run) || '';
|
|
@@ -246,5 +467,5 @@
|
|
|
246
467
|
};
|
|
247
468
|
}
|
|
248
469
|
|
|
249
|
-
return { render, filterRows, totals, humanBytes, repoName, shortPath, label, STATUSES, LABEL };
|
|
470
|
+
return { render, filterRows, totals, humanBytes, repoName, shortPath, label, removable, blockReason, selectable, summaryText, resultLines, STATUSES, LABEL };
|
|
250
471
|
});
|
package/ui/forge_ui/storage.py
CHANGED
|
@@ -82,6 +82,20 @@ def with_commands(result):
|
|
|
82
82
|
return result
|
|
83
83
|
|
|
84
84
|
|
|
85
|
+
def with_keys(answer, keys):
|
|
86
|
+
"""The answer with each run's forge-ui key, or None for a run dir the run list does not show (the Disk screen
|
|
87
|
+
links only the ones it can open). A copy: the cached result keeps no key, since the run list changes."""
|
|
88
|
+
data = answer.get('data')
|
|
89
|
+
if not data:
|
|
90
|
+
return answer
|
|
91
|
+
from forge_ui.reader import run_key
|
|
92
|
+
runs = []
|
|
93
|
+
for run in data['runs']:
|
|
94
|
+
key = run_key(run['path'])
|
|
95
|
+
runs.append(dict(run, key=key if key in keys else None))
|
|
96
|
+
return dict(answer, data=dict(data, runs=runs))
|
|
97
|
+
|
|
98
|
+
|
|
85
99
|
class Screen:
|
|
86
100
|
"""The cached answer of /api/storage for one server; one measurement at a time, in a background thread."""
|
|
87
101
|
|