@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.
Files changed (153) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +19 -12
  3. package/SKILL.md +137 -216
  4. package/VERSION +1 -1
  5. package/docs/README.md +2 -3
  6. package/docs/add-ons.md +5 -3
  7. package/docs/artifacts.md +17 -2
  8. package/docs/commands.md +85 -63
  9. package/docs/decomposed-runs.md +195 -21
  10. package/docs/development.md +11 -9
  11. package/docs/forge-ui.md +33 -4
  12. package/docs/install.md +37 -5
  13. package/docs/memory.md +6 -1
  14. package/docs/models.md +36 -10
  15. package/docs/reviews.md +44 -25
  16. package/docs/safety.md +27 -2
  17. package/docs/troubleshooting.md +7 -10
  18. package/forge +25 -4
  19. package/package.json +2 -1
  20. package/references/dataset.md +10 -9
  21. package/references/decompose-integration.md +337 -0
  22. package/references/decompose-opt-in.md +527 -0
  23. package/references/decompose-recovery.md +569 -0
  24. package/references/decompose-review.md +256 -0
  25. package/references/decompose.md +99 -1606
  26. package/references/findings.md +68 -0
  27. package/references/harnesses.md +7 -12
  28. package/references/memory.md +13 -2
  29. package/references/planning.md +48 -18
  30. package/references/ripwire.md +38 -13
  31. package/references/runtime.md +22 -33
  32. package/references/setup.md +90 -0
  33. package/references/solo.md +13 -42
  34. package/references/ui.md +12 -5
  35. package/registry.tsv +40 -22
  36. package/scripts/forge-artifact.sh +143 -12
  37. package/scripts/forge-compare.py +5 -15
  38. package/scripts/forge-config.py +14 -1
  39. package/scripts/forge-contract.py +216 -53
  40. package/scripts/forge-control.py +777 -54
  41. package/scripts/forge-dispatch.sh +95 -12
  42. package/scripts/forge-du.py +13 -3
  43. package/scripts/forge-handoff.py +221 -39
  44. package/scripts/forge-install-ripwire.sh +100 -24
  45. package/scripts/forge-install.sh +18 -32
  46. package/scripts/forge-issues.py +6 -4
  47. package/scripts/forge-jev-options.sh +3 -5
  48. package/scripts/forge-lib-adopt.sh +169 -5
  49. package/scripts/forge-lib-attribute.sh +10 -3
  50. package/scripts/forge-lib-decompose.sh +454 -0
  51. package/scripts/forge-lib-env.sh +21 -0
  52. package/scripts/forge-lib-group.sh +4 -1
  53. package/scripts/forge-lib-plans.sh +30 -18
  54. package/scripts/forge-lib-review.sh +28 -8
  55. package/scripts/forge-lib-task.sh +225 -56
  56. package/scripts/forge-lib-verify.sh +59 -10
  57. package/scripts/forge-memory.sh +81 -4
  58. package/scripts/forge-metrics.sh +4 -2
  59. package/scripts/forge-parallel-options.sh +23 -4
  60. package/scripts/forge-parallel.sh +447 -175
  61. package/scripts/forge-plan-check.py +71 -8
  62. package/scripts/forge-planner.py +303 -17
  63. package/scripts/forge-pr.py +9 -1
  64. package/scripts/forge-prompt.py +2 -2
  65. package/scripts/forge-review-links.py +248 -0
  66. package/scripts/forge-ripwire.py +234 -16
  67. package/scripts/forge-route.py +19 -27
  68. package/scripts/forge-runs-rm.py +92 -21
  69. package/scripts/forge-runs.py +46 -5
  70. package/scripts/forge-runtime.py +37 -12
  71. package/scripts/forge-schedule.py +124 -33
  72. package/scripts/forge-setup-stale.py +236 -0
  73. package/scripts/forge-setup.py +804 -0
  74. package/scripts/forge-shadow.py +2 -20
  75. package/scripts/forge-solo-lock.py +46 -0
  76. package/scripts/forge-solo.sh +33 -56
  77. package/scripts/forge-sweep.py +2 -1
  78. package/scripts/forge-ui.py +8 -1
  79. package/scripts/forge-update.sh +2 -2
  80. package/scripts/forge-verify.py +16 -1
  81. package/scripts/forge-version.py +13 -1
  82. package/scripts/forge-watch.py +7 -2
  83. package/scripts/forge_dataset/__init__.py +1 -1
  84. package/scripts/forge_dataset/capture.py +0 -34
  85. package/scripts/forge_dataset/checks.py +0 -1
  86. package/scripts/forge_dataset/cli.py +5 -1
  87. package/scripts/forge_dataset/export.py +28 -6
  88. package/scripts/forge_dataset/facts.py +1 -2
  89. package/scripts/forge_dataset/forecast.py +1 -1
  90. package/scripts/forge_dataset/harvest.py +107 -7
  91. package/scripts/forge_dataset/importer.py +3 -2
  92. package/scripts/forge_dataset/pairs.py +3 -3
  93. package/scripts/forge_dataset/reviewers.py +4 -3
  94. package/scripts/forge_dataset/routing.py +6 -3
  95. package/scripts/forge_dataset/tiers.py +1 -1
  96. package/scripts/forge_decide/__init__.py +1 -1
  97. package/scripts/forge_decide/profiles.py +11 -14
  98. package/scripts/forge_decompose.py +987 -0
  99. package/scripts/forge_groups/review.py +6 -1
  100. package/scripts/forge_jev/__init__.py +1 -1
  101. package/scripts/forge_jev/cli.py +10 -1
  102. package/scripts/forge_jev/gates.py +10 -1
  103. package/scripts/forge_jev/verify.py +10 -2
  104. package/scripts/forge_legacy.py +86 -0
  105. package/scripts/forge_memory_home.py +57 -0
  106. package/scripts/forge_models.py +151 -0
  107. package/scripts/forge_prefs.py +138 -0
  108. package/scripts/forge_side/__init__.py +10 -0
  109. package/scripts/forge_storage.py +28 -15
  110. package/ui/README.md +22 -10
  111. package/ui/docs/api.md +121 -99
  112. package/ui/forge_ui/control.py +46 -14
  113. package/ui/forge_ui/export.py +0 -10
  114. package/ui/forge_ui/models.py +15 -2
  115. package/ui/forge_ui/projects.py +4 -1
  116. package/ui/forge_ui/reader.py +456 -59
  117. package/ui/forge_ui/server.py +0 -10
  118. package/ui/forge_ui/static/app.js +28 -9
  119. package/ui/forge_ui/static/checksview.js +12 -3
  120. package/ui/forge_ui/static/controls.js +147 -11
  121. package/ui/forge_ui/static/convo.js +5 -2
  122. package/ui/forge_ui/static/diffview.js +4 -5
  123. package/ui/forge_ui/static/panel.js +180 -77
  124. package/ui/forge_ui/static/projectsview.js +16 -2
  125. package/ui/forge_ui/static/runmodel.js +18 -4
  126. package/ui/forge_ui/static/scene3d.js +29 -29
  127. package/ui/forge_ui/static/settings.js +1 -1
  128. package/ui/forge_ui/static/storageview.js +2 -2
  129. package/ui/forge_ui/static/style.css +23 -6
  130. package/ui/forge_ui/static/worktreesview.js +8 -4
  131. package/ui/forge_ui/transcripts.py +6 -0
  132. package/ui/forge_ui/worktrees.py +13 -1
  133. package/docs/fractal.md +0 -181
  134. package/references/fractal-dashboard.md +0 -21
  135. package/references/fractal.md +0 -307
  136. package/scripts/forge-fractal-dispatch.sh +0 -4
  137. package/scripts/forge-fractal-options.sh +0 -54
  138. package/scripts/forge-fractal.py +0 -6
  139. package/scripts/forge-install-fractal.sh +0 -4
  140. package/scripts/forge_fractal/__init__.py +0 -88
  141. package/scripts/forge_fractal/bridge.py +0 -46
  142. package/scripts/forge_fractal/cli.py +0 -224
  143. package/scripts/forge_fractal/dashboard.css +0 -138
  144. package/scripts/forge_fractal/dashboard.html +0 -41
  145. package/scripts/forge_fractal/dashboard.js +0 -687
  146. package/scripts/forge_fractal/decomposition.py +0 -262
  147. package/scripts/forge_fractal/execution.py +0 -659
  148. package/scripts/forge_fractal/inspection.py +0 -261
  149. package/scripts/forge_fractal/install.py +0 -158
  150. package/scripts/forge_fractal/invocation.py +0 -95
  151. package/scripts/forge_fractal/pipeline.py +0 -125
  152. package/scripts/forge_fractal/selection.py +0 -180
  153. package/ui/forge_ui/fractal.py +0 -582
