@giamme/forge 0.19.0 → 0.20.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/ui/docs/api.md CHANGED
@@ -305,11 +305,26 @@ its last 20,000 behind a leading `…`. Their `truncated` lists the field names
305
305
  | `POST /api/runs/<key>/tasks/<id>/answer` | answer a task that waits for input (`forge control retry … --answer-file -`); authenticated, see Controls |
306
306
  | `POST /api/worktrees/remove` | remove chosen worktrees (`forge worktrees rm`); authenticated, 900 s timeout |
307
307
  | `POST /api/projects/<id>/memories/forget` | forget learnings in a project's checkouts (`forge memory forget`); authenticated |
308
+ | `POST /api/projects/<id>/memories/add` | add a learning in a project's checkouts (`forge memory add`); body `{path?, category, text, paths?}`; authenticated |
309
+ | `POST /api/projects/<id>/memories/edit` | replace a learning's text in a project's checkouts (`forge memory edit`); body `{path?, key, text}`; authenticated |
310
+ | `POST /api/projects/<id>/findings/fix` | mark findings fixed (`forge findings fix`); body `{fps, commit?, reason?}`; authenticated |
311
+ | `POST /api/projects/<id>/findings/dismiss` | dismiss findings (`forge findings dismiss`); body `{fps, reason}`; authenticated |
312
+ | `POST /api/projects/<id>/findings/reopen` | reopen findings (`forge findings reopen`); body `{fps}`; authenticated |
313
+ | `POST /api/projects/<id>/findings/to-file` | mark findings to-file and keep a draft (`forge findings to-file`); body `{fps, title?, body?}`; authenticated |
314
+ | `POST /api/projects/<id>/findings/dup` | mark one finding a duplicate (`forge findings dup`); body `{fps: [one], of}`; authenticated |
315
+ | `POST /api/projects/<id>/findings/tag` | add or remove tags (`forge findings tag`); body `{fps, tags, remove?}`; authenticated |
316
+ | `POST /api/projects/<id>/findings/note` | set or clear one finding's note (`forge findings note`); body `{fps: [one], text}`; authenticated |
317
+ | `POST /api/projects/<id>/findings/edit` | edit one finding's severity or text (`forge findings edit`); body `{fps: [one], severity?, text?}`; authenticated |
318
+ | `POST /api/projects/<id>/triage` | start a detached triage (`forge findings triage --spec S --detach`); body `{spec, max_findings?}`; authenticated |
319
+ | `GET /api/projects/<id>/triage[?n=N]` | `200 {state, proposals}` from `forge findings triage-status` and `proposals`, read each time |
320
+ | `POST /api/projects/<id>/triage/<n>/<pid>/apply` | approve one proposal (`forge findings apply --approve HASH`); body `{hash, plan_dir?}`; authenticated |
321
+ | `POST /api/projects/<id>/triage/<n>/<pid>/reject` | reject one proposal (`forge findings reject`); body `{reason?}`; authenticated |
322
+ | `GET /api/specs/check?spec=S` | `200 {ok: true, resolved}` or `{ok: false, error}` from `bash scripts/forge-dispatch.sh doctor --spec S --role side`; no model call; answered in read-only mode |
308
323
  | `POST /api/storage/compact` | compact one run or all (`forge runs compact --logs`); authenticated, 900 s timeout |
