@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.
Files changed (165) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +25 -15
  3. package/SKILL.md +137 -216
  4. package/VERSION +1 -1
  5. package/bin/forge.js +104 -0
  6. package/docs/README.md +2 -3
  7. package/docs/add-ons.md +5 -3
  8. package/docs/artifacts.md +17 -2
  9. package/docs/commands.md +85 -63
  10. package/docs/decomposed-runs.md +195 -21
  11. package/docs/development.md +12 -10
  12. package/docs/forge-ui.md +33 -4
  13. package/docs/install.md +127 -6
  14. package/docs/memory.md +6 -1
  15. package/docs/models.md +36 -10
  16. package/docs/reviews.md +50 -29
  17. package/docs/safety.md +27 -2
  18. package/docs/troubleshooting.md +8 -11
  19. package/forge +29 -4
  20. package/forge.cmd +56 -0
  21. package/package.json +6 -3
  22. package/references/dataset.md +10 -9
  23. package/references/decompose-integration.md +337 -0
  24. package/references/decompose-opt-in.md +527 -0
  25. package/references/decompose-recovery.md +569 -0
  26. package/references/decompose-review.md +256 -0
  27. package/references/decompose.md +99 -1606
  28. package/references/findings.md +68 -0
  29. package/references/harnesses.md +7 -12
  30. package/references/memory.md +13 -2
  31. package/references/planning.md +48 -18
  32. package/references/ripwire.md +38 -13
  33. package/references/runtime.md +22 -33
  34. package/references/setup.md +90 -0
  35. package/references/solo.md +13 -42
  36. package/references/ui.md +12 -5
  37. package/registry.tsv +40 -22
  38. package/scripts/forge-artifact.sh +148 -13
  39. package/scripts/forge-compare.py +5 -15
  40. package/scripts/forge-config.py +14 -1
  41. package/scripts/forge-contract.py +216 -53
  42. package/scripts/forge-control.py +781 -51
  43. package/scripts/forge-dispatch.sh +202 -42
  44. package/scripts/forge-du.py +13 -3
  45. package/scripts/forge-guard.py +137 -6
  46. package/scripts/forge-handoff.py +221 -39
  47. package/scripts/forge-install-ripwire.sh +100 -24
  48. package/scripts/forge-install.sh +100 -41
  49. package/scripts/forge-issues.py +6 -4
  50. package/scripts/forge-jev-options.sh +3 -5
  51. package/scripts/forge-lib-adopt.sh +169 -5
  52. package/scripts/forge-lib-attribute.sh +10 -3
  53. package/scripts/forge-lib-decompose.sh +454 -0
  54. package/scripts/forge-lib-env.sh +179 -0
  55. package/scripts/forge-lib-group.sh +9 -6
  56. package/scripts/forge-lib-plans.sh +38 -21
  57. package/scripts/forge-lib-review.sh +28 -8
  58. package/scripts/forge-lib-task.sh +263 -69
  59. package/scripts/forge-lib-verify.sh +59 -10
  60. package/scripts/forge-memory.sh +83 -4
  61. package/scripts/forge-metrics.sh +10 -3
  62. package/scripts/forge-parallel-options.sh +23 -4
  63. package/scripts/forge-parallel.sh +602 -217
  64. package/scripts/forge-plan-check.py +71 -8
  65. package/scripts/forge-planner.py +303 -17
  66. package/scripts/forge-pr.py +9 -1
  67. package/scripts/forge-prompt.py +2 -2
  68. package/scripts/forge-review-links.py +248 -0
  69. package/scripts/forge-ripwire.py +234 -16
  70. package/scripts/forge-route.py +19 -27
  71. package/scripts/forge-runs-rm.py +92 -21
  72. package/scripts/forge-runs.py +46 -5
  73. package/scripts/forge-runtime.py +39 -14
  74. package/scripts/forge-schedule.py +141 -33
  75. package/scripts/forge-setup-stale.py +236 -0
  76. package/scripts/forge-setup.py +804 -0
  77. package/scripts/forge-shadow.py +2 -20
  78. package/scripts/forge-solo-lock.py +46 -0
  79. package/scripts/forge-solo.sh +39 -58
  80. package/scripts/forge-sweep.py +3 -2
  81. package/scripts/forge-ui.py +8 -1
  82. package/scripts/forge-update.sh +8 -3
  83. package/scripts/forge-verify.py +17 -1
  84. package/scripts/forge-version.py +13 -1
  85. package/scripts/forge-watch.py +7 -2
  86. package/scripts/forge-win.sh +156 -0
  87. package/scripts/forge_brief/__init__.py +6 -1
  88. package/scripts/forge_brief/proposals.py +6 -1
  89. package/scripts/forge_dataset/__init__.py +1 -1
  90. package/scripts/forge_dataset/capture.py +0 -34
  91. package/scripts/forge_dataset/checks.py +0 -1
  92. package/scripts/forge_dataset/cli.py +5 -1
  93. package/scripts/forge_dataset/export.py +28 -6
  94. package/scripts/forge_dataset/facts.py +1 -2
  95. package/scripts/forge_dataset/forecast.py +1 -1
  96. package/scripts/forge_dataset/harvest.py +107 -7
  97. package/scripts/forge_dataset/importer.py +3 -2
  98. package/scripts/forge_dataset/pairs.py +3 -3
  99. package/scripts/forge_dataset/reviewers.py +4 -3
  100. package/scripts/forge_dataset/routing.py +6 -3
  101. package/scripts/forge_dataset/tiers.py +1 -1
  102. package/scripts/forge_decide/__init__.py +1 -1
  103. package/scripts/forge_decide/budget.py +12 -7
  104. package/scripts/forge_decide/profiles.py +11 -14
  105. package/scripts/forge_decide/replay.py +9 -4
  106. package/scripts/forge_decompose.py +987 -0
  107. package/scripts/forge_flock.py +17 -2
  108. package/scripts/forge_groups/review.py +6 -1
  109. package/scripts/forge_jev/__init__.py +1 -1
  110. package/scripts/forge_jev/cli.py +10 -1
  111. package/scripts/forge_jev/gates.py +10 -1
  112. package/scripts/forge_jev/verify.py +10 -2
  113. package/scripts/forge_legacy.py +86 -0
  114. package/scripts/forge_memory_home.py +57 -0
  115. package/scripts/forge_models.py +151 -0
  116. package/scripts/forge_posix.py +17 -0
  117. package/scripts/forge_prefs.py +138 -0
  118. package/scripts/forge_proc.py +108 -0
  119. package/scripts/forge_registry.py +2 -2
  120. package/scripts/forge_side/__init__.py +23 -4
  121. package/scripts/forge_storage.py +28 -15
  122. package/ui/README.md +22 -10
  123. package/ui/docs/api.md +121 -99
  124. package/ui/forge_ui/control.py +53 -16
  125. package/ui/forge_ui/export.py +0 -10
  126. package/ui/forge_ui/models.py +15 -2
  127. package/ui/forge_ui/projects.py +4 -1
  128. package/ui/forge_ui/reader.py +462 -60
  129. package/ui/forge_ui/server.py +0 -10
  130. package/ui/forge_ui/static/app.js +28 -9
  131. package/ui/forge_ui/static/checksview.js +12 -3
  132. package/ui/forge_ui/static/controls.js +147 -11
  133. package/ui/forge_ui/static/convo.js +5 -2
  134. package/ui/forge_ui/static/diffview.js +4 -5
  135. package/ui/forge_ui/static/panel.js +180 -77
  136. package/ui/forge_ui/static/projectsview.js +16 -2
  137. package/ui/forge_ui/static/runmodel.js +18 -4
  138. package/ui/forge_ui/static/scene3d.js +52 -31
  139. package/ui/forge_ui/static/settings.js +1 -1
  140. package/ui/forge_ui/static/storageview.js +2 -2
  141. package/ui/forge_ui/static/style.css +23 -6
  142. package/ui/forge_ui/static/worktreesview.js +8 -4
  143. package/ui/forge_ui/transcripts.py +6 -0
  144. package/ui/forge_ui/worktrees.py +13 -1
  145. package/docs/fractal.md +0 -181
  146. package/references/fractal-dashboard.md +0 -21
  147. package/references/fractal.md +0 -307
  148. package/scripts/forge-fractal-dispatch.sh +0 -4
  149. package/scripts/forge-fractal-options.sh +0 -54
  150. package/scripts/forge-fractal.py +0 -6
  151. package/scripts/forge-install-fractal.sh +0 -4
  152. package/scripts/forge_fractal/__init__.py +0 -88
  153. package/scripts/forge_fractal/bridge.py +0 -46
  154. package/scripts/forge_fractal/cli.py +0 -224
  155. package/scripts/forge_fractal/dashboard.css +0 -138
  156. package/scripts/forge_fractal/dashboard.html +0 -41
  157. package/scripts/forge_fractal/dashboard.js +0 -687
  158. package/scripts/forge_fractal/decomposition.py +0 -262
  159. package/scripts/forge_fractal/execution.py +0 -659
  160. package/scripts/forge_fractal/inspection.py +0 -261
  161. package/scripts/forge_fractal/install.py +0 -158
  162. package/scripts/forge_fractal/invocation.py +0 -95
  163. package/scripts/forge_fractal/pipeline.py +0 -125
  164. package/scripts/forge_fractal/selection.py +0 -180
  165. package/ui/forge_ui/fractal.py +0 -582
