@xulthekl/team-flow 0.24.0 → 0.26.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 (61) hide show
  1. package/.claude/always/phase-guard.md +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/.cursor-plugin/marketplace.json +1 -1
  6. package/.cursor-plugin/plugin.json +1 -1
  7. package/.github/plugin/marketplace.json +2 -2
  8. package/AGENTS.md +3 -3
  9. package/CHANGELOG.md +86 -0
  10. package/GEMINI.md +1 -1
  11. package/INSTALL.md +1 -1
  12. package/README.md +1 -1
  13. package/docs/README_en.md +1 -1
  14. package/docs/solutions/INDEX.md +1 -0
  15. package/docs/solutions/cross-phase/2026-07-29-no-summary.md +17 -0
  16. package/gemini-extension.json +1 -1
  17. package/hooks/session-start +2 -2
  18. package/llms.txt +1 -1
  19. package/package.json +1 -1
  20. package/plugin.json +1 -1
  21. package/scripts/lib/config-loader.mjs +10 -3
  22. package/skills/bug-investigator/SKILL.md +1 -1
  23. package/skills/build-executor/SKILL.md +19 -19
  24. package/skills/build-executor/implementer-prompt.md +1 -1
  25. package/skills/build-executor/references/execution-modes.md +6 -6
  26. package/skills/build-executor/task-reviewer-prompt.md +1 -1
  27. package/skills/ce-brainstorm/SKILL.md +63 -347
  28. package/skills/ce-brainstorm/references/brainstorm-sections.md +11 -0
  29. package/skills/ce-brainstorm/references/grounding.md +47 -0
  30. package/skills/ce-brainstorm/references/output-format.md +25 -0
  31. package/skills/ce-brainstorm/references/phase0-routing.md +96 -0
  32. package/skills/ce-brainstorm/references/prd-mapping.md +37 -0
  33. package/skills/ce-brainstorm/references/prototype-loop.md +55 -0
  34. package/skills/ce-ideate/SKILL.md +31 -348
  35. package/skills/ce-ideate/references/grounding.md +107 -0
  36. package/skills/ce-ideate/references/phase0-scope.md +134 -0
  37. package/skills/ce-ideate/references/topic-surface.md +37 -0
  38. package/skills/ce-proof/SKILL.md +8 -266
  39. package/skills/ce-proof/references/api-recipes.md +145 -0
  40. package/skills/ce-proof/references/workflows.md +124 -0
  41. package/skills/code-reviewer/SKILL.md +2 -2
  42. package/skills/code-reviewer/code-reviewer-prompt.md +1 -1
  43. package/skills/contract-builder/SKILL.md +6 -6
  44. package/skills/need-explorer/SKILL.md +2 -2
  45. package/skills/prototype/SKILL.md +16 -2
  46. package/skills/prototype/references/agents/design-system-architect.md +11 -122
  47. package/skills/prototype/references/interactive-prototype.md +110 -0
  48. package/skills/prototype/references/layouts.md +188 -2
  49. package/skills/prototype/references/orchestration-flow.md +8 -1
  50. package/skills/prototype/references/template.html +32 -0
  51. package/skills/prototype/references/wireframe.md +117 -0
  52. package/skills/release-archivist/SKILL.md +14 -12
  53. package/skills/release-archivist/references/closing-procedures.md +11 -9
  54. package/skills/spec-merger/SKILL.md +2 -2
  55. package/skills/spec-writer/SKILL.md +3 -3
  56. package/skills/workflow-orchestrator/references/s2-prd-prototype-loop.md +1 -1
  57. package/skills/workflow-orchestrator/references/s4-split-validate.md +1 -1
  58. package/skills/workflow-orchestrator/references/s5-monitoring.md +1 -1
  59. package/skills/workflow-start/SKILL.md +16 -16
  60. package/skills/workflow-start/references/routing-rules.md +17 -17
  61. package/templates/prd-brainstorm-profile.md +69 -0
