@seanyao/roll 3.620.1 → 3.624.1

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 (67) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/roll.mjs +4563 -3369
  3. package/package.json +1 -1
  4. package/lib/__pycache__/changelog_audit.cpython-314.pyc +0 -0
  5. package/lib/__pycache__/github_sync.cpython-314.pyc +0 -0
  6. package/lib/__pycache__/loop-fmt.cpython-314.pyc +0 -0
  7. package/lib/__pycache__/loop_result_eval.cpython-314.pyc +0 -0
  8. package/lib/__pycache__/loop_unstick.cpython-314.pyc +0 -0
  9. package/lib/__pycache__/model_prices.cpython-314.pyc +0 -0
  10. package/lib/__pycache__/prices_fetcher.cpython-314.pyc +0 -0
  11. package/lib/__pycache__/roll-home.cpython-314.pyc +0 -0
  12. package/lib/__pycache__/roll-loop-status.cpython-314.pyc +0 -0
  13. package/lib/__pycache__/roll_git.cpython-314.pyc +0 -0
  14. package/lib/__pycache__/roll_render.cpython-314.pyc +0 -0
  15. package/lib/__pycache__/slides-render.cpython-314.pyc +0 -0
  16. package/lib/agent_usage/__pycache__/__init__.cpython-314.pyc +0 -0
  17. package/lib/agent_usage/__pycache__/gemini.cpython-314.pyc +0 -0
  18. package/lib/agent_usage/__pycache__/kimi.cpython-314.pyc +0 -0
  19. package/lib/agent_usage/__pycache__/openai.cpython-314.pyc +0 -0
  20. package/lib/agent_usage/__pycache__/pi.cpython-314.pyc +0 -0
  21. package/lib/agent_usage/__pycache__/pi_emit.cpython-314.pyc +0 -0
  22. package/lib/agent_usage/__pycache__/qwen.cpython-314.pyc +0 -0
  23. package/skills/README.md +0 -64
  24. package/skills/docs/skill-authoring.md +0 -74
  25. package/skills/reports/skill-audit-summary.md +0 -53
  26. package/skills/roll-.changelog/SKILL.md +0 -47
  27. package/skills/roll-.changelog/references/full-contract.md +0 -462
  28. package/skills/roll-.clarify/SKILL.md +0 -64
  29. package/skills/roll-.dream/SKILL.md +0 -47
  30. package/skills/roll-.dream/references/full-contract.md +0 -365
  31. package/skills/roll-.echo/SKILL.md +0 -118
  32. package/skills/roll-.qa/SKILL.md +0 -47
  33. package/skills/roll-.qa/references/full-contract.md +0 -256
  34. package/skills/roll-.review/SKILL.md +0 -148
  35. package/skills/roll-build/SKILL.md +0 -49
  36. package/skills/roll-build/references/full-contract.md +0 -968
  37. package/skills/roll-debug/SKILL.md +0 -48
  38. package/skills/roll-debug/assets/injectable-bb.js +0 -263
  39. package/skills/roll-debug/references/full-contract.md +0 -607
  40. package/skills/roll-design/SKILL.md +0 -52
  41. package/skills/roll-design/references/engineering-checklist.md +0 -298
  42. package/skills/roll-design/references/full-contract.md +0 -940
  43. package/skills/roll-doc-audit/SKILL.md +0 -51
  44. package/skills/roll-doc-audit/references/full-contract.md +0 -796
  45. package/skills/roll-doctor/SKILL.md +0 -211
  46. package/skills/roll-fix/SKILL.md +0 -49
  47. package/skills/roll-fix/references/full-contract.md +0 -672
  48. package/skills/roll-idea/SKILL.md +0 -62
  49. package/skills/roll-loop/SKILL.md +0 -50
  50. package/skills/roll-loop/references/full-contract.md +0 -534
  51. package/skills/roll-notes/SKILL.md +0 -107
  52. package/skills/roll-onboard/SKILL.md +0 -238
  53. package/skills/roll-peer/SKILL.md +0 -47
  54. package/skills/roll-peer/references/full-contract.md +0 -323
  55. package/skills/roll-propose/SKILL.md +0 -155
  56. package/skills/roll-review-pr/SKILL.md +0 -62
  57. package/skills/roll-spar/SKILL.md +0 -47
  58. package/skills/roll-spar/references/full-contract.md +0 -288
  59. package/skills/route-cases/skills.json +0 -216
  60. package/skills/scripts/audit-skills.mjs +0 -272
  61. package/skills/scripts/test-audit-skills.mjs +0 -39
  62. package/skills/tests/fixtures/skill-audit/block-skill/SKILL.md +0 -12
  63. package/skills/tests/fixtures/skill-audit/minimal-skill/SKILL.md +0 -8
  64. package/skills/tests/fixtures/skill-audit/quoted-skill/SKILL.md +0 -10
  65. package/skills/tests/fixtures/skill-audit/route-cases.json +0 -21
  66. package/skills/tests/fixtures/skill-audit/spoke-skill/SKILL.md +0 -12
  67. package/skills/tests/fixtures/skill-audit/spoke-skill/references/runbook.md +0 -3