@@ -15,24 +15,72 @@ verify_lanes_present() { # verify_lanes_present <dir>
15
15
  }
16
16
 
17
17
  # Where a plan's verification comes from, in this order: the plan's lanes (--verify-lane,
18
- # $PLAN/verify.d/), the plan's --verify, the repository's lanes (.forge/verify.d/), the
19
- # repository's .forge/verify. Prints "<kind><TAB><location>" with kind lanes:plan,
20
- # command:plan, lanes:repo or command:repo, or nothing when none is configured.
21
- verify_source_for() { # verify_source_for <plan> <repo>
18
+ # $PLAN/verify.d/), the plan's --verify, then the repository's lanes (.forge/verify.d/) and its
19
+ # .forge/verify. With a checkout (the integration worktree or an integrate candidate) that is not
20
+ # the repository itself, the repository's configuration committed in that checkout comes before
21
+ # the repository root's copy (#151): lanes belong to the commit they verify, so a merged task or an
22
+ # adopted range that changes .forge/verify.d/ is verified with its own lanes. Only tracked files
23
+ # count there; a checkout whose .forge/ is not in git falls through to the root's.
24
+ # Prints "<kind><TAB><location>" with kind lanes:plan, command:plan, lanes:checkout,
25
+ # command:checkout, lanes:repo or command:repo, or nothing when none is configured.
26
+ verify_source_for() { # verify_source_for <plan> <repo> [checkout]
27
+ local co="${3:-}"
28
+ if [ -n "$co" ] && { [ ! -d "$co" ] || [ "$co" -ef "$2" ]; }; then co=""; fi
22
29
  if verify_lanes_present "$1/verify.d"; then printf 'lanes:plan\t%s\n' "$1/verify.d"
23
30
  elif [ -s "$1/verify_cmd" ]; then printf 'command:plan\t%s\n' "$1/verify_cmd"
31
+ elif [ -n "$co" ] && verify_lanes_present "$co/.forge/verify.d" \
32
+ && [ -n "$(git -C "$co" ls-files -- .forge/verify.d 2>/dev/null)" ]; then
33
+ printf 'lanes:checkout\t%s\n' "$co/.forge/verify.d"
34
+ elif [ -n "$co" ] && [ -s "$co/.forge/verify" ] \
35
+ && [ -n "$(git -C "$co" ls-files -- .forge/verify 2>/dev/null)" ]; then
36
+ printf 'command:checkout\t%s\n' "$co/.forge/verify"
24
37
  elif verify_lanes_present "$2/.forge/verify.d"; then printf 'lanes:repo\t%s\n' "$2/.forge/verify.d"
25
38
  elif [ -s "$2/.forge/verify" ]; then printf 'command:repo\t%s\n' "$2/.forge/verify"
26
39
  fi
27
40
  return 0
28
41
  }
29
42
 
43
+ # When verification runs the configuration committed in the checkout (lanes:checkout,
44
+ # command:checkout), say how the repository root's copy differs, so a run never wonders which
45
+ # one ran: one line per lane that is changed, only on the branch, or only in the root. Prints
46
+ # nothing when they agree or the root has nothing.
47
+ verify_root_difference() { # verify_root_difference <source line> <repo>
48
+ local kind="${1%%$'\t'*}" loc="${1#*$'\t'}" repo="$2" f name changed="" mine="" theirs=""
49
+ case "$kind" in
50
+ lanes:checkout)
51
+ verify_lanes_present "$repo/.forge/verify.d" || return 0
52
+ for f in "$loc"/*; do
53
+ [ -f "$f" ] || continue
54
+ name="${f##*/}"; case "$name" in *~) continue ;; esac
55
+ if [ ! -f "$repo/.forge/verify.d/$name" ]; then mine="${mine:+$mine, }$name"
56
+ elif ! cmp -s "$f" "$repo/.forge/verify.d/$name"; then changed="${changed:+$changed, }$name"; fi
57
+ done
58
+ for f in "$repo/.forge/verify.d"/*; do
59
+ [ -f "$f" ] || continue
60
+ name="${f##*/}"; case "$name" in *~) continue ;; esac
61
+ [ -f "$loc/$name" ] || theirs="${theirs:+$theirs, }$name"
62
+ done
63
+ [ -n "$changed$mine$theirs" ] || return 0
64
+ echo "verification runs the lanes committed on the branch it verifies ($loc), not $repo/.forge/verify.d:"
65
+ [ -z "$changed" ] || echo " changed on the branch: $changed"
66
+ [ -z "$mine" ] || echo " only on the branch: $mine"
67
+ [ -z "$theirs" ] || echo " only in the repository root (not run): $theirs"
68
+ ;;
69
+ command:checkout)
70
+ if [ -s "$repo/.forge/verify" ] && ! cmp -s "$loc" "$repo/.forge/verify"; then
71
+ echo "verification runs the .forge/verify committed on the branch it verifies ($loc), which differs from $repo/.forge/verify"
72
+ fi
73
+ ;;
74
+ esac
75
+ return 0
76
+ }
77
+
30
78
  # The verify command a plan would run, as text: the command itself, or for lanes every