309
324
  | `GET /api/models/reviewers` | `200` the `forge dataset reviewers --json` report (how each reviewer's PASSed work held up); no parameters |
310
325
  | `GET /api/projects` | `200 {projects: [ProjectRow]}`: one row per repository (see Projects) |
311
326
  | `GET /api/projects/<id>` | `200 Project`, `404` for an unknown id |
312
- | `GET /api/projects/<id>/findings[?refresh=1]` | `200 ProjectFindings`: every review's findings with their status |
327
+ | `GET /api/projects/<id>/findings[?refresh=1]` | `200 ProjectFindings`: every review's findings with status, tags, record and draft |
313
328
  | `GET /api/projects/<id>/memories[?refresh=1]` | `200 ProjectMemories`: what each checkout's memory gives models and every learning's state |
314
329
  | `GET /api/worktrees[?refresh=1]` | `200 Worktrees`: every worktree forge created, with its status and the commands to remove it; cached 60 s (see Worktrees) |
315
330
  | `GET /api/storage[?refresh=1]` | `200 Storage`: what forge takes on disk and the commands that take it back, measured in the background; cached 600 s (see Storage) |
@@ -1772,6 +1787,93 @@ false; when every checkout failed the first failure is the answer. A project wit
1772
1787
  checkout is `409`. A server-wide lock (`409 busy`); timeout 60 s per checkout. A real forget drops
1773
1788
  the project screen's memory answers. Refused under `--read-only` and without the token.
1774
1789
 
1790
+ ### `POST /api/projects/<id>/memories/add` and `/memories/edit`
1791
+
1792
+ The project is `<id>` of `GET /api/projects` (`404` when unknown). Without `path` the call runs in every
1793
+ checkout of the project that exists; `path` must be one of them (`400` otherwise). A project with no
1794
+ existing checkout is `409`.
1795
+
1796
+ `add` body: `{"path": string, "category": "verify"|"trap"|"finding", "text": string, "paths": [string]}`.
1797
+ `text` is one line of 1 to 300 characters with no control character. `paths` is at most 20 relative
1798
+ paths (no `..`, no comma, no `[` or `]`, each at most 300 characters); omit it or pass `[]` for none.
1799
+ Runs `memory add <checkout> --category C --text T [--path P]… --actor ui --json` once per checkout.
1800
+
1801
+ `edit` body: `{"path": string, "key": "category:key", "text": string}`, the same text rule. Runs
1802
+ `memory edit <checkout> <key> --text T --actor ui --json` once per checkout. The route takes no
1803
+ `paths` field.
1804
+
1805
+ Both answer `200 {"ok", "checkouts": [{"path", "result"}]}`, `result` being that CLI's object. A
1806
+ checkout whose call failed has `result: null` plus `status` and `error`, and `ok` is false; when
1807
+ every checkout failed the first failure is the answer. A server-wide lock (`409 busy`); timeout 60 s
1808
+ per checkout. The project screen's memory answers are dropped after the calls. Refused under
1809
+ `--read-only` and without the token.
1810
+
1811
+ ### `POST /api/projects/<id>/findings/<op>`
1812
+
1813
+ `<op>` is `fix`, `dismiss`, `reopen`, `to-file`, `dup`, `tag`, `note` or `edit`. The project is `<id>`
1814
+ of `GET /api/projects` (`404` when unknown, or when it has no root). Runs `findings <op> <root> … --actor
1815
+ ui --json`. `dup`, `note` and `edit` take exactly one fingerprint; the others take 1 to 200, and a
1816
+ repeated fingerprint is one finding. Every fingerprint is 12 lowercase hex characters. `200` with the
1817
+ CLI's object (`ok`, `op`, `changed`, `unchanged`). Exit 2 is `400`, exit 3 is `409` with the CLI's
1818
+ message. A server-wide findings lock (`409 {"error": "busy"}`); timeout 60 s. A successful call drops
1819
+ the project screen's findings listings and its run cache. Refused under `--read-only` and without the
1820
+ token. Unknown fields are `400`.
1821
+
1822
+ | `<op>` | Body | What the CLI receives |
1823
+ | --- | --- | --- |
1824
+ | `fix` | `{fps, commit?, reason?}`. At least one of `commit` (7 to 40 lowercase hex) and `reason` (at most 500 characters, no NUL) | `--commit`, `--reason` |
1825
+ | `dismiss` | `{fps, reason}` (`reason` required, same limit) | `--reason` |
1826
+ | `reopen` | `{fps}` | the fingerprints only |
1827
+ | `to-file` | `{fps, title?, body?}`. `title` at most 200 characters, no NUL. `body` at most 20000 characters, written to a private file | `--title`, `--body-file` |
1828
+ | `dup` | `{fps: [one], of}` (`of` is 12 lowercase hex) | `--of` |
1829
+ | `tag` | `{fps, tags, remove?}`. `tags` is 1 to 8 values matching `^[a-z][a-z0-9-]{0,23}$`. `remove` true selects `--remove`, otherwise `--add` | `-- TAG… --add` or `-- TAG… --remove` |
1830
+ | `note` | `{fps: [one], text}` (`text` at most 2000 characters, no NUL; empty clears the note) | the text as the positional argument |
1831
+ | `edit` | `{fps: [one], severity?, text?}`. At least one. `severity` is `P0`, `P1`, `P2` or `P3`. `text` at most 4000 characters, written to a private file | `--severity`, `--text-file` |
1832
+
1833
+ ### `POST /api/projects/<id>/triage`, `GET /api/projects/<id>/triage`, apply and reject
1834
+
1835
+ The repository is the project's root when that directory exists, otherwise the first checkout that
1836
+ still exists. An unknown project is `404 {"error": "not found"}`; a project with no directory left
1837
+ on this machine is `404 {"error": "no checkout"}`.
1838
+
1839
+ `POST /api/projects/<id>/triage` body: `{"spec": string, "max_findings": int}`. `spec` is 1 to 120
1840
+ characters of letters, digits and `. _ : / @ + -`. `max_findings`, when present, is an integer from
1841
+ 1 to 2000. Runs `findings triage <repo> --spec S [--max-findings N] --detach --actor ui --json` and
1842
+ answers `200` with the CLI's object (`triage`, `state`). `--detach` returns at once; this is the one
1843
+ route whose CLI starts a model. Exit 3 is `409` with the CLI's message. It does not take the findings
1844
+ lock. Timeout 60 s. Refused under `--read-only` and without the token.
1845
+
1846
+ `GET /api/projects/<id>/triage[?n=N]` runs `findings triage-status <repo> [N] --json` and `findings
1847
+ proposals <repo> [N] --json` on every request, with no cache. `N` is 1 to 9 digits. No triage yet
1848
+ (the status command exits 3 with that message) is `200 {"state": null, "proposals": null}`. A triage
1849
+ with no proposals yet leaves `proposals` null and still returns the state. Any other query parameter
1850
+ is `400`. Read-only servers answer this GET. Timeout 60 s per CLI call.
1851
+
1852
+ `POST …/triage/<n>/<pid>/apply` body: `{"hash": string, "plan_dir": string}`. `<n>` is 1 to 9 digits,
1853
+ `<pid>` matches `^p[0-9]{1,4}$`, and `hash` is 12 lowercase hex characters (the proposal's hash; a
1854
+ mismatch is the CLI's refusal). `plan_dir`, when present, is an absolute path. Runs `findings apply
1855
+ <repo> N PID --approve HASH [--plan-dir D] --actor ui --json`. `200` with the CLI's object. For a
1856
+ `plan` proposal that object carries `plan_dir` and `next` (`bash scripts/forge-parallel.sh plan DIR
1857
+ --repo CHECKOUT`); nothing is dispatched. An `issue` proposal only marks findings `to-file` with the
1858
+ draft.
1859
+
1860
+ `POST …/triage/<n>/<pid>/reject` body: `{"reason": string}`. `reason`, when present, is at most 500
1861
+ characters (newline and tab allowed; blank is omitted). Runs `findings reject <repo> N PID [--reason
1862
+ T] --actor ui --json`.
1863
+
1864
+ Apply and reject hold the server-wide findings lock (`409 {"error": "busy"}`). Exit 2 is `400`, exit
1865
+ 3 is `409` with the CLI's message. A successful call drops the project screen's findings listings and
1866
+ its run cache. Timeout 60 s. Refused under `--read-only` and without the token.
1867
+
1868
+ ### `GET /api/specs/check?spec=S`
1869
+
1870
+ Runs `bash scripts/forge-dispatch.sh doctor --spec S --role side` and answers `200 {"ok": true,
1871
+ "resolved": {key: value}}` from the doctor's `key=value` lines, or `200 {"ok": false, "error"}` when
1872
+ the doctor refuses. The check finished either way; no model is called. `spec` is required and uses
1873
+ the same 1-to-120-character check as triage start: a spec that fails it is `400` and the doctor is
1874
+ not run. A literal `+` in the query is a plus. Any other query parameter is `400`. Read-only servers
1875
+ answer this GET. Timeout 60 s.
1876
+
1775
1877
  ### `POST /api/storage/compact`
1776
1878
 
1777
1879
  Body: `{"run": "<12-hex run key>"}` or `{"all": true}` (exactly one), and `"dry_run": bool (false)`.
@@ -1810,14 +1912,20 @@ cloud's (cloudmodel.js `hashId`: FNV-1a over the root's UTF-16 code units, 8 hex
1810
1912
 
1811
1913
  ```
1812
1914
  ProjectRow = {id, name, root, exists, runs, live, last, path_only (runs tied by path only), checkouts,
1813
- memory_lines (lines of <root>/.forge/memory.md, null when absent), open_findings (not superseded)}
1915
+ memory_lines (lines of <root>/.forge/memory.md, null when absent),
1916
+ open_findings (rows the record and the review rules call open or to-file; this list does not
1917
+ ask GitHub, so a filed or swept finding can still be counted)}
1814
1918
  Project = {id, name, root, exists, live, last, path_only, memory_off_runs,
1815
1919
  checkouts: [{path, exists, branch, runs, root}], runs: [RunSummary + identity_source, dataset_uid, no_memory]}
1816
- ProjectFindings = {id, rows: [Finding], notes: [text], runs, dataset_runs, computed, available}
1920
+ ProjectFindings = {id, rows: [Finding], notes: [text], runs, dataset_runs, computed, available,
1921
+ issues_online (true when that listing was the online one), issues_read_at (unix time the listing was read, or null)}
1817
1922
  Finding = {source: run|dataset, run (key or null), run_id, task, final_review (its dir name, 'final' from the
1818
1923
  dataset), attempt, kind: primary|shadow|final, reviewer, verdict, at, id, severity, confidence, location,
1819
- summary, text, fp (forge issues' key, null when it cannot parse the line), count, occurrences: [{run,
1820
- run_id, task, attempt, kind, reviewer, at, href}], status, fileable, origin, href (the diff at the finding)}
1924
+ summary, text, fp (forge issues' key, null when it cannot parse the line), record_fp (the finding
1925
+ record's 12-hex key, or null when the row cannot be keyed), record (that record entry, or null),
1926
+ tags (the entry's tags, or the default for the path when none are stored), draft (the to-file
1927
+ draft, or null), count, occurrences: [{run, run_id, task, attempt, kind, reviewer, at, href}],
1928
+ status, fileable, origin, href (the diff at the finding)}
1821
1929
  ProjectMemories = {id, sources: [{path, root, branch, ok, ledger, memory, rebuilt_differs, max_lines}], differs,
1822
1930
  learnings: [{category, key, text, count, states: {source path: state}, rows, last, dataset_only}],
1823
1931
  notes, memory_off_runs, runs, computed}
