@giamme/forge 0.15.0 → 0.16.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 (63) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/VERSION +1 -1
  3. package/docs/artifacts.md +1 -1
  4. package/docs/commands.md +14 -3
  5. package/docs/forge-ui.md +14 -0
  6. package/docs/memory.md +22 -0
  7. package/docs/reviews.md +7 -0
  8. package/forge +11 -0
  9. package/package.json +1 -1
  10. package/references/dataset.md +5 -2
  11. package/references/decompose.md +51 -5
  12. package/references/harnesses.md +4 -1
  13. package/references/solo.md +5 -1
  14. package/references/ui.md +10 -1
  15. package/scripts/forge-artifact.sh +53 -0
  16. package/scripts/forge-contract.py +55 -8
  17. package/scripts/forge-control.py +0 -2
  18. package/scripts/forge-dispatch.sh +28 -12
  19. package/scripts/forge-fail-first.py +3 -1
  20. package/scripts/forge-guard.py +247 -8
  21. package/scripts/forge-issues.py +12 -0
  22. package/scripts/forge-lib-adopt.sh +260 -0
  23. package/scripts/forge-lib-attribute.sh +10 -2
  24. package/scripts/forge-lib-plans.sh +16 -4
  25. package/scripts/forge-lib-review.sh +8 -2
  26. package/scripts/forge-lib-task.sh +19 -5
  27. package/scripts/forge-memory.sh +41 -4
  28. package/scripts/forge-metrics.sh +7 -0
  29. package/scripts/forge-parallel.sh +96 -13
  30. package/scripts/forge-route.py +16 -2
  31. package/scripts/forge-runs-rm.py +23 -7
  32. package/scripts/forge-runtime.py +25 -2
  33. package/scripts/forge-schedule.py +5 -2
  34. package/scripts/forge-shadow.py +2 -0
  35. package/scripts/forge-solo.sh +6 -0
  36. package/scripts/forge_dataset/cli.py +16 -0
  37. package/scripts/forge_dataset/export.py +1 -0
  38. package/scripts/forge_dataset/harvest.py +11 -0
  39. package/scripts/forge_dataset/history.py +126 -0
  40. package/scripts/forge_dataset/worktrees.py +95 -0
  41. package/scripts/forge_memory_list.py +153 -0
  42. package/scripts/forge_worktrees.py +88 -0
  43. package/ui/README.md +31 -0
  44. package/ui/docs/api.md +81 -4
  45. package/ui/forge_ui/__init__.py +14 -1
  46. package/ui/forge_ui/__main__.py +1 -1
  47. package/ui/forge_ui/control.py +77 -0
  48. package/ui/forge_ui/findings.py +7 -0
  49. package/ui/forge_ui/projects.py +571 -0
  50. package/ui/forge_ui/reader.py +27 -7
  51. package/ui/forge_ui/static/app.js +99 -21
  52. package/ui/forge_ui/static/cloudui.js +6 -2
  53. package/ui/forge_ui/static/convo.js +1 -1
  54. package/ui/forge_ui/static/diffview.js +2 -2
  55. package/ui/forge_ui/static/files.js +1 -1
  56. package/ui/forge_ui/static/index.html +5 -1
  57. package/ui/forge_ui/static/panel.js +28 -2
  58. package/ui/forge_ui/static/projectsview.js +372 -0
  59. package/ui/forge_ui/static/settings.js +136 -4
  60. package/ui/forge_ui/static/style.css +93 -3
  61. package/ui/forge_ui/static/uikit.js +94 -1
  62. package/ui/forge_ui/static/worktreesview.js +250 -0
  63. package/ui/forge_ui/worktrees.py +570 -0
@@ -4,7 +4,20 @@ from __future__ import annotations
4
4
  import hashlib
5
5
  from pathlib import Path
6
6
 
7
- __version__ = '0.4.0'
7
+ # forge's own version: this package ships inside forge, and two numbers could only disagree. What a
8
+ # running server reports is what it started with, which an upgrade underneath it does not change.
9
+ VERSION_FILE = Path(__file__).resolve().parents[2] / 'VERSION'
10
+
11
+
12
+ def read_version(path=VERSION_FILE):
13
+ """The first line of forge's VERSION file, or None when it cannot be read."""
14
+ try:
15
+ return Path(path).read_text(encoding='utf-8').split('\n', 1)[0].strip() or None
16
+ except (OSError, ValueError):
17
+ return None
18
+
19
+
20
+ __version__ = read_version()
8
21
 
9
22
 
10
23
  def build_id():
@@ -38,7 +38,7 @@ def _parser():
38
38
  parser.add_argument('--read-only', action='store_true',
39
39
  help='answer no write at all (also FORGE_UI_READONLY=1); the page shows no controls')
40
40
  parser.add_argument('--open', action='store_true', help='open the page in the browser once started')
41
- parser.add_argument('--version', action='version', version=f'forge-ui {__version__}')
41
+ parser.add_argument('--version', action='version', version=f'forge-ui {__version__ or "unknown"}')
42
42
  return parser
43
43
 
44
44
 
@@ -784,6 +784,78 @@ def _reviewer_outcomes(ctx):
784
784
  return ctx.call('dataset', 'reviewers', '--json')