31
79
  # lane's command (its #forge: option lines left out), one after another. Prints nothing
32
80
  # when nothing is configured.
33
- verify_command_for() { # verify_command_for <plan> <repo>
81
+ verify_command_for() { # verify_command_for <plan> <repo> [checkout]
34
82
  local src loc
35
- src="$(verify_source_for "$1" "$2")"
83
+ src="$(verify_source_for "$1" "$2" "${3:-}")"
36
84
  loc="${src#*$'\t'}"
37
85
  case "$src" in
38
86
  command:*) cat "$loc" ;;
@@ -82,12 +130,13 @@ verify_lanes_snapshot() { # verify_lanes_snapshot <lanes dir> <out>
82
130
  # nothing, passes.
83
131
  verify_lanes_check() { # verify_lanes_check <plan> <repo> <checkout>
84
132
  local src loc out
85
- src="$(verify_source_for "$1" "$2")"
133
+ src="$(verify_source_for "$1" "$2" "$3")"
86
134
  case "$src" in lanes:*) ;; *) return 0 ;; esac
87
135
  loc="${src#*$'\t'}"
88
- if [ "${src%%$'\t'*}" = lanes:repo ] && [ -s "$2/.forge/verify" ]; then
89
- note ".forge/verify is ignored: the repository declares verification lanes in .forge/verify.d/"
90
- fi
136
+ case "${src%%$'\t'*}" in
137
+ lanes:repo) [ ! -s "$2/.forge/verify" ] || note ".forge/verify is ignored: the repository declares verification lanes in .forge/verify.d/" ;;
138
+ lanes:checkout) [ ! -s "$3/.forge/verify" ] || note ".forge/verify is ignored: the repository declares verification lanes in .forge/verify.d/" ;;
139
+ esac
91
140
  out="$(python3 "$SKILL_DIR/scripts/forge-verify.py" lanes --lanes-dir "$loc" --checkout "$3" 2>&1 >/dev/null)" \