@@ -306,6 +306,7 @@ def validate_body(body):
306
306
  shapes = {'set': ({'action', 'key', 'value', 'task'}, ('key', 'value')),
307
307
  'pin': ({'action', 'task', 'spec'}, ('task', 'spec')),
308
308
  'unpin': ({'action', 'task'}, ('task',)),
309
+ 'models': ({'action', 'tier', 'dwarf', 'qa'}, ('tier',)),
309
310
  'retry': ({'action', 'task', 'dwarf'}, ('task',)),
310
311
  'drain': ({'action'}, ()),
311
312
  'resume': ({'action'}, ()),
@@ -321,6 +322,12 @@ def validate_body(body):
321
322
  tail += ['--task', _text(body, 'task')]
322
323
  if action == 'retry' and 'dwarf' in body:
323
324
  tail += ['--dwarf', _text(body, 'dwarf')]
325
+ if action == 'models':
326
+ if 'dwarf' not in body and 'qa' not in body:
327
+ raise BadBody('models needs dwarf, qa or both')
328
+ for role in ('dwarf', 'qa'):
329
+ if role in body:
330
+ tail += ['--' + role, _text(body, role)]
324
331
  if action == 'stop' and 'now' in body:
325
332
  if not isinstance(body['now'], bool):
326
333
  raise BadBody('now must be true or false')
@@ -1452,6 +1459,43 @@ def _scheduler_live(path):
1452
1459
  return forge_proc.pid_alive(pid)
1453
1460
 
1454
1461
 
1462
+ def _task_text(ctx, allowed=('text',)):
1463
+ """The stripped `text` of a task message body as UTF-8 bytes (an answer, a steer message), or BadBody."""
1464
+ body = _body_object(ctx, allowed)
1465
+ text = body.get('text')
1466
+ if not isinstance(text, str):
1467
+ raise BadBody('text must be a string')
1468
+ text = text.strip()
1469
+ if '\x00' in text:
1470
+ raise BadBody('text must not contain a NUL')
1471
+ if not 1 <= len(text) <= MAX_TASK_ANSWER:
1472
+ raise BadBody(f'text must be 1 to {MAX_TASK_ANSWER} characters')
1473
+ try:
1474
+ return text.encode('utf-8')
1475
+ except UnicodeEncodeError:
1476
+ raise BadBody('text must be valid text')
1477
+
1478
+
1479
+ def _task_steer(ctx):
1480
+ """POST `{text, now?}`: `forge control steer <plan> <id> --file - --actor ui --json`, the text on stdin (#134).
1481
+ The message waits in the task's steer.jsonl for its next implementer attempt; nothing is started. With `now`
1482
+ true it goes to the running implementer instead (#252: `--now`), refused when none runs live."""
1483
+ ctx.route = 'steer'
1484
+ task = ctx.parts[0]
1485
+ try:
1486
+ stdin = _task_text(ctx, ('text', 'now'))
1487
+ now = ctx.body.get('now', False)
1488
+ if not isinstance(now, bool):
1489
+ raise BadBody('now must be true or false')
1490
+ except BadBody as exc:
1491
+ return _invalid(str(exc))
1492
+ path = ctx.locate(('plan',))
1493
+ if path is None:
1494
+ return 404, {'error': 'not found'}
1495
+ return ctx.locked(lambda: ctx.call('control', 'steer', path, task, '--file', '-', '--actor', 'ui', '--json',
1496
+ *(('--now',) if now else ()), stdin=stdin))
1497
+
1498
+
1455
1499
  def _task_answer(ctx):
1456
1500
  """POST `{text}`: `forge control retry <plan> <id> --answer-file - --actor ui --json`, the text on stdin.
1457
1501
 
@@ -1459,19 +1503,7 @@ def _task_answer(ctx):
1459
1503
  ctx.route = 'answer'
1460
1504
  task = ctx.parts[0]
1461
1505
  try:
1462
- body = _body_object(ctx, ('text',))
1463
- text = body.get('text')
1464
- if not isinstance(text, str):
1465
- raise BadBody('text must be a string')
1466
- text = text.strip()
1467
- if '\x00' in text:
1468
- raise BadBody('text must not contain a NUL')
1469
- if not 1 <= len(text) <= MAX_TASK_ANSWER:
1470
- raise BadBody(f'text must be 1 to {MAX_TASK_ANSWER} characters')
1471
- try:
1472
- stdin = text.encode('utf-8')
1473
- except UnicodeEncodeError:
1474
- raise BadBody('text must be valid text')
1506
+ stdin = _task_text(ctx)
1475
1507
  except BadBody as exc:
1476
1508
  return _invalid(str(exc))
1477
1509
  path = ctx.locate(('plan',))
@@ -1646,7 +1678,6 @@ def _findings_action(ctx):
1646
1678
  `--text-file`). `findings_lock` makes a second write 409 `busy`. Exit 3 is 409 with the CLI's
1647
1679
  message. A successful call drops the project screen's issues listings and its run cache.
1648
1680
  """
1649
- from forge_ui import projects
1650
1681
  op = ctx.parts[0]
1651
1682
  ctx.route = 'findings ' + op
1652
1683
  try:
@@ -1971,6 +2002,7 @@ ROUTES = [
1971
2002
  ('POST', re.compile(r'/api/runs/([0-9a-f]{12})/issues/dismiss'), _issues_dismiss),
1972
2003
  ('POST', re.compile(r'/api/runs/([0-9a-f]{12})/delete'), _delete),
1973
2004
  ('POST', re.compile(r'/api/runs/([0-9a-f]{12})/tasks/([A-Za-z0-9][A-Za-z0-9._-]{0,127})/answer'), _task_answer),
2005
+ ('POST', re.compile(r'/api/runs/([0-9a-f]{12})/tasks/([A-Za-z0-9][A-Za-z0-9._-]{0,127})/steer'), _task_steer),
1974
2006
  ('POST', re.compile(r'/api/worktrees/remove()'), _worktrees_remove),
1975
2007
  ('POST', re.compile(r'/api/storage/compact()'), _storage_compact),
1976
2008
  ('POST', re.compile(r'/api/projects/([0-9a-f]{8})/memories/forget'), _memories_forget),
@@ -17,7 +17,6 @@ import base64
17
17
  import hashlib
18
18
  import json
19
19
  import os
20
- from pathlib import Path
21
20
  import re
22
21
  import time
23
22
  import urllib.parse
@@ -225,15 +224,6 @@ def build(catalog, key, texts=False, paths=False, now=None):
225
224
  snap.add(f'{base}/adoptions/{_enc(name)}')
226
225
  snap.add(f'{base}/files')
227
226
  snap.add(f'{base}/findings')
228
- fractal = run.get('fractal') or {}
229
- if fractal.get('enabled') and fractal.get('available'):
230
- for task in tasks:
231
- tree = snap.add(f"{base}/tasks/{_enc(task['id'])}/fractal")
232
- for node in (tree or {}).get('nodes') or []:
233
- if isinstance(node, dict) and node.get('id') and not node.get('reserved'):
234
- snap.add(f"{base}/tasks/{_enc(task['id'])}/fractal/nodes/{_enc(node['id'])}")
235
- if texts and node.get('has_diff'):
236
- snap.add(f"{base}/tasks/{_enc(task['id'])}/fractal/nodes/{_enc(node['id'])}/diff", cap=DIFF_CAP)
237
227
  if texts:
238
228
  # every diff a page of this run can open: each task's files and each review's, the final reviews'
239
229
  for task in tasks:
@@ -261,6 +261,19 @@ def _attempts(rows, execs, plan_spec):
261
261
  return result
262
262
 
263
263
 
264
+ def _censor_steered(attempts, rd, base):
265
+ """A person's message (#134: `forge control steer`) went into an attempt: from it on, the task's attempts say
266
+ nothing about the implementer alone, so they are censored, as forge dataset leaves them out."""
267
+ marked = [row['n'] for row in attempts if reader._nonempty(rd, f"{base}/steered.{row['n']}.jsonl")]
268
+ if not marked:
269
+ return attempts
270
+ first = min(marked)
271
+ for row in attempts:
272
+ if row['n'] >= first:
273
+ row['outcome'], row['reason'], row['gate'], row['gate_fail'] = 'censored', 'steered', False, False
274
+ return attempts
275
+
276
+
264
277
  def _route(rd, base):
265
278
  explored, propensity = rd.exists(base + '/route.explored'), None
266
279
  for n, line in enumerate((rd.text(base + '/route.jsonl') or '').splitlines(), 1):
@@ -322,8 +335,8 @@ def _facts(path, summary, root):
322
335
  tasks.append(dict(base_row, task=task['id'], kind='plan', difficulty=task['difficulty'] or None,
323
336
  explored=explored, propensity=propensity, final_status=task['status'],
324
337
  accepted=reader._nonempty(rd, base + '/accepted.by'),
325
- attempts=[] if scripted else _attempts(_attempt_rows(rd, base + '/attempts.tsv'), execs,
326
- task['dwarf']),
338
+ attempts=[] if scripted else _censor_steered(
339
+ _attempts(_attempt_rows(rd, base + '/attempts.tsv'), execs, task['dwarf']), rd, base),
327
340
  escalations=[{'n': item['attempt'], 'from': item['from'], 'to': item['to']}
328
341
  for item in reader._history(rd, base + '/escalations.tsv', True)]))
329
342
  reviews += _reviews(key, task['id'], execs, shadows)
@@ -573,7 +573,8 @@ class Screen:
573
573
  listing, at = self._cli_unlocked_at(('issues', path, True), lambda: _issues_call(issues, path, True),
574
574
  refresh, now)
575
575
  if listing is not None:
576
- return listing, True, at
576
+ # a repository with no GitHub name lists without asking GitHub, online or not (#174)
577
+ return listing, not (isinstance(listing, dict) and listing.get('online') is False), at
577
578
  online_failed = True
578
579
  listing, at = self._cli_unlocked_at(('issues', path, False), lambda: _issues_call(issues, path, False),
579
580
  refresh, now)
@@ -638,6 +639,8 @@ class Screen:
638
639
  notes.append('the dataset is off (FORGE_DATASET=off): only the run directories that still exist are read')
639
640
  if listing is None:
640
641
  notes.append('forge issues could not be read: dismissed and filed findings show as open')
642
+ elif not online and isinstance(listing, dict) and listing.get('online') is False and not listing.get('repo'):
643
+ notes.append('the repository has no GitHub remote: issue states were not read from GitHub')
641
644
  elif not online:
642
645
  notes.append('issue states could not be read from GitHub: filed findings may show as open')
643
646
  if modules is None or record is None: