@clemrig/factory 0.18.3 → 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.
Files changed (70) hide show
  1. package/README.md +25 -23
  2. package/dist/app/board.js +1 -0
  3. package/dist/app/board.js.map +1 -1
  4. package/dist/app/factory.d.ts +2 -0
  5. package/dist/app/factory.js +5 -1
  6. package/dist/app/factory.js.map +1 -1
  7. package/dist/app/review.d.ts +16 -0
  8. package/dist/app/review.js +87 -0
  9. package/dist/app/review.js.map +1 -0
  10. package/dist/app/spec-page.d.ts +11 -0
  11. package/dist/app/spec-page.js +37 -0
  12. package/dist/app/spec-page.js.map +1 -0
  13. package/dist/app/workflows/implement.js +3 -7
  14. package/dist/app/workflows/implement.js.map +1 -1
  15. package/dist/app/workflows/issue-save.d.ts +4 -1
  16. package/dist/app/workflows/issue-save.js +35 -4
  17. package/dist/app/workflows/issue-save.js.map +1 -1
  18. package/dist/app/workflows/stages/deliver.d.ts +5 -4
  19. package/dist/app/workflows/stages/deliver.js +47 -53
  20. package/dist/app/workflows/stages/deliver.js.map +1 -1
  21. package/dist/app/workflows/stages/prepare.js +11 -7
  22. package/dist/app/workflows/stages/prepare.js.map +1 -1
  23. package/dist/app/workflows/stages/resume.js +0 -4
  24. package/dist/app/workflows/stages/resume.js.map +1 -1
  25. package/dist/app/workflows/stages/run.d.ts +1 -2
  26. package/dist/app/workflows/tidy.js +2 -3
  27. package/dist/app/workflows/tidy.js.map +1 -1
  28. package/dist/cli/ui.d.ts +5 -2
  29. package/dist/cli/ui.js +24 -5
  30. package/dist/cli/ui.js.map +1 -1
  31. package/dist/domain/board.d.ts +6 -0
  32. package/dist/domain/board.js +5 -1
  33. package/dist/domain/board.js.map +1 -1
  34. package/dist/domain/description.d.ts +57 -5
  35. package/dist/domain/description.js +133 -12
  36. package/dist/domain/description.js.map +1 -1
  37. package/dist/domain/diff.d.ts +8 -0
  38. package/dist/domain/diff.js +90 -0
  39. package/dist/domain/diff.js.map +1 -0
  40. package/dist/domain/pull-request.d.ts +9 -21
  41. package/dist/domain/pull-request.js +43 -228
  42. package/dist/domain/pull-request.js.map +1 -1
  43. package/dist/domain/review-page.d.ts +171 -0
  44. package/dist/domain/review-page.js +200 -0
  45. package/dist/domain/review-page.js.map +1 -0
  46. package/dist/domain/spec-page.d.ts +132 -0
  47. package/dist/domain/spec-page.js +155 -0
  48. package/dist/domain/spec-page.js.map +1 -0
  49. package/dist/system/environment.d.ts +6 -0
  50. package/dist/system/environment.js +19 -0
  51. package/dist/system/environment.js.map +1 -1
  52. package/dist/system/factory.d.ts +2 -0
  53. package/dist/system/factory.js +4 -0
  54. package/dist/system/factory.js.map +1 -1
  55. package/dist/system/git.d.ts +5 -1
  56. package/dist/system/git.js +19 -2
  57. package/dist/system/git.js.map +1 -1
  58. package/dist/system/github.d.ts +3 -12
  59. package/dist/system/github.js +7 -31
  60. package/dist/system/github.js.map +1 -1
  61. package/dist/system/issues.d.ts +10 -0
  62. package/dist/system/issues.js +57 -1
  63. package/dist/system/issues.js.map +1 -1
  64. package/dist/system/run-files.d.ts +14 -0
  65. package/dist/system/run-files.js +51 -8
  66. package/dist/system/run-files.js.map +1 -1
  67. package/package.json +2 -2
  68. package/prompts/describe.md +36 -15
  69. package/templates/init/gitignore +1 -0
  70. package/templates/skills/issue/SKILL.md +49 -7
package/README.md CHANGED
@@ -7,7 +7,7 @@ An idea becomes an issue; the operator specifies it with an agent; one run then
7
7
  ## Requirements
8
8
 
9
9
  - macOS or Linux, Node.js 24 or later, npm.
