@@ -8,46 +8,51 @@ metrics (churn, hotspots, coverage). Agents do the writing; humans read and stay
88This repo holds the ** spec program** and the ** runbook** . It is built spec-by-spec by Ricky
99(the workflow agent) via an overnight runner — not hand-written all at once.
1010
11- ## How it works
11+ ## Two phases
1212
13- ```
14- Sage / MSD / NightCTO workflows
15- │ (call the shared story-writer skill as a side-effect of their work)
16- ▼
17- @code-story/skill ──writes──▶ relayfile /stories/<type>/<id>.json (the artifact)
18- ▲ ▲
19- code-narrator persona ┘ └ code-health persona (churn/hotspots/coverage)
20- │
21- @code-story/react (one shared, artifact-driven, read-only renderer,
22- ▲ extracted from MSD's renderer + PRStory)
23- ┌──────────────┼───────────────┐
24- MSD webapp Pear `story` web guided tour (stepped)
25- (primary web) view mode hosted by MSD webapp + Pear
26- ```
13+ - ** Phase 1 — self-contained (default).** Everything lives in this repo. A ** watcher** persona
14+ synthesizes stories from artifacts products * already* write to relayfile (pull, not push), and
15+ a ** standalone web viewer** renders them. ** Zero changes to sage/MSD/nightcto/pear.** One repo,
16+ one deploy, per-wave PRs. → ` specs/storybook/ `
17+ - ** Phase 2 — deferred, cross-repo (optional).** When you want * richer* stories (products emit
18+ with their internal context) or stories rendered * inline* inside Pear/MSD, edit those repos.
19+ Cross-repo, so it runs via dispatch mode. → ` specs/storybook-phase2/ `
20+
21+ Start with Phase 1; reach for Phase 2 only where the extra richness/inline-surface pays off.
2722
28- - ** relayfile** is the artifact substrate — stories are JSON files; "the filesystem is the protocol."
29- - The ** renderer is extracted from MSD** (custom tokenizer highlighting, ` diffUtils ` , and the
30- ` PRStory ` slide-deck), generalized into one backend-free ` @code-story/react ` package that MSD's
31- webapp, Pear, and the web tour all consume — so no surface reimplements code rendering.
32- - Two helper ** personas** (narrator, health) enrich stories; the three product agents emit them.
23+ ## How Phase 1 works
3324
34- See [ ` specs/storybook/PROGRAM.md ` ] ( specs/storybook/PROGRAM.md ) for the full architecture and
35- [ ` docs/storybook-boundary.md ` ] (produced by spec ` 000 ` ) for the frozen scope.
25+ ```
26+ products already write to relayfile (no storybook code in them):
27+ Sage → /notion,/linear MSD → /github/**/reviews NightCTO → /nightcto/signals
28+ │ (the watcher OBSERVES these)
29+ ▼
30+ personas/story-builder ─synthesize→ @code-story/skill ─writes→ /stories/<type>/<id>.json
31+ ▲ ▲
32+ code-narrator persona ┘ └ code-health persona (churn/hotspots/coverage)
33+ │
34+ @code-story/react (read-only renderer, vendored from MSD)
35+ │
36+ web/ standalone viewer + guided tour ◀── the Phase 1 surface
37+ ```
3638
37- ## Why its own repo
39+ - ** relayfile** is the substrate * and* the integration: the watcher reads files products already
40+ produce, so Phase 1 touches no other repo. "The filesystem is the protocol."
41+ - The renderer is ** vendored from MSD** (its tokenizer highlighting, ` diffUtils ` , and the ` PRStory `
42+ slide-deck) into one backend-free ` @code-story/react ` — a one-time copy, no MSD import/edit.
3843
39- Storybook spans repos — Sage, MSD, Pear, and a shared ` @code-story ` package all participate.
40- It does not belong inside any one of them, so the spec program + orchestration live here .
44+ See [ ` specs/storybook/PROGRAM.md ` ] ( specs/storybook/PROGRAM.md ) for the architecture and
45+ ` docs/storybook-boundary.md ` (produced by spec ` 000 ` ) for the frozen scope .
4146
42- ## Spec program (14 specs, 5 waves)
47+ ## Phase 1 spec program (14 specs, 5 waves — all in this repo )
4348
44- | Wave | Specs | Target |
45- | ---| ---| --- |
46- | 0 — Contract | ` 000 ` boundary · ` 001 ` ` CodeStory ` schema | shared ` @code-story ` |
47- | 1 — Writer | ` 010 ` story-writer skill · ` 011 ` index + ACL | shared ` @code-story ` |
48- | 2 — Emit | ` 020 ` Sage planning · ` 021 ` MSD review · ` 022 ` NightCTO runtime | sage · My-Senior-Dev/app · nightcto |
49- | 3 — Renderer | ` 030 ` extract ` @code-story/react ` from MSD · ` 031 ` Pear mount · ` 032 ` MSD webapp surface · ` 033 ` web tour | My-Senior-Dev/app → shared · pear |
50- | 4 — Narrate/health/proof | ` 040 ` narrator persona · ` 041 ` health persona · ` 042 ` e2e proof | shared (cross-repo e2e) |
49+ | Wave | Specs |
50+ | ---| ---|
51+ | 0 — Contract | ` 000 ` boundary · ` 001 ` ` CodeStory ` schema |
52+ | 1 — Library | ` 010 ` story-writer skill · ` 011 ` index + ACL |
53+ | 2 — Watcher | ` 020 ` story-builder · ` 021 ` planning synthesis · ` 022 ` review synthesis · ` 023 ` runtime synthesis |
54+ | 3 — Renderer + viewer | ` 030 ` ` @code-story/react ` (vendored) · ` 031 ` standalone viewer · ` 032 ` guided tour |
55+ | 4 — Narrate/health/proof | ` 040 ` narrator persona · ` 041 ` health persona · ` 042 ` e2e proof |
5156
5257Each spec is bounded (` Goal / Context / In scope / Out of scope / Acceptance / Review / Handoff ` )
5358and ends with a reviewer-checkable PASS gate.
@@ -59,60 +64,47 @@ Specs are implemented one at a time by Ricky, in dependency order, with an
5964` specs/storybook/_review.md ` / ` _fix.md ` ).
6065
6166``` bash
62- # inspect the plan (no side effects)
63- ./scripts/run-overnight.sh storybook --dry-run
64-
65- # run it: implement → review → fix each spec, commit, open a draft PR per wave
66- ./scripts/run-overnight.sh storybook
67+ # Phase 1 (self-contained, single repo, per-wave PRs)
68+ ./scripts/run-overnight.sh storybook --dry-run # inspect the plan (no side effects)
69+ ./scripts/run-overnight.sh storybook # implement → review → fix, commit, PR per wave
6770```
6871
6972Flags / env:
7073- ` --from <spec-id> ` — resume from a spec (e.g. ` --from 030 ` )
7174- ` --no-pr ` — skip per-wave draft PRs
7275- ` MAX_REVIEW_ITERS ` (default 3) — review/fix loop cap
73- - ` REVIEW_CMD ` / ` FIX_CMD ` — override the reviewer/fixer invocation (default: Ricky local with ` _review.md ` / ` _fix.md ` )
74-
75- ### Cross-repo dispatch (automatic)
76-
77- Storybook is cross-repo, so each spec declares a machine-readable ** ` **Repo:** ` slug** in its
78- header. The runner auto-detects these and switches to ** dispatch mode** : each spec is
79- implemented in its ** target repo** on a ` results/storybook ` branch, and a draft PR is opened
80- ** per touched repo** — no manual repo-hopping.
81-
82- Slugs resolve to local repo paths (sibling clones assumed):
76+ - ` REVIEW_CMD ` / ` FIX_CMD ` — override the reviewer/fixer invocation
8377
84- | slug | resolves to | holds |
85- | ---| ---| ---|
86- | ` code-storybook ` | this repo | the shared ` @code-story ` package (schema, skill, ` react ` renderer, helper personas) |
87- | ` sage ` | ` $PROJECTS_ROOT/sage ` | ` 020 ` planning story |
88- | ` my-senior-dev ` | ` $PROJECTS_ROOT/../My-Senior-Dev/app ` | ` 021 ` review story, ` 030 ` extract, ` 032 ` webapp surface |
89- | ` nightcto ` | ` $PROJECTS_ROOT/nightcto ` | ` 022 ` runtime story |
90- | ` pear ` | ` $PROJECTS_ROOT/pear ` | ` 031 ` story view |
78+ ### Phase 2 (deferred, cross-repo dispatch)
9179
92- ` PROJECTS_ROOT ` defaults to this repo's parent; override any path with ` REPO_<slug> ` env
93- (e.g. ` REPO_my_senior_dev=/path/to/app ` ). Inspect routing first with ` --dry-run ` :
80+ Phase 2 specs declare a machine-readable ` **Repo:** ` slug; the runner auto-detects these and
81+ switches to ** dispatch mode** — each spec is implemented in its target repo on a
82+ ` results/storybook-phase2 ` branch, one draft PR ** per touched repo** .
9483
9584``` bash
96- ./scripts/run-overnight.sh storybook --dry-run # prints START <spec> -> <slug> (<repo>)
85+ ./scripts/run-overnight.sh storybook-phase2 --dry-run # prints START <spec> -> <slug> (<repo>)
86+ ./scripts/run-overnight.sh storybook-phase2
9787```
9888
99- Because of dependencies, the shared pieces (waves 0–1 + the ` 030 ` extract) build first in
100- ` code-storybook ` ; publish ` @code-story ` , then the per-product specs consume it. The runner
101- walks them in order and the review cycle gates each before moving on.
89+ Slugs resolve to local repo paths (sibling clones assumed): ` sage ` , ` nightcto ` , ` pear ` →
90+ ` $PROJECTS_ROOT/<slug> ` ; ` my-senior-dev ` → ` $PROJECTS_ROOT/../My-Senior-Dev/app ` . ` PROJECTS_ROOT `
91+ defaults to this repo's parent; override any path with ` REPO_<slug> ` (e.g. ` REPO_my_senior_dev=… ` ).
92+ Phase 2 depends on Phase 1 being merged and ` @code-story ` published.
10293
10394## Spec format & CI
10495
10596Every numbered spec must carry the sections the runner + reviewer rely on
106- (` Goal / In scope / Out of scope / Acceptance / Review / Handoff ` ) and a valid ` **Repo:** `
107- slug. ` scripts/lint-specs.sh ` enforces this and runs in CI (` .github/workflows/lint-specs.yml ` )
108- on every push/PR touching ` specs/ ` :
97+ (` Goal / In scope / Out of scope / Acceptance / Review / Handoff ` ). A ` **Repo:** ` slug is
98+ ** optional** (Phase 1 omits it; Phase 2 requires it for dispatch) and, when present, must be a
99+ valid slug. ` scripts/lint-specs.sh ` enforces this in CI (` .github/workflows/lint-specs.yml ` ) on
100+ every push/PR touching ` specs/ ` :
109101
110102``` bash
111- ./scripts/lint-specs.sh # OK — N specs, all have required sections + a valid **Repo:** header
103+ ./scripts/lint-specs.sh # OK — N specs, all have required sections (and any **Repo:** slug is valid)
112104```
113105
114106## Related
115107
116108- ` AgentWorkforce/nightcto ` → ` specs/persona-migration/ ` — the reference persona migration this
117- storybook program assumes (NightCTO emits runtime stories from its migrated watch handler ).
109+ program assumes (NightCTO writes the ` /nightcto/signals/** ` the runtime synthesizer reads ).
118110- ` AgentWorkforce/nightcto ` → ` specs/INVENTORY.md ` — front door indexing both programs.
0 commit comments