You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: make galley spec the single source of truth for the agent contract
The agent-facing contract (review modes, the await/comment/reload loop,
await exit semantics, ReviewResult, how to act on a review, the
guided-review schema) was hand-duplicated across SKILL.md, the AGENTS.md
snippet, and partially in guide-spec — and CLAUDE.md warned to update
SKILL.md on every contract change. The skill and snippet drift from the
installed binary's real behavior.
Consolidate the full contract into a CLI-printed spec so the binary and
its instructions ship together and can't diverge:
- Rename src/guidespec.ts -> src/spec.ts; the SPEC export now holds the
full contract, with the guided-review JSON schema folded in as a
section.
- Add `galley spec`; remove `galley guide-spec` entirely (clean break).
Repoint the server error `docs` field and the inline schema pointer to
`galley spec`.
- Shrink SKILL.md and the AGENTS.md snippet to bootstrap only (what
Galley is, when to use it, install, the 3 start commands) plus a
once-per-session "run `galley spec` and follow it" pointer.
- Redirect CLAUDE.md's maintenance rule and README's pointer at
src/spec.ts / `galley spec`.
- Add src/spec.test.ts guarding that SPEC carries every consolidated
section and has no dangling skill/guide-spec references.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ The two worlds do not import each other. `src/types.ts` (backend) and `src/ui/ty
46
46
-`contentHash`/`reviewedHash` pairs detect staleness: if the agent rewrites a block (or a file) after it was decided/approved, the decision/approval resets to pending on reload. The same pattern invalidates comment anchors (`anchorText` → re-anchoring → `unanchored`) and guides (`baseDiffHash`).
47
47
- Desks are idempotent per repo+session: `stablePort` hashes repo+session to a port in 41000–50999 so a restarted desk binds the same origin and an open tab self-heals; a desk lock file is trusted only if the server actually answers (`deskAlive`).
48
48
49
-
**Agent contract:** plain JSON on stdout. `galley await` long-polls and prints one tagged event — `{"kind":"question",…}` (answer now via `galley comment`) or `{"kind":"review","result":{…ReviewResult…}}` (the reviewer hit Send). The contract is documented for consuming agents in `skills/galley/SKILL.md` (and the short form in `skills/galley/agents-snippet.md`); the server's error responses point there too. **If you change the CLI flags, events, or ReviewResult shape, update SKILL.md in the same change.**`scripts/smoke.mjs`exercises this contract end-to-end and is the regression net for it.
49
+
**Agent contract:** plain JSON on stdout. `galley await` long-polls and prints one tagged event — `{"kind":"question",…}` (answer now via `galley comment`) or `{"kind":"review","result":{…ReviewResult…}}` (the reviewer hit Send). The contract is the single source of truth in `src/spec.ts` (printed by `galley spec`); the skill (`skills/galley/SKILL.md`) and the AGENTS.md snippet (`skills/galley/agents-snippet.md`) are bootstrap-only and point consuming agents at `galley spec`, and the server's error responses do too. **If you change the CLI flags, events, or ReviewResult shape, update `src/spec.ts` in the same change.**`scripts/smoke.mjs`and `src/spec.test.ts` exercise this contract and are the regression net for it.
50
50
51
51
**UI:** an Alpine.js app with a global store (`src/ui/store.ts`); `poll.ts` polls `/api/state`, `render.ts` renders the diff via `@pierre/diffs` (which renumbers lines per render — display anchors are derived, raw file lines stay canonical), `keys.ts` holds the keyboard-first command map, and `guide.ts`/`tree.ts`/`decisions.ts` etc. are feature modules.
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ I'm not saying this is *the* review surface. I built it in a week and I'm still
48
48
galley pr feature-branch # review a branch's commits vs its merge-base
49
49
```
50
50
51
-
Galley opens in your browser and stays open. You review and click **Send to Agent**; the agent attaches, acts on each send, and replies in the same tab. More flags (`--repo`, `--path`, `--port`, `--no-open`, `--guide`, …) are documented in the skill.
51
+
Galley opens in your browser and stays open. You review and click **Send to Agent**; the agent attaches, acts on each send, and replies in the same tab. The full agent contract — modes, the event loop, all flags (`--repo`, `--path`, `--port`, `--no-open`, `--guide`, …), `ReviewResult`, and the guided-review schema — is printed by **`galley spec`** (always current with your installed version); the skill is a thin pointer to it.
Paste the block below into your agent's instruction file (`AGENTS.md`, `CLAUDE.md`, `.cursorrules`, …) so the agent always routes plan/PR/change review through Galley. It's deliberately short and points at the skill (`skills/galley/SKILL.md`) for the full contract — modes, the event loop, CLI options, and the `ReviewResult` shape.
3
+
Paste the block below into your agent's instruction file (`AGENTS.md`, `CLAUDE.md`, `.cursorrules`, …) so the agent always routes plan/PR/change review through Galley. It's deliberately short: it points at `galley spec` — printed by the installed binary, always current — for the full contract (modes, the event loop, CLI options, `ReviewResult`, and how to act).
4
4
5
5
---
6
6
7
7
## Reviewing with Galley
8
8
9
-
When the user should review a plan, a PR, or code changes you've made, hand it to **Galley** — a living browser review desk.
9
+
When the user should review a plan, a PR, or code changes you've made, hand it to **Galley** — a living browser review desk. Three ways to start (each stays alive across rounds):
10
10
11
11
-**Changes you made** → `galley --session <task-id> &` (working tree; `--diff staged` for staged only).
12
12
-**A markdown plan / single artifact** → `galley file <path> &`.
13
13
-**A branch / PR** → `galley pr <ref> &`.
14
14
15
-
Optionally attach an AI **guided review** so the human gets an overview + a logical, annotated file order: add `--guide <file>` to the start command (see the skill for the JSON schema). Write the guide file **outside the repo working tree** (a temp path or gitignored dir) — working-tree review surfaces untracked files, so a guide left in the repo shows up as a stray addition.
16
-
17
-
Then loop: `galley await --session <task-id>` blocks for the next event and prints a tagged JSON envelope.
18
-
-`{"kind":"question",…}` → answer **now** with `galley comment --path … --line … --side … --body "…"` at the question's location. While gathering the answer (or acting on a review), post brief `galley status --session <task-id> --body "Reading X…"` lines — they show live next to the reviewer's waiting indicator so they're not staring at a static spinner.
19
-
-`{"kind":"review","result":{…}}` → act on `result`: revert **rejected**, make **requestedChanges**, leave **accepted** alone, leave **approvedFiles** (signed off as-is) untouched, don't touch **stagedFiles** unless a change requires it. (Editing an approved file invalidates its approval → it needs re-review next round.)
20
-
21
-
After editing code, run `galley reload --session <task-id>` so your edits show in the open tab (add `--guide <file>` to swap in a regenerated guide), then `galley await` again for the next round. The desk stays open across rounds and the reviewer keeps **one tab**: starting is idempotent (a live desk is reused, never duplicated) and the port is stable per session, so even after a desk process dies, re-running the start command brings the same tab back to life — never open a second desk for the same session.
22
-
23
-
Full reference (modes, options, exit semantics, `ReviewResult`): **`skills/galley/SKILL.md`**.
15
+
**For the full contract — the `await`/`comment`/`reload` loop, event shapes, `ReviewResult`, how to act on accepted/rejected/requested changes, the guided-review schema, and all options — run `galley spec` and follow it (once per session before your first review).**`galley spec` ships with the binary, so it never goes stale; this snippet intentionally doesn't duplicate it.
0 commit comments