@brainfish-ai/devdoc 0.1.37 → 0.1.39
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.
- package/ai-agents/.claude/skills/bootstrap-docs/SKILL.md +382 -434
- package/ai-agents/.claude/skills/create-doc/SKILL.md +47 -10
- package/ai-agents/.claude/skills/update-doc/SKILL.md +40 -15
- package/ai-agents/.cursor/rules/devdoc-bootstrap.mdc +211 -153
- package/ai-agents/.cursor/rules/devdoc-create.mdc +17 -5
- package/ai-agents/.cursor/rules/devdoc-update.mdc +29 -12
- package/ai-agents/schemas/code-graph.schema.json +413 -0
- package/ai-agents/schemas/context.schema.json +20 -0
- package/dist/cli/commands/deploy.js +40 -15
- package/dist/cli/commands/upload.js +37 -2
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ description: Create new documentation pages interactively. Analyzes codebase and
|
|
|
7
7
|
|
|
8
8
|
When user wants to create documentation:
|
|
9
9
|
|
|
10
|
-
### Step 0: Read Context
|
|
10
|
+
### Step 0: Read Context & Code Graph
|
|
11
11
|
|
|
12
12
|
**First, read `.devdoc/context.json` if it exists:**
|
|
13
13
|
- Use `product.name` for product references
|
|
@@ -15,6 +15,13 @@ When user wants to create documentation:
|
|
|
15
15
|
- Use `documentation.codeExamples.primaryLanguage` for code
|
|
16
16
|
- Read templates from `documentation.templates`
|
|
17
17
|
|
|
18
|
+
**Then, read `.devdoc/code-graph.json` if it exists:**
|
|
19
|
+
- Use `modules` array to understand codebase structure
|
|
20
|
+
- Reference exact function signatures from `exports`
|
|
21
|
+
- Use `types` array for type definitions
|
|
22
|
+
- Find examples in `examples` array
|
|
23
|
+
- Reference `errors` for error handling docs
|
|
24
|
+
|
|
18
25
|
### Step 1: Understand What to Create
|
|
19
26
|
|
|
20
27
|
Ask the user:
|
|
@@ -63,20 +70,30 @@ Based on their choice:
|
|
|
63
70
|
|
|
64
71
|
When documenting code:
|
|
65
72
|
|
|
73
|
+
**If `.devdoc/code-graph.json` exists:**
|
|
74
|
+
```
|
|
75
|
+
Read from code-graph.json:
|
|
76
|
+
- modules[].exports → Function signatures, params, returns
|
|
77
|
+
- types[] → Type definitions
|
|
78
|
+
- examples[] → Code examples
|
|
79
|
+
- api.endpoints[] → API routes
|
|
80
|
+
- errors[] → Error types
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**If code-graph.json doesn't exist:**
|
|
66
84
|
```
|
|
67
|
-
Scan for:
|
|
85
|
+
Scan the codebase for:
|
|
68
86
|
- Function signatures and JSDoc/docstrings
|
|
69
87
|
- Type definitions and interfaces
|
|
70
88
|
- Usage examples in tests
|
|
71
89
|
- README sections about this feature
|
|
72
|
-
- Existing related documentation
|
|
73
90
|
```
|
|
74
91
|
|
|
75
92
|
Show user what you found:
|
|
76
|
-
"I found:
|
|
77
|
-
- 5
|
|
78
|
-
-
|
|
79
|
-
-
|
|
93
|
+
"I found in code-graph.json:
|
|
94
|
+
- Module: `auth` with 5 exports (login, logout, verifyToken...)
|
|
95
|
+
- Types: User, AuthToken, Session
|
|
96
|
+
- Examples: `examples/auth-flow.ts`
|
|
80
97
|
|
|
81
98
|
Should I proceed with generating documentation for these?"
|
|
82
99
|
|
|
@@ -98,9 +115,29 @@ Create the documentation:
|
|
|
98
115
|
|
|
99
116
|
1. **Read the template** for structure guidance
|
|
100
117
|
2. **Apply context** (terminology, voice, language)
|
|
101
|
-
3. **
|
|
102
|
-
|
|
103
|
-
|
|
118
|
+
3. **Use code-graph.json** for accuracy:
|
|
119
|
+
- Get exact function signatures from `exports`
|
|
120
|
+
- Get type definitions from `types`
|
|
121
|
+
- Reference examples from `examples` array
|
|
122
|
+
- Document errors from `errors` array
|
|
123
|
+
4. **Include mermaid diagrams** for flows/architecture
|
|
124
|
+
5. **Add real code examples** from codebase/code-graph
|
|
125
|
+
6. **Use proper MDX components** (Steps, Cards, Tabs, etc.)
|
|
126
|
+
|
|
127
|
+
**Example using code-graph:**
|
|
128
|
+
```
|
|
129
|
+
// From code-graph.json:
|
|
130
|
+
{
|
|
131
|
+
"name": "login",
|
|
132
|
+
"type": "function",
|
|
133
|
+
"signature": "login(email: string, password: string): Promise<AuthToken>",
|
|
134
|
+
"params": [...]
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Generate accurate documentation:
|
|
138
|
+
## login(email, password)
|
|
139
|
+
Authenticate user and return JWT token.
|
|
140
|
+
```
|
|
104
141
|
|
|
105
142
|
### Step 6: Propose File Location
|
|
106
143
|
|
|
@@ -7,7 +7,7 @@ description: Update existing documentation by analyzing codebase changes or user
|
|
|
7
7
|
|
|
8
8
|
When user wants to update documentation:
|
|
9
9
|
|
|
10
|
-
### Step 0: Read Context
|
|
10
|
+
### Step 0: Read Context & Code Graph
|
|
11
11
|
|
|
12
12
|
**First, read `.devdoc/context.json` if it exists:**
|
|
13
13
|
- Use `product.name` for product references
|
|
@@ -15,6 +15,12 @@ When user wants to update documentation:
|
|
|
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
|
+
|
|
18
24
|
### Step 1: Understand What to Update
|
|
19
25
|
|
|
20
26
|
Ask the user:
|
|
@@ -42,13 +48,24 @@ Based on their choice:
|
|
|
42
48
|
- Other (describe)"
|
|
43
49
|
|
|
44
50
|
#### For Codebase Sync:
|
|
45
|
-
|
|
46
|
-
-
|
|
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:
|
|
47
65
|
- Function signatures changed?
|
|
48
66
|
- New exports not documented?
|
|
49
67
|
- Removed features still documented?
|
|
50
68
|
- Version numbers outdated?
|
|
51
|
-
- Generate sync report (see below)
|
|
52
69
|
|
|
53
70
|
#### For Navigation:
|
|
54
71
|
- Read current `docs.json`
|
|
@@ -69,24 +86,31 @@ Based on their choice:
|
|
|
69
86
|
|
|
70
87
|
### Step 3: Generate Sync Report (if syncing)
|
|
71
88
|
|
|
89
|
+
**Compare docs against code-graph.json:**
|
|
90
|
+
|
|
72
91
|
```
|
|
73
92
|
## Documentation Sync Report
|
|
74
93
|
|
|
75
|
-
###
|
|
94
|
+
### Signature Changes (from code-graph.json)
|
|
76
95
|
- `docs/api/users.mdx`: Function signature changed
|
|
77
96
|
- Documented: `createUser(name, email)`
|
|
78
|
-
-
|
|
97
|
+
- Code-graph: `createUser(options: CreateUserInput)`
|
|
79
98
|
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
|
83
107
|
|
|
84
|
-
###
|
|
85
|
-
- `
|
|
108
|
+
### Type Changes
|
|
109
|
+
- `User` interface: Added `role` property
|
|
110
|
+
- `AuthToken`: Changed `expiresAt` type
|
|
86
111
|
|
|
87
|
-
###
|
|
88
|
-
- `
|
|
89
|
-
- `POST /api/v2/webhooks` - New endpoint
|
|
112
|
+
### New Endpoints (from code-graph.api.endpoints)
|
|
113
|
+
- `POST /api/v2/webhooks` - Not documented
|
|
90
114
|
|
|
91
115
|
### Up to Date ✓
|
|
92
116
|
- `docs/guides/authentication.mdx`
|
|
@@ -96,7 +120,8 @@ Based on their choice:
|
|
|
96
120
|
Ask: "How would you like to proceed?
|
|
97
121
|
1. **Fix all** - Update everything automatically
|
|
98
122
|
2. **Interactive** - Review each change
|
|
99
|
-
3. **Specific items** - Tell me which to fix
|
|
123
|
+
3. **Specific items** - Tell me which to fix
|
|
124
|
+
4. **Refresh code-graph first** - Re-scan codebase before updating"
|
|
100
125
|
|
|
101
126
|
### Step 4: Propose Changes
|
|
102
127
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Rules for bootstrapping documentation with
|
|
2
|
+
description: Rules for bootstrapping documentation with user-driven preferences and code memory mapping
|
|
3
3
|
globs: ["**/README.md", "**/package.json", "**/src/**", "**/lib/**"]
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -7,131 +7,224 @@ globs: ["**/README.md", "**/package.json", "**/src/**", "**/lib/**"]
|
|
|
7
7
|
|
|
8
8
|
When asked to bootstrap or generate initial documentation:
|
|
9
9
|
|
|
10
|
-
## Step 1: Check Context
|
|
10
|
+
## Step 1: Check Existing Context & Codebase
|
|
11
11
|
|
|
12
|
-
**
|
|
12
|
+
**Detect if codebase exists:**
|
|
13
|
+
- Look for: package.json, src/, lib/, app/, *.py, *.ts, *.go
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
-
|
|
15
|
+
**If NO codebase:**
|
|
16
|
+
- "No codebase detected. Creating docs-only project."
|
|
17
|
+
- Skip code-graph, go to Step 2 → Step 6
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
**If codebase exists, check git:**
|
|
20
|
+
```bash
|
|
21
|
+
git rev-parse HEAD # Current commit
|
|
22
|
+
```
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
**If `.devdoc/code-graph.json` exists:**
|
|
25
|
+
1. Compare `git.commitHash` vs current HEAD
|
|
26
|
+
2. **Same commit** → "Code graph up to date" → Skip to Step 6
|
|
27
|
+
3. **Different commit** → "{N} files changed"
|
|
28
|
+
- Ask: "1. Full rescan 2. Incremental 3. Skip"
|
|
20
29
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- Otherwise, ask user for source code path
|
|
30
|
+
**If `.devdoc/context.json` exists:** Read and use it.
|
|
31
|
+
**If missing:** Proceed to ask user preferences first.
|
|
24
32
|
|
|
25
|
-
|
|
33
|
+
## Step 2: Ask User Preferences First
|
|
26
34
|
|
|
27
|
-
**
|
|
28
|
-
- `openapi.json`, `openapi.yaml`, `swagger.json`, `swagger.yaml`
|
|
29
|
-
- `**/openapi.*`, `**/swagger.*`
|
|
35
|
+
**Don't auto-scan yet. Ask what they want:**
|
|
30
36
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
### Question 1: Documentation Type
|
|
38
|
+
```
|
|
39
|
+
What type of documentation are you creating?
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
1. API Docs - REST/GraphQL API reference for developers
|
|
42
|
+
2. Product Docs - Feature guides and tutorials for end users
|
|
43
|
+
3. Internal Docs - Team setup, architecture, contribution guides
|
|
44
|
+
```
|
|
36
45
|
|
|
37
|
-
###
|
|
46
|
+
### Question 2: API Type (if API Docs)
|
|
47
|
+
```
|
|
48
|
+
What type of API do you have?
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
- **Source structure:** Key directories, conventions
|
|
50
|
+
1. OpenAPI/REST - I have an OpenAPI/Swagger spec
|
|
51
|
+
2. GraphQL - I have a GraphQL schema
|
|
52
|
+
3. Both - REST and GraphQL APIs
|
|
53
|
+
4. Manual - I'll document manually (no spec)
|
|
54
|
+
```
|
|
45
55
|
|
|
46
|
-
###
|
|
56
|
+
### Question 3: Target Audience
|
|
57
|
+
```
|
|
58
|
+
Who is your primary audience?
|
|
59
|
+
```
|
|
47
60
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
3. **product** - Feature guides for end users"
|
|
61
|
+
### Question 4: Code Examples Language
|
|
62
|
+
```
|
|
63
|
+
What language for code examples? (TypeScript, Python, curl, etc.)
|
|
64
|
+
```
|
|
53
65
|
|
|
54
|
-
|
|
66
|
+
## Step 3: Import API Spec (if applicable)
|
|
55
67
|
|
|
56
|
-
|
|
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"
|
|
68
|
+
**Ask user for spec path or search:**
|
|
61
69
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
1. **Import** - Copy to api-reference/schema.graphql
|
|
65
|
-
2. **Reference** - Point to existing location
|
|
66
|
-
3. **Skip** - Manual docs only"
|
|
70
|
+
OpenAPI: `openapi.json`, `swagger.json`, `**/openapi.*`
|
|
71
|
+
GraphQL: `schema.graphql`, `schema.gql`, `**/*.graphql`
|
|
67
72
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
2. **GraphQL** - GraphQL playground
|
|
72
|
-
3. **Both** - Separate tabs for each
|
|
73
|
-
4. **Skip** - Manual only"
|
|
73
|
+
1. Copy spec to `api-reference/`
|
|
74
|
+
2. Validate format
|
|
75
|
+
3. Extract metadata (endpoints, auth, types)
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
"Who is your primary audience?"
|
|
77
|
+
## Step 4: Build Code Graph (Optional)
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
"Any terms to use/avoid? Brand names? (Enter to skip)"
|
|
79
|
+
**Skip if:** No codebase, user chose skip, or docs-only project.
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
"Primary language for code examples?"
|
|
81
|
+
**If scanning, create `.devdoc/code-graph.json`:**
|
|
83
82
|
|
|
84
|
-
|
|
83
|
+
```
|
|
84
|
+
Scan and map:
|
|
85
|
+
├── README.md → name, description, features
|
|
86
|
+
├── package.json → language, framework, deps
|
|
87
|
+
├── src/
|
|
88
|
+
│ ├── api/ → routes, controllers
|
|
89
|
+
│ ├── models/ → data schemas
|
|
90
|
+
│ ├── services/ → business logic
|
|
91
|
+
│ └── types/ → type definitions
|
|
92
|
+
├── tests/ → code examples
|
|
93
|
+
└── examples/ → usage examples
|
|
94
|
+
```
|
|
85
95
|
|
|
86
|
-
|
|
96
|
+
**For each module, extract:**
|
|
97
|
+
- All public functions with FULL signatures
|
|
98
|
+
- Class definitions with methods
|
|
99
|
+
- Type/interface definitions
|
|
100
|
+
- Exported constants
|
|
101
|
+
- Error types and codes
|
|
87
102
|
|
|
103
|
+
**Save to `.devdoc/code-graph.json`:**
|
|
88
104
|
```json
|
|
89
105
|
{
|
|
90
|
-
"$schema": "https://devdoc.sh/schemas/
|
|
106
|
+
"$schema": "https://devdoc.sh/schemas/code-graph.json",
|
|
91
107
|
"version": "1.0",
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
},
|
|
99
|
-
"api": {
|
|
100
|
-
"style": "[REST/GraphQL if detected]",
|
|
101
|
-
"specPath": "[imported spec path]",
|
|
102
|
-
"baseUrl": "[from spec]",
|
|
103
|
-
"authentication": { "type": "[from spec]" }
|
|
108
|
+
"generatedAt": "[timestamp]",
|
|
109
|
+
"git": {
|
|
110
|
+
"commitHash": "[full 40-char hash]",
|
|
111
|
+
"commitShort": "[7-char hash]",
|
|
112
|
+
"branch": "[branch name]",
|
|
113
|
+
"isDirty": false
|
|
104
114
|
},
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
115
|
+
"project": {
|
|
116
|
+
"name": "[name]",
|
|
117
|
+
"language": "[lang]",
|
|
118
|
+
"framework": "[framework]",
|
|
119
|
+
"rootDir": "src/"
|
|
109
120
|
},
|
|
110
|
-
"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
"
|
|
115
|
-
"
|
|
121
|
+
"modules": [
|
|
122
|
+
{
|
|
123
|
+
"name": "auth",
|
|
124
|
+
"path": "src/auth/",
|
|
125
|
+
"description": "Authentication",
|
|
126
|
+
"exports": [
|
|
127
|
+
{
|
|
128
|
+
"name": "login",
|
|
129
|
+
"type": "function",
|
|
130
|
+
"signature": "login(email: string, password: string): Promise<AuthToken>",
|
|
131
|
+
"params": [
|
|
132
|
+
{ "name": "email", "type": "string" },
|
|
133
|
+
{ "name": "password", "type": "string" }
|
|
134
|
+
],
|
|
135
|
+
"returns": { "type": "Promise<AuthToken>" },
|
|
136
|
+
"async": true
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"docPriority": "high"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"types": [
|
|
143
|
+
{
|
|
144
|
+
"name": "AuthToken",
|
|
145
|
+
"path": "src/types/auth.ts",
|
|
146
|
+
"kind": "interface",
|
|
147
|
+
"definition": "interface AuthToken { token: string; expiresAt: Date; }"
|
|
116
148
|
}
|
|
149
|
+
],
|
|
150
|
+
"examples": [
|
|
151
|
+
{ "path": "examples/basic.ts", "description": "Basic usage", "tags": ["auth"] }
|
|
152
|
+
],
|
|
153
|
+
"errors": [
|
|
154
|
+
{ "name": "AuthError", "code": "AUTH_FAILED", "message": "Invalid credentials" }
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Step 5: Save Context
|
|
160
|
+
|
|
161
|
+
Create `.devdoc/context.json`:
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"preferences": {
|
|
165
|
+
"docType": "[api/product/internal]",
|
|
166
|
+
"apiType": "[openapi/graphql/both/manual]",
|
|
167
|
+
"audience": "[target audience]",
|
|
168
|
+
"codeLanguage": "[language]"
|
|
169
|
+
},
|
|
170
|
+
"product": {
|
|
171
|
+
"name": "[name]",
|
|
172
|
+
"description": "[desc]"
|
|
173
|
+
},
|
|
174
|
+
"api": {
|
|
175
|
+
"style": "[REST/GraphQL]",
|
|
176
|
+
"specPath": "[path if imported]"
|
|
117
177
|
}
|
|
118
178
|
}
|
|
119
179
|
```
|
|
120
180
|
|
|
121
|
-
## Step
|
|
181
|
+
## Step 6: Plan Structure Based on Preferences
|
|
122
182
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
183
|
+
### API Docs
|
|
184
|
+
```
|
|
185
|
+
docs/
|
|
186
|
+
├── index.mdx
|
|
187
|
+
├── quickstart.mdx
|
|
188
|
+
├── authentication.mdx
|
|
189
|
+
├── guides/
|
|
190
|
+
├── api-reference/
|
|
191
|
+
│ ├── openapi.json (or schema.graphql)
|
|
192
|
+
│ └── introduction.mdx
|
|
193
|
+
└── sdks/
|
|
194
|
+
```
|
|
127
195
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
196
|
+
### Product Docs
|
|
197
|
+
```
|
|
198
|
+
docs/
|
|
199
|
+
├── index.mdx
|
|
200
|
+
├── getting-started/
|
|
201
|
+
├── features/
|
|
202
|
+
├── tutorials/
|
|
203
|
+
└── troubleshooting/
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Internal Docs
|
|
207
|
+
```
|
|
208
|
+
docs/
|
|
209
|
+
├── index.mdx
|
|
210
|
+
├── getting-started/
|
|
211
|
+
├── architecture/
|
|
212
|
+
├── development/
|
|
213
|
+
└── contributing.mdx
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Step 7: Generate Documentation
|
|
217
|
+
|
|
218
|
+
**Use code graph for accuracy:**
|
|
131
219
|
|
|
132
|
-
|
|
220
|
+
1. Read `.devdoc/code-graph.json` before each page
|
|
221
|
+
2. Use EXACT function signatures from exports
|
|
222
|
+
3. Reference types from types array
|
|
223
|
+
4. Extract examples from examples array
|
|
224
|
+
5. Document errors from errors array
|
|
225
|
+
6. Add TODO markers for uncertain sections
|
|
133
226
|
|
|
134
|
-
|
|
227
|
+
## Step 8: Update docs.json
|
|
135
228
|
|
|
136
229
|
**OpenAPI:**
|
|
137
230
|
```json
|
|
@@ -149,84 +242,49 @@ Add `docType` and API reference:
|
|
|
149
242
|
**GraphQL:**
|
|
150
243
|
```json
|
|
151
244
|
{
|
|
152
|
-
"docType": "api",
|
|
153
245
|
"navigation": {
|
|
154
246
|
"tabs": [
|
|
155
247
|
{ "tab": "Guides", "groups": [...] },
|
|
156
|
-
{ "tab": "GraphQL API", "type": "graphql", "schema": "api-reference/schema.graphql"
|
|
248
|
+
{ "tab": "GraphQL API", "type": "graphql", "schema": "api-reference/schema.graphql" }
|
|
157
249
|
]
|
|
158
250
|
}
|
|
159
251
|
}
|
|
160
252
|
```
|
|
161
253
|
|
|
162
|
-
## Step
|
|
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
|
|
254
|
+
## Step 9: Summary
|
|
171
255
|
|
|
172
|
-
### docType: "internal"
|
|
173
256
|
```
|
|
174
|
-
|
|
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
|
|
257
|
+
✅ Documentation Generated!
|
|
184
258
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
├── index.mdx
|
|
191
|
-
├── quickstart.mdx
|
|
192
|
-
├── authentication.mdx
|
|
193
|
-
├── guides/
|
|
194
|
-
├── api-reference/
|
|
195
|
-
│ ├── openapi.json # If imported
|
|
196
|
-
│ └── schema.graphql # If imported
|
|
197
|
-
├── sdks/
|
|
198
|
-
└── changelog.mdx
|
|
199
|
-
```
|
|
200
|
-
**Voice:** Professional, code-focused
|
|
259
|
+
Preferences:
|
|
260
|
+
- Type: API Documentation
|
|
261
|
+
- API: OpenAPI/REST
|
|
262
|
+
- Audience: [audience]
|
|
263
|
+
- Code: [language]
|
|
201
264
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
├── features/
|
|
210
|
-
├── tutorials/
|
|
211
|
-
├── troubleshooting/
|
|
212
|
-
└── release-notes.mdx
|
|
265
|
+
Files created:
|
|
266
|
+
- .devdoc/context.json (preferences)
|
|
267
|
+
- .devdoc/code-graph.json (code analysis)
|
|
268
|
+
- docs.json
|
|
269
|
+
- [list of mdx files]
|
|
270
|
+
|
|
271
|
+
Next: Run `devdoc dev` to preview, then "whisk theme" for branding.
|
|
213
272
|
```
|
|
214
|
-
**Voice:** Friendly, non-technical
|
|
215
273
|
|
|
216
|
-
##
|
|
274
|
+
## Key Principles
|
|
217
275
|
|
|
218
|
-
|
|
|
219
|
-
|
|
220
|
-
|
|
|
221
|
-
|
|
|
222
|
-
|
|
|
276
|
+
| Principle | Description |
|
|
277
|
+
|-----------|-------------|
|
|
278
|
+
| Ask first | Get user preferences before scanning |
|
|
279
|
+
| Build code graph | Scan entire codebase with full signatures |
|
|
280
|
+
| Store the graph | Save to code-graph.json for updates |
|
|
281
|
+
| Real code only | Use exact signatures, never fabricate |
|
|
282
|
+
| Mark unknowns | Add TODO for sections needing review |
|
|
223
283
|
|
|
224
|
-
##
|
|
284
|
+
## Code Graph Benefits
|
|
225
285
|
|
|
226
|
-
-
|
|
227
|
-
-
|
|
228
|
-
-
|
|
229
|
-
-
|
|
230
|
-
- **
|
|
231
|
-
- **Validate specs** before importing
|
|
232
|
-
- Update context.json if you learn new info
|
|
286
|
+
- **Accurate docs** - Exact function signatures
|
|
287
|
+
- **Complete coverage** - All exports documented
|
|
288
|
+
- **Easy updates** - Re-scan refreshes the graph
|
|
289
|
+
- **No hallucination** - Only document real code
|
|
290
|
+
- **Type safety** - Reference actual type definitions
|
|
@@ -7,9 +7,16 @@ globs: ["**/*.mdx", "**/docs.json"]
|
|
|
7
7
|
|
|
8
8
|
When asked to create documentation:
|
|
9
9
|
|
|
10
|
-
## Step 0: Read Context
|
|
10
|
+
## Step 0: Read Context & Code Graph
|
|
11
11
|
|
|
12
|
-
Read `.devdoc/context.json`
|
|
12
|
+
Read `.devdoc/context.json` for terminology, templates, and code language.
|
|
13
|
+
|
|
14
|
+
Read `.devdoc/code-graph.json` for:
|
|
15
|
+
- `modules[].exports` → Function signatures, params, returns
|
|
16
|
+
- `types[]` → Type definitions
|
|
17
|
+
- `examples[]` → Code examples to include
|
|
18
|
+
- `api.endpoints[]` → API routes
|
|
19
|
+
- `errors[]` → Error types to document
|
|
13
20
|
|
|
14
21
|
## Step 1: Understand What to Create
|
|
15
22
|
|
|
@@ -49,9 +56,14 @@ Read from `.devdoc/templates/`:
|
|
|
49
56
|
|
|
50
57
|
1. Follow template structure
|
|
51
58
|
2. Apply context (terminology, voice)
|
|
52
|
-
3.
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
3. **Use code-graph.json for accuracy:**
|
|
60
|
+
- Get exact signatures from `modules[].exports`
|
|
61
|
+
- Get type definitions from `types[]`
|
|
62
|
+
- Find examples from `examples[]`
|
|
63
|
+
- Document errors from `errors[]`
|
|
64
|
+
4. Include mermaid diagrams for flows
|
|
65
|
+
5. Add real code examples from code-graph
|
|
66
|
+
6. Use MDX components (Steps, Cards, etc.)
|
|
55
67
|
|
|
56
68
|
## Step 5: Save and Update Navigation
|
|
57
69
|
|