@@ -0,0 +1,134 @@
1
+ # Phase 0: Resume and Scope
2
+
3
+ Detailed routing logic for Phase 0 sub-phases. When subject, mode, and format are already clear from the prompt, resolve in one pass and move on.
4
+
5
+ ## 0.0 Resolve Output Mode
6
+
7
+ Determine `OUTPUT_FORMAT` for the ideation artifact. Output mode is **exclusive** — HTML (`.html`) OR markdown (`.md`), never both. Unlike `ce-plan` and `ce-brainstorm` (which default to `md`), ce-ideate defaults to **`html`** — ideation artifacts are read mainly by humans weighing candidate directions.
8
+
9
+ Precedence: in-prompt request > user-stated preference > config > default (`html`), with a hard pipeline-mode override.
10
+
11
+ **Read config.** Resolve `<repo-root>` via `git rev-parse --show-toplevel`. Then read `<repo-root>/.compound-engineering/config.local.yaml`. If unavailable, fall through to defaults.
12
+
13
+ Resolution steps:
14
+
15
+ 1. **In-prompt request.** Match `output:` shorthand or plain language to `md`/`html` case-insensitively. Distinguish doc-format request from subject matter: "ideate on an HTML export feature" is the work, not a format request.
16
+ - `output:` alone (no value) → no-op, fall through to step 2.
17
+ - `output:<unknown>` (e.g., `output:pdf`) → drop the token, fall through, remember to emit a one-line note after final resolution.
18
+
19
+ 2. **User-stated preference.** Honor a preference established earlier in session/memory/instructions. A remembered preference overrides config. Do not search instruction files.
20
+
21
+ 3. **Config.** If config has an **active (non-commented)** `ideate_output:` key matching `md` or `html`, use it. Critical: lines starting with `#` are YAML comments and must be ignored.
22
+
23
+ 4. **Default.** `OUTPUT_FORMAT=html`.
24
+
25
+ 5. **Pipeline override.** Force `OUTPUT_FORMAT=md` in any pipeline or `disable-model-invocation` context.
26
+
27
+ **Token-parsing convention:** only literal-prefix flag tokens (`output:`, `mode:`) are consumed and stripped. Other `<word>:<word>` tokens pass through verbatim.
28
+
29
+ **Defer loading the format-rendering reference.** The deliverable is written at Phase 4, so `references/ideation-sections.md` and rendering references are only needed then.
30
+
31
+ The `output:` preference does NOT auto-propagate to `ce-brainstorm` on handoff.
32
+
33
+ ## 0.1 Check for Recent Ideation Work
34
+
35
+ Look in `docs/ideation/` for ideation documents (`*.md` or `*.html`) created within the last 30 days.
36
+
37
+ Treat a prior ideation doc as relevant when:
38
+ - the topic matches the requested focus
39
+ - the path or subsystem overlaps the requested focus
40
+ - the request is open-ended and there is an obvious recent open ideation doc
41
+ - the issue-grounded status matches (don't mix issue-tracker and non-issue ideation)
42
+
43
+ If a relevant doc exists, ask whether to continue from it or start fresh. If continuing: read the document, summarize what has been explored, preserve previous ideas and rejection summary, update the existing file.
44
+
45
+ **Write the update back in the existing file's format**, overriding the Phase 0.0 baseline. Format precedence on resume: explicit `output:` arg > resumed file's extension > config > default (`html`); pipeline runs still force `md`.
46
+
47
+ ## 0.2 Subject-Identification Gate
48
+
49
+ Check whether the subject of ideation is identifiable. If the subject is ambiguous enough that reasonable sub-agents would diverge, output will be scattered.
50
+
51
+ **Questioning principles (apply in this phase and in 0.4):**
52
+ - Questions exist only to supply what sub-agents need: an identifiable subject (this phase) and enough context for the agent to say something specific (0.4).
53
+ - Never ask about solution direction, constraints, audience, tone, success criteria.
54
+ - Always keep "Surprise me" as a real option.
55
+ - Stop as soon as the subject is identifiable or delegated to "Surprise me." More than 3 total questions is a smell — consider suggesting `ce-brainstorm`.
56
+
57
+ **Detection — issue-tracker intent (repo mode only).** Trigger only when the prompt uses phrases like `github issues`, `open issues`, `issue patterns`, `what users are reporting`, `bug reports`. Do NOT trigger on `bug in auth`, `fix the login issue` — these are focus hints.
58
+
59
+ **Detection — subject identifiability.** Test: would a reader, seeing only this prompt, know what subject the agent should ideate on? Vagueness is about what the words *refer to*, not phrase length: `browser sniff` names a feature (identifiable); `quick wins` names only a quality (vague).
60
+
61
+ **Being inside a repo does not settle vagueness.** `improvements` in any repo is still scattered. The repo provides material for grounding *after* a subject is settled, not the subject itself.
62
+
63
+ **Genuine ambiguity (repo mode).** When real doubt remains, Glob for the phrase in filenames, or Grep for it in README/docs. Any repo footprint → identifiable; none and still vague → ask.
64
+
65
+ **The scope question.** Ask via blocking question tool:
66
+ - Stem: "What should the agent ideate about?"
67
+ - Options: "Specify a subject" / "Surprise me" / "Cancel"
68
+
69
+ Routing:
70
+ - **Specify** → accept the user's follow-up as the subject. Re-apply identifiability check once.
71
+ - **Surprise me** → mark as **surprise-me mode**. Agent discovers subjects from Phase 1 material. CWD inside git repo → route to repo-grounded; otherwise elsewhere-software (require Phase 0.4 to collect substance). Skip Decision 1/2 in Phase 0.3.
72
+ - **Cancel** → exit cleanly.
73
+
74
+ ## 0.3 Mode Classification
75
+
76
+ Classify the **subject of ideation** (settled in 0.2) into one of three modes:
77
+
78
+ **Surprise-me short-circuit.** Skip the two-decision classification. Use deterministic rule from 0.2: repo-grounded when CWD is inside git repo, elsewhere-software otherwise. State chosen mode in one sentence and proceed.
79
+
80
+ For specified subjects, make two sequential binary decisions:
81
+
82
+ **Decision 1 — repo-grounded vs elsewhere.** Weigh prompt content first, topic-repo coherence second, CWD repo presence as supporting evidence only.
83
+
84
+ - Positive signals for **repo-grounded**: prompt references repo files, code, architecture, modules, tests, workflows. Issue-tracker intent is always repo-grounded.
85
+ - Negative signals (push toward **elsewhere**): prompt names things absent from the repo (pricing, naming, narrative, business model, personal decisions, brand).
86
+
87
+ **Decision 2 (only fires if Decision 1 = elsewhere) — software vs non-software.** Classify by whether the *subject* of ideation is a software artifact or system. If the topic concerns a product, app, SaaS, web/mobile UI, feature, it is **elsewhere-software** — even when ideas are about copy, UX, CRO, pricing for that software product. **Elsewhere-non-software** is reserved for topics with no software surface: company naming, narrative writing, personal decisions, non-digital business strategy, physical products.
88
+
89
+ State the inferred mode in one sentence using plain language. Never print internal taxonomy labels.
90
+
91
+ **Active confirmation on mode ambiguity.** Only fire when classification is genuinely ambiguous. Ask one confirmation question via blocking tool with two self-contained labels.
92
+
93
+ **Routing rule (non-software mode).** Run Phase 1 Elsewhere-mode grounding. Load `references/universal-ideation.md` and follow it in place of Phase 2 and Phase 5 menu. Do not run repo-specific codebase scan.
94
+
95
+ ## 0.4 Context-Substance Gate (Elsewhere Modes Only)
96
+
97
+ Skip in repo mode. In elsewhere modes, Phase 1 agents depend on user-supplied context. A bare prompt leaves agents with nothing to synthesize.
98
+
99
+ Apply discrimination test: would swapping one piece of the user's stated context for a contrasting alternative materially change which ideas survive? If yes, context is load-bearing — proceed. If no, ask 1-3 narrowly chosen questions focused on **supplying substance**:
100
+ - A URL or file to read
101
+ - A brief description of the current state
102
+ - A paste of an existing draft or brief
103
+
104
+ **Surprise-me exception.** In surprise-me + elsewhere-software, at least one piece of substance is required. Dismissive responses are not acceptable — tell them the run needs material and end cleanly.
105
+
106
+ When user provides rich context up front, confirm understanding in one line and skip.
107
+
108
+ If this step materially changes the topic, re-run 0.2 and 0.3 before dispatching Phase 1.
109
+
110
+ ## 0.5 Interpret Focus and Volume
111
+
112
+ Infer two things from the argument:
113
+ - **Focus context** — concept, path, constraint, or open-ended
114
+ - **Volume override** — any hint that changes candidate or survivor counts
115
+
116
+ Default volume: each ideation frame yields ~6-8 ideas (~36-48 raw across six frames; ~25-30 survivors after dedupe); keep top 5-7 survivors.
117
+
118
+ Honor clear overrides: `top 3`, `100 ideas`, `raise the bar`.
119
+
120
+ **Depth override.** `go deep` opts into maximum depth: every ideation agent moves to ceiling tier, Phase 2 verification read budget doubles, Phase 3 adds a second critic.
121
+
122
+ **Tactical scope detection.** Parse focus hint for: `polish`, `typo`, `quick wins`, `small improvements`, `cleanup`. When present, lower Phase 2 ambition floor.
123
+
124
+ ## 0.6 Cost Transparency Notice
125
+
126
+ Before dispatching Phase 1, surface the agent count and cost shape for the inferred mode in one short line.
127
+
128
+ Compute the count: 1 grounding-context agent + 1 learnings (skip in elsewhere-non-software) + 1 web researcher + evidence scouts (repo mode only, max 5) + user-research distillers + ideation fleet (5 default: 3 generation + 2 ceiling; 6 all-ceiling in surprise-me or `go deep`; 4 in issue-tracker mode) + 1 basis verifier.
129
+
130
+ Examples (defaults, no skips):
131
+ - **Repo mode, specified subject:** "Will dispatch ~13 agents, most on cheap tiers."
132
+ - **Repo mode, surprise-me:** "Will dispatch ~10 agents (surprise-me mode: deeper exploration per agent)."
133
+ - **Elsewhere-software:** "Will dispatch ~9 agents."
134
+ - **Elsewhere-non-software:** "Will dispatch ~8 agents."
@@ -0,0 +1,37 @@
1
+ # Phase 1.5: Topic-Surface Decomposition
2
+
3
+ Before dispatching frame agents in Phase 2, decompose the topic into 3-5 orthogonal **axes** that name *what aspects of the subject to think about*. Phase 2 frames determine *how to think* (the lens); axes determine *what to think on* (the surface). Without an explicit axis list, parallel frames tend to converge on whichever interpretation of the subject is most salient.
4
+
5
+ The axis analysis itself is a single orchestrator-side pass against the grounding summary already in context — no additional grounding read, no user-facing question.
6
+
7
+ ## Axis Criteria
8
+
9
+ - **3-5 axes.** Fewer than 3 means the topic is atomic — skip. More than 5 fragments dispatch and produces thin coverage.
10
+ - **Orthogonal.** A single idea should naturally fall on one axis, not span multiple. Merge axes that overlap heavily.
11
+ - **Derived from grounding.** The grounding summary contains the substance; do not pick axes from a generic template.
12
+ - **At the same level.** Don't mix "the entire pricing page" with "the $9.99 tier copy".
13
+ - **Named in the topic's language.** Use words a reader of the topic would recognize, not meta-language about ideation.
14
+
15
+ ## Worked Examples (illustrative, not a template)
16
+
17
+ | Topic | Axes |
18
+ |---|---|
19
+ | Social sharing of convergence pages | Send mechanics; discovery (receive side); arrival/dwell experience; compounding over time; actor types |
20
+ | Improve authentication system | Sign-in flow; session management; account recovery; permissions; identity providers |
21
+ | Dark mode for our app | Visual surfaces; toggle UX; system-preference detection; asset variants; edge cases |
22
+
23
+ ## Skip Condition
24
+
25
+ Some subjects are atomic and resist meaningful decomposition — a single string output (a name, a tagline), a narrowly-scoped tactical fix, or a topic where candidate axes *are* the deliverable. When 3+ orthogonal axes cannot be generated, skip decomposition. Note `Decomposition skipped — atomic subject` in the grounding summary.
26
+
27
+ **Surprise-me skip.** In surprise-me mode there is no settled subject to decompose. Skip and note `Decomposition skipped — surprise-me mode`.
28
+
29
+ ## Evidence Scouts (repo mode, when axes exist)
30
+
31
+ Decomposition names what to look at; scouts gather what is actually there. Dispatch one extraction-tier sub-agent per axis (max 5) in parallel. Prompt:
32
+
33
+ > Gather evidence about **{axis}** in this repo, scoped to {focus/subject}. Search first with native file-search and content-search tools, then read targeted sections — budget ~20 reads. Write an **evidence dossier** to `{scratch-dir}/evidence-{axis-slug}.md`: at most 150 lines of verbatim quotes and short code snippets, each with a `file:line` pointer, covering pain points, workarounds, TODO/FIXME markers, surprising patterns, and leverage points on this axis. Extraction only — quote what the repo says; do not interpret or propose ideas. Return only a gist: 3-5 lines summarizing what the dossier holds, plus its absolute path and entry count.
34
+
35
+ Append the returned gists (with dossier paths) to the consolidated grounding summary under `Evidence: <axis>`. The dossier files are the evidence layer Phase 2 agents read and cite from. Skip scouts when decomposition was skipped, in surprise-me mode, and in elsewhere modes.
36
+
37
+ Append the axis list (or skip-reason) to the consolidated grounding summary under `Topic axes`. Phase 2 reads this section to thread axes into sub-agent prompts; Phase 3 uses it for axis-spread scoring; Phase 4 includes it under Grounding Context.
@@ -23,15 +23,12 @@ Set the display name once per doc session by posting to presence with the `X-Age
23
23
 
24
24
  ## Publish Mode
25
25
 
26
- The primary use is one-way publishing: take an existing local markdown file (a brainstorm, a unified plan, a learning, a draft), read its full contents and post them as the new doc's body (see "Workflow: Create and Share a New Document" for the source-file recipe — never publish placeholder content), and hand the user a shareable URL. The local file stays canonical — publishing does not sync anything back to disk. The user can open the link to read, comment, and share with others; the agent can also participate via the edit APIs below when given the URL. Two entry points, identical mechanics (see "Workflow: Create and Share a New Document"):
26
+ The primary use is one-way publishing: take an existing local markdown file (a brainstorm, a unified plan, a learning, a draft), read its full contents and post them as the new doc's body, and hand the user a shareable URL. The local file stays canonical — publishing does not sync anything back to disk. Two entry points:
27
27
 
28
- - **Direct user request** — a bare user phrase naming a local markdown file and asking to share it via Proof: "share this to proof", "publish this to proof", "open this in proof editor so I can review", "get me a proof link for this doc". The file is whichever markdown the user just created, edited, or referenced; if ambiguous, ask which file. This is a first-class entry point — do not require an upstream caller.
28
+ - **Direct user request** — a bare user phrase naming a local markdown file and asking to share it via Proof: "share this to proof", "publish this to proof", "open this in proof editor so I can review", "get me a proof link for this doc". The file is whichever markdown the user just created, edited, or referenced; if ambiguous, ask which file.
29
29
  - **Upstream skill handoff** — `ce-brainstorm`, `ce-ideate`, or `ce-plan` finishes a draft and hands it off to publish for human review, passing the file path and title explicitly.
30
30
 
31
- Only publish markdown. If the source is an HTML unified plan, do not upload it
32
- to Proof; return the local browser/open path instead. When publishing a unified
33
- plan, label the title by readiness when available, e.g. `Plan: <title>
34
- (requirements-only)` or `Plan: <title> (implementation-ready)`.
31
+ Only publish markdown. If the source is an HTML unified plan, do not upload it to Proof; return the local browser/open path instead. When publishing a unified plan, label the title by readiness when available, e.g. `Plan: <title> (requirements-only)` or `Plan: <title> (implementation-ready)`.
35
32
 
36
33
  Do not silently replace repo-tracked project docs with Proof links. Do not put secrets, credentials, API keys, private tokens, or sensitive personal data in Proof unless the user explicitly approves.
37
34
 
@@ -63,94 +60,9 @@ Canonical agent read/write (v3 only — do not invent other agent mutation paths
63
60
  - Read: `GET /api/agent/<slug>/v3/document`
64
61
  - Write: `POST /api/agent/<slug>/v3/edit`
65
62
 
66
- ### Create a Shared Document
63
+ For detailed curl examples for all operations (create, read, edit, presence, title, delete), read `references/api-recipes.md`.
67
64
 
68
- No authentication required on the public create route. Returns a shareable URL with tokens.
69
-
70
- ```bash
71
- curl -sS -X POST https://www.proofeditor.ai/share/markdown \
72
- -H "Content-Type: application/json" \
73
- -d '{"title":"My Doc","markdown":"# Hello\n\nContent here."}'
74
- ```
75
-
76
- **Response fields to keep:**
77
-
78
- ```json
79
- {
80
- "slug": "abc123",
81
- "tokenUrl": "https://www.proofeditor.ai/d/abc123?token=xxx",
82
- "accessToken": "xxx",
83
- "ownerSecret": "yyy",
84
- "shareUrl": "https://www.proofeditor.ai/d/abc123",
85
- "_links": {
86
- "read": "https://www.proofeditor.ai/api/agent/abc123/v3/document",
87
- "edit": { "method": "POST", "href": "/api/agent/abc123/v3/edit" },
88
- "delete": { "method": "DELETE", "href": "/api/documents/abc123" }
89
- }
90
- }
91
- ```
92
-
93
- Use `tokenUrl` as the shareable link. Extract `slug`, `accessToken`, and `ownerSecret` immediately — `ownerSecret` is required for cleanup while the doc is still unclaimed.
94
-
95
- ### Read a Shared Document
96
-
97
- If you already have a shared Proof URL, fetch with content negotiation or v3:
98
-
99
- ```bash
100
- curl -sS -H "Accept: application/json" "https://www.proofeditor.ai/d/{slug}?token=<token>"
101
- curl -sS -H "Accept: text/markdown" "https://www.proofeditor.ai/d/{slug}?token=<token>"
102
-
103
- curl -sS "https://www.proofeditor.ai/api/agent/{slug}/v3/document" \
104
- -H "Authorization: Bearer <token>" \
105
- -H "X-Agent-Id: ai:compound-engineering"
106
- # -> { ok, revision, title, markdown, comments[], suggestions[], mutationReady? }
107
- ```
108
-
109
- ACTIVE docs can be read tokenlessly via `v3/document`. Mutations, presence, and events need a tokenized credential. Tokenless `GET /d/<slug>` JSON reports `role: null` and no mutation links — that is truthful capability reporting, not a browser lock.
110
-
111
- `comments[]` and `suggestions[]` on the v3 read are the source of review state. Use a comment's `id` for `reply` / `resolve` / `unresolve`. Use a suggestion's `id` for `accept` / `reject`. v3 supports resolving and unresolving comments; it does **not** support deleting comments.
112
-
113
- When `mutationReady` is `false`, `revision` may be `null` — omit `baseRevision` and re-read shortly.
114
-
115
- ### Edit a Shared Document
116
-
117
- Send `{ by, baseRevision?, operations: [...] }` to `POST /api/agent/{slug}/v3/edit`. Targets are **visible text** in `markdown` (not raw markdown syntax, not block refs). There is no base token. `baseRevision` (integer from the last read) is an optional conflict guard — omit it to apply at head. `Idempotency-Key` is optional; use one for important writes and retries.
118
-
119
- ```bash
120
- curl -sS -X POST "https://www.proofeditor.ai/api/agent/{slug}/v3/edit" \
121
- -H "Content-Type: application/json" \
122
- -H "Authorization: Bearer <token>" \
123
- -H "X-Agent-Id: ai:compound-engineering" \
124
- -H "Idempotency-Key: $(uuidgen)" \
125
- -d '{
126
- "by":"ai:compound-engineering",
127
- "operations":[
128
- {"op":"replace","find":"old visible text","with":"new text"},
129
- {"op":"comment","on":"text to anchor on","body":"Is this still accurate?"}
130
- ]
131
- }'
132
- ```
133
-
134
- **Content operations:**
135
-
136
- | op | body |
137
- |---|---|
138
- | `replace` | `find`, `with` (optional `occurrence` / `before` / `after`) |
139
- | `insert` | `after` or `before` + `markdown` (anchor: quote, `heading:Title`, `section:Title`, `"start"`, or `"end"`) |
140
- | `delete` | `find` |
141
- | `set_document` | `markdown` (whole-doc replace as a minimal diff; safe with live collaborators) |
142
-
143
- **Review operations:**
144
-
145
- | op | body |
146
- |---|---|
147
- | `comment` | `on`, `body` (optional `occurrence`) |
148
- | `reply` | `comment` (id), `body`, optional `resolve: true` |
149
- | `resolve` / `unresolve` | `comment` (id) |
150
- | `suggest` | `kind: "insert"\|"delete"\|"replace"`, `find`, `with?` (`with` required for insert/replace) |
151
- | `accept` / `reject` | `suggestion` (id) |
152
-
153
- ### Edit Strategy
65
+ ## Edit Strategy
154
66
 
155
67
  Prefer the narrowest op:
156
68
 
@@ -158,183 +70,13 @@ Prefer the narrowest op:
158
70
  2. Visible track-changes desired → `suggest` (then `accept`/`reject` as needed)
159
71
  3. Whole-doc replacement → `set_document` only when the user asks for full replacement or the change cannot be expressed narrowly
160
72
 
161
- If a `find`/anchor matches more than once, the server rejects with `TARGET_AMBIGUOUS` and `error.candidates` nothing is changed. Disambiguate with `occurrence` (`"first"`, `"last"`, or 0-based index) or `before`/`after`. Never assume silent first-match.
162
-
163
- Content ops in one request apply atomically; review ops then apply in order. If a review op fails after content committed, the response is `ok: false` with `partial: true` — re-read and retry only the failed op (same `Idempotency-Key` safely replays).
164
-
165
- **Errors** use `{ ok:false, error:{ code, message, retryable, opIndex?, target?, candidates?, current? } }`. Codes: `AUTH`, `NOT_FOUND`, `INVALID_REQUEST`, `TARGET_NOT_FOUND`, `TARGET_AMBIGUOUS`, `CONFLICT`, `TOO_LARGE`, `BUSY`, `PENDING`, `INTERNAL`.
166
-
167
- - `retryable: false` — fix the request; do not blind-retry
168
- - `retryable: true` with `error.current` — re-resolve targets against `current` and retry once
169
- - `TARGET_AMBIGUOUS` — add `occurrence` / `before` / `after` from `candidates`
170
- - `BUSY` — brief backoff and retry
171
- - Settled `200` with `ok:true` — inspect returned `revision` / document; chain without an extra read when the body is complete
172
- - `202` / `PENDING` — write may have committed; re-read `v3/document` before chaining or reporting success
73
+ If a `find`/anchor matches more than once, the server rejects with `TARGET_AMBIGUOUS` — disambiguate with `occurrence` / `before` / `after`. Never assume silent first-match.
173
74
 
174
75
  After every successful edit: confirm `ok:true`, confirm the intended text/comment/suggestion, then report the Proof link with a short summary.
175
76
 
176
- ### Presence
177
-
178
- ```bash
179
- curl -sS -X POST "https://www.proofeditor.ai/api/agent/{slug}/presence" \
180
- -H "Content-Type: application/json" \
181
- -H "Authorization: Bearer <token>" \
182
- -H "X-Agent-Id: ai:compound-engineering" \
183
- -d '{"name":"Compound Engineering","status":"reading","summary":"Joining the doc"}'
184
- ```
185
-
186
- Common statuses: `reading`, `thinking`, `acting`, `waiting`, `completed`, `error`.
187
-
188
- ### Title
189
-
190
- ```bash
191
- curl -sS -X PUT "https://www.proofeditor.ai/api/documents/{slug}/title" \
192
- -H "Content-Type: application/json" \
193
- -H "Authorization: Bearer <token>" \
194
- -d '{"title":"Updated document title"}'
195
- ```
196
-
197
- ### Delete
198
-
199
- Only owner credentials can delete:
200
-
201
- ```bash
202
- curl -sS -X DELETE "https://www.proofeditor.ai/api/documents/{slug}" \
203
- -H "Authorization: Bearer <ownerSecret>"
204
- ```
205
-
206
- Viewer, commenter, and editor `accessToken` values cannot delete. Success returns `shareState: "DELETED"`; later reads return deleted-document responses (`410` on many routes).
207
-
208
- **Lifecycle:** Do **not** auto-delete after every publish handoff — review docs must linger. Persist `ownerSecret` for the session. Delete when the user asks to remove/clean up, or when finishing an explicitly ephemeral scratch doc the user is done with.
209
-
210
- ### Marks and privacy
211
-
212
- Emptying the markdown (including `set_document` to blank/minimal content) does **not** scrub comment marks. Quote and commentary fields can remain readable via `v3/document` to anyone with the share credential. Without owner delete authority, content wipe is not a privacy cleanup — delete the document with `ownerSecret` (while unclaimed) or ask the owner after claim.
213
-
214
- ### When the loop breaks
215
-
216
- If a mutation keeps failing after a fresh read and one safe retry, call `POST https://www.proofeditor.ai/api/bridge/report_bug` with the failing request ID, slug, and raw response. The server enriches and files an issue. Ask before including the user's name/email.
217
-
218
- ## Workflow: Review a Shared Document
219
-
220
- When given a Proof URL like `https://www.proofeditor.ai/d/abc123?token=xxx`:
221
-
222
- 1. Extract the slug and token
223
- 2. Bind presence with the CE identity defaults
224
- 3. Read via `v3/document`
225
- 4. Edit with `v3/edit` (narrow content ops; review ops for comments/suggestions)
226
-
227
- ```bash
228
- TOKEN="xxx"
229
- SLUG="abc123"
230
- AGENT="ai:compound-engineering"
231
-
232
- curl -sS -X POST "https://www.proofeditor.ai/api/agent/$SLUG/presence" \
233
- -H "Content-Type: application/json" \
234
- -H "Authorization: Bearer $TOKEN" \
235
- -H "X-Agent-Id: $AGENT" \
236
- -d '{"name":"Compound Engineering","status":"reading","summary":"Reviewing doc"}'
237
-
238
- DOC=$(curl -sS "https://www.proofeditor.ai/api/agent/$SLUG/v3/document" \
239
- -H "Authorization: Bearer $TOKEN" \
240
- -H "X-Agent-Id: $AGENT")
241
- REVISION=$(printf '%s' "$DOC" | jq -r '.revision // empty')
242
-
243
- # Comment on visible text
244
- curl -sS -X POST "https://www.proofeditor.ai/api/agent/$SLUG/v3/edit" \
245
- -H "Content-Type: application/json" \
246
- -H "Authorization: Bearer $TOKEN" \
247
- -H "X-Agent-Id: $AGENT" \
248
- -H "Idempotency-Key: $(uuidgen)" \
249
- -d "$(jq -n --argjson rev "${REVISION:-null}" '{
250
- by:"ai:compound-engineering",
251
- baseRevision: (if $rev == null then null else $rev end),
252
- operations:[{op:"comment",on:"text to comment on",body:"Your comment here"}]
253
- } | if .baseRevision == null then del(.baseRevision) else . end')"
254
-
255
- # Narrow content edit
256
- curl -sS -X POST "https://www.proofeditor.ai/api/agent/$SLUG/v3/edit" \
257
- -H "Content-Type: application/json" \
258
- -H "Authorization: Bearer $TOKEN" \
259
- -H "X-Agent-Id: $AGENT" \
260
- -H "Idempotency-Key: $(uuidgen)" \
261
- -d '{"by":"ai:compound-engineering","operations":[{"op":"replace","find":"old","with":"new"}]}'
262
-
263
- # Tracked suggestion
264
- curl -sS -X POST "https://www.proofeditor.ai/api/agent/$SLUG/v3/edit" \
265
- -H "Content-Type: application/json" \
266
- -H "Authorization: Bearer $TOKEN" \
267
- -H "X-Agent-Id: $AGENT" \
268
- -H "Idempotency-Key: $(uuidgen)" \
269
- -d '{"by":"ai:compound-engineering","operations":[{"op":"suggest","kind":"replace","find":"old","with":"new"}]}'
270
- ```
271
-
272
- ## Workflow: Create and Share a New Document
273
-
274
- **Publishing a local file (the primary case):** read the file and JSON-encode its full contents into the `markdown` field with `jq --rawfile` so newlines, quotes, and backticks are escaped correctly. Never hand-write the body or leave an inline placeholder — that publishes a placeholder doc instead of the source artifact.
275
-
276
- ```bash
277
- SRC="docs/plans/2026-05-04-001-feat-foo-plan.md"
278
- TITLE="Plan: Foo"
279
-
280
- RESPONSE=$(jq -n --arg title "$TITLE" --rawfile md "$SRC" '{title:$title, markdown:$md}' \
281
- | curl -sS -X POST https://www.proofeditor.ai/share/markdown \
282
- -H "Content-Type: application/json" -d @-)
283
-
284
- URL=$(echo "$RESPONSE" | jq -r '.tokenUrl')
285
- SLUG=$(echo "$RESPONSE" | jq -r '.slug')
286
- TOKEN=$(echo "$RESPONSE" | jq -r '.accessToken')
287
- OWNER_SECRET=$(echo "$RESPONSE" | jq -r '.ownerSecret') # required for owner delete while unclaimed
288
-
289
- # Keep OWNER_SECRET in session memory only — never write it into the repo tree.
290
-
291
- curl -sS -X POST "https://www.proofeditor.ai/api/agent/$SLUG/presence" \
292
- -H "Content-Type: application/json" \
293
- -H "Authorization: Bearer $TOKEN" \
294
- -H "X-Agent-Id: ai:compound-engineering" \
295
- -d '{"name":"Compound Engineering","status":"reading","summary":"Uploaded doc"}'
296
-
297
- echo "$URL"
298
- ```
299
-
300
- After publish handoffs from planning workflows, surface the URL and return control — do not delete the doc automatically.
301
-
302
- When the user later asks to clean up an unclaimed doc you created:
303
-
304
- ```bash
305
- curl -sS -X DELETE "https://www.proofeditor.ai/api/documents/$SLUG" \
306
- -H "Authorization: Bearer $OWNER_SECRET"
307
- ```
308
-
309
- ## Workflow: Pull a Proof Doc to Local
310
-
311
- Sync the current Proof doc state to a local markdown file. Used for:
77
+ ## Workflows
312
78
 