92
141
  || die "invalid verification lanes in $loc:
93
142
  $out"
@@ -23,6 +23,7 @@
23
23
  # forge-memory.sh record <repo> --last <file> --role <r> [--run-id X] [--task T]
24
24
  # [--model M] [--verdict V] [--duration S]
25
25
  # forge-memory.sh show <repo>
26
+ # forge-memory.sh where <repo> the checkout whose .forge/ holds the memory (#159)
26
27
  # forge-memory.sh prune <repo>
27
28
  # forge-memory.sh spend <repo> [--run <run-id>]
28
29
  # forge-memory.sh learnings <repo> [--json] every ledger learning and its state, as JSON
@@ -49,6 +50,8 @@ TAB="$(printf '\t')"
49
50
  # export it, and this script is also run directly. Getting it wrong would leave the Jev
50
51
  # curation below silently disabled instead of visibly broken.
51
52
  SKILL_DIR="${SKILL_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
53
+ source "$SKILL_DIR/scripts/forge-lib-env.sh"
54
+ forge_ensure_python3
52
55
 
53
56
  # Writing files into someone's repo automatically needs an escape hatch that does
54
57
  # not require editing the skill.
@@ -70,9 +73,73 @@ memory_dataset_event() { # memory_dataset_event <name> <repo> <run-dir> [--set k
70
73
  >/dev/null 2>&1 || true
71
74
  }
