@brainfish-ai/devdoc 0.1.40 → 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.
@@ -100,10 +100,25 @@ What is the primary goal of this documentation?
100
100
  5. **Inform stakeholders** - Communicate architecture and decisions
101
101
  ```
102
102
 
103
- #### Question 2: Primary Audience (WHO)
103
+ #### Question 2: Audiences & Roles (WHO)
104
104
  ```
105
- Who is your PRIMARY audience? (Choose one)
105
+ Who are your documentation audiences?
106
106
 
107
+ ═══════════════════════════════════════════════════════════
108
+ SINGLE vs MULTI-ROLE PRODUCTS
109
+ ═══════════════════════════════════════════════════════════
110
+
111
+ Does your product have multiple user roles with different permissions?
112
+
113
+ A) **Single audience** - All users have same access
114
+ → Example: Open-source library, public API
115
+
116
+ B) **Multiple roles** - Different users see different features
117
+ → Example: SaaS with Admin/User roles, Enterprise with permissions
118
+ ```
119
+
120
+ **If Single Audience (A), choose one:**
121
+ ```
107
122
  1. **Internal Developer** - Engineers on your team
108
123
  → Needs: Code flow, architecture, debugging, contribution guides
109
124
 
@@ -120,6 +135,57 @@ Who is your PRIMARY audience? (Choose one)
120
135
  → Needs: Feature overview, roadmap, IA map
121
136
  ```
122
137
 
138
+ **If Multiple Roles (B), define your role matrix:**
139
+ ```
140
+ ═══════════════════════════════════════════════════════════
141
+ ROLE MATRIX DEFINITION
142
+ ═══════════════════════════════════════════════════════════
143
+
144
+ List your user roles and their permissions:
145
+
146
+ Example for a SaaS product:
147
+ ┌─────────────────┬────────────────────────────────────────┐
148
+ │ Role │ Permissions / Features │
149
+ ├─────────────────┼────────────────────────────────────────┤
150
+ │ Admin │ All features, user management, billing │
151
+ │ Editor │ Create/edit content, limited settings │
152
+ │ Viewer │ Read-only access │
153
+ │ API Developer │ API access, webhooks, integrations │
154
+ └─────────────────┴────────────────────────────────────────┘
155
+
156
+ Your roles:
157
+ 1. Role name: _______
158
+ - Permissions: _______
159
+ - Key features: _______
160
+
161
+ 2. Role name: _______
162
+ - Permissions: _______
163
+ - Key features: _______
164
+
165
+ (Add more as needed)
166
+ ```
167
+
168
+ **For Multi-Role Products, also ask:**
169
+ ```
170
+ How should role-specific content be organized?
171
+
172
+ 1. **Separate sections** - Each role gets its own section/tab
173
+ docs/
174
+ ├── admin/ # Admin-only guides
175
+ ├── users/ # Regular user guides
176
+ └── developers/ # API/developer guides
177
+
178
+ 2. **Inline badges** - Mixed content with role indicators
179
+ <RoleBadge roles={["admin", "editor"]}>
180
+ This feature is only available to Admins and Editors.
181
+ </RoleBadge>
182
+
183
+ 3. **Permission gates** - Content varies by logged-in user
184
+ (Requires auth integration)
185
+
186
+ 4. **Hybrid** - Combination of above
187
+ ```
188
+
123
189
  #### Question 3: Documentation Domain
124
190
  ```
125
191
  What type of documentation are you creating?
@@ -219,6 +285,96 @@ docs/
219
285
  └── troubleshooting/ # [How-To] Problem solving
