@giamme/forge 0.21.0 → 0.22.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 +20 -0
- package/README.md +6 -3
- package/VERSION +1 -1
- package/bin/forge.js +104 -0
- package/docs/development.md +1 -1
- package/docs/install.md +91 -2
- package/docs/reviews.md +6 -4
- package/docs/troubleshooting.md +1 -1
- package/forge +4 -0
- package/forge.cmd +56 -0
- package/package.json +5 -3
- package/scripts/forge-artifact.sh +5 -1
- package/scripts/forge-control.py +10 -3
- package/scripts/forge-dispatch.sh +108 -31
- package/scripts/forge-guard.py +137 -6
- package/scripts/forge-install.sh +82 -9
- package/scripts/forge-lib-env.sh +158 -0
- package/scripts/forge-lib-group.sh +5 -5
- package/scripts/forge-lib-plans.sh +8 -3
- package/scripts/forge-lib-task.sh +40 -15
- package/scripts/forge-memory.sh +2 -0
- package/scripts/forge-metrics.sh +6 -1
- package/scripts/forge-parallel.sh +156 -43
- package/scripts/forge-runtime.py +2 -2
- package/scripts/forge-schedule.py +18 -1
- package/scripts/forge-solo.sh +6 -2
- package/scripts/forge-sweep.py +1 -1
- package/scripts/forge-update.sh +6 -1
- package/scripts/forge-verify.py +1 -0
- 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_decide/budget.py +12 -7
- package/scripts/forge_decide/replay.py +9 -4
- package/scripts/forge_flock.py +17 -2
- package/scripts/forge_posix.py +17 -0
- package/scripts/forge_proc.py +108 -0
- package/scripts/forge_registry.py +2 -2
- package/scripts/forge_side/__init__.py +13 -4
- package/ui/forge_ui/control.py +7 -2
- package/ui/forge_ui/reader.py +6 -1
- package/ui/forge_ui/static/scene3d.js +23 -2
package/scripts/forge-install.sh
CHANGED
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
# forge-install.sh [--dry-run]
|
|
14
14
|
set -uo pipefail
|
|
15
15
|
|
|
16
|
-
SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
16
|
+
SKILL_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
17
|
+
source "$SKILL_DIR/scripts/forge-lib-env.sh"
|
|
18
|
+
forge_ensure_python3
|
|
17
19
|
RESULT=0
|
|
18
20
|
DRY=0
|
|
19
21
|
# `forge install --help` must never install; nor may a mistyped --dry-run.
|
|
@@ -28,16 +30,33 @@ say() { printf '%s\n' "$*"; }
|
|
|
28
30
|
do_() { if [ "$DRY" = 1 ]; then say " would: $*"; else "$@"; fi; }
|
|
29
31
|
|
|
30
32
|
link_dir() { # link_dir <target-parent> <label>
|
|
31
|
-
local parent="$1" label="$2" dest="$1/forge"
|
|
33
|
+
local parent="$1" label="$2" dest="$1/forge" target=""
|
|
32
34
|
if [ ! -d "$parent" ]; then say "$label: skipped ($parent does not exist)"; return; fi
|
|
33
35
|
if [ "$dest" = "$SKILL_DIR" ]; then say "$label: is the source directory"; return; fi
|
|
34
|
-
if [ -L "$dest" ]
|
|
35
|
-
|
|
36
|
+
if [ -L "$dest" ]; then
|
|
37
|
+
# Canonicalize physically so /tmp mounts, 8.3 short names, and relative symlinks match SKILL_DIR.
|
|
38
|
+
target="$(cd -P -- "$dest" 2>/dev/null && pwd -P || true)"
|
|
39
|
+
if [ -n "$target" ] && [ "$target" = "$SKILL_DIR" ]; then
|
|
40
|
+
say "$label: already linked"; return
|
|
41
|
+
fi
|
|
36
42
|
fi
|
|
37
43
|
if [ -e "$dest" ] && [ ! -L "$dest" ]; then
|
|
38
44
|
# Never clobber a real directory the user may have edited in place.
|
|
39
45
|
say "$label: SKIPPED — $dest exists and is not a symlink; move it aside first"; return 1
|
|
40
46
|
fi
|
|
47
|
+
if forge_is_windows; then
|
|
48
|
+
if [ "$DRY" = 1 ]; then
|
|
49
|
+
say " would: mklink /J $(forge_win_path "$dest") $(forge_win_path "$SKILL_DIR")"
|
|
50
|
+
say "$label: linked -> $dest"
|
|
51
|
+
return 0
|
|
52
|
+
fi
|
|
53
|
+
if forge_link_dir "$SKILL_DIR" "$dest"; then
|
|
54
|
+
say "$label: linked (junction) -> $dest"
|
|
55
|
+
else
|
|
56
|
+
cp -R "$SKILL_DIR" "$dest" && say "$label: copied -> $dest (re-run forge install after editing)"
|
|
57
|
+
fi
|
|
58
|
+
return $?
|
|
59
|
+
fi
|
|
41
60
|
do_ ln -sfn "$SKILL_DIR" "$dest" && say "$label: linked -> $dest"
|
|
42
61
|
}
|
|
43
62
|
|
|
@@ -51,6 +70,35 @@ report_opencode() {
|
|
|
51
70
|
say "opencode : auto-detected from ~/.claude/skills (no install needed)"
|
|
52
71
|
}
|
|
53
72
|
|
|
73
|
+
copy_skill_dir() { # copy_skill_dir <target-parent> <label> — real directory copy for scanners that ignore junctions
|
|
74
|
+
local parent="$1" label="$2" dest="$1/forge" item stage
|
|
75
|
+
if [ ! -d "$parent" ]; then say "$label: skipped ($parent does not exist)"; return; fi
|
|
76
|
+
if [ "$dest" = "$SKILL_DIR" ]; then say "$label: is the source directory"; return; fi
|
|
77
|
+
if [ "$DRY" = 1 ]; then
|
|
78
|
+
say " would: copy skill files to $dest"
|
|
79
|
+
say "$label: copied -> $dest (re-run forge install after editing)"
|
|
80
|
+
return 0
|
|
81
|
+
fi
|
|
82
|
+
if [ -L "$dest" ]; then
|
|
83
|
+
rmdir "$dest" 2>/dev/null || rm -f "$dest" 2>/dev/null || rm -rf "$dest"
|
|
84
|
+
elif [ -e "$dest" ] && [ ! -f "$dest/.forge-installed" ]; then
|
|
85
|
+
say "$label: SKIPPED — $dest exists and is not managed by forge; move it aside first"; return 1
|
|
86
|
+
fi
|
|
87
|
+
stage="$dest.tmp.$$"
|
|
88
|
+
rm -rf "$stage"
|
|
89
|
+
mkdir -p "$stage" || return 1
|
|
90
|
+
for item in SKILL.md VERSION LICENSE package.json forge forge.cmd bin scripts references ui; do
|
|
91
|
+
if [ -e "$SKILL_DIR/$item" ]; then
|
|
92
|
+
cp -R "$SKILL_DIR/$item" "$stage/$item" || { rm -rf "$stage"; return 1; }
|
|
93
|
+
fi
|
|
94
|
+
done
|
|
95
|
+
find "$stage" -type d -name '__pycache__' -exec rm -rf {} + 2>/dev/null || true
|
|
96
|
+
: > "$stage/.forge-installed"
|
|
97
|
+
rm -rf "$dest"
|
|
98
|
+
mv "$stage" "$dest" || { rm -rf "$stage"; return 1; }
|
|
99
|
+
say "$label: copied -> $dest (re-run forge install after editing)"
|
|
100
|
+
}
|
|
101
|
+
|
|
54
102
|
# Antigravity loads skills only as part of a plugin — a loose directory under
|
|
55
103
|
# ~/.gemini/skills is ignored (agy cannot see skills placed there at all). So forge
|
|
56
104
|
# is wrapped in a minimal plugin whose skills/ entry points back at this directory.
|
|
@@ -60,14 +108,30 @@ report_opencode() {
|
|
|
60
108
|
# not track edits to this directory automatically: re-run this installer after
|
|
61
109
|
# changing the skill, or agy keeps running the version it copied.
|
|
62
110
|
install_antigravity() {
|
|
63
|
-
local label="antigravity"
|
|
64
|
-
if !
|
|
111
|
+
local label="antigravity" gemini_home="$HOME/.gemini" wrapper agy_skills has_agy=0 rc=0
|
|
112
|
+
if forge_is_windows && [ ! -d "$gemini_home" ] && [ -n "${USERPROFILE:-}" ]; then
|
|
113
|
+
gemini_home="$(forge_posix_path "$USERPROFILE")/.gemini"
|
|
114
|
+
fi
|
|
115
|
+
wrapper="$gemini_home/forge-plugin"
|
|
116
|
+
agy_skills="$gemini_home/config/skills"
|
|
117
|
+
if command -v agy >/dev/null 2>&1; then
|
|
118
|
+
has_agy=1
|
|
119
|
+
fi
|
|
120
|
+
if forge_is_windows && [ -d "$agy_skills" ]; then
|
|
121
|
+
# Windows only. Electron/Node scanners check dirent.isDirectory(), which is false for Windows
|
|
122
|
+
# junctions, and Antigravity loads skills directly from ~/.gemini/config/skills without
|
|
123
|
+
# `agy plugin install` (which hits Access is denied on Windows while Antigravity.exe watches
|
|
124
|
+
# ~/.gemini/config/plugins). macOS and Linux keep the plugin below.
|
|
125
|
+
copy_skill_dir "$agy_skills" "antigravity" || rc=1
|
|
126
|
+
return "$rc"
|
|
127
|
+
fi
|
|
128
|
+
if [ "$has_agy" = 0 ]; then
|
|
65
129
|
say "$label: skipped (agy not on PATH)"; return
|
|
66
130
|
fi
|
|
67
131
|
if [ "$DRY" = 1 ]; then
|
|
68
132
|
say " would: write plugin wrapper $wrapper"
|
|
69
133
|
say " would: agy plugin install $wrapper"
|
|
70
|
-
say "$label: plugin -> $wrapper"; return
|
|
134
|
+
say "$label: plugin -> $wrapper"; return "$rc"
|
|
71
135
|
fi
|
|
72
136
|
mkdir -p "$wrapper/skills" || return 1
|
|
73
137
|
cat > "$wrapper/plugin.json" <<EOF
|
|
@@ -79,13 +143,22 @@ install_antigravity() {
|
|
|
79
143
|
}
|
|
80
144
|
EOF
|
|
81
145
|
[ "$?" = 0 ] || return 1
|
|
82
|
-
|
|
83
|
-
if
|
|
146
|
+
local agy_wrapper
|
|
147
|
+
if forge_is_windows; then
|
|
148
|
+
# `agy plugin install` on Windows rejects junctions/symlinks inside the plugin bundle.
|
|
149
|
+
copy_skill_dir "$wrapper/skills" "antigravity" >/dev/null || return 1
|
|
150
|
+
agy_wrapper="$(forge_win_path "$wrapper")"
|
|
151
|
+
else
|
|
152
|
+
forge_link_dir "$SKILL_DIR" "$wrapper/skills/forge" || return 1
|
|
153
|
+
agy_wrapper="$wrapper"
|
|
154
|
+
fi
|
|
155
|
+
if agy plugin install "$agy_wrapper"; then
|
|
84
156
|
say "$label: plugin installed (copied — re-run this script after editing the skill)"
|
|
85
157
|
else
|
|
86
158
|
say "$label: FAILED — try: agy plugin install $wrapper"
|
|
87
159
|
return 1
|
|
88
160
|
fi
|
|
161
|
+
return "$rc"
|
|
89
162
|
}
|
|
90
163
|
|
|
91
164
|
say "forge source: $SKILL_DIR"
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Shared environment helpers for cross-platform shell entrypoints.
|
|
3
|
+
#
|
|
4
|
+
# On Windows (Git Bash / MSYS2), `python3` on PATH is often the Microsoft Store
|
|
5
|
+
# execution alias in WindowsApps while a real Python 3.9+ lives at `python` or
|
|
6
|
+
# `py -3`. Prepending a small per-user wrapper directory to PATH fixes every
|
|
7
|
+
# downstream `python3` call (in bash scripts and Windows subprocesses) with zero
|
|
8
|
+
# overhead or external commands on macOS/Linux.
|
|
9
|
+
|
|
10
|
+
forge_is_windows() {
|
|
11
|
+
case "${OSTYPE:-}" in
|
|
12
|
+
msys*|cygwin*) [ "${FORGE_WIN_MODE:-native}" != msys2 ] ;; # MSYS2 mode (#164) runs forge as on POSIX
|
|
13
|
+
*) return 1 ;;
|
|
14
|
+
esac
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
forge_posix_path() {
|
|
18
|
+
local p="${1:-}"
|
|
19
|
+
p="${p%$'\r'}"
|
|
20
|
+
if [ -n "$p" ] && forge_is_windows && command -v cygpath >/dev/null 2>&1; then
|
|
21
|
+
cygpath -u "$p" 2>/dev/null || printf '%s\n' "$p"
|
|
22
|
+
else
|
|
23
|
+
printf '%s\n' "$p"
|
|
24
|
+
fi
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
forge_win_path() {
|
|
28
|
+
local p="${1:-}"
|
|
29
|
+
p="${p%$'\r'}"
|
|
30
|
+
if [ -n "$p" ] && forge_is_windows && command -v cygpath >/dev/null 2>&1; then
|
|
31
|
+
cygpath -w "$p" 2>/dev/null || printf '%s\n' "$p"
|
|
32
|
+
else
|
|
33
|
+
printf '%s\n' "$p"
|
|
34
|
+
fi
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
forge_host_path() {
|
|
38
|
+
local p="${1:-}"
|
|
39
|
+
p="${p%$'\r'}"
|
|
40
|
+
if [ -n "$p" ] && forge_is_windows && command -v cygpath >/dev/null 2>&1; then
|
|
41
|
+
cygpath -m "$p" 2>/dev/null || printf '%s\n' "$p"
|
|
42
|
+
else
|
|
43
|
+
printf '%s\n' "$p"
|
|
44
|
+
fi
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
forge_ensure_python3() {
|
|
48
|
+
forge_is_windows || return 0
|
|
49
|
+
|
|
50
|
+
local current exe win_exe cand base shim_dir shim cmd_shim expected cmd_expected
|
|
51
|
+
current="$(command -v python3 2>/dev/null || true)"
|
|
52
|
+
case "$current" in
|
|
53
|
+
'') ;;
|
|
54
|
+
*[Ww]indows[Aa]pps*) ;;
|
|
55
|
+
*/forge/bin/python3) ;;
|
|
56
|
+
*) return 0 ;;
|
|
57
|
+
esac
|
|
58
|
+
|
|
59
|
+
exe=""
|
|
60
|
+
for cand in python python3; do
|
|
61
|
+
command -v "$cand" >/dev/null 2>&1 || continue
|
|
62
|
+
case "$(command -v "$cand" 2>/dev/null || true)" in
|
|
63
|
+
*[Ww]indows[Aa]pps*) continue ;;
|
|
64
|
+
esac
|
|
65
|
+
exe="$("$cand" -c 'import sys; print(sys.executable if sys.version_info >= (3, 9) else "")' 2>/dev/null || true)"
|
|
66
|
+
[ -n "$exe" ] && break
|
|
67
|
+
done
|
|
68
|
+
if [ -z "$exe" ] && command -v py >/dev/null 2>&1; then
|
|
69
|
+
exe="$(py -3 -c 'import sys; print(sys.executable if sys.version_info >= (3, 9) else "")' 2>/dev/null || true)"
|
|
70
|
+
fi
|
|
71
|
+
[ -n "$exe" ] || return 0
|
|
72
|
+
|
|
73
|
+
exe="${exe%$'\r'}"
|
|
74
|
+
win_exe="$exe"
|
|
75
|
+
if command -v cygpath >/dev/null 2>&1; then
|
|
76
|
+
win_exe="$(cygpath -w "$exe" 2>/dev/null || printf '%s' "$exe")"
|
|
77
|
+
exe="$(cygpath -u "$exe" 2>/dev/null || printf '%s' "$exe")"
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
base="${LOCALAPPDATA:-${XDG_STATE_HOME:-${HOME:-}/.local/state}}"
|
|
81
|
+
[ -n "$base" ] || return 0
|
|
82
|
+
base="$(forge_posix_path "$base")"
|
|
83
|
+
shim_dir="$base/forge/bin"
|
|
84
|
+
( umask 077 && mkdir -p "$shim_dir" ) 2>/dev/null || return 0
|
|
85
|
+
|
|
86
|
+
shim="$shim_dir/python3"
|
|
87
|
+
printf -v expected '#!/usr/bin/env bash\nexec %q "$@"\n' "$exe"
|
|
88
|
+
if [ ! -x "$shim" ] || [ "$(cat "$shim" 2>/dev/null)" != "${expected%$'\n'}" ]; then
|
|
89
|
+
printf '%s' "$expected" > "$shim" 2>/dev/null || return 0
|
|
90
|
+
chmod +x "$shim" 2>/dev/null || true
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
cmd_shim="$shim_dir/python3.cmd"
|
|
94
|
+
printf -v cmd_expected '@echo off\r\n"%s" %%*\r\n' "$win_exe"
|
|
95
|
+
if [ ! -f "$cmd_shim" ] || [ "$(cat "$cmd_shim" 2>/dev/null)" != "${cmd_expected%$'\n'}" ]; then
|
|
96
|
+
printf '%s' "$cmd_expected" > "$cmd_shim" 2>/dev/null || true
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
case ":$PATH:" in
|
|
100
|
+
*":$shim_dir:"*) ;;
|
|
101
|
+
*) export PATH="$shim_dir:$PATH" ;;
|
|
102
|
+
esac
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_FORGE_ENV_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
106
|
+
|
|
107
|
+
forge_winpid() {
|
|
108
|
+
local pid="${1:-}" win=""
|
|
109
|
+
[ -n "$pid" ] || return 0
|
|
110
|
+
# Under MSYS2 mode /proc/<pid>/winpid exists too, but forge works with Cygwin pids there.
|
|
111
|
+
if forge_is_windows && [ -r "/proc/$pid/winpid" ]; then
|
|
112
|
+
read -r win 2>/dev/null < "/proc/$pid/winpid" || win=""
|
|
113
|
+
win="${win%$'\r'}"
|
|
114
|
+
fi
|
|
115
|
+
printf '%s\n' "${win:-$pid}"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
forge_kill_children() {
|
|
119
|
+
local pid="${1:-}" sig="${2:-TERM}" cpid winpid
|
|
120
|
+
[ -n "$pid" ] || return 0
|
|
121
|
+
if command -v pkill >/dev/null 2>&1; then
|
|
122
|
+
pkill "-$sig" -P "$pid" 2>/dev/null || true
|
|
123
|
+
return 0
|
|
124
|
+
fi
|
|
125
|
+
# Git Bash / MSYS2 has no pkill: signal MSYS children via ps -ef and native children via forge-guard.py.
|
|
126
|
+
if [ -r "/proc/$pid/winpid" ]; then
|
|
127
|
+
while read -r cpid; do
|
|
128
|
+
[ -n "$cpid" ] && kill "-$sig" "$cpid" 2>/dev/null || true
|
|
129
|
+
done < <(ps -ef 2>/dev/null | awk -v p="$pid" '$3 == p { print $2 }')
|
|
130
|
+
winpid="$(forge_winpid "$pid")"
|
|
131
|
+
if [ -r "$_FORGE_ENV_DIR/forge-guard.py" ] && [ -n "$winpid" ]; then
|
|
132
|
+
python3 "$_FORGE_ENV_DIR/forge-guard.py" kill-children "$winpid" "$sig" 2>/dev/null || true
|
|
133
|
+
fi
|
|
134
|
+
fi
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
forge_kill_group() {
|
|
138
|
+
local pid="${1:-}" sig="${2:-TERM}"
|
|
139
|
+
[ -n "$pid" ] || return 0
|
|
140
|
+
kill -s "$sig" -- "-$pid" 2>/dev/null || true
|
|
141
|
+
if forge_is_windows && [ -r "/proc/$pid/winpid" ]; then
|
|
142
|
+
forge_kill_children "$pid" "$sig"
|
|
143
|
+
fi
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
# Create a live directory link (<src> -> <dest>). Uses NTFS directory junctions on Windows
|
|
147
|
+
# (no admin/Developer Mode required; unlike MSYS `ln -sfn`, edits remain live and `-L` works).
|
|
148
|
+
forge_link_dir() {
|
|
149
|
+
local src="${1:-}" dest="${2:-}"
|
|
150
|
+
if forge_is_windows; then
|
|
151
|
+
if [ -L "$dest" ]; then
|
|
152
|
+
rmdir "$dest" 2>/dev/null || rm -f "$dest" 2>/dev/null || true
|
|
153
|
+
fi
|
|
154
|
+
MSYS_NO_PATHCONV=1 cmd /c mklink /J "$(forge_win_path "$dest")" "$(forge_win_path "$src")" >/dev/null 2>&1
|
|
155
|
+
return $?
|
|
156
|
+
fi
|
|
157
|
+
ln -sfn "$src" "$dest"
|
|
158
|
+
}
|
|
@@ -75,7 +75,7 @@ do_group() (
|
|
|
75
75
|
# 1. Status and round.
|
|
76
76
|
mkdir -p "$G" || die "could not create $G" 3
|
|
77
77
|
local round REPO run_id wt_root
|
|
78
|
-
round="$(tr -dc '0-9' < "$G/round"
|
|
78
|
+
round="$(tr -dc '0-9' 2>/dev/null < "$G/round")"
|
|
79
79
|
round=$(( ${round:-0} + 1 ))
|
|
80
80
|
printf '%s\n' "$round" > "$G/round.tmp" && mv -f "$G/round.tmp" "$G/round"
|
|
81
81
|
# What an earlier round left that this one would otherwise be read as. attribution.json and
|
|
@@ -400,7 +400,7 @@ do_group_settle() (
|
|
|
400
400
|
done
|
|
401
401
|
for id in "${ids[@]}"; do case ",${named// /}," in *",$id,"*) want+=("$id") ;; esac; done
|
|
402
402
|
fi
|
|
403
|
-
round="$(tr -dc '0-9' < "$G/round"
|
|
403
|
+
round="$(tr -dc '0-9' 2>/dev/null < "$G/round")"
|
|
404
404
|
[ -n "$round" ] || die "group $gid has not been reviewed" 2
|
|
405
405
|
# One settle per round, however often it is asked.
|
|
406
406
|
[ "$(cat "$G/settled.round" 2>/dev/null)" = "$round" ] && return 0
|
|
@@ -532,7 +532,7 @@ merge_group() { # merge_group <plan> <gid> -> 0 merged, 1 not
|
|
|
532
532
|
if [ "$st" != PASS ]; then note "group $gid: ${st:-not reviewed}, not PASS — nothing to merge"; return 1; fi
|
|
533
533
|
REPO="$(cat "$PLAN/repo")"; run_id="$(cat "$PLAN/run_id")"
|
|
534
534
|
int_wt="$(cat "$PLAN/wt_root")/_integration"
|
|
535
|
-
round="$(tr -dc '0-9' < "$G/round"
|
|
535
|
+
round="$(tr -dc '0-9' 2>/dev/null < "$G/round")"
|
|
536
536
|
local ids=()
|
|
537
537
|
IFS=, read -ra ids <<< "$members"
|
|
538
538
|
|
|
@@ -607,8 +607,8 @@ merge_group() { # merge_group <plan> <gid> -> 0 merged, 1 not
|
|
|
607
607
|
for id in "${ids[@]}"; do rm -f "$PLAN/tasks/$id/.qa.last.merge.tmp"; echo CONFLICT > "$PLAN/tasks/$id/status"; done
|
|
608
608
|
group_set_status "$G" CONFLICT
|
|
609
609
|
forge_dataset_event group_merge --dir "$PLAN" --set group="$gid" --set status=CONFLICT --set commit="$commit" \
|
|
610
|
-
--set conflicts="$(tr '\n' ' ' < "$G/conflict.files"
|
|
611
|
-
note "group $gid: conflicts with the integration branch: $(tr '\n' ' ' < "$G/conflict.files"
|
|
610
|
+
--set conflicts="$(tr '\n' ' ' 2>/dev/null < "$G/conflict.files")"
|
|
611
|
+
note "group $gid: conflicts with the integration branch: $(tr '\n' ' ' 2>/dev/null < "$G/conflict.files")"
|
|
612
612
|
return 1
|
|
613
613
|
fi
|
|
614
614
|
git -C "$int_wt" rev-parse HEAD > "$PLAN/accepted.integration"
|
|
@@ -596,7 +596,7 @@ do_accept() {
|
|
|
596
596
|
write_results "$PLAN"
|
|
597
597
|
die "task '$id' could not be merged (status now $(task_status "$PLAN" "$id")); nothing was accepted. See 'git -C $int_wt status' and the task branch $br" 6
|
|
598
598
|
fi
|
|
599
|
-
rm -f "$kibak"
|
|
599
|
+
rm -f "$kibak" "$tdir/decision.md" "$tdir/decision.from"
|
|
600
600
|
record_attempt "$PLAN" "$id"
|
|
601
601
|
write_results "$PLAN"
|
|
602
602
|
echo "$id accepted by a human and merged"
|
|
@@ -613,8 +613,13 @@ do_accept() {
|
|
|
613
613
|
# very integration branch being merged). The lock is taken by re-exec, like the router's
|
|
614
614
|
# own lock for run/retry/integrate, so the file descriptors stay open for bash.
|
|
615
615
|
PLANS_LOCK_PY='
|
|
616
|
-
import
|
|
616
|
+
import os, sys
|
|
617
617
|
script, count = sys.argv[1], int(sys.argv[2])
|
|
618
|
+
_scripts = os.path.dirname(os.path.abspath(script))
|
|
619
|
+
if _scripts not in sys.path:
|
|
620
|
+
sys.path.insert(0, _scripts)
|
|
621
|
+
import forge_flock as fcntl
|
|
622
|
+
import forge_proc
|
|
618
623
|
held = []
|
|
619
624
|
for path in sys.argv[3:3 + count]:
|
|
620
625
|
try:
|
|
@@ -627,7 +632,7 @@ for path in sys.argv[3:3 + count]:
|
|
|
627
632
|
os.set_inheritable(handle.fileno(), True)
|
|
628
633
|
held.append(handle)
|
|
629
634
|
env = dict(os.environ, FORGE_COMBINE_LOCKED="1")
|
|
630
|
-
|
|
635
|
+
forge_proc.exec_or_exit(forge_proc.bash_cmd(script, "combine", *sys.argv[3 + count:]), env=env, inherit_fds=True)
|
|
631
636
|
'
|
|
632
637
|
|
|
633
638
|
plans_predict_conflict() { # 0 merges cleanly, 1 would conflict, 2 cannot tell (old git)
|
|
@@ -741,6 +741,8 @@ PYEOF
|
|
|
741
741
|
esac
|
|
742
742
|
echo " lower the threshold: forge-parallel.sh retry $PLAN $id --decide threshold=P1 --reason \"...\" --approved"
|
|
743
743
|
echo " (this task's blocking threshold, then one retry)"
|
|
744
|
+
echo " clarify the brief: edit tasks/$id/prompt.md (or approach.md), then retry with --decide retry=1"
|
|
745
|
+
echo " (--reason \"...\" --approved; unchanged code is re-reviewed against the new brief)"
|
|
744
746
|
echo " a named model: forge-parallel.sh retry $PLAN $id --dwarf <spec> --reason \"...\" --approved"
|
|
745
747
|
echo " (one attempt; with --decide retry=N, up to N attempts held on that model)"
|
|
746
748
|
case "$from" in FAIL|UNKNOWN) # with no reviewer verdict, accept has nothing to override
|
|
@@ -782,7 +784,14 @@ decision_after_attempt() { # decision_after_attempt <plan> <id> <stop-before> <c
|
|
|
782
784
|
retry_decision_gate() { # retry_decision_gate <plan> <id> <status> <decide> <dwarf> <reason> <approved 0|1>
|
|
783
785
|
local PLAN="$1" id="$2" st="$3" decide="$4" dwarf="$5" reason="$6" approved="$7" n
|
|
784
786
|
if [ "$st" != NEEDS_DECISION ]; then
|
|
785
|
-
[ -
|
|
787
|
+
if [ -n "$decide" ]; then
|
|
788
|
+
case "$st" in
|
|
789
|
+
FAIL|UNKNOWN|ERROR|TIMEOUT|INTERRUPTED|INVALIDATED|CONFLICT)
|
|
790
|
+
die "retry: '$id' is $st, not waiting for a decision; --decide only decides a NEEDS_DECISION task (run without --decide: forge-parallel.sh retry $PLAN $id)" ;;
|
|
791
|
+
*)
|
|
792
|
+
die "retry: '$id' is $st, not waiting for a decision; --decide only decides a NEEDS_DECISION task" ;;
|
|
793
|
+
esac
|
|
794
|
+
fi
|
|
786
795
|
return 0
|
|
787
796
|
fi
|
|
788
797
|
if [ -z "$decide" ] && [ -z "$dwarf" ]; then
|
|
@@ -996,7 +1005,7 @@ prepare_retry() { # prepare_retry <plan> <id> [new-dwarf [decided]]
|
|
|
996
1005
|
if [ -n "$next" ]; then
|
|
997
1006
|
# retry_per_model replaces escalate_after (forge-route.py escalation). The note names the
|
|
998
1007
|
# count that moved the task, and does not point at a flag that no longer governs the plan.
|
|
999
|
-
per_model="$(tr -d '[:space:]' < "$PLAN/retry_per_model"
|
|
1008
|
+
per_model="$(tr -d '[:space:]' 2>/dev/null < "$PLAN/retry_per_model" || true)"
|
|
1000
1009
|
case "$per_model" in
|
|
1001
1010
|
[1-9]|[1-9][0-9]) ;;
|
|
1002
1011
|
*) per_model="" ;;
|
|
@@ -1017,7 +1026,7 @@ prepare_retry() { # prepare_retry <plan> <id> [new-dwarf [decided]]
|
|
|
1017
1026
|
write_escalation "$PLAN" "$id" "$cur" "$newdwarf" "$esc_source" || { rm -f "$tdir/retry_findings.next"; return 1; }
|
|
1018
1027
|
fi
|
|
1019
1028
|
[ "$st" != NEEDS_INPUT ] || commit_answer_findings "$tdir" || return 1
|
|
1020
|
-
rm -f "$tdir/noretry"
|
|
1029
|
+
rm -f "$tdir/noretry" "$tdir/decision.md" "$tdir/decision.from"
|
|
1021
1030
|
}
|
|
1022
1031
|
|
|
1023
1032
|
# Puts the next implementer in place: tasks.tsv, the escalations.tsv record and the dataset
|
|
@@ -1347,6 +1356,18 @@ qa_gate() { # qa_gate <plan> <id> <tdir> <verdict> [threshold]
|
|
|
1347
1356
|
}
|
|
1348
1357
|
|
|
1349
1358
|
# --- report blocks ----------------------------------------------------------------
|
|
1359
|
+
# The id column is as wide as the plan's longest task id, and never narrower than 14. Here and
|
|
1360
|
+
# not in forge-parallel.sh, which uses it too, because this file is also sourced on its own.
|
|
1361
|
+
id_col_width() { # id_col_width <tsv...> -> longest col-1 task id length across readable TSVs, at least 14
|
|
1362
|
+
local w=14 f n=0
|
|
1363
|
+
for f in "$@"; do
|
|
1364
|
+
[ -r "$f" ] || continue
|
|
1365
|
+
n="$(awk -F'\t' '!/^#/ && NF { if (length($1) > m) m = length($1) } END { print m + 0 }' "$f" 2>/dev/null)" || n=0
|
|
1366
|
+
[ "$n" -gt "$w" ] && w="$n"
|
|
1367
|
+
done
|
|
1368
|
+
echo "$w"
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1350
1371
|
# The wording of each line, and what the causes need, is forge_infra.py's; this block only lays them out.
|
|
1351
1372
|
# A lateral move is news whether or not a task is still paused, so its lines come out either way.
|
|
1352
1373
|
report_infra() { # report_infra <plan>
|
|
@@ -1381,7 +1402,8 @@ report_infra() { # report_infra <plan>
|
|
|
1381
1402
|
}
|
|
1382
1403
|
|
|
1383
1404
|
report_known_issues() { # report_known_issues <plan>
|
|
1384
|
-
local plan="$1" id n=0
|
|
1405
|
+
local plan="$1" id n=0 id_w
|
|
1406
|
+
id_w="$(id_col_width "$plan/tasks.tsv")"
|
|
1385
1407
|
for id in $(all_ids "$plan/tasks.tsv"); do
|
|
1386
1408
|
[ -s "$plan/tasks/$id/known_issues.md" ] || continue
|
|
1387
1409
|
# A FAIL task's tolerated findings are on disk too (the gate writes them whatever its
|
|
@@ -1389,7 +1411,7 @@ report_known_issues() { # report_known_issues <plan>
|
|
|
1389
1411
|
case "$(task_status "$plan" "$id")" in PASS|MERGED) ;; *) continue ;; esac
|
|
1390
1412
|
[ "$n" = 0 ] && echo "known issues accepted (findings below the QA threshold, or accepted by a human):"
|
|
1391
1413
|
n=$((n+1))
|
|
1392
|
-
printf '
|
|
1414
|
+
printf ' %-*s %s finding(s) %s\n' "$id_w" "$id" "$(grep -c '^- ' "$plan/tasks/$id/known_issues.md" 2>/dev/null || echo 0)" "$plan/tasks/$id/known_issues.md"
|
|
1393
1415
|
done
|
|
1394
1416
|
# What an adopted range kept: findings below the threshold, or a verdict --approved overrode.
|
|
1395
1417
|
local dir
|
|
@@ -1397,7 +1419,7 @@ report_known_issues() { # report_known_issues <plan>
|
|
|
1397
1419
|
[ -s "$plan/$dir/known_issues.md" ] || continue
|
|
1398
1420
|
[ "$n" = 0 ] && echo "known issues accepted (findings below the QA threshold, or accepted by a person):"
|
|
1399
1421
|
n=$((n+1))
|
|
1400
|
-
printf '
|
|
1422
|
+
printf ' %-*s %s finding(s) %s\n' "$id_w" adopted "$(grep -c '^- ' "$plan/$dir/known_issues.md" 2>/dev/null)" "$plan/$dir/known_issues.md"
|
|
1401
1423
|
done
|
|
1402
1424
|
[ "$n" -gt 0 ] && echo
|
|
1403
1425
|
return 0
|
|
@@ -1406,14 +1428,15 @@ report_known_issues() { # report_known_issues <plan>
|
|
|
1406
1428
|
# The PASS verdicts forge turned into FAIL, since FORGE_RUN_STARTED (set by run and retry;
|
|
1407
1429
|
# unset shows them all), including those whose task a later attempt fixed.
|
|
1408
1430
|
report_gate_flips() { # report_gate_flips <plan>
|
|
1409
|
-
local plan="$1" id n=0 at attempt thr worst
|
|
1431
|
+
local plan="$1" id n=0 at attempt thr worst id_w
|
|
1432
|
+
id_w="$(id_col_width "$plan/tasks.tsv")"
|
|
1410
1433
|
for id in $(all_ids "$plan/tasks.tsv"); do
|
|
1411
1434
|
[ -s "$plan/tasks/$id/qa.flips" ] || continue
|
|
1412
1435
|
while IFS="$(printf '\t')" read -r at attempt thr worst; do
|
|
1413
1436
|
awk -v at="${at:-0}" -v since="${FORGE_RUN_STARTED:-0}" 'BEGIN { exit !(at + 0 >= since + 0) }' || continue
|
|
1414
1437
|
[ "$n" = 0 ] && echo "forge overrode the reviewer's verdict (PASS, but it listed a CONFIRMED finding at or above the threshold):"
|
|
1415
1438
|
n=$((n+1))
|
|
1416
|
-
printf '
|
|
1439
|
+
printf ' %-*s attempt %s: PASS -> FAIL at the %s threshold (worst %s)\n' "$id_w" "$id" "$attempt" "$thr" "$worst"
|
|
1417
1440
|
done < "$plan/tasks/$id/qa.flips"
|
|
1418
1441
|
done
|
|
1419
1442
|
[ "$n" -gt 0 ] && echo
|
|
@@ -1421,12 +1444,13 @@ report_gate_flips() { # report_gate_flips <plan>
|
|
|
1421
1444
|
}
|
|
1422
1445
|
|
|
1423
1446
|
report_guard_notes() { # report_guard_notes <plan>
|
|
1424
|
-
local plan="$1" id n=0 line
|
|
1447
|
+
local plan="$1" id n=0 line id_w
|
|
1448
|
+
id_w="$(id_col_width "$plan/tasks.tsv")"
|
|
1425
1449
|
for id in $(all_ids "$plan/tasks.tsv"); do
|
|
1426
1450
|
[ -s "$plan/tasks/$id/guard.txt" ] || continue
|
|
1427
1451
|
[ "$n" = 0 ] && echo "implementer guard notes (observed by forge, not self-reported):"
|
|
1428
1452
|
n=$((n+1))
|
|
1429
|
-
while IFS= read -r line; do printf '
|
|
1453
|
+
while IFS= read -r line; do printf ' %-*s %s\n' "$id_w" "$id" "$line"; done < "$plan/tasks/$id/guard.txt"
|
|
1430
1454
|
done
|
|
1431
1455
|
[ "$n" -gt 0 ] && echo
|
|
1432
1456
|
return 0
|
|
@@ -1480,7 +1504,8 @@ report_size() { # report_size <plan>
|
|
|
1480
1504
|
# withdrawn since the last attempt leaves the `escalation.next` that `--check` wrote for it,
|
|
1481
1505
|
# so a marker found with no pin pending is decided again rather than trusted.
|
|
1482
1506
|
report_escalations() { # report_escalations <plan>
|
|
1483
|
-
local plan="$1" id n=0 head pin
|
|
1507
|
+
local plan="$1" id n=0 head pin id_w
|
|
1508
|
+
id_w="$(id_col_width "$plan/tasks.tsv")"
|
|
1484
1509
|
head="retry policy (after $(cat "$plan/escalate_after" 2>/dev/null || echo 3) failed attempts on one model):"
|
|
1485
1510
|
for id in $(all_ids "$plan/tasks.tsv"); do
|
|
1486
1511
|
pin="$(pin_spec "$plan/tasks/$id/escalation.pin")"
|
|
@@ -1489,9 +1514,9 @@ report_escalations() { # report_escalations <plan>
|
|
|
1489
1514
|
[ "$n" = 0 ] && echo "$head"
|
|
1490
1515
|
n=$((n+1))
|
|
1491
1516
|
if qa_only_next "$plan" "$id"; then
|
|
1492
|
-
printf '
|
|
1517
|
+
printf ' %-*s its next retry goes to %s (pinned; after the QA-only re-run)\n' "$id_w" "$id" "$pin"
|
|
1493
1518
|
else
|
|
1494
|
-
printf '
|
|
1519
|
+
printf ' %-*s its next retry goes to %s (pinned)\n' "$id_w" "$id" "$pin"
|
|
1495
1520
|
fi
|
|
1496
1521
|
continue
|
|
1497
1522
|
fi
|
|
@@ -1501,10 +1526,10 @@ report_escalations() { # report_escalations <plan>
|
|
|
1501
1526
|
fi
|
|
1502
1527
|
if [ -s "$plan/tasks/$id/split.suggested" ]; then
|
|
1503
1528
|
[ "$n" = 0 ] && echo "$head"
|
|
1504
|
-
n=$((n+1)); printf '
|
|
1529
|
+
n=$((n+1)); printf ' %-*s split suggested: %s\n' "$id_w" "$id" "$(cat "$plan/tasks/$id/split.suggested")"
|
|
1505
1530
|
elif [ -s "$plan/tasks/$id/escalation.next" ] && [ "$(task_status "$plan" "$id")" != MERGED ]; then
|
|
1506
1531
|
[ "$n" = 0 ] && echo "$head"
|
|
1507
|
-
n=$((n+1)); printf '
|
|
1532
|
+
n=$((n+1)); printf ' %-*s its next retry goes to %s\n' "$id_w" "$id" "$(cat "$plan/tasks/$id/escalation.next")"
|
|
1508
1533
|
fi
|
|
1509
1534
|
done
|
|
1510
1535
|
[ "$n" -gt 0 ] && echo
|
package/scripts/forge-memory.sh
CHANGED
|
@@ -49,6 +49,8 @@ TAB="$(printf '\t')"
|
|
|
49
49
|
# export it, and this script is also run directly. Getting it wrong would leave the Jev
|
|
50
50
|
# curation below silently disabled instead of visibly broken.
|
|
51
51
|
SKILL_DIR="${SKILL_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
|
|
52
|
+
source "$SKILL_DIR/scripts/forge-lib-env.sh"
|
|
53
|
+
forge_ensure_python3
|
|
52
54
|
|
|
53
55
|
# Writing files into someone's repo automatically needs an escape hatch that does
|
|
54
56
|
# not require editing the skill.
|
package/scripts/forge-metrics.sh
CHANGED
|
@@ -53,7 +53,12 @@ forge_outcomes_harvest() { # forge_outcomes_harvest <plan dir>
|
|
|
53
53
|
( sleep $(( limit + 10 )); kill -KILL "$pid" 2>/dev/null ) >/dev/null 2>&1 &
|
|
54
54
|
watcher=$!
|
|
55
55
|
wait "$pid" 2>/dev/null
|
|
56
|
-
|
|
56
|
+
if command -v pkill >/dev/null 2>&1; then
|
|
57
|
+
pkill -P "$watcher" 2>/dev/null
|
|
58
|
+
elif declare -F forge_kill_children >/dev/null 2>&1; then
|
|
59
|
+
forge_kill_children "$watcher"
|
|
60
|
+
fi
|
|
61
|
+
kill "$watcher" 2>/dev/null; wait "$watcher" 2>/dev/null
|
|
57
62
|
return 0
|
|
58
63
|
}
|
|
59
64
|
forge_dataset_invocation() { # forge_dataset_invocation <command> <rc> <started> [argv...]
|