72
75
 
73
- dir_for() { echo "$1/.forge"; }
74
- memory_for() { echo "$1/.forge/memory.md"; }
75
- ledger_for() { echo "$1/.forge/ledger.tsv"; }
76
+ # Where a checkout's project memory lives (#159). A linked worktree (`git worktree add`) whose
77
+ # .forge/memory.md and .forge/ledger.tsv are not tracked keeps its memory in the main checkout's
78
+ # .forge/: `git worktree remove` deletes ignored files without a word, and the main checkout is where
79
+ # later runs start. Everything else keeps it in the checkout itself: the main checkout, a tracked
80
+ # .forge/ (git refuses to remove a worktree with changes to it), a bare repository's worktree, a path
81
+ # outside git, or FORGE_MEMORY_PER_CHECKOUT=1. scripts/forge_memory_home.py is the same rule in Python.
82
+ memory_home() { # memory_home <repo>
83
+ local repo="$1" gd common main listing
84
+ [ "${FORGE_MEMORY_PER_CHECKOUT:-}" != 1 ] || { printf '%s\n' "$repo"; return 0; }
85
+ gd="$(cd "$repo" 2>/dev/null && cd "$(git rev-parse --git-dir 2>/dev/null)" 2>/dev/null && pwd -P)" \
86
+ && common="$(cd "$repo" 2>/dev/null && cd "$(git rev-parse --git-common-dir 2>/dev/null)" 2>/dev/null && pwd -P)" \
87
+ && [ "$gd" != "$common" ] || { printf '%s\n' "$repo"; return 0; }
88
+ # The first entry of the worktree list is the main working tree; a bare repository has none.
89
+ listing="$(git -C "$repo" worktree list --porcelain 2>/dev/null)"
90
+ main="$(printf '%s\n' "$listing" | sed -n '1s/^worktree //p')"
91
+ [ -n "$main" ] || { printf '%s\n' "$repo"; return 0; }
92
+ if printf '%s\n' "$listing" | awk 'NR > 1 && /^$/ { exit } NR > 1 && /^bare$/ { found = 1 } END { exit !found }'; then
93
+ printf '%s\n' "$repo"; return 0
94
+ fi
95
+ [ -d "$main" ] || { printf '%s\n' "$repo"; return 0; }
96
+ if [ -n "$(git -C "$repo" ls-files -- .forge/memory.md .forge/ledger.tsv 2>/dev/null)" ]; then
97
+ printf '%s\n' "$repo"; return 0
98
+ fi
99
+ printf '%s\n' "$main"
100
+ }
101
+
102
+ # Resolved once per command for the repository it names (memory_cache below), so the helpers below
103
+ # cost no git call each time; any other path is resolved when it is asked about.
104
+ MEMORY_HOME_REPO="" MEMORY_HOME_DIR=""
105
+ memory_cache() { MEMORY_HOME_REPO="$1"; MEMORY_HOME_DIR="$(memory_home "$1")"; }
106
+ memory_root() {
107
+ if [ -n "$MEMORY_HOME_REPO" ] && [ "$1" = "$MEMORY_HOME_REPO" ]; then printf '%s\n' "$MEMORY_HOME_DIR"
108
+ else memory_home "$1"; fi
109
+ }
110
+ dir_for() { echo "$(memory_root "$1")/.forge"; }
111
+ memory_for() { echo "$(memory_root "$1")/.forge/memory.md"; }
112
+ ledger_for() { echo "$(memory_root "$1")/.forge/ledger.tsv"; }
113
+
114
+ # A linked worktree that kept memory of its own before #159 (or before its .forge/ was untracked):
115
+ # its ledger rows go into the main checkout's ledger once (rows already there are not added twice),
116
+ # and its two files are renamed *.merged, so nothing is lost and nothing is read twice. Fail-quiet:
117
+ # a merge that cannot complete leaves both ledgers as they were.
118
+ memory_adopt_stranded() { # memory_adopt_stranded <repo>
119
+ local repo="$1" home own_led home_led n
120
+ home="$(memory_root "$repo")"
121
+ [ "$home" != "$repo" ] || return 0
122
+ own_led="$repo/.forge/ledger.tsv"; home_led="$home/.forge/ledger.tsv"
123
+ [ -f "$own_led" ] || return 0
124
+ mkdir -p "$home/.forge" || return 0
125
+ # Appended, as `record` appends: a row another dispatch adds meanwhile is never lost. Two merges at
126
+ # once can add a row twice, which changes no count (a learning counts the distinct runs it came from).
127
+ if [ -s "$home_led" ]; then
128
+ n="$(awk 'NR == FNR { seen[$0] = 1; next } FNR > 1 && !($0 in seen)' "$home_led" "$own_led" | wc -l | tr -d ' ')"
129
+ awk 'NR == FNR { seen[$0] = 1; next } FNR > 1 && !($0 in seen)' "$home_led" "$own_led" > "$own_led.adding" \
130
+ && cat "$own_led.adding" >> "$home_led" || { rm -f "$own_led.adding"; return 0; }
131
+ rm -f "$own_led.adding"
132
+ else
133
+ n="$(awk 'FNR > 1' "$own_led" | wc -l | tr -d ' ')"
134
+ cat "$own_led" >> "$home_led" || return 0
135
+ fi
136
+ mv "$own_led" "$own_led.merged" 2>/dev/null
137
+ [ ! -f "$repo/.forge/memory.md" ] || mv "$repo/.forge/memory.md" "$repo/.forge/memory.md.merged" 2>/dev/null
138
+ FORGE_MEMORY_DEEP_PRUNE=0 rebuild "$repo" >/dev/null 2>&1 || true
139
+ printf 'forge: memory: %s learning row(s) of the linked worktree %s moved to %s, where its memory now lives\n' \
140
+ "$n" "$repo" "$home_led" >&2
141
+ return 0
142
+ }
76
143
 
