@brainfish-ai/devdoc 0.1.41 → 0.1.42

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.
@@ -1,26 +1,20 @@
1
1
  ---
2
2
  name: update-doc
3
- description: Update existing documentation by analyzing codebase changes or user references.
3
+ description: Update existing documentation by searching codebase for current implementation.
4
4
  ---
5
5
 
6
6
  ## Instructions
7
7
 
8
8
  When user wants to update documentation:
9
9
 
10
- ### Step 0: Read Context & Code Graph
10
+ ### Step 0: Read Context
11
11
 
12
- **First, read `.devdoc/context.json` if it exists:**
12
+ **Read `.devdoc/context.json` if it exists:**
13
13
  - Use `product.name` for product references
14
14
  - Apply `terminology.glossary` for correct terms
15
15
  - Avoid `terminology.avoidTerms`
16
16
  - Match `documentation.voice` for writing style
17
17
 
18
- **Then, read `.devdoc/code-graph.json` if it exists:**
19
- - Compare documented signatures vs code-graph exports
20
- - Check if new exports need documentation
21
- - Verify types match code-graph definitions
22
- - Find new examples to include
23
-
24
18
  ### Step 1: Understand What to Update
25
19
 
26
20
  Ask the user:
@@ -47,21 +41,34 @@ Based on their choice:
47
41
  - Rewrite for clarity
48
42
  - Other (describe)"
49
43
 
50
- #### For Codebase Sync:
51
- **If code-graph.json exists:**
52
- - Re-scan codebase to update code-graph.json
53
- - Compare OLD code-graph vs NEW code-graph:
54
- - Changed function signatures
55
- - New exports added
56
- - Removed exports
57
- - Changed types
58
- - Generate sync report (see below)
59
-
60
- **If code-graph.json doesn't exist:**
61
- - Run bootstrap first: "Run `/bootstrap-docs` first to create code-graph.json"
62
- - Or manually scan source code
63
-
64
- Compare documentation against code-graph:
44
+ #### For Codebase Sync (Search Real Files):
45
+
46
+ **Step 2a: Search for source files related to documented topics:**
47
+ ```bash
48
+ # Find all exported functions/classes
49
+ rg "export (function|class|const|interface|type)" --type ts -l
50
+
51
+ # Find specific topic files
52
+ git ls-files | grep -iE "(auth|user|api)"
53
+ ```
54
+
55
+ **Step 2b: Read both doc files AND source files:**
56
+ 1. Read the doc file to see what's documented
57
+ 2. Search and read the corresponding source file
58
+ 3. Compare documented vs actual implementation
59
+
60
+ **Step 2c: Generate comparison:**
61
+ ```
62
+ DOCUMENTED (from docs/api/users.mdx):
63
+ - createUser(name: string, email: string)
64
+
65
+ ACTUAL (from src/lib/users.ts):
66
+ - createUser(options: CreateUserInput)
67
+
68
+ → SIGNATURE MISMATCH - needs update
69
+ ```
70
+
71
+ Compare documentation against actual source:
65
72
  - Function signatures changed?
66
73
  - New exports not documented?
67
74
  - Removed features still documented?
@@ -84,67 +91,137 @@ Compare documentation against code-graph:
84
91
  - "What's the problem you're seeing?"
85
92
  - Analyze and propose fixes
86
93
 
87
- ### Step 3: Generate Sync Report (if syncing)
94
+ ### Step 3: Detect Feature Flags & Duplicates
95
+
96
+ **Search for feature flags in source:**
97
+ ```bash
98
+ rg -l "featureFlag|feature_flag|isEnabled|FF_" --type ts
99
+ rg "if.*\(.*feature|process\.env\.FEATURE" --type ts
100
+ ```
101
+
102
+ **Search for duplicate/similar features:**
103
+ ```bash
104
+ rg "export.*(login|authenticate|signIn)" --type ts -l
105
+ ```
106
+
107
+ **Include in sync report:**
88
108
 
89
- **Compare docs against code-graph.json:**
109
+ ### Step 4: Generate Sync Report (From File Search)
110
+
111
+ **Compare docs against actual source files:**
90
112
 