220
286
  ```
221
287
 
288
+ #### For Multi-Role Products (with separate sections):
289
+ ```
290
+ docs/
291
+ ├── index.mdx # [Explanation] Product overview (all roles)
292
+ ├── getting-started/
293
+ │ ├── quickstart.mdx # [Tutorial] First experience (all roles)
294
+ │ └── key-concepts.mdx # [Explanation] Core concepts (all roles)
295
+
296
+ ├── admin/ # 🔒 ADMIN-ONLY SECTION
297
+ │ ├── overview.mdx # [Explanation] Admin dashboard overview
298
+ │ ├── user-management.mdx # [How-To] Manage users & permissions
299
+ │ ├── billing.mdx # [How-To] Billing & subscriptions
300
+ │ ├── settings.mdx # [Reference] Admin settings
301
+ │ └── audit-logs.mdx # [Reference] Audit & compliance
302
+
303
+ ├── users/ # 👤 REGULAR USER SECTION
304
+ │ ├── overview.mdx # [Explanation] User dashboard
305
+ │ ├── features/ # [How-To] Feature guides
306
+ │ └── account.mdx # [How-To] Account settings
307
+
308
+ ├── developers/ # 💻 DEVELOPER SECTION
309
+ │ ├── overview.mdx # [Explanation] API overview
310
+ │ ├── authentication.mdx # [How-To] API auth
311
+ │ ├── webhooks.mdx # [How-To] Webhook setup
312
+ │ └── api-reference/ # [Reference] API docs
313
+
314
+ └── troubleshooting/ # [How-To] Problem solving (all roles)
315
+ ```
316
+
317
+ #### For Multi-Role Products (with inline badges):
318
+ ```
319
+ When using inline role badges, add to each page's frontmatter:
320
+
321
+ ---
322
+ title: User Management
323
+ description: Add and manage users in your organization
324
+ roles: ["admin", "owner"] # Roles that can access this feature
325
+ ---
326
+
327
+ <RoleBadge roles={["admin", "owner"]}>
328
+ This feature requires Admin or Owner permissions.
329
+ </RoleBadge>
330
+
331
+ ## Overview
332
+
333
+ User management allows you to...
334
+ ```
335
+
336
+ #### Role-Specific Content Patterns:
337
+
338
+ **Pattern 1: Conditional sections within a page**
339
+ ```mdx
340
+ ## Basic Settings
341
+
342
+ All users can configure these settings...
343
+
344
+ <RoleSection roles={["admin"]}>
345
+ ## Advanced Settings (Admin Only)
346
+
347
+ Administrators can additionally configure...
348
+ </RoleSection>
349
+ ```
350
+
351
+ **Pattern 2: Feature availability matrix**
352
+ ```mdx
353
+ ## Feature Availability
354
+
355
+ | Feature | Viewer | Editor | Admin |
356
+ |---------|--------|--------|-------|
357
+ | View dashboards | ✅ | ✅ | ✅ |
358
+ | Edit content | ❌ | ✅ | ✅ |
359
+ | Manage users | ❌ | ❌ | ✅ |
360
+ | Billing access | ❌ | ❌ | ✅ |
361
+ ```
362
+
363
+ **Pattern 3: Navigation tabs by role**
364
+ ```json
365
+ // docs.json with role-based tabs
366
+ {
367
+ "navigation": {
368
+ "tabs": [
369
+ { "tab": "Getting Started", "groups": [...] },
370
+ { "tab": "Admin Guide", "icon": "shield", "groups": [...] },
371
+ { "tab": "User Guide", "icon": "user", "groups": [...] },
372
+ { "tab": "Developer", "icon": "code", "groups": [...] }
373
+ ]
374
+ }
375
+ }
376
+ ```
377
+
222
378
  #### For Internal Docs:
223
379
  ```
224
380
  docs/
@@ -250,8 +406,24 @@ Present the **complete Information Architecture** to the user, covering:
250
406
 
251
407
  Based on your preferences:
252
408
  - Goal: [selected goal]
253
- - Audience: [primary audience]
409
+ - Audience: [primary audience OR "Multi-role"]
254
410
  - Domain: [api/product/internal]
411
+
412
+ [If multi-role, show role matrix:]
413
+ ═══════════════════════════════════════════════════════════════
414
+ USER ROLES
415
+ ═══════════════════════════════════════════════════════════════
416
+
417
+ ┌─────────────────┬────────────────────────────────────────┐
418
+ │ Role │ Documentation Sections │
419
+ ├─────────────────┼────────────────────────────────────────┤
420
+ │ Admin │ admin/, shared sections │
421
+ │ Editor │ users/, shared sections │
422
+ │ Viewer │ users/ (read-only features) │
423
+ │ Developer │ developers/, api-reference/ │
424
+ └─────────────────┴────────────────────────────────────────┘
425
+
426
+ Role organization: [Separate sections | Inline badges | Hybrid]
255
427
 
256
428
  ═══════════════════════════════════════════════════════════════
257
429
  NAVIGATION STRUCTURE
@@ -382,6 +554,8 @@ Does this architecture look complete?
382
554
  ### Step 6: Create Context File (After Approval)
383
555
 
384
556
  Save to `.devdoc/context.json`:
