@brainfish-ai/devdoc 0.1.32 → 0.1.34

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 (35) hide show
  1. package/ai-agents/.claude/skills/blame-doc/SKILL.md +171 -0
  2. package/ai-agents/.claude/skills/bootstrap-docs/SKILL.md +519 -64
  3. package/ai-agents/.claude/skills/check-docs/SKILL.md +107 -12
  4. package/ai-agents/.claude/skills/commit-doc/SKILL.md +214 -0
  5. package/ai-agents/.claude/skills/create-doc/SKILL.md +198 -0
  6. package/ai-agents/.claude/skills/delete-doc/SKILL.md +164 -0
  7. package/ai-agents/.claude/skills/update-doc/SKILL.md +219 -0
  8. package/ai-agents/.cursor/rules/devdoc-blame.mdc +114 -0
  9. package/ai-agents/.cursor/rules/devdoc-bootstrap.mdc +207 -41
  10. package/ai-agents/.cursor/rules/devdoc-commit.mdc +103 -0
  11. package/ai-agents/.cursor/rules/devdoc-create.mdc +89 -0
  12. package/ai-agents/.cursor/rules/devdoc-delete.mdc +101 -0
  13. package/ai-agents/.cursor/rules/devdoc-update.mdc +95 -0
  14. package/ai-agents/.devdoc/context.json +66 -0
  15. package/ai-agents/.devdoc/templates/api-reference.md +211 -0
  16. package/ai-agents/.devdoc/templates/guide.md +133 -0
  17. package/ai-agents/.devdoc/templates/quickstart.md +179 -0
  18. package/ai-agents/.devdoc/templates/troubleshooting.md +215 -0
  19. package/ai-agents/.devdoc/templates/tutorial.md +212 -0
  20. package/ai-agents/CLAUDE.md +15 -3
  21. package/ai-agents/schemas/context.schema.json +259 -0
  22. package/dist/cli/commands/ai.d.ts +1 -0
  23. package/dist/cli/commands/ai.js +115 -46
  24. package/dist/cli/commands/create.d.ts +12 -0
  25. package/dist/cli/commands/create.js +110 -62
  26. package/dist/cli/commands/init.js +11 -7
  27. package/dist/cli/index.js +4 -2
  28. package/package.json +1 -1
  29. package/renderer/components/docs-viewer/sidebar/index.tsx +118 -87
  30. package/ai-agents/.claude/skills/create-doc-page/SKILL.md +0 -57
  31. package/ai-agents/.claude/skills/docs-from-code/SKILL.md +0 -73
  32. package/ai-agents/.claude/skills/generate-api-docs/SKILL.md +0 -94
  33. package/ai-agents/.claude/skills/sync-docs/SKILL.md +0 -112
  34. package/ai-agents/.claude/skills/update-docs-json/SKILL.md +0 -60
  35. package/ai-agents/.cursor/rules/devdoc-sync.mdc +0 -70
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Rules for bootstrapping documentation from repository analysis
2
+ description: Rules for bootstrapping documentation with context memory and API spec detection
3
3
  globs: ["**/README.md", "**/package.json", "**/src/**", "**/lib/**"]
4
4
  ---
5
5
 
@@ -7,60 +7,226 @@ globs: ["**/README.md", "**/package.json", "**/src/**", "**/lib/**"]
7
7
 
8
8
  When asked to bootstrap or generate initial documentation:
9
9
 
10
- ## Analysis Checklist
10
+ ## Step 1: Check Context Memory
11
11
 
12
- 1. Read README.md for project overview
13
- 2. Check package.json for:
14
- - Project name and description
15
- - Dependencies (to understand tech stack)
16
- - Scripts (for CLI documentation)
17
- 3. Scan source directory structure
18
- 4. Identify API endpoints or exported functions
19
- 5. Look for existing OpenAPI/GraphQL specs
20
- 6. Check for example files or tests
12
+ **First, check if `.devdoc/context.json` exists:**
21
13
 
22
- ## Documentation Generation Order
14
+ - **If populated:** Read and use existing context. Tell user: "Using existing product context."
15
+ - **If empty/missing:** Run Discovery Flow below.
23
16
 