91
113
  ```
92
114
  ## Documentation Sync Report
93
115
 
94
- ### Signature Changes (from code-graph.json)
95
- - `docs/api/users.mdx`: Function signature changed
116
+ ### Signature Changes (from source files)
117
+ - `docs/api/users.mdx` vs `src/lib/users.ts`:
96
118
  - Documented: `createUser(name, email)`
97
- - Code-graph: `createUser(options: CreateUserInput)`
119
+ - Source file: `createUser(options: CreateUserInput)`
120
+ - Action: Update signature and params
98
121
 
99
- ### New Exports (in code-graph, not in docs)
100
- - Module `auth`: `refreshToken()` - Not documented
101
- - Module `users`: `deleteUser()` - Not documented
102
- - Type: `SessionConfig` - Not documented
103
-
104
- ### Removed (in docs, not in code-graph)
105
- - `legacyAuth()` - Removed from codebase
106
- - Type: `OldUserFormat` - No longer exists
122
+ ### New Exports (in source, not in docs)
123
+ - `src/lib/auth.ts`: `refreshToken()` - Not documented
124
+ - `src/lib/users.ts`: `deleteUser()` - Not documented
107
125
 
108
- ### Type Changes
109
- - `User` interface: Added `role` property
110
- - `AuthToken`: Changed `expiresAt` type
111
-
112
- ### New Endpoints (from code-graph.api.endpoints)
113
- - `POST /api/v2/webhooks` - Not documented
126
+ ### Removed (in docs, not in source)
127
+ - `legacyAuth()` - Not found in any source file
114
128
 
115
129
  ### Up to Date ✓
116
- - `docs/guides/authentication.mdx`
117
- - `docs/api/errors.mdx`
130
+ - `docs/guides/authentication.mdx` matches `src/lib/auth/`
131
+
132
+ ### Unable to Verify (source not found)
133
+ ⚠️ `docs/legacy/old-api.mdx` - No matching source file
134
+
135
+ ═══════════════════════════════════════════════════════════
136
+ FEATURE FLAGS DETECTED
137
+ ═══════════════════════════════════════════════════════════
138
+
139
+ ⚠️ src/lib/auth/index.ts:45 - newAuthFlow
140
+ Current docs: OLD implementation
141
+ Feature flag: NEW implementation available
142
+
143
+ Question: Update docs to which version?
144
+ 1. Keep current (old)
145
+ 2. Update to new (feature-flagged)
146
+ 3. Document both with toggle notice
147
+
148
+ ═══════════════════════════════════════════════════════════
149
+ DUPLICATE FEATURES
150
+ ═══════════════════════════════════════════════════════════
151
+
152
+ 🔄 Similar functions found:
153
+ - src/lib/auth/login.ts → login()
154
+ - src/lib/auth/v2/authenticate.ts → authenticate()
155
+
156
+ Question: How to handle?
157
+ 1. Document primary only
158
+ 2. Document all with comparison
159
+ 3. Mark duplicates as deprecated
118
160
  ```
119
161
 
120
162
  Ask: "How would you like to proceed?
121
- 1. **Fix all** - Update everything automatically
122
- 2. **Interactive** - Review each change
163
+ 1. **Fix all** - Update everything (choose defaults for flags/duplicates)
164
+ 2. **Interactive** - Review each change with me
123
165
  3. **Specific items** - Tell me which to fix
