@rune-kit/rune 2.1.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 (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +357 -0
  3. package/agents/.gitkeep +0 -0
  4. package/agents/architect.md +29 -0
  5. package/agents/asset-creator.md +11 -0
  6. package/agents/audit.md +11 -0
  7. package/agents/autopsy.md +11 -0
  8. package/agents/brainstorm.md +11 -0
  9. package/agents/browser-pilot.md +11 -0
  10. package/agents/coder.md +29 -0
  11. package/agents/completion-gate.md +11 -0
  12. package/agents/constraint-check.md +11 -0
  13. package/agents/context-engine.md +11 -0
  14. package/agents/cook.md +11 -0
  15. package/agents/db.md +11 -0
  16. package/agents/debug.md +11 -0
  17. package/agents/dependency-doctor.md +11 -0
  18. package/agents/deploy.md +11 -0
  19. package/agents/design.md +11 -0
  20. package/agents/docs-seeker.md +11 -0
  21. package/agents/fix.md +11 -0
  22. package/agents/hallucination-guard.md +11 -0
  23. package/agents/incident.md +11 -0
  24. package/agents/integrity-check.md +11 -0
  25. package/agents/journal.md +11 -0
  26. package/agents/launch.md +11 -0
  27. package/agents/logic-guardian.md +11 -0
  28. package/agents/marketing.md +11 -0
  29. package/agents/onboard.md +11 -0
  30. package/agents/perf.md +11 -0
  31. package/agents/plan.md +11 -0
  32. package/agents/preflight.md +11 -0
  33. package/agents/problem-solver.md +11 -0
  34. package/agents/rescue.md +11 -0
  35. package/agents/research.md +11 -0
  36. package/agents/researcher.md +29 -0
  37. package/agents/review-intake.md +11 -0
  38. package/agents/review.md +11 -0
  39. package/agents/reviewer.md +28 -0
  40. package/agents/safeguard.md +11 -0
  41. package/agents/sast.md +11 -0
  42. package/agents/scanner.md +28 -0
  43. package/agents/scope-guard.md +11 -0
  44. package/agents/scout.md +11 -0
  45. package/agents/sentinel.md +11 -0
  46. package/agents/sequential-thinking.md +11 -0
  47. package/agents/session-bridge.md +11 -0
  48. package/agents/skill-forge.md +11 -0
  49. package/agents/skill-router.md +11 -0
  50. package/agents/surgeon.md +11 -0
  51. package/agents/team.md +11 -0
  52. package/agents/test.md +11 -0
  53. package/agents/trend-scout.md +11 -0
  54. package/agents/verification.md +11 -0
  55. package/agents/video-creator.md +11 -0
  56. package/agents/watchdog.md +11 -0
  57. package/agents/worktree.md +11 -0
  58. package/commands/.gitkeep +0 -0
  59. package/commands/rune.md +168 -0
  60. package/compiler/__tests__/openclaw-adapter.test.js +140 -0
  61. package/compiler/__tests__/parser.test.js +55 -0
  62. package/compiler/adapters/antigravity.js +59 -0
  63. package/compiler/adapters/claude.js +37 -0
  64. package/compiler/adapters/cursor.js +67 -0
  65. package/compiler/adapters/generic.js +60 -0
  66. package/compiler/adapters/index.js +45 -0
  67. package/compiler/adapters/openclaw.js +150 -0
  68. package/compiler/adapters/windsurf.js +60 -0
  69. package/compiler/bin/rune.js +288 -0
  70. package/compiler/doctor.js +153 -0
  71. package/compiler/emitter.js +240 -0
  72. package/compiler/parser.js +208 -0
  73. package/compiler/transformer.js +69 -0
  74. package/compiler/transforms/branding.js +27 -0
  75. package/compiler/transforms/cross-references.js +29 -0
  76. package/compiler/transforms/frontmatter.js +38 -0
  77. package/compiler/transforms/hooks.js +68 -0
  78. package/compiler/transforms/subagents.js +36 -0
  79. package/compiler/transforms/tool-names.js +60 -0
  80. package/contexts/dev.md +34 -0
  81. package/contexts/research.md +43 -0
  82. package/contexts/review.md +55 -0
  83. package/extensions/ai-ml/PACK.md +517 -0
  84. package/extensions/analytics/PACK.md +557 -0
  85. package/extensions/backend/PACK.md +678 -0
  86. package/extensions/chrome-ext/PACK.md +995 -0
  87. package/extensions/content/PACK.md +381 -0
  88. package/extensions/devops/PACK.md +520 -0
  89. package/extensions/ecommerce/PACK.md +280 -0
  90. package/extensions/gamedev/PACK.md +393 -0
  91. package/extensions/mobile/PACK.md +273 -0
  92. package/extensions/saas/PACK.md +805 -0
  93. package/extensions/security/PACK.md +536 -0
  94. package/extensions/trading/PACK.md +597 -0
  95. package/extensions/ui/PACK.md +947 -0
  96. package/package.json +47 -0
  97. package/skills/.gitkeep +0 -0
  98. package/skills/adversary/SKILL.md +271 -0
  99. package/skills/asset-creator/SKILL.md +157 -0
  100. package/skills/audit/SKILL.md +466 -0
  101. package/skills/autopsy/SKILL.md +200 -0
  102. package/skills/ba/SKILL.md +279 -0
  103. package/skills/brainstorm/SKILL.md +266 -0
  104. package/skills/browser-pilot/SKILL.md +168 -0
  105. package/skills/completion-gate/SKILL.md +151 -0
  106. package/skills/constraint-check/SKILL.md +165 -0
  107. package/skills/context-engine/SKILL.md +176 -0
  108. package/skills/cook/SKILL.md +636 -0
  109. package/skills/db/SKILL.md +256 -0
  110. package/skills/debug/SKILL.md +240 -0
  111. package/skills/dependency-doctor/SKILL.md +235 -0
  112. package/skills/deploy/SKILL.md +174 -0
  113. package/skills/design/DESIGN-REFERENCE.md +365 -0
  114. package/skills/design/SKILL.md +462 -0
  115. package/skills/doc-processor/SKILL.md +254 -0
  116. package/skills/docs/SKILL.md +336 -0
  117. package/skills/docs-seeker/SKILL.md +166 -0
  118. package/skills/fix/SKILL.md +192 -0
  119. package/skills/git/SKILL.md +285 -0
  120. package/skills/hallucination-guard/SKILL.md +204 -0
  121. package/skills/incident/SKILL.md +241 -0
  122. package/skills/integrity-check/SKILL.md +169 -0
  123. package/skills/journal/SKILL.md +190 -0
  124. package/skills/launch/SKILL.md +330 -0
  125. package/skills/logic-guardian/SKILL.md +240 -0
  126. package/skills/marketing/SKILL.md +229 -0
  127. package/skills/mcp-builder/SKILL.md +311 -0
  128. package/skills/onboard/SKILL.md +298 -0
  129. package/skills/perf/SKILL.md +297 -0
  130. package/skills/plan/SKILL.md +520 -0
  131. package/skills/preflight/SKILL.md +231 -0
  132. package/skills/problem-solver/SKILL.md +284 -0
  133. package/skills/rescue/SKILL.md +434 -0
  134. package/skills/research/SKILL.md +122 -0
  135. package/skills/review/SKILL.md +354 -0
  136. package/skills/review-intake/SKILL.md +222 -0
  137. package/skills/safeguard/SKILL.md +188 -0
  138. package/skills/sast/SKILL.md +190 -0
  139. package/skills/scaffold/SKILL.md +276 -0
  140. package/skills/scope-guard/SKILL.md +150 -0
  141. package/skills/scout/SKILL.md +232 -0
  142. package/skills/sentinel/SKILL.md +320 -0
  143. package/skills/sentinel-env/SKILL.md +226 -0
  144. package/skills/sequential-thinking/SKILL.md +234 -0
  145. package/skills/session-bridge/SKILL.md +287 -0
  146. package/skills/skill-forge/SKILL.md +317 -0
  147. package/skills/skill-router/SKILL.md +267 -0
  148. package/skills/surgeon/SKILL.md +203 -0
  149. package/skills/team/SKILL.md +397 -0
  150. package/skills/test/SKILL.md +271 -0
  151. package/skills/trend-scout/SKILL.md +145 -0
  152. package/skills/verification/SKILL.md +201 -0
  153. package/skills/video-creator/SKILL.md +201 -0
  154. package/skills/watchdog/SKILL.md +166 -0
  155. package/skills/worktree/SKILL.md +140 -0
@@ -0,0 +1,254 @@
1
+ ---
2
+ name: doc-processor
3
+ description: Generate and parse office documents — PDF, DOCX, XLSX, PPTX, CSV. Pure format utility for creating reports, exporting data, and processing uploaded documents.
4
+ metadata:
5
+ author: runedev
6
+ version: "0.2.0"
7
+ layer: L3
8
+ model: sonnet
9
+ group: utility
10
+ tools: "Read, Write, Edit, Bash, Glob, Grep"
11
+ ---
12
+
13
+ # doc-processor
14
+
15
+ ## Purpose
16
+
17
+ Document format utility. Generates and parses office documents (PDF, DOCX, XLSX, PPTX, CSV). Pure utility — no business logic, just format handling. Other skills call doc-processor when they need to produce or consume structured documents.
18
+
19
+ ## Triggers
20
+
21
+ - Called by `docs` when export to PDF/DOCX is requested
22
+ - Called by `marketing` for generating PDF reports, PPTX presentations
23
+ - Called by Rune Pro packs for business document generation
24
+ - `/rune doc-processor generate <format> <source>` — manual document generation
25
+ - `/rune doc-processor parse <file>` — manual document parsing
26
+
27
+ ## Calls (outbound)
28
+
29
+ None — pure L3 utility. Receives content, produces formatted output.
30
+
31
+ ## Called By (inbound)
32
+
33
+ - `docs` (L2): export documentation to PDF/DOCX
34
+ - `marketing` (L2): generate PDF reports, PPTX pitch decks
35
+ - Rune Pro packs: business document generation (invoices, proposals, reports)
36
+ - User: `/rune doc-processor` direct invocation
37
+
38
+ ## Format Reference
39
+
40
+ ### Supported Formats
41
+
42
+ | Format | Generate | Parse | Node.js Library | Python Library |
43
+ |--------|----------|-------|-----------------|----------------|
44
+ | PDF | Yes | Yes (via Read tool) | jsPDF, Puppeteer (HTML→PDF) | reportlab, weasyprint |
45
+ | DOCX | Yes | Yes | docx (officegen) | python-docx |
46
+ | XLSX | Yes | Yes | ExcelJS | openpyxl |
47
+ | PPTX | Yes | Yes | pptxgenjs | python-pptx |
48
+ | CSV | Yes | Yes | Built-in (fs + string ops) | Built-in (csv module) |
49
+ | HTML | Yes | Yes | Built-in | Built-in |
50
+
51
+ ### Library Selection
52
+
53
+ Detect project language from context:
54
+ - If Node.js project → use Node.js libraries
55
+ - If Python project → use Python libraries
56
+ - If unclear → default to Node.js (wider ecosystem)
57
+ - For HTML→PDF → prefer Puppeteer (best fidelity) or weasyprint (Python)
58
+
59
+ ## Executable Steps
60
+
61
+ ### Generate Mode
62
+
63
+ #### Step 1 — Determine Format and Template
64
+
65
+ Identify:
66
+ - Target format (PDF, DOCX, XLSX, PPTX, CSV)
67
+ - Content source (markdown, data object, template + data)
68
+ - Styling requirements (brand colors, fonts, layout)
69
+ - Output path
70
+
71
+ #### Step 2 — Select Generation Strategy
72
+
73
+ | Source | Target | Strategy |
74
+ |--------|--------|----------|
75
+ | Markdown → PDF | HTML intermediate | Render MD → HTML → Puppeteer → PDF |
76
+ | Markdown → DOCX | Direct conversion | Parse MD → docx library → DOCX |
77
+ | Data → XLSX | Direct write | Map data to sheets/cells → ExcelJS |
78
+ | Slides → PPTX | Template + data | Build slides from content → pptxgenjs |
79
+ | Data → CSV | Direct write | Serialize rows → CSV string → file |
80
+ | Any → HTML | Direct render | Template engine → HTML file |
81
+
82
+ #### Step 3 — Generate Code
83
+
84
+ Produce the generation script:
85
+
86
+ **PDF from Markdown:**
87
+ ```javascript
88
+ // Strategy: Markdown → HTML → Puppeteer → PDF
89
+ const puppeteer = require('puppeteer');
90
+ const { marked } = require('marked');
91
+
92
+ async function generatePDF(markdownContent, outputPath, options = {}) {
93
+ const html = `
94
+ <!DOCTYPE html>
95
+ <html>
96
+ <head><style>${options.css || defaultCSS}</style></head>
97
+ <body>${marked(markdownContent)}</body>
98
+ </html>
99
+ `;
100
+ const browser = await puppeteer.launch();
101
+ const page = await browser.newPage();
102
+ await page.setContent(html, { waitUntil: 'networkidle0' });
103
+ await page.pdf({ path: outputPath, format: 'A4', margin: { top: '1in', bottom: '1in', left: '1in', right: '1in' } });
104
+ await browser.close();
105
+ }
106
+ ```
107
+
108
+ **XLSX from Data:**
109
+ ```javascript
110
+ const ExcelJS = require('exceljs');
111
+
112
+ async function generateXLSX(data, outputPath, options = {}) {
113
+ const workbook = new ExcelJS.Workbook();
114
+ const sheet = workbook.addWorksheet(options.sheetName || 'Sheet1');
115
+ if (data.length > 0) {
116
+ sheet.columns = Object.keys(data[0]).map(key => ({ header: key, key, width: 20 }));
117
+ data.forEach(row => sheet.addRow(row));
118
+ // Style header row
119
+ sheet.getRow(1).font = { bold: true };
120
+ sheet.getRow(1).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFE0E0E0' } };
121
+ }
122
+ await workbook.xlsx.writeFile(outputPath);
123
+ }
124
+ ```
125
+
126
+ **PPTX from Slides:**
127
+ ```javascript
128
+ const PptxGenJS = require('pptxgenjs');
129
+
130
+ function generatePPTX(slides, outputPath, options = {}) {
131
+ const pptx = new PptxGenJS();
132
+ pptx.author = options.author || 'Generated by Rune';
133
+ slides.forEach(slide => {
134
+ const s = pptx.addSlide();
135
+ if (slide.title) s.addText(slide.title, { x: 0.5, y: 0.5, fontSize: 28, bold: true });
136
+ if (slide.body) s.addText(slide.body, { x: 0.5, y: 1.5, fontSize: 16 });
137
+ if (slide.bullets) s.addText(slide.bullets.map(b => ({ text: b, options: { bullet: true } })), { x: 0.5, y: 1.5, fontSize: 16 });
138
+ });
139
+ return pptx.writeFile({ fileName: outputPath });
140
+ }
141
+ ```
142
+
143
+ #### Step 4 — Execute and Verify
144
+
145
+ Run the generation script. Verify:
146
+ - Output file exists and is non-empty
147
+ - File can be opened (basic format validation)
148
+ - Content matches expected structure
149
+
150
+ ### Parse Mode
151
+
152
+ #### Step 1 — Detect Format
153
+
154
+ Identify file format from extension and MIME type.
155
+
156
+ #### Step 2 — Extract Content
157
+
158
+ | Format | Extraction Strategy |
159
+ |--------|-------------------|
160
+ | PDF | Use Read tool (Claude can read PDFs natively) |
161
+ | DOCX | docx library → extract text, tables, images |
162
+ | XLSX | ExcelJS → extract sheets, rows, formulas |
163
+ | PPTX | pptxgenjs → extract slides, text, notes |
164
+ | CSV | Built-in parser → structured data |
165
+
166
+ #### Step 3 — Structure Output
167
+
168
+ Return parsed content as structured data:
169
+ ```json
170
+ {
171
+ "format": "xlsx",
172
+ "sheets": [
173
+ {
174
+ "name": "Sheet1",
175
+ "headers": ["Name", "Email", "Role"],
176
+ "rows": [["Alice", "alice@co.com", "Engineer"], ...],
177
+ "rowCount": 100
178
+ }
179
+ ]
180
+ }
181
+ ```
182
+
183
+ ## Output Format
184
+
185
+ ### Generate Mode Output
186
+ - Generated document file at specified output path
187
+ - Verification report: file exists, non-empty, format valid
188
+
189
+ ```
190
+ Document Generated:
191
+ - Format: [PDF/DOCX/XLSX/PPTX/CSV]
192
+ - Path: [output file path]
193
+ - Size: [file size]
194
+ - Strategy: [e.g., Markdown → HTML → Puppeteer → PDF]
195
+ - Status: verified ✓
196
+ ```
197
+
198
+ ### Parse Mode Output
199
+ Structured JSON returned to calling skill:
200
+
201
+ ```json
202
+ {
203
+ "format": "xlsx",
204
+ "metadata": { "author": "...", "created": "..." },
205
+ "content": {
206
+ "sheets": [
207
+ {
208
+ "name": "Sheet1",
209
+ "headers": ["Col1", "Col2"],
210
+ "rows": [["val1", "val2"]],
211
+ "rowCount": 100
212
+ }
213
+ ]
214
+ }
215
+ }
216
+ ```
217
+
218
+ Format-specific fields: `sheets` (XLSX), `pages` (PDF/DOCX), `slides` (PPTX), `rows` (CSV).
219
+
220
+ ## Constraints
221
+
222
+ 1. MUST verify output file exists and is non-empty after generation
223
+ 2. MUST handle missing libraries gracefully — suggest `npm install` / `pip install` if not found
224
+ 3. MUST NOT embed secrets or sensitive data in generated documents
225
+ 4. MUST preserve formatting fidelity — generated docs should look professional
226
+ 5. Parse mode MUST handle malformed files gracefully — report errors, don't crash
227
+ 6. MUST use appropriate library for each format — don't force one library for all formats
228
+
229
+ ## Sharp Edges
230
+
231
+ | Failure Mode | Severity | Mitigation |
232
+ |---|---|---|
233
+ | Library not installed in project | HIGH | Check package.json/requirements.txt, suggest install command |
234
+ | PDF generation fails without headless browser | HIGH | Puppeteer needs chromium — suggest alternative (jsPDF) if unavailable |
235
+ | XLSX with formulas not evaluated | MEDIUM | Use ExcelJS formula support, warn if complex formulas |
236
+ | Large file generation runs out of memory | MEDIUM | Stream large datasets instead of loading all at once |
237
+ | Generated file is empty or corrupt | HIGH | Step 4 verification catches this — retry or report |
238
+
239
+ ## Done When
240
+
241
+ ### Generate Mode
242
+ - Target format and source identified
243
+ - Generation strategy selected
244
+ - Code produced and executed
245
+ - Output file verified (exists, non-empty, valid format)
246
+
247
+ ### Parse Mode
248
+ - File format detected
249
+ - Content extracted to structured data
250
+ - Output returned in consistent JSON format
251
+
252
+ ## Cost Profile
253
+
254
+ ~1000-3000 tokens input, ~500-2000 tokens output. Sonnet — document processing requires understanding format libraries and generating correct code, but not deep reasoning.
@@ -0,0 +1,336 @@
1
+ ---
2
+ name: docs
3
+ description: Auto-generate and maintain project documentation. Creates README, API docs, architecture docs, changelogs, and keeps them in sync with code changes. The "docs are never outdated" skill.
4
+ metadata:
5
+ author: runedev
6
+ version: "0.2.0"
7
+ layer: L2
8
+ model: sonnet
9
+ group: delivery
10
+ tools: "Read, Write, Edit, Glob, Grep"
11
+ ---
12
+
13
+ # docs
14
+
15
+ ## Purpose
16
+
17
+ Documentation lifecycle manager. Generates initial project documentation, keeps docs in sync with code changes, produces API references, and auto-generates changelogs. Solves the #1 documentation problem: docs that exist but are outdated.
18
+
19
+ <HARD-GATE>
20
+ Docs MUST be generated from actual code, not invented. Every statement in generated docs must be traceable to a specific file, function, or configuration in the codebase. If code doesn't exist yet, docs describe the PLAN, not the implementation.
21
+ </HARD-GATE>
22
+
23
+ ## Triggers
24
+
25
+ - Called by `scaffold` Phase 7 for initial documentation generation
26
+ - Called by `cook` post-Phase 7 to update docs after feature implementation
27
+ - Called by `launch` pre-deploy to ensure docs are current
28
+ - `/rune docs init` — first-time documentation generation
29
+ - `/rune docs update` — sync docs with recent code changes
30
+ - `/rune docs api` — generate API documentation
31
+ - `/rune docs changelog` — auto-generate changelog from git history
32
+
33
+ ## Calls (outbound)
34
+
35
+ - `scout` (L2): scan codebase for documentation targets (routes, exports, components, configs)
36
+ - `doc-processor` (L3): generate PDF/DOCX exports if requested
37
+ - `git` (L3): read commit history for changelog generation
38
+
39
+ ## Called By (inbound)
40
+
41
+ - `scaffold` (L1): Phase 7 — generate initial docs for new project
42
+ - `cook` (L1): post-implementation — update docs for changed modules
43
+ - `launch` (L1): pre-deploy — verify docs are current
44
+ - `mcp-builder` (L2): generate MCP server documentation
45
+ - User: `/rune docs` direct invocation
46
+
47
+ ## Modes
48
+
49
+ ### Init Mode — `/rune docs init`
50
+
51
+ First-time documentation generation for a project.
52
+
53
+ ### Update Mode — `/rune docs update`
54
+
55
+ Incremental sync — update only docs affected by recent code changes.
56
+
57
+ ### API Mode — `/rune docs api`
58
+
59
+ Generate or update API documentation specifically.
60
+
61
+ ### Changelog Mode — `/rune docs changelog`
62
+
63
+ Auto-generate changelog from git commit history.
64
+
65
+ ## Executable Steps
66
+
67
+ ### Init Mode
68
+
69
+ #### Step 1 — Scan Codebase
70
+
71
+ Invoke `rune:scout` to extract:
72
+ - Project name, description, tech stack
73
+ - Directory structure and key files
74
+ - Entry points (main, index, app)
75
+ - Public API surface (exports, routes, components)
76
+ - Configuration files (.env.example, config patterns)
77
+ - Existing docs (if any — merge, don't overwrite)
78
+
79
+ #### Step 2 — Generate README.md
80
+
81
+ Structure:
82
+ ```markdown
83
+ # [Project Name]
84
+ [One-line description]
85
+
86
+ ## Quick Start
87
+ [3-5 commands to get running: install, configure, start]
88
+
89
+ ## Features
90
+ [Bullet list extracted from code — routes, components, capabilities]
91
+
92
+ ## Tech Stack
93
+ [Detected from package.json, requirements.txt, Cargo.toml, etc.]
94
+
95
+ ## Project Structure
96
+ [Key directories with one-line descriptions]
97
+
98
+ ## Configuration
99
+ [Environment variables from .env.example with descriptions]
100
+
101
+ ## Development
102
+ [Dev server, test, lint, build commands]
103
+
104
+ ## API Reference
105
+ [Link to API.md if applicable, or inline summary]
106
+
107
+ ## License
108
+ [Detected from LICENSE file or package.json]
109
+ ```
110
+
111
+ #### Step 3 — Generate ARCHITECTURE.md (if project has 10+ files)
112
+
113
+ Structure:
114
+ ```markdown
115
+ # Architecture
116
+
117
+ ## Overview
118
+ [System diagram in text/mermaid — components and data flow]
119
+
120
+ ## Key Decisions
121
+ [Detected patterns: framework choice, state management, DB, auth approach]
122
+
123
+ ## Module Map
124
+ [Each top-level directory: purpose, key files, dependencies]
125
+
126
+ ## Data Flow
127
+ [Request lifecycle or data pipeline description]
128
+ ```
129
+
130
+ #### Step 4 — Generate API.md (if routes/endpoints detected)
131
+
132
+ Scan route files and extract:
133
+ - HTTP method + path
134
+ - Request parameters (path, query, body)
135
+ - Response shape
136
+ - Authentication requirements
137
+ - Error responses
138
+
139
+ Format as markdown table or OpenAPI-compatible reference.
140
+
141
+ #### Step 5 — Report
142
+
143
+ Present generated docs to user with summary:
144
+ - Files generated: [list]
145
+ - Coverage: [what's documented vs what exists]
146
+ - Gaps: [code areas without docs — suggest next steps]
147
+
148
+ ### Update Mode
149
+
150
+ #### Step 1 — Detect Changes
151
+
152
+ Read `git diff` since last docs update (tracked via git log on doc files or `.rune/docs-sync.json`).
153
+
154
+ Identify:
155
+ - New files/modules → need new doc sections
156
+ - Changed functions/routes → need doc updates
157
+ - Deleted code → need doc removal
158
+ - New configuration → need config doc update
159
+
160
+ #### Step 2 — Update Affected Sections
161
+
162
+ For each changed area:
163
+ 1. Read the changed code
164
+ 2. Find corresponding doc section
165
+ 3. Update doc to match current code
166
+ 4. If doc section doesn't exist → create it
167
+ 5. If code was deleted → remove or mark as deprecated in docs
168
+
169
+ <HARD-GATE>
170
+ Never silently remove doc content. If code was deleted, mark the doc section as "Removed in [commit]" or ask user before deleting the doc section.
171
+ </HARD-GATE>
172
+
173
+ #### Step 3 — Generate Changelog Entry
174
+
175
+ Delegate to `rune:git changelog` to produce a changelog entry from commits since last docs update.
176
+
177
+ #### Step 4 — Report
178
+
179
+ Show user: what was updated, what was added, what was flagged for review.
180
+
181
+ ### API Mode
182
+
183
+ #### Step 1 — Detect API Framework
184
+
185
+ | Framework | Route Pattern | File Pattern |
186
+ |-----------|--------------|--------------|
187
+ | Express | `router.get/post/put/delete` | `routes/*.ts`, `*.router.ts` |
188
+ | FastAPI | `@app.get/post/put/delete` | `routers/*.py`, `main.py` |
189
+ | NestJS | `@Get/@Post/@Put/@Delete` | `*.controller.ts` |
190
+ | Next.js App | `export async function GET/POST` | `app/**/route.ts` |
191
+ | Next.js Pages | `export default function handler` | `pages/api/**/*.ts` |
192
+ | SvelteKit | `export function GET/POST` | `src/routes/**/+server.ts` |
193
+ | Hono | `app.get/post/put/delete` | `src/*.ts` |
194
+
195
+ #### Step 2 — Extract Endpoints
196
+
197
+ For each detected route:
198
+ - Method (GET, POST, PUT, DELETE, PATCH)
199
+ - Path (with parameters highlighted)
200
+ - Request: params, query, body shape (from Zod schemas, TypeScript types, Pydantic models)
201
+ - Response: shape (from return type or response helper)
202
+ - Auth: required? (detect middleware like `authMiddleware`, `@UseGuards`)
203
+ - Description: from JSDoc/docstring if available
204
+
205
+ #### Step 3 — Generate API Reference
206
+
207
+ Format as markdown:
208
+ ```markdown
209
+ # API Reference
210
+
211
+ ## Authentication
212
+ [Auth mechanism description]
213
+
214
+ ## Endpoints
215
+
216
+ ### `POST /api/auth/login`
217
+ **Description**: Authenticate user and return tokens
218
+ **Auth**: None
219
+ **Request Body**:
220
+ | Field | Type | Required | Description |
221
+ |-------|------|----------|-------------|
222
+ | email | string | yes | User email |
223
+ | password | string | yes | User password |
224
+
225
+ **Response** (200):
226
+ ```json
227
+ { "token": "string", "refreshToken": "string" }
228
+ ```
229
+
230
+ **Errors**:
231
+ - 401: Invalid credentials
232
+ - 422: Validation error
233
+ ```
234
+
235
+ #### Step 4 — Output
236
+
237
+ Save to `docs/API.md` or project-specific location. If OpenAPI requested, generate `openapi.yaml`.
238
+
239
+ ### Changelog Mode
240
+
241
+ #### Step 1 — Delegate to Git
242
+
243
+ Invoke `rune:git changelog` to group commits by type and format as Keep a Changelog.
244
+
245
+ #### Step 2 — Enhance
246
+
247
+ Add context to raw changelog:
248
+ - Link PR numbers to actual descriptions
249
+ - Group related changes under feature headers
250
+ - Highlight breaking changes prominently
251
+
252
+ #### Step 3 — Output
253
+
254
+ Append to or update `CHANGELOG.md`.
255
+
256
+ ## Output Format
257
+
258
+ ### Init Mode Output
259
+ Files generated in project root:
260
+ - `README.md` — Quick Start, Features, Tech Stack, Structure, Config, Dev Commands
261
+ - `ARCHITECTURE.md` — Overview diagram, Key Decisions, Module Map, Data Flow (if 10+ files)
262
+ - `docs/API.md` — Endpoint reference with method, path, params, response, auth (if routes detected)
263
+
264
+ ### Update Mode Output
265
+ Modified doc sections with change summary:
266
+ ```
267
+ Docs Update Report:
268
+ - Updated: [list of doc sections modified]
269
+ - Added: [new sections for new code]
270
+ - Flagged: [stale sections referencing deleted code]
271
+ - Changelog: [entry appended to CHANGELOG.md]
272
+ ```
273
+
274
+ ### API Mode Output
275
+ `docs/API.md` — markdown reference per endpoint:
276
+ ```
277
+ ### `METHOD /path/:param`
278
+ **Description**: [from JSDoc/docstring]
279
+ **Auth**: [required/none]
280
+ **Request**: [params, query, body table]
281
+ **Response**: [shape with status codes]
282
+ **Errors**: [error codes and descriptions]
283
+ ```
284
+
285
+ ### Changelog Mode Output
286
+ `CHANGELOG.md` — Keep a Changelog format grouped by: Added, Fixed, Changed, Removed.
287
+
288
+ ## Constraints
289
+
290
+ 1. MUST generate docs from actual code — never invent features or APIs that don't exist
291
+ 2. MUST preserve existing docs — update sections, don't overwrite entire files
292
+ 3. MUST detect doc staleness — flag sections that reference deleted/changed code
293
+ 4. MUST include Quick Start in every README — users need to get running in < 2 minutes
294
+ 5. MUST NOT generate docs for code that doesn't exist yet (unless explicitly creating spec docs)
295
+ 6. API docs MUST match actual route signatures — wrong API docs are worse than no docs
296
+
297
+ ## Sharp Edges
298
+
299
+ | Failure Mode | Severity | Mitigation |
300
+ |---|---|---|
301
+ | Inventing API endpoints that don't exist | CRITICAL | Constraint 1: scan actual route files, not guess |
302
+ | Overwriting user-written README sections | HIGH | Constraint 2: merge, don't overwrite — detect custom sections |
303
+ | Stale docs after code changes | HIGH | Update mode detects diffs and updates affected sections |
304
+ | API docs with wrong request/response shapes | HIGH | Extract from Zod/Pydantic/TypeScript types, not from memory |
305
+ | Missing Quick Start section | MEDIUM | Constraint 4: every README has Quick Start |
306
+ | Changelog with orphan PR links | LOW | Validate PR numbers exist before linking |
307
+
308
+ ## Done When
309
+
310
+ ### Init Mode
311
+ - Codebase scanned with scout
312
+ - README.md generated with Quick Start, Features, Tech Stack, Structure
313
+ - ARCHITECTURE.md generated (if 10+ files)
314
+ - API.md generated (if routes detected)
315
+ - Coverage report presented to user
316
+
317
+ ### Update Mode
318
+ - Changes since last doc update detected
319
+ - Affected doc sections updated
320
+ - Changelog entry generated
321
+ - Update report presented to user
322
+
323
+ ### API Mode
324
+ - API framework detected
325
+ - All endpoints extracted with method, path, request, response
326
+ - API reference generated in markdown
327
+ - Saved to docs/API.md
328
+
329
+ ### Changelog Mode
330
+ - Commits grouped by type
331
+ - Formatted as Keep a Changelog
332
+ - CHANGELOG.md updated
333
+
334
+ ## Cost Profile
335
+
336
+ ~2000-5000 tokens input, ~1000-3000 tokens output. Sonnet — documentation requires understanding code patterns but not deep architectural reasoning.