24
- 1. index.mdx (homepage) - from README
25
- 2. quickstart.mdx - installation + basic usage
26
- 3. API reference - from specs or code analysis
27
- 4. Feature guides - from major modules
17
+ ## Step 2: Discovery Flow
28
18
 
29
- ## Always Include
19
+ ### 2a. Locate Project
30
20
 
31
- - Real code examples from the codebase
32
- - Accurate installation commands
33
- - Links between related pages
34
- - TODO comments for sections needing review
21
+ - If `docs.json` exists you're in docs folder, source is in `../`
22
+ - If `package.json` + `src/` exist → you're at repo root
23
+ - Otherwise, ask user for source code path
35
24
 
36
- ## File Structure to Generate
25
+ ### 2b. Scan for API Specs
37
26
 
27
+ **Search for OpenAPI:**
28
+ - `openapi.json`, `openapi.yaml`, `swagger.json`, `swagger.yaml`
29
+ - `**/openapi.*`, `**/swagger.*`
30
+
31
+ **Search for GraphQL:**
32
+ - `schema.graphql`, `schema.gql`
33
+ - `**/*.graphql`
34
+
35
+ **Store paths for import prompt.**
36
+
37
+ ### 2c. Auto-Discover
38
+
39
+ Scan and extract:
40
+ - **README.md:** Product name, description, features
41
+ - **package.json:** Language, framework, dependencies
42
+ - **OpenAPI:** API style, base URL, auth, endpoint count
43
+ - **GraphQL:** Types, queries, mutations count
44
+ - **Source structure:** Key directories, conventions
45
+
46
+ ### 2d. Ask Key Questions
47
+
48
+ 1. **Documentation Type:**
49
+ "What type of documentation?
50
+ 1. **internal** - Team setup, architecture
51
+ 2. **api** - API reference, SDKs for developers
52
+ 3. **product** - Feature guides for end users"
53
+
54
+ 2. **Import API Spec (if found):**
55
+
56
+ **For OpenAPI:**
57
+ "Found OpenAPI spec at `{path}` with {n} endpoints.
58
+ 1. **Import** - Copy to api-reference/openapi.json
59
+ 2. **Reference** - Point to existing location
60
+ 3. **Skip** - Manual docs only"
61
+
62
+ **For GraphQL:**
63
+ "Found GraphQL schema at `{path}` with {n} types.
64
+ 1. **Import** - Copy to api-reference/schema.graphql
65
+ 2. **Reference** - Point to existing location
66
+ 3. **Skip** - Manual docs only"
67
+
68
+ **For Both:**
69
+ "Found OpenAPI and GraphQL specs.
70
+ 1. **OpenAPI** - REST API playground
71
+ 2. **GraphQL** - GraphQL playground
72
+ 3. **Both** - Separate tabs for each
73
+ 4. **Skip** - Manual only"
74
+
75
+ 3. **Target Audience:**
76
+ "Who is your primary audience?"
77
+
78
+ 4. **Terminology (optional):**
79
+ "Any terms to use/avoid? Brand names? (Enter to skip)"
80
+
81
+ 5. **Code Examples:**
82
+ "Primary language for code examples?"
83
+
84
+ ### 2e. Create Context Memory
85
+
86
+ Create `.devdoc/context.json`:
87
+
88
+ ```json
89
+ {
90
+ "$schema": "https://devdoc.sh/schemas/context.json",
91
+ "version": "1.0",
92
+ "lastUpdated": "[timestamp]",
93
+ "product": {
94
+ "name": "[discovered]",
95
+ "description": "[discovered]",
96
+ "type": "[api/sdk/platform/cli]",
97
+ "targetAudience": "[from question]"
98
+ },
99
+ "api": {
100
+ "style": "[REST/GraphQL if detected]",
101
+ "specPath": "[imported spec path]",
102
+ "baseUrl": "[from spec]",
103
+ "authentication": { "type": "[from spec]" }
104
+ },
105
+ "codebase": {
106
+ "language": "[detected]",
107
+ "framework": "[detected]",
108
+ "sourceLocation": "../"
109
+ },
110
+ "documentation": {
111
+ "voice": "[based on docType]",
112
+ "codeExamples": { "primaryLanguage": "[from question]" },
113
+ "templates": {
114
+ "guide": ".devdoc/templates/guide.md",
115
+ "apiReference": ".devdoc/templates/api-reference.md"
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+ ## Step 3: Import API Spec
122
+
123
+ **For Import option:**
124
+ 1. Copy spec to `api-reference/`
125
+ 2. Validate spec format
126
+ 3. Update context.json with spec info
127
+
128
+ **For Reference option:**
129
+ 1. Note relative path for docs.json
130
+ 2. Update context.json with spec info
131
+
132
+ ## Step 4: Update docs.json
133
+
134
+ Add `docType` and API reference:
135
+
136
+ **OpenAPI:**
137
+ ```json
138
+ {
139
+ "docType": "api",
140
+ "navigation": {
141
+ "tabs": [
142
+ { "tab": "Guides", "groups": [...] },
143
+ { "tab": "API Reference", "type": "openapi", "spec": "api-reference/openapi.json" }
144
+ ]
145
+ }
146
+ }
147
+ ```
148
+
149
+ **GraphQL:**
150
+ ```json
151
+ {
152
+ "docType": "api",
153
+ "navigation": {
154
+ "tabs": [
155
+ { "tab": "Guides", "groups": [...] },
156
+ { "tab": "GraphQL API", "type": "graphql", "schema": "api-reference/schema.graphql", "endpoint": "https://..." }
157
+ ]
158
+ }
159
+ }
160
+ ```
161
+
162
+ ## Step 5: Generate Documentation
163
+
164
+ **Before generating, always:**
165
+ 1. Read `.devdoc/context.json`
166
+ 2. Read appropriate template from `.devdoc/templates/`
167
+ 3. Apply terminology from context
168
+ 4. Use correct product name
169
+ 5. Match voice to docType
170
+ 6. Reference imported API spec
171
+
172
+ ### docType: "internal"
173
+ ```
174
+ docs/
175
+ ├── .devdoc/context.json
176
+ ├── docs.json (docType: "internal")
177
+ ├── index.mdx
178
+ ├── getting-started/
179
+ ├── architecture/
180
+ ├── development/
181
+ └── contributing.mdx
182
+ ```
183
+ **Voice:** Technical, direct
184
+
185
+ ### docType: "api"
38
186
  ```