124
- 4. **Refresh code-graph first** - Re-scan codebase before updating"
166
+ 4. **Re-search** - Search for different file patterns"
167
+
168
+ ### Step 5: Review Each Change with User (MANDATORY)
169
+
170
+ **For EACH file being updated, show before/after:**
171
+
172
+ ```
173
+ ═══════════════════════════════════════════════════════════
174
+ CHANGE REVIEW: docs/api/users.mdx
175
+ ═══════════════════════════════════════════════════════════
176
+
177
+ 📄 BEFORE (current):
178
+ ───────────────────────────────────────────────────────────
179
+ ## createUser(name, email)
125
180
 
126
- ### Step 4: Propose Changes
181
+ Creates a new user account.
127
182
 
128
- Before making changes, show what will be modified:
183
+ | Parameter | Type |
184
+ |-----------|------|
185
+ | name | string |
186
+ | email | string |
187
+ ───────────────────────────────────────────────────────────
129
188
 
130
- "I'll make these changes:
189
+ 📄 AFTER (proposed):
190
+ ───────────────────────────────────────────────────────────
191
+ ## createUser(options)
131
192
 
132
- **`docs/api/users.mdx`**
133
- - Update `createUser` signature and examples
134
- - Add new `options` parameter documentation
193
+ Creates a new user account.
135
194
 
136
- **`docs/quickstart.mdx`**
137
- - Update version from 1.2.0 to 2.0.0
138
- - Update installation command
195
+ | Parameter | Type | Description |
196
+ |-----------|------|-------------|
197
+ | options | CreateUserInput | User creation options |
139
198
 
140
- **`docs.json`**
141
- - Add new page: `guides/webhooks.mdx`
199
+ ### CreateUserInput
142
200
 
143
- Proceed with these changes?"
201
+ | Property | Type | Required |
202
+ |----------|------|----------|
203
+ | name | string | Yes |
204
+ | email | string | Yes |
205
+ | role | 'admin' \| 'user' | No |
206
+ ───────────────────────────────────────────────────────────
144
207
 
145
- ### Step 5: Apply Updates
208
+ ⚠️ NOTICES:
209
+ - Source: src/lib/users.ts:23
210
+ - Feature flag: None
211
+ - Duplicates: None
146
212
 
147
- When updating:
213
+ OPTIONS:
214
+ 1. ✅ **Approve** - Apply this change
215
+ 2. ✏️ **Edit** - Modify the proposed content
216
+ 3. ⏭️ **Skip** - Don't update this file
217
+ 4. ❌ **Cancel all** - Stop updating
218
+
219
+ Choose an option:
220
+ ```
221
+
222
+ ### Step 6: Apply Updates (After Approval)
223
+
224
+ **Only after user approves each change:**
148
225
 
149
226
  1. **Preserve prose** - Keep explanations, update technical details
150
227
  2. **Update code examples** - Match current signatures
@@ -156,7 +233,13 @@ When updating:
156
233
  See [migration guide](/guides/v2-migration).
157
234
  </Warning>
158
235
  ```
159
- 5. **Create stubs** for new features:
236
+ 5. **Add feature flag notices** where applicable:
237
+ ```mdx
238
+ <Note>
239
+ **Feature Flag**: This feature requires `newAuthFlow` to be enabled.
240
+ </Note>
241
+ ```
242
+ 6. **Create stubs** for new features:
160
243
  ```mdx
161
244
  {/* TODO: Document this new feature */}
162
245
  ## New Feature
@@ -234,11 +317,27 @@ Documentation coming soon.
234
317
 
235
318
  ---
236
319
 
320
+ ## Key Principles
321
+
322
+ | Principle | Description |
323
+ |-----------|-------------|
324
+ | **Search before update** | ALWAYS read source files before changing docs |
325
+ | **No hallucination** | Only update based on actual file contents |
326
+ | **Review before write** | ALWAYS show before/after for user approval |
327
+ | **Flag feature flags** | Detect and highlight conditional features |
328
+ | **Flag duplicates** | Identify similar/related features |
329
+ | **Verify changes** | Read source to confirm what changed |
330
+
237
331
  ## Quality Guidelines
238
332
 
333
+ - **SEARCH FIRST** - Read source files before making any update
334
+ - **REVIEW WITH USER** - Show before/after for each change
335
+ - **DETECT FEATURE FLAGS** - Search for conditional features
336
+ - **DETECT DUPLICATES** - Find similar functions/features
239
337
  - Always show changes before applying
240
338
  - Preserve existing prose and explanations
241
339
  - Update only technical details (code, versions, signatures)
340
+ - Flag when source file not found - offer auto-correct options
242
341
  - Add TODO markers for human review
243
342
  - Apply terminology from context.json
244
343
  - Create stubs rather than skip new features
@@ -63,16 +63,41 @@ What is the primary goal?
63
63
  5. **Inform stakeholders** - Architecture/decisions
64
64
  ```
65
65
 
66
- #### Question 2: Primary Audience
66
+ #### Question 2: Audience & Roles
67
67
  ```
