ystack 0.1.0 → 0.2.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.
package/PLAN.md DELETED
@@ -1,515 +0,0 @@
1
- # ystack — Plan
2
-
3
- ## Problem
4
-
5
- AI coding agents need three things they don't have:
6
-
7
- 1. **Memory** — persistent state across sessions → Beads
8
- 2. **Workflow** — a guided path from idea to PR → ystack commands
9
- 3. **Spec-code-docs coherence** — docs reflect what's built, not what's planned → module registry + doc sync
10
-
11
- ## Commands
12
-
13
- ```
14
- /scaffold → split a big plan into module docs scaffold
15
- /import → analyze existing repo, generate module registry + doc stubs
16
- /build → plan a feature (reads docs + code, surfaces assumptions)
17
- /go → execute the plan (fresh subagents, atomic commits)
18
- /review → code review + goal-backward verification
19
- /docs → update documentation for completed work
20
- /pr → verify → docs check → create PR
21
- ```
22
-
23
- ### The Two Flows
24
-
25
- **New project:**
26
- ```
27
- Big plan (markdown)
28
- → /scaffold
29
- → module registry, doc scaffold (overviews, interactions, stubs)
30
- → epic beads per module with child features
31
- → pick a module
32
- → /build → /go → /review → /docs → /pr
33
- → repeat per module
34
- ```
35
-
36
- **Existing project:**
37
- ```
38
- Existing repo + docs
39
- → /import
40
- → scans code, docs, git history
41
- → generates module registry
42
- → creates epic beads per module (marks implemented features as closed)
43
- → flags doc gaps
44
- → continue with /build → /go → /review → /docs → /pr
45
- ```
46
-
47
- ---
48
-
49
- ## Architecture
50
-
51
- ```
52
- ┌──────────────────────────────────────────────────────┐
53
- │ Developer │
54
- │ /scaffold /import /build /go /review /docs /pr │
55
- ├──────────────────────────────────────────────────────┤
56
- │ ystack (workflow layer) │
57
- │ • Module registry (modules ↔ docs ↔ beads) │
58
- │ • Doc-driven planning │
59
- │ • Execution with fresh subagents │
60
- │ • Goal-backward verification │
61
- │ • Doc sync (completed work → docs) │
62
- ├──────────────────────────────────────────────────────┤
63
- │ Beads (memory layer) │
64
- │ • Epic beads per module │
65
- │ • Feature beads as children │
66
- │ • Structured notes, dependencies │
67
- │ • Cross-session continuity │
68
- ├──────────────────────────────────────────────────────┤
69
- │ Project │
70
- │ • docs/ (the spec — final state only) │
71
- │ • CLAUDE.md / AGENTS.md │
72
- │ • Existing skills: pr-draft, docs-update, commit │
73
- └──────────────────────────────────────────────────────┘
74
- ```
75
-
76
- ### The Module Registry
77
-
78
- The bridge between code, docs, and Beads. Lives in `ystack.config.json`:
79
-
80
- ```json
81
- {
82
- "modules": {
83
- "payments": {
84
- "doc": "shared/payments",
85
- "scope": [
86
- "packages/payments/**",
87
- "packages/db/src/schema/transactions.*",
88
- "apps/api/src/routes/payments.*"
89
- ],
90
- "epic": "bd-a1b2",
91
- "status": "active"
92
- },
93
- "notifications": {
94
- "doc": "notifications",
95
- "scope": [
96
- "packages/notifications/**",
97
- "apps/api/src/messaging-gateway/**"
98
- ],
99
- "epic": "bd-c3d4",
100
- "status": "active"
101
- },
102
- "admin": {
103
- "doc": "admin",
104
- "scope": [
105
- "apps/admin/**"
106
- ],
107
- "epic": "bd-e5f6",
108
- "status": "active"
109
- }
110
- },
111
- "docs": {
112
- "root": "docs/src/content",
113
- "framework": "nextra" // or "fumadocs"
114
- },
115
- "monorepo": {
116
- "enabled": true,
117
- "scopes": {
118
- "apps/api": "api",
119
- "apps/admin": "admin",
120
- "packages/shared": "shared",
121
- "packages/db": "db"
122
- }
123
- },
124
- "workflow": {
125
- "plan_checker": true,
126
- "fresh_context_per_task": true,
127
- "auto_docs_check": true,
128
- "small_task_threshold": 3
129
- }
130
- }
131
- ```
132
-
133
- Each module entry connects three things:
134
- - **doc** — path to the docs section (relative to docs root). Sub-modules are doc sub-pages, not separate registry entries.
135
- - **scope** — glob patterns for code that belongs to this module. A module can span files across multiple packages.
136
- - **epic** — the Beads epic tracking this module's progress. Features are child beads, not registry entries.
137
-
138
- ### Two Sources of Truth
139
-
140
- | | Docs (Nextra) | Beads |
141
- |---|---|---|
142
- | **Shows** | What the system IS (final state) | What's been done, what's left |
143
- | **Audience** | Whole team, new devs, AI agents | Active developers, AI agents |
144
- | **Changes when** | Feature is completed and verified | Every task starts/finishes |
145
- | **Contains** | Architecture, contracts, data models, flows | Progress, decisions, context, next steps |
146
- | **Never contains** | Planning, in-progress, "coming soon" | Final specs (those go in docs) |
147
-
148
- **The sync rule:** docs reflect only completed work. When a bead closes → check parent epic → flag doc page for update. `/docs` reads closed-but-not-yet-documented children to know what's new.
149
-
150
- ---
151
-
152
- ## Commands — Detailed Specs
153
-
154
- ### `/scaffold` — Start a New Project
155
-
156
- Takes a big plan (markdown input or file) and produces a documentation scaffold + module registry + epic beads.
157
-
158
- **When to use:** Starting a new project, or when you have an overall architecture in your head and want to turn it into a structured starting point.
159
-
160
- **Input:** A markdown document describing the project. Can be rough — module names, how they connect, key features. Example:
161
-
162
- ```markdown
163
- # MyApp
164
-
165
- ## Modules
166
-
167
- ### Auth
168
- - Email/password login
169
- - OAuth (Google, GitHub)
170
- - Session management
171
- - Connects to: Database, API
172
-
173
- ### Payments
174
- - Stripe integration
175
- - Wallet with balance
176
- - Subscription management
177
- - Connects to: Auth, Database, API
178
-
179
- ### Dashboard
180
- - User overview
181
- - Usage charts
182
- - Settings page
183
- - Connects to: Auth, Payments, API
184
- ```
185
-
186
- **Process:**
187
-
188
- 1. **Parse the plan** — extract modules, features per module, and inter-module connections.
189
-
190
- 2. **Generate doc scaffold** — for each module, create:
191
- - `docs/src/content/<module>/index.mdx` — module overview with:
192
- - Purpose (1-2 sentences from the plan)
193
- - Module interaction diagram (Mermaid, auto-generated from connections)
194
- - Feature list as stub sections (headers only, no content yet)
195
- - Dependencies table
196
- - `docs/src/content/<module>/_meta.ts` — navigation entries
197
- - Update parent `_meta.ts` to include new modules
198
-
199
- 3. **Generate system overview** — a top-level architecture page with:
200
- - Full system diagram showing all modules and their connections
201
- - Module table (name, purpose, status)
202
- - This becomes the "map" that everything else references
203
-
204
- 4. **Create module registry** — write `ystack.config.json` with module entries.
205
-
206
- 5. **Create epic beads** — one epic per module, child beads per feature:
207
- ```
208
- bd create "Auth Module" -t epic --metadata '{"doc": "auth"}'
209
- bd create "Email/password login" -t feature --parent bd-xxxx
210
- bd create "OAuth (Google, GitHub)" -t feature --parent bd-xxxx
211
- bd create "Session management" -t feature --parent bd-xxxx
212
- ```
213
-
214
- 6. **Add inter-module dependencies** where features cross boundaries:
215
- ```
216
- bd dep add bd-payments-wallet blocks:bd-dashboard-usage
217
- ```
218
-
219
- 7. **Present scaffold to user** — show the doc structure, module diagram, and bead graph. Ask for corrections.
220
-
221
- **Output:** A project with:
222
- - Doc scaffold (overviews with diagrams, feature stubs)
223
- - Module registry linking code ↔ docs ↔ beads
224
- - Epic beads with feature children
225
- - A clear "ready front" — features with no blockers that you can `/build` first
226
-
227
- **Key design:** The scaffold is intentionally shallow — module overviews and interaction diagrams only. No detailed specs. Those get written as features are implemented via `/docs`. This keeps docs honest: they describe what IS, not what's planned. The stubs show structure, the beads track what's left.
228
-
229
- ---
230
-
231
- ### `/import` — Adopt an Existing Project
232
-
233
- Analyzes an existing repo and generates the module registry, doc stubs, and Beads state. This is the on-ramp for projects that already have code (and possibly docs).
234
-
235
- **When to use:** You have an existing codebase and want to bring it into the ystack workflow.
236
-
237
- **Process:**
238
-
239
- 1. **Scan codebase** — spawn parallel agents to analyze:
240
- - **Structure agent:** package.json files, directory tree, monorepo layout → module boundaries
241
- - **Dependency agent:** imports, package.json deps → inter-module connections
242
- - **Schema agent:** database schemas, API routes, type definitions → data model inventory
243
- - **Docs agent:** existing docs, README files, CLAUDE.md → current documentation state
244
-
245
- 2. **Detect modules** — group code into logical modules based on:
246
- - Package boundaries (monorepo packages/apps)
247
- - Directory structure (feature folders)
248
- - Import patterns (what depends on what)
249
-
250
- 3. **Scan existing docs** — if docs exist:
251
- - Map doc pages to detected modules
252
- - Identify documented vs. undocumented modules
253
- - Check for stale docs (code changed, docs didn't)
254
-
255
- 4. **Generate module registry** — write `ystack.config.json` with discovered modules.
256
-
257
- 5. **Create epic beads** — one per module. For each:
258
- - Analyze code to identify implemented features
259
- - Create child beads, marking implemented ones as **closed**
260
- - Mark undocumented features with label `needs-docs`
261
- - Mark features with stale docs with label `docs-stale`
262
-
263
- 6. **Generate gap report:**
264
- ```markdown
265
- # Import Report
266
-
267
- ## Modules Detected: 8
268
- - payments (3 features, all documented)
269
- - auth (4 features, 2 undocumented)
270
- - admin (5 features, 1 stale doc)
271
- ...
272
-
273
- ## Documentation Gaps
274
- - auth/oauth: implemented but no docs
275
- - auth/sessions: implemented but no docs
276
- - admin/campaigns: docs reference old API shape
277
-
278
- ## Suggested Next Steps
279
- 1. Run /docs to update 3 gap pages
280
- 2. Review stale docs for admin/campaigns
281
- 3. /build for any new features
282
- ```
283
-
284
- 7. **Create doc stubs** for undocumented modules (if docs site exists) or offer to scaffold with `/scaffold`.
285
-
286
- **Key design:** This is a long-running process. For a large repo it could take several minutes with parallel agents. Progress should be visible. The output is conservative — it creates beads and a registry but doesn't modify existing docs without user confirmation.
287
-
288
- **Incremental adoption:** You don't have to import everything at once. `/import --module payments` can import a single module.
289
-
290
- ---
291
-
292
- ### `/build <feature>` — Plan
293
-
294
- The entry point for implementing a feature.
295
-
296
- **Process:**
297
-
298
- 1. **Check status** — `bd ready` for in-progress work. If resuming, show context.
299
-
300
- 2. **Find module** — match feature description to module registry. If ambiguous, ask.
301
-
302
- 3. **Read docs** — load the module's doc page to understand current spec.
303
-
304
- 4. **Read code** — load the module's packages to understand current implementation.
305
-
306
- 5. **Surface assumptions:**
307
- ```
308
- I'd approach this by:
309
- 1. Adding a refundReason enum column to the transactions table
310
- 2. Accepting it in POST /api/payments/refund
311
- 3. Displaying as a badge in admin transaction detail
312
-
313
- Assumptions:
314
- - Enum values: duplicate, fraud, requested, other
315
- - Column on transactions, not a separate table
316
-
317
- Correct anything, or confirm.
318
- ```
319
-
320
- 6. **Capture decisions** → `.context/<bead-id>/DECISIONS.md`
321
-
322
- 7. **Create plan** → `.context/<bead-id>/PLAN.md` with goal-backward success criteria.
323
-
324
- 8. **Create child beads** under the module's epic with dependencies.
325
-
326
- 9. **Plan-checker gate** — subagent validates plan delivers all decisions. Max 2 revisions.
327
-
328
- 10. **Present plan** — wait for confirmation.
329
-
330
- **Small task detection:** 1 task, ≤3 files → "This is small — want me to just do it?"
331
-
332
- ---
333
-
334
- ### `/go` — Execute
335
-
336
- Runs the plan with fresh subagents.
337
-
338
- **Process:**
339
-
340
- 1. Read `.context/<bead-id>/PLAN.md`.
341
- 2. Compute execution order from dependencies.
342
- 3. Per task:
343
- a. `bd update <id> --claim`
344
- b. Spawn subagent with: task description + file targets + verification step
345
- c. Subagent works in fresh context (reads only its target files)
346
- d. Atomic commit on success
347
- e. Update bead notes (COMPLETED / KEY DECISIONS format)
348
- f. `bd close <id>`
349
- 4. Report results.
350
-
351
- **Deviation rules:**
352
- - Auto-fix: minor bugs, missing imports, type errors
353
- - STOP and ask: architectural decisions, scope changes
354
-
355
- ---
356
-
357
- ### `/review` — Code Review + Verification
358
-
359
- Reviews changes and verifies against success criteria.
360
-
361
- **Process:**
362
-
363
- 1. Load project rules (.claude/rules/, CLAUDE.md, contributor guidance, design guide).
364
- 2. Read diff (all changes since before `/go`).
365
- 3. Check: security, accessibility, performance, style, types, error handling.
366
- 4. Goal-backward verification — check each success criterion against actual code.
367
- 5. Output findings with file:line references.
368
- 6. User decides: fix or accept.
369
-
370
- ---
371
-
372
- ### `/docs` — Update Documentation
373
-
374
- Updates docs for completed work. Only completed work.
375
-
376
- **Process:**
377
-
378
- 1. Read module registry — which module was this work for?
379
- 2. Read the module's epic — which children just closed?
380
- 3. Read the module's doc page — what's currently documented?
381
- 4. Update only the sections affected by newly completed features:
382
- - New data model fields
383
- - New API endpoints
384
- - Updated flow diagrams
385
- - Changed dependencies
386
- 5. Mark beads as documented (label `documented`).
387
- 6. Never add "planned" or "coming soon" content.
388
-
389
- Delegates to existing `docs-update` skill.
390
-
391
- ---
392
-
393
- ### `/pr` — Create PR
394
-
395
- **Process:**
396
-
397
- 1. Final success criteria verification.
398
- 2. Docs check — code changes without doc updates? Warn.
399
- 3. `pnpm fix` + `pnpm typecheck`.
400
- 4. Delegate to `pr-draft` skill.
401
- 5. Verify all beads in scope are closed.
402
- 6. Clean up `.context/<bead-id>/`.
403
-
404
- ---
405
-
406
- ## Hooks
407
-
408
- ### Context Monitor (PostToolUse)
409
- - 60% context: suggest subagents for remaining work
410
- - 80%: suggest finishing current task
411
-
412
- ### Session Start
413
- - Auto-detect project (`.beads/` + `ystack.config.json`)
414
- - Show: module status summary, ready front, in-progress work
415
- - If `.context/` has active bead folders: remind of in-progress work
416
-
417
- ### Workflow Nudge (PreToolUse on Edit)
418
- - Editing code with no active `.context/<bead-id>/PLAN.md`: "Consider `/build` for tracked changes."
419
-
420
- ---
421
-
422
- ## Design Principles
423
-
424
- ### From GSD
425
- 1. **Plans are prompts** — PLAN.md is the subagent's literal prompt
426
- 2. **Goal-backward verification** — success criteria against actual code
427
- 3. **Fresh context per agent** — clean context window per task
428
- 4. **Scope reduction prohibition** — never silently simplify
429
- 5. **Plan-checker gate** — validate before execution
430
-
431
- ### From Beads
432
- 6. **Beads is the state layer** — don't reinvent task tracking
433
- 7. **Structured notes** — COMPLETED / IN PROGRESS / NEXT / KEY DECISIONS / BLOCKERS
434
- 8. **Ready fronts** — `bd ready` drives work selection
435
- 9. **Epics as module trackers** — parent-child for module → features
436
-
437
- ### Our Own
438
- 10. **Docs are final state only** — never "planned" or "in progress"
439
- 11. **Module registry** — the bridge between code, docs, and beads
440
- 12. **Scaffold-first** — start with structure, fill in as you build
441
- 13. **Import existing** — on-ramp for repos that already have code
442
- 14. **7 commands** — scaffold, import, build, go, review, docs, pr
443
-
444
- ---
445
-
446
- ## The `.context/` Directory
447
-
448
- Ephemeral working files during active feature work. Gitignored. Scoped by bead ID so multiple agents/features can work in parallel without collisions.
449
-
450
- ```
451
- .context/
452
- ├── bd-a1b2/ # "Add refund reason" feature
453
- │ ├── DECISIONS.md
454
- │ └── PLAN.md
455
- ├── bd-c3d4/ # "Add OAuth support" feature
456
- │ ├── DECISIONS.md
457
- │ └── PLAN.md
458
- └── bd-e5f6/ # "Dashboard charts" feature
459
- ├── DECISIONS.md
460
- └── PLAN.md
461
- ```
462
-
463
- Each `/build` creates `.context/<bead-id>/`. Each `/go` reads from the same folder. No collisions across parallel agents or features.
464
-
465
- ### What Gets Committed vs. What Stays Ephemeral
466
-
467
- | Artifact | Committed? | Shared with team? | Why |
468
- |----------|-----------|-------------------|-----|
469
- | Docs (`docs/src/content/`) | Yes | Yes | Final state of the product |
470
- | Module registry (`ystack.config.json`) | Yes | Yes | Module map everyone needs |
471
- | CLAUDE.md / AGENTS.md | Yes | Yes | AI context for all agents |
472
- | Beads (`.beads/`) | Yes (Dolt refs) | Yes | Progress, notes, decisions — the development state machine |
473
- | `.context/<bead-id>/` | No | No | Temporary working files — consumed by `/go`, then cleaned up |
474
-
475
- The valuable parts of `.context/` flow to their permanent homes:
476
-
477
- ```
478
- /build → .context/<bead-id>/DECISIONS.md (temporary)
479
-
480
- /go → bead structured notes (committed via Beads)
481
-
482
- /docs → doc pages (committed via git)
483
-
484
- /pr → .context/<bead-id>/ cleaned up
485
- ```
486
-
487
- Nothing is lost. Decisions get written into bead notes during execution. Outcomes get written into docs during `/docs`. The temporary files are just a working scratch pad for the active agent.
488
-
489
- ---
490
-
491
- ## Build Order
492
-
493
- | Phase | What | Value |
494
- |-------|------|-------|
495
- | **1** | Module registry format + `ystack.config.json` | Foundation everything builds on |
496
- | **2** | `/build` — doc reading, assumptions, planning | Standalone planning tool |
497
- | **3** | `/go` — execution with fresh subagents | Core loop: build → go |
498
- | **4** | `/review` — code review + verification | Quality gate |
499
- | **5** | `/docs` — doc sync for completed work | Docs stay current |
500
- | **6** | `/pr` — shipping chain | Wraps pr-draft |
501
- | **7** | `/scaffold` — new project scaffolding | New project on-ramp |
502
- | **8** | `/import` — existing project adoption | Existing project on-ramp (long-running, complex) |
503
- | **9** | Hooks + installer + docs | Polish and distribution |
504
-
505
- ---
506
-
507
- ## Open Questions
508
-
509
- 1. **Beads version** — minimum `bd` version to depend on?
510
- 2. ~~**Docs framework**~~ — supports Nextra and Fumadocs via docs adapter.
511
- 3. **Parallel execution** — should `/go` parallelize independent tasks from day 1?
512
- 4. **Linear sync** — use Beads `--external-ref linear:LIN-123` by default?
513
- 5. **Import depth** — how deep should `/import` analyze? Function-level or module-level?
514
- 6. **Scaffold input** — accept markdown file, clipboard, or interactive Q&A?
515
- 7. **Multi-repo** — should module registry support modules across repos?