@giamme/forge 0.21.0 → 0.23.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 +81 -0
- package/README.md +25 -15
- package/SKILL.md +137 -216
- package/VERSION +1 -1
- package/bin/forge.js +104 -0
- package/docs/README.md +2 -3
- package/docs/add-ons.md +5 -3
- package/docs/artifacts.md +17 -2
- package/docs/commands.md +85 -63
- package/docs/decomposed-runs.md +195 -21
- package/docs/development.md +12 -10
- package/docs/forge-ui.md +33 -4
- package/docs/install.md +127 -6
- package/docs/memory.md +6 -1
- package/docs/models.md +36 -10
- package/docs/reviews.md +50 -29
- package/docs/safety.md +27 -2
- package/docs/troubleshooting.md +8 -11
- package/forge +29 -4
- package/forge.cmd +56 -0
- package/package.json +6 -3
- package/references/dataset.md +10 -9
- package/references/decompose-integration.md +337 -0
- package/references/decompose-opt-in.md +527 -0
- package/references/decompose-recovery.md +569 -0
- package/references/decompose-review.md +256 -0
- package/references/decompose.md +99 -1606
- package/references/findings.md +68 -0
- package/references/harnesses.md +7 -12
- package/references/memory.md +13 -2
- package/references/planning.md +48 -18
- package/references/ripwire.md +38 -13
- package/references/runtime.md +22 -33
- package/references/setup.md +90 -0
- package/references/solo.md +13 -42
- package/references/ui.md +12 -5
- package/registry.tsv +40 -22
- package/scripts/forge-artifact.sh +148 -13
- package/scripts/forge-compare.py +5 -15
- package/scripts/forge-config.py +14 -1
- package/scripts/forge-contract.py +216 -53
- package/scripts/forge-control.py +781 -51
- package/scripts/forge-dispatch.sh +202 -42
- package/scripts/forge-du.py +13 -3
- package/scripts/forge-guard.py +137 -6
- package/scripts/forge-handoff.py +221 -39
- package/scripts/forge-install-ripwire.sh +100 -24
- package/scripts/forge-install.sh +100 -41
- package/scripts/forge-issues.py +6 -4
- package/scripts/forge-jev-options.sh +3 -5
- package/scripts/forge-lib-adopt.sh +169 -5
- package/scripts/forge-lib-attribute.sh +10 -3
- package/scripts/forge-lib-decompose.sh +454 -0
- package/scripts/forge-lib-env.sh +179 -0
- package/scripts/forge-lib-group.sh +9 -6
- package/scripts/forge-lib-plans.sh +38 -21
- package/scripts/forge-lib-review.sh +28 -8
- package/scripts/forge-lib-task.sh +263 -69
- package/scripts/forge-lib-verify.sh +59 -10
- package/scripts/forge-memory.sh +83 -4
- package/scripts/forge-metrics.sh +10 -3
- package/scripts/forge-parallel-options.sh +23 -4
- package/scripts/forge-parallel.sh +602 -217
- package/scripts/forge-plan-check.py +71 -8
- package/scripts/forge-planner.py +303 -17
- package/scripts/forge-pr.py +9 -1
- package/scripts/forge-prompt.py +2 -2
- package/scripts/forge-review-links.py +248 -0
- package/scripts/forge-ripwire.py +234 -16
- package/scripts/forge-route.py +19 -27
- package/scripts/forge-runs-rm.py +92 -21
- package/scripts/forge-runs.py +46 -5
- package/scripts/forge-runtime.py +39 -14
- package/scripts/forge-schedule.py +141 -33
- package/scripts/forge-setup-stale.py +236 -0
- package/scripts/forge-setup.py +804 -0
- package/scripts/forge-shadow.py +2 -20
- package/scripts/forge-solo-lock.py +46 -0
- package/scripts/forge-solo.sh +39 -58
- package/scripts/forge-sweep.py +3 -2
- package/scripts/forge-ui.py +8 -1
- package/scripts/forge-update.sh +8 -3
- package/scripts/forge-verify.py +17 -1
- package/scripts/forge-version.py +13 -1
- package/scripts/forge-watch.py +7 -2
- package/scripts/forge-win.sh +156 -0
- package/scripts/forge_brief/__init__.py +6 -1
- package/scripts/forge_brief/proposals.py +6 -1
- package/scripts/forge_dataset/__init__.py +1 -1
- package/scripts/forge_dataset/capture.py +0 -34
- package/scripts/forge_dataset/checks.py +0 -1
- package/scripts/forge_dataset/cli.py +5 -1
- package/scripts/forge_dataset/export.py +28 -6
- package/scripts/forge_dataset/facts.py +1 -2
- package/scripts/forge_dataset/forecast.py +1 -1
- package/scripts/forge_dataset/harvest.py +107 -7
- package/scripts/forge_dataset/importer.py +3 -2
- package/scripts/forge_dataset/pairs.py +3 -3
- package/scripts/forge_dataset/reviewers.py +4 -3
- package/scripts/forge_dataset/routing.py +6 -3
- package/scripts/forge_dataset/tiers.py +1 -1
- package/scripts/forge_decide/__init__.py +1 -1
- package/scripts/forge_decide/budget.py +12 -7
- package/scripts/forge_decide/profiles.py +11 -14
- package/scripts/forge_decide/replay.py +9 -4
- package/scripts/forge_decompose.py +987 -0
- package/scripts/forge_flock.py +17 -2
- package/scripts/forge_groups/review.py +6 -1
- package/scripts/forge_jev/__init__.py +1 -1
- package/scripts/forge_jev/cli.py +10 -1
- package/scripts/forge_jev/gates.py +10 -1
- package/scripts/forge_jev/verify.py +10 -2
- package/scripts/forge_legacy.py +86 -0
- package/scripts/forge_memory_home.py +57 -0
- package/scripts/forge_models.py +151 -0
- package/scripts/forge_posix.py +17 -0
- package/scripts/forge_prefs.py +138 -0
- package/scripts/forge_proc.py +108 -0
- package/scripts/forge_registry.py +2 -2
- package/scripts/forge_side/__init__.py +23 -4
- package/scripts/forge_storage.py +28 -15
- package/ui/README.md +22 -10
- package/ui/docs/api.md +121 -99
- package/ui/forge_ui/control.py +53 -16
- package/ui/forge_ui/export.py +0 -10
- package/ui/forge_ui/models.py +15 -2
- package/ui/forge_ui/projects.py +4 -1
- package/ui/forge_ui/reader.py +462 -60
- package/ui/forge_ui/server.py +0 -10
- package/ui/forge_ui/static/app.js +28 -9
- package/ui/forge_ui/static/checksview.js +12 -3
- package/ui/forge_ui/static/controls.js +147 -11
- package/ui/forge_ui/static/convo.js +5 -2
- package/ui/forge_ui/static/diffview.js +4 -5
- package/ui/forge_ui/static/panel.js +180 -77
- package/ui/forge_ui/static/projectsview.js +16 -2
- package/ui/forge_ui/static/runmodel.js +18 -4
- package/ui/forge_ui/static/scene3d.js +52 -31
- package/ui/forge_ui/static/settings.js +1 -1
- package/ui/forge_ui/static/storageview.js +2 -2
- package/ui/forge_ui/static/style.css +23 -6
- package/ui/forge_ui/static/worktreesview.js +8 -4
- package/ui/forge_ui/transcripts.py +6 -0
- package/ui/forge_ui/worktrees.py +13 -1
- package/docs/fractal.md +0 -181
- package/references/fractal-dashboard.md +0 -21
- package/references/fractal.md +0 -307
- package/scripts/forge-fractal-dispatch.sh +0 -4
- package/scripts/forge-fractal-options.sh +0 -54
- package/scripts/forge-fractal.py +0 -6
- package/scripts/forge-install-fractal.sh +0 -4
- package/scripts/forge_fractal/__init__.py +0 -88
- package/scripts/forge_fractal/bridge.py +0 -46
- package/scripts/forge_fractal/cli.py +0 -224
- package/scripts/forge_fractal/dashboard.css +0 -138
- package/scripts/forge_fractal/dashboard.html +0 -41
- package/scripts/forge_fractal/dashboard.js +0 -687
- package/scripts/forge_fractal/decomposition.py +0 -262
- package/scripts/forge_fractal/execution.py +0 -659
- package/scripts/forge_fractal/inspection.py +0 -261
- package/scripts/forge_fractal/install.py +0 -158
- package/scripts/forge_fractal/invocation.py +0 -95
- package/scripts/forge_fractal/pipeline.py +0 -125
- package/scripts/forge_fractal/selection.py +0 -180
- package/ui/forge_ui/fractal.py +0 -582
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
# (claude, openclaude, codex; custom prompt only)
|
|
14
14
|
# forge-dispatch.sh dwarf <spec> ... --continue-session <id> continue that implementer session
|
|
15
15
|
# (claude, openclaude)
|
|
16
|
+
# forge-dispatch.sh dwarf <spec> ... --steer <plan> <task> <attempt> live steering (#252): a claude or
|
|
17
|
+
# openclaude implementer takes the task's `forge control steer --now`
|
|
18
|
+
# messages while it runs (stream-json input fed by forge-control.py)
|
|
16
19
|
# forge-dispatch.sh side <spec> --prompt-file <f> [--repo <dir>] [--run-dir <d>] [--yolo] [--dry-run]
|
|
17
20
|
# read-only; a brief or summary dispatch (default effort low)
|
|
18
21
|
# any role: [--no-ripwire] [--ripwire-query-file <requirements>]
|
|
@@ -39,11 +42,15 @@
|
|
|
39
42
|
#
|
|
40
43
|
# Environment: FORGE_REGISTRY alternate registry file (default: <skill>/registry.tsv)
|
|
41
44
|
# FORGE_ORPHAN_GUARD off = do not run the harness in its own process group
|
|
42
|
-
# (default on
|
|
45
|
+
# (default on)
|
|
43
46
|
# FORGE_RESULT_GRACE claude/openclaude: seconds a log that ends in the model's final
|
|
44
47
|
# result may stay silent before forge ends the harness (an open
|
|
45
48
|
# background task keeps it up); default 1800, 0 = off. Either way
|
|
46
49
|
# a dispatch killed after that result is not a timeout.
|
|
50
|
+
# FORGE_LIVE_STEER off = never run an implementer live, --steer or not (default on)
|
|
51
|
+
# FORGE_LIVE_GRACE live steering: seconds of silence after the final result, with no
|
|
52
|
+
# background task open, before forge ends the harness (default 10;
|
|
53
|
+
# its input stays open, so it never exits by itself)
|
|
47
54
|
#
|
|
48
55
|
# Exit codes: 0 ok | 2 usage/resolution error | 3 harness missing or unusable
|
|
49
56
|
# (including a --service-tier fast the harness cannot take per invocation)
|
|
@@ -65,6 +72,10 @@
|
|
|
65
72
|
set -uo pipefail
|
|
66
73
|
|
|
67
74
|
SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
75
|
+
# Windows: re-run inside MSYS2 when started from Git Bash (no-op elsewhere).
|
|
76
|
+
. "$SKILL_DIR/scripts/forge-win.sh"
|
|
77
|
+
source "$SKILL_DIR/scripts/forge-lib-env.sh"
|
|
78
|
+
forge_ensure_python3
|
|
68
79
|
REGISTRY="${FORGE_REGISTRY:-$SKILL_DIR/registry.tsv}"
|
|
69
80
|
RUNTIME="$SKILL_DIR/scripts/forge-runtime.py"
|
|
70
81
|
GUARD="$SKILL_DIR/scripts/forge-guard.py"
|
|
@@ -94,6 +105,51 @@ binary_for() {
|
|
|
94
105
|
case "$1" in antigravity) echo agy ;; *) echo "$1" ;; esac
|
|
95
106
|
}
|
|
96
107
|
|
|
108
|
+
# Resolve a harness CLI: first PATH, then well-known per-user Windows install paths.
|
|
109
|
+
resolve_binary() { # resolve_binary <harness> -> path on stdout, exit 1 if missing
|
|
110
|
+
local name bin cand localappdata appdata userprofile
|
|
111
|
+
name="$(binary_for "$1")"
|
|
112
|
+
if bin="$(command -v "$name" 2>/dev/null)" && [ -n "$bin" ]; then
|
|
113
|
+
printf '%s\n' "$bin"; return 0
|
|
114
|
+
fi
|
|
115
|
+
forge_is_windows || return 1
|
|
116
|
+
if bin="$(command -v "$name.cmd" 2>/dev/null)" && [ -n "$bin" ]; then
|
|
117
|
+
printf '%s\n' "$bin"; return 0
|
|
118
|
+
fi
|
|
119
|
+
localappdata="$(forge_posix_path "${LOCALAPPDATA:-}")"
|
|
120
|
+
appdata="$(forge_posix_path "${APPDATA:-}")"
|
|
121
|
+
userprofile="$(forge_posix_path "${USERPROFILE:-}")"
|
|
122
|
+
case "$1" in
|
|
123
|
+
antigravity)
|
|
124
|
+
for cand in ${localappdata:+"$localappdata/agy/bin/agy.exe"}; do
|
|
125
|
+
[ -f "$cand" ] && { printf '%s\n' "$cand"; return 0; }
|
|
126
|
+
done ;;
|
|
127
|
+
opencode)
|
|
128
|
+
if bin="$(command -v opencode-cli 2>/dev/null)" && [ -n "$bin" ]; then
|
|
129
|
+
printf '%s\n' "$bin"; return 0
|
|
130
|
+
fi
|
|
131
|
+
for cand in \
|
|
132
|
+
${localappdata:+"$localappdata/Programs/@opencode-aidesktop/resources/opencode-cli.exe"} \
|
|
133
|
+
${appdata:+"$appdata/npm/opencode.cmd"} \
|
|
134
|
+
${appdata:+"$appdata/npm/opencode"}; do
|
|
135
|
+
[ -f "$cand" ] && { printf '%s\n' "$cand"; return 0; }
|
|
136
|
+
done ;;
|
|
137
|
+
claude)
|
|
138
|
+
for cand in \
|
|
139
|
+
${userprofile:+"$userprofile/.local/bin/claude.exe"} \
|
|
140
|
+
${HOME:+"$HOME/.local/bin/claude.exe"}; do
|
|
141
|
+
[ -f "$cand" ] && { printf '%s\n' "$cand"; return 0; }
|
|
142
|
+
done ;;
|
|
143
|
+
openclaude|codex)
|
|
144
|
+
for cand in \
|
|
145
|
+
${appdata:+"$appdata/npm/$name.cmd"} \
|
|
146
|
+
${appdata:+"$appdata/npm/$name"}; do
|
|
147
|
+
[ -f "$cand" ] && { printf '%s\n' "$cand"; return 0; }
|
|
148
|
+
done ;;
|
|
149
|
+
esac
|
|
150
|
+
return 1
|
|
151
|
+
}
|
|
152
|
+
|
|
97
153
|
# Every effort word forge recognizes, weakest first. Used only to tell "you asked
|
|
98
154
|
# for more thinking than this pairing offers" (clamp, keep going) apart from "that
|
|
99
155
|
# is not an effort level" (stop). ultra and ultracode are each their harness's top
|
|
@@ -190,7 +246,7 @@ doctor() {
|
|
|
190
246
|
local rc=0 h bin
|
|
191
247
|
printf '%-12s %-10s %s\n' HARNESS STATUS DETAIL
|
|
192
248
|
for h in codex claude openclaude opencode antigravity grok; do
|
|
193
|
-
bin="$(
|
|
249
|
+
bin="$(resolve_binary "$h" 2>/dev/null)"
|
|
194
250
|
if [ -z "$bin" ]; then
|
|
195
251
|
printf '%-12s %-10s %s\n' "$h" MISSING "$(binary_for "$h") not on PATH"; rc=1; continue
|
|
196
252
|
fi
|
|
@@ -239,6 +295,7 @@ SPEC="$1"; shift
|
|
|
239
295
|
RIPWIRE_QUERY=""
|
|
240
296
|
OUTPUT=full
|
|
241
297
|
REPO="$PWD"; RUN_DIR=""; PROMPT_FILE=""; YOLO=0; DRY=0; REVIEW_BASE=""; PROMPT_VIA_STDIN=0; NATIVE_REVIEW=0; CONTINUE_ID=""; CONTINUE_GIVEN=0; AGY_TIMEOUT="30m"; TIMEOUT_FLAG=""; SERVICE_TIER=""
|
|
298
|
+
LIVE=0; LIVE_PLAN=""; LIVE_TASK=""; LIVE_ATTEMPT=""
|
|
242
299
|
while [ $# -gt 0 ]; do
|
|
243
300
|
case "$1" in
|
|
244
301
|
--no-ripwire) export FORGE_RIPWIRE=off; shift ;;
|
|
@@ -255,6 +312,8 @@ while [ $# -gt 0 ]; do
|
|
|
255
312
|
--service-tier) [ $# -ge 2 ] || die "--service-tier needs a value"; [ "$2" = fast ] || die "--service-tier accepts only fast"; SERVICE_TIER=fast; shift 2 ;;
|
|
256
313
|
--yolo) YOLO=1; shift ;;
|
|
257
314
|
--dry-run) DRY=1; shift ;;
|
|
315
|
+
--steer) [ $# -ge 4 ] || die "--steer needs a plan dir, a task id and an attempt number"
|
|
316
|
+
LIVE_PLAN="$2"; LIVE_TASK="$3"; LIVE_ATTEMPT="$4"; shift 4 ;;
|
|
258
317
|
*) die "unknown option '$1'" ;;
|
|
259
318
|
esac
|
|
260
319
|
done
|
|
@@ -288,7 +347,14 @@ else
|
|
|
288
347
|
# never seen, and guessing wrong burns a real dispatch.
|
|
289
348
|
[ -n "$HARNESS" ] || die "'$ALIAS' is not a known alias. Either add it to $REGISTRY or name the harness explicitly, e.g. --dwarf $ALIAS:high:opencode"
|
|
290
349
|
if [ -n "$(awk -F'\t' -v a="$ALIAS" '!/^#/ && $1 == a {print; exit}' "$REGISTRY")" ]; then
|
|
291
|
-
|
|
350
|
+
# An alias is one model on every harness (#187): another version a harness serves has a
|
|
351
|
+
# versioned alias of its own (opus-4.6 on antigravity). Name those, so the fix is one word.
|
|
352
|
+
VERSIONED="$(awk -F'\t' -v a="$ALIAS-" -v h="$HARNESS" '!/^#/ && index($1, a) == 1 && $2 == h {printf "%s%s", sep, $1; sep=", "}' "$REGISTRY")"
|
|
353
|
+
if [ -n "$VERSIONED" ]; then
|
|
354
|
+
note "alias '$ALIAS' has no row for harness '$HARNESS' — using it as a literal model id ($HARNESS serves $VERSIONED)"
|
|
355
|
+
else
|
|
356
|
+
note "alias '$ALIAS' has no row for harness '$HARNESS' — using it as a literal model id"
|
|
357
|
+
fi
|
|
292
358
|
else
|
|
293
359
|
note "'$ALIAS' is not in the registry — using it as a literal model id on $HARNESS"
|
|
294
360
|
fi
|
|
@@ -406,6 +472,24 @@ RESULT_GRACE="${FORGE_RESULT_GRACE:-1800}"
|
|
|
406
472
|
case "$RESULT_GRACE" in ''|*[!0-9]*) die "FORGE_RESULT_GRACE must be a nonnegative integer" ;; esac
|
|
407
473
|
[ "${#RESULT_GRACE}" -gt 9 ] || RESULT_GRACE=$((10#$RESULT_GRACE))
|
|
408
474
|
|
|
475
|
+
# --- live steering (#252) -------------------------------------------------------
|
|
476
|
+
# A claude or openclaude implementer given --steer reads stream-json on stdin: forge-control.py
|
|
477
|
+
# _steer-feed sends the prompt as the first user message, then each `forge control steer --now`
|
|
478
|
+
# message, which the CLI takes in at its next tool boundary. Windows has no FIFO for the feed, so
|
|
479
|
+
# it dispatches as before. Preflight turns it off for a CLI whose help lacks the input flags.
|
|
480
|
+
LIVE_GRACE="${FORGE_LIVE_GRACE:-10}"
|
|
481
|
+
case "$LIVE_GRACE" in ''|*[!0-9]*) die "FORGE_LIVE_GRACE must be a nonnegative integer" ;; esac
|
|
482
|
+
if [ -n "$LIVE_PLAN" ]; then
|
|
483
|
+
case "$LIVE_ATTEMPT" in ''|0*|*[!0-9]*) die "--steer needs a positive attempt number" ;; esac
|
|
484
|
+
[ -d "$LIVE_PLAN" ] || die "--steer: '$LIVE_PLAN' is not a directory"
|
|
485
|
+
LIVE_PLAN="$(cd "$LIVE_PLAN" && pwd)"
|
|
486
|
+
case "${FORGE_LIVE_STEER:-on}" in off|OFF|Off|0|no|false) ;; *)
|
|
487
|
+
if [ "$ROLE" = dwarf ] && ! forge_is_windows; then
|
|
488
|
+
case "$HARNESS" in claude|openclaude) LIVE=1 ;; esac
|
|
489
|
+
fi ;;
|
|
490
|
+
esac
|
|
491
|
+
fi
|
|
492
|
+
|
|
409
493
|
# --- run dir & prompt ---------------------------------------------------------
|
|
410
494
|
[ -d "$REPO" ] || die "--repo '$REPO' is not a directory"
|
|
411
495
|
REPO="$(cd "$REPO" && pwd)"
|
|
@@ -432,19 +516,22 @@ if [ "$PREFLIGHT" != 1 ] && [ "$DRY" != 1 ]; then
|
|
|
432
516
|
# dispatch and must not be the thing that hangs it.
|
|
433
517
|
exit_cleanup() {
|
|
434
518
|
[ -z "${tpid:-}" ] || kill -TERM "$tpid" 2>/dev/null
|
|
519
|
+
# Live steering: the feeder ends with its harness; its unsent messages go back to the queue.
|
|
520
|
+
[ "${LIVE:-0}" != 1 ] || [ -z "${FEED_STOP:-}" ] || { : > "$FEED_STOP"; } 2>/dev/null
|
|
521
|
+
local _hw="${hwinpid:-${hpid:-}}"
|
|
435
522
|
if [ -n "${hpid:-}" ] && kill -0 "$hpid" 2>/dev/null; then
|
|
436
|
-
[ "${GUARD_ON:-0}" != 1 ] ||
|
|
437
|
-
|
|
523
|
+
[ "${GUARD_ON:-0}" != 1 ] || forge_kill_group "$hpid" TERM
|
|
524
|
+
forge_kill_children "$hpid" TERM; kill -TERM "$hpid" 2>/dev/null
|
|
438
525
|
if [ "${GUARD_ON:-0}" = 1 ]; then
|
|
439
|
-
sleep 1;
|
|
526
|
+
sleep 1; forge_kill_group "$hpid" KILL
|
|
440
527
|
# what it started in sessions of their own (#129)
|
|
441
|
-
python3 "$GUARD" reap "$
|
|
528
|
+
python3 "$GUARD" reap "$_hw" "$RUN_DIR/$ROLE.orphans" --tracked "$RUN_DIR/$ROLE.tracked" >/dev/null 2>&1
|
|
442
529
|
fi
|
|
443
|
-
elif [ "${GUARD_ON:-0}" = 1 ] && [ "${reaped:-0}" != 1 ] && [ -n "${
|
|
530
|
+
elif [ "${GUARD_ON:-0}" = 1 ] && [ "${reaped:-0}" != 1 ] && [ -n "${_hw:-}" ]; then
|
|
444
531
|
# Interrupted after the harness exited but before the normal reap.
|
|
445
|
-
python3 "$GUARD" reap "$
|
|
532
|
+
python3 "$GUARD" reap "$_hw" "$RUN_DIR/$ROLE.orphans" --tracked "$RUN_DIR/$ROLE.tracked" >/dev/null 2>&1
|
|
446
533
|
fi
|
|
447
|
-
for watcher in ${wpid:-} ${spid:-}; do
|
|
534
|
+
for watcher in ${wpid:-} ${spid:-}; do forge_kill_children "$watcher" TERM; kill "$watcher" 2>/dev/null; done
|
|
448
535
|
[ -z "${cpid:-}" ] || kill "$cpid" 2>/dev/null
|
|
449
536
|
rm -f "$RUN_DIR/$ROLE.harness" "$RUN_DIR/$ROLE.tracked"
|
|
450
537
|
case "${ROLE_TMP:-}" in "$RUN_DIR"/.*-tmp.*) [ ! -d "$ROLE_TMP" ] || rm -rf -- "$ROLE_TMP" ;; esac
|
|
@@ -547,6 +634,15 @@ codex_read_only() {
|
|
|
547
634
|
}
|
|
548
635
|
|
|
549
636
|
# Sets CMD (and PROMPT_VIA_STDIN) for the dispatch, or for the fresh one when CONTINUE_ID is empty.
|
|
637
|
+
D_REPO="$REPO"; D_RUN_DIR="$RUN_DIR"; D_LAST="$LAST"; D_PROMPT_FILE="$PROMPT_FILE"; D_GUARD="$GUARD"
|
|
638
|
+
if forge_is_windows; then
|
|
639
|
+
D_REPO="$(forge_host_path "$REPO")"
|
|
640
|
+
D_RUN_DIR="$(forge_host_path "$RUN_DIR")"
|
|
641
|
+
D_LAST="$(forge_host_path "$LAST")"
|
|
642
|
+
D_PROMPT_FILE="$(forge_host_path "$PROMPT_FILE")"
|
|
643
|
+
D_GUARD="$(forge_host_path "$GUARD")"
|
|
644
|
+
fi
|
|
645
|
+
|
|
550
646
|
build_cmd() {
|
|
551
647
|
CMD=()
|
|
552
648
|
case "$HARNESS" in
|
|
@@ -557,7 +653,7 @@ build_cmd() {
|
|
|
557
653
|
# whether the diff is correct, but not whether it is the change that was
|
|
558
654
|
# actually asked for. `codex exec review` also has no --cd, hence the
|
|
559
655
|
# subshell cd below.
|
|
560
|
-
CMD=(codex exec review --json -m "$MODEL" --skip-git-repo-check -o "$
|
|
656
|
+
CMD=(codex exec review --json -m "$MODEL" --skip-git-repo-check -o "$D_LAST")
|
|
561
657
|
[ -n "$EFFORT" ] && CMD+=(-c "model_reasoning_effort=$EFFORT")
|
|
562
658
|
[ "$SERVICE_TIER" = fast ] && CMD+=(-c "service_tier=fast")
|
|
563
659
|
if [ -n "$REVIEW_BASE" ]; then CMD+=(--base "$REVIEW_BASE"); else CMD+=(--uncommitted); fi
|
|
@@ -569,7 +665,7 @@ build_cmd() {
|
|
|
569
665
|
# An id that starts with '-' would be read as a flag, so it goes after a `--`.
|
|
570
666
|
CMD=(codex exec resume)
|
|
571
667
|
case "$CONTINUE_ID" in -*) ;; *) CMD+=("$CONTINUE_ID") ;; esac
|
|
572
|
-
CMD+=(--json -m "$MODEL" --skip-git-repo-check -o "$
|
|
668
|
+
CMD+=(--json -m "$MODEL" --skip-git-repo-check -o "$D_LAST")
|
|
573
669
|
[ -n "$EFFORT" ] && CMD+=(-c "model_reasoning_effort=$EFFORT")
|
|
574
670
|
[ "$SERVICE_TIER" = fast ] && CMD+=(-c "service_tier=fast")
|
|
575
671
|
if [ "$YOLO" = 1 ]; then CMD+=(--dangerously-bypass-approvals-and-sandbox)
|
|
@@ -578,7 +674,7 @@ build_cmd() {
|
|
|
578
674
|
CMD+=(-)
|
|
579
675
|
PROMPT_VIA_STDIN=1
|
|
580
676
|
else
|
|
581
|
-
CMD=(codex exec --json -m "$MODEL" -C "$
|
|
677
|
+
CMD=(codex exec --json -m "$MODEL" -C "$D_REPO" --skip-git-repo-check -o "$D_LAST")
|
|
582
678
|
[ -n "$EFFORT" ] && CMD+=(-c "model_reasoning_effort=$EFFORT")
|
|
583
679
|
[ "$SERVICE_TIER" = fast ] && CMD+=(-c "service_tier=fast")
|
|
584
680
|
# --approve-for-me and --dangerously-bypass-... are mutually exclusive.
|
|
@@ -593,11 +689,14 @@ build_cmd() {
|
|
|
593
689
|
# The run dir sits outside the repo (so it stays out of the diff), which also
|
|
594
690
|
# puts it outside the harness's default reach — without this the agent
|
|
595
691
|
# refuses to open the very artifacts forge just wrote for it.
|
|
596
|
-
CMD=("$HARNESS" -p --model "$MODEL" --add-dir "$
|
|
692
|
+
CMD=("$HARNESS" -p --model "$MODEL" --add-dir "$D_RUN_DIR")
|
|
597
693
|
# One JSON message per line: what the agent said and every tool call, so the run keeps
|
|
598
694
|
# its conversation (forge-ui reads it), ending in the `result` line forge-runtime.py
|
|
599
695
|
# takes the final message and the tokens from. stream-json needs --verbose with -p.
|
|
600
696
|
CMD+=(--output-format stream-json --verbose)
|
|
697
|
+
# Live steering (#252): the prompt and later messages come as stream-json user messages, and
|
|
698
|
+
# the log replays each one where the CLI took it in (forge-ui shows them in the conversation).
|
|
699
|
+
[ "$LIVE" != 1 ] || CMD+=(--input-format stream-json --replay-user-messages)
|
|
601
700
|
[ -n "$EFFORT" ] && CMD+=(--effort "$EFFORT")
|
|
602
701
|
# Hidden: claude --help does not list it. openclaude has no per-invocation tier
|
|
603
702
|
# and is refused before build_cmd; this guard keeps the flag off its argv too.
|
|
@@ -639,7 +738,7 @@ build_cmd() {
|
|
|
639
738
|
PROMPT_VIA_STDIN=1
|
|
640
739
|
;;
|
|
641
740
|
opencode)
|
|
642
|
-
CMD=(opencode run -m "$MODEL" --dir "$
|
|
741
|
+
CMD=(opencode run -m "$MODEL" --dir "$D_REPO")
|
|
643
742
|
[ -n "$EFFORT" ] && CMD+=(--variant "$EFFORT")
|
|
644
743
|
# opencode run exposes no sandbox tier — without --auto it blocks on a
|
|
645
744
|
# permission prompt that nothing can answer headlessly, so it is always set.
|
|
@@ -660,7 +759,7 @@ build_cmd() {
|
|
|
660
759
|
# --add-dir on the repo is not optional. Antigravity is workspace-scoped
|
|
661
760
|
# rather than cwd-scoped, so without it the agent searches the wrong tree and
|
|
662
761
|
# the run dies on "Find command timed out: context deadline exceeded".
|
|
663
|
-
CMD+=(--add-dir "$
|
|
762
|
+
CMD+=(--add-dir "$D_REPO" --add-dir "$D_RUN_DIR")
|
|
664
763
|
if [ "$YOLO" = 1 ]; then CMD+=(--dangerously-skip-permissions)
|
|
665
764
|
elif read_only_role; then CMD+=(--mode plan)
|
|
666
765
|
else CMD+=(--mode accept-edits); fi
|
|
@@ -672,7 +771,7 @@ build_cmd() {
|
|
|
672
771
|
# claude gives without acceptEdits, so the dwarf gets edits and the whole shell.
|
|
673
772
|
# The Messages-format stream ends in a claude-shaped `result` line, which
|
|
674
773
|
# forge-runtime.py reads for the final message and the tokens.
|
|
675
|
-
CMD=(grok --model "$MODEL" --prompt-file "$
|
|
774
|
+
CMD=(grok --model "$MODEL" --prompt-file "$D_PROMPT_FILE" --output-format streaming-messages-json)
|
|
676
775
|
[ -n "$EFFORT" ] && CMD+=(--reasoning-effort "$EFFORT")
|
|
677
776
|
# After its last turn a headless run waits for the background work it started (a test
|
|
678
777
|
# suite, say) and wakes the model with each result, but by default for only 600 s: then
|
|
@@ -693,6 +792,9 @@ build_cmd() {
|
|
|
693
792
|
;;
|
|
694
793
|
*) die "no dispatch recipe for harness '$HARNESS'" ;;
|
|
695
794
|
esac
|
|
795
|
+
if [ -n "${RESOLVED_BIN:-}" ] && ! command -v "$(binary_for "$HARNESS")" >/dev/null 2>&1; then
|
|
796
|
+
CMD[0]="$RESOLVED_BIN"
|
|
797
|
+
fi
|
|
696
798
|
}
|
|
697
799
|
# A read-only role's own writable temp dir (#148). Test runners need one (Vitest's EPERM in a
|
|
698
800
|
# read-only sandbox), and the role gets none otherwise. It sits in the run dir, outside the
|
|
@@ -700,12 +802,15 @@ build_cmd() {
|
|
|
700
802
|
# point at it, and the dispatch removes it when it ends. A dry run or a preflight only shows
|
|
701
803
|
# its shape.
|
|
702
804
|
ROLE_TMP=""
|
|
805
|
+
D_ROLE_TMP=""
|
|
703
806
|
if read_only_role; then
|
|
704
807
|
if [ -n "$ATTEMPT" ]; then
|
|
705
808
|
ROLE_TMP="$(mktemp -d "$RUN_DIR/.$ROLE-tmp.XXXXXX")" || ROLE_TMP=""
|
|
706
809
|
else
|
|
707
810
|
ROLE_TMP="$RUN_DIR/.$ROLE-tmp.XXXXXX"
|
|
708
811
|
fi
|
|
812
|
+
D_ROLE_TMP="$ROLE_TMP"
|
|
813
|
+
[ -z "$ROLE_TMP" ] || ! forge_is_windows || D_ROLE_TMP="$(forge_host_path "$ROLE_TMP")"
|
|
709
814
|
fi
|
|
710
815
|
build_cmd
|
|
711
816
|
|
|
@@ -735,11 +840,26 @@ unadvertised_flag() { # unadvertised_flag <help text>
|
|
|
735
840
|
preflight_command() {
|
|
736
841
|
local bin help flag request="$CONTINUE_ID"
|
|
737
842
|
local help_args=(--help) continue_args=(--help)
|
|
738
|
-
bin="$(
|
|
843
|
+
bin="$(resolve_binary "$HARNESS")" || die "harness '$HARNESS' is not installed" 3
|
|
844
|
+
! forge_is_windows || bin="$(forge_host_path "$bin")"
|
|
845
|
+
RESOLVED_BIN="$bin"
|
|
846
|
+
if ! command -v "$(binary_for "$HARNESS")" >/dev/null 2>&1; then
|
|
847
|
+
CMD[0]="$RESOLVED_BIN"
|
|
848
|
+
fi
|
|
739
849
|
case "$HARNESS" in
|
|
740
850
|
codex) help_args=(exec --help); continue_args=(exec resume --help); [ "$NATIVE_REVIEW" = 1 ] && help_args=(exec review --help) ;;
|
|
741
851
|
opencode) help_args=(run --help) ;;
|
|
742
852
|
esac
|
|
853
|
+
# A CLI that does not advertise the stream-json input runs as before, without live steering.
|
|
854
|
+
if [ "$LIVE" = 1 ]; then
|
|
855
|
+
help="$(capability_help "$bin" --help 2>/dev/null)" || help=""
|
|
856
|
+
for flag in --input-format --replay-user-messages; do
|
|
857
|
+
printf '%s\n' "$help" | grep -E -- "(^|[[:space:],|])$flag([=[:space:],|]|$)" >/dev/null && continue
|
|
858
|
+
LIVE=0; build_cmd
|
|
859
|
+
note "$HARNESS does not advertise $flag; this implementer runs without live steering"
|
|
860
|
+
break
|
|
861
|
+
done
|
|
862
|
+
fi
|
|
743
863
|
# grok's help hides --background-wait-timeout, which every grok recipe passes. grok checks
|
|
744
864
|
# every flag and its value before it answers --help, so a help call with the flag in front
|
|
745
865
|
# proves it exists.
|
|
@@ -782,6 +902,7 @@ if [ "$DRY" != 1 ] || [ "$PREFLIGHT" = 1 ]; then preflight_command; fi
|
|
|
782
902
|
echo "timeout=$LIMIT"
|
|
783
903
|
echo "timeout_source=$LIMIT_SOURCE"
|
|
784
904
|
case "$HARNESS" in claude|openclaude) echo "result_grace=$RESULT_GRACE" ;; esac
|
|
905
|
+
[ "$LIVE" != 1 ] || echo "steer=live"
|
|
785
906
|
# Native review ignores the assembled prompt, so whether it reached the model is a fact
|
|
786
907
|
# worth recording rather than inferring from the role and harness later.
|
|
787
908
|
echo "delivery=$([ "$NATIVE_REVIEW" = 1 ] && echo native_review || echo custom)"
|
|
@@ -829,7 +950,11 @@ fi
|
|
|
829
950
|
if [ "$YOLO" = 1 ]; then
|
|
830
951
|
note "YOLO: $HARNESS runs with sandbox and approvals disabled in $REPO"
|
|
831
952
|
fi
|
|
832
|
-
|
|
953
|
+
RESOLVED_BIN="$(resolve_binary "$HARNESS")" || die "harness '$HARNESS' is not installed ($(binary_for "$HARNESS") not on PATH)" 3
|
|
954
|
+
! forge_is_windows || RESOLVED_BIN="$(forge_host_path "$RESOLVED_BIN")"
|
|
955
|
+
if ! command -v "$(binary_for "$HARNESS")" >/dev/null 2>&1; then
|
|
956
|
+
CMD[0]="$RESOLVED_BIN"
|
|
957
|
+
fi
|
|
833
958
|
|
|
834
959
|
# Harnesses that take the prompt on argv get stdin redirected from /dev/null:
|
|
835
960
|
# codex exec otherwise blocks waiting to append piped input to the prompt, which
|
|
@@ -853,22 +978,33 @@ t0="$(date +%s)"
|
|
|
853
978
|
# process running after dispatch returns, mutating the tree under whoever reads it next.
|
|
854
979
|
# forge-guard.py does setsid() and then exec()s the harness, so $! is still the harness
|
|
855
980
|
# pid and is now also its group id; after the harness exits, anything left in the group is
|
|
856
|
-
# reaped and listed. Off by kill switch
|
|
857
|
-
# groups and would otherwise lose the ability to signal this one). If the helper cannot
|
|
981
|
+
# reaped and listed. Off by kill switch. If the helper cannot
|
|
858
982
|
# even start, fall back to the plain exec: a guard failure must never cost the run.
|
|
859
983
|
GUARD_ON=0; reaped=0
|
|
860
984
|
case "${FORGE_ORPHAN_GUARD:-on}" in off|OFF|Off|0|no|false) ;; *)
|
|
861
|
-
if [ -
|
|
985
|
+
if [ -r "$GUARD" ] && [ "$(python3 "$GUARD" ping 2>/dev/null)" = ok ]; then GUARD_ON=1; fi ;;
|
|
862
986
|
esac
|
|
863
987
|
RUNCMD=("${CMD[@]}")
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
988
|
+
# Windows MSYS2 mode (forge-win.sh): the harness gets the PATH it had in Git Bash, not MSYS2's.
|
|
989
|
+
[ -z "${FORGE_WIN_AGENT_PATH:-}" ] || RUNCMD=(env -u MSYS -u FORGE_WIN_AGENT_PATH "PATH=$FORGE_WIN_AGENT_PATH" "MSYSTEM=${FORGE_WIN_MSYSTEM-}" "${CMD[@]}")
|
|
990
|
+
[ "$GUARD_ON" != 1 ] || RUNCMD=(python3 "$D_GUARD" session -- "${RUNCMD[@]}")
|
|
991
|
+
role_env() { [ -z "$D_ROLE_TMP" ] || export TMPDIR="$D_ROLE_TMP" TMP="$D_ROLE_TMP" TEMP="$D_ROLE_TMP"; }
|
|
992
|
+
FEED_STOP="$RUN_DIR/$ROLE.feed.stop"; FEED_PID="$RUN_DIR/$ROLE.feed.pid"
|
|
993
|
+
if [ "$LIVE" = 1 ]; then
|
|
994
|
+
# The feeder is the harness's stdin, and the harness becomes its parent through the exec: it stops
|
|
995
|
+
# when the model ends its turn, when the harness is gone, or when FEED_STOP appears. Its own
|
|
996
|
+
# messages go to $ROLE.feed, never into the log forge parses.
|
|
997
|
+
rm -f "$FEED_STOP" "$FEED_PID"
|
|
998
|
+
( cd "$REPO" && role_env && exec "${RUNCMD[@]}" < <(exec python3 "$SKILL_DIR/scripts/forge-control.py" _steer-feed "$LIVE_PLAN" "$LIVE_TASK" \
|
|
999
|
+
"$LIVE_ATTEMPT" "$PROMPT_FILE" "$LOG" --harness "$HARNESS" --stop "$FEED_STOP" --pidfile "$FEED_PID" \
|
|
1000
|
+
</dev/null 2>>"$RUN_DIR/$ROLE.feed") ) > "$LOG" 2>&1 &
|
|
1001
|
+
elif [ "$PROMPT_VIA_STDIN" = 1 ]; then
|
|
1002
|
+
( cd "$REPO" && role_env && { ! forge_is_windows || export MSYS_NO_PATHCONV=1; } && exec "${RUNCMD[@]}" < "$PROMPT_FILE" ) > "$LOG" 2>&1 &
|
|
868
1003
|
else
|
|
869
|
-
( cd "$REPO" && role_env && exec "${RUNCMD[@]}" </dev/null ) > "$LOG" 2>&1 &
|
|
1004
|
+
( cd "$REPO" && role_env && { ! forge_is_windows || export MSYS_NO_PATHCONV=1; } && exec "${RUNCMD[@]}" </dev/null ) > "$LOG" 2>&1 &
|
|
870
1005
|
fi
|
|
871
1006
|
hpid=$!
|
|
1007
|
+
hwinpid="$(forge_winpid "$hpid")"
|
|
872
1008
|
# Log clock: when the log grew, so forge-ui can time the commands of a harness whose events
|
|
873
1009
|
# carry no time (codex, grok). Advisory and off with FORGE_LOG_CLOCK=off; it ends on its own
|
|
874
1010
|
# if this dispatch dies first.
|
|
@@ -881,9 +1017,9 @@ esac
|
|
|
881
1017
|
# (forge-guard.py stop) in case this dispatch dies before the trap finishes. The start time
|
|
882
1018
|
# tells the pid apart from a later reuse, and survives the exec chain $! still goes through.
|
|
883
1019
|
if [ "$GUARD_ON" = 1 ]; then
|
|
884
|
-
hident="$(python3 "$GUARD" identity "$
|
|
1020
|
+
hident="$(python3 "$GUARD" identity "$hwinpid" 2>/dev/null)" || hident=""
|
|
885
1021
|
if [ -n "$hident" ]; then
|
|
886
|
-
printf '%s\t%s\n' "$
|
|
1022
|
+
printf '%s\t%s\n' "$hwinpid" "$hident" > "$RUN_DIR/.$ROLE.harness.tmp" \
|
|
887
1023
|
&& mv -f "$RUN_DIR/.$ROLE.harness.tmp" "$RUN_DIR/$ROLE.harness"
|
|
888
1024
|
fi
|
|
889
1025
|
fi
|
|
@@ -892,19 +1028,31 @@ fi
|
|
|
892
1028
|
# it as a descendant, so the reap finds it by pid and start time. Advisory, like the guard.
|
|
893
1029
|
tpid=""
|
|
894
1030
|
if [ "$GUARD_ON" = 1 ]; then
|
|
895
|
-
python3 "$GUARD" track "$
|
|
1031
|
+
python3 "$GUARD" track "$hwinpid" "$RUN_DIR/$ROLE.tracked" </dev/null >/dev/null 2>&1 & tpid=$!
|
|
896
1032
|
fi
|
|
897
1033
|
|
|
1034
|
+
stop_feeder() {
|
|
1035
|
+
local fp n=0
|
|
1036
|
+
: > "$FEED_STOP" 2>/dev/null
|
|
1037
|
+
fp="$(cat "$FEED_PID" 2>/dev/null)"
|
|
1038
|
+
case "$fp" in ''|*[!0-9]*) fp="" ;; esac
|
|
1039
|
+
while [ -n "$fp" ] && kill -0 "$fp" 2>/dev/null && [ "$n" -lt 30 ]; do sleep 0.1; n=$((n + 1)); done
|
|
1040
|
+
[ -z "$fp" ] || kill -TERM "$fp" 2>/dev/null
|
|
1041
|
+
n="$(python3 "$SKILL_DIR/scripts/forge-control.py" _steer-close "$LIVE_PLAN" "$LIVE_TASK" 2>/dev/null)" || n=0
|
|
1042
|
+
case "$n" in ''|*[!0-9]*|0) ;; *) note "$n live message(s) arrived after the implementer's final result; they wait for the task's next attempt" ;; esac
|
|
1043
|
+
rm -f "$FEED_STOP" "$FEED_PID"
|
|
1044
|
+
}
|
|
1045
|
+
|
|
898
1046
|
# Ends the harness: the whole process group first when the harness has its own (GUARD_ON),
|
|
899
1047
|
# then children, then the process itself, then SIGKILL for a CLI that traps TERM and takes
|
|
900
1048
|
# its time. Without the guard there is no group to signal as a unit.
|
|
901
1049
|
stop_harness() {
|
|
902
|
-
[ "$GUARD_ON" != 1 ] ||
|
|
903
|
-
|
|
1050
|
+
[ "$GUARD_ON" != 1 ] || forge_kill_group "$hpid" TERM
|
|
1051
|
+
forge_kill_children "$hpid" TERM
|
|
904
1052
|
kill -TERM "$hpid" 2>/dev/null
|
|
905
1053
|
sleep 5
|
|
906
|
-
[ "$GUARD_ON" != 1 ] ||
|
|
907
|
-
|
|
1054
|
+
[ "$GUARD_ON" != 1 ] || forge_kill_group "$hpid" KILL
|
|
1055
|
+
forge_kill_children "$hpid" KILL
|
|
908
1056
|
kill -KILL "$hpid" 2>/dev/null
|
|
909
1057
|
}
|
|
910
1058
|
|
|
@@ -925,13 +1073,19 @@ if [ "${LIMIT:-0}" != "0" ]; then
|
|
|
925
1073
|
fi
|
|
926
1074
|
# A final result the CLI stays open after (#110): once the log ends in it and has been silent for
|
|
927
1075
|
# the grace, the harness is ended like a timeout, but the result stands (see below).
|
|
928
|
-
|
|
1076
|
+
# Live, its input stays open, so the CLI never exits by itself: with no background task open,
|
|
1077
|
+
# FORGE_LIVE_GRACE of silence after the result is enough.
|
|
1078
|
+
spid=""; LIVE_QUICK=""; [ "$LIVE" != 1 ] || LIVE_QUICK="$LIVE_GRACE"
|
|
1079
|
+
rm -f "$RUN_DIR/.$ROLE.settle"
|
|
929
1080
|
case "$HARNESS" in claude|openclaude)
|
|
930
|
-
if [ "$RESULT_GRACE" != 0 ]; then
|
|
1081
|
+
if [ "$RESULT_GRACE" != 0 ] || [ "$LIVE" = 1 ]; then
|
|
931
1082
|
(
|
|
932
|
-
|
|
1083
|
+
# Straight into the file, not through $(...): the settler stays this watcher's own child, so
|
|
1084
|
+
# the kill after `wait` below reaches it (a grandchild would outlive the dispatch, holding
|
|
1085
|
+
# whatever it inherited, such as a solo run's lock).
|
|
1086
|
+
python3 "$RUNTIME" settle "$LOG" "$RESULT_GRACE" "$hwinpid" ${LIVE_QUICK:+"$LIVE_QUICK"} </dev/null > "$RUN_DIR/.$ROLE.settle" || exit 0
|
|
933
1087
|
kill -0 "$hpid" 2>/dev/null || exit 0
|
|
934
|
-
|
|
1088
|
+
mv -f "$RUN_DIR/.$ROLE.settle" "$RUN_DIR/$ROLE.settled"
|
|
935
1089
|
stop_harness
|
|
936
1090
|
) >/dev/null 2>&1 &
|
|
937
1091
|
spid=$!
|
|
@@ -950,18 +1104,22 @@ fi
|
|
|
950
1104
|
for watcher in $wpid $spid; do
|
|
951
1105
|
# The watchdog is asleep in a child of its own, and so is the grace watcher; kill that
|
|
952
1106
|
# too or it outlives the run as an orphan holding the timer.
|
|
953
|
-
|
|
1107
|
+
forge_kill_children "$watcher" TERM
|
|
954
1108
|
kill "$watcher" 2>/dev/null
|
|
955
1109
|
wait "$watcher" 2>/dev/null
|
|
956
1110
|
done
|
|
1111
|
+
rm -f "$RUN_DIR/.$ROLE.settle"
|
|
957
1112
|
# Anything the harness left running in its group is an abandoned background job, and so is
|
|
958
1113
|
# anything the tracker saw it start that is still alive, in whatever session: a timeout stops
|
|
959
1114
|
# the harness, not the test servers its tools started (#129). Kill them before reading the
|
|
960
1115
|
# tree, and leave the list for the caller. Bounded (~6s) and advisory: a reaper failure
|
|
961
1116
|
# changes nothing about the exit code.
|
|
962
1117
|
if [ -n "$tpid" ]; then kill -TERM "$tpid" 2>/dev/null; wait "$tpid" 2>/dev/null; tpid=""; fi
|
|
1118
|
+
# The feeder is forge's, not the harness's: it is stopped (at most ~3s) before the reap below could
|
|
1119
|
+
# count it as an orphan, and what it left unsent goes back to the queue for the next attempt.
|
|
1120
|
+
[ "$LIVE" != 1 ] || stop_feeder
|
|
963
1121
|
if [ "$GUARD_ON" = 1 ]; then
|
|
964
|
-
orphans_found="$(python3 "$GUARD" reap "$
|
|
1122
|
+
orphans_found="$(python3 "$GUARD" reap "$hwinpid" "$RUN_DIR/$ROLE.orphans" --tracked "$RUN_DIR/$ROLE.tracked" 2>/dev/null)"
|
|
965
1123
|
case "$orphans_found" in ''|*[!0-9]*|0) ;; *) note "$HARNESS left $orphans_found process(es) running after it exited; killed — see $RUN_DIR/$ROLE.orphans" ;; esac
|
|
966
1124
|
fi
|
|
967
1125
|
reaped=1
|
|
@@ -985,12 +1143,14 @@ if [ -f "$RUN_DIR/$ROLE.settled" ] || [ -f "$RUN_DIR/$ROLE.timedout" ]; then
|
|
|
985
1143
|
case "$HARNESS" in claude|openclaude)
|
|
986
1144
|
if verdict="$(python3 "$RUNTIME" settled "$LOG" 2>/dev/null)"; then
|
|
987
1145
|
# The marker is written before the harness is stopped, so it says the grace came first.
|
|
988
|
-
if [
|
|
1146
|
+
if [ "$(cat "$RUN_DIR/$ROLE.settled" 2>/dev/null)" = quick ]; then after="${LIVE_GRACE}s of silence"; ended_by=live
|
|
1147
|
+
elif [ -f "$RUN_DIR/$ROLE.settled" ]; then after="${RESULT_GRACE}s of silence"; ended_by=grace
|
|
989
1148
|
else after="the ${LIMIT}s timeout"; ended_by=timeout; fi
|
|
990
1149
|
printf 'ended_by=%s\nbackend_exit=%s\n' "$ended_by" "$rc" > "$RUN_DIR/$ROLE.settled"
|
|
991
1150
|
rm -f "$RUN_DIR/$ROLE.timedout"
|
|
992
1151
|
if [ "$verdict" = error ]; then rc=1; else rc=0; fi
|
|
993
|
-
|
|
1152
|
+
# Live, that is how every implementer ends: its input stays open, so it never exits by itself.
|
|
1153
|
+
[ "$ended_by" = live ] || note "$HARNESS gave its final result, then stayed open on a background task; forge ended it after $after — the result stands"
|
|
994
1154
|
elif [ -f "$RUN_DIR/$ROLE.settled" ]; then
|
|
995
1155
|
rm -f "$RUN_DIR/$ROLE.settled"; : > "$RUN_DIR/$ROLE.timedout"
|
|
996
1156
|
note "$HARNESS began another turn while forge was ending it after its final result — see $LOG"
|
package/scripts/forge-du.py
CHANGED
|
@@ -11,18 +11,19 @@ every repository with `--all`:
|
|
|
11
11
|
worktrees each run's worktree folder (<repo>/../.forge-worktrees/<run id>); forge-ui's Worktrees
|
|
12
12
|
screen has the state of each one and the command that removes it safely
|
|
13
13
|
data home the dataset (kept: it is what forge learns from), its blobs, archives, exports, legacy
|
|
14
|
+
removed what a removed part of forge left behind: the state directory of Fractal (removed in 0.23),
|
|
15
|
+
with the command that deletes it. forge never deletes it for you
|
|
14
16
|
|
|
15
17
|
Sizes are disk usage, as `du` counts it (forge_storage.py has the rules). It reads only, and measuring a
|
|
16
18
|
large tree takes a while: every file is visited. The repository's total is kept for the storage.warn-gb
|
|
17
19
|
check at run start.
|
|
18
20
|
|
|
19
|
-
--json prints {repo, computed, complete, runs, strays, worktrees, data_home, totals, commands}.
|
|
21
|
+
--json prints {repo, computed, complete, runs, strays, worktrees, data_home, totals, removed, commands}.
|
|
20
22
|
"""
|
|
21
23
|
from __future__ import annotations
|
|
22
24
|
|
|
23
25
|
import argparse
|
|
24
26
|
import json
|
|
25
|
-
import os
|
|
26
27
|
from pathlib import Path
|
|
27
28
|
import shlex
|
|
28
29
|
import subprocess
|
|
@@ -62,6 +63,10 @@ def commands(result: dict) -> list[dict]:
|
|
|
62
63
|
if result['worktrees']:
|
|
63
64
|
out.append(dict(label='see each worktree\'s state and the command that removes it safely', command='forge ui open',
|
|
64
65
|
bytes=result['totals']['worktrees'], note='then open Worktrees'))
|
|
66
|
+
for left in result.get('removed') or []:
|
|
67
|
+
out.append(dict(label='delete what %s left behind (forge %s removed it; nothing reads this directory, and old '
|
|
68
|
+
'runs stay readable without it)' % (left['name'], left['since']),
|
|
69
|
+
command='rm -rf -- %s' % shlex.quote(left['path']), bytes=left['bytes']))
|
|
65
70
|
return out
|
|
66
71
|
|
|
67
72
|
|
|
@@ -95,7 +100,7 @@ def print_text(result: dict, top: int) -> None:
|
|
|
95
100
|
name = run['run_id'] if len(run['run_id']) <= 28 else run['run_id'][:27] + '…'
|
|
96
101
|
print(' %-28s %9s %10s %9s %9s %12s %12s %s' % (
|
|
97
102
|
name, size_text(run['total']), size_text(run['snapshots']), size_text(run['logs'] + run['gz']),
|
|
98
|
-
size_text(run['other']
|
|
103
|
+
size_text(run['other']), size_text(run['strays']) if run['strays'] else '-',
|
|
99
104
|
size_text(run['reclaimable']), age(run['updated'], now)))
|
|
100
105
|
print(' %s' % run['path'])
|
|
101
106
|
if result['strays']:
|
|
@@ -115,6 +120,8 @@ def print_text(result: dict, top: int) -> None:
|
|
|
115
120
|
'(forge dataset export writes them again); legacy %s; other %s'
|
|
116
121
|
% (size_text(p['dataset']), size_text(p['blobs']), size_text(p['archive']), size_text(p['exports']),
|
|
117
122
|
size_text(p['legacy']), size_text(p['storage'] + p['other'])))
|
|
123
|
+
for left in result.get('removed') or []:
|
|
124
|
+
print('\nleft by %s, which forge %s removed: %s in %s' % (left['name'], left['since'], size_text(left['bytes']), left['path']))
|
|
118
125
|
if result['commands']:
|
|
119
126
|
print('\nto take space back:')
|
|
120
127
|
for c in result['commands']:
|
|
@@ -158,6 +165,9 @@ def main(argv=None) -> int:
|
|
|
158
165
|
print('forge du: no registered runs for %s' % (repo or 'any repository'))
|
|
159
166
|
if result['data_home']:
|
|
160
167
|
print('data home %s: %s' % (result['data_home']['path'], size_text(result['data_home']['bytes'])))
|
|
168
|
+
for left in result['removed']:
|
|
169
|
+
print('left by %s, which forge %s removed: %s in %s\n to delete it: rm -rf -- %s'
|
|
170
|
+
% (left['name'], left['since'], size_text(left['bytes']), left['path'], shlex.quote(left['path'])))
|
|
161
171
|
return 0
|
|
162
172
|
print_text(result, args.top)
|
|
163
173
|
return 0
|