77
144
  # Normalized dedup key: lowercase, every run of non-alphanumerics collapsed to a
78
145
  # single space. Exact match after that — genuinely different phrasings will NOT
@@ -1272,6 +1339,8 @@ memory_usage() {
1272
1339
  usage: forge memory <command> <repo> [...] (scripts/forge-memory.sh)
1273
1340
 
1274
1341
  show <repo> the repository's .forge/memory.md
1342
+ where <repo> the checkout whose .forge/ holds that memory: the repository itself, or for a
1343
+ linked worktree whose .forge/ is not tracked, the main checkout (#159)
1275
1344
  learnings <repo> [--json] every ledger learning and what forge does with it (in_memory, waiting,
1276
1345
  stale, capped, muted), from forge's own rebuild; changes nothing
1277
1346
  prune <repo> re-apply staleness and the cap now, then print what a dwarf is told
@@ -1287,10 +1356,20 @@ usage: forge memory <command> <repo> [...] (scripts/forge-memory.sh)
1287
1356
  (--path P, --actor ui|cli, --json); an unknown key is an error
1288
1357
  USAGE
1289
1358
  }
1290
- [ $# -ge 1 ] || die "usage: forge-memory.sh <inject|note|record|show|prune|spend|learnings|forget|add|edit> [repo] [...]"
1359
+ [ $# -ge 1 ] || die "usage: forge-memory.sh <inject|note|record|show|prune|spend|learnings|forget|add|edit|where> [repo] [...]"
1291
1360
  CMD="$1"; shift
1361
+ # The repository named first: where its memory lives is decided once (#159), and memory a linked
1362
+ # worktree kept of its own is moved there before anything reads it.
1363
+ case "$CMD" in
1364
+ inject|record|show|spend|learnings|prune|forget|add|edit|where)
1365
+ if [ -n "${1:-}" ] && [ -d "$1" ]; then
1366
+ forge_repo_memory_off "$1" && export FORGE_MEMORY=off # forge setup chose no memory here
1367
+ memory_cache "$1"; memory_off || memory_adopt_stranded "$1"
1368
+ fi ;;
1369
+ esac
1292
1370
  case "$CMD" in
1293
1371
  -h|--help|help) memory_usage; exit 0 ;;
1372
+ where) [ -n "${1:-}" ] || die "where needs a repo"; memory_root "$1" ;;
1294
1373
  inject) do_inject "$@" ;;