68
- Who is your PRIMARY audience?
68
+ Does your product have multiple user roles?
69
69
 
70
- 1. **Internal Developer** Code flow, architecture, debugging
71
- 2. **External Developer** Quick start, auth, code examples
70
+ A) **Single audience** - All users have same access
71
+ B) **Multiple roles** - Different users see different features
72
+ (e.g., Admin/Editor/Viewer, different permission levels)
73
+ ```
74
+
75
+ **If Single (A):**
76
+ ```
77
+ 1. **Internal Developer** → Code flow, architecture
78
+ 2. **External Developer** → Quick start, auth, examples
72
79
  3. **Product User** → Tutorials, feature guides
73
80
  4. **Content Author** → MDX syntax, structure
74
81
  ```
75
82
 
83
+ **If Multi-role (B):**
84
+ ```
85
+ Define your roles:
86
+ ┌─────────────────┬────────────────────────────┐
87
+ │ Role │ Features/Permissions │
88
+ ├─────────────────┼────────────────────────────┤
89
+ │ Admin │ All features, user mgmt │
90
+ │ Editor │ Create/edit content │
91
+ │ Viewer │ Read-only access │
92
+ │ Developer │ API access, webhooks │
93
+ └─────────────────┴────────────────────────────┘
94
+
95
+ How to organize role-specific content?
96
+ 1. **Separate sections** - admin/, users/, developers/
97
+ 2. **Inline badges** - <RoleBadge roles={["admin"]}>
98
+ 3. **Hybrid** - Both approaches
99
+ ```
100
+
76
101
  #### Question 3: Documentation Domain
77
102
  ```
78
103
  1. **API Docs** - Voice: Professional, code-focused
@@ -241,31 +266,129 @@ Create `.devdoc/context.json`:
241
266
  }
242
267
  ```
243
268
 
244
- ### Step 7: Generate Using Writing Guidelines
269
+ ### Step 7: Generate WITH File Search (CRITICAL)
245
270
 
246
271
  **Only after user approval in Step 5.**
247
272
 
273
+ **For EACH page in the content plan:**
274
+
275
+ ```
276
+ 1. SEARCH for relevant files
277
+ git ls-files | grep -iE "(auth|login|token)"
278
+ rg -l "authentication" --type ts
279
+
280
+ 2. READ the files found
281
+ - Extract real signatures, types, examples
282
+ - Note the source files
283
+
284
+ 3. DETECT feature flags & duplicates
285
+ rg -l "featureFlag|isEnabled|FF_" --type ts
286
+ rg "export.*(login|authenticate)" --type ts -l
287
+
288
+ ⚠️ FEATURE FLAG: newAuthFlow
289
+ OLD vs NEW implementation
290
+ → Ask user which to document
291
+
292
+ 🔄 DUPLICATE: authenticate() in v2/
293
+ → Ask user how to handle
294
+
295
+ 4. ASSESS if enough info exists
296
+ ✅ Sufficient → Draft content
297
+ ⚠️ Partial → Draft with TODOs
298
+ ❌ Insufficient → Flag and offer options
299
+
300
+ 5. REVIEW DRAFT with user (MANDATORY)
301
+ ═══════════════════════════════════
302
+ CONTENT REVIEW: authentication.mdx
303
+ ═══════════════════════════════════
304
+
305
+ [Show full draft content]
306
+
307
+ NOTICES:
308
+ ⚠️ Feature flag: newAuthFlow
309
+ 🔄 Duplicate: authenticate() in v2/
310
+
311
+ OPTIONS:
312
+ 1. ✅ Approve - Create file
313
+ 2. ✏️ Edit - Make changes
314
+ 3. 🔄 Switch version - Use flagged version
315
+ 4. ➕ Add duplicate - Include related
316
+ 5. ⏭️ Skip - Don't create
317
+
318
+ 6. WRITE only after user approves
319
+ ```
320
+
248
321
  **Expert Writing Standards:**
249
- 1. **Second Person** - "You can configure..."
250
- 2. **Active Voice** - "Run the command"
251
- 3. **Task-Oriented Headings** - "How to add..."
252
- 4. **Include Examples** - Every concept
253
- 5. **Progressive Disclosure** - Basic Advanced
322
+ 1. **Search before write** - ALWAYS find source files first
323
+ 2. **No hallucination** - Only real data from files
324
+ 3. **Review with user** - Show draft before creating
325
+ 4. **Flag feature flags** - Ask which version
326
+ 5. **Flag duplicates** - Let user choose
327
+ 6. **Second Person** - "You can configure..."
328
+ 7. **Include REAL Examples** - From tests/examples
329
+ 8. **Use Mermaid Diagrams** - For architecture, flows, sequences
330
+
331
+ **Mermaid Diagram Requirements:**
332
+ | Content | Diagram Type |
333
+ |---------|--------------|
334
+ | Architecture | `flowchart TB` |
335
+ | Data flow | `flowchart LR` |
336
+ | API calls | `sequenceDiagram` |
337
+ | State machine | `stateDiagram-v2` |
338
+ | Data models | `erDiagram` |
339
+
340
+ Example:
341
+ ```mermaid
342
+ sequenceDiagram
343
+ User->>API: Request
344
+ API->>Service: Process
345
+ Service-->>API: Response
346
+ API-->>User: Result
347
+ ```
254
348
 
255
- ### Step 8: Update docs.json
349
+ ### Step 8: Create docs.json and theme.json
350
+
351
+ **CRITICAL: Read schema files before creating config files.**
352
+
353
+ ```
354
+ 📋 SCHEMA REFERENCES (Read before writing)
355
+
356
+ 1. schemas/docs.schema.json → docs.json structure
357
+ 2. schemas/theme.schema.json → theme.json structure
358
+ ```
359
+
360
+ **Review config with user before writing:**
361
+
362
+ ```
363
+ ═══════════════════════════════════════════════════
364
+ CONFIG REVIEW: docs.json
365
+ ═══════════════════════════════════════════════════
256
366
 
