@seanyao/roll 3.610.1 → 3.610.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 (73) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +5 -5
  3. package/dist/roll.mjs +9115 -11282
  4. package/package.json +3 -1
  5. package/skills/README.md +14 -1
  6. package/skills/docs/skill-authoring.md +66 -0
  7. package/skills/reports/skill-audit-summary.md +53 -0
  8. package/skills/roll-.changelog/SKILL.md +25 -443
  9. package/skills/roll-.changelog/references/full-contract.md +462 -0
  10. package/skills/roll-.clarify/SKILL.md +6 -4
  11. package/skills/roll-.dream/SKILL.md +26 -353
  12. package/skills/roll-.dream/references/full-contract.md +365 -0
  13. package/skills/roll-.echo/SKILL.md +6 -4
  14. package/skills/roll-.qa/SKILL.md +25 -236
  15. package/skills/roll-.qa/references/full-contract.md +256 -0
  16. package/skills/roll-.review/SKILL.md +6 -2
  17. package/skills/roll-brief/SKILL.md +6 -8
  18. package/skills/roll-build/SKILL.md +28 -864
  19. package/skills/roll-build/references/full-contract.md +883 -0
  20. package/skills/roll-debug/SKILL.md +26 -585
  21. package/skills/roll-debug/references/full-contract.md +607 -0
  22. package/skills/roll-design/SKILL.md +28 -903
  23. package/skills/roll-design/references/full-contract.md +923 -0
  24. package/skills/roll-doc/SKILL.md +25 -574
  25. package/skills/roll-doc/references/full-contract.md +594 -0
  26. package/skills/roll-doctor/SKILL.md +21 -2
  27. package/skills/roll-fix/SKILL.md +28 -621
  28. package/skills/roll-fix/references/full-contract.md +640 -0
  29. package/skills/roll-idea/SKILL.md +6 -2
  30. package/skills/roll-loop/SKILL.md +27 -543
  31. package/skills/roll-loop/references/full-contract.md +555 -0
  32. package/skills/roll-notes/SKILL.md +6 -2
  33. package/skills/roll-onboard/SKILL.md +6 -2
  34. package/skills/roll-peer/SKILL.md +27 -316
  35. package/skills/roll-peer/references/full-contract.md +329 -0
  36. package/skills/roll-propose/SKILL.md +6 -8
  37. package/skills/roll-review-pr/SKILL.md +6 -2
  38. package/skills/roll-sentinel/SKILL.md +26 -344
  39. package/skills/roll-sentinel/references/full-contract.md +363 -0
  40. package/skills/roll-spar/SKILL.md +27 -269
  41. package/skills/roll-spar/references/full-contract.md +288 -0
  42. package/skills/route-cases/skills.json +235 -0
  43. package/skills/scripts/audit-skills.mjs +272 -0
  44. package/skills/scripts/test-audit-skills.mjs +39 -0
  45. package/skills/tests/fixtures/skill-audit/block-skill/SKILL.md +12 -0
  46. package/skills/tests/fixtures/skill-audit/minimal-skill/SKILL.md +8 -0
  47. package/skills/tests/fixtures/skill-audit/quoted-skill/SKILL.md +10 -0
  48. package/skills/tests/fixtures/skill-audit/route-cases.json +21 -0
  49. package/skills/tests/fixtures/skill-audit/spoke-skill/SKILL.md +12 -0
  50. package/skills/tests/fixtures/skill-audit/spoke-skill/references/runbook.md +3 -0
  51. package/lib/i18n/slides.sh +0 -3
  52. package/lib/i18n/slides_build.sh +0 -38
  53. package/lib/i18n/slides_delete.sh +0 -19
  54. package/lib/i18n/slides_list.sh +0 -14
  55. package/lib/i18n/slides_logs.sh +0 -12
  56. package/lib/i18n/slides_new.sh +0 -15
  57. package/lib/i18n/slides_preview.sh +0 -14
  58. package/lib/i18n/slides_templates.sh +0 -7
  59. package/lib/slides/components/README.md +0 -123
  60. package/lib/slides/components/cards-2.html +0 -9
  61. package/lib/slides/components/cards-3.html +0 -9
  62. package/lib/slides/components/cards-4.html +0 -9
  63. package/lib/slides/components/compare.html +0 -22
  64. package/lib/slides/components/highlight.html +0 -9
  65. package/lib/slides/components/pipeline.html +0 -12
  66. package/lib/slides/components/plain.html +0 -7
  67. package/lib/slides/components/quote.html +0 -4
  68. package/lib/slides/components/timeline.html +0 -9
  69. package/lib/slides/templates/introduction-v3.html +0 -571
  70. package/lib/slides/templates/pitch.html +0 -0
  71. package/skills/roll-deck/SKILL.md +0 -296
  72. /package/skills/roll-debug/{injectable-bb.js → assets/injectable-bb.js} +0 -0
  73. /package/skills/roll-design/{ENGINEERING_CHECKLIST.md → references/engineering-checklist.md} +0 -0