1295
1374
  note) do_note "$@" ;;
1296
1375
  record) do_record "$@" ;;
@@ -5,9 +5,9 @@ forge_metric_begin() {
5
5
  FORGE_METRIC="$(python3 "$SKILL_DIR/scripts/forge-runtime.py" begin "$1" "$2")" || return 3
6
6
  # Dispatches started from here name this execution as their parent in the run dataset.
7
7
  export FORGE_DATASET_PARENT="${FORGE_METRIC##*/}"
8
- # The hook, when the caller defines it, records status before finish and Fractal's _outcome. A review
8
+ # The hook, when the caller defines it, records status before finish. A review
9
9
  # snapshot the runner names in FORGE_REVIEW_SNAPSHOT is removed on every way out (#139).
10
- trap 'metric_rc=$?; [ -z "${FORGE_REVIEW_SNAPSHOT:-}" ] || ! declare -F forge_drop_snapshot >/dev/null || forge_drop_snapshot "$FORGE_REVIEW_SNAPSHOT"; ! declare -F forge_metric_on_exit >/dev/null || forge_metric_on_exit "$metric_rc"; python3 "$SKILL_DIR/scripts/forge-runtime.py" finish "$FORGE_METRIC" "$FORGE_METRIC_ROOT" "$FORGE_METRIC_ROLE" pipeline "$metric_rc"; if [ -n "${FORGE_FRACTAL_RUN:-}" ]; then python3 "$SKILL_DIR/scripts/forge-fractal.py" _outcome "$FORGE_METRIC_ROOT" "$metric_rc"; fi; exit "$metric_rc"' EXIT
10
+ trap 'metric_rc=$?; [ -z "${FORGE_REVIEW_SNAPSHOT:-}" ] || ! declare -F forge_drop_snapshot >/dev/null || forge_drop_snapshot "$FORGE_REVIEW_SNAPSHOT"; ! declare -F forge_metric_on_exit >/dev/null || forge_metric_on_exit "$metric_rc"; python3 "$SKILL_DIR/scripts/forge-runtime.py" finish "$FORGE_METRIC" "$FORGE_METRIC_ROOT" "$FORGE_METRIC_ROLE" pipeline "$metric_rc"; exit "$metric_rc"' EXIT
11
11
  }
12
12
  forge_metric_phase() {
13
13
  python3 "$SKILL_DIR/scripts/forge-runtime.py" phase "$FORGE_METRIC" "$1"
@@ -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
- pkill -P "$watcher" 2>/dev/null; kill "$watcher" 2>/dev/null; wait "$watcher" 2>/dev/null
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...]
@@ -69,4 +74,6 @@ forge_dataset_invocation() { # forge_dataset_invocation <command> <rc> <started>
69
74
  # offline, in CI and with FORGE_UPDATE_CHECK=off; it never changes a run's exit code.
70
75
  forge_update_notice() {
71
76
  python3 "$SKILL_DIR/scripts/forge-version.py" notice --source "$SKILL_DIR" </dev/null >&2 2>/dev/null || true
77
+ # The same for Ripwire (#170): on a terminal it asks before updating; without one it prints the command.
78
+ python3 "$SKILL_DIR/scripts/forge-ripwire.py" --notice </dev/null >&2 2>/dev/null || true
72
79
  }
@@ -38,7 +38,9 @@
38
38
  # --qa-threshold Pn|none|default plan run retry review $PLAN/qa_threshold least severe CONFIRMED
39
39
  # finding that still blocks; none (or off) =
40
40
  # P3, default removes the file (P2)
41
- # --verify-retries N run retry integrate $PLAN/verify_retries reruns of a failed verify command
41
+ # --qa-test-minutes N|default plan run retry review $PLAN/qa_test_minutes reviewer test-time guideline
42
+ # in minutes (0 = no cap; default removes, 5)
43
+ # --verify-retries N run retry integrate verify $PLAN/verify_retries reruns of a failed verify command
42
44
  # --escalate-after N run retry $PLAN/escalate_after failed attempts on one model before the
43
45
  # next goes a tier up (default 3; 0 = off)
44
46
  # --max-attempts N plan $PLAN/max_attempts attempts a task may spend across runs before it
@@ -64,7 +66,10 @@
64
66
  # options as in a lane file (group=g,first,...);
65
67
  # repeatable; replaces --verify and the lanes
66
68
  # of an earlier invocation
67
- # --verify-parallel N run retry integrate $PLAN/verify_parallel lanes run at once (1-32, default 3)
69
+ # --verify-parallel N run retry integrate verify $PLAN/verify_parallel lanes run at once (1-32, default 3)
70
+ # --setup-before-verify plan run retry integrate verify $PLAN/setup_before_verify re-run worktree setup in
71
+ # --no-setup-before-verify the integration checkout before verification
72
+ # when HEAD (or a .forge/setup-inputs file) moved
68
73
  PP_SHIFT=2
69
74
  PP_RETRY_FAILED=0
70
75
  PP_INFRA_RETRIES=0
@@ -132,6 +137,14 @@ forge_pp_flag() {
132
137
  default) rm -f "$plan/qa_threshold" ;;
133
138
  *) die "--qa-threshold needs P0, P1, P2, P3, none or default" ;;