39
187
  docs/
40
- ├── docs.json # Navigation config
41
- ├── index.mdx # Homepage
42
- ├── quickstart.mdx # Getting started
188
+ ├── .devdoc/context.json
189
+ ├── docs.json (docType: "api")
190
+ ├── index.mdx
191
+ ├── quickstart.mdx
192
+ ├── authentication.mdx
43
193
  ├── guides/
44
- │ └── overview.mdx # Architecture
45
- ├── api-reference/ # If API exists
46
- ├── introduction.mdx
47
- │ └── openapi.json
48
- └── theme.json # Theme config
194
+ ├── api-reference/
195
+ ├── openapi.json # If imported
196
+ └── schema.graphql # If imported
197
+ ├── sdks/
198
+ └── changelog.mdx
199
+ ```
200
+ **Voice:** Professional, code-focused
201
+
202
+ ### docType: "product"
203
+ ```
204
+ docs/
205
+ ├── .devdoc/context.json
206
+ ├── docs.json (docType: "product")
207
+ ├── index.mdx
208
+ ├── getting-started/
209
+ ├── features/
210
+ ├── tutorials/
211
+ ├── troubleshooting/
212
+ └── release-notes.mdx
49
213
  ```
214
+ **Voice:** Friendly, non-technical
50
215
 
51
- ## Content Extraction
216
+ ## Content Guidelines
52
217
 
53
- | Source | Documentation |
54
- |--------|---------------|
55
- | README.md | Homepage, overview |
56
- | package.json | Name, version, scripts |
57
- | src/index.ts | Main exports |
58
- | tests/ | Usage examples |
59
- | .env.example | Configuration options |
218
+ | docType | Focus | Tone | Code |
219
+ |---------|-------|------|------|
220
+ | internal | Setup, architecture | Technical | Heavy |
221
+ | api | Endpoints, auth, examples | Professional | Heavy |
222
+ | product | Features, workflows | Friendly | Minimal |
60
223
 
61
224
  ## Quality Guidelines
62
225
 
226
+ - Use terminology from context.json consistently
227
+ - Read templates before generating each page type
63
228
  - Extract real examples, don't fabricate
64
- - Note areas needing human review
65
- - Generate SEO-friendly descriptions
66
- - Include all installation steps
229
+ - Add TODO for sections needing review
230
+ - **Import existing API specs** instead of manual docs
231
+ - **Validate specs** before importing
232
+ - Update context.json if you learn new info
@@ -0,0 +1,103 @@
1
+ ---
2
+ description: Commit documentation changes to git
3
+ globs: ["**/*.mdx", "**/docs.json"]
4
+ ---
5
+
6
+ # Commit Documentation
7
+
8
+ When asked to commit documentation changes:
9
+
10
+ ## Step 1: Check Status
11
+
12
+ Run git status and show summary:
13
+
14
+ "**Changes Ready to Commit:**
15
+
16
+ Modified (3):
17
+ - `guides/auth.mdx` - Updated examples
18
+ - `api/users.mdx` - Added endpoint
19
+ - `docs.json` - Updated navigation
20
+
21
+ New (1):
22
+ - `guides/webhooks.mdx`
23
+
24
+ Deleted (1):
25
+ - `old/deprecated.mdx`
26
+
27
+ Options:
28
+ 1. Review changes
29
+ 2. Commit all
30
+ 3. Select files
31
+ 4. Cancel"
32
+
33
+ ## Step 2: Review (if requested)
34
+
35
+ Show meaningful diff:
36
+ ```diff
37
+ - const token = auth.getToken(user);
38
+ + const token = await auth.getToken(user, { refresh: true });
39
+ ```
40
+
41
+ ## Step 3: Generate Message
42
+
43
+ Suggest commit message based on changes:
44
+
45
+ ```
46
+ docs: update authentication and add webhooks guide
47
+
48
+ - Update auth.getToken() with refresh parameter
49
+ - Add webhook integration guide
50
+ - Remove deprecated API docs
51
+ ```
52
+
53
+ Options:
54
+ 1. Use this message
55
+ 2. Edit message
56
+ 3. Custom message
57
+
58
+ ## Step 4: Confirm
59
+
60
+ "Ready to commit:
61
+
62
+ ```
63
+ docs: update authentication and add webhooks guide
64
+ ```
65
+
66
+ Files: 5 changed
67
+
68
+ Proceed? (yes/no)"
69
+
70
+ ## Step 5: Execute
71
+
72
+ ```bash
73
+ git add docs/
74
+ git commit -m "message"
75
+ ```
76
+
77
+ ## Step 6: Summary
78
+
79
+ "✓ Committed!
80
+
81
+ Commit: `abc1234`
82
+ Branch: `main`
83
+
84
+ Next steps:
85
+ 1. Push: `git push`
86
+ 2. Deploy: `npx @brainfish-ai/devdoc deploy`
87
+
88
+ Push changes?"
89
+
90
+ ## Commit Types
91
+
92
+ - `docs:` - Documentation changes
93
+ - `fix:` - Fix doc errors
94
+ - `feat:` - New doc features
95
+ - `refactor:` - Reorganize docs
96
+ - `chore:` - Maintenance
97
+
98
+ ## Safety
99
+
100
+ - Always show changes first
101
+ - Generate meaningful messages
102
+ - Don't commit secrets
103
+ - Suggest pushing, don't auto-push
@@ -0,0 +1,89 @@
1
+ ---
2
+ description: Create new documentation pages interactively
3
+ globs: ["**/*.mdx", "**/docs.json"]
4
+ ---
5
+
6
+ # Create Documentation
7
+
8
+ When asked to create documentation:
9
+
10
+ ## Step 0: Read Context
11
+
12
+ Read `.devdoc/context.json` if exists for terminology, templates, and code language.
13
+
14
+ ## Step 1: Understand What to Create
15
+
16
+ Ask: "What would you like to document?
17
+ 1. **A feature or concept** - I'll create a guide/tutorial
18
+ 2. **Code files** - Point me to the code, I'll generate docs
19
+ 3. **API endpoints** - I'll analyze your API
20
+ 4. **Something else** - Describe what you need"
21
+
22
+ ## Step 2: Gather Information
23
+
24
+ **For Feature/Concept:**
25
+ - Topic/title?
26
+ - Page type? (Guide, Tutorial, Reference, Troubleshooting)
27
+ - Specific sections?
28
+
29
+ **For Code Documentation:**
30
+ - Which files/directories?
31
+ - Focus? (Public API, Architecture, Examples, All)
32
+ - Read and extract functions, types, examples
33
+
34
+ **For API Documentation:**
35
+ - Check for OpenAPI/GraphQL specs
36
+ - If found, offer to generate from spec
37
+ - Extract endpoints, parameters, responses
38
+
39
+ ## Step 3: Read Template
40
+
41
+ Read from `.devdoc/templates/`:
42
+ - Guide → `guide.md`
43
+ - Tutorial → `tutorial.md`
44
+ - API → `api-reference.md`
45
+ - Quickstart → `quickstart.md`
46
+ - Troubleshooting → `troubleshooting.md`
47
+
48
+ ## Step 4: Generate Content
49
+
50
+ 1. Follow template structure
51
+ 2. Apply context (terminology, voice)
52
+ 3. Include mermaid diagrams for flows
53
+ 4. Add real code examples
54
+ 5. Use MDX components (Steps, Cards, etc.)
55
+
56
+ ## Step 5: Save and Update Navigation
57
+
58
+ 1. Propose file location
59
+ 2. Create MDX file
60
+ 3. Ask to update docs.json
61
+ 4. Show summary
62
+
63
+ ## Code to Doc Example
64
+
65
+ ```typescript
66
+ // Source
67
+ export function validateToken(token: string): boolean
68
+ ```
69
+
70
+ Generates:
71
+ ```mdx
72
+ ## validateToken
73
+
74
+ Validates an authentication token.
75
+
76
+ | Parameter | Type | Description |
77
+ |-----------|------|-------------|
78
+ | `token` | `string` | JWT token to validate |
79
+
80
+ **Returns:** `boolean`
81
+ ```
82
+
83
+ ## Guidelines
84
+
85
+ - Extract real examples, don't fabricate
86
+ - Include error handling
87
+ - Add TODO for sections needing review
88
+ - Use mermaid for complex flows
89
+ - Apply terminology from context.json
@@ -0,0 +1,101 @@
1
+ ---
2
+ description: Delete documentation pages interactively
3
+ globs: ["**/*.mdx", "**/docs.json"]
4
+ ---
5
+
6
+ # Delete Documentation
7
+
8
+ When asked to delete documentation:
9
+
10
+ ## Step 1: Understand What to Delete
11
+
12
+ Ask: "What would you like to delete?
13
+ 1. **A specific page** - Tell me which page(s)
14
+ 2. **Find unused pages** - I'll identify orphans
15
+ 3. **Deprecated content** - I'll find deprecated pages
16
+ 4. **Clean up** - Describe what to remove"
17
+
18
+ ## Step 2: Identify Pages
19
+
20
+ **For Specific Page:**
21
+ - Verify file exists
22
+ - Check for incoming links
23
+
24
+ **For Unused Pages:**
25
+ Compare .mdx files vs docs.json:
26
+ ```
27
+ Orphan pages (not in navigation):
28
+ - drafts/unused.mdx
29
+ - old/deprecated.mdx
30
+ ```
31
+
32
+ **For Deprecated:**
33
+ Search for deprecation markers in files.
34
+
35
+ ## Step 3: Analyze Impact
36
+
37
+ Before deletion, check:
38
+ - Incoming links from other pages
39
+ - Entry in docs.json
40
+ - Should redirect to new page?
41
+
42
+ Show analysis:
43
+ ```
44
+ Deleting `guides/old-feature.mdx`:
45
+
46
+ Links from:
47
+ - quickstart.mdx:45
48
+ - api/overview.mdx:23
49
+
50
+ In docs.json: Yes
51
+
52
+ Options:
53
+ 1. Delete and fix links
54
+ 2. Delete and redirect
55
+ 3. Delete only
56
+ 4. Cancel
57
+ ```
58
+
59
+ ## Step 4: Confirm
60
+
61
+ "Ready to delete?
62
+
63
+ This will:
64
+ - ❌ Delete the file
65
+ - ❌ Remove from docs.json
66
+ - ⚠️ Leave broken links (I can fix)
67
+
68
+ Proceed?"
69
+
70
+ ## Step 5: Execute
71
+
72
+ **Delete and Fix Links:**
73
+ 1. Delete file
74
+ 2. Update docs.json
75
+ 3. Fix links in other pages
76
+
77
+ **Delete and Redirect:**
78
+ 1. Delete file
79
+ 2. Update docs.json
80
+ 3. Add redirect rule
81
+
82
+ **Delete Only:**
83
+ 1. Delete file
84
+ 2. Update docs.json
85
+ 3. Warn about broken links
86
+
87
+ ## Summary
88
+
89
+ "Deleted:
90
+ - ❌ `guides/old-feature.mdx`
91
+ - ✓ Removed from navigation
92
+ - ✓ Fixed links in 2 pages
93
+
94
+ Use `/commit-doc` when ready to commit."
95
+
96
+ ## Safety
97
+
98
+ - Always confirm before deleting
99
+ - Check for incoming links
100
+ - Offer redirects for public pages
101
+ - Never delete docs.json without explicit confirmation
@@ -0,0 +1,95 @@
1
+ ---
2
+ description: Update existing documentation by analyzing codebase
3
+ globs: ["**/*.mdx", "**/docs.json"]
4
+ ---
5
+
6
+ # Update Documentation
7
+
8
+ When asked to update documentation:
9
+
10
+ ## Step 0: Read Context
11
+
12
+ Read `.devdoc/context.json` for terminology and conventions.
13
+
14
+ ## Step 1: Understand What to Update
15
+
16
+ Ask: "What would you like to update?
17
+ 1. **A specific page** - Tell me which page
18
+ 2. **Sync with codebase** - I'll find outdated docs
19
+ 3. **Navigation** - Update docs.json
20
+ 4. **Multiple pages** - Describe changes
21
+ 5. **Fix issues** - Point me to problems"
22
+
23
+ ## Step 2: Analyze
24
+
25
+ **For Specific Page:**
26
+ - Read current content
27
+ - Ask what changes needed
28
+
29
+ **For Codebase Sync:**
30
+ Compare docs vs code:
31
+ - Function signatures changed?
32
+ - New exports undocumented?
33
+ - Removed features still documented?
34
+ - Versions outdated?
35
+
36
+ Generate sync report:
37
+ ```
38
+ ## Sync Report
39
+
40
+ ### Outdated
41
+ - `api/users.mdx`: signature changed
42
+ - `quickstart.mdx`: version outdated
43
+
44
+ ### Missing
45
+ - New endpoint not documented
46
+
47
+ ### Up to Date ✓
48
+ - `guides/auth.mdx`
49
+ ```
50
+
51
+ **For Navigation:**
52
+ - Read docs.json
53
+ - Ask what to change
54
+
55
+ ## Step 3: Propose Changes
56
+
57
+ Show what will change before applying:
58
+
59
+ "I'll make these changes:
60
+ - `api/users.mdx`: Update signature
61
+ - `quickstart.mdx`: Update version
62
+ - `docs.json`: Add new page
63
+
64
+ Proceed?"
65
+
66
+ ## Step 4: Apply Updates
67
+
68
+ - Preserve prose, update technical details
69
+ - Fix terminology per context.json
70
+ - Add deprecation notices for removed features
71
+ - Create stubs for new features
72
+
73
+ ## Update Patterns
74
+
75
+ **Changed Signature:**
76
+ Update code and parameters table.
77
+
78
+ **Removed Feature:**
79
+ ```mdx
80
+ <Warning>
81
+ **Deprecated in v2.0**: Use `newMethod()` instead.
82
+ </Warning>
83
+ ```
84
+
85
+ **New Feature:**
86
+ ```mdx
87
+ {/* TODO: Document this */}
88
+ ## New Feature
89
+ Coming soon...
90
+ ```
91
+
92
+ ## Summary
93
+
94
+ Show what was updated and suggest:
95
+ "Use `/commit-doc` when ready to commit changes."