557
+
558
+ **For Single Audience:**
385
559
  ```json
386
560
  {
387
561
  "$schema": "https://devdoc.sh/schemas/context.json",
@@ -391,6 +565,7 @@ Save to `.devdoc/context.json`:
391
565
  "strategy": {
392
566
  "goal": "Support API consumers",
393
567
  "audience": {
568
+ "type": "single",
394
569
  "primary": "External Developer",
395
570
  "needs": ["Quick start", "Authentication", "Code examples", "Reference"]
396
571
  }
@@ -402,54 +577,436 @@ Save to `.devdoc/context.json`:
402
577
  "codeLanguage": "TypeScript"
403
578
  },
404
579
 
405
- "product": {
406
- "name": "Product Name",
407
- "description": "From README",
408
- "type": "api"
409
- },
580
+ "contentPlan": {
581
+ "approved": true,
582
+ "pages": [
583
+ { "path": "index.mdx", "type": "explanation", "priority": "high" },
584
+ { "path": "quickstart.mdx", "type": "tutorial", "priority": "high" }
585
+ ]
586
+ }
587
+ }
588
+ ```
589
+
590
+ **For Multi-Role Products:**
591
+ ```json
592
+ {
593
+ "$schema": "https://devdoc.sh/schemas/context.json",
594
+ "version": "1.0",
595
+ "lastUpdated": "2026-01-25T10:00:00Z",
410
596
 
411
- "api": {
412
- "style": "REST",
413
- "specPath": "api-reference/openapi.json",
414
- "baseUrl": "https://api.example.com"
597
+ "strategy": {
598
+ "goal": "Support all user types",
599
+ "audience": {
600
+ "type": "multi-role",
601
+ "organization": "separate-sections", // or "inline-badges" or "hybrid"
602
+ "roles": [
603
+ {
604
+ "name": "Admin",
605
+ "slug": "admin",
606
+ "permissions": ["all"],
607
+ "features": ["user-management", "billing", "settings", "audit-logs"],
608
+ "docSection": "admin/"
609
+ },
610
+ {
611
+ "name": "Editor",
612
+ "slug": "editor",
613
+ "permissions": ["create", "edit", "delete"],
614
+ "features": ["content-management", "workflows"],
615
+ "docSection": "users/"
616
+ },
617
+ {
618
+ "name": "Viewer",
619
+ "slug": "viewer",
620
+ "permissions": ["read"],
621
+ "features": ["view-content", "search"],
622
+ "docSection": "users/"
623
+ },
624
+ {
625
+ "name": "Developer",
626
+ "slug": "developer",
627
+ "permissions": ["api-access", "webhooks"],
628
+ "features": ["api", "integrations", "webhooks"],
629
+ "docSection": "developers/"
630
+ }
631
+ ]
632
+ }
415
633
  },
416
634
 
417
- "documentation": {
418
- "voice": "professional",
419
- "codeExamples": {
420
- "primaryLanguage": "TypeScript"
421
- }
635
+ "preferences": {
636
+ "docType": "product",
637
+ "codeLanguage": "TypeScript"
422
638
  },
423
639
 
424
640
  "contentPlan": {
425
641
  "approved": true,
426
- "approvedAt": "2026-01-25T10:00:00Z",
427
642
  "pages": [
428
- { "path": "index.mdx", "type": "explanation", "priority": "high", "status": "planned" },
429
- { "path": "quickstart.mdx", "type": "tutorial", "priority": "high", "status": "planned" },
430
- { "path": "authentication.mdx", "type": "how-to", "priority": "high", "status": "planned" },
431
- { "path": "guides/overview.mdx", "type": "explanation", "priority": "medium", "status": "planned" },
432
- { "path": "api-reference/errors.mdx", "type": "reference", "priority": "medium", "status": "planned" }
643
+ // Shared pages (all roles)
644
+ { "path": "index.mdx", "type": "explanation", "roles": ["all"] },
645
+ { "path": "quickstart.mdx", "type": "tutorial", "roles": ["all"] },
646
+
647
+ // Admin-only pages
648
+ { "path": "admin/overview.mdx", "type": "explanation", "roles": ["admin"] },
649
+ { "path": "admin/user-management.mdx", "type": "how-to", "roles": ["admin"] },
650
+ { "path": "admin/billing.mdx", "type": "how-to", "roles": ["admin"] },
651
+
652
+ // User pages (editor, viewer)
653
+ { "path": "users/overview.mdx", "type": "explanation", "roles": ["editor", "viewer"] },
654
+ { "path": "users/content.mdx", "type": "how-to", "roles": ["editor"] },
655
+
656
+ // Developer pages
657
+ { "path": "developers/overview.mdx", "type": "explanation", "roles": ["developer"] },
658
+ { "path": "developers/api-reference/", "type": "reference", "roles": ["developer"] }
433
659
  ]
434
660
  }
435
661
  }
436
662
  ```
437
663
 
438
- ### Step 7: Generate Documentation
664
+ ### Step 7: Generate Documentation (WITH FILE SEARCH)
439
665
 
440
666
  **Only proceed after user has approved the IA structure in Step 5.**
441
667
 