134
139
  esac ;;
140
+ --qa-test-minutes)
141
+ case "$cmd" in plan|run|retry|review) ;; *) return 1 ;; esac
142
+ if [ "${2:-}" = default ]; then
143
+ rm -f "$plan/qa_test_minutes"
144
+ else
145
+ pp_nonneg --qa-test-minutes "${2:-}"
146
+ printf '%s\n' "$2" > "$plan/qa_test_minutes" || die "could not write $plan/qa_test_minutes"
147
+ fi ;;
135
148
  --escalate-after)
136
149
  case "$cmd" in run|retry) ;; *) return 1 ;; esac
137
150
  pp_nonneg --escalate-after "${2:-}"
@@ -159,14 +172,14 @@ forge_pp_flag() {
159
172
  PP_SHIFT=1
160
173
  rm -f "$plan/escalate_effort" ;;
161
174
  --verify-retries)
162
- case "$cmd" in run|retry|integrate) ;; *) return 1 ;; esac
175
+ case "$cmd" in run|retry|integrate|verify) ;; *) return 1 ;; esac
163
176
  pp_nonneg --verify-retries "${2:-}"
164
177
  printf '%s' "$2" > "$plan/verify_retries" ;;
165
178
  --verify-lane)
166
179
  case "$cmd" in run|retry) ;; *) return 1 ;; esac
167
180
  pp_lane "$plan" "${2-}" ;;
168
181
  --verify-parallel)
169
- case "$cmd" in run|retry|integrate) ;; *) return 1 ;; esac
182
+ case "$cmd" in run|retry|integrate|verify) ;; *) return 1 ;; esac
170
183
  case "${2:-}" in ''|*[!0-9]*) die "--verify-parallel needs an integer from 1 to 32" ;; esac
171
184
  [ "$2" -ge 1 ] && [ "$2" -le 32 ] || die "--verify-parallel needs an integer from 1 to 32"
172
185
  printf '%s' "$2" > "$plan/verify_parallel" ;;
@@ -192,6 +205,12 @@ forge_pp_flag() {
192
205
  --no-attribute)
193
206
  [ "$cmd" = run ] || return 1
194
207
  PP_SHIFT=1; rm -f "$plan/attribute_on" ;;
208
+ --setup-before-verify)
209
+ case "$cmd" in plan|run|retry|integrate|verify) ;; *) return 1 ;; esac
210
+ PP_SHIFT=1; printf 'on\n' > "$plan/setup_before_verify" ;;
211
+ --no-setup-before-verify)
212
+ case "$cmd" in plan|run|retry|integrate|verify) ;; *) return 1 ;; esac
213
+ PP_SHIFT=1; rm -f "$plan/setup_before_verify" ;;
195
214
  --final-review)
196
215
  [ "$cmd" = integrate ] || return 1
197
216
  PP_FINAL_REVIEW="${2:?--final-review needs a QA spec}"