@seanyao/roll 4.630.2 → 4.702.2

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 (108) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +65 -56
  3. package/conventions/global/AGENTS.md +8 -7
  4. package/dist/roll.mjs +12909 -8532
  5. package/docs/INDEX.md +32 -0
  6. package/docs/architecture.md +444 -0
  7. package/docs/difftest-freeze-paradigm.md +113 -0
  8. package/docs/live-console.md +203 -0
  9. package/docs/manifesto.md +65 -0
  10. package/docs/migration/role-taxonomy-v4.md +60 -0
  11. package/docs/verification.md +83 -0
  12. package/guide/INDEX.md +86 -0
  13. package/guide/assets/layouts/cards-2.png +0 -0
  14. package/guide/assets/layouts/cards-3.png +0 -0
  15. package/guide/assets/layouts/cards-4.png +0 -0
  16. package/guide/assets/layouts/compare.png +0 -0
  17. package/guide/assets/layouts/highlight.png +0 -0
  18. package/guide/assets/layouts/pipeline.png +0 -0
  19. package/guide/assets/layouts/plain.png +0 -0
  20. package/guide/assets/layouts/quote.png +0 -0
  21. package/guide/assets/layouts/timeline.png +0 -0
  22. package/guide/en/acceptance-evidence.md +231 -0
  23. package/guide/en/ai-agents.md +185 -0
  24. package/guide/en/backlog-github-sync.md +108 -0
  25. package/guide/en/changelog.md +66 -0
  26. package/guide/en/configuration.md +112 -0
  27. package/guide/en/consistency.md +58 -0
  28. package/guide/en/conventions.md +113 -0
  29. package/guide/en/dream.md +121 -0
  30. package/guide/en/faq.md +855 -0
  31. package/guide/en/feedback.md +31 -0
  32. package/guide/en/getting-started.md +103 -0
  33. package/guide/en/installation.md +86 -0
  34. package/guide/en/legacy-onboarding.md +195 -0
  35. package/guide/en/loop-data-layout.md +256 -0
  36. package/guide/en/loop-driven-architecture.md +186 -0
  37. package/guide/en/loop.md +1324 -0
  38. package/guide/en/methodology.md +715 -0
  39. package/guide/en/migration-2.0.md +154 -0
  40. package/guide/en/overview.md +190 -0
  41. package/guide/en/pairing.md +151 -0
  42. package/guide/en/patterns/README.md +76 -0
  43. package/guide/en/patterns/graft-pattern.md +110 -0
  44. package/guide/en/patterns/replant-pattern.md +114 -0
  45. package/guide/en/patterns/seed-pattern.md +132 -0
  46. package/guide/en/peer.md +71 -0
  47. package/guide/en/pr-review.md +62 -0
  48. package/guide/en/practices/engineering-common-sense.md +395 -0
  49. package/guide/en/pricing.md +116 -0
  50. package/guide/en/project-setup.md +126 -0
  51. package/guide/en/roll-doc-audit.md +98 -0
  52. package/guide/en/skills.md +206 -0
  53. package/guide/en/test-isolation.md +51 -0
  54. package/guide/en/testing/quality-rubric.md +340 -0
  55. package/guide/en/testing.md +123 -0
  56. package/guide/en/tools.md +173 -0
  57. package/guide/skills.md +30 -0
  58. package/guide/zh/acceptance-evidence.md +194 -0
  59. package/guide/zh/ai-agents.md +170 -0
  60. package/guide/zh/backlog-github-sync.md +105 -0
  61. package/guide/zh/changelog.md +57 -0
  62. package/guide/zh/configuration.md +99 -0
  63. package/guide/zh/consistency.md +48 -0
  64. package/guide/zh/conventions.md +96 -0
  65. package/guide/zh/dream.md +97 -0
  66. package/guide/zh/faq.md +773 -0
  67. package/guide/zh/feedback.md +30 -0
  68. package/guide/zh/getting-started.md +96 -0
  69. package/guide/zh/installation.md +83 -0
  70. package/guide/zh/legacy-onboarding.md +192 -0
  71. package/guide/zh/loop-data-layout.md +236 -0
  72. package/guide/zh/loop-driven-architecture.md +186 -0
  73. package/guide/zh/loop.md +1124 -0
  74. package/guide/zh/methodology.md +702 -0
  75. package/guide/zh/migration-2.0.md +154 -0
  76. package/guide/zh/overview.md +186 -0
  77. package/guide/zh/pairing.md +117 -0
  78. package/guide/zh/patterns/README.md +74 -0
  79. package/guide/zh/patterns/graft-pattern.md +108 -0
  80. package/guide/zh/patterns/replant-pattern.md +112 -0
  81. package/guide/zh/patterns/seed-pattern.md +130 -0
  82. package/guide/zh/peer.md +63 -0
  83. package/guide/zh/pr-review.md +54 -0
  84. package/guide/zh/practices/engineering-common-sense.md +393 -0
  85. package/guide/zh/pricing.md +97 -0
  86. package/guide/zh/project-setup.md +114 -0
  87. package/guide/zh/roll-doc-audit.md +90 -0
  88. package/guide/zh/skills.md +191 -0
  89. package/guide/zh/test-isolation.md +46 -0
  90. package/guide/zh/testing/quality-rubric.md +284 -0
  91. package/guide/zh/testing.md +116 -0
  92. package/guide/zh/tools.md +173 -0
  93. package/package.json +4 -1
  94. package/skills/README.md +1 -0
  95. package/skills/roll-.qa/SKILL.md +1 -1
  96. package/skills/roll-.review/SKILL.md +1 -1
  97. package/skills/roll-build/SKILL.md +1 -1
  98. package/skills/roll-build/references/full-contract.md +16 -13
  99. package/skills/roll-design/SKILL.md +3 -3
  100. package/skills/roll-design/references/full-contract.md +17 -13
  101. package/skills/roll-fix/SKILL.md +1 -1
  102. package/skills/roll-fix/references/full-contract.md +13 -10
  103. package/skills/roll-peer/SKILL.md +1 -1
  104. package/skills/roll-prime/SKILL.md +77 -0
  105. package/skills/roll-prime/references/explorer-annex.md +39 -0
  106. package/skills/roll-prime/references/supervisor-prompt.md +165 -0
  107. package/skills/route-cases/skills.json +10 -0
  108. package/template/AGENTS.md +3 -1