257
- ```json
258
367
  {
259
- "docType": "api",
368
+ "$schema": "https://devdoc.sh/docs.json",
369
+ "name": "[Product Name]",
370
+ "docType": "[api|product|internal]",
260
371
  "navigation": {
261
372
  "tabs": [
262
- { "tab": "Guides", "groups": [...] },
263
- { "tab": "API Reference", "type": "openapi", "spec": "api-reference/openapi.json" }
373
+ { "tab": "Guides", "type": "docs", "groups": [...] },
374
+ { "tab": "API Reference", "type": "openapi" }
264
375
  ]
265
376
  }
266
377
  }
378
+
379
+ Validated against: schemas/docs.schema.json ✓
380
+
381
+ OPTIONS:
382
+ 1. ✅ Approve
383
+ 2. ✏️ Edit
384
+ 3. ❌ Cancel
267
385
  ```
268
386
 
387
+ **Quick Reference:**
388
+ - Tab types: `docs`, `openapi`, `graphql`, `changelog`
389
+ - Icons: `rocket-launch`, `book-open`, `code`, `gear`, `terminal`, `star`
390
+ - Colors: indigo (#6366f1), blue (#3b82f6), green (#10b981)
391
+
269
392
  ### Step 9: Summary
270
393
 
271
394
  ```
@@ -299,8 +422,15 @@ Next: `devdoc dev` to preview
299
422
  | **Project overview first** | Quick git scan to understand structure |
300
423
  | **Strategy first** | Goals and audience before structure |
301
424
  | **Audience-driven** | Match content to user needs |
425
+ | **Support multi-role** | Handle products with multiple user roles |
302
426
  | **Diátaxis types** | Classify every page |
303
427
  | **IA approval required** | User confirms before generating |
428
+ | **Search before generate** | ALWAYS search/read files before each page |
429
+ | **No hallucination** | Only use real data from source files |
430
+ | **Review before write** | ALWAYS show draft for user approval |
431
+ | **Flag feature flags** | Detect conditional features, ask which version |
432
+ | **Flag duplicates** | Find similar features, let user choose |
433
+ | **Flag unclear sections** | Offer auto-correct IA if info not found |
304
434
  | **Expert writing** | 2nd person, active voice |
305
435
  | **Mark unknowns** | Add TODO for review |
306
436