@@ -1825,13 +1933,23 @@ ProjectMemories = {id, sources: [{path, root, branch, ok, ledger, memory, rebuil
1825
1933
 
1826
1934
  Findings come from every review of every run dir (parsed by forge-contract.py through `findings.py`), and
1827
1935
  from `dataset history --json` for runs whose dir is gone (their base commit ties a run whose checkout is
1828
- gone to the project, as `repos.py` does). `status` comes from one `issues <run> --json --offline --all-runs
1829
- --include-plausible --include-dismissed` listing per project, matched by `forge issues`' own key, else
1830
- `superseded` when a later review of the same task (or a later final review) passed, else `open`. Repeats
1831
- within a task collapse by that key; a line it cannot parse is its own row. Memories run `memory learnings
1832
- <checkout> --json` for the root and each checkout a run started in that still exists. A run's findings
1833
- are cached by its `updated` time, the CLI's answers for 300 s; `refresh=1` reads everything again; any
1834
- other parameter is a `400`.
1936
+ gone to the project, as `repos.py` does). Repeats within a task collapse by `forge issues`' own key; a
1937
+ line it cannot parse is its own row. `status` is `forge_findings.status.effective`: the record when it is
1938
+ `duplicate`, `dismissed`, `fixed`, `filed` or `to-file`; otherwise the `forge issues` entry (filed and
1939
+ `CLOSED` is `fixed`, any other filed issue is `filed`, and, unless the record reopened it, swept is
1940
+ `swept` and an old dismissal is `dismissed`); otherwise the review row (`shadow`, `unlabelled` when the
1941
+ confidence is `UNSTATED`, `superseded` when a later review of the same task or a later final review
1942
+ passed); otherwise `open`. Only `open` and `to-file` count as open. `tags` are the record's tags when it
1943
+ has any, otherwise the default for the file (`tests`, `docs`, `infra`, `ui` or `backend`; no path gives
1944
+ none). `draft` is the record entry's draft, or null. The issues listing is `issues <path> --json
1945
+ --all-runs --include-plausible --include-dismissed`, asked of the repository root first and then of up
1946
+ to three of its run dirs: online (no `--offline`, so GitHub can say an issue is closed), and with
1947
+ `--offline` when that fails or takes over 60 s. `notes` says
1948
+ when the dataset, `forge issues` or the finding record could not be read, and when issue states were not
1949
+ read from GitHub (a filed finding may then show as open). Memories run `memory learnings <checkout>
1950
+ --json` for the root and each checkout a run started in that still exists. A run's findings are cached
1951
+ by its `updated` time, the CLI's answers for 300 s; `refresh=1` reads everything again; any other
1952
+ parameter is a `400`.
1835
1953
 
1836
1954
  ### `GET /api/worktrees`
1837
1955