442
- **Use project overview and Diátaxis principles:**
668
+ **CRITICAL: Search and read relevant files BEFORE generating each page.**
669
+
670
+ #### 7a. For EACH Page in the Content Plan:
671
+
672
+ ```
673
+ ┌─────────────────────────────────────────────────────────────────┐
674
+ │ PAGE GENERATION FLOW │
675
+ ├─────────────────────────────────────────────────────────────────┤
676
+ │ │
677
+ │ 1. SEARCH for relevant files │
678
+ │ ↓ │
679
+ │ 2. READ the files found │
680
+ │ ↓ │
681
+ │ 3. ASSESS if enough information exists │
682
+ │ ↓ │
683
+ │ ┌─────────────┐ ┌─────────────────────────────────┐ │
684
+ │ │ Sufficient? │─YES─│ GENERATE content from real data │ │
685
+ │ └──────┬──────┘ └─────────────────────────────────┘ │
686
+ │ │NO │
687
+ │ ↓ │
688
+ │ ┌─────────────────────────────────────────────────────┐ │
689
+ │ │ FLAG and offer options: │ │
690
+ │ │ 1. Auto-correct IA (remove/modify page) │ │
691
+ │ │ 2. Rename page to match what exists │ │
692
+ │ │ 3. Mark as TODO and continue │ │
693
+ │ │ 4. Ask user for clarification │ │
694
+ │ └─────────────────────────────────────────────────────┘ │
695
+ │ │
696
+ └─────────────────────────────────────────────────────────────────┘
697
+ ```
698
+
699
+ #### 7b. File Search Strategy (Per Page)
700
+
701
+ **Before generating each page, search for relevant source files:**
702
+
703
+ ```bash
704
+ # For authentication.mdx - search auth-related files
705
+ git ls-files | grep -iE "(auth|login|session|jwt|token|credential)"
706
+
707
+ # For quickstart.mdx - search for README, examples, getting started
708
+ git ls-files | grep -iE "(readme|example|getting.?started|quickstart)"
709
+
710
+ # For errors.mdx - search for error handling
711
+ git ls-files | grep -iE "(error|exception|fault|handler)"
712
+
713
+ # For API reference - search for route handlers, controllers
714
+ git ls-files | grep -iE "(route|controller|handler|endpoint|api)"
715
+ ```
716
+
717
+ **Also search file contents:**
718
+ ```bash
719
+ # Search for specific terms in code
720
+ rg -l "authentication" --type ts
721
+ rg -l "class.*Error" --type ts
722
+ rg -l "export.*function" src/
723
+ ```
724
+
725
+ #### 7c. Read and Extract Information
726
+
727
+ **For each relevant file found:**
728
+
729
+ 1. **Read the file** - Get actual implementation details
730
+ 2. **Extract key information:**
731
+ - Function signatures and parameters
732
+ - Configuration options
733
+ - Error codes and messages
734
+ - Code examples from tests/examples folders
735
+ 3. **Note the source** - Reference where info came from
736
+
737
+ #### 7d. Detect Feature Flags & Duplicates
738
+
739
+ **Search for feature flags:**
740
+ ```bash
741
+ rg -l "featureFlag|feature_flag|isEnabled|FF_" --type ts
742
+ rg "if.*\(.*feature|process\.env\.FEATURE" --type ts
743
+ ```
744
+
745
+ **Search for duplicate features:**
746
+ ```bash
747
+ rg "export.*(login|authenticate|signIn)" --type ts -l
748
+ ```
749
+
750
+ **Flag for user guidance:**
751
+ ```
752
+ ⚠️ FEATURE FLAGS DETECTED for [page]:
753
+
754
+ 📍 src/lib/auth/index.ts:45
755
+ Feature: newAuthFlow
756
+ - OLD implementation: lines 50-80 (current)
757
+ - NEW implementation: lines 82-120 (behind flag)
758
+
759
+ Question: Which version to document?
760
+ 1. Current (old) - stable
761
+ 2. New (flagged) - upcoming
762
+ 3. Both with notice
763
+
764
+ 🔄 DUPLICATE FEATURES DETECTED:
765
+
766
+ Similar to [page]:
767
+ - src/lib/auth/v2/authenticate.ts → authenticate()
768
+ - src/lib/legacy/signIn.ts → signIn()
769
+
770
+ Question: How to handle?
771
+ 1. Document primary only
772
+ 2. Document all with links
773
+ 3. Mark legacy as deprecated
774
+ ```
775
+
776
+ #### 7e. Assess Information Sufficiency
777
+
778
+ **Before writing, evaluate:**
779
+
780
+ | Assessment | Criteria | Action |
781
+ |------------|----------|--------|
782
+ | ✅ **Sufficient** | Found source files, clear implementation | Generate with real data |
783
+ | ⚠️ **Partial** | Some files found, gaps exist | Generate with TODOs for gaps |
784
+ | ❌ **Insufficient** | No relevant files, unclear | Flag and offer options |
785
+
786
+ #### 7e. Handle Unclear Sections
787
+
788
+ **If information is insufficient, present options:**
789
+
790
+ ```
791
+ ⚠️ UNCLEAR SECTION DETECTED
792
+
793
+ Page: authentication.mdx
794
+ Issue: Could not find authentication implementation files.
795
+
796
+ Searched for:
797
+ - **/auth/** → Not found
798
+ - **/*auth*.ts → Not found
799
+ - src/middleware/auth* → Not found
800
+
801
+ Options:
802
+ 1. 🔄 **Auto-correct IA** - Remove this page from the plan
803
+ 2. ✏️ **Rename page** - Change to match what exists (e.g., "api-keys.mdx")
804
+ 3. 📝 **Mark as TODO** - Create placeholder, document later
805
+ 4. ❓ **Ask for path** - "Where is authentication implemented?"
806
+
807
+ Choose an option (1-4):
808
+ ```
809
+
810
+ #### 7g. Review Content with User (MANDATORY)
811
+
812
+ **For EACH page, show draft content for approval before writing:**
813
+
814
+ ```
815
+ ═══════════════════════════════════════════════════════════
816
+ CONTENT REVIEW: authentication.mdx
817
+ ═══════════════════════════════════════════════════════════
818
+
819
+ 📂 SOURCES USED:
820
+ ✓ src/lib/auth/index.ts (main auth module)
821
+ ✓ src/lib/auth/jwt.ts (JWT handling)
822
+ ✓ examples/auth-example.ts (code example)
823
+
824
+ ───────────────────────────────────────────────────────────
825
+ DRAFT CONTENT
826
+ ───────────────────────────────────────────────────────────
827
+
828
+ ---
829
+ title: Authentication
830
+ description: Secure your application with JWT authentication
831
+ sources: ["src/lib/auth/index.ts", "src/lib/auth/jwt.ts"]
832
+ ---
833
+
834
+ ## Overview
835
+
836
+ Authentication in this project uses JWT tokens...
837
+
838
+ ## login(email, password)
839
+
840
+ Authenticate user and receive a JWT token.
841
+
842
+ | Parameter | Type | Description |
843
+ |-----------|------|-------------|
844
+ | email | string | User email |
845
+ | password | string | User password |
846
+
847
+ **Returns:** `Promise<AuthToken>`
848
+
849
+ ### Example
850
+
851
+ ```typescript
852
+ import { login } from '@package/auth';
853
+ const token = await login('user@example.com', 'password');
854
+ ```
855
+
856
+ ───────────────────────────────────────────────────────────
857
+ NOTICES
858
+ ───────────────────────────────────────────────────────────
859
+
860
+ ⚠️ FEATURE FLAG: newAuthFlow
861
+ Documenting: OLD implementation (current default)
862
+ Alternative: New OAuth flow behind flag
863
+
864
+ 🔄 DUPLICATE: authenticate() exists in v2/
865
+ This doc covers: login() (primary)
866
+
867
+ ───────────────────────────────────────────────────────────
868
+ OPTIONS
869
+ ───────────────────────────────────────────────────────────
870
+
871
+ 1. ✅ **Approve** - Create this file
872
+ 2. ✏️ **Edit** - Tell me what to change
873
+ 3. 🔄 **Switch version** - Document flagged version
874
+ 4. ➕ **Add duplicate** - Include related feature
875
+ 5. ⏭️ **Skip** - Don't create this page
876
+ 6. ❌ **Cancel** - Stop all generation
877
+
878
+ Choose an option:
879
+ ```
880
+
881
+ **Only proceed to write after user approves.**
882
+
883
+ #### 7h. Generate With Real Data (After Approval)
884
+
885
+ **Only generate content from actual source files:**
886
+
887
+ ```
888
+ 📄 CREATING: authentication.mdx (APPROVED)
889
+
890
+ Writing file with:
891
+ - Auth methods: login(), logout(), verifyToken()
892
+ - Config options: JWT_SECRET, TOKEN_EXPIRY
893
+ - Example code from examples/auth-example.ts
894
+
895
+ ✓ File created successfully
896
+ ```
443
897
 