785
785
 
786
786
 
787
+ def _project_call(ctx, *args):
788
+ status, body = ctx.call(*args)
789
+ return body if status == 200 else None
790
+
791
+
792
+ def _projects(ctx):
793
+ # The Projects screen (#126): forge_ui/projects.py, which reads run dirs here and the rest through the CLI.
794
+ from forge_ui import projects
795
+ ctx.route = 'projects'
796
+ try:
797
+ _query_params(ctx.query, ())
798
+ except BadBody as exc:
799
+ return _invalid(str(exc))
800
+ return 200, projects.screen(ctx.server).listing(ctx.server.catalog)
801
+
802
+
803
+ def _project(ctx):
804
+ from forge_ui import projects
805
+ ctx.route = 'project'
806
+ try:
807
+ _query_params(ctx.query, ())
808
+ except BadBody as exc:
809
+ return _invalid(str(exc))
810
+ found = projects.screen(ctx.server).detail(ctx.server.catalog, ctx.key)
811
+ return (404, {'error': 'not found'}) if found is None else (200, found)
812
+
813
+
814
+ def _project_findings(ctx):
815
+ from forge_ui import projects
816
+ ctx.route = 'project findings'
817
+ try:
818
+ refresh = _bit(_query_params(ctx.query, ('refresh',)), 'refresh')
819
+ except BadBody as exc:
820
+ return _invalid(str(exc))
821
+ # --offline: no gh call; the listing says which findings are dismissed, filed (as recorded) or swept.
822
+ found = projects.screen(ctx.server).findings(
823
+ ctx.server.catalog, ctx.key, lambda: _project_call(ctx, 'dataset', 'history', '--json'),
824
+ lambda path: _project_call(ctx, 'issues', path, '--json', '--offline', '--all-runs', '--include-plausible',
825
+ '--include-dismissed'), refresh=refresh)
826
+ return (404, {'error': 'not found'}) if found is None else (200, found)
827
+
828
+
829
+ def _project_memories(ctx):
830
+ from forge_ui import projects
831
+ ctx.route = 'project memories'
832
+ try:
833
+ refresh = _bit(_query_params(ctx.query, ('refresh',)), 'refresh')
834
+ except BadBody as exc:
835
+ return _invalid(str(exc))
836
+ found = projects.screen(ctx.server).memories(
837
+ ctx.server.catalog, ctx.key, lambda path: _project_call(ctx, 'memory', 'learnings', path, '--json'),
838
+ lambda: _project_call(ctx, 'dataset', 'history', '--json'), refresh=refresh)
839
+ return (404, {'error': 'not found'}) if found is None else (200, found)
840
+
841
+
842
+ def _worktrees(ctx):
843
+ # The Worktrees screen (#125): git and the run dirs, read here, plus the history `forge dataset worktrees`
844
+ # keeps, read through the CLI. Cached per server (worktrees.CACHE_S); ?refresh=1 reads everything again.
845
+ from forge_ui import worktrees
846
+ ctx.route = 'worktrees'
847
+ try:
848
+ params = _query_params(ctx.query, ('refresh',))
849
+ refresh = _bit(params, 'refresh')
850
+ except BadBody as exc:
851
+ return _invalid(str(exc))
852
+
853
+ def history():
854
+ status, body = ctx.call('dataset', 'worktrees', '--json')
855
+ return body if status == 200 else None
856
+ return 200, worktrees.screen(ctx.server).answer(ctx.server.catalog, history, refresh=refresh)
857
+
858
+
787
859
  ROUTES = [
788
860
  ('GET', re.compile(r'/api/runs/([0-9a-f]{12})/controls'), _show),
789
861
  ('POST', re.compile(r'/api/runs/([0-9a-f]{12})/controls'), _change),
@@ -796,6 +868,11 @@ ROUTES = [
796
868
  ('GET', re.compile(r'/api/config()'), _config_get),
797
869
  ('POST', re.compile(r'/api/config()'), _config_set),
798
870
  ('GET', re.compile(r'/api/models/reviewers()'), _reviewer_outcomes),
871
+ ('GET', re.compile(r'/api/worktrees()'), _worktrees),
872
+ ('GET', re.compile(r'/api/projects()'), _projects),
873
+ ('GET', re.compile(r'/api/projects/([0-9a-f]{8})'), _project),
874
+ ('GET', re.compile(r'/api/projects/([0-9a-f]{8})/findings'), _project_findings),
875
+ ('GET', re.compile(r'/api/projects/([0-9a-f]{8})/memories'), _project_memories),
799
876
  ]
800
877
 
801
878
 
@@ -116,6 +116,13 @@ def listing(text, limit=200):
116
116
  return result
117
117
 
118
118
 
119
+ def tests(text):
120
+ """What the reply says about its tests (forge-contract.py's tests_report), or None."""
121
+ module = _load()
122
+ report = getattr(module, 'tests_report', None)
123
+ return report(text[:_MAX_CHARS]) if report and text else None
124
+
125
+
119
126
  def parse_gate(text):
120
127
  """A qa.gate line: threshold, decision, worst, n_confirmed, n_unlabelled, n_below; None if malformed."""
121
128
  line = next((item for item in (text or '').splitlines() if item.strip()), None)