313
- - Ad-hoc snapshots of a Proof doc to disk
314
- - Pulling a shared Proof doc that the user (or others) edited back down to a local working copy
315
- - Refreshing a local working copy against the live Proof version
316
-
317
- Canonical read for this workflow: `GET /api/agent/$SLUG/v3/document`.
318
-
319
- ```bash
320
- SLUG=<slug>
321
- TOKEN=<accessToken>
322
- LOCAL=<absolute-path>
323
-
324
- STATE_TMP=$(mktemp)
325
- curl -sS "https://www.proofeditor.ai/api/agent/$SLUG/v3/document" \
326
- -H "Authorization: Bearer $TOKEN" \
327
- -H "X-Agent-Id: ai:compound-engineering" > "$STATE_TMP"
328
- REVISION=$(jq -r '.revision // empty' "$STATE_TMP")
329
-
330
- TMP="${LOCAL}.proof-sync.$$"
331
- jq -jr '.markdown' "$STATE_TMP" > "$TMP" && mv "$TMP" "$LOCAL"
332
- rm "$STATE_TMP"
333
- ```
334
-
335
- `jq -jr` streams markdown bytes without going through a shell variable, so trailing newlines survive. `mv` within the same filesystem is atomic.
336
-
337
- **Confirm before writing when the pull isn't directly asked for.** If a workflow ends up pulling as a side-effect of a different action, surface the impending write with a short confirm like "Sync Proof doc to `<localPath>`?" A silent overwrite is surprising.
79
+ For complete workflow recipes (review, create, pull to local), read `references/workflows.md`.
338
80
 