444
898
  #### Writing Guidelines (Expert Standards)
445
899
 
446
900
  1. **Use Second Person** - "You can configure..." not "Users can configure..."
447
901
  2. **Active Voice** - "Run the command" not "The command should be run"
448
902
  3. **Task-Oriented Headings** - "How to add a custom domain" not "Custom domains"
449
- 4. **Include Examples** - Every concept needs a code example
903
+ 4. **Include Examples** - Use REAL examples from codebase, not fabricated
450
904
  5. **Progressive Disclosure** - Basic → Advanced ordering
905
+ 6. **Cite Sources** - Note which files information came from
906
+ 7. **Use Mermaid Diagrams** - For architecture, flows, sequences, and relationships
907
+
908
+ #### Mermaid Diagram Guidelines (REQUIRED for visual content)
451
909
 
452
- #### Page Structure by Content Type
910
+ **ALWAYS use mermaid diagrams for:**
911
+
912
+ | Content Type | Diagram Type | When to Use |
913
+ |--------------|--------------|-------------|
914
+ | Architecture | `flowchart` | System components, module relationships |
915
+ | Data Flow | `flowchart LR` | How data moves through the system |
916
+ | Sequence | `sequenceDiagram` | API calls, request/response flows |
917
+ | State | `stateDiagram-v2` | State machines, lifecycle |
918
+ | Entity Relationships | `erDiagram` | Database schemas, data models |
919
+ | Class Structure | `classDiagram` | OOP relationships, interfaces |
920
+ | User Journey | `journey` | User flows, onboarding steps |
921
+
922
+ **Mermaid Examples:**
923
+
924
+ ```mdx
925
+ ## Architecture Overview
926
+
927
+ ```mermaid
928
+ flowchart TB
929
+ subgraph Client
930
+ UI[Web App]
931
+ SDK[SDK]
932
+ end
933
+
934
+ subgraph API
935
+ Gateway[API Gateway]
936
+ Auth[Auth Service]
937
+ Core[Core Service]
938
+ end
939
+
940
+ subgraph Data
941
+ DB[(Database)]
942
+ Cache[(Redis)]
943
+ end
944
+
945
+ UI --> Gateway
946
+ SDK --> Gateway
947
+ Gateway --> Auth
948
+ Gateway --> Core
949
+ Core --> DB
950
+ Core --> Cache
951
+ ```
952
+
953
+ ## Authentication Flow
954
+
955
+ ```mermaid
956
+ sequenceDiagram
957
+ participant User
958
+ participant App
959
+ participant API
960
+ participant Auth
961
+
962
+ User->>App: Login request
963
+ App->>API: POST /auth/login
964
+ API->>Auth: Validate credentials
965
+ Auth-->>API: JWT token
966
+ API-->>App: Token response
967
+ App-->>User: Logged in
968
+ ```
969
+
970
+ ## Request Lifecycle
971
+
972
+ ```mermaid
973
+ stateDiagram-v2
974
+ [*] --> Pending
975
+ Pending --> Processing: Start
976
+ Processing --> Completed: Success
977
+ Processing --> Failed: Error
978
+ Failed --> Pending: Retry
979
+ Completed --> [*]
980
+ ```
981
+
982
+ ## Data Model
983
+
984
+ ```mermaid
985
+ erDiagram
986
+ User ||--o{ Document : creates
987
+ User {
988
+ string id PK
989
+ string email
990
+ string name
991
+ }
992
+ Document {
993
+ string id PK
994
+ string title
995
+ string content
996
+ string userId FK
997
+ }
998
+ ```
999
+ ```
1000
+
1001
+ **When to include diagrams:**
1002
+ - Architecture overview pages → flowchart
1003
+ - API documentation → sequenceDiagram
1004
+ - Feature explanations → flowchart or stateDiagram
1005
+ - Database/data model docs → erDiagram
1006
+ - Integration guides → sequenceDiagram
1007
+ - Onboarding flows → journey
1008
+
1009
+ #### Page Templates (Use After File Search)
453
1010
 
454
1011
  **Tutorial Template:**
455
1012
  ```mdx
@@ -457,26 +1014,21 @@ Save to `.devdoc/context.json`:
457
1014
  title: Build [Something] with [Technology]
458
1015
  description: A complete tutorial to [achieve outcome] from scratch
459
1016
  contentType: tutorial
1017
+ sources: ["README.md", "examples/basic.ts"] # Files used as reference
460
1018
  ---
461
1019
 
462
1020
  ## What You'll Build
463
-
464
- [End result description + estimated time]
1021
+ [Based on actual example from examples/ folder]
465
1022
 
466
1023
  ## Prerequisites
467
-
468
- <Note>Before you begin, ensure you have: [requirements]</Note>
1024
+ [From package.json dependencies and README]
469
1025
 
470
1026
  ## Steps
471
-
472
1027
  <Steps>
473
- <Step title="Step 1">Content</Step>
474
- <Step title="Step 2">Content</Step>
1028
+ <Step title="Step 1">[Real code from source files]</Step>
475
1029
  </Steps>
476
1030
 
477
1031
  ## Next Steps
478
-
479
- [Links to related content]
480
1032
  ```
481
1033
 
482
1034
  **How-To Guide Template:**
@@ -485,25 +1037,19 @@ contentType: tutorial
485
1037
  title: How to [Achieve Specific Goal]
486
1038
  description: Learn how to [specific outcome]
487
1039
  contentType: how-to
1040
+ sources: ["src/lib/feature.ts"]
488
1041
  ---
489
1042
 
490
1043
  ## Overview
491
-
492
- [2-3 sentences: What, Who, Why]
493
-
494
- ## Prerequisites (if applicable)
1044
+ [From source file docstrings/comments]
495
1045
 
496
1046
  ## Steps
497
-
498
1047
  <Steps>
499
- <Step title="[Action verb] [object]">Content</Step>
1048
+ <Step title="[Action]">[Actual implementation steps]</Step>
500
1049
  </Steps>
501
1050
 
502
1051
  ## Example
503
-
504
- [Complete working example]
505
-
506
- ## Next Steps
1052
+ [Real code from tests or examples]
507
1053
  ```
508
1054
 
509
1055
  **Reference Template:**
@@ -512,23 +1058,18 @@ contentType: how-to
512
1058
  title: [Component/API/Config] Reference
513
1059
  description: Complete reference for [topic]
514
1060
  contentType: reference
1061
+ sources: ["src/types/config.ts", "src/lib/api.ts"]
515
1062
  ---
516
1063
 
517
- ## Overview
518
-
519
- [Brief description]
520
-
521
1064
  ## Properties/Parameters
1065
+ [Extracted from actual TypeScript interfaces/types]
522
1066
 
523
1067
  | Property | Type | Description | Default |
524
1068
  |----------|------|-------------|---------|
525
- | ... | ... | ... | ... |
1069
+ [From real type definitions]
526
1070
 
527
1071
  ## Examples
528
-
529
- ## Related
530
-
531
- [Links to related references]
1072
+ [From tests or examples folder]
532
1073
  ```
533
1074
 
534
1075
  **Explanation Template:**
@@ -537,60 +1078,144 @@ contentType: reference
537
1078
  title: Understanding [Concept]
538
1079
  description: Deep dive into [topic] and how it works
539
1080
  contentType: explanation
1081
+ sources: ["docs/architecture.md", "src/lib/core/"]
540
1082
  ---
541
1083
 
542
- ## Overview
1084
+ ## How It Works
1085
+ [From actual implementation, not made up]
543
1086
 
544
- [Why this matters]
1087
+ ## Key Concepts
1088
+ [Based on real code patterns found]
1089
+ ```
545
1090
 
546
- ## How It Works
1091
+ ### Step 8: Create/Update docs.json and theme.json
547
1092
 
548
- [Conceptual explanation with diagrams]
1093
+ **CRITICAL: Read schema files before creating configuration files.**
549
1094
 
550
- ## Key Concepts
1095
+ #### 8a. Read Schema References (MANDATORY)
1096
+
1097
+ Before creating or updating `docs.json` or `theme.json`, ALWAYS read the schema files:
1098
+
1099
+ ```
1100
+ 📋 SCHEMA REFERENCES
551
1101
 
552
- ## When to Use
1102
+ Read these files before writing configuration:
553
1103
 
554
- ## Related
1104
+ 1. .claude/skills/bootstrap-docs/../../schemas/docs.schema.json
1105
+ → Full schema for docs.json with all valid properties
1106
+ → Tab types: docs, openapi, graphql, changelog
1107
+ → Group structure and icon options
1108
+ → API and SEO configuration
555
1109
 
556
- [Links to tutorials and how-tos that apply this concept]
1110
+ 2. .claude/skills/bootstrap-docs/../../schemas/theme.schema.json
1111
+ → Full schema for theme.json with all valid properties
1112
+ → Logo configuration options
1113
+ → Color presets (indigo, blue, green, amber, etc.)
1114
+ → Header and navbar options
557
1115
  ```
558
1116
 
559
- ### Step 8: Update docs.json
1117
+ **Schema file locations:**
1118
+ - `packages/devdoc/ai-agents/schemas/docs.schema.json`
1119
+ - `packages/devdoc/ai-agents/schemas/theme.schema.json`
560
1120
 
561
- Configure navigation based on doc type:
1121
+ #### 8b. Review Configuration Before Writing (MANDATORY)
1122
+
1123
+ **Show proposed configuration for user approval:**
1124
+
1125
+ ```
1126
+ ═══════════════════════════════════════════════════════════
1127
+ CONFIG REVIEW: docs.json
1128
+ ═══════════════════════════════════════════════════════════
562
1129
 
563
- **API Docs with OpenAPI:**
564
- ```json
565
1130
  {
566
- "name": "Product Name",
567
- "docType": "api",
1131
+ "$schema": "https://devdoc.sh/docs.json",
1132
+ "name": "[Product Name]",
1133
+ "docType": "[api|product|internal]",
1134
+ "favicon": "/favicon.svg",
568
1135
  "navigation": {
569
1136
  "tabs": [
570
1137
  {
571
1138
  "tab": "Guides",
1139
+ "type": "docs",
572
1140
  "groups": [
573
1141
  {
574
1142
  "group": "Getting Started",
575
1143
  "icon": "rocket-launch",
576
1144
  "pages": ["index", "quickstart", "authentication"]
577
- },
578
- {
579
- "group": "Guides",
580
- "icon": "book-open",
581
- "pages": ["guides/overview"]
582
1145
  }
583
1146
  ]
584
- },
585
- {
586
- "tab": "API Reference",
587
- "type": "openapi",
588
- "spec": "api-reference/openapi.json"
589
1147
  }
590
1148
  ]
591
1149
  }
592
1150
  }
1151
+
1152
+ ───────────────────────────────────────────────────────────
1153
+ Validated against: schemas/docs.schema.json ✓
1154
+
1155
+ OPTIONS:
1156
+ 1. ✅ Approve - Create this file
1157
+ 2. ✏️ Edit - Make changes
1158
+ 3. ❌ Cancel
1159
+ ```
1160
+
593
1161
  ```
1162
+ ═══════════════════════════════════════════════════════════
1163
+ CONFIG REVIEW: theme.json
1164
+ ═══════════════════════════════════════════════════════════
1165
+
1166
+ {
1167
+ "$schema": "https://devdoc.sh/theme.json",
1168
+ "logo": {
1169
+ "light": "/assets/logo/light.svg",
1170
+ "dark": "/assets/logo/dark.svg",
1171
+ "alt": "[Product Name]",
1172
+ "width": 120
1173
+ },
1174
+ "colors": {
1175
+ "primary": "#6366f1",
1176
+ "primaryLight": "#818cf8",
1177
+ "primaryDark": "#4f46e5"
1178
+ },
1179
+ "header": {
1180
+ "showAskAI": true,
1181
+ "showSearch": true,
1182
+ "showThemeToggle": true
1183
+ }
1184
+ }
1185
+
1186
+ ───────────────────────────────────────────────────────────
1187
+ Validated against: schemas/theme.schema.json ✓
1188
+ Color preset used: indigo
1189
+
1190
+ OPTIONS:
1191
+ 1. ✅ Approve - Create this file
1192
+ 2. ✏️ Edit - Make changes
1193
+ 3. 🎨 Change colors - Pick different preset
1194
+ 4. ❌ Cancel
1195
+ ```
1196
+
1197
+ #### 8c. Quick Reference (from schemas)
1198
+
1199
+ **docs.json Tab Types:**
1200
+ | Type | Description |
1201
+ |------|-------------|
1202
+ | `docs` | MDX documentation pages |
1203
+ | `openapi` | Auto-generated API reference |
1204
+ | `graphql` | GraphQL schema documentation |
1205
+ | `changelog` | Changelog entries |
1206
+
1207
+ **Common Phosphor Icons:**
1208
+ `rocket-launch`, `book-open`, `code`, `gear`, `terminal`, `puzzle-piece`, `star`, `shield`, `user`, `robot`, `github-logo`, `discord-logo`
1209
+
1210
+ **theme.json Color Presets:**
1211
+ | Preset | Primary |
1212
+ |--------|---------|
1213
+ | indigo | #6366f1 |
1214
+ | blue | #3b82f6 |
1215
+ | green | #10b981 |
1216
+ | amber | #f59e0b |
1217
+ | purple | #8b5cf6 |
1218
+ | pink | #ec4899 |
594
1219
 
595
1220
  ### Step 9: Summary
596
1221
 
@@ -630,6 +1255,12 @@ Next steps:
630
1255
  | **Audience-driven** | Match content to user needs |
631
1256
  | **Diátaxis types** | Classify every page by content type |
632
1257
  | **IA approval required** | Always get user approval before generating content |
1258
+ | **Search before generate** | ALWAYS search/read relevant files before writing each page |
1259
+ | **No hallucination** | Only use real data from source files, never fabricate |
1260
+ | **Review before write** | ALWAYS show draft content for user approval |
1261
+ | **Flag feature flags** | Detect conditional features, ask which version to document |
1262
+ | **Flag duplicates** | Identify similar features, let user choose |
1263
+ | **Flag unclear sections** | If info not found, offer auto-correct IA options |
633
1264
  | **Expert writing** | Second person, active voice, task-oriented |
634
1265
  | **Mark unknowns** | Add TODO for sections needing review |
635
1266