10
- - For the `implement` run: Git, a GitHub repository whose remote is `origin`, with `origin/HEAD` naming the main branch (`git clone` sets it; otherwise `git remote set-head origin --auto`), and the [GitHub CLI](https://cli.github.com) `gh` 2.99.0 or later (it attaches screenshots to the pull request), logged in (`gh auth login`).
10
+ - For the `implement` run: Git, a GitHub repository whose remote is `origin`, with `origin/HEAD` naming the main branch (`git clone` sets it; otherwise `git remote set-head origin --auto`), and the [GitHub CLI](https://cli.github.com) `gh`, logged in (`gh auth login`).
11
11
  - For agents run by Claude Code: the `claude` CLI 2.1.296 or later in the `PATH`, logged in with a claude.ai subscription (`claude`, then `/login`) or given an API key (`ANTHROPIC_API_KEY`), and a `ps` that lists processes with their group and start time (macOS's, or procps on Linux), with which each call ends what its agent's commands leave running.
12
12
  - For agents run by Codex: the `codex` CLI 0.160.1 or later in the `PATH`, logged in with a ChatGPT account or an API key (`codex login`) or given an API key (`CODEX_API_KEY`); Codex works only in a Git repository.
13
13
  - For agents run by Pi: the `pi` CLI (`@earendil-works/pi-coding-agent` 1.1.0 or later) in the `PATH`, connected to the provider each Pi profile names (`pi`, then `/login`, or the provider's API key).
@@ -33,8 +33,8 @@ factory doctor
33
33
  index.ts an example workflow of the repository
34
34
  prompts/answer.md the prompt of its answer stage
35
35
  tsconfig.json editor settings only
36
- .gitignore node_modules/, runs/, .env
37
- issues/<slug>/ issue.md, spec.md, plan.md (committed)
36
+ .gitignore node_modules/, runs/, .env, issues/*/spec-answers.json*
37
+ issues/<slug>/ issue.md, spec.md, spec-page.json, plan.md (committed)
38
38
  runs/ one folder per run (ignored)
39
39
  .env optional secrets (ignored)
40
40
  .agents/skills/issue/ the issue skill, read by Codex and Pi
@@ -46,14 +46,14 @@ The global `factory` command uses the nearest `.factory/` holding a `package.jso
46
46
  ## From an idea to a pull request
47
47
 
48
48
  1. **Backlog.** In Claude Code, Codex or Pi, `/issue` asks for a title and a description, writes a draft outside the repository and saves it with `factory run issue-save --issue <slug> --kind issue --file <draft>`. The command checks the draft and writes `.factory/issues/<slug>/issue.md` itself: the agent chooses neither the path nor the format.
49
- 2. **Specifying.** `/issue` again: the agent reads the code, asks questions until it can fill every section without inventing anything, including the issues this one depends on, and proposes the spec; once the operator agrees, `--kind spec` writes `spec.md`. When a run refuses to start because of the spec, `/issue` fixes it from the problems the run listed.
50
- 3. Review the spec, commit it and push it on the main branch.
49
+ 2. **Specifying.** `/issue` again: the agent reads the code, asks questions until it can fill every section without inventing anything, including the issues this one depends on, and proposes the spec; once the operator agrees, `--kind spec` writes `spec.md`. The agent then presents it, with a mockup for each change that brings an interface, and `--kind page` keeps the presentation as `spec-page.json` (see The spec page). When a run refuses to start because of the spec, `/issue` fixes it from the problems the run listed.
50
+ 3. Validate the spec on its page in `factory ui` (the Spec link of its card): the message of the cards you send back goes to `/issue`, which updates the spec and presents it again. Then commit the spec and its presentation and push them on the main branch.
51
51
  4. **Executing.** `factory run implement --issue <slug>`: starting the run approves the spec. It runs without the operator; follow it in `factory ui`.
52
52
  5. **To Approve → Done.** Review and merge the pull request. After `git pull`, `plan.md` is on the main branch: the issue is done. Its folder stays.
53
53
 
54
- A failed run stops; past `prepare`, it leaves the repository on the branch `<slug>`, with the agent's changes, for inspection. When the cause has passed (a timeout, the budget, the network, a Git hook), or when the checks or the review stopped it at their maximum of corrections and you grant one more round, `factory resume <RUN_ID>` starts the stopped stage again (each resumption allows that loop one more correction), its agent in the same conversation: the repository must still be on `<slug>` at the commit where the run stopped (the plan's commit, or the starting commit before it), with its changes in progress and none in `.factory/`; a delivery that stopped after its commit resumes once `git reset --soft <plan commit>` puts the changes back in progress, as the refusal says, a run whose pull request is recorded in its state, stopped once its delivery was done, does not resume, unless it stopped while attaching its screenshots, which it then attaches without any condition on the repository, and neither does, past `prepare`, a run started with an earlier version of the factory. Otherwise, clean up, fix what is needed (often the spec, committed and pushed again) and start a new run: it starts again from the main branch, recreates the branch and replaces the pull request's content. Requested changes on a pull request are fixed the same way, or by hand on the branch. An issue is abandoned by deleting its folder (and closing its pull request, if any).
54
+ A failed run stops; past `prepare`, it leaves the repository on the branch `<slug>`, with the agent's changes, for inspection. When the cause has passed (a timeout, the budget, the network, a Git hook), or when the checks or the review stopped it at their maximum of corrections and you grant one more round, `factory resume <RUN_ID>` starts the stopped stage again (each resumption allows that loop one more correction), its agent in the same conversation: the repository must still be on `<slug>` at the commit where the run stopped (the plan's commit, or the starting commit before it), with its changes in progress and none in `.factory/`; a delivery that stopped after its commit resumes once `git reset --soft <plan commit>` puts the changes back in progress, as the refusal says, a run whose pull request is recorded in its state, stopped once its delivery was done, does not resume, and neither does, past `prepare`, a run started with an earlier version of the factory. Otherwise, clean up, fix what is needed (often the spec, committed and pushed again) and start a new run: it starts again from the main branch, recreates the branch and replaces the pull request's content. Requested changes on a pull request are fixed the same way, or by hand on the branch. An issue is abandoned by deleting its folder (and closing its pull request, if any).
55
55
 
56
- `issue-save` lists every problem of a draft's format at once, then, for a valid spec, its dependencies that are no issue, refuses a spec for an issue that has no `issue.md`, replaces the file if it exists and commits nothing; each save is a run. The skill tells the agent never to write in `.factory/issues/` directly, commit or run `implement`. Pi reads a project's skills once the project is trusted; Codex ignores a `SKILL.md` that is itself a link, hence the folder link.
56
+ `issue-save` lists every problem of a draft's format at once, then, for a valid spec, its dependencies that are no issue, and for a presentation, what does not present the saved spec; it refuses a spec for an issue that has no `issue.md` and a presentation for an issue whose `spec.md` is missing or invalid, replaces the file if it exists and commits nothing; each save is a run. The skill tells the agent never to write in `.factory/issues/` directly, commit or run `implement`. Pi reads a project's skills once the project is trusted; Codex ignores a `SKILL.md` that is itself a link, hence the folder link.
57
57
 
58
58
  ### Issues
59
59
 
@@ -63,20 +63,21 @@ An issue is a folder `.factory/issues/<slug>/` holding at least one of the files
63
63
  - `spec.md`: a `# ` title, then exactly `## Objective`, `## Scope`, `## Out of scope`, `## Acceptance criteria`, `## Constraints` and `## Dependencies`, in this order, with nothing before the first and none empty (`None.`). Acceptance criteria holds only `- AC<n>: <criterion>` items numbered from AC1 without gaps; an indented line continues an item. Dependencies holds only `- <slug>` items, each another issue of the repository that must be delivered first, or `None.`. The spec says what and why, not how; headings stay in English, the content may be in any language. `issue-save` and `implement` read it the same way; `issue-save` also refuses a dependency that is no issue of the repository.
64
64
  - `plan.md`: written by the run, in the language of the spec's content: the approach, what the code already does that the change must keep (Existing), steps that each name the criteria they serve, their files, the cases they must handle besides their main path and their tests, how it read the spec where the spec reads more than one way, and the risks.
65
65
 
66
+ Beside `spec.md`, `spec-page.json` keeps the presentation of the spec for its page, as `issue-save` checked it, with the spec it presents word for word (see The spec page), and `spec-answers.json` where the operator is on that page, forgotten when a new presentation is saved; Git ignores the latter. A repository initialized before factory 0.20.0 adds `issues/*/spec-answers.json*` to its `.factory/.gitignore`: otherwise the answers are changes in progress, and `implement` refuses to start.
67
+
66
68
  ### The `implement` run
67
69
 
68
70
  | Stage | What it does |
69
71
  |---|---|
70
- | `prepare` | Refuses to start, listing every reason, unless the repository is on the main branch without any change in progress, the main branch matches `origin` after `git fetch`, `spec.md` is valid (otherwise it says to fix it with `/issue <slug>`), each of its dependencies is delivered (its `plan.md` is on the main branch), the issue has no `plan.md` (an issue already delivered is never restarted), its slug does not name the main branch (its branch would replace it), `gh` is 2.99.0 or later, logged in, and finds the repository on GitHub; then the repository's checks must pass on the main branch, before any agent; then, under a lock of the working tree (`factory-implement.lock` in its Git directory, held for that step only) and unless the repository moved meanwhile (another run is using it: the run stops), creates (or recreates) the branch `<slug>` from the approved start commit. Branches are read and pushed by their full reference: a tag of the same name never stands in for them |
72
+ | `prepare` | Refuses to start, listing every reason, unless the repository is on the main branch without any change in progress, the main branch matches `origin` after `git fetch`, `spec.md` is valid (otherwise it says to fix it with `/issue <slug>`), each of its dependencies is delivered (its `plan.md` is on the main branch), the issue has no `plan.md` (an issue already delivered is never restarted), its slug does not name the main branch (its branch would replace it), `FACTORY_UI_URL`, when set, is an http or https address, and `gh` is logged in and finds the repository on GitHub; then the repository's checks must pass on the main branch, before any agent; then, under a lock of the working tree (`factory-implement.lock` in its Git directory, held for that step only) and unless the repository moved meanwhile (another run is using it: the run stops), creates (or recreates) the branch `<slug>` from the approved start commit. Branches are read and pushed by their full reference: a tag of the same name never stands in for them |
71
73
  | `plan`, `planned` | The `plan` agent receives the slug and the spec. It first explores the code where the spec changes it (mechanisms, invariants, conventions, test tools), handing each area of a spec that touches several to a sub-agent when its profile allows it, then answers with a plan: what the code already does that the change must keep, and steps with their criteria, the files expected, the situations to handle besides the main path and their tests. Where the spec reads more than one way, or its letter would give a behavior its objective would not want, the plan records the reading it chose, apart from its risks: the pull request asks you to confirm it. The plan says what must be true, not how to write it; the implementing agent may take a better way and records it as a deviation; every criterion must be served by a step, otherwise the plan goes back to it (2 times at most) |
72
74
  | `commit-plan` | Writes `plan.md` and commits it alone (`docs: plan <slug>`): the run's reference commit |
73
75
  | `implement`, `implemented` | The `implement` agent receives the spec, the plan and the run's browser, in one conversation for the run, and answers with evidence for each criterion and its deviations from the plan. It fixes what the review asks for test first: a test that reproduces the trigger and fails, the fix, then a test for each situation around it that the fix changes; what no test can show, it checks in the browser before and after; the run stops if it committed, switched branches or changed `.factory/`, whatever it answered |
74
76
  | `verify` | The repository's checks, in order, a check with `when` only if a file changed since the reference commit matches it; a failure, a timeout or a command that cannot start goes back to `implement` with the command, the cause and the end of its output (3 times at most). What each check wrote is kept in the run's folder, for the review, and a failed check's whole output in `checks/failed-<n>-<name>.log`, the run's `n`th failure, resumptions included, whose path the run journals (over 2 MiB per stream, its end, marked as truncated) |
75
77
  | `diff` | Every change since the reference commit, new files included, with each file's added and removed lines; the run stops if it is over 2 MiB. Over 1,500 lines of diff, the change is large: its diff is kept in the run's folder instead of being sent in the review's request. |
76
78
  | `review`, `reviewed` | The `review` agent, in a new conversation for each review, receives the spec, the changes (the diff, or for a large change where to read it), the checks and where their output is, and the run's browser, never the implementing agent's answer. It judges each criterion `met` or `not_met`, with its decisive evidence, and gives each finding a nature, only on what it established: a test it ran, the application it tried or a code path it followed to its end; a risk it could not establish is at most a `weak_test`. From the second round on, once it has answered on its own with a review the run can judge (an answer it cannot, such as a note sent while its sub-agents still run, goes back to it as an invalid review), it receives in the same conversation the previous review's unmet criteria and findings and checks them itself, without sub-agents: it reads and runs the tests of each fix and answers on them alone, with each criterion judged again, the findings a faithful test proves fixed (one that reproduces the trigger, would fail without the fix and covers the situations around it), those its first answer reports again, and what the fixes broke (a fix that breaks what worked is a `regression`). The run keeps its first answer whole and adds that check to it: a previous finding stays as it was until its fix is proven, unless the first answer reports it again with a nature that blocks as much, and a criterion is met only when both answers say so. Every review judged is kept in the run. An unmet criterion or a blocking finding goes back to `implement` (4 times at most) with the other findings, to fix as well when that is safe, and the implementing agent fixes the mechanism that let a defect happen, wherever the change has it, rather than adding a guard per case |
77
- | `describe`, `described` | Once the change is approved, the `describe` agent explains it for the pull request (see below) and takes its screenshots. It receives the spec, the plan, the changes, the checks, the approved review, the deviations from the plan, whether the repository is public, the screenshots folder and the run's browser, never the implementing agent's summary. Its guide must name changed files only, each once, its screenshots must be distinct images of the folder, 10 MB at most, and the pull request's body must stay under 60,000 characters; otherwise its answer goes back to it (2 times at most) |
79
+ | `describe`, `described` | Once the change is approved, the `describe` agent explains it for the review page (see below), takes its screenshots, and writes the decisions and the checks only a person can do. It receives the spec, the plan, its interpretations numbered `I1`…, the changes, the checks, the approved review, the deviations from the plan numbered `D1`…, the screenshots folder and the run's browser, never the implementing agent's summary. Its guide must name changed files only, each once, its screenshots must be distinct images of the folder, 10 MB at most, and each decision must name what exists: a criterion of the spec, an interpretation or a deviation, a changed file, lines the diff changes (60 at most), screenshots of the description; otherwise its answer goes back to it (2 times at most) |
78
80
  | `deliver` | Commits the changes with the plan's conventional commit subject, force-pushes `<slug>` to `origin`, updates the branch's open pull request or opens one with `gh`, then returns to the main branch |
79
- | `attach` | When there are screenshots: replaces the pull request's body with one that shows them and uploads them (`gh pr edit --attach`) |
80
81
 
81
82
  A finding's nature alone decides whether it blocks the change: `incorrect_behavior`, `data_loss`, `outage`, `security`, `regression` and `spec_violation` block it; `weak_test`, `maintainability` and `documentation` do not.
82
83
 
@@ -108,18 +109,19 @@ The `implement`, `review` and `describe` agents check a change that shows in a w
108
109
 
109
110
  #### The pull request
110
111
 
111
- Its title is the commit subject. Its body, for a reader who remembers nothing of the issue, short where it is read and folded where it is detail:
112
+ Its title is the commit subject. Its body is short: a warning first when the operator delivered the change despite its review (see below), a caution when merging is a one-way door (reverting does not walk it back: a migration that transforms data, a published contract, an external effect), then the link to the change's review page with what there is to decide, and a table at a glance: the files changed with their lines, links to the spec at the starting commit and to `plan.md`, the run's ID; the door and the blast radius; the criteria met, the checks and the screenshots; how the review ended and what it left. The link is `FACTORY_UI_URL` followed by `review?run=<RUN_ID>`; without it, the body says to open `/review?run=<RUN_ID>` in `factory ui` where the run ran.
113
+
114
+ #### The spec page
115
+
116
+ `factory ui` serves, for each issue whose spec is presented, a page to validate it before any run, linked from the issue's card: a deck of cards, with the same piles, drags and keys as the review page below. The agent of `/issue` writes the presentation in plain words, in the spec's language: the need; a card per change, with a mockup when it brings an interface (a whole HTML document drawn at a given size, shown scaled to the card and at full size on a click, in a frame without script, network or anything but its own HTML and inline styles); a card per choice the spec made, with the options it weighed and the one it took, where taking another sends the card back; a card per group of acceptance criteria, each in plain words with how it will be checked; and what the spec leaves out. `issue-save` checks that it presents every criterion of the saved spec once and that each choice's options hold, and keeps the spec it presents: once the spec changes, the page says it is stale. The verdict is spec validated, with the command to run next, or changes requested, with a message made of the cards you sent back, your notes and the options you took instead, to give to the agent. Each card but the choices and the verdict opens the spec's own words. Your answers are kept in `.factory/issues/<slug>/spec-answers.json`, so that another device resumes them. Validating gates nothing yet: `implement` starts on any valid spec.
117
+
118
+ #### The review page
112
119
 
113
- - a warning first when the operator delivered the change despite its review (see below), then a caution when merging is a one-way door (reverting does not walk it back: a migration that transforms data, a published contract, an external effect), then a note when the plan chose how to read the spec;
114
- - a table at a glance: the files changed with their lines, links to the spec at the starting commit and to `plan.md`, the run's ID; the door and the blast radius; the criteria met, the checks and the screenshots; how the review ended and what it left;
115
- - **Why**: the spec's Objective;
116
- - **What changes**, one item per change, a change to what already existed among them, **How it works** (Mermaid diagrams of how components interact or how data flows, sketches of a tree as a diff, pseudocode; none when the text suffices), **Merge danger** (a table: door, blast radius, rollback, what to do after the merge) and **Review guide** (the file to start with, then the files in reading order, every group's list folded when the change has more than 10 files; the run lists the others), written by the `describe` agent with as many items as the change calls for;
117
- - **Needs your judgment**: the plan's readings of the spec, to confirm or to fix in the spec; the review rounds, what stays open, the non-blocking findings with their nature and the deviations from the plan; folded, what earlier reviews found and later rounds resolved (fixed, or shown wrong), with the proof, and the plan's assumptions;
118
- - **Evidence**: the screenshots of the new state, or why there are none; the criteria met; the checks passed or skipped; each criterion with the review's evidence, folded.
120
+ `factory ui` serves, for each run that delivered a described pull request, a page to review it from the run's data alone, linked from the pull request and from the issue's card. It is a deck of cards, one at a time, between two piles: send a card right when it suits you, left when it needs another look, by dragging it or with the keyboard (→, ←, D for its dossier, S to skip a check, Backspace to take it back). The cards to know come first: the mission and its danger (door, blast radius, rollback), what the review did (each round's criteria met and findings, the checks), what changes (each change, the size of the diff, why there is no screenshot when there is none), then, when the run took screenshots, what it looks like: each screenshot with its caption, at full size on a click, where ← and → go from one to the next. Then a card per decision: each the `describe` agent wrote by rule (a change beyond the spec, an existing test whose expectation changed, a reading of the spec beyond its letter), with its advice and what shows it (the spec's words beside the plan's reading, an excerpt of the diff, screenshots, a short list); one for the non-blocking findings the review left, to merge and note for later or not; one for what the operator delivered open. Then a card per check only a person can do (a real phone, real data, a sound), and the verdict: good to merge, with what to note and what you did not check, or changes requested, with a message made of the cards you sent back and your notes, to copy. Each card opens its dossier: the run's texts word for word, the review's evidence, links to the spec, the plan and the file in the pull request; the change's dossier also holds the diagrams, where to read the code, and every interpretation, deviation and assumption no card shows. Your answers are kept with the run (`answers.json` in its folder), so that another device resumes them.
119
121
 
120
- No text of the run opens a code block or a comment that would swallow the rest of the body: the factory escapes them.
122
+ To open it away from the machine of the run, publish `factory ui` on your private network, for instance with [Tailscale](https://tailscale.com): run `factory ui --port 4321` there (kept running, under a service manager or `tmux`), then `tailscale serve --bg 4321`, and set `FACTORY_UI_URL` to the address it prints (such as `https://forge.example.ts.net/`) in `.factory/.env` or the shell. Pull requests then link the page there, and `factory ui` answers that host name, which `tailscale serve` passes on.
121
123
 
122
- When the review still asks for changes after its last round, the run stops; `factory resume <RUN_ID>` gives it one more round, and `factory resume <RUN_ID> --accept-review` delivers it as the review left it, on your decision: the pull request then opens with a warning and lists, under Needs your judgment, the unmet criteria and blocking findings left open. What comes from the run (the spec, the criteria, the checks, the review, the deviations, the risks) is put together by the factory, never rewritten by an agent; the implementing agent's own summary is not shown. In a public repository, anyone can see the screenshots: the describing agent shows only test or seed data. The screenshots are kept in the run's folder and uploaded once the pull request is open; the body names them by file only, never by a path of the machine. A failed upload leaves the pull request recorded, saying again that its screenshots are coming, and fails the run; `factory resume` only uploads them again.
124
+ When the review still asks for changes after its last round, the run stops; `factory resume <RUN_ID>` gives it one more round, and `factory resume <RUN_ID> --accept-review` delivers it as the review left it, on your decision: the pull request then opens with a warning, and the review page has a card for the unmet criteria and blocking findings left open. What comes from the run (the spec, the criteria, the checks, the review, the deviations, the risks) is put together by the factory, never rewritten by an agent; the implementing agent's own summary is not shown. The screenshots stay in the run's folder, where the review page shows them: nothing is uploaded to GitHub.
123
125
 
124
126
  ### The `tidy` run
125
127
 
@@ -131,7 +133,7 @@ Working fast with agents leaves waste in the code. `factory run tidy` removes it
131
133
  | `survey` | Reads what the scout needs: recent code, that is the commits of the main branch since the last cleanup merged (the last commit that brought a `.factory/issues/tidy-*/plan.md` to it), or of the last 14 days before the first one, 200 at most, merges aside, with their files and how often each changed; the files of the open pull requests; the cleanups closed without being merged |
132
134
  | `scout`, `scouted` | The `scout` agent, with the `plan` profile, explores recent code first, then the rest of the repository, compares candidates and answers with the cleanup that comes first, or none. A cleanup changes nothing observable: it removes the waste that fast changes leave (duplicates, dead code, needless defenses, functions too long to follow, departures from the conventions, stale comments and documentation, weak tests), leaves the files of the open pull requests alone and proposes no cleanup like those the operator closed. It answers with the cleanup's `issue.md` and `spec.md`: the gate reads them as `issue-save` does and refuses a dependency, since a cleanup starts from the main branch alone, otherwise the answer goes back to the scout (2 times at most). When none is worth a pull request, the run goes back to the main branch, deletes its empty branch (`release`) and ends there |
133
135
  | `commit-spec` | Commits the cleanup's `issue.md` and `spec.md` on the run's branch (`docs: spec tidy-<run id>`) |
134
- | `plan` … `attach` | As in `implement`, from that spec, except that the review sends the change back 2 times at most; the pull request links the spec at its own commit |
136
+ | `plan` … `deliver` | As in `implement`, from that spec, except that the review sends the change back 2 times at most; the pull request links the spec at its own commit |
135
137
 
136
138
  The pull request is your approval: merge it, or close it, and the scout does not propose that cleanup again. A defect the scout finds is named in the issue, never fixed by a cleanup. Until it is merged, a cleanup lives on its branch only, so the Kanban does not show it: follow its run under `/runs/`; once merged, it is an issue like the others, in Done. The run needs the repository on its main branch without changes, as `implement` does: run it from a clone kept for it rather than the one you work in. A cleanup is named after its run: its branch and its folder `.factory/issues/tidy-<run id>/` lead to the run under `/runs/`, and its title is that of its pull request and `issue.md`. A failed run stops on its branch and resumes as `implement` does.
137
139
 
@@ -148,7 +150,7 @@ The pull request is your approval: merge it, or close it, and the scout does not
148
150
  | To Approve | the last `implement` run completed, and `plan.md` is not on the main branch |
149
151
  | Done | `plan.md` is on the main branch, a merged cleanup's too |
150
152
 
151
- The files are read in the working tree, the main branch is the local branch `origin/HEAD` names, and runs are those of `.factory/runs/`. A card shows the issue's title (the `# ` line of `issue.md`; its slug without one), its slug, the dependencies of its spec not delivered yet (none once the issue is delivered), the newest pull request its `implement` runs recorded (a new run updates the same one) and, for each workflow shown on cards, its last run on the issue: its steps (done, current, failed or to come, each with the corrections that sent the run back into it), its duration and its estimated cost. `implement` shows six steps: prepare, plan, implement, verify, review and deliver (the description and the screenshots' upload included). The title opens the newest of these runs in the runs dashboard. The most recently active issue comes first in its column; the page refreshes every 2 seconds. What may leave the board incomplete is listed above it: a `factory.ts` that does not load (`factory ui` loads it when it starts: restart it once fixed), an unreadable `issue.md` or run, an undelivered issue's `spec.md` that cannot be read or is invalid (its dependencies are then not shown), or a main branch Git cannot read (`origin/HEAD` missing: `git remote set-head origin --auto` sets it).
153
+ The files are read in the working tree, the main branch is the local branch `origin/HEAD` names, and runs are those of `.factory/runs/`. A card shows the issue's title (the `# ` line of `issue.md`; its slug without one), its slug, the dependencies of its spec not delivered yet (none once the issue is delivered), the newest pull request its `implement` runs recorded (a new run updates the same one), with a Review link to its review page when the run described it, a Spec link to its spec page when its spec is presented and, for each workflow shown on cards, its last run on the issue: its steps (done, current, failed or to come, each with the corrections that sent the run back into it), its duration and its estimated cost. `implement` shows six steps: prepare, plan, implement, verify, review and deliver (the description included). The title opens the newest of these runs in the runs dashboard. The most recently active issue comes first in its column; the page refreshes every 2 seconds. What may leave the board incomplete is listed above it: a `factory.ts` that does not load (`factory ui` loads it when it starts: restart it once fixed), an unreadable `issue.md` or run, an undelivered issue's `spec.md` that cannot be read or is invalid (its dependencies are then not shown), or a main branch Git cannot read (`origin/HEAD` missing: `git remote set-head origin --auto` sets it).
152
154
 
153
155
  ## Adapt the factory
154
156
 
@@ -327,7 +329,7 @@ The run executes in the foreground. The terminal first shows the launch (flow's
327
329
 
328
330
  **Resume.** `factory resume RUN_ID` runs a failed run again in the foreground, under the same ID, at the stage where it stopped (with `--accept-review`, an `implement` or `tidy` run its review stopped by asking for changes is delivered as the review left it: see The pull request): its input, data, corrections, cost and agents' conversations are kept, the stage's journal starts with why the run had stopped (`Resumed after: …`), and its agent is told so and asked to continue rather than start over. The workflow is the one `factory.ts` defines now, its prompts are read again, and its runtimes are checked as for `factory run`. The budget is the one given with `--max-cost-usd`, else the run's own, else the workflow's; a run that already spent it does not resume without a higher one. The run's budget still counts its whole cost, but calls that announced no cost before the resumption, such as a call stopped by its timeout, no longer fail it; their cost counts only if the runtime includes it in the total it later announces for the resumed session, and the run's cost stays marked partial. The run's duration leaves out the time it spent stopped. Only a failed run resumes, and by one command at a time: a run left `running` after a second Ctrl-C does not, and a workflow may refuse to resume from the state of the repository, as `implement` does. A resumed stage starts over: what it did before it failed must be safe to do again. A run stopped by a correction maximum resumes at the stage that asked for it, which may then take one more correction: the checks may pass after a fix by hand, and a gate judging the same answer sends it back once more.
329
331
 
330
- `factory status` lists the repository's runs or shows one; while `factory.ts` cannot load, `status` and `ui` say so and still show the runs with the default rendering. `factory ui` serves on `127.0.0.1` (port chosen by the system unless `--port` sets it, URL printed; Ctrl-C stops it) the Kanban on `/` and, under `/runs/`, a read-only dashboard of the repository's runs, with a Board link back to the Kanban: the runs in a rail grouped by day, named by their issue, filtered and searched; for a run its figures and links above three tabs: Timeline with its launches on one bar with the pauses between them and why each stopped, each opening what it ran with and what changed since the one before, its stage executions in lanes over its active time with its rounds and corrections, then the selected execution's panel (Overview with the session each call ran in as its runtime confirmed it, Input with the correction it received and what flow sent each agent call, loaded on demand: the workflow's prompt, the instructions, the context and the output schema, the whole request and the command, Output with the agent's answer, the correction sent back or not and each call's answer when it made several, Activity with its calls, tool calls, journal and warnings in one timeline), Cost with its cost by session and over time, Result with its result, its links and its data as a tree. The address keeps the run, its tab, the execution chosen and the execution's tab. It follows a running run as it goes. To watch on another machine, forward the same port through SSH: `ssh -L 4321:127.0.0.1:4321 machine`, run `factory ui --port 4321` there, and open `http://localhost:4321/`. `factory doctor` checks Node, loads the workflows, reads their prompts, lists each workflow's options and checks each runtime's executable, version and connection, without any provider request.
332
+ `factory status` lists the repository's runs or shows one; while `factory.ts` cannot load, `status` and `ui` say so and still show the runs with the default rendering. `factory ui` serves on `127.0.0.1` (port chosen by the system unless `--port` sets it, URL printed; Ctrl-C stops it) the Kanban on `/`, each presented spec's page at `/spec?issue=<slug>` (see The spec page), each delivered run's review page at `/review?run=<RUN_ID>` (see The review page; it also answers the host of `FACTORY_UI_URL`), and, under `/runs/`, a read-only dashboard of the repository's runs, with a Board link back to the Kanban: the runs in a rail grouped by day, named by their issue, filtered and searched; for a run its figures and links above three tabs: Timeline with its launches on one bar with the pauses between them and why each stopped, each opening what it ran with and what changed since the one before, its stage executions in lanes over its active time with its rounds and corrections, then the selected execution's panel (Overview with the session each call ran in as its runtime confirmed it, Input with the correction it received and what flow sent each agent call, loaded on demand: the workflow's prompt, the instructions, the context and the output schema, the whole request and the command, Output with the agent's answer, the correction sent back or not and each call's answer when it made several, Activity with its calls, tool calls, journal and warnings in one timeline), Cost with its cost by session and over time, Result with its result, its links and its data as a tree. The address keeps the run, its tab, the execution chosen and the execution's tab. It follows a running run as it goes. To watch on another machine, forward the same port through SSH: `ssh -L 4321:127.0.0.1:4321 machine`, run `factory ui --port 4321` there, and open `http://localhost:4321/`. `factory doctor` checks Node, loads the workflows, reads their prompts, lists each workflow's options and checks each runtime's executable, version and connection, without any provider request.
331
333
 
332
334
  ## Data
333
335
 
@@ -342,7 +344,7 @@ Tokens and costs are the figures each runtime announces: Claude Code announces a
342
344
  - The repository is used in place: one `implement` run at a time, since it needs a clean tree and stops if another run moved the repository during its starting checks; after a failure, the operator cleans up, or leaves the branch as it is to resume the run. The repository's Git hooks run on the run's commits, and a failing hook fails the run.
343
345
  - The factory's own agents (`plan`, `implement`, `review`, `describe`) cannot run on Codex, since `maxCostUsd` is required and Codex announces no cost; the repository's own workflows and the `issue` skill can use Codex.
344
346
  - Runtimes are not sandboxes: the implementing agent's tools can run any command its profile allows, bounded only by its prompt, the repository's agent instructions and the run's checks.
345
- - The rule that a public repository's screenshots show only test or seed data holds only through the describing agent's prompt. The factory does not check the Mermaid syntax: GitHub shows an error in place of an invalid diagram.
347
+ - The review page lives on the machine of the run: elsewhere, the pull request shows only its header. A spec page shows the working tree of the machine that serves it: a spec written elsewhere is validated there once pulled. Both are served without sign-in: anyone who reaches `factory ui`, on that machine or through `FACTORY_UI_URL`, can read them and change their answers. Validating a spec does not gate `implement` yet. The factory does not check the Mermaid syntax: the page shows the text of a diagram it cannot draw. Mermaid, built into the page, brings `@clemrig/factory-ui` to about 5.5 MB.
346
348
  - Screenshots show the new state only, never the previous one; no videos.
347
349
  - `tidy` has no scheduler of its own: cron, launchd or a CI runner starts it. Its scout reads at most 200 recent commits and the latest 100 open and 100 closed pull requests, with the first 100 files of each open one, as `gh` lists them, and a defect it finds is only named in the cleanup's issue.
348
350
  - Not in this version: changing the factory's prompts, correction maximums, pull request format or columns from a repository; columns added by a workflow; backlog priority; actions or drag-and-drop on the board; resuming a run left `running` after its process was killed, detached runs, logs `--follow` and stop; local settings or profile overrides; graph drawing in the dashboard; runs or issues of several repositories; `factory new`; a shared stage library; a test harness for workflows; CI, cron or Git hook triggers; notifications; Windows.
package/dist/app/board.js CHANGED
@@ -66,6 +66,7 @@ export async function readBoard(factory, loadError) {
66
66
  slug: folder.slug,
67
67
  title: (folder.issue && issueTitle(folder.issue)) || folder.slug,
68
68
  hasSpec: folder.hasSpec,
69
+ hasSpecPage: folder.hasSpecPage,
69
70
  // A delivered issue's spec may predate today's format: it waits for nothing.
70
71
  dependencies: folder.hasSpec && !isDelivered
71
72
  ? (await dependenciesOf(factory.dir, folder.slug, problems)).map((slug) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"board.js","sourceRoot":"","sources":["../../src/app/board.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,GAIR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,EAAE,CACjC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAEzD,qHAAqH;AACrH,SAAS,cAAc,CAAC,OAAgB;IACtC,OAAO,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAC5C,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EA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AO,CAAC,MAAM,EAAE,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAClE,CAAC"}
@@ -12,3 +12,5 @@ export declare function openFactoryForReading(factoryDir: string): Promise<{
12
12
  factory: Factory;
13
13
  error?: string;
14
14
  }>;
15
+ /** Where others reach `factory ui`, when `FACTORY_UI_URL` says it. */
16
+ export declare function uiAddress(): URL | undefined;
@@ -1,4 +1,4 @@
1
- import { loadLocalEnvironment } from "../system/environment.js";
1
+ import { loadLocalEnvironment, uiUrl } from "../system/environment.js";
2
2
  import { emptyFactory, importFactory, } from "../system/factory.js";
3
3
  import { workflowsOf } from "./define.js";
4
4
  import { optionProblems } from "./options.js";
@@ -38,4 +38,8 @@ export async function openFactoryForReading(factoryDir) {
38
38
  return { factory: emptyFactory(factoryDir), error: message(error) };
39
39
  }
40
40
  }
41
+ /** Where others reach `factory ui`, when `FACTORY_UI_URL` says it. */
42
+ export function uiAddress() {
43
+ return uiUrl();
44
+ }
41
45
  //# sourceMappingURL=factory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/app/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACL,YAAY,EAEZ,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI9C,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,EAAE,CACjC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAEzD,iGAAiG;AACjG,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,UAAkB;IACpD,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,aAAa,CAAC,UAAU,CAA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C,QAAQ,CAAC,CAAC;QAC1C,IAAI,QAAQ,CAAC,MAAM;YACjB,MAAM,IAAI,KAAK,CACb,oBAAoB,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC5D,CAAC;IACN,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,UAAkB;IAClD,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACjC,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,UAAkB;IAElB,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACjC,IAAI,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;IACtE,CAAC;AACH,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,SAAS;IACvB,OAAO,KAAK,EAAE,CAAC;AACjB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type ReviewAnswers, type ReviewPage } from "../domain/review-page.js";
2
+ import { type Factory } from "../system/factory.js";
3
+ /**
4
+ * The review page of run `id`, from its data; `undefined` when it delivered
5
+ * no described pull request. `screenshotUrl` says where the page loads one.
6
+ */
7
+ export declare function readReviewPage(factory: Factory, id: string, screenshotUrl: (file: string) => string): Promise<ReviewPage | undefined>;
8
+ /** One of the screenshots the run's description lists; `undefined` for any other file. */
9
+ export declare function readReviewScreenshot(factory: Factory, id: string, file: string): Promise<{
10
+ body: Uint8Array;
11
+ type: string;
12
+ } | undefined>;
13
+ /** Where a person is in the run's review; `undefined` before the first answer, or when what is kept no longer reads. */
14
+ export declare function readReviewAnswers(factory: Factory, id: string): Promise<ReviewAnswers | undefined>;
15
+ /** Keeps the answers the page sent for the run's review; returns why they are refused, if they are. */
16
+ export declare function saveReviewAnswers(factory: Factory, id: string, answers: unknown): Promise<string | undefined>;
@@ -0,0 +1,87 @@
1
+ import { summarizeRun, UnknownRunError, z } from "@clemrig/flow";
2
+ import { maxScreenshotBytes } from "../domain/description.js";
3
+ import { reviewAnswers, reviewPage, } from "../domain/review-page.js";
4
+ import { runDir } from "../system/factory.js";
5
+ import { fileAnchor } from "../system/github.js";
6
+ import { keepAnswers, readAnswers, readScreenshot, } from "../system/run-files.js";
7
+ import { loadRun } from "./runs.js";
8
+ import { diffOf } from "./workflows/stages/deliver.js";
9
+ import { facts, specCommitOf } from "./workflows/stages/run.js";
10
+ /** The run, when it delivered a described pull request; `undefined` otherwise, an unknown ID included. */
11
+ async function delivered(factory, id) {
12
+ let state;
13
+ try {
14
+ state = await loadRun(factory, id);
15
+ }
16
+ catch (error) {
17
+ if (error instanceof UnknownRunError)
18
+ return undefined;
19
+ throw error;
20
+ }
21
+ const { pullRequest, description } = state.data;
22
+ return typeof pullRequest === "string" && typeof description === "object"
23
+ ? state
24
+ : undefined;
25
+ }
26
+ /**
27
+ * The review page of run `id`, from its data; `undefined` when it delivered
28
+ * no described pull request. `screenshotUrl` says where the page loads one.
29
+ */
30
+ export async function readReviewPage(factory, id, screenshotUrl) {
31
+ const state = await delivered(factory, id);
32
+ if (!state)
33
+ return undefined;
34
+ const f = facts(state);
35
+ const { durationMs, costUsd } = summarizeRun(state);
36
+ return reviewPage({
37
+ run: { id, durationMs, costUsd },
38
+ title: f.title,
39
+ objective: f.objective,
40
+ criteria: f.criteria,
41
+ plan: f.plan,
42
+ implementation: f.implementation,
43
+ review: f.review,
44
+ ...(f.reviews ? { reviews: f.reviews } : {}),
45
+ acceptedReview: f.acceptedReview === true,
46
+ checks: f.checks,
47
+ skippedChecks: f.skippedChecks,
48
+ files: f.changes.files,
49
+ diff: await diffOf(f),
50
+ description: f.description,
51
+ pullRequest: f.pullRequest,
52
+ links: {
53
+ spec: `${f.repository.url}/blob/${specCommitOf(f)}/${f.specPath}`,
54
+ plan: `${f.repository.url}/blob/${f.planCommit}/${f.planPath}`,
55
+ },
56
+ fileUrl: (path) => fileAnchor(f.pullRequest, path),
57
+ screenshotUrl,
58
+ });
59
+ }
60
+ /** One of the screenshots the run's description lists; `undefined` for any other file. */
61
+ export async function readReviewScreenshot(factory, id, file) {
62
+ const state = await delivered(factory, id);
63
+ if (!state)
64
+ return undefined;
65
+ const { description, screenshotsDir } = facts(state);
66
+ if (!description.screenshots.some((shot) => shot.file === file))
67
+ return undefined;
68
+ return readScreenshot(screenshotsDir, file, maxScreenshotBytes);
69
+ }
70
+ /** Where a person is in the run's review; `undefined` before the first answer, or when what is kept no longer reads. */
71
+ export async function readReviewAnswers(factory, id) {
72
+ if (!(await delivered(factory, id)))
73
+ return undefined;
74
+ const kept = reviewAnswers.safeParse(await readAnswers(runDir(factory, id)));
75
+ return kept.success ? kept.data : undefined;
76
+ }
77
+ /** Keeps the answers the page sent for the run's review; returns why they are refused, if they are. */
78
+ export async function saveReviewAnswers(factory, id, answers) {
79
+ if (!(await delivered(factory, id)))
80
+ return `Run ${id} has no change to review`;
81
+ const parsed = reviewAnswers.safeParse(answers);
82
+ if (!parsed.success)
83
+ return `Invalid answers:\n${z.prettifyError(parsed.error)}`;
84
+ await keepAnswers(runDir(factory, id), parsed.data);
85
+ return undefined;
86
+ }
87
+ //# sourceMappingURL=review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.js","sourceRoot":"","sources":["../../src/app/review.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAGL,aAAa,EACb,UAAU,GACX,MAAM,0BAA0B,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AC;IACpD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type SpecAnswers, type SpecPage } from "../domain/spec-page.js";
2
+ import type { Factory } from "../system/factory.js";
3
+ /**
4
+ * The page of issue `slug`'s spec, from its presentation; `undefined` when
5
+ * its spec is not presented, an unknown issue included.
6
+ */
7
+ export declare function readSpecPage(factory: Factory, slug: string): Promise<SpecPage | undefined>;
8
+ /** Where the operator is in issue `slug`'s spec validation; `undefined` before the first answer, or when what is kept no longer reads. */
9
+ export declare function readSpecAnswers(factory: Factory, slug: string): Promise<SpecAnswers | undefined>;
10
+ /** Keeps the answers the page sent for issue `slug`'s spec; returns why they are refused, if they are. */
11
+ export declare function saveSpecAnswers(factory: Factory, slug: string, answers: unknown): Promise<string | undefined>;
@@ -0,0 +1,37 @@
1
+ import { z } from "@clemrig/flow";
2
+ import { isSlug } from "../domain/issue.js";
3
+ import { presentedSpec, specAnswers, specPage, } from "../domain/spec-page.js";
4
+ import { keepSpecAnswers, readArtifact, readSpecAnswers as readKeptAnswers, readSpecPage as readPresented, } from "../system/issues.js";
5
+ /**
6
+ * The page of issue `slug`'s spec, from its presentation; `undefined` when
7
+ * its spec is not presented, an unknown issue included.
8
+ */
9
+ export async function readSpecPage(factory, slug) {
10
+ if (!isSlug(slug))
11
+ return undefined;
12
+ const kept = await readPresented(factory.dir, slug);
13
+ if (kept === undefined)
14
+ return undefined;
15
+ const parsed = presentedSpec.safeParse(kept);
16
+ if (!parsed.success)
17
+ throw new Error(`The presentation of ${slug}'s spec no longer reads:\n${z.prettifyError(parsed.error)}`);
18
+ return specPage(slug, parsed.data, await readArtifact(factory.dir, slug, "spec"));
19
+ }
20
+ /** Where the operator is in issue `slug`'s spec validation; `undefined` before the first answer, or when what is kept no longer reads. */
21
+ export async function readSpecAnswers(factory, slug) {
22
+ if (!(await readSpecPage(factory, slug)))
23
+ return undefined;
24
+ const kept = specAnswers.safeParse(await readKeptAnswers(factory.dir, slug));
25
+ return kept.success ? kept.data : undefined;
26
+ }
27
+ /** Keeps the answers the page sent for issue `slug`'s spec; returns why they are refused, if they are. */
28
+ export async function saveSpecAnswers(factory, slug, answers) {
29
+ if (!(await readSpecPage(factory, slug)))
30
+ return `Issue ${slug} has no presented spec`;
31
+ const parsed = specAnswers.safeParse(answers);
32
+ if (!parsed.success)
33
+ return `Invalid answers:\n${z.prettifyError(parsed.error)}`;
34
+ await keepSpecAnswers(factory.dir, slug, parsed.data);
35
+ return undefined;
36
+ }
37
+ //# sourceMappingURL=spec-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-page.js","sourceRoot":"","sources":["../../src/app/spec-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,aAAa,EAGb,WAAW,EACX,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,IAAI,eAAe,EAClC,YAAY,IAAI,aAAa,GAC9B,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAgB,EAChB,IAAY;IAEZ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IACpC,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACpD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,CAAC,OAAO;QACjB,MAAM,IAAI,KAAK,CACb,uBAAuB,IAAI,6BAA6B,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACxF,CAAC;IACJ,OAAO,QAAQ,CACb,IAAI,EACJ,MAAM,CAAC,IAAI,EACX,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAC9C,CAAC;AACJ,CAAC;AAED,0IAA0I;AAC1I,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAgB,EAChB,IAAY;IAEZ,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3D,MAAM,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,MAAM,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IAC7E,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9C,CAAC;AAED,0GAA0G;AAC1G,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAgB,EAChB,IAAY,EACZ,OAAgB;IAEhB,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACtC,OAAO,SAAS,IAAI,wBAAwB,CAAC;IAC/C,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,CAAC,MAAM,CAAC,OAAO;QACjB,OAAO,qBAAqB,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAC9D,MAAM,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACtD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { defineWorkflow, END, node, retry, z } from "@clemrig/flow";
2
2
  import { DELIVERY } from "../../domain/delivery.js";
3
3
  import { isSlug } from "../../domain/issue.js";
4
- import { attach, deliver, deliveryResult, describer, judgeDescription, } from "./stages/deliver.js";
4
+ import { deliver, deliveryResult, describer, judgeDescription, } from "./stages/deliver.js";
5
5
  import { implementer, judgeImplementation } from "./stages/implement.js";
6
6
  import { commitPlan, judgePlan, planner } from "./stages/plan.js";
7
7
  import { prepareIssue } from "./stages/prepare.js";
@@ -27,10 +27,7 @@ export function implement(definition) {
27
27
  { name: "implement", stages: ["implement", "implemented"] },
28
28
  { name: "verify", stages: ["verify"] },
29
29
  { name: "review", stages: ["diff", "review", "reviewed"] },
30
- {
31
- name: "deliver",
32
- stages: ["describe", "described", "deliver", "attach"],
33
- },
30
+ { name: "deliver", stages: ["describe", "described", "deliver"] },
34
31
  ],
35
32
  nodes: {
36
33
  prepare: node(prepareIssue(definition.verify), { ok: "plan" }),
@@ -66,8 +63,7 @@ export function implement(definition) {
66
63
  ok: "deliver",
67
64
  invalid: retry("describe", 2),
68
65
  }),
69
- deliver: node(deliver, { done: END, attach: "attach" }),
70
- attach: node(attach, { ok: END }),
66
+ deliver: node(deliver, { done: END }),
71
67
  },
72
68
  resumeProblem,
73
69
  // Also called for a failed run, which opened no pull request.
@@ -1 +1 @@
1
- {"version":3,"file":"implement.js","sourceRoot":"","sources":["../../../src/app/workflows/implement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EACL,MAAM,EACN,OAAO,EACP,cAAc,EACd,SAAS,EACT,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC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,EAAE,UAAU,CAAC,GAAG,CAAC,EAC/D,EAAE,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CACpD;YACD,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE;gBAChC,EAAE,EAAE,SAAS;gBACb,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;aAC9B,CAAC;YACF,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;SACtC;QACD,aAAa;QACb,8DAA8D;QAC9D,aAAa,EAAE,cAAc;KAC9B,CAAC,CAAC;AACL,CAAC"}
@@ -1,2 +1,5 @@
1
- /** Checks a draft written by an agent, then writes it as the issue's issue.md or spec.md. */
1
+ /**
2
+ * Checks a draft written by an agent, then writes it as the issue's
3
+ * issue.md or spec.md, or as the presentation of its spec (`page`).
4
+ */
2
5
  export declare const issueSave: import("@clemrig/flow").Workflow;
@@ -1,15 +1,16 @@
1
1
  import { defineWorkflow, END, node, step, z } from "@clemrig/flow";
2
2
  import { isSlug, parseIssue } from "../../domain/issue.js";
3
3
  import { parseSpec } from "../../domain/spec.js";
4
- import { hasArtifact, isIssue, readDraft, writeArtifact, } from "../../system/issues.js";
4
+ import { parsePresentation } from "../../domain/spec-page.js";
5
+ import { forgetSpecAnswers, hasArtifact, isIssue, readArtifact, readDraft, writeArtifact, writeSpecPage, } from "../../system/issues.js";
5
6
  const input = z.object({
6
7
  issue: z
7
8
  .string()
8
9
  .refine(isSlug, "Expected lowercase words separated by hyphens"),
9
- kind: z.enum(["issue", "spec"]),
10
+ kind: z.enum(["issue", "spec", "page"]),
10
11
  file: z.string().min(1),
11
12
  });
12
- /** What is wrong with a draft: its format, and for a spec, dependencies that are no issue of the repository. */
13
+ /** What is wrong with a draft of issue.md or spec.md: its format, and for a spec, dependencies that are no issue of the repository. */
13
14
  async function draftProblems(dir, { issue, kind }, text) {
14
15
  if (kind === "issue") {
15
16
  const parsed = parseIssue(text);
@@ -24,7 +25,35 @@ async function draftProblems(dir, { issue, kind }, text) {
24
25
  problems.push(`Dependencies: there is no issue ${dependency} in .factory/issues/`);
25
26
  return problems;
26
27
  }
27
- /** Checks a draft written by an agent, then writes it as the issue's issue.md or spec.md. */
28
+ /**
29
+ * Checks the presentation of issue `issue`'s spec an agent drafted, then
30
+ * keeps it with the spec it presents, word for word, as `spec-page.json`;
31
+ * the operator's answers on the previous one are forgotten.
32
+ */
33
+ async function savePresentation(dir, issue, file) {
34
+ const spec = await readArtifact(dir, issue, "spec");
35
+ if (spec === undefined)
36
+ throw new Error(`Issue ${issue} has no spec.md: save it first`);
37
+ const parsedSpec = parseSpec(spec, issue);
38
+ if (!parsedSpec.ok)
39
+ throw new Error(`Issue ${issue}'s spec.md is invalid: save a valid spec first`);
40
+ const parsed = parsePresentation(await readDraft(file), parsedSpec.value);
41
+ if (!parsed.ok)
42
+ throw new Error([
43
+ `Invalid presentation draft ${file}:`,
44
+ ...parsed.problems.map((problem) => `- ${problem}`),
45
+ ].join("\n"));
46
+ const path = await writeSpecPage(dir, issue, {
47
+ spec,
48
+ presentation: parsed.value,
49
+ });
50
+ await forgetSpecAnswers(dir, issue);
51
+ return path;
52
+ }
53
+ /**
54
+ * Checks a draft written by an agent, then writes it as the issue's
55
+ * issue.md or spec.md, or as the presentation of its spec (`page`).
56
+ */
28
57
  export const issueSave = defineWorkflow({
29
58
  name: "issue-save",
30
59
  input,
@@ -32,6 +61,8 @@ export const issueSave = defineWorkflow({
32
61
  nodes: {
33
62
  save: node(step(async ({ dir, state }) => {
34
63
  const { issue, kind, file } = state.input;
64
+ if (kind === "page")
65
+ return { path: await savePresentation(dir, issue, file) };
35
66
  if (kind === "spec" && !(await hasArtifact(dir, issue, "issue")))
36
67
  throw new Error(`Issue ${issue} does not exist: save its issue.md first`);
37
68
  const text = await readDraft(file);
@@ -1 +1 @@
1
- {"version":3,"file":"issue-save.js","sourceRoot":"","sources":["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CAAC,CACb,CAAC;YACJ,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QAC/D,CAAC,CAAC,EACF,EAAE,EAAE,EAAE,GAAG,EAAE,CACZ;KACF;IACD,qDAAqD;IACrD,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAC1B,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;CAC9D,CAAC,CAAC"}
@@ -1,19 +1,20 @@
1
1
  import { type AgentProfile, type RunState, type Stage } from "@clemrig/flow";
2
2
  import type { AppDeclaration } from "../../../domain/app.js";
3
+ import { type Facts } from "./run.js";
3
4
  /**
4
5
  * The describing agent: once the change is approved, it explains it to a
5
6
  * reader who forgot its issue, and takes its screenshots. It never reads the
6
7
  * implementing agent's account of its own work.
7
8
  */
8
9
  export declare function describer(profile: AgentProfile, app?: AppDeclaration): Stage<"ok" | "modified">;
9
- /** Changed files only in the guide, distinct screenshots of their folder, a body GitHub accepts. */
10
+ /** The change's whole diff: a large one, from the file the review read. */
11
+ export declare function diffOf({ changes }: Facts): Promise<string>;
12
+ /** Changed files only in the guide and the decisions, distinct screenshots of their folder. */
10
13
  export declare const judgeDescription: Stage<"invalid" | "ok">;
11
14
  /**
12
15
  * Commits the changes with the plan's subject, force-pushes the branch, opens
13
16
  * or updates its pull request, then returns to the main branch.
14
17
  */
15
- export declare const deliver: Stage<"attach" | "done">;
16
- /** Uploads the screenshots into the open pull request's body. */
17
- export declare const attach: Stage<"ok">;
18
+ export declare const deliver: Stage<"done">;
18
19
  /** The delivered pull request, its review, checks and merge danger; nothing before it is open. */
19
20
  export declare function deliveryResult(state: Readonly<RunState>): string[];