@@ -0,0 +1,594 @@
1
+ # Full Contract Reference
2
+
3
+ This file preserves the detailed contract extracted from SKILL.md. Read it when the hub points here for exact workflow steps, templates, rubrics, or recovery branches.
4
+
5
+ ---
6
+
7
+ # roll-doc
8
+
9
+ Four-phase legacy documentation automation (plus deep-read Phase 3b): scan → index → gap analysis → fill (directory-level) → deep read (cross-directory topics).
10
+
11
+ Works on any project root. No manual mode switching — reads the project state and decides what to do.
12
+
13
+ ## When to Use
14
+
15
+ - Starting to work on a legacy project with scattered or missing documentation
16
+ - `docs/INDEX.md` is out of date or doesn't exist yet
17
+ - `roll-.dream` Scan 6 flagged undocumented modules (REFACTOR entry referencing roll-doc)
18
+ - You want a complete picture of what's documented and what isn't
19
+
20
+ ## When Not to Use
21
+
22
+ - The project has up-to-date, maintained docs — no need to rebuild the index
23
+ - You need authoritative documentation reviewed and approved (drafts only; human reviews and commits)
24
+ - You want to write a specific known doc from scratch — write it directly
25
+
26
+ ## Invocation
27
+
28
+ ```
29
+ $roll-doc # Full four-phase run
30
+ $roll-doc --dry-run # Phases 1–2 only; print Phase 3 plan without writing any files
31
+ $roll-doc --force # Re-generate drafts even for existing files
32
+ ```
33
+
34
+ ## Phase 1 — Scan & Index
35
+
36
+ Scan the project root for all `*.md` files and known convention files.
37
+
38
+ **Exclusions — never scan these directories:**
39
+
40
+ ```
41
+ node_modules/ .git/ dist/ build/ .shared/ .roll/dream/ .roll/briefs/
42
+ ```
43
+
44
+ **Convention files — detect by filename anywhere in the tree:**
45
+
46
+ ```
47
+ AGENTS.md CLAUDE.md GEMINI.md CONVENTIONS.md CONTRIBUTING.md
48
+ ARCHITECTURE.md ADR-*.md
49
+ ```
50
+
51
+ **Classification rules:**
52
+
53
+ | Category | Criteria |
54
+ |----------|----------|
55
+ | `guide` | Path under `guide/` |
56
+ | `domain` | Path under `.roll/domain/` |
57
+ | `convention` | Filename matches convention markers list above |
58
+ | `module` | File is `<dir>/README.md` for a source directory |
59
+ | `stray` | None of the above (top-level, unorganized, or orphaned) |
60
+
61
+ **Output — produce/update `docs/INDEX.md`:**
62
+
63
+ ```markdown
64
+ # Documentation Index
65
+
66
+ > Auto-generated by roll-doc on YYYY-MM-DD. Edit individual docs, not this file.
67
+
68
+ ## Index
69
+
70
+ | Path | Title | Category | Last Modified |
71
+ |------|-------|----------|---------------|
72
+ | guide/en/loop.md | Loop User Guide | guide | 2026-05-01 |
73
+ | AGENTS.md | Agent Conventions | convention | 2026-04-28 |
74
+
75
+ ## Coverage Summary
76
+
77
+ - Total docs indexed: N
78
+ - By category: guide (N) / domain (N) / convention (N) / module (N) / stray (N)
79
+
80
+ ## Gap Report
81
+
82
+ Directories with ≥3 source files and no linked documentation:
83
+
84
+ | Directory | Source Files | Missing Doc |
85
+ |-----------|-------------|-------------|
86
+ | src/commands/ | 8 | README.md |
87
+ ```
88
+
89
+ `docs/INDEX.md` is always overwritten on each run — it is a derived artifact, not authoritative content.
90
+
91
+ ## Phase 2 — Gap Analysis
92
+
93
+ Walk every directory (applying Phase 1 exclusions):
94
+
95
+ 1. Count non-hidden, non-`.md` source files directly in the directory
96
+ 2. If count ≥ 3 AND no `README.md` in that directory AND no `docs/INDEX.md` entry links to it → **module gap**
97
+ 3. **High fan-in gap**: a directory imported by **≥ 5 other source files** is a gap targeting `<dir>/README.md`, **even if it has < 3 source files** — critical low-volume modules (shared utils, single-file core) must not be skipped by the file-count threshold. The existing count ≥ 3 rule (rule 2) continues to apply independently; high fan-in only widens what qualifies, it never overrides rule 2.
98
+
99
+ **Special gaps (checked once per project):**
100
+ - No `.roll/domain/` directory or empty → gap: `.roll/domain/context-map.md`
101
+ - No `CONVENTIONS.md` or `docs/CONVENTIONS.md` exists → gap: `docs/CONVENTIONS.md`
102
+
103
+ **Threshold**: a directory qualifies for a module README gap when **file count ≥ 3 OR imported by ≥ 5 other source files** (default). The fan-in count comes from the Phase 3b symbol table `imports` edges; exclude test files (`*.test.*`, `*.spec.*`, `tests/`) when counting referencing files. An existing `<dir>/README.md` is never overwritten unless `--force`. Tune by editing the skill.
104
+
105
+ Record all gaps — they become Phase 3 input.
106
+
107
+ ## Phase 3 — Fill
108
+
109
+ **Skip this phase entirely when:**
110
+ - `--dry-run` was passed (print the fill plan to stdout, write nothing)
111
+ - Phase 2 found zero gaps
112
+
113
+ **Idempotency rule**: Without `--force`, re-running when no new gaps exist is a **no-op** — no files are written, no existing drafts are modified.
114
+
115
+ For each gap:
116
+ 1. Read up to 20 source files from the target directory to infer module purpose, key exports, dependencies, and configuration patterns
117
+ 2. Generate a draft document at the conventional location (see table below)
118
+ 3. **Skip if the target file already exists**, unless `--force` was passed
119
+
120
+ **Draft locations by gap type:**
121
+
122
+ | Gap Type | Draft Location |
123
+ |----------|---------------|
124
+ | Module with no README | `<dir>/README.md` |
125
+ | No `.roll/domain/` entries | `.roll/domain/context-map.md` |
126
+ | No conventions doc | `docs/CONVENTIONS.md` |
127
+ | Missing `AGENTS.md` `## Where to Look` section | `AGENTS.md` (append or create) |
128
+
129
+ **AGENTS.md Where to Look bootstrap:**
130
+
131
+ When `AGENTS.md` has no `## Where to Look` section, generate and append one:
132
+
133
+ 1. Scan which doc directories actually exist: `.roll/domain/`, `.roll/features/`, `.roll/verification/`, etc.
134
+ 2. Generate pointer lines **only for directories that actually exist** — never fabricate pointers to missing paths
135
+ 3. If `.roll/domain/context-map.md` exists, read it to extract Bounded Context names for a one-line summary
136
+ 4. Append the section to the end of `AGENTS.md` with the standard draft header
137
+ 5. **Idempotency**: if `## Where to Look` already present, do not overwrite or duplicate — skip this gap
138
+
139
+ Draft output format:
140
+
141
+ ```markdown
142
+ > **Draft** — auto-generated by roll-doc on YYYY-MM-DD. Review before treating as authoritative.
143
+
144
+ ## Where to Look
145
+ - **Domain model**: `.roll/domain/context-map.md` — Contexts: {list from context-map, or "see file"}
146
+ - **Story details**: `.roll/features/` — AC, implementation specs, dependencies
147
+ ```
148
+
149
+ Only include lines for directories that already exist in the project.
150
+
151
+ **Every generated file starts with this exact header line:**
152
+
153
+ ```
154
+ > **Draft** — auto-generated by roll-doc on YYYY-MM-DD. Review before treating as authoritative.
155
+ ```
156
+
157
+ **Minimum draft content:**
158
+
159
+ - Module README: purpose (1–2 sentences), key files with one-line descriptions, dependencies (imports from / depended on by)
160
+ - Context map: bounded contexts identified in the project, their responsibilities, relationships
161
+ - Conventions: detected patterns — ENV vars, naming conventions, repeated file structure templates
162
+
163
+ Do not fabricate details — infer only from source files actually read.
164
+
165
+ ## Phase 3b — Deep Read
166
+
167
+ Deep-read phase that builds a full project symbol table (without truncation) and auto-detects
168
+ cross-directory topics that directory-level Phase 3 alone cannot discover.
169
+
170
+ **Trigger conditions** — Phase 3b runs when either is true:
171
+ - Phase 2 found any gap (module or special gap)
172
+ - The project exhibits code characteristics that Phase 3a cannot capture:
173
+ cross-directory import chains spanning ≥ 3 directories, state enums referenced by
174
+ multiple files, external URL/endpoint calls, or CI pipeline configuration files
175
+
176
+ Pure documentation-only projects (no source code gaps, no code characteristics) skip Phase 3b.
177
+
178
+ ### Step 1 — Build Symbol Table
179
+
180
+ Read each source file through the context-feed budget (US-CTX-001), not by hard-stuffing whole
181
+ files unconditionally. The existing Phase 3 "up to 20 source files" count limit does not apply —
182
+ Phase 3b aims for a complete project symbol table — but per-file material still goes through the
183
+ feed budget: files within budget are read in full, and over-budget files are summarized/chunked
184
+ with an explicit notice (never silently truncated) so the inner agent's context window is not
185
+ blown. This replaces the previous "read every source file in full, no truncation" unbounded path.
186
+
187
+ **Exclusion directories** (same as Phase 1):
188
+
189
+ ```
190
+ node_modules/ .git/ dist/ build/ .shared/ .roll/dream/ .roll/briefs/
191
+ ```
192
+
193
+ **Symbol table fields:**
194
+
195
+ | Field | Content |
196
+ |-------|---------|
197
+ | `exports` | class / interface / type / function / const declarations, per file |
198
+ | `imports` | source file → target file mapping (dependency graph edges) |
199
+ | `enums` | enum declarations with enumerated values, per file |
200
+ | `external_urls` | `fetch(...)` / `axios` / `http.*` calls, `API_ENDPOINT` / `*_URL` / `*_HOST` constants, hardcoded `https?://` strings (exclude comments and test fixtures) |
201
+ | `configs` | CI workflow YAML files, build config paths, test framework config file paths |
202
+
203
+ **`--dry-run` behavior:** print symbol table summary counts per category (e.g. "exports: 42, imports: 156, enums: 7, external_urls: 4, configs: 3") plus top-N examples per category. Write nothing to disk.
204
+
205
+ **`--force` behavior:** unchanged — `--force` only affects draft generation (Phase 3/3b output files).
206
+ The symbol table itself is rebuilt from scratch on every run regardless of flags.
207
+
208
+ ### Step 2 — Topic Detection
209
+
210
+ Using the symbol table from Step 1, detect cross-directory topics. Each topic type has a
211
+ detection rule and a target output file. Skip any topic whose target file already exists
212
+ (unless `--force`). Skip any topic whose detection rule finds no matches.
213
+
214
+ | Topic | Detection Rule | Output |
215
+ |-------|---------------|--------|
216
+ | 数据流 / 调用链 | Entry files (`bin/`, `cmd/`, `main.*`, `index.*`) → trace import chain to leaf nodes; require ≥ 1 chain spanning ≥ 3 directories | `docs/data-flows.md` |
217
+ | 状态机 | Enums matching `*State` / `*Status` referenced by ≥ 2 source files | `docs/state-machines.md` |
218
+ | 外部集成 | `external_urls` entries from symbol table (exclude comment/test-fixture matches) | `docs/integrations.md` |
219
+ | 部署管线 | `.github/workflows/*.yml` / `.gitlab-ci.yml` / `circle.yml` / `Jenkinsfile` present, with deploy URL patterns detected | `docs/deployment.md` |
220
+ | Agent 入口 (AGENTS.md) | Project root has no `AGENTS.md` AND `src/` (or equivalent source root) has ≥ 3 subdirectories | `AGENTS.md` |
221
+ | 高引用目录 | Directory imported by ≥ 5 other source files, even if directory itself has < 3 source files | `<dir>/README.md` |
222
+
223
+ #### Data Flow / Import Chain Tracing
224
+
225
+ **Entry point selection:** start from entry files — any file matching patterns:
226
+ `bin/*`, `cmd/**/*`, `main.*` (e.g. `main.ts`, `main.py`), `index.*` (e.g. `index.ts`, `index.jsx`),
227
+ `App.*`, `server.*`. Exclude `node_modules/`, `dist/`, `build/`, test files (`*.test.*`, `*.spec.*`, `tests/`).
228
+
229
+ **Chain construction:**
230
+ 1. For each entry file, read its imports from the symbol table's `imports` field.
231
+ 2. Recursively follow each imported file to its own imports, building a directed call graph.
232
+ 3. Stop at leaf nodes — files that import nothing or whose imports all point to:
233
+ - External packages (node_modules / stdlib / third-party)
234
+ - Already-visited nodes (cycle termination)
235
+ 4. Each distinct path from an entry file to a leaf is one call chain.
236
+
237
+ **Threshold (cross-directory filter):**
238
+ A call chain is valid for inclusion only if it spans **≥ 3 distinct source directories**.
239
+ Count based on the unique parent directories of files in the chain:
240
+ `src/cli/main.ts → src/commands/build.ts → lib/utils/fs.ts` = 3 directories ✅
241
+ `src/cli/main.ts → src/cli/config.ts → lib/utils/fs.ts` = 2 directories ❌
242
+ If no chain meets the ≥ 3 directory threshold, skip generation entirely (no empty `docs/data-flows.md`).
243
+
244
+ **Output document structure** (`docs/data-flows.md`):
245
+
246
+ ```markdown
247
+ > **Draft** — auto-generated by roll-doc on YYYY-MM-DD. Review before treating as authoritative.
248
+
249
+ # Data Flows
250
+
251
+ ## Flow: {short descriptive name from entry file purpose}
252
+
253
+ **Entry point:** `{entry_file}:{line}`
254
+ **Directories spanned:** N ({comma-separated list})
255
+
256
+ ### Complete Call Chain
257
+
258
+ {entry_file}
259
+ → import {symbol} from "{file}" ({line})
260
+ → import {symbol} from "{file}" ({line})
261
+ → ... (leaf node)
262
+
263
+ ### Files Involved
264
+
265
+ | Step | File:Line | Function / Method |
266
+ |------|-----------|-------------------|
267
+ | 1 | `path/to/file:12` | `functionName` |
268
+ | 2 | `path/to/file:34` | `otherFunction` |
269
+ | ... | ... | ... |
270
+ ```
271
+
272
+ - Sort flows by number of directories spanned, descending (widest cross-cutting flow first).
273
+ - If an entry file produces multiple distinct call chains, list each one as a separate flow entry.
274
+ - `file:line` annotations must come from actual symbol table records — do not fabricate.
275
+
276
+ **Idempotency:** skip (do not overwrite) if `docs/data-flows.md` already exists, unless `--force`.
277
+
278
+ #### State Machine
279
+
280
+ **Detection rule:** enums whose name matches `*State` or `*Status` (case-insensitive)
281
+ AND that are imported/referenced by **≥ 2 distinct source files**. Only count
282
+ imports from source files — exclude test files (`*.test.*`, `*.spec.*`, `tests/`)
283
+ and declaration files (`*.d.ts`).
284
+
285
+ **Threshold:** if no enum meets the ≥ 2 cross-file reference threshold, skip
286
+ generation entirely (no empty `docs/state-machines.md`).
287
+
288
+ **Output document structure** (`docs/state-machines.md`):
289
+
290
+ ```markdown
291
+ > **Draft** — auto-generated by roll-doc on YYYY-MM-DD. Review before treating as authoritative.
292
+
293
+ # State Machines
294
+
295
+ ## State: `{EnumName}`
296
+
297
+ **Defined in:** `{file}:{line}`
298
+
299
+ ### States
300
+ {list of all enum values}
301
+
302
+ ### Referenced By
303
+
304
+ | File:Line | Context |
305
+ |-----------|---------|
306
+ | `path/to/file:12` | `function processOrder(status: OrderState)` |
307
+ | `path/to/file:34` | `if (status === OrderState.Pending)` |
308
+
309
+ ### Inferred Transitions
310
+
311
+ | From | To | Evidence |
312
+ |------|----|----------|
313
+ | `Pending` | `Processing` | `order.ts:45` — `if (status === Pending) { status = Processing }` |
314
+ | `Processing` | `Shipped` | `handler.ts:78` — assignment after `ship()` call |
315
+ ```
316
+
317
+ **Transition inference:** scan the referencing files for patterns where an enum
318
+ value is checked (`if (status === X)`, `case X:`) and the status variable is
319
+ reassigned to another enum value in the same block. Record each distinct
320
+ `{from, to, evidence file:line}` pair. Only include transitions backed by
321
+ explicit code — do not fabricate implied transitions.
322
+
323
+ **Output rules:**
324
+ - One top-level `## State:` section per qualifying enum, sorted alphabetically.
325
+ - Each enum section lists all defined values under `### States`.
326
+ - `file:line` annotations must come from actual symbol table records — do not fabricate.
327
+ - Existing `docs/state-machines.md` → skip unless `--force`.
328
+ - No qualifying enum → skip generation entirely (no empty document).
329
+
330
+ #### External Integrations
331
+
332
+ **Detection rule:** scan `external_urls` from the symbol table —
333
+ `fetch(...)` / `axios` / `http.get` (and `http.*`) calls, constants shaped like
334
+ `API_ENDPOINT` / `*_URL` / `*_HOST`, and hardcoded `https?://` strings. Exclude
335
+ matches inside comments and test fixtures (`*.test.*`, `*.spec.*`, `tests/`,
336
+ `fixtures/`).
337
+
338
+ **Threshold:** if no external integration is detected, skip generation entirely
339
+ (no empty `docs/integrations.md`).
340
+
341
+ **Output document structure** (`docs/integrations.md`):
342
+
343
+ ```markdown
344
+ > **Draft** — auto-generated by roll-doc on YYYY-MM-DD. Review before treating as authoritative.
345
+
346
+ # External Integrations
347
+
348
+ ## Integration: `{endpoint URL}`
349
+
350
+ ### Call Sites
351
+
352
+ | File:Line | Timeout | Error Handling / Fallback |
353
+ |-----------|---------|---------------------------|
354
+ | `path/to/file:12` | `timeout: 5000` | `.catch` retry fallback |
355
+ | `path/to/file:48` | — | try/catch |
356
+ ```
357
+
358
+ **Per-integration fields:**
359
+ - **endpoint URL** — the external URL / endpoint reached.
360
+ - **call file:line** — every source location calling this endpoint.
361
+ - **timeout config** — the value if the calling code carries a `timeout: N` field,
362
+ otherwise `—`.
363
+ - **error handling / fallback** — recorded when the calling code has a `.catch`
364
+ handler or a `try` / `catch` block around the call, otherwise `—`.
365
+
366
+ **Output rules:**
367
+ - The same endpoint reached from multiple sites is merged into **one** integration
368
+ section that lists **all** its call sites — never one section per call.
369
+ - One top-level `## Integration:` section per distinct endpoint, sorted alphabetically.
370
+ - `file:line` annotations must come from actual symbol table records — do not fabricate.
371
+ - Existing `docs/integrations.md` → skip unless `--force`.
372
+ - No external integration detected → skip generation entirely (no empty document).
373
+
374
+ #### Deployment Pipeline
375
+
376
+ **Detection rule:** the project has at least one CI configuration file —
377
+ `.github/workflows/*.yml` (or `*.yaml`) / `.gitlab-ci.yml` / `circle.yml` /
378
+ `.circleci/config.yml` / `Jenkinsfile` — AND a deploy URL pattern appears in the
379
+ code or CI config (vercel / netlify / cloudflare / firebase, or hostnames ending
380
+ in `*.app` / `*.dev`). Pull deploy URLs from the `configs` and `external_urls`
381
+ fields of the symbol table.
382
+
383
+ **Threshold:** if no CI configuration file is detected, skip generation entirely
384
+ (no empty `docs/deployment.md`).
385
+
386
+ **Output document structure** (`docs/deployment.md`):
387
+
388
+ ```markdown
389
+ > **Draft** — auto-generated by roll-doc on YYYY-MM-DD. Review before treating as authoritative.
390
+
391
+ # Deployment
392
+
393
+ ## Pipeline: `{ci config file}`
394
+
395
+ **CI Platform:** GitHub Actions
396
+ **Trigger events:** push (main), pull_request, release
397
+
398
+ ### Key Jobs
399
+
400
+ | Job | File:Line | Purpose |
401
+ |-----|-----------|---------|
402
+ | `test` | `.github/workflows/deploy.yml:18` | run test suite |
403
+ | `build` | `.github/workflows/deploy.yml:25` | compile artifacts |
404
+ | `deploy` | `.github/workflows/deploy.yml:33` | deploy to Vercel |
405
+
406
+ ### Deploy Targets
407
+
408
+ | URL | File:Line |
409
+ |-----|-----------|
410
+ | `https://my-app.vercel.app` | `.github/workflows/deploy.yml:14` |
411
+
412
+ ### Environment Variables
413
+
414
+ | Name | File:Line |
415
+ |------|-----------|
416
+ | `NODE_ENV` | `.github/workflows/deploy.yml:11` |
417
+ | `VERCEL_TOKEN` | `.github/workflows/deploy.yml:12` |
418
+ ```
419
+
420
+ **Per-pipeline fields:**
421
+ - **CI platform** — inferred from which config file is present (GitHub Actions /
422
+ GitLab CI / CircleCI / Jenkins).
423
+ - **trigger events** — the events that start the pipeline (`push` / `pull_request` /
424
+ `tag` / `release`), read from the CI config.
425
+ - **key jobs** — each job / stage name with its `file:line` location.
426
+ - **deploy target URL** — the deploy URL(s) matched by the detection rule.
427
+ - **environment variable names** — every env var name referenced in the CI config,
428
+ listed **without values** (never emit secret values, only names).
429
+
430
+ **Output rules:**
431
+ - One top-level `## Pipeline:` section per CI configuration file, sorted alphabetically.
432
+ - `file:line` annotations must come from actual symbol table / CI config records — do not fabricate.
433
+ - Existing `docs/deployment.md` → skip unless `--force`.
434
+ - No CI configuration detected → skip generation entirely (no empty document).
435
+
436
+ #### Agent Entrypoint (AGENTS.md)
437
+
438
+ This topic handles the **「文件不存在 → 创建」** case: when a project has no agent-facing
439
+ convention file at all, generate a complete baseline `AGENTS.md`. It is complementary to the
440
+ Phase 2 **"AGENTS.md Where to Look bootstrap"** rule, which handles the **「文件存在 → 补章节」**
441
+ case (append a missing `## Where to Look` section to an existing `AGENTS.md`). The two rules
442
+ never overlap — this one only fires when no `AGENTS.md` exists.
443
+
444
+ **Detection rule:** project root has **no** `AGENTS.md` AND the source root (`src/`, or the
445
+ equivalent — `lib/`, `app/`, `pkg/`, etc.) contains **≥ 3 subdirectories**. If `AGENTS.md`
446
+ already exists, skip entirely (do not overwrite unless `--force`). If the source root has
447
+ fewer than 3 subdirectories, skip — the project is too small to warrant a baseline doc.
448
+
449
+ **Output document structure** (`AGENTS.md`) — at minimum three required sections:
450
+
451
+ ```markdown
452
+ > **Draft** — auto-generated by roll-doc on YYYY-MM-DD. Review before treating as authoritative.
453
+
454
+ # {Project Name}
455
+
456
+ {One-sentence positioning: what this project is, inferred from README / package metadata.}
457
+
458
+ ## Where to Look
459
+
460
+ - **Domain model**: `.roll/domain/context-map.md` — Contexts: {list, or "see file"}
461
+ - **Story details**: `.roll/features/` — AC, implementation specs, dependencies
462
+ - **Doc index**: `docs/INDEX.md` — generated documentation map
463
+
464
+ ## Source Layout
465
+
466
+ | Directory | Purpose |
467
+ |-----------|---------|
468
+ | `src/parser/` | tokenize and parse input (≤ 2 lines each) |
469
+ | `src/codegen/` | emit output artifacts |
470
+ | `src/cli/` | command-line entry and option wiring |
471
+ ```
472
+
473
+ **Per-section rules:**
474
+ - **Project positioning** — a single sentence describing what the project does, inferred from
475
+ the README / package metadata; never fabricate beyond what the source supports.
476
+ - **`## Where to Look`** — pointer lines **only for directories that actually exist**
477
+ (`.roll/domain/`, `.roll/features/`, `docs/INDEX.md`, etc.); never fabricate pointers to
478
+ missing paths. If `.roll/domain/context-map.md` exists, read it for Bounded Context names.
479
+ - **Source Layout** — one row per key source subdirectory, each description **≤ 2 lines**,
480
+ inferred from the files actually read in the symbol table.
481
+
482
+ **Output rules:**
483
+ - Existing `AGENTS.md` → skip unless `--force` (never overwrite a human-authored file).
484
+ - Source root with < 3 subdirectories → skip generation entirely (no empty `AGENTS.md`).
485
+ - All three sections must be present in the generated file.
486
+
487
+ #### High Fan-in Directory (README)
488
+
489
+ This topic complements the Phase 2 file-count threshold. A directory may hold only one or two
490
+ source files yet be imported across the whole codebase (shared utils, a single-file core
491
+ module). The file-count rule (≥ 3 files) alone skips such hot paths, so high fan-in widens the
492
+ threshold to **「文件数 ≥ 3 OR 被 ≥ 5 个文件引用」**.
493
+
494
+ **Detection rule:** using the symbol table's `imports` edges, count the **distinct source files
495
+ that import any file in the directory**. If that count is **≥ 5**, the directory qualifies for a
496
+ `<dir>/README.md` gap, **even when it contains < 3 source files**. Only count referencing files
497
+ that are source files — exclude test files (`*.test.*`, `*.spec.*`, `tests/`) and files inside
498
+ the directory itself. This rule operates **in addition to** the Phase 2 count ≥ 3 rule, never
499
+ replacing it: directories meeting either condition get a README.
500
+
501
+ **Output rules:**
502
+ - Target file is `<dir>/README.md`, generated with the same Module README content as Phase 3
503
+ (purpose, key files, dependencies).
504
+ - Existing `<dir>/README.md` → skip unless `--force` (never overwrite).
505
+ - Directory imported by < 5 source files **and** holding < 3 source files → skip (no gap).
506
+ - A directory already qualifying under the count ≥ 3 rule is not double-counted — one README.
507
+
508
+ ### Step 3 — Source Annotations
509
+
510
+ Every topic document generated in Step 2 must cite `file:line` for each claim (function call,
511
+ endpoint URL, state transition, CI job, import path). Annotations must come from actual
512
+ symbol table records — do not fabricate line numbers. Follows the same "Do not fabricate"
513
+ rule as Phase 3.
514
+
515
+ **Mandatory `file:line` column** — each topic document's source-reference tables MUST carry a
516
+ dedicated `file:line` column so the reader can jump straight to the code:
517
+ - 「涉及文件」/ Files Involved table → one `file:line` per row.
518
+ - 「引用文件」/ Referenced By table → one `file:line` per referencing site.
519
+ - 「调用链」/ Complete Call Chain table → one `file:line` per hop.
520
+
521
+ Do **not** fabricate a `file:line` value: every annotation MUST come from an actual symbol
522
+ table record (the same "Do not fabricate" rule as above). If the symbol table has no line for
523
+ a claim, omit the row rather than invent a location.
524
+
525
+ ---
526
+
527
+ ## Phase 4 — Report
528
+
529
+ After all phases complete, output a summary:
530
+
531
+ ```
532
+ 📚 roll-doc complete
533
+
534
+ Phase 1 — Index
535
+ N docs scanned, docs/INDEX.md updated
536
+ Categories: guide(N) domain(N) convention(N) module(N) stray(N)
537
+
538
+ Phase 2 — Gaps
539
+ N undocumented module directories found
540
+ N special gaps (domain map / conventions)
541
+
542
+ Phase 3 — Fill
543
+ N drafts generated: [list of paths]
544
+ N skipped (already exist; use --force to regenerate)
545
+
546
+ Phase 3b — Deep Read
547
+ Symbol table: exports(N) imports(N) enums(N) external_urls(N) configs(N)
548
+ N topic documents generated:
549
+ - docs/dataflow.md (data-flow) source entries: N
550
+ - docs/state-machines.md (state-machine) source entries: N
551
+ - docs/integrations.md (external-integration) source entries: N
552
+ N topics skipped (no matches or already exist; use --force to regenerate)
553
+
554
+ 📋 Review priority (largest / most active modules first):
555
+ 1. src/commands/README.md — 8 source files
556
+ 2. docs/CONVENTIONS.md — 6 patterns detected
557
+ ```
558
+
559
+ Each generated topic document is listed with its **path**, **type**, and **来源条目数 /
560
+ source entries** (how many symbol-table records back the document). When Phase 3b produced no
561
+ subject-level documents, print exactly one line and do **not** error:
562
+
563
+ ```
564
+ Phase 3b: no subject-level drafts generated
565
+ ```
566
+
567
+ If `--dry-run`, the `Phase 3b — Deep Read` section is shown the same way but every generated
568
+ line is tagged `(plan)` — matching Phase 3's dry-run convention (nothing is written):
569
+
570
+ ```
571
+ Phase 3b — Deep Read (plan)
572
+ N topic documents would be generated:
573
+ - docs/dataflow.md (data-flow) source entries: N (plan)
574
+ ```
575
+
576
+ If no gaps were found:
577
+
578
+ ```
579
+ ✅ roll-doc: no gaps found. docs/INDEX.md updated.
580
+ ```
581
+
582
+ If `--dry-run`:
583
+
584
+ ```
585
+ 🔍 roll-doc --dry-run: N drafts would be generated (nothing written).
586
+ ```
587
+
588
+ ## Rules
589
+
590
+ - Never modify existing documentation files — only generate new drafts
591
+ - `docs/INDEX.md` is the only existing file that may be overwritten (derived artifact)
592
+ - Draft files are never committed by this skill — human reviews and commits them
593
+ - Works on any project; always read project structure before acting
594
+ - Do not fabricate module details — infer only from source files actually read
@@ -2,11 +2,15 @@
2
2
  name: roll-doctor