@@ -0,0 +1,154 @@
1
+ # Migrating to Roll 2.0
2
+
3
+ > **TL;DR:** Run `npx @seanyao/roll@2 migrate --dry-run`, review, then `npx @seanyao/roll@2 migrate`. One atomic commit. Done.
4
+
5
+ Roll 2.0 moves all "process" artifacts (BACKLOG, PROPOSALS, feature specs, briefs, dream logs, design docs) from your project root + `docs/` into a single `.roll/` directory. User-facing docs (`docs/guide/`, `docs/site/`) move up to the project root.
6
+
7
+ This is a one-time, breaking change. Your existing files keep their git history — Roll uses `git mv`.
8
+
9
+ ## Before you start
10
+
11
+ - **Pin your old version** if you want a safety net: `npm install -g @seanyao/roll@1`. Old npm versions never go away, so you can always go back.
12
+ - **Make sure your working tree is clean.** `npx @seanyao/roll@2 migrate` refuses to run with uncommitted changes. Commit or stash first.
13
+ - **Optional but recommended**: read this whole page before running.
14
+
15
+ ## What will move
16
+
17
+ | Old path | New path | Notes |
18
+ |----------|----------|-------|
19
+ | `BACKLOG.md` (root) | `.roll/backlog.md` | The main project workflow file |
20
+ | `PROPOSALS.md` (root) | `.roll/proposals.md` | Pending proposals |
21
+ | `docs/features.md` | `.roll/features.md` | Feature index |
22
+ | `docs/features/` | `.roll/features/` | Per-feature specs |
23
+ | `docs/briefs/` | `.roll/briefs/` | `roll-brief` output (auto-generated) |
24
+ | `docs/dream/` | `.roll/dream/` | `roll-.dream` output (auto-generated) |
25
+ | `docs/design/` | `.roll/design/` | Design exploration docs |
26
+ | `docs/domain/` | `.roll/domain/` | DDD models |
27
+ | `docs/practices/loop-autorun-verification.md` | `.roll/features/loop-engine/loop-autorun-verification.md` | Execution records |
28
+ | `docs/practices/engineering-common-sense.md` | `guide/en/practices/engineering-common-sense.md` | Engineering norm (user-facing) |
29
+ | `docs/intro/` | `site/slides/` | Promotional HTML pages |
30
+ | `docs/guide/en/` | `guide/en/` | User docs (English) |
31
+ | `docs/guide/zh/` | `guide/zh/` | User docs (Chinese) |
32
+ | `docs/site/` | `site/` | Marketing site source |
33
+
34
+ After migration, your `docs/` directory is gone. If you had your own files in `docs/` outside this list, `npx @seanyao/roll@2 migrate` won't touch them.
35
+
36
+ ## Why two destinations
37
+
38
+ Roll 2.0 enforces an architectural split:
39
+
40
+ - **`.roll/`** = process artifacts, for *us* (the maintainers). Backlog, dream logs, design notes.
41
+ - **Root** = product artifacts, for *others*. README, guide, site, source code.
42
+
43
+ Whether `.roll/` is gitignored is your choice (see [Privacy](#privacy) below). Whether it's tracked is orthogonal to the directional split.
44
+
45
+ ## Three-state safety
46
+
47
+ `npx @seanyao/roll@2 migrate` is idempotent and refuses to do anything dangerous:
48
+
49
+ | State | Action |
50
+ |-------|--------|
51
+ | Old paths only | Migrate (single atomic commit) |
52
+ | `.roll/` only, no old paths | No-op with "already migrated" message |
53
+ | Both present | **Refuse** — list conflicts, require manual resolution |
54
+ | Neither present | No-op |
55
+
56
+ If you stop midway, the partial state goes into the "both" bucket and you'll get a clear conflict report on the next run.
57
+
58
+ ## Step by step
59
+
60
+ ### 1. Update Roll to 2.0
61
+
62
+ ```bash
63
+ npm install -g @seanyao/roll@2
64
+ npx @seanyao/roll@2 version # Should show 2.x
65
+ ```
66
+
67
+ ### 2. Preview the migration
68
+
69
+ ```bash
70
+ cd your-project
71
+ npx @seanyao/roll@2 migrate --dry-run
72
+ ```
73
+
74
+ This prints a table of every move. Nothing happens to your files.
75
+
76
+ ### 3. Execute
77
+
78
+ ```bash
79
+ npx @seanyao/roll@2 migrate
80
+ ```
81
+
82
+ You'll see a single commit on your current branch:
83
+
84
+ ```
85
+ Migrate project layout to .roll/ structure
86
+
87
+ Paths migrated: 14
88
+ ```
89
+
90
+ `git log --follow .roll/backlog.md` should still show the full history from `BACKLOG.md`.
91
+
92
+ ### 4. Verify
93
+
94
+ ```bash
95
+ roll status # Should run cleanly
96
+ ls -la .roll/ # New structure
97
+ git log -1 # The migration commit
98
+ ```
99
+
100
+ If anything looks wrong, revert with `git revert HEAD`.
101
+
102
+ ## Privacy
103
+
104
+ By default, `.roll/` is **tracked** (visible to everyone with repo access). If you want process artifacts private:
105
+
106
+ ```bash
107
+ echo ".roll/" >> .gitignore
108
+ git add .gitignore && git commit -m "chore: gitignore .roll/"
109
+ ```
110
+
111
+ Then untrack what's already been committed:
112
+
113
+ ```bash
114
+ git rm -r --cached .roll/
115
+ git commit -m "chore: stop tracking .roll/"
116
+ ```
117
+
118
+ Roll itself uses a separate **private repo** (`seanyao/roll-meta`) instead of gitignoring — that's a valid pattern too, but only makes sense if you want totally separate access controls.
119
+
120
+ ## Rolling back
121
+
122
+ If you need to undo:
123
+
124
+ ```bash
125
+ git revert HEAD # Undo the migration commit
126
+ npm install -g @seanyao/roll@1 # Reinstall old Roll
127
+ ```
128
+
129
+ Your file history is preserved either way (`git mv` doesn't lose blame).
130
+
131
+ ## Updates to other tools
132
+
133
+ After migration:
134
+
135
+ - `roll status`, `roll backlog`, `roll loop`, `roll brief` — all automatically use the new paths
136
+ - `$roll-build`, `$roll-fix`, `$roll-design` skills — all updated; just re-run `roll setup` to refresh
137
+ - Any external scripts referencing `BACKLOG.md` etc. — **you need to update those manually**
138
+
139
+ ## FAQ
140
+
141
+ **Q: Can I migrate one piece at a time?**
142
+ No. Migration is atomic — single commit. The "both" state intentionally errors out so you never end up in a half-migrated mess.
143
+
144
+ **Q: What about CI / GitHub Actions referencing old paths?**
145
+ Update them in the same commit window. If CI breaks after migration, that's almost always a stale path reference in a workflow file.
146
+
147
+ **Q: My team uses Roll on multiple projects. Do I need to migrate all of them?**
148
+ Each project independently. Roll 2.0 refuses to run on old structure with a clear hint pointing to `npx @seanyao/roll@2 migrate`, so nothing silently breaks.
149
+
150
+ **Q: Can I skip migration and stay on Roll 1.x forever?**
151
+ Yes. Old npm versions are permanent. But you'll miss new features (existing-codebase onboarding, agent discovery, plan-driven init).
152
+
153
+ **Q: Roll runs `npm test` and many tests fail after migration — is that expected?**
154
+ No. The migration should not change test outcomes. If tests break, run `git diff HEAD~1` to see what moved and look for paths in test files or fixtures that didn't get migrated. File an issue with the diff.
@@ -0,0 +1,190 @@
1
+ # Roll — Overview
2
+
3
+ Roll is a Supervisor-led delivery harness. Write a goal, let Roll turn it into Stories, and route each Story through scoped `supervise`, `execute`, and `evaluate` roles.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ curl -fsSL https://seanyao.github.io/roll/install | bash
9
+
10
+ cd my-project
11
+ roll setup && roll init
12
+
13
+ roll next # continue with design/apply/repair/migrate/loop/status
14
+ roll loop on # AI starts executing BACKLOG on a configurable schedule
15
+ roll loop status # check scheduler state and recent cycles
16
+ roll loop watch # optional: CLI-first live view of the current cycle
17
+ ```
18
+
19
+ ## How It Works
20
+
21
+ Roll runs as a V4 Supervisor execution system:
22
+
23
+ - **Supervisor** — project-level observe/advise role. It reads backlog, merge truth, open PRs, scoped role bindings, repeated failures, release readiness, and owner questions. It coordinates across Stories; it never implements a Story or overrides evidence gates.
24
+ - **Delta Unit** — one Story delivered through `design` when needed, then `execute`, and, when configured, `evaluate`.
25
+ - **Roles and bindings** — `supervise`, `design`, `execute`, and `evaluate` are stable roles. The concrete agent and optional model are resolved from `Scope -> Role -> Binding -> Agent -> Model`. If a requested binding is unavailable, Roll records that and fails loud instead of pretending another agent was used.
26
+ - **Loop** — on a configurable schedule, picks the top story from BACKLOG and executes it in an isolated worktree. CI must pass before anything lands on `main`.
27
+ - **Dream** — at 3am, scans the codebase for dead code, doc gaps, and architectural drift. Queues `REFACTOR-NNN` entries for loop to pick up.
28
+ - **Skills** — remain the capability layer. Roles invoke `$roll-design`, `$roll-build`, `$roll-fix`, `$roll-peer`, `$roll-.qa`, and other skills.
29
+
30
+ You set goals, review PRs, and run releases. Everything in between is Roll.
31
+
32
+ ## Operating Modes
33
+
34
+ Roll has two modes over the same backlog, route profile, evidence, Evaluator,
35
+ and release gates. `guided` means the owner asks `roll supervisor status/next/why`
36
+ and explicitly starts work, usually with `roll loop go --cards <id>`.
37
+ `autonomous` means `roll loop on` has installed the scheduler, so eligible Todo
38
+ work may run within the existing gates. `roll loop pause` / `roll loop off`
39
+ return control to guided operation; `roll loop resume` / `roll loop on` switch
40
+ back explicitly.
41
+
42
+ ### Onboarding Samples
43
+
44
+ **New project from zero**
45
+
46
+ ```bash
47
+ mkdir my-product && cd my-product
48
+ roll init
49
+ roll next
50
+ roll design --from-file .roll/brief.md
51
+ roll loop on
52
+ ```
53
+
54
+ Start with a short requirement, PRD, or notes. Roll explains the next design step instead of silently creating fake work; Designer creates the backlog, Supervisor picks `standard`, `verified`, or `designed` execution per Story, and the owner reviews story-scoped attest evidence.
55
+
56
+ **Existing project**
57
+
58
+ ```bash
59
+ cd existing-codebase
60
+ roll init
61
+ roll next
62
+ roll init --apply
63
+ roll loop on
64
+ ```
65
+
66
+ Roll diagnoses current code without destructive migration, creates or updates Roll metadata after review, and then reasons over the existing backlog/docs/context. Inspect state through CLI-first observability: `roll status`, `roll loop watch`, `roll loop runs`, `roll loop cycle <id>`, alerts, and story reports.
67
+
68
+ **Scoped role routing**
69
+
70
+ ```yaml
71
+ schema: roll-agents/v1
72
+ defaults:
73
+ story:
74
+ roles:
75
+ execute:
76
+ candidates: [kimi, codex]
77
+ evaluate:
78
+ candidates: [pi, reasonix]
79
+ ```
80
+
81
+ Runtime availability is explicit. Unavailable agents are recorded as unavailable; role resolution is fail-loud, not silent substitution.
82
+
83
+ ## Features
84
+
85
+ ### Autonomous Execution
86
+
87
+ - `roll loop on` — AI picks stories from BACKLOG and executes on a configurable schedule in an isolated worktree `[core]`
88
+ - `roll loop status` — scheduler snapshot, recent cycles, queue, alerts, and cost `[core]`
89
+ - `roll loop watch` — default read-only live status; use `--events` for compact events and `--raw-events` only for audit/debug `[highlight]`
90
+ - `roll loop pause / resume` — hand-code yourself; let AI resume when you're done
91
+
92
+ ### Quality Gates
93
+
94
+ - Peer Review — a second AI agent challenges the plan or diff before any risky build `[core]` `[highlight]`
95
+ - Self-Review — post-commit self-check on each micro-commit
96
+ - Acceptance Check — ACs verified against story definition after every build
97
+ - CI Gate — loop waits for green CI; red CI halts the loop and writes an alert `[core]`
98
+ - TCR Discipline — no commit without passing tests; zero-diff commits revert automatically `[core]`
99
+
100
+ ### Nightly Dream
101
+
102
+ - Code Health Scan — detects dead code, architectural drift, over-engineering candidates `[highlight]`
103
+ - Doc Coverage — flags missing guides, stale docs, undocumented ENV vars
104
+ - REFACTOR Queue — writes REFACTOR-NNN entries to BACKLOG for loop to pick up next morning
105
+
106
+ ### Story Lifecycle
107
+
108
+ - `$roll-idea` — one-liner capture: instant FIX or IDEA backlog entry `[core]`
109
+ - `roll design` / `$roll-design` — DDD-backed planning: clarify → design → split into INVEST stories. `roll design` launches the skill in your AI agent from the command line and renders detailed designs as a self-contained Design Review Page. `[core]`
110
+ - `$roll-build` — Builder role execution: TCR story execution → worktree → PR → evidence `[core]`
111
+ - `$roll-fix` — fast-path bug fix, same CI gate, lighter ceremony
112
+ - Evaluator role — independent review, visual evidence checks, score/attest contracts where the execution profile requires it
113
+
114
+ ### Observability
115
+
116
+ - `roll status` — verdict-first truth summary (LOOP · CYCLE · RELEASE · STORY with attest coverage), then convention/AI-client sync health `[core]`
117
+ - `roll loop watch` — CLI-first live activity stream for the current cycle
118
+ - `roll loop cycle <id>` — one cycle's trace and evidence pointers
119
+ - `roll loop runs` — per-cycle TerminalOutcome history with TCR count and duration
120
+ - `roll loop alert` — view, acknowledge, and clear loop alerts
121
+ - Acceptance Review Page — the Story's own `latest/<id>-review.html` is the human acceptance entry `[highlight]`
122
+
123
+ ### Current Observability
124
+
125
+ The current product is CLI-first. `roll status`, `roll loop watch`, `roll loop runs`, `roll loop cycle <id>`, `roll status pulse`, alerts, and story-scoped attest reports are the active truth surfaces. the archive rebuild is an on-demand static archive/repair renderer, useful for CI artifacts and migration reconciliation; it is not the current truth surface.
126
+
127
+ The three-state delivery ladder still matters: **claimed -> merged -> attested**. A backlog row that says done is only `claimed`; it becomes `merged` when the PR lands on `main`, and `attested` when story-scoped evidence is on file. Use `roll supervisor live` for a one-frame CLI-first multi-role board, or `roll supervisor live --watch` to keep that board refreshing in-place; browser/TUI Supervisor Live Console remains future work.
128
+
129
+ ### On-Demand Skills
130
+
131
+ - `$roll-debug` — mount a diagnostic probe, trace root cause, auto-fix if source-traceable
132
+ - `$roll-doc-audit` — check docs/site/help against implementation; index gaps and draft missing docs
133
+ - `$roll-doctor` — diagnose the dev toolchain: node, npm, git, AI tools
134
+ - `$roll-notes` — capture a development moment in narrative form
135
+
136
+ ### Multi-Agent
137
+
138
+ - Fail-loud Routing — requested agent/model/rig unavailable → record the limit and pause or route only through an explicit fallback policy `[highlight]`
139
+ - `$roll-peer` — multi-round negotiation; the structured adapter records one-shot reviewer facts `[core]`
140
+ - PR Inbox — external PRs get AI review before merge; stale PRs auto-rebase `[new]`
141
+ - `roll review-pr` — on-demand AI review for any PR, any agent `[new]`
142
+
143
+ ## Project Structure
144
+
145
+ Roll 2.0 keeps the project root clean. All Roll-managed artifacts live under
146
+ `.roll/`:
147
+
148
+ ```
149
+ my-project/
150
+ ├── AGENTS.md # engineering constraints (root-level — agents read this first)
151
+ ├── README.md # product front door
152
+ ├── src/ tests/ # your code
153
+ └── .roll/ # everything Roll touches
154
+ ├── backlog.md # Story / Fix / Refactor index
155
+ ├── features/ # per-Story AC + plan docs
156
+ ├── domain/ # DDD models, context map
157
+ ├── briefs/ dream/ # autonomous-layer output
158
+ └── decisions/ # ADRs
159
+ ```
160
+
161
+ Upgrading a pre-2.0 project? See [migration-2.0.md](migration-2.0.md) —
162
+ `npx @seanyao/roll@2 migrate` moves `BACKLOG.md`, `docs/features/`, and
163
+ `docs/domain/` into the new layout in one pass.
164
+
165
+ ## Choosing an Adoption Mode
166
+
167
+ Roll supports three adoption patterns. Pick the one that fits your starting
168
+ point — see [patterns/](patterns/README.md) for the decision tree:
169
+
170
+ - **Seed** — empty directory + a product vision. Roll is native from day one.
171
+ - **Graft** — existing project, zero-invasion. `$roll-onboard` reverse-engineers
172
+ `.roll/` from what's already there. See [legacy-onboarding.md](legacy-onboarding.md).
173
+ - **Replant** — heavy legacy debt. Reverse-engineer the spec, then rebuild on
174
+ the new spec.
175
+
176
+ ## Guide Index
177
+
178
+ | Topic | Document |
179
+ |-------|----------|
180
+ | First working project | [getting-started.md](getting-started.md) |
181
+ | Scheduling, subcommands, tmux visibility | [loop.md](loop.md) |
182
+ | Governed tool registry and policy | [tools.md](tools.md) |
183
+ | Nightly code health and REFACTOR generation | [dream.md](dream.md) |
184
+ | Cross-agent review protocol | [peer.md](peer.md) |
185
+ | Complete skill catalog | [skills.md](skills.md) |
186
+ | Adoption patterns (seed / graft / replant) | [patterns/](patterns/README.md) |
187
+ | Onboarding an existing codebase | [legacy-onboarding.md](legacy-onboarding.md) |
188
+ | Upgrading from pre-2.0 layout | [migration-2.0.md](migration-2.0.md) |
189
+ | Common scenarios and troubleshooting | [faq.md](faq.md) |
190
+ | Environment variable configuration | [configuration.md](configuration.md) |
@@ -0,0 +1,151 @@
1
+ # Cross-Agent Pairing — heterogeneous second eyes, in the loop
2
+
3
+ Pairing makes a **different** agent (a different vendor) cross-check your work
4
+ automatically. The primitive is the **pair**, not the review: a working agent
5
+ delivers, and a heterogeneous peer reviews it for perspective diversity. A code
6
+ bug that one model's blind spot hides, another model's catches.
7
+
8
+ Roll treats reviewer assignment as the `evaluate` role in the scoped Agent
9
+ model: `Scope -> Role -> Binding -> Agent -> optional Model`. The agent is the
10
+ finite seven-name identity (`claude`, `kimi`, `codex`, `pi`, `agy`, `reasonix`, `cursor`);
11
+ the model is optional data carried by that agent.
12
+
13
+ Pairing is distinct from [`$roll-peer`](peer.md): peer is an on-demand,
14
+ multi-round negotiation you (or the loop's risk gate) trigger; pairing is an
15
+ always-available, one-way second pass wired into the cycle and governed by the
16
+ Project Scope `evaluate` binding.
17
+
18
+ ## Turning it on — explicit, never silent
19
+
20
+ ```bash
21
+ roll agent # inspect story.evaluate
22
+ roll agent migrate --dry-run # convert legacy pairing.yaml if present
23
+ ```
24
+
25
+ New projects should author the evaluator pool in `.roll/agents.yaml`:
26
+
27
+ ```yaml
28
+ # .roll/agents.yaml
29
+ schema: roll-agents/v1
30
+ scope: project
31
+ defaults:
32
+ story:
33
+ roles:
34
+ evaluate:
35
+ kind: select
36
+ from: [claude, codex, kimi, pi, agy, reasonix]
37
+ require: [evaluate]
38
+ strategy: health-aware
39
+ ```
40
+
41
+ `.roll/pairing.yaml` remains a legacy compatibility input. When both files are
42
+ present, the scoped `evaluate` role is preferred. Static config lists fair
43
+ candidates; runtime auth/network/VPN/account failures skip candidates only for
44
+ the current resolution.
45
+
46
+ ## Seeing what it does — observability
47
+
48
+ Loop cycle evidence and role views show the pool (who can pair, their vendor,
49
+ declared capability, and **why** an agent is excluded), plus **how much pairing
50
+ has cost**:
51
+
52
+ ```
53
+ Cross-Agent Pairing — pool status
54
+
55
+ enabled: true · stages: [code]
56
+
57
+ ✓ claude vendor=anthropic · [code]
58
+ ✓ codex vendor=openai · [code]
59
+ · pi vendor=pi · [code] · excluded: no heterogeneous partner
60
+
61
+ pairings to date: 7 (codex×4, kimi×3) · total cost $0.94 · 11 findings
62
+ ```
63
+
64
+ Cost is recorded on every pairing from day one — you always know what the
65
+ second pair of eyes is spending, even without budget-adaptive throttling.
66
+
67
+ ## How selection works
68
+
69
+ When a stage fires, the selector keeps **only** agents that are installed,
70
+ available, declared capable for that stage, able to run as a headless reviewer,
71
+ and a **different vendor** from the working agent — then rotates among them
72
+ (seeded by the cycle id, so it is replayable). Agents with a track record are
73
+ gently preferred (ε-greedy, ε≈0.2), but exploration is always preserved so no
74
+ single pair monopolizes. If no qualified heterogeneous peer exists, that absence
75
+ is itself recorded (`pair:none-available`) — never a silent skip.
76
+
77
+ ## Safety — pairing never blocks a cycle
78
+
79
+ - **30s hard timeout** on the peer review (belt-and-braces in the executor), so
80
+ a slow peer never stalls the cycle.
81
+ - **Non-blocking**: a timeout, error, or missing peer is recorded and the cycle
82
+ proceeds. Pairing is an enhancement, never a gate.
83
+ - **Never touches main on its own**: pairing produces evidence and events, not
84
+ merges.
85
+
86
+ ## Events & evidence
87
+
88
+ Each pairing emits `pair:selected`, then `pair:verdict` (with the verdict,
89
+ findings count, cost, and stage) or `pair:none-available`. The verdict is also
90
+ written as evidence under the run's `peer/cycle-<id>.pair.json`. A score
91
+ pairing emits `pair:score` (score, verdict, cost) and writes
92
+ `peer/cycle-<id>.score.pair.json`.
93
+
94
+ ## Stages
95
+
96
+ `code` and `score` are the defaults — a heterogeneous peer reviews the
97
+ delivered diff, and another scores the finished cycle. `design`, `test`, and
98
+ `cycle` extend the same mechanism to other checkpoints; enable them in
99
+ `stages` when you want earlier or broader second eyes.
100
+
101
+ ## Review Score — a peer grades the cycle, never the author
102
+
103
+ An agent grading its own delivery is a conflict of interest, so the cycle's
104
+ quality score — the **Review Score** — is always produced by a Reviewer in a
105
+ **fresh, separate session**, never by the building agent (the agent does NOT
106
+ self-score):
107
+
108
+ - **In the loop**: after the acceptance gate passes, the runner casts a
109
+ fresh-session Reviewer to score the delivery. The note lands in the card's
110
+ `notes/` with provenance — `scoring: pair`, `scored-by: <agent>`, and the
111
+ fresh-session id (so independence is verifiable).
112
+ - **Loop delivery**: after the acceptance gate passes, the runner triggers the
113
+ same adapter from a fresh session.
114
+ - **Design output** (`roll-design`, no loop cycle): the design workflow can
115
+ trigger a fresh-session Reviewer to grade the **design** (INVEST split,
116
+ visual-AC completeness, `deliverable_url` correctness, domain/spec
117
+ consistency) — not code. It stamps the score `stage=design`. The designing
118
+ agent triggers but never grades its own work; no peer available → honest
119
+ unscored (fail-loud), never a self-grade.
120
+ - **The builder's own agent never scores its own cycle when an independent peer
121
+ exists**: whenever any other agent is installed, the builder is excluded from
122
+ the score pool entirely — an independent Evaluator grades the delivery or the
123
+ cycle fails loud (no self-score fallback, even from a fresh same-vendor
124
+ session). The builder's own agent is the scorer **only** in a true
125
+ single-agent install, where a fresh same-vendor session is the minimum
126
+ acceptable independence. Independence is still verified by session id (a
127
+ different `agent × model × session` rig is encouraged), so the single-agent
128
+ case never deadlocks.
129
+ A score sharing the builder's session — including any sub-agent of it — is
130
+ rejected as a self-score. No independent candidate, a timeout, or a
131
+ protocol miss does **not** fall back to a self-score; the absence is audited
132
+ via a `pair:none-available` event and the story owes a fresh-session Review
133
+ Score before it can attest (`review_score_missing`).
134
+ - **Real agent output is normalized before scoring**: an Evaluator's reply is
135
+ accepted even when its stdout carries terminal control bytes, ANSI startup
136
+ banners, a JSONL stream-json wrapper, or a bullet/markdown prefix — the parser
137
+ normalizes these away, then still requires one complete, in-order
138
+ `SCORE`/`VERDICT`/`RATIONALE` block (score 1..10, supported verdict). Prose
139
+ that merely mentions the markers is still rejected.
140
+ - **Repeated final blocks are tolerated when they agree**: some Evaluators repaint
141
+ their terminal (so the final block appears twice) or print the reply template and
142
+ their analysis before the real block. The parser isolates the **final usable
143
+ block** and accepts it when every valid `SCORE` line agrees and every valid
144
+ `VERDICT` line agrees — a redraw is a resolved answer. Genuinely conflicting
145
+ duplicate blocks (different scores or verdicts), template `<placeholder>` echoes,
146
+ out-of-range scores, and unsupported verdicts are still rejected.
147
+ - **Rejections are observable, not generic**: when a reply is not accepted, the
148
+ cycle records a specific reason instead of a bare "unparseable". `roll loop cycle
149
+ <id> --roles` distinguishes an Evaluator that **returned score-like text but was
150
+ not accepted** (e.g. conflicting duplicate blocks, a missing field) from one that
151
+ **returned no score content** at all, with the precise reason on the role line.
@@ -0,0 +1,76 @@
1
+ > Mirror of the original Chinese source — English translation pending. See IDEA-NNN for translation status.
2
+
3
+ # Roll 接入模式(Patterns)
4
+
5
+ > 三种把 Roll 引入项目的标准姿势。基于项目所处的生命周期阶段与团队风险偏好选择。
6
+
7
+ ## 三种 pattern 速览
8
+
9
+ | Pattern | 中文 | 起点 | 比喻 |
10
+ |---------|------|------|------|
11
+ | [seed-pattern](./seed-pattern.md) | 播种 | 空目录 + 愿景 | 处女地播种 |
12
+ | [graft-pattern](./graft-pattern.md) | 嫁接 | 仍在演化的现有项目 | 砧木上嫁接接穗 |
13
+ | [replant-pattern](./replant-pattern.md) | 翻种 | 累积过多债的现有项目 | 连根拔起栽新苗 |
14
+
15
+ ## 决策树
16
+
17
+ ```
18
+ 你的项目处于哪个状态?
19
+
20
+ ├── 还没开始 / 只有一个 idea
21
+ │ └──→ seed-pattern
22
+
23
+ └── 已有代码
24
+
25
+ ├── 项目仍在快速演化、不能停 → graft-pattern
26
+ ├── 团队想小步试水 Roll → graft-pattern
27
+ ├── 代码量 < 1000 行 → graft-pattern(先嫁接,需要时再 replant)
28
+
29
+ ├── 累积包袱重、想清债 → replant-pattern
30
+ ├── 想借机做架构跃迁 → replant-pattern
31
+ └── 现有版本可冷藏 → replant-pattern(必要前提)
32
+ ```
33
+
34
+ ## 三种 pattern 的核心精神对比
35
+
36
+ | 维度 | seed | graft | replant |
37
+ |------|-----------|-------|---------|
38
+ | 对原架构 | 不存在 | 零侵入保留 | 推翻 |
39
+ | 可逆性 | — | 高(`rm -rf .roll/`) | 低(发布后) |
40
+ | 风险 | 低 | 低 | 高 |
41
+ | 上限 | 高 | 中 | 高 |
42
+ | 启动门槛 | 中(要写 spec) | 低 | 高 |
43
+ | 典型周期 | 持续演化 | 持续演化 | 一次性工程 |
44
+
45
+ ## 共通要素
46
+
47
+ 无论选哪个 pattern,三者都共享同一个 `.roll/` 目录约定:
48
+
49
+ ```
50
+ .roll/
51
+ ├── backlog.md 项目管理入口
52
+ ├── specs/ 设计权威(PRD / Architecture / DDD)
53
+ ├── features/ Story 详情
54
+ ├── briefs/ dream/ Roll 自动产出
55
+ ├── decisions/ ADR
56
+ └── state/ 运行时中间产物
57
+ ```
58
+
59
+ 差别在于 **`.roll/` 是怎么诞生的**:
60
+ - seed:人手写 specs + backlog
61
+ - graft:`$roll-onboard` 从现有项目反推后落盘
62
+ - replant:先反推到 `roll-rev/`,精炼后写入 `.roll/specs/`
63
+
64
+ ## 选错了怎么办
65
+
66
+ 三种 pattern 之间存在迁移路径:
67
+
68
+ | 从 | 到 | 可行? |
69
+ |----|----|-------|
70
+ | graft | replant | ✓ 任何时候都可以"升级"为重建 |
71
+ | graft | seed | ✗ 项目已存在,不能假装没有 |
72
+ | replant | graft | ✓ 反推后发现不必重建,退回嫁接 |
73
+ | seed | graft | 不适用(seed 已经是从零起步) |
74
+ | seed | replant | ✓ 项目跑一段时间后决定重建 |
75
+
76
+ 最常见的真实路径:**graft 起步 → 跑半年 → 决定 replant 清债**。这是最稳健的演进路线。
@@ -0,0 +1,110 @@
1
+ > Mirror of the original Chinese source — English translation pending. See IDEA-NNN for translation status.
2
+
3
+ # Graft Pattern — Legacy 项目的"续写"路径
4
+
5
+ > Roll 三种接入模式之一。另见 [replant-pattern.md](./replant-pattern.md)、[seed-pattern.md](./seed-pattern.md)。
6
+ >
7
+ > **核心精神:原架构零侵入,Roll 作为接穗嫁接进来,与项目共生演化。**
8
+
9
+ ## 何时选这个 pattern
10
+
11
+ 适合:
12
+ - 项目仍在快速演化,不能停下来重建
13
+ - 团队风险偏好低,想小步增量验证
14
+ - 想先试用 Roll 一段时间再决定是否深入采用
15
+ - 原项目代码质量尚可,只是缺少 AI 辅助的项目管理与自治执行
16
+
17
+ 不适合:
18
+ - 项目本身架构腐烂,"续写" 等于继续累积债 → 选 replant
19
+ - 团队希望借机做架构跃迁 → 选 replant
20
+ - 项目尚未开始 → 选 seed
21
+
22
+ ## 目录结构
23
+
24
+ ```
25
+ my-legacy-project/ ← 砧木:现有项目,零侵入
26
+
27
+ ├── src/ lib/ tests/ docs/ 原有结构,全部不动
28
+ ├── package.json 不动
29
+ ├── README.md 不动
30
+
31
+ ├── AGENTS.md ← 嫁接接口:新增或 section-merge(非破坏)
32
+
33
+ └── .roll/ ← 接穗:Roll 工具栖息地
34
+ ├── backlog.md 项目管理增量(新故事走这里)
35
+ ├── features/ Story 详情
36
+ ├── dream/ Roll 自动产出(代码健康扫描)
37
+ ├── specs/ 可选:增量沉淀的规格文档
38
+ └── (可选 .gitignore) 团队决定是否公开
39
+ ```
40
+
41
+ ## 数据流
42
+
43
+ ```
44
+ 现有项目(砧木) ──持续演化──→ 项目继续生长,原有工作流不变
45
+
46
+ .roll/(接穗)嫁接进来
47
+
48
+ Roll 工具链接管新故事的管理与自治执行
49
+ (loop / dream / peer review / status·cycle 可观测)
50
+ ```
51
+
52
+ ## 砧木与接穗的边界
53
+
54
+ | 内容 | 砧木的职责 | 接穗的职责 |
55
+ |------|----------|----------|
56
+ | 现有源码 | ✓ 团队手动维护 | — |
57
+ | 现有测试 / CI | ✓ 不动 | — |
58
+ | 现有 issue tracker | ✓ 继续用 | — |
59
+ | 新功能的设计 / 拆解 | — | ✓ Roll 接管(`$roll-design` → backlog) |
60
+ | 新故事的实现 | — | ✓ Loop 增量执行 |
61
+ | 文档新鲜度巡检 | — | ✓ `$roll-.dream` 自动巡 |
62
+ | 跨 agent 评审 | — | ✓ Peer review 入循环 |
63
+ | 交付可观测 | — | ✓ `roll status` / `roll loop cycle` / story reports |
64
+
65
+ **`.roll/` 完全可以被 `rm -rf` 整体移除,项目回到嫁接前的状态。**
66
+ 这是 graft-pattern 与 replant-pattern 的根本区别——嫁接是**可逆**的。
67
+
68
+ ## 执行步骤
69
+
70
+ 1. `cd my-legacy-project && roll init`
71
+ 2. Roll 检测到 Legacy 结构(有源码、无 `AGENTS.md`),进入 onboarding 引导
72
+ 3. 用户在 AI agent 里运行 `$roll-onboard`
73
+ 4. Skill 读代码、理解项目、走三组九问、产出 `.roll/onboard-plan.yaml`
74
+ 5. `roll init --apply` 先打印计划操作检查点并等待确认,再按 plan 落盘 `.roll/` 结构
75
+ 6. 团队 review 生成的 backlog,调整后开始用 `$roll-build` 推新故事
76
+ 7. 可选:`roll loop on` 进入自治模式
77
+
78
+ ## 渐进式深入(L1 → L5)
79
+
80
+ graft 不是一次性事件,可以分阶段加深采用:
81
+
82
+ | 阶段 | 做了什么 | 砧木受影响程度 |
83
+ |------|---------|-------------|
84
+ | L1: 工具链 | 装 Roll CLI,`AGENTS.md` 同步 AI 工具约定 | 零(仅追加文件) |
85
+ | L2: 项目管理 | `.roll/backlog.md` 接管新故事 | 零(新故事走新流,老故事不动) |
86
+ | L3: 自动巡检 | 启用 `roll-.dream` 代码健康扫描 | 零(仅读、产出独立文件) |
87
+ | L4: Loop 自治 | 启用 `roll loop` 自动执行 Todo | 低(loop 会改源码,但走 PR 流程) |
88
+ | L5: Peer review | 跨 agent 评审入流 | 低(评审是 gating,非自动 merge) |
89
+
90
+ 团队可以停在任一层。**L1+L2 已经能拿到 70% 的 Roll 价值。**
91
+
92
+ ## 与其他 pattern 的对比
93
+
94
+ | 维度 | graft-pattern | replant-pattern | seed-pattern |
95
+ |------|--------------|----------------|---------------------|
96
+ | 对原架构的态度 | 保留并嫁接 | 推翻重建 | 无原架构(从零) |
97
+ | 风险 | 低 | 高 | 低 |
98
+ | 上限 | 中(受历史约束) | 高(彻底清债) | 高(无包袱起步) |
99
+ | 可逆性 | 高(`rm -rf .roll/` 即可) | 低(覆盖发布后) | 不适用 |
100
+ | 启动门槛 | 低 | 高 | 中 |
101
+ | 适用 | 仍在演化、不可停下来 | 包袱重、可冷藏老版本 | 新项目、从 idea 阶段 |
102
+
103
+ ## 实例
104
+
105
+ 任何使用 Roll 的已有代码库都是 graft 的实例。典型场景:
106
+
107
+ - 5 年的 Django 项目,团队装 Roll 只为给新功能做自治管理
108
+ - Spring Boot 微服务集群,装 Roll 给跨服务的 PR 评审做 peer
109
+ - Long-lived bash 工具链,装 Roll 给文档新鲜度做 dream 巡检
110
+ - 任何已有 `git log` 但缺方法论的项目