339
81
  ## Safety
340
82
 
@@ -0,0 +1,145 @@
1
+ # Proof Web API Recipes
2
+
3
+ Detailed curl examples and error handling for Proof's hosted web API at `https://www.proofeditor.ai`.
4
+
5
+ ## Create a Shared Document
6
+
7
+ No authentication required on the public create route. Returns a shareable URL with tokens.
8
+
9
+ ```bash
10
+ curl -sS -X POST https://www.proofeditor.ai/share/markdown \
11
+ -H "Content-Type: application/json" \
12
+ -d '{"title":"My Doc","markdown":"# Hello\n\nContent here."}'
13
+ ```
14
+
15
+ **Response fields to keep:**
16
+
17
+ ```json
18
+ {
19
+ "slug": "abc123",
20
+ "tokenUrl": "https://www.proofeditor.ai/d/abc123?token=xxx",
21
+ "accessToken": "xxx",
22
+ "ownerSecret": "yyy",
23
+ "shareUrl": "https://www.proofeditor.ai/d/abc123",
24
+ "_links": {
25
+ "read": "https://www.proofeditor.ai/api/agent/abc123/v3/document",
26
+ "edit": { "method": "POST", "href": "/api/agent/abc123/v3/edit" },
27
+ "delete": { "method": "DELETE", "href": "/api/documents/abc123" }
28
+ }
29
+ }
30
+ ```
31
+
32
+ Use `tokenUrl` as the shareable link. Extract `slug`, `accessToken`, and `ownerSecret` immediately — `ownerSecret` is required for cleanup while the doc is still unclaimed.
33
+
34
+ ## Read a Shared Document
35
+
36
+ If you already have a shared Proof URL, fetch with content negotiation or v3:
37
+
38
+ ```bash
39
+ curl -sS -H "Accept: application/json" "https://www.proofeditor.ai/d/{slug}?token=<token>"
40
+ curl -sS -H "Accept: text/markdown" "https://www.proofeditor.ai/d/{slug}?token=<token>"
41
+
42
+ curl -sS "https://www.proofeditor.ai/api/agent/{slug}/v3/document" \
43
+ -H "Authorization: Bearer <token>" \
44
+ -H "X-Agent-Id: ai:compound-engineering"
45
+ # -> { ok, revision, title, markdown, comments[], suggestions[], mutationReady? }
46
+ ```
47
+
48
+ ACTIVE docs can be read tokenlessly via `v3/document`. Mutations, presence, and events need a tokenized credential. Tokenless `GET /d/<slug>` JSON reports `role: null` and no mutation links — that is truthful capability reporting, not a browser lock.
49
+
50
+ `comments[]` and `suggestions[]` on the v3 read are the source of review state. Use a comment's `id` for `reply` / `resolve` / `unresolve`. Use a suggestion's `id` for `accept` / `reject`. v3 supports resolving and unresolving comments; it does **not** support deleting comments.
51
+
52
+ When `mutationReady` is `false`, `revision` may be `null` — omit `baseRevision` and re-read shortly.
53
+
54
+ ## Edit a Shared Document
55
+
56
+ Send `{ by, baseRevision?, operations: [...] }` to `POST /api/agent/{slug}/v3/edit`. Targets are **visible text** in `markdown` (not raw markdown syntax, not block refs). There is no base token. `baseRevision` (integer from the last read) is an optional conflict guard — omit it to apply at head. `Idempotency-Key` is optional; use one for important writes and retries.
57
+
58
+ ```bash
59
+ curl -sS -X POST "https://www.proofeditor.ai/api/agent/{slug}/v3/edit" \
60
+ -H "Content-Type: application/json" \
61
+ -H "Authorization: Bearer <token>" \
62
+ -H "X-Agent-Id: ai:compound-engineering" \
63
+ -H "Idempotency-Key: $(uuidgen)" \
64
+ -d '{
65
+ "by":"ai:compound-engineering",
66
+ "operations":[
67
+ {"op":"replace","find":"old visible text","with":"new text"},
68
+ {"op":"comment","on":"text to anchor on","body":"Is this still accurate?"}
69
+ ]
70
+ }'
71
+ ```
72
+
73
+ ### Content operations
74
+
75
+ | op | body |
76
+ |---|---|
77
+ | `replace` | `find`, `with` (optional `occurrence` / `before` / `after`) |
78
+ | `insert` | `after` or `before` + `markdown` (anchor: quote, `heading:Title`, `section:Title`, `"start"`, or `"end"`) |
79
+ | `delete` | `find` |
80
+ | `set_document` | `markdown` (whole-doc replace as a minimal diff; safe with live collaborators) |
81
+
82
+ ### Review operations
83
+
84
+ | op | body |
85
+ |---|---|
86
+ | `comment` | `on`, `body` (optional `occurrence`) |
87
+ | `reply` | `comment` (id), `body`, optional `resolve: true` |
88
+ | `resolve` / `unresolve` | `comment` (id) |
89
+ | `suggest` | `kind: "insert"\|"delete"\|"replace"`, `find`, `with?` (`with` required for insert/replace) |
90
+ | `accept` / `reject` | `suggestion` (id) |
91
+
92
+ ### Error handling
93
+
94
+ Errors use `{ ok:false, error:{ code, message, retryable, opIndex?, target?, candidates?, current? } }`. Codes: `AUTH`, `NOT_FOUND`, `INVALID_REQUEST`, `TARGET_NOT_FOUND`, `TARGET_AMBIGUOUS`, `CONFLICT`, `TOO_LARGE`, `BUSY`, `PENDING`, `INTERNAL`.
95
+
96
+ - `retryable: false` — fix the request; do not blind-retry
97
+ - `retryable: true` with `error.current` — re-resolve targets against `current` and retry once
98
+ - `TARGET_AMBIGUOUS` — add `occurrence` / `before` / `after` from `candidates`
99
+ - `BUSY` — brief backoff and retry
100
+ - Settled `200` with `ok:true` — inspect returned `revision` / document; chain without an extra read when the body is complete
101
+ - `202` / `PENDING` — write may have committed; re-read `v3/document` before chaining or reporting success
102
+
103
+ After every successful edit: confirm `ok:true`, confirm the intended text/comment/suggestion, then report the Proof link with a short summary.
104
+
105
+ ## Presence
106
+
107
+ ```bash
108
+ curl -sS -X POST "https://www.proofeditor.ai/api/agent/{slug}/presence" \
109
+ -H "Content-Type: application/json" \
110
+ -H "Authorization: Bearer <token>" \
111
+ -H "X-Agent-Id: ai:compound-engineering" \
112
+ -d '{"name":"Compound Engineering","status":"reading","summary":"Joining the doc"}'
113
+ ```
114
+
115
+ Common statuses: `reading`, `thinking`, `acting`, `waiting`, `completed`, `error`.
116
+
117
+ ## Title
118
+
119
+ ```bash
120
+ curl -sS -X PUT "https://www.proofeditor.ai/api/documents/{slug}/title" \
121
+ -H "Content-Type: application/json" \
122
+ -H "Authorization: Bearer <token>" \
123
+ -d '{"title":"Updated document title"}'
124
+ ```
125
+
126
+ ## Delete
127
+
128
+ Only owner credentials can delete:
129
+
130
+ ```bash
131
+ curl -sS -X DELETE "https://www.proofeditor.ai/api/documents/{slug}" \
132
+ -H "Authorization: Bearer <ownerSecret>"
133
+ ```
134
+
135
+ Viewer, commenter, and editor `accessToken` values cannot delete. Success returns `shareState: "DELETED"`; later reads return deleted-document responses (`410` on many routes).
136
+
137
+ **Lifecycle:** Do **not** auto-delete after every publish handoff — review docs must linger. Persist `ownerSecret` for the session. Delete when the user asks to remove/clean up, or when finishing an explicitly ephemeral scratch doc the user is done with.
138
+
139
+ ### Marks and privacy
140
+
141
+ Emptying the markdown (including `set_document` to blank/minimal content) does **not** scrub comment marks. Quote and commentary fields can remain readable via `v3/document` to anyone with the share credential. Without owner delete authority, content wipe is not a privacy cleanup — delete the document with `ownerSecret` (while unclaimed) or ask the owner after claim.
142
+
143
+ ## When the loop breaks
144
+
145
+ If a mutation keeps failing after a fresh read and one safe retry, call `POST https://www.proofeditor.ai/api/bridge/report_bug` with the failing request ID, slug, and raw response. The server enriches and files an issue. Ask before including the user's name/email.