@@ -1,796 +0,0 @@
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-audit
8
-
9
- Documentation/product consistency audit plus legacy documentation automation (and deep-read Phase 3b): consistency audit (Phase 0 — shipped surfaces vs docs) → scan docs, user guidance, site pages, CLI help, and code surfaces → 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
- - README, guides, site pages, CLI help, or docs may be drifting from implemented behavior
18
- - `roll-.dream` Scan 6 flagged undocumented modules (REFACTOR entry referencing roll-doc-audit)
19
- - You want a complete picture of what's documented and what isn't
20
-
21
- ## When Not to Use
22
-
23
- - The project has up-to-date, maintained docs — no need to rebuild the index
24
- - You need authoritative documentation reviewed and approved (drafts only; human reviews and commits)
25
- - You want to write a specific known doc from scratch — write it directly
26
-
27
- ## Invocation
28
-
29
- ```
30
- $roll-doc-audit # Full consistency/inventory run
31
- $roll-doc-audit --dry-run # Phases 1–2 only; print Phase 3 plan without writing any files
32
- $roll-doc-audit --force # Re-generate drafts even for existing files
33
- ```
34
-
35
- ## Phase 0 — Consistency Audit
36
-
37
- Run this phase **first**, before the inventory phases (1–3b). The inventory phases ask
38
- *"what is undocumented?"*; Phase 0 asks the sharper release-time question: *"does every shipped
39
- user-facing surface have a doc, and does that doc still tell the truth?"* It is the
40
- judgment-heavy pass — enumerate the real surfaces, compare them against the docs, and draft the
41
- drift fixes.
42
-
43
- **Skill vs. gate.** This skill is the **investigator + drafter**: a human (or agent) runs it to
44
- find drift and write the fix. The *deterministic, enumerable* subset of these same checks is
45
- **also** enforced inside the `roll release` consistency gate (`release-consistency.ts`), so a
46
- drift cannot silently ship even when nobody runs this skill. The gate is the **floor** (it
47
- blocks the release on the mechanical mismatches it can prove); this skill is the **ceiling** (it
48
- also catches the judgment cases — a description that is technically present but stale, a doc that
49
- contradicts behavior — that a mechanical check cannot decide). Run the skill to investigate and
50
- fix; trust the gate to keep the floor from dropping.
51
-
52
- **Scope:** Phase 0 reads only — it never writes during the audit itself. Its output is the
53
- **Consistency Report** (template at the end of this phase) plus a list of drafted fixes the
54
- operator reviews and applies. As with every other phase, do not fabricate behavior: every
55
- "Accurate?" verdict must cite the source (help text, code path, or guide line) it was checked
56
- against.
57
-
58
- This phase has three check-classes. Run all three.
59
-
60
- ### 0.1 — Shipped-surface coverage
61
-
62
- Enumerate every user-facing surface the product ships, then assert each one is **documented**
63
- AND **described accurately** (the doc's description matches actual behavior, not a stale copy).
64
-
65
- **Surface 1 — CLI commands.**
66
-
67
- Gather the evidence:
68
-
69
- ```
70
- # every top-level command
71
- roll --help # or: node dist/roll.mjs --help
72
-
73
- # every subcommand of a command that has subcommands
74
- roll <command> --help # e.g. roll loop --help, roll agent --help
75
- ```
76
-
77
- Parse the command/subcommand list and each one-line description out of the help output. For each
78
- command, locate its documentation in `guide/{en,zh}/*.md` and/or `README.md` (grep the command
79
- name).
80
-
81
- - **Pass:** the command appears in at least one guide page or `README.md`, AND the documented
82
- description does not contradict the `--help` description / actual behavior.
83
- - **Fail (undocumented):** a command exists in `--help` but no guide/README mentions it.
84
- - **Fail (stale):** a command is documented, but the doc's description disagrees with `--help`
85
- or with the implemented behavior (e.g. renamed flag, removed option, changed default).
86
-
87
- Draft the fix: for an undocumented command, draft the missing guide section (purpose, synopsis,
88
- options) from the `--help` text and the command's source. For a stale description, draft the
89
- corrected sentence and cite the `--help` line or code path that proves the new truth.
90
-
91
- **Surface 2 — Web-console pages / machine-global breadcrumb entries.**
92
-
93
- The product's console exposes a fixed set of machine-global pages (e.g. **Agents · Skills ·
94
- Tools · Conventions · About**). Each shipped page must be reflected in the site copy
95
- (`site/roll-data.js`) and in the guides.
96
-
97
- Gather the evidence:
98
-
99
- ```
100
- # the breadcrumb / nav set as the site renders it
101
- grep -nE "Agents|Skills|Tools|Conventions|About" site/roll-data.js
102
-
103
- # the guide pages that should describe those surfaces
104
- ls guide/en guide/zh
105
- ```
106
-
107
- - **Pass:** every shipped console page is present in `site/roll-data.js` and has a corresponding
108
- guide treatment.
109
- - **Fail:** a console page ships but `site/roll-data.js` (or the guide) never reflects it, or the
110
- site lists a page that no longer exists.
111
-
112
- Draft the fix: add/correct the `site/roll-data.js` entry and draft the guide paragraph for the
113
- missing page; cite the page's source.
114
-
115
- **Verdict for 0.1:** flag *any* shipped surface with **no doc**, or **a doc whose description
116
- contradicts the implementation**. Each flag becomes a row in the Consistency Report.
117
-
118
- ### 0.2 — Changelog coverage of the release delta
119
-
120
- Assert that every user-facing card merged since the last release is reflected in `CHANGELOG.md`.
121
-
122
- Gather the evidence:
123
-
124
- ```
125
- # latest release tag (roll tags look like v2026.601.4)
126
- LATEST=$(git describe --tags --abbrev=0 --match 'v*')
127
-
128
- # commits merged since that tag
129
- git log "$LATEST"..HEAD --oneline
130
-
131
- # card ids in the delta (US-/FIX-/REFACTOR-)
132
- git log "$LATEST"..HEAD --format='%s%n%b' | grep -oE '(US|FIX|REFACTOR)-[0-9]+' | sort -u
133
- ```
134
-
135
- For each card id in the delta, decide whether it is **user-facing** (changes CLI behavior,
136
- output, flags, console pages, or documented workflow) — purely internal refactors that change no
137
- surface are out of scope. Then:
138
-
139
- - **Pass:** the user-facing card has a `CHANGELOG.md` entry **or** its spec carries an explicit
140
- `changelog_exempt:` marker (read the card's spec under `.roll/features/` to check).
141
- - **Fail:** a user-facing delta card has neither a `CHANGELOG.md` entry nor a `changelog_exempt:`
142
- marker — it would ship undocumented.
143
-
144
- Check changelog presence:
145
-
146
- ```
147
- grep -nE '(US|FIX|REFACTOR)-[0-9]+' CHANGELOG.md
148
- ```
149
-
150
- Draft the fix: for each missing user-facing card, draft a plain-language `CHANGELOG.md` line
151
- (what changed / what the user can now do) from the card's spec and merged diff — no internal
152
- jargon. If the card is genuinely not user-facing, note that it needs a `changelog_exempt:`
153
- marker rather than a changelog line, and say why.
154
-
155
- **Verdict for 0.2:** report every user-facing delta card that would ship undocumented.
156
-
157
- ### 0.3 — Site-copy ↔ generated-console consistency
158
-
159
- Assert that `site/roll-data.js` matches reality on three axes. This is the class where a new
160
- guide page or console page ships but the site index is never updated to link it.
161
-
162
- Gather the evidence:
163
-
164
- ```
165
- # every guide file that exists on disk
166
- ls guide/en guide/zh
167
-
168
- # the guide nav / page list the site actually exposes
169
- grep -nE "guide|slug|nav|page" site/roll-data.js
170
-
171
- # the machine-global breadcrumb description and the skill tiles
172
- grep -nE "Agents|Skills|Tools|Conventions|About|skill" site/roll-data.js
173
- ```
174
-
175
- Then check each axis:
176
-
177
- 1. **Guide reachability** — every `guide/<lang>/*.md` file on disk is reachable from the site
178
- guide nav defined in `site/roll-data.js`.
179
- - **Fail:** a guide file exists but is not linked from the nav (orphaned page), or the nav
180
- links a guide slug that has no file (dead link).
181
- 2. **Breadcrumb completeness** — the machine-global breadcrumb description in `site/roll-data.js`
182
- lists the **real** set of machine pages (the same set verified in 0.1, Surface 2).
183
- - **Fail:** the breadcrumb omits a shipped page or lists a removed one.
184
- 3. **Skill-tile correctness** — the skill tiles in `site/roll-data.js` match the actual skill
185
- set (the `roll-*` skill directories that ship).
186
- - **Fail:** a shipped skill has no tile, or a tile points to a retired skill.
187
-
188
- Draft the fix: add the missing nav entry / breadcrumb item / skill tile to `site/roll-data.js`,
189
- or remove the stale one; cite the on-disk file (or its absence) that proves the drift.
190
-
191
- **Verdict for 0.3:** flag every stale or missing `site/roll-data.js` entry.
192
-
193
- ### Consistency Report
194
-
195
- After running 0.1–0.3, emit one report. One row per surface checked; group by check-class. The
196
- `Fix` column states the drafted correction (and, for an undocumented surface, the path of the
197
- draft).
198
-
199
- ```markdown
200
- > roll-doc-audit — Consistency Report (YYYY-MM-DD)
201
- > Phase 0 read-only audit. Floor enforced by `roll release` consistency gate (release-consistency.ts).
202
-
203
- ## 0.1 Shipped-surface coverage
204
-
205
- | Surface | Documented? | Accurate? | Drift | Fix |
206
- |---------|-------------|-----------|-------|-----|
207
- | `roll loop` (CLI) | ✅ guide/en/loop.md | ❌ | guide says `--once`, help says `--single` | draft: rename flag in loop.md:42, cite `roll loop --help` |
208
- | `roll agent swap` (CLI) | ❌ | — | command ships, no guide/README mention | draft guide/en/agents.md §swap from `roll agent swap --help` |
209
- | Console: Tools page | ✅ guide | ❌ site | page ships, missing from site/roll-data.js | draft: add Tools entry to site/roll-data.js |
210
-
211
- ## 0.2 Changelog coverage of the release delta
212
-
213
- | Card | User-facing? | In CHANGELOG / exempt? | Drift | Fix |
214
- |------|--------------|------------------------|-------|-----|
215
- | US-AGENT-041 | yes | ❌ | merged since v2026.601.4, no entry | draft CHANGELOG line from spec |
216
- | REFACTOR-118 | no | — | internal only | mark `changelog_exempt:` in spec |
217
-
218
- ## 0.3 Site-copy ↔ generated-console consistency
219
-
220
- | Surface | Documented? | Accurate? | Drift | Fix |
221
- |---------|-------------|-----------|-------|-----|
222
- | guide/zh/consistency.md | ✅ on disk | ❌ nav | file exists, not linked in site nav | draft: add nav entry to site/roll-data.js |
223
- | Skill tile: roll-doc-audit | ✅ | ❌ | tile still labeled `roll-doc` | draft: update tile id in site/roll-data.js |
224
-
225
- ## Summary
226
-
227
- - Surfaces checked: N (CLI N / console N / changelog cards N / site entries N)
228
- - Drift found: N (undocumented N / stale N / unlinked N)
229
- - Drafted fixes: N — review and apply, then re-run.
230
- ```
231
-
232
- A clean run prints the report with no drift rows and the summary line `Drift found: 0`.
233
-
234
- ---
235
-
236
- ## Phase 1 — Scan & Index
237
-
238
- Scan the project root for all `*.md` files and known convention files.
239
-
240
- **Exclusions — never scan these directories:**
241
-
242
- ```
243
- node_modules/ .git/ dist/ build/ .shared/ .roll/dream/ .roll/briefs/
244
- ```
245
-
246
- **Convention files — detect by filename anywhere in the tree:**
247
-
248
- ```
249
- AGENTS.md CLAUDE.md GEMINI.md CONVENTIONS.md CONTRIBUTING.md
250
- ARCHITECTURE.md ADR-*.md
251
- ```
252
-
253
- **Classification rules:**
254
-
255
- | Category | Criteria |
256
- |----------|----------|
257
- | `guide` | Path under `guide/` |
258
- | `domain` | Path under `.roll/domain/` |
259
- | `convention` | Filename matches convention markers list above |
260
- | `module` | File is `<dir>/README.md` for a source directory |
261
- | `stray` | None of the above (top-level, unorganized, or orphaned) |
262
-
263
- **Output — produce/update `docs/INDEX.md`:**
264
-
265
- ```markdown
266
- # Documentation Index
267
-
268
- > Auto-generated by roll-doc-audit on YYYY-MM-DD. Edit individual docs, not this file.
269
-
270
- ## Index
271
-
272
- | Path | Title | Category | Last Modified |
273
- |------|-------|----------|---------------|
274
- | guide/en/loop.md | Loop User Guide | guide | 2026-05-01 |
275
- | AGENTS.md | Agent Conventions | convention | 2026-04-28 |
276
-
277
- ## Coverage Summary
278
-
279
- - Total docs indexed: N
280
- - By category: guide (N) / domain (N) / convention (N) / module (N) / stray (N)
281
-
282
- ## Gap Report
283
-
284
- Directories with ≥3 source files and no linked documentation:
285
-
286
- | Directory | Source Files | Missing Doc |
287
- |-----------|-------------|-------------|
288
- | src/commands/ | 8 | README.md |
289
- ```
290
-
291
- `docs/INDEX.md` is always overwritten on each run — it is a derived artifact, not authoritative content.
292
-
293
- ## Phase 2 — Gap Analysis
294
-
295
- Walk every directory (applying Phase 1 exclusions):
296
-
297
- 1. Count non-hidden, non-`.md` source files directly in the directory
298
- 2. If count ≥ 3 AND no `README.md` in that directory AND no `docs/INDEX.md` entry links to it → **module gap**
299
- 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.
300
-
301
- **Special gaps (checked once per project):**
302
- - No `.roll/domain/` directory or empty → gap: `.roll/domain/context-map.md`
303
- - No `CONVENTIONS.md` or `docs/CONVENTIONS.md` exists → gap: `docs/CONVENTIONS.md`
304
-
305
- **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.
306
-
307
- Record all gaps — they become Phase 3 input.
308
-
309
- ## Phase 3 — Fill
310
-
311
- **Skip this phase entirely when:**
312
- - `--dry-run` was passed (print the fill plan to stdout, write nothing)
313
- - Phase 2 found zero gaps
314
-
315
- **Idempotency rule**: Without `--force`, re-running when no new gaps exist is a **no-op** — no files are written, no existing drafts are modified.
316
-
317
- For each gap:
318
- 1. Read up to 20 source files from the target directory to infer module purpose, key exports, dependencies, and configuration patterns
319
- 2. Generate a draft document at the conventional location (see table below)
320
- 3. **Skip if the target file already exists**, unless `--force` was passed
321
-
322
- **Draft locations by gap type:**
323
-
324
- | Gap Type | Draft Location |
325
- |----------|---------------|
326
- | Module with no README | `<dir>/README.md` |
327
- | No `.roll/domain/` entries | `.roll/domain/context-map.md` |
328
- | No conventions doc | `docs/CONVENTIONS.md` |
329
- | Missing `AGENTS.md` `## Where to Look` section | `AGENTS.md` (append or create) |
330
-
331
- **AGENTS.md Where to Look bootstrap:**
332
-
333
- When `AGENTS.md` has no `## Where to Look` section, generate and append one:
334
-
335
- 1. Scan which doc directories actually exist: `.roll/domain/`, `.roll/features/`, `.roll/verification/`, etc.
336
- 2. Generate pointer lines **only for directories that actually exist** — never fabricate pointers to missing paths
337
- 3. If `.roll/domain/context-map.md` exists, read it to extract Bounded Context names for a one-line summary
338
- 4. Append the section to the end of `AGENTS.md` with the standard draft header
339
- 5. **Idempotency**: if `## Where to Look` already present, do not overwrite or duplicate — skip this gap
340
-
341
- Draft output format:
342
-
343
- ```markdown
344
- > **Draft** — auto-generated by roll-doc-audit on YYYY-MM-DD. Review before treating as authoritative.
345
-
346
- ## Where to Look
347
- - **Domain model**: `.roll/domain/context-map.md` — Contexts: {list from context-map, or "see file"}
348
- - **Story details**: `.roll/features/` — AC, implementation specs, dependencies
349
- ```
350
-
351
- Only include lines for directories that already exist in the project.
352
-
353
- **Every generated file starts with this exact header line:**
354
-
355
- ```
356
- > **Draft** — auto-generated by roll-doc-audit on YYYY-MM-DD. Review before treating as authoritative.
357
- ```
358
-
359
- **Minimum draft content:**
360
-
361
- - Module README: purpose (1–2 sentences), key files with one-line descriptions, dependencies (imports from / depended on by)
362
- - Context map: bounded contexts identified in the project, their responsibilities, relationships
363
- - Conventions: detected patterns — ENV vars, naming conventions, repeated file structure templates
364
-
365
- Do not fabricate details — infer only from source files actually read.
366
-
367
- ## Phase 3b — Deep Read
368
-
369
- Deep-read phase that builds a full project symbol table (without truncation) and auto-detects
370
- cross-directory topics that directory-level Phase 3 alone cannot discover.
371
-
372
- **Trigger conditions** — Phase 3b runs when either is true:
373
- - Phase 2 found any gap (module or special gap)
374
- - The project exhibits code characteristics that Phase 3a cannot capture:
375
- cross-directory import chains spanning ≥ 3 directories, state enums referenced by
376
- multiple files, external URL/endpoint calls, or CI pipeline configuration files
377
-
378
- Pure documentation-only projects (no source code gaps, no code characteristics) skip Phase 3b.
379
-
380
- ### Step 1 — Build Symbol Table
381
-
382
- Read each source file through the context-feed budget (US-CTX-001), not by hard-stuffing whole
383
- files unconditionally. The existing Phase 3 "up to 20 source files" count limit does not apply —
384
- Phase 3b aims for a complete project symbol table — but per-file material still goes through the
385
- feed budget: files within budget are read in full, and over-budget files are summarized/chunked
386
- with an explicit notice (never silently truncated) so the inner agent's context window is not
387
- blown. This replaces the previous "read every source file in full, no truncation" unbounded path.
388
-
389
- **Exclusion directories** (same as Phase 1):
390
-
391
- ```
392
- node_modules/ .git/ dist/ build/ .shared/ .roll/dream/ .roll/briefs/
393
- ```
394
-
395
- **Symbol table fields:**
396
-
397
- | Field | Content |
398
- |-------|---------|
399
- | `exports` | class / interface / type / function / const declarations, per file |
400
- | `imports` | source file → target file mapping (dependency graph edges) |
401
- | `enums` | enum declarations with enumerated values, per file |
402
- | `external_urls` | `fetch(...)` / `axios` / `http.*` calls, `API_ENDPOINT` / `*_URL` / `*_HOST` constants, hardcoded `https?://` strings (exclude comments and test fixtures) |
403
- | `configs` | CI workflow YAML files, build config paths, test framework config file paths |
404
-
405
- **`--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.
406
-
407
- **`--force` behavior:** unchanged — `--force` only affects draft generation (Phase 3/3b output files).
408
- The symbol table itself is rebuilt from scratch on every run regardless of flags.
409
-
410
- ### Step 2 — Topic Detection
411
-
412
- Using the symbol table from Step 1, detect cross-directory topics. Each topic type has a
413
- detection rule and a target output file. Skip any topic whose target file already exists
414
- (unless `--force`). Skip any topic whose detection rule finds no matches.
415
-
416
- | Topic | Detection Rule | Output |
417
- |-------|---------------|--------|
418
- | 数据流 / 调用链 | Entry files (`bin/`, `cmd/`, `main.*`, `index.*`) → trace import chain to leaf nodes; require ≥ 1 chain spanning ≥ 3 directories | `docs/data-flows.md` |
419
- | 状态机 | Enums matching `*State` / `*Status` referenced by ≥ 2 source files | `docs/state-machines.md` |
420
- | 外部集成 | `external_urls` entries from symbol table (exclude comment/test-fixture matches) | `docs/integrations.md` |
421
- | 部署管线 | `.github/workflows/*.yml` / `.gitlab-ci.yml` / `circle.yml` / `Jenkinsfile` present, with deploy URL patterns detected | `docs/deployment.md` |
422
- | Agent 入口 (AGENTS.md) | Project root has no `AGENTS.md` AND `src/` (or equivalent source root) has ≥ 3 subdirectories | `AGENTS.md` |
423
- | 高引用目录 | Directory imported by ≥ 5 other source files, even if directory itself has < 3 source files | `<dir>/README.md` |
424
-
425
- #### Data Flow / Import Chain Tracing
426
-
427
- **Entry point selection:** start from entry files — any file matching patterns:
428
- `bin/*`, `cmd/**/*`, `main.*` (e.g. `main.ts`, `main.py`), `index.*` (e.g. `index.ts`, `index.jsx`),
429
- `App.*`, `server.*`. Exclude `node_modules/`, `dist/`, `build/`, test files (`*.test.*`, `*.spec.*`, `tests/`).
430
-
431
- **Chain construction:**
432
- 1. For each entry file, read its imports from the symbol table's `imports` field.
433
- 2. Recursively follow each imported file to its own imports, building a directed call graph.
434
- 3. Stop at leaf nodes — files that import nothing or whose imports all point to:
435
- - External packages (node_modules / stdlib / third-party)
436
- - Already-visited nodes (cycle termination)
437
- 4. Each distinct path from an entry file to a leaf is one call chain.
438
-
439
- **Threshold (cross-directory filter):**
440
- A call chain is valid for inclusion only if it spans **≥ 3 distinct source directories**.
441
- Count based on the unique parent directories of files in the chain:
442
- `src/cli/main.ts → src/commands/build.ts → lib/utils/fs.ts` = 3 directories ✅
443
- `src/cli/main.ts → src/cli/config.ts → lib/utils/fs.ts` = 2 directories ❌
444
- If no chain meets the ≥ 3 directory threshold, skip generation entirely (no empty `docs/data-flows.md`).
445
-
446
- **Output document structure** (`docs/data-flows.md`):
447
-
448
- ```markdown
449
- > **Draft** — auto-generated by roll-doc-audit on YYYY-MM-DD. Review before treating as authoritative.
450
-
451
- # Data Flows
452
-
453
- ## Flow: {short descriptive name from entry file purpose}
454
-
455
- **Entry point:** `{entry_file}:{line}`
456
- **Directories spanned:** N ({comma-separated list})
457
-
458
- ### Complete Call Chain
459
-
460
- {entry_file}
461
- → import {symbol} from "{file}" ({line})
462
- → import {symbol} from "{file}" ({line})
463
- → ... (leaf node)
464
-
465
- ### Files Involved
466
-
467
- | Step | File:Line | Function / Method |
468
- |------|-----------|-------------------|
469
- | 1 | `path/to/file:12` | `functionName` |
470
- | 2 | `path/to/file:34` | `otherFunction` |
471
- | ... | ... | ... |
472
- ```
473
-
474
- - Sort flows by number of directories spanned, descending (widest cross-cutting flow first).
475
- - If an entry file produces multiple distinct call chains, list each one as a separate flow entry.
476
- - `file:line` annotations must come from actual symbol table records — do not fabricate.
477
-
478
- **Idempotency:** skip (do not overwrite) if `docs/data-flows.md` already exists, unless `--force`.
479
-
480
- #### State Machine
481
-
482
- **Detection rule:** enums whose name matches `*State` or `*Status` (case-insensitive)
483
- AND that are imported/referenced by **≥ 2 distinct source files**. Only count
484
- imports from source files — exclude test files (`*.test.*`, `*.spec.*`, `tests/`)
485
- and declaration files (`*.d.ts`).
486
-
487
- **Threshold:** if no enum meets the ≥ 2 cross-file reference threshold, skip
488
- generation entirely (no empty `docs/state-machines.md`).
489
-
490
- **Output document structure** (`docs/state-machines.md`):
491
-
492
- ```markdown
493
- > **Draft** — auto-generated by roll-doc-audit on YYYY-MM-DD. Review before treating as authoritative.
494
-
495
- # State Machines
496
-
497
- ## State: `{EnumName}`
498
-
499
- **Defined in:** `{file}:{line}`
500
-
501
- ### States
502
- {list of all enum values}
503
-
504
- ### Referenced By
505
-
506
- | File:Line | Context |
507
- |-----------|---------|
508
- | `path/to/file:12` | `function processOrder(status: OrderState)` |
509
- | `path/to/file:34` | `if (status === OrderState.Pending)` |
510
-
511
- ### Inferred Transitions
512
-
513
- | From | To | Evidence |
514
- |------|----|----------|
515
- | `Pending` | `Processing` | `order.ts:45` — `if (status === Pending) { status = Processing }` |
516
- | `Processing` | `Shipped` | `handler.ts:78` — assignment after `ship()` call |
517
- ```
518
-
519
- **Transition inference:** scan the referencing files for patterns where an enum
520
- value is checked (`if (status === X)`, `case X:`) and the status variable is
521
- reassigned to another enum value in the same block. Record each distinct
522
- `{from, to, evidence file:line}` pair. Only include transitions backed by
523
- explicit code — do not fabricate implied transitions.
524
-
525
- **Output rules:**
526
- - One top-level `## State:` section per qualifying enum, sorted alphabetically.
527
- - Each enum section lists all defined values under `### States`.
528
- - `file:line` annotations must come from actual symbol table records — do not fabricate.
529
- - Existing `docs/state-machines.md` → skip unless `--force`.
530
- - No qualifying enum → skip generation entirely (no empty document).
531
-
532
- #### External Integrations
533
-
534
- **Detection rule:** scan `external_urls` from the symbol table —
535
- `fetch(...)` / `axios` / `http.get` (and `http.*`) calls, constants shaped like
536
- `API_ENDPOINT` / `*_URL` / `*_HOST`, and hardcoded `https?://` strings. Exclude
537
- matches inside comments and test fixtures (`*.test.*`, `*.spec.*`, `tests/`,
538
- `fixtures/`).
539
-
540
- **Threshold:** if no external integration is detected, skip generation entirely
541
- (no empty `docs/integrations.md`).
542
-
543
- **Output document structure** (`docs/integrations.md`):
544
-
545
- ```markdown
546
- > **Draft** — auto-generated by roll-doc-audit on YYYY-MM-DD. Review before treating as authoritative.
547
-
548
- # External Integrations
549
-
550
- ## Integration: `{endpoint URL}`
551
-
552
- ### Call Sites
553
-
554
- | File:Line | Timeout | Error Handling / Fallback |
555
- |-----------|---------|---------------------------|
556
- | `path/to/file:12` | `timeout: 5000` | `.catch` retry fallback |
557
- | `path/to/file:48` | — | try/catch |
558
- ```
559
-
560
- **Per-integration fields:**
561
- - **endpoint URL** — the external URL / endpoint reached.
562
- - **call file:line** — every source location calling this endpoint.
563
- - **timeout config** — the value if the calling code carries a `timeout: N` field,
564
- otherwise `—`.
565
- - **error handling / fallback** — recorded when the calling code has a `.catch`
566
- handler or a `try` / `catch` block around the call, otherwise `—`.
567
-
568
- **Output rules:**
569
- - The same endpoint reached from multiple sites is merged into **one** integration
570
- section that lists **all** its call sites — never one section per call.
571
- - One top-level `## Integration:` section per distinct endpoint, sorted alphabetically.
572
- - `file:line` annotations must come from actual symbol table records — do not fabricate.
573
- - Existing `docs/integrations.md` → skip unless `--force`.
574
- - No external integration detected → skip generation entirely (no empty document).
575
-
576
- #### Deployment Pipeline
577
-
578
- **Detection rule:** the project has at least one CI configuration file —
579
- `.github/workflows/*.yml` (or `*.yaml`) / `.gitlab-ci.yml` / `circle.yml` /
580
- `.circleci/config.yml` / `Jenkinsfile` — AND a deploy URL pattern appears in the
581
- code or CI config (vercel / netlify / cloudflare / firebase, or hostnames ending
582
- in `*.app` / `*.dev`). Pull deploy URLs from the `configs` and `external_urls`
583
- fields of the symbol table.
584
-
585
- **Threshold:** if no CI configuration file is detected, skip generation entirely
586
- (no empty `docs/deployment.md`).
587
-
588
- **Output document structure** (`docs/deployment.md`):
589
-
590
- ```markdown
591
- > **Draft** — auto-generated by roll-doc-audit on YYYY-MM-DD. Review before treating as authoritative.
592
-
593
- # Deployment
594
-
595
- ## Pipeline: `{ci config file}`
596
-
597
- **CI Platform:** GitHub Actions
598
- **Trigger events:** push (main), pull_request, release
599
-
600
- ### Key Jobs
601
-
602
- | Job | File:Line | Purpose |
603
- |-----|-----------|---------|
604
- | `test` | `.github/workflows/deploy.yml:18` | run test suite |
605
- | `build` | `.github/workflows/deploy.yml:25` | compile artifacts |
606
- | `deploy` | `.github/workflows/deploy.yml:33` | deploy to Vercel |
607
-
608
- ### Deploy Targets
609
-
610
- | URL | File:Line |
611
- |-----|-----------|
612
- | `https://my-app.vercel.app` | `.github/workflows/deploy.yml:14` |
613
-
614
- ### Environment Variables
615
-
616
- | Name | File:Line |
617
- |------|-----------|
618
- | `NODE_ENV` | `.github/workflows/deploy.yml:11` |
619
- | `VERCEL_TOKEN` | `.github/workflows/deploy.yml:12` |
620
- ```
621
-
622
- **Per-pipeline fields:**
623
- - **CI platform** — inferred from which config file is present (GitHub Actions /
624
- GitLab CI / CircleCI / Jenkins).
625
- - **trigger events** — the events that start the pipeline (`push` / `pull_request` /
626
- `tag` / `release`), read from the CI config.
627
- - **key jobs** — each job / stage name with its `file:line` location.
628
- - **deploy target URL** — the deploy URL(s) matched by the detection rule.
629
- - **environment variable names** — every env var name referenced in the CI config,
630
- listed **without values** (never emit secret values, only names).
631
-
632
- **Output rules:**
633
- - One top-level `## Pipeline:` section per CI configuration file, sorted alphabetically.
634
- - `file:line` annotations must come from actual symbol table / CI config records — do not fabricate.
635
- - Existing `docs/deployment.md` → skip unless `--force`.
636
- - No CI configuration detected → skip generation entirely (no empty document).
637
-
638
- #### Agent Entrypoint (AGENTS.md)
639
-
640
- This topic handles the **「文件不存在 → 创建」** case: when a project has no agent-facing
641
- convention file at all, generate a complete baseline `AGENTS.md`. It is complementary to the
642
- Phase 2 **"AGENTS.md Where to Look bootstrap"** rule, which handles the **「文件存在 → 补章节」**
643
- case (append a missing `## Where to Look` section to an existing `AGENTS.md`). The two rules
644
- never overlap — this one only fires when no `AGENTS.md` exists.
645
-
646
- **Detection rule:** project root has **no** `AGENTS.md` AND the source root (`src/`, or the
647
- equivalent — `lib/`, `app/`, `pkg/`, etc.) contains **≥ 3 subdirectories**. If `AGENTS.md`
648
- already exists, skip entirely (do not overwrite unless `--force`). If the source root has
649
- fewer than 3 subdirectories, skip — the project is too small to warrant a baseline doc.
650
-
651
- **Output document structure** (`AGENTS.md`) — at minimum three required sections:
652
-
653
- ```markdown
654
- > **Draft** — auto-generated by roll-doc-audit on YYYY-MM-DD. Review before treating as authoritative.
655
-
656
- # {Project Name}
657
-
658
- {One-sentence positioning: what this project is, inferred from README / package metadata.}
659
-
660
- ## Where to Look
661
-
662
- - **Domain model**: `.roll/domain/context-map.md` — Contexts: {list, or "see file"}
663
- - **Story details**: `.roll/features/` — AC, implementation specs, dependencies
664
- - **Doc index**: `docs/INDEX.md` — generated documentation map
665
-
666
- ## Source Layout
667
-
668
- | Directory | Purpose |
669
- |-----------|---------|
670
- | `src/parser/` | tokenize and parse input (≤ 2 lines each) |
671
- | `src/codegen/` | emit output artifacts |
672
- | `src/cli/` | command-line entry and option wiring |
673
- ```
674
-
675
- **Per-section rules:**
676
- - **Project positioning** — a single sentence describing what the project does, inferred from
677
- the README / package metadata; never fabricate beyond what the source supports.
678
- - **`## Where to Look`** — pointer lines **only for directories that actually exist**
679
- (`.roll/domain/`, `.roll/features/`, `docs/INDEX.md`, etc.); never fabricate pointers to
680
- missing paths. If `.roll/domain/context-map.md` exists, read it for Bounded Context names.
681
- - **Source Layout** — one row per key source subdirectory, each description **≤ 2 lines**,
682
- inferred from the files actually read in the symbol table.
683
-
684
- **Output rules:**
685
- - Existing `AGENTS.md` → skip unless `--force` (never overwrite a human-authored file).
686
- - Source root with < 3 subdirectories → skip generation entirely (no empty `AGENTS.md`).
687
- - All three sections must be present in the generated file.
688
-
689
- #### High Fan-in Directory (README)
690
-
691
- This topic complements the Phase 2 file-count threshold. A directory may hold only one or two
692
- source files yet be imported across the whole codebase (shared utils, a single-file core
693
- module). The file-count rule (≥ 3 files) alone skips such hot paths, so high fan-in widens the
694
- threshold to **「文件数 ≥ 3 OR 被 ≥ 5 个文件引用」**.
695
-
696
- **Detection rule:** using the symbol table's `imports` edges, count the **distinct source files
697
- that import any file in the directory**. If that count is **≥ 5**, the directory qualifies for a
698
- `<dir>/README.md` gap, **even when it contains < 3 source files**. Only count referencing files
699
- that are source files — exclude test files (`*.test.*`, `*.spec.*`, `tests/`) and files inside
700
- the directory itself. This rule operates **in addition to** the Phase 2 count ≥ 3 rule, never
701
- replacing it: directories meeting either condition get a README.
702
-
703
- **Output rules:**
704
- - Target file is `<dir>/README.md`, generated with the same Module README content as Phase 3
705
- (purpose, key files, dependencies).
706
- - Existing `<dir>/README.md` → skip unless `--force` (never overwrite).
707
- - Directory imported by < 5 source files **and** holding < 3 source files → skip (no gap).
708
- - A directory already qualifying under the count ≥ 3 rule is not double-counted — one README.
709
-
710
- ### Step 3 — Source Annotations
711
-
712
- Every topic document generated in Step 2 must cite `file:line` for each claim (function call,
713
- endpoint URL, state transition, CI job, import path). Annotations must come from actual
714
- symbol table records — do not fabricate line numbers. Follows the same "Do not fabricate"
715
- rule as Phase 3.
716
-
717
- **Mandatory `file:line` column** — each topic document's source-reference tables MUST carry a
718
- dedicated `file:line` column so the reader can jump straight to the code:
719
- - 「涉及文件」/ Files Involved table → one `file:line` per row.
720
- - 「引用文件」/ Referenced By table → one `file:line` per referencing site.
721
- - 「调用链」/ Complete Call Chain table → one `file:line` per hop.
722
-
723
- Do **not** fabricate a `file:line` value: every annotation MUST come from an actual symbol
724
- table record (the same "Do not fabricate" rule as above). If the symbol table has no line for
725
- a claim, omit the row rather than invent a location.
726
-
727
- ---
728
-
729
- ## Phase 4 — Report
730
-
731
- After all phases complete, output a summary:
732
-
733
- ```
734
- 📚 roll-doc-audit complete
735
-
736
- Phase 1 — Index
737
- N docs scanned, docs/INDEX.md updated
738
- Categories: guide(N) domain(N) convention(N) module(N) stray(N)
739
-
740
- Phase 2 — Gaps
741
- N undocumented module directories found
742
- N special gaps (domain map / conventions)
743
-
744
- Phase 3 — Fill
745
- N drafts generated: [list of paths]
746
- N skipped (already exist; use --force to regenerate)
747
-
748
- Phase 3b — Deep Read
749
- Symbol table: exports(N) imports(N) enums(N) external_urls(N) configs(N)
750
- N topic documents generated:
751
- - docs/dataflow.md (data-flow) source entries: N
752
- - docs/state-machines.md (state-machine) source entries: N
753
- - docs/integrations.md (external-integration) source entries: N
754
- N topics skipped (no matches or already exist; use --force to regenerate)
755
-
756
- 📋 Review priority (largest / most active modules first):
757
- 1. src/commands/README.md — 8 source files
758
- 2. docs/CONVENTIONS.md — 6 patterns detected
759
- ```
760
-
761
- Each generated topic document is listed with its **path**, **type**, and **来源条目数 /
762
- source entries** (how many symbol-table records back the document). When Phase 3b produced no
763
- subject-level documents, print exactly one line and do **not** error:
764
-
765
- ```
766
- Phase 3b: no subject-level drafts generated
767
- ```
768
-
769
- If `--dry-run`, the `Phase 3b — Deep Read` section is shown the same way but every generated
770
- line is tagged `(plan)` — matching Phase 3's dry-run convention (nothing is written):
771
-
772
- ```
773
- Phase 3b — Deep Read (plan)
774
- N topic documents would be generated:
775
- - docs/dataflow.md (data-flow) source entries: N (plan)
776
- ```
777
-
778
- If no gaps were found:
779
-
780
- ```
781
- ✅ roll-doc-audit: no gaps found. docs/INDEX.md updated.
782
- ```
783
-
784
- If `--dry-run`:
785
-
786
- ```
787
- 🔍 roll-doc-audit --dry-run: N drafts would be generated (nothing written).
788
- ```
789
-
790
- ## Rules
791
-
792
- - Never modify existing documentation files — only generate new drafts
793
- - `docs/INDEX.md` is the only existing file that may be overwritten (derived artifact)
794
- - Draft files are never committed by this skill — human reviews and commits them
795
- - Works on any project; always read project structure before acting
796
- - Do not fabricate module details — infer only from source files actually read