3
3
  license: MIT
4
4
  allowed-tools: "Read, Bash, Edit"
5
- description: "Diagnose Roll toolchain health. Checks skill files, YAML frontmatter, symlinks, conventions sync, template integrity, and config validity."
5
+ description: "Load when diagnosing Roll toolchain health, conventions sync, skill file health, templates, symlinks, config validity, or installation integrity."
6
6
  ---
7
-
8
7
  # Roll Doctor
9
8
 
9
+ ## Gotchas
10
+
11
+ - Doctor diagnoses toolchain and convention health; it should fail loud on broken contracts rather than hiding drift.
12
+ - Skill health checks belong here only as diagnostics; changing skill content still happens in roll-skills.
13
+
10
14
  诊断 Roll 工具链健康状态。快速定位 skill 不工作、convention 不同步、symlink 断裂等问题。
11
15
 
12
16
  ## When to Use
@@ -50,6 +54,21 @@ Check:
50
54
  - No duplicate `name` values across skills
51
55
  - File is readable markdown
52
56
 
57
+ When diagnosing a roll-skills checkout, run the first-class skill audit:
58
+
59
+ ```bash
60
+ node scripts/audit-skills.mjs
61
+ node scripts/audit-skills.mjs --json
62
+ node scripts/audit-skills.mjs --strict
63
+ ```
64
+
65
+ Check:
66
+ - Every description starts with `Load when...` and stays at 50 words or fewer
67
+ - Every skill has positive and negative route cases in `route-cases/skills.json`
68
+ - Every skill has Gotchas / Known Failure Modes coverage
69
+ - Hub/spoke integrity has no missing or unreferenced `references/`, `assets/`, or `scripts/` files
70
+ - Oversized hubs either split below 250 lines or carry an explicit reviewed waiver
71
+
53
72
  ### 3. Symlinks
54
73
 
55
74
  ```bash