@giamme/forge 0.22.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 +61 -0
- package/README.md +19 -12
- package/SKILL.md +137 -216
- package/VERSION +1 -1
- 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 +11 -9
- package/docs/forge-ui.md +33 -4
- package/docs/install.md +37 -5
- package/docs/memory.md +6 -1
- package/docs/models.md +36 -10
- package/docs/reviews.md +44 -25
- package/docs/safety.md +27 -2
- package/docs/troubleshooting.md +7 -10
- package/forge +25 -4
- package/package.json +2 -1
- 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 +143 -12
- 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 +777 -54
- package/scripts/forge-dispatch.sh +95 -12
- package/scripts/forge-du.py +13 -3
- package/scripts/forge-handoff.py +221 -39
- package/scripts/forge-install-ripwire.sh +100 -24
- package/scripts/forge-install.sh +18 -32
- 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 +21 -0
- package/scripts/forge-lib-group.sh +4 -1
- package/scripts/forge-lib-plans.sh +30 -18
- package/scripts/forge-lib-review.sh +28 -8
- package/scripts/forge-lib-task.sh +225 -56
- package/scripts/forge-lib-verify.sh +59 -10
- package/scripts/forge-memory.sh +81 -4
- package/scripts/forge-metrics.sh +4 -2
- package/scripts/forge-parallel-options.sh +23 -4
- package/scripts/forge-parallel.sh +447 -175
- 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 +37 -12
- package/scripts/forge-schedule.py +124 -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 +33 -56
- package/scripts/forge-sweep.py +2 -1
- package/scripts/forge-ui.py +8 -1
- package/scripts/forge-update.sh +2 -2
- package/scripts/forge-verify.py +16 -1
- package/scripts/forge-version.py +13 -1
- package/scripts/forge-watch.py +7 -2
- 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/profiles.py +11 -14
- package/scripts/forge_decompose.py +987 -0
- 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_prefs.py +138 -0
- package/scripts/forge_side/__init__.py +10 -0
- 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 +46 -14
- 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 +456 -59
- 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 +29 -29
- 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
package/scripts/forge-handoff.py
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
show [RUN_DIR | --repo DIR] [--json] (the default subcommand: `forge handoff RUN_DIR`)
|
|
5
5
|
Everything a new session, or another harness, needs to carry a run on, in one output:
|
|
6
|
-
the run, the choices it was launched with, whether a scheduler lives, each task
|
|
6
|
+
the run, the choices it was launched with, whether a scheduler lives, each task (and under
|
|
7
|
+
a task that was split, its subtasks with the sub-plan dir they are tasks of), what
|
|
7
8
|
needs a person, the last human changes, tasks left RUNNING by a dead scheduler, the
|
|
8
9
|
handoff notes and driver, and the exact commands to run next.
|
|
9
10
|
With no RUN_DIR it picks --repo's (default: this checkout's) newest run that is live or
|
|
@@ -28,12 +29,15 @@
|
|
|
28
29
|
resume RUN_DIR [--take-over] [--harness H] [--session S] [--json]
|
|
29
30
|
Carry a decomposed run on from any harness. It claims the run first (like claim; a refused
|
|
30
31
|
claim exits 3 and does nothing else), then: with a live scheduler it only says so and points
|
|
31
|
-
at `forge control show` (nothing is started); a Fractal
|
|
32
|
+
at `forge control show` (nothing is started); a plan made with Fractal (removed in 0.23) is refused;
|
|
32
33
|
otherwise each task left RUNNING by a dead scheduler has its worktree diff saved to
|
|
33
34
|
tasks/<id>/interrupted-<epoch>.diff, the worktree reset and cleaned (only after it passes a
|
|
34
35
|
guard: exactly <wt_root>/<id>, a git worktree on forge/<run_id>/<id>), the status set to
|
|
35
|
-
INTERRUPTED and the attempt counter rewound when attempts.tsv has no row for it
|
|
36
|
-
|
|
36
|
+
INTERRUPTED and the attempt counter rewound when attempts.tsv has no row for it (unless
|
|
37
|
+
the attempt reached its commit: it was stopped during its review, and the retry re-runs
|
|
38
|
+
only that review). Every
|
|
39
|
+
INTERRUPTED task is prepared with `forge-parallel.sh retry --no-dispatch` (the subtasks of a split
|
|
40
|
+
task are recovered and prepared the same way, in the task's sub-plan), and the run is
|
|
37
41
|
started again, detached, from run.flags.json (log: resume-<epoch>.log; the exit code goes to
|
|
38
42
|
resume-<epoch>.done). Without run.flags.json it prints the run command to finish by hand.
|
|
39
43
|
FORGE_HANDOFF_NO_START=1 prints the command and starts nothing.
|
|
@@ -67,6 +71,8 @@ SCRIPTS = Path(__file__).resolve().parent
|
|
|
67
71
|
sys.path.insert(0, str(SCRIPTS))
|
|
68
72
|
import forge_infra # noqa: E402
|
|
69
73
|
import forge_registry # noqa: E402
|
|
74
|
+
import forge_flock # noqa: E402
|
|
75
|
+
import forge_legacy # noqa: E402
|
|
70
76
|
|
|
71
77
|
PARALLEL = str(SCRIPTS / 'forge-parallel.sh')
|
|
72
78
|
SWEEP_OK = re.compile(r'P[0-3]')
|
|
@@ -80,15 +86,17 @@ TASK_OK = frozenset('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456
|
|
|
80
86
|
OPTION_FILES = (
|
|
81
87
|
'no_ripwire', 'no_memory', 'yolo_dwarf', 'yolo_qa', 'reviewer_session', 'reviewer_session_rate',
|
|
82
88
|
'reviewer_session_tasks', 'implementer_session', 'fast', 'pre_review_tests', 'pre_review_parallel',
|
|
83
|
-
'qa_threshold', 'timeout', 'verify_retries', 'verify_cmd', 'verify_parallel', 'setup_cmd', 'final_qa',
|
|
89
|
+
'qa_threshold', 'qa_test_minutes', 'timeout', 'verify_retries', 'verify_cmd', 'verify_parallel', 'setup_cmd', 'setup_before_verify', 'final_qa',
|
|
84
90
|
'shadow_qa', 'shadow_rate', 'explore', 'escalate_after', 'retry_per_model', 'fail_first',
|
|
85
|
-
'
|
|
91
|
+
'dwarf-routing.json', 'jev-selection.json', 'profile.json', 'routed.json',
|
|
92
|
+
# What a plan made before forge 0.23 has instead (forge_legacy.py): its tier pools and its Fractal choice.
|
|
93
|
+
'fractal-routing.json', 'fractal-selection.json',
|
|
86
94
|
'qa-routing.json', 'retro_mode', 'brief', 'brief_scope', 'brief_model', 'summaries', 'summaries_model',
|
|
87
95
|
'groups.tsv', 'groups.frozen', 'group_max_tasks', 'group_max_diff_kb', 'after', 'max_parallel')
|
|
88
96
|
FLAG_KEYS = ('retry_failed', 'infra_retries', 'sweep', 'sweep_max', 'sweep_plausible', 'sweep_ahead',
|
|
89
|
-
'max_parallel', 'timeout', 'verify', '
|
|
97
|
+
'max_parallel', 'timeout', 'verify', 'argv', 'at')
|
|
90
98
|
JSON_KEYS = ('run', 'choices', 'flags', 'scheduler', 'tasks', 'needs_you', 'changes', 'stale', 'notes',
|
|
91
|
-
'driver', 'next')
|
|
99
|
+
'driver', 'next', 'subtasks')
|
|
92
100
|
NOTE_MAX = 2000
|
|
93
101
|
SESSION_MAX = 200
|
|
94
102
|
# A different driver last seen longer ago than this is replaced without --take-over. Tests patch it.
|
|
@@ -195,6 +203,7 @@ class Plan:
|
|
|
195
203
|
# ------------------------------------------------------------------------------------ the sections
|
|
196
204
|
|
|
197
205
|
def kind_of(plan, fractal):
|
|
206
|
+
# 'fractal' is an old record: a plan made before forge 0.23 removed that backend (#154).
|
|
198
207
|
if (plan.path / 'tasks.tsv').is_file():
|
|
199
208
|
return 'fractal' if fractal else 'decomposed'
|
|
200
209
|
if (plan.path / 'prompt.md').is_file() and (plan.path / 'repo').is_file():
|
|
@@ -203,8 +212,7 @@ def kind_of(plan, fractal):
|
|
|
203
212
|
|
|
204
213
|
|
|
205
214
|
def is_fractal(plan):
|
|
206
|
-
|
|
207
|
-
return bool(data and data.get('enabled'))
|
|
215
|
+
return forge_legacy.was_fractal(plan.path)
|
|
208
216
|
|
|
209
217
|
|
|
210
218
|
def run_section(plan, kind):
|
|
@@ -277,7 +285,52 @@ def tasks_section(plan):
|
|
|
277
285
|
return rows
|
|
278
286
|
|
|
279
287
|
|
|
280
|
-
|
|
288
|
+
SUB_DEPTH = 8 # the depth limit of a run's decomposition tops out at 6
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def split_state(plan, task):
|
|
292
|
+
"""None for a task with no sub-plan, else `open` (its subtasks' work is not on its branch yet) or `merged`."""
|
|
293
|
+
if not plan.exists(f'tasks/{task}/sub/tasks.tsv'):
|
|
294
|
+
return None
|
|
295
|
+
return 'merged' if plan.exists(f'tasks/{task}/sub.merged') else 'open'
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def subtasks_section(plan, tasks, prefix='', depth=0):
|
|
299
|
+
"""The subtasks of every task that was split (#153), through every level, in tree order:
|
|
300
|
+
[{id, task, parent, plan, status, dwarf, split}]. `id` is the path from the run's own task (`d/a`),
|
|
301
|
+
`plan` the sub-plan dir the subtask is a task of: every command about it names that dir."""
|
|
302
|
+
rows = []
|
|
303
|
+
if depth >= SUB_DEPTH:
|
|
304
|
+
return rows
|
|
305
|
+
for task in tasks:
|
|
306
|
+
state = split_state(plan, task['id'])
|
|
307
|
+
if state is None:
|
|
308
|
+
continue
|
|
309
|
+
sub = Plan(plan.path / 'tasks' / task['id'] / 'sub')
|
|
310
|
+
children = tasks_section(sub)
|
|
311
|
+
plan.warnings.extend(f'{prefix}{task["id"]}/sub: {w}' for w in sub.warnings)
|
|
312
|
+
for child in children:
|
|
313
|
+
rows.append(dict(id=f'{prefix}{task["id"]}/{child["id"]}', task=child['id'], parent=prefix + task['id'],
|
|
314
|
+
plan=str(sub.path), status=child['status'], dwarf=child['dwarf'],
|
|
315
|
+
split=split_state(sub, child['id'])))
|
|
316
|
+
rows += subtasks_section(sub, [child], f'{prefix}{task["id"]}/', depth + 1)
|
|
317
|
+
return rows
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def needs_you_section(plan, tasks, now, subtasks=()):
|
|
321
|
+
items = needs_of(plan, tasks, now)
|
|
322
|
+
# A subtask that waits for a person waits in its own sub-plan: the item carries that plan dir.
|
|
323
|
+
by_plan = {}
|
|
324
|
+
for row in subtasks:
|
|
325
|
+
by_plan.setdefault(row['plan'], []).append(row)
|
|
326
|
+
for where, rows in by_plan.items():
|
|
327
|
+
for item in needs_of(Plan(where), [dict(id=row['task'], status=row['status']) for row in rows], now):
|
|
328
|
+
path = next(row['id'] for row in rows if row['task'] == item['task'])
|
|
329
|
+
items.append(dict(item, plan=where, path=path))
|
|
330
|
+
return items
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def needs_of(plan, tasks, now):
|
|
281
334
|
items = []
|
|
282
335
|
pauses = None
|
|
283
336
|
for task in tasks:
|
|
@@ -354,18 +407,24 @@ def next_section(plan, run, scheduler, tasks, needs):
|
|
|
354
407
|
live = scheduler['live']
|
|
355
408
|
if live:
|
|
356
409
|
steps.append(dict(command=f'forge control show {q(here)}', why='the run is live: its state and controls'))
|
|
410
|
+
elif open_tasks and run['kind'] == 'fractal':
|
|
411
|
+
steps.append(dict(command=f'forge ui open {q(here)}', why=forge_legacy.refusal('this run')))
|
|
357
412
|
elif open_tasks:
|
|
358
413
|
steps.append(dict(command=f'forge handoff resume {q(here)}', why='no scheduler is live and work is left'))
|
|
359
|
-
if run['kind'] == 'fractal':
|
|
360
|
-
steps.append(dict(command=f'forge fractal resume {q(run["run_id"] or here)}',
|
|
361
|
-
why='a Fractal-backed run: recover its recorded executions'))
|
|
362
414
|
for item in needs:
|
|
415
|
+
# A subtask's commands name its own sub-plan dir (#153).
|
|
416
|
+
where, name = q(item.get('plan') or here), item.get('path') or item['task']
|
|
417
|
+
verb = f'forge control retry {where} {q(item["task"])}' if live else f'{PARALLEL} retry {where} {q(item["task"])}'
|
|
363
418
|
if item['kind'] == 'NEEDS_INPUT':
|
|
364
|
-
verb
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
419
|
+
steps.append(dict(command=verb + ' --answer "…"', why=f'answer the question of {name}'))
|
|
420
|
+
elif item['kind'] == 'NEEDS_DECISION':
|
|
421
|
+
if live:
|
|
422
|
+
steps.append(dict(command=f'forge control retry {where} {q(item["task"])} --decide retry=N --reason "…" --approved',
|
|
423
|
+
why=f'{name} needs a decision (or --decide threshold=Pn, or --dwarf SPEC)'))
|
|
424
|
+
if 'split' in [word.strip() for word in (item['reasons'] or '').replace('reasons:', '').split(',')]:
|
|
425
|
+
steps.append(dict(command=verb + ' --decide split --subtasks FILE --reason "…" --approved',
|
|
426
|
+
why=f'{name} stopped on split: split it into subtasks, only on the user\'s word '
|
|
427
|
+
'(FILE holds the subtasks; without a live run, --planner SPEC asks a planner instead)'))
|
|
369
428
|
if tasks and not open_tasks and run['kind'] != 'solo':
|
|
370
429
|
steps.append(dict(command=f'{PARALLEL} integrate {q(here)} --approved',
|
|
371
430
|
why='every task is merged; run this only on the user\'s word'))
|
|
@@ -383,10 +442,14 @@ def report(path):
|
|
|
383
442
|
run = run_section(plan, kind)
|
|
384
443
|
scheduler = scheduler_section(plan)
|
|
385
444
|
tasks = tasks_section(plan)
|
|
386
|
-
|
|
445
|
+
subtasks = subtasks_section(plan, tasks) if kind != 'solo' else []
|
|
446
|
+
needs = needs_you_section(plan, tasks, time.time(), subtasks)
|
|
387
447
|
stale = [] if scheduler['live'] else [dict(task=task['id'], note='left RUNNING with no live process')
|
|
388
448
|
for task in tasks if task['status'] == 'RUNNING']
|
|
449
|
+
if not scheduler['live']:
|
|
450
|
+
stale += [dict(task=row['id'], note='left RUNNING with no live process') for row in subtasks if row['status'] == 'RUNNING']
|
|
389
451
|
out = dict(run=run, choices=choices_section(plan), flags=flags_section(plan), scheduler=scheduler, tasks=tasks,
|
|
452
|
+
subtasks=subtasks,
|
|
390
453
|
needs_you=needs, changes=changes_section(plan), stale=stale, notes=notes_section(plan),
|
|
391
454
|
driver=driver_section(plan), next=next_section(plan, run, scheduler, tasks, needs))
|
|
392
455
|
out['warnings'] = plan.warnings
|
|
@@ -442,20 +505,35 @@ def render(data):
|
|
|
442
505
|
h = sched['holder']
|
|
443
506
|
out.append(f' schedule.holder: {h["command"]} (pid {h["pid"]}, since {when(h["at"])})')
|
|
444
507
|
head('Tasks')
|
|
508
|
+
below = {}
|
|
509
|
+
for row in data.get('subtasks') or []:
|
|
510
|
+
below.setdefault(row['parent'], []).append(row)
|
|
511
|
+
|
|
512
|
+
def subtasks_of(parent, depth):
|
|
513
|
+
# A split task's subtasks, under it: each is a task of the sub-plan dir printed on the first line.
|
|
514
|
+
rows = below.get(parent) or []
|
|
515
|
+
if rows:
|
|
516
|
+
out.append(f' {" " * depth}subtasks, in {rows[0]["plan"]}:')
|
|
517
|
+
for row in rows:
|
|
518
|
+
out.append(f' {" " * depth}{row["task"]:<{max(1, 24 - 2 * depth)}} {row["status"]:<15} {row["dwarf"] or "-"}')
|
|
519
|
+
subtasks_of(row['id'], depth + 1)
|
|
520
|
+
|
|
445
521
|
for task in data['tasks']:
|
|
446
522
|
out.append(f' {task["id"]:<24} {task["status"]:<15} {task["dwarf"] or "-"}')
|
|
523
|
+
subtasks_of(task['id'], 1)
|
|
447
524
|
if not data['tasks']:
|
|
448
525
|
out.append(' (none)')
|
|
449
526
|
head('Needs you')
|
|
450
527
|
for item in data['needs_you']:
|
|
528
|
+
name = item.get('path') or item['task']
|
|
451
529
|
if item['kind'] == 'NEEDS_INPUT':
|
|
452
|
-
out.append(f' {
|
|
530
|
+
out.append(f' {name}: NEEDS_INPUT, the question:')
|
|
453
531
|
out.extend(' ' + line for line in (item['question'] or '(needs_input.md missing)').splitlines())
|
|
454
532
|
elif item['kind'] == 'NEEDS_DECISION':
|
|
455
|
-
out.append(f' {
|
|
533
|
+
out.append(f' {name}: NEEDS_DECISION {item["reasons"] or "(decision.md missing)"}')
|
|
456
534
|
else:
|
|
457
535
|
where = '/'.join(part for part in (item['harness'], item['model']) if part) or 'unknown'
|
|
458
|
-
line = f' {
|
|
536
|
+
line = f' {name}: INFRA, {item["cause"]} on {where}'
|
|
459
537
|
if item['stage']:
|
|
460
538
|
line += f' ({item["stage"]} stage)'
|
|
461
539
|
if item['needs_you']:
|
|
@@ -805,10 +883,6 @@ def run_command(plan, flags):
|
|
|
805
883
|
command += ['--timeout', str(flags['timeout'])]
|
|
806
884
|
if isinstance(flags.get('verify'), str) and flags['verify']:
|
|
807
885
|
command += ['--verify', flags['verify']]
|
|
808
|
-
if flags.get('fractal') is True:
|
|
809
|
-
command.append('--fractal')
|
|
810
|
-
elif flags.get('fractal') is False:
|
|
811
|
-
command.append('--no-fractal')
|
|
812
886
|
return command
|
|
813
887
|
|
|
814
888
|
|
|
@@ -883,8 +957,23 @@ def save_diff(wt, dest):
|
|
|
883
957
|
shutil.rmtree(scratch, ignore_errors=True)
|
|
884
958
|
|
|
885
959
|
|
|
886
|
-
def
|
|
887
|
-
"""
|
|
960
|
+
def attempt_committed(ctrl, plan, task, wt, number):
|
|
961
|
+
"""Whether attempt NUMBER reached its commit: reviewed.commit is "forge(<task>) attempt NUMBER: ...".
|
|
962
|
+
|
|
963
|
+
Such an attempt was stopped during its review. It keeps its number: the retry re-runs only the
|
|
964
|
+
review (forge-lib-task.sh unjudged_attempt_commit), which spends no attempt.
|
|
965
|
+
"""
|
|
966
|
+
commit = (ctrl.read_file(plan, f'tasks/{task}/reviewed.commit') or '').strip()
|
|
967
|
+
if not commit:
|
|
968
|
+
return False
|
|
969
|
+
result = git(wt, 'log', '-1', '--format=%s', commit)
|
|
970
|
+
subject = result.stdout.decode('utf-8', 'replace').strip() if result.returncode == 0 else ''
|
|
971
|
+
return subject.startswith(f'forge({task}) attempt {number}: ')
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
def attempt_rewound(ctrl, plan, task, wt):
|
|
975
|
+
"""Write the attempt counter back by one when attempts.tsv has no row for it and the attempt
|
|
976
|
+
never reached its commit. Whether it did."""
|
|
888
977
|
text = ctrl.read_file(plan, f'tasks/{task}/attempt')
|
|
889
978
|
word = (text or '').split()
|
|
890
979
|
if not word or not word[0].isdigit() or int(word[0]) < 1:
|
|
@@ -895,6 +984,8 @@ def attempt_rewound(ctrl, plan, task):
|
|
|
895
984
|
cols = row.split('\t')
|
|
896
985
|
if len(cols) > 1 and cols[1].strip() == str(number):
|
|
897
986
|
return False
|
|
987
|
+
if attempt_committed(ctrl, plan, task, wt, number):
|
|
988
|
+
return False
|
|
898
989
|
ctrl.write_atomic(plan, f'tasks/{task}/attempt', f'{number - 1}\n')
|
|
899
990
|
return True
|
|
900
991
|
|
|
@@ -965,12 +1056,86 @@ def recover_task(ctrl, plan, wt_root, run_id, task, warn):
|
|
|
965
1056
|
try:
|
|
966
1057
|
ctrl.write_atomic(str(plan), f'tasks/{task}/status', 'INTERRUPTED\n')
|
|
967
1058
|
interrupted_event(plan, task)
|
|
968
|
-
row['attempt_rewound'] = attempt_rewound(ctrl, str(plan), task)
|
|
1059
|
+
row['attempt_rewound'] = attempt_rewound(ctrl, str(plan), task, wt)
|
|
969
1060
|
except (OSError, ctrl.Invalid) as error:
|
|
970
1061
|
warn(f'{task}: could not update its status or attempt counter ({error})')
|
|
971
1062
|
return row
|
|
972
1063
|
|
|
973
1064
|
|
|
1065
|
+
def resume_subtasks(ctrl, plan, warn, out, depth=0):
|
|
1066
|
+
"""The same recovery one level down (#153): in the sub-plan of every split task whose subtasks' work is
|
|
1067
|
+
not on the task's branch yet, a subtask left RUNNING by a dead run is saved, reset and marked
|
|
1068
|
+
INTERRUPTED, and every INTERRUPTED subtask is prepared. Each sub-plan is worked on under its own plan
|
|
1069
|
+
lock; one a live run still holds is left alone, and said. Rows carry `plan`, the sub-plan dir."""
|
|
1070
|
+
if depth >= SUB_DEPTH:
|
|
1071
|
+
return
|
|
1072
|
+
for task in tasks_section(Plan(plan)):
|
|
1073
|
+
if split_state(Plan(plan), task['id']) != 'open':
|
|
1074
|
+
continue
|
|
1075
|
+
sub = os.path.join(str(plan), 'tasks', task['id'], 'sub')
|
|
1076
|
+
view = Plan(sub)
|
|
1077
|
+
wt_root, run_id = view.line('wt_root'), view.line('run_id')
|
|
1078
|
+
if wt_root and run_id: # else it has never run: nothing can be stale in it
|
|
1079
|
+
lock = take_plan_lock(sub)
|
|
1080
|
+
if lock is None:
|
|
1081
|
+
warn(f'{task["id"]}: its subtasks ({sub}) are locked by {lock_holder(sub)}; nothing there was recovered')
|
|
1082
|
+
continue
|
|
1083
|
+
try:
|
|
1084
|
+
if scheduler_section(Plan(sub))['live']:
|
|
1085
|
+
warn(f'{task["id"]}: a run of its subtasks ({sub}) is live; nothing there was recovered')
|
|
1086
|
+
continue
|
|
1087
|
+
for child in tasks_section(Plan(sub)):
|
|
1088
|
+
if child['status'] == 'RUNNING':
|
|
1089
|
+
row = recover_task(ctrl, sub, wt_root, run_id, child['id'], warn)
|
|
1090
|
+
if row is not None:
|
|
1091
|
+
out['recovered'].append(dict(row, plan=sub))
|
|
1092
|
+
finally:
|
|
1093
|
+
try:
|
|
1094
|
+
forge_flock.flock(lock, forge_flock.LOCK_UN)
|
|
1095
|
+
except (OSError, ValueError):
|
|
1096
|
+
pass
|
|
1097
|
+
lock.close()
|
|
1098
|
+
for child in tasks_section(Plan(sub)):
|
|
1099
|
+
if child['status'] == 'INTERRUPTED':
|
|
1100
|
+
result = dict(prepare_task(sub, child['id']), plan=sub)
|
|
1101
|
+
out['prepared'].append(result)
|
|
1102
|
+
if not result['ok']:
|
|
1103
|
+
warn(f'{task["id"]}/{child["id"]}: could not be prepared for a retry: {result["message"]}')
|
|
1104
|
+
resume_subtasks(ctrl, sub, warn, out, depth + 1)
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
def take_plan_lock(plan):
|
|
1108
|
+
"""schedule.lock, the plan lock every forge-parallel.sh command that changes a plan holds (#157).
|
|
1109
|
+
|
|
1110
|
+
The open file while it is held, else None (another command holds it, or it cannot be taken). Held
|
|
1111
|
+
while stale tasks are reset, so a `run` started meanwhile is refused at the lock instead of racing
|
|
1112
|
+
the git reset and the status write; released before `retry --no-dispatch`, which takes it itself.
|
|
1113
|
+
"""
|
|
1114
|
+
try:
|
|
1115
|
+
handle = open(os.path.join(str(plan), 'schedule.lock'), 'a')
|
|
1116
|
+
except OSError:
|
|
1117
|
+
return None
|
|
1118
|
+
try:
|
|
1119
|
+
forge_flock.flock(handle, forge_flock.LOCK_EX | forge_flock.LOCK_NB)
|
|
1120
|
+
except (OSError, ValueError):
|
|
1121
|
+
handle.close()
|
|
1122
|
+
return None
|
|
1123
|
+
return handle
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
def lock_holder(plan):
|
|
1127
|
+
"""Who holds the plan lock, in words, from schedule.holder (written by each command that takes it)."""
|
|
1128
|
+
try:
|
|
1129
|
+
with open(os.path.join(str(plan), 'schedule.holder'), encoding='utf-8') as handle:
|
|
1130
|
+
holder = json.loads(handle.read(READ_CAP))
|
|
1131
|
+
except (OSError, ValueError):
|
|
1132
|
+
holder = None
|
|
1133
|
+
if isinstance(holder, dict) and isinstance(holder.get('command'), str) and holder['command'].isidentifier() \
|
|
1134
|
+
and type(holder.get('pid')) is int and pid_alive(holder['pid']):
|
|
1135
|
+
return f'forge-parallel.sh {holder["command"]} (pid {holder["pid"]})'
|
|
1136
|
+
return 'another forge command'
|
|
1137
|
+
|
|
1138
|
+
|
|
974
1139
|
def prepare_task(plan, task):
|
|
975
1140
|
"""forge-parallel.sh retry PLAN TASK --no-dispatch. {task, ok, message}."""
|
|
976
1141
|
command = forge_proc.bash_cmd(parallel_script(), 'retry', str(plan), task, '--no-dispatch')
|
|
@@ -1007,7 +1172,7 @@ def cmd_resume(args):
|
|
|
1007
1172
|
if not (Path(plan) / 'tasks.tsv').is_file():
|
|
1008
1173
|
raise Usage(f'{plan}: resume needs a decomposed run (tasks.tsv)') # before the claim: a solo run is not marked
|
|
1009
1174
|
claim_run(plan, args.harness, session, args.take_over) # Held (a refused claim) exits 3 before anything else
|
|
1010
|
-
out = dict(live=False, recovered=[], prepared=[], started=None, command=[])
|
|
1175
|
+
out = dict(live=False, locked=False, recovered=[], prepared=[], started=None, command=[])
|
|
1011
1176
|
view = Plan(plan)
|
|
1012
1177
|
scheduler = scheduler_section(view)
|
|
1013
1178
|
quote = shlex.quote
|
|
@@ -1025,22 +1190,39 @@ def cmd_resume(args):
|
|
|
1025
1190
|
return finish(f'the run is live (scheduler pid {scheduler["pid"]}) and is being followed; nothing was started',
|
|
1026
1191
|
f'forge control show {quote(plan)}')
|
|
1027
1192
|
if is_fractal(view):
|
|
1028
|
-
|
|
1029
|
-
return finish('a Fractal plan is not restarted here; recover its recorded executions:',
|
|
1030
|
-
f'forge fractal resume {quote(run_id or plan)}')
|
|
1193
|
+
return finish(forge_legacy.refusal('this plan'))
|
|
1031
1194
|
|
|
1032
1195
|
ctrl, wt_root, run_id = control(), view.line('wt_root'), view.line('run_id')
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1196
|
+
# The plan lock first (#157): a command that holds it is working on the plan, and nothing here may
|
|
1197
|
+
# reset its worktrees or restart it. Held through the resets, so no scheduler can start meanwhile.
|
|
1198
|
+
lock = take_plan_lock(plan)
|
|
1199
|
+
if lock is None:
|
|
1200
|
+
out['locked'] = True
|
|
1201
|
+
return finish(f'the plan is locked by {lock_holder(plan)}; nothing was recovered or started. '
|
|
1202
|
+
'Run this again once it has finished.', f'forge control show {quote(plan)}')
|
|
1203
|
+
try:
|
|
1204
|
+
if scheduler_section(Plan(plan))['live']:
|
|
1205
|
+
out['live'] = True
|
|
1206
|
+
return finish('a scheduler started while resume was starting; nothing was changed or started',
|
|
1207
|
+
f'forge control show {quote(plan)}')
|
|
1208
|
+
for task in tasks_section(Plan(plan)):
|
|
1209
|
+
if task['status'] == 'RUNNING':
|
|
1210
|
+
row = recover_task(ctrl, plan, wt_root, run_id, task['id'], warn)
|
|
1211
|
+
if row is not None:
|
|
1212
|
+
out['recovered'].append(row)
|
|
1213
|
+
finally:
|
|
1214
|
+
try:
|
|
1215
|
+
forge_flock.flock(lock, forge_flock.LOCK_UN)
|
|
1216
|
+
except (OSError, ValueError):
|
|
1217
|
+
pass
|
|
1218
|
+
lock.close()
|
|
1038
1219
|
for task in tasks_section(Plan(plan)):
|
|
1039
1220
|
if task['status'] == 'INTERRUPTED':
|
|
1040
1221
|
result = prepare_task(plan, task['id'])
|
|
1041
1222
|
out['prepared'].append(result)
|
|
1042
1223
|
if not result['ok']:
|
|
1043
1224
|
warn(f'{task["id"]}: could not be prepared for a retry: {result["message"]}')
|
|
1225
|
+
resume_subtasks(ctrl, plan, warn, out)
|
|
1044
1226
|
|
|
1045
1227
|
flags_view = Plan(plan)
|
|
1046
1228
|
flags = flags_view.json('run.flags.json')
|
|
@@ -1,52 +1,128 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Optional
|
|
2
|
+
# Optional Ripwire install or update, from upstream's release installer. No network activity
|
|
3
|
+
# before consent.
|
|
4
|
+
#
|
|
5
|
+
# forge-install-ripwire.sh [--yes] [--dry-run] [--upgrade] [--version TAG]
|
|
6
|
+
#
|
|
7
|
+
# --yes do not ask (the caller already has the user's consent)
|
|
8
|
+
# --dry-run say what would happen; never downloads
|
|
9
|
+
# --upgrade replace ~/.local/bin/ripwire, the binary forge installs. A Ripwire installed
|
|
10
|
+
# anywhere else is reported and never replaced.
|
|
11
|
+
# --version TAG install this release (e.g. v0.6.10) instead of the latest one; also
|
|
12
|
+
# FORGE_RIPWIRE_VERSION.
|
|
13
|
+
#
|
|
14
|
+
# What is verified: the release tag is resolved through the GitHub releases API (Intel Macs stop
|
|
15
|
+
# at v0.6.1, the last release with a binary for them), and upstream's scripts/install.sh is
|
|
16
|
+
# fetched AT THAT TAG over HTTPS. That installer refuses a release without a checksum, checks the
|
|
17
|
+
# archive's SHA-256, runs the binary's --version before installing it and again after. What is
|
|
18
|
+
# not verified: the installer script's own bytes. A moving version cannot be pinned by hash, so
|
|
19
|
+
# forge only checks it is upstream's release installer before running it.
|
|
3
20
|
set -uo pipefail
|
|
4
|
-
YES=0; DRY=0
|
|
5
|
-
|
|
6
|
-
|
|
21
|
+
YES=0; DRY=0; UPGRADE=0; TAG="${FORGE_RIPWIRE_VERSION:-}"
|
|
22
|
+
SCRIPTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
23
|
+
while [ $# -gt 0 ]; do
|
|
24
|
+
case "$1" in
|
|
7
25
|
--yes) YES=1 ;;
|
|
8
26
|
--dry-run) DRY=1 ;;
|
|
9
|
-
|
|
27
|
+
--upgrade) UPGRADE=1 ;;
|
|
28
|
+
--version)
|
|
29
|
+
[ $# -ge 2 ] || { echo 'forge: --version needs a release tag, e.g. v0.6.10' >&2; exit 2; }
|
|
30
|
+
TAG="$2"; shift ;;
|
|
31
|
+
-h|--help) sed -n '2,13p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
32
|
+
*) echo "forge: unknown installation option: $1" >&2; exit 2 ;;
|
|
10
33
|
esac
|
|
34
|
+
shift
|
|
11
35
|
done
|
|
36
|
+
case "$TAG" in
|
|
37
|
+
''|v[0-9]*.[0-9]*.[0-9]*) ;;
|
|
38
|
+
[0-9]*.[0-9]*.[0-9]*) TAG="v$TAG" ;;
|
|
39
|
+
*) echo "forge: --version must be a release tag such as v0.6.10, not '$TAG'" >&2; exit 2 ;;
|
|
40
|
+
esac
|
|
12
41
|
[ "${FORGE_RIPWIRE:-}" != off ] || exit 0
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
42
|
+
# `forge setup` answered "never offer it" (ripwire never): a run's offer stays silent. Asking for
|
|
43
|
+
# it by name (--yes, from forge ripwire install or update) still installs.
|
|
44
|
+
if [ "$YES" = 0 ] && [ "$UPGRADE" = 0 ] && [ "$DRY" = 0 ] \
|
|
45
|
+
&& [ "$(python3 "$SCRIPTS/forge_prefs.py" get ripwire 2>/dev/null)" = never ]; then
|
|
16
46
|
exit 0
|
|
17
47
|
fi
|
|
18
|
-
|
|
48
|
+
DEST="$HOME/.local/bin/ripwire"
|
|
49
|
+
FOUND="$(command -v ripwire 2>/dev/null || true)"
|
|
50
|
+
same_file() { [ -e "$1" ] && [ -e "$2" ] && [ "$(cd -P "$(dirname "$1")" && pwd)/$(basename "$1")" = "$(cd -P "$(dirname "$2")" && pwd)/$(basename "$2")" ]; }
|
|
51
|
+
have=''
|
|
52
|
+
if [ "$UPGRADE" = 0 ]; then
|
|
53
|
+
if [ -n "$FOUND" ] || [ -e "$DEST" ] || [ -L "$DEST" ]; then
|
|
54
|
+
echo 'forge: preserving existing Ripwire installation' >&2
|
|
55
|
+
exit 0
|
|
56
|
+
fi
|
|
57
|
+
else
|
|
58
|
+
if [ -n "$FOUND" ] && ! same_file "$FOUND" "$DEST"; then
|
|
59
|
+
# Never replace a binary forge did not install, and do not install a second one behind it.
|
|
60
|
+
echo "forge: Ripwire at $FOUND was not installed by forge; update it the way you installed it" >&2
|
|
61
|
+
exit 0
|
|
62
|
+
fi
|
|
63
|
+
if [ -L "$DEST" ]; then
|
|
64
|
+
echo "forge: $DEST is a symlink, so forge did not install it; not replacing it" >&2
|
|
65
|
+
exit 0
|
|
66
|
+
fi
|
|
67
|
+
[ -f "$DEST" ] && have="$("$DEST" --version 2>/dev/null | head -1)"
|
|
68
|
+
fi
|
|
69
|
+
if [ -n "$TAG" ]; then want="Ripwire $TAG"; else want='the latest Ripwire release'; fi
|
|
70
|
+
printf 'forge: %s -> %s\n' "$want" "$DEST" >&2
|
|
19
71
|
[ "$DRY" = 0 ] || exit 0
|
|
20
72
|
if [ "$YES" = 0 ]; then
|
|
73
|
+
if [ -n "$have" ]; then question="Update Ripwire ($have) to $want? [Y/n] "
|
|
74
|
+
else question='Ripwire is missing. Install it now? [Y/n] '; fi
|
|
21
75
|
# Open the controlling terminal, never task stdin (which may be a pipe/FIFO).
|
|
22
76
|
if { exec 3<> /dev/tty; } 2>/dev/null && [ -t 3 ]; then
|
|
23
|
-
printf '
|
|
77
|
+
printf '%s' "$question" >&3
|
|
24
78
|
reply=''
|
|
25
79
|
if ! IFS= read -r reply <&3; then exec 3>&-; exit 0; fi
|
|
26
80
|
exec 3>&-
|
|
27
81
|
case "$reply" in ''|y|Y|yes|YES) ;; *) exit 0 ;; esac
|
|
28
82
|
else
|
|
29
|
-
printf 'forge: optional install: bash %q --yes\n' "${BASH_SOURCE[0]}" >&2
|
|
83
|
+
printf 'forge: optional install: bash %q --yes%s\n' "${BASH_SOURCE[0]}" "$([ "$UPGRADE" = 1 ] && printf ' --upgrade')" >&2
|
|
30
84
|
exit 0
|
|
31
85
|
fi
|
|
32
86
|
fi
|
|
87
|
+
if [ -z "$TAG" ]; then
|
|
88
|
+
TAG="$(python3 "$SCRIPTS/forge-ripwire.py" --latest)" || { echo 'forge: Ripwire installation skipped; Forge can continue' >&2; exit 1; }
|
|
89
|
+
fi
|
|
90
|
+
if [ -n "$have" ] && [ "$(python3 -c 'import re,sys
|
|
91
|
+
v=lambda t: tuple(map(int, re.search(r"(\d+)\.(\d+)\.(\d+)", t).groups()))
|
|
92
|
+
print(int(v(sys.argv[1]) >= v(sys.argv[2])))' "$have" "$TAG" 2>/dev/null)" = 1 ]; then
|
|
93
|
+
echo "forge: Ripwire is already at ${have##* } (release $TAG); nothing to update" >&2
|
|
94
|
+
exit 0
|
|
95
|
+
fi
|
|
33
96
|
work="$(mktemp -d "${TMPDIR:-/tmp}/forge-install-ripwire.XXXXXX")" || exit 1
|
|
34
97
|
trap 'rm -rf "$work"' EXIT
|
|
35
98
|
curl -fLSs --connect-timeout 10 --max-time 60 \
|
|
36
|
-
https://raw.githubusercontent.com/redhat-et/ripwire/
|
|
99
|
+
"https://raw.githubusercontent.com/redhat-et/ripwire/$TAG/scripts/install.sh" \
|
|
37
100
|
-o "$work/install.sh" || { echo 'forge: Ripwire installer download failed' >&2; exit 1; }
|
|
38
|
-
#
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
RIPWIRE_REPO=redhat-et/ripwire RIPWIRE_VERSION=v0.4.0 \
|
|
101
|
+
# Not a hash pin (see the header): only that this is upstream's release installer.
|
|
102
|
+
if ! head -1 "$work/install.sh" | grep -q '^#!/usr/bin/env bash' \
|
|
103
|
+
|| ! grep -q 'RIPWIRE_REPO' "$work/install.sh" || ! grep -q 'sha256' "$work/install.sh"; then
|
|
104
|
+
echo 'forge: the downloaded file is not the Ripwire release installer; nothing was run' >&2
|
|
105
|
+
exit 1
|
|
106
|
+
fi
|
|
107
|
+
# The upstream installer verifies archive checksums and the binary version, and replaces an
|
|
108
|
+
# existing binary by rename. Its skills and hooks are never activated.
|
|
109
|
+
RIPWIRE_REPO=redhat-et/ripwire RIPWIRE_VERSION="$TAG" \
|
|
48
110
|
RIPWIRE_INSTALL_PREFIX="$HOME/.local" RIPWIRE_INSTALL_YES=1 RIPWIRE_NO_ACTIVATE=1 \
|
|
49
111
|
/bin/bash "$work/install.sh"
|
|
50
112
|
rc=$?
|
|
51
|
-
[ "$rc"
|
|
52
|
-
exit
|
|
113
|
+
if [ "$rc" != 0 ]; then
|
|
114
|
+
echo "forge: Ripwire installation failed (exit $rc); Forge can continue" >&2
|
|
115
|
+
exit "$rc"
|
|
116
|
+
fi
|
|
117
|
+
python3 - "$DEST" <<'PYCHECK'
|
|
118
|
+
import re, subprocess, sys
|
|
119
|
+
try:
|
|
120
|
+
out = subprocess.run([sys.argv[1], '--version'], capture_output=True, text=True, timeout=10).stdout
|
|
121
|
+
except (OSError, subprocess.SubprocessError):
|
|
122
|
+
out = ''
|
|
123
|
+
found = re.search(r'(\d+)\.(\d+)\.(\d+)', out)
|
|
124
|
+
if not found or tuple(map(int, found.groups())) < (0, 6, 0):
|
|
125
|
+
print('forge: the installed Ripwire (%s) is older than 0.6, so forge will not use it' % (out.strip() or '?'),
|
|
126
|
+
file=sys.stderr)
|
|
127
|
+
PYCHECK
|
|
128
|
+
exit 0
|
package/scripts/forge-install.sh
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# forge-install.sh — make /forge reachable from codex, claude, openclaude and
|
|
2
|
+
# forge-install.sh — make /forge reachable from codex, claude, openclaude, opencode, antigravity and grok.
|
|
3
3
|
#
|
|
4
4
|
# This skill directory stays the single source of truth.
|
|
5
5
|
#
|
|
@@ -134,11 +134,15 @@ install_antigravity() {
|
|
|
134
134
|
say "$label: plugin -> $wrapper"; return "$rc"
|
|
135
135
|
fi
|
|
136
136
|
mkdir -p "$wrapper/skills" || return 1
|
|
137
|
+
# The plugin's version is forge's own (VERSION), not a fixed placeholder.
|
|
138
|
+
local version=""
|
|
139
|
+
read -r version < "$SKILL_DIR/VERSION" 2>/dev/null || true
|
|
140
|
+
[ -n "$version" ] || version="0"
|
|
137
141
|
cat > "$wrapper/plugin.json" <<EOF
|
|
138
142
|
{
|
|
139
143
|
"name": "forge",
|
|
140
|
-
"description": "Dispatch a coding task to a dwarf model to implement, then an independent qa model to review its actual diff, across codex/claude/openclaude/opencode/antigravity.",
|
|
141
|
-
"version": "
|
|
144
|
+
"description": "Dispatch a coding task to a dwarf model to implement, then an independent qa model to review its actual diff, across codex/claude/openclaude/opencode/antigravity/grok.",
|
|
145
|
+
"version": "$version",
|
|
142
146
|
"author": { "name": "forge" }
|
|
143
147
|
}
|
|
144
148
|
EOF
|
|
@@ -173,36 +177,18 @@ report_opencode
|
|
|
173
177
|
say
|
|
174
178
|
say "Verify with: bash $SKILL_DIR/scripts/forge-dispatch.sh doctor"
|
|
175
179
|
|
|
176
|
-
#
|
|
180
|
+
# What a first run needs (models, reviews, forge-ui, memory, Ripwire, decision models),
|
|
181
|
+
# asked once on a terminal and saved as defaults (#162). `forge update` re-runs this installer with
|
|
182
|
+
# FORGE_SETUP=off: an update never asks again. Setup failing never fails the install.
|
|
177
183
|
if [ "$DRY" = 1 ]; then
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
184
|
+
say " would: run forge setup on a terminal (models, reviews, forge-ui, memory, Ripwire; skipped once done)"
|
|
185
|
+
elif [ "${FORGE_SETUP:-}" = off ]; then
|
|
186
|
+
:
|
|
187
|
+
elif [ -t 0 ] && [ -t 1 ]; then
|
|
188
|
+
say
|
|
189
|
+
python3 "$SKILL_DIR/scripts/forge-setup.py" --after-install || true
|
|
190
|
+
elif ! python3 "$SKILL_DIR/scripts/forge_prefs.py" done 2>/dev/null; then
|
|
191
|
+
say "Next: forge setup (models, reviews and add-ons, asked once), or forge setup --defaults"
|
|
181
192
|
fi
|
|
182
193
|
|
|
183
|
-
# Optional runtime; installing never activates it for a run.
|
|
184
|
-
if [ "$DRY" = 1 ]; then
|
|
185
|
-
/bin/bash "$SKILL_DIR/scripts/forge-install-fractal.sh" --dry-run
|
|
186
|
-
elif [ -t 0 ]; then
|
|
187
|
-
printf 'Install optional Fractal execution support? [y/N] '
|
|
188
|
-
read -r fractal_answer
|
|
189
|
-
if [ "$fractal_answer" = y ] || [ "$fractal_answer" = Y ]; then
|
|
190
|
-
/bin/bash "$SKILL_DIR/scripts/forge-install-fractal.sh" --with-prerequisites || true
|
|
191
|
-
fi
|
|
192
|
-
fi
|
|
193
|
-
say "Fractal CLI: $SKILL_DIR/forge fractal --help (repository-local; existing forge commands are preserved)"
|
|
194
|
-
|
|
195
|
-
# Optional advisory judgments; sends task/diff/test/memory excerpts to an external
|
|
196
|
-
# API. Off unless configured and enabled. Failure never prevents Forge setup.
|
|
197
|
-
if [ "$DRY" = 1 ]; then
|
|
198
|
-
say " would: offer optional Jev setup (sends data to an external API; declined by default)"
|
|
199
|
-
elif [ -t 0 ]; then
|
|
200
|
-
printf 'Set up optional Jev advisory judgments? Sends task/diff excerpts to an external API. [y/N] '
|
|
201
|
-
read -r jev_answer
|
|
202
|
-
if [ "$jev_answer" = y ] || [ "$jev_answer" = Y ]; then
|
|
203
|
-
python3 "$SKILL_DIR/scripts/forge-jev.py" setup || true
|
|
204
|
-
fi
|
|
205
|
-
fi
|
|
206
|
-
say "Jev CLI: $SKILL_DIR/forge jev --help (optional; disabled until configured)"
|
|
207
|
-
|
|
208
194
|
exit "$RESULT"
|