opencodekit 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/template/.opencode/agent/planner.md +3 -2
- package/dist/template/.opencode/command/accessibility-check.md +297 -30
- package/dist/template/.opencode/command/analyze-mockup.md +412 -20
- package/dist/template/.opencode/command/analyze-project.md +445 -30
- package/dist/template/.opencode/command/brainstorm.md +294 -5
- package/dist/template/.opencode/command/commit.md +231 -17
- package/dist/template/.opencode/command/create.md +415 -77
- package/dist/template/.opencode/command/design-audit.md +483 -29
- package/dist/template/.opencode/command/design.md +615 -6
- package/dist/template/.opencode/command/edit-image.md +223 -20
- package/dist/template/.opencode/command/finish.md +163 -71
- package/dist/template/.opencode/command/fix-ci.md +297 -24
- package/dist/template/.opencode/command/fix-types.md +351 -13
- package/dist/template/.opencode/command/fix-ui.md +299 -13
- package/dist/template/.opencode/command/fix.md +262 -9
- package/dist/template/.opencode/command/generate-diagram.md +327 -26
- package/dist/template/.opencode/command/generate-icon.md +266 -22
- package/dist/template/.opencode/command/generate-image.md +232 -12
- package/dist/template/.opencode/command/generate-pattern.md +234 -20
- package/dist/template/.opencode/command/generate-storyboard.md +231 -21
- package/dist/template/.opencode/command/handoff.md +208 -31
- package/dist/template/.opencode/command/implement.md +163 -50
- package/dist/template/.opencode/command/import-plan.md +253 -52
- package/dist/template/.opencode/command/init.md +154 -35
- package/dist/template/.opencode/command/integration-test.md +410 -24
- package/dist/template/.opencode/command/issue.md +177 -21
- package/dist/template/.opencode/command/new-feature.md +390 -54
- package/dist/template/.opencode/command/plan.md +394 -107
- package/dist/template/.opencode/command/pr.md +235 -29
- package/dist/template/.opencode/command/quick-build.md +234 -5
- package/dist/template/.opencode/command/research-and-implement.md +442 -12
- package/dist/template/.opencode/command/research-ui.md +444 -34
- package/dist/template/.opencode/command/research.md +179 -45
- package/dist/template/.opencode/command/restore-image.md +416 -22
- package/dist/template/.opencode/command/resume.md +447 -63
- package/dist/template/.opencode/command/revert-feature.md +347 -65
- package/dist/template/.opencode/command/review-codebase.md +199 -4
- package/dist/template/.opencode/command/skill-create.md +506 -14
- package/dist/template/.opencode/command/skill-optimize.md +487 -16
- package/dist/template/.opencode/command/status.md +326 -60
- package/dist/template/.opencode/command/summarize.md +374 -33
- package/dist/template/.opencode/command/triage.md +361 -0
- package/dist/template/.opencode/command/ui-review.md +296 -25
- package/dist/template/.opencode/skill/beads/SKILL.md +108 -3
- package/dist/template/.opencode/skill/playwriter/SKILL.md +148 -0
- package/package.json +1 -1
|
@@ -1,22 +1,275 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Debug and fix issues
|
|
3
|
-
argument-hint: "[
|
|
3
|
+
argument-hint: "<issue or bead-id> [--quick]"
|
|
4
4
|
agent: build
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Fix: $ARGUMENTS
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Load Beads Skill
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
```typescript
|
|
12
|
+
skill({ name: "beads" });
|
|
13
|
+
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
## Options
|
|
16
|
+
|
|
17
|
+
- `--quick`: Skip deep analysis, fix directly (for obvious bugs)
|
|
18
|
+
|
|
19
|
+
## Phase 1: Load Context
|
|
20
|
+
|
|
21
|
+
**Check for bead context:**
|
|
22
|
+
|
|
23
|
+
If `$ARGUMENTS` looks like a bead ID (e.g., `bd-abc123`):
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
bd_show({ id: "$ARGUMENTS" });
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Load constraints from `.beads/artifacts/<bead-id>/spec.md` if it exists.
|
|
30
|
+
|
|
31
|
+
**Check for messages about this issue:**
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
bd_inbox({ n: 5, unread: true, global: false });
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Phase 2: Parse Error Information
|
|
38
|
+
|
|
39
|
+
Extract from the issue:
|
|
40
|
+
|
|
41
|
+
| Field | Extract |
|
|
42
|
+
| ----------------- | ------------------------------------ |
|
|
43
|
+
| **Error message** | Exact error text |
|
|
44
|
+
| **Stack trace** | Call stack with file:line references |
|
|
45
|
+
| **Reproduction** | Steps to trigger the bug |
|
|
46
|
+
| **Expected** | What should happen |
|
|
47
|
+
| **Actual** | What happens instead |
|
|
48
|
+
|
|
49
|
+
**For stack traces:**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Find the first application code (skip node_modules, stdlib)
|
|
53
|
+
grep -E "at .*(src/|lib/|app/)" <<< "[stack trace]"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Phase 3: Estimate Complexity
|
|
57
|
+
|
|
58
|
+
| Signals | Estimate | Approach |
|
|
59
|
+
| ------------------------------------------- | -------- | ------------------ |
|
|
60
|
+
| Error points to exact line, obvious fix | S (~10) | Quick fix |
|
|
61
|
+
| Error in known area, clear reproduction | M (~30) | Systematic debug |
|
|
62
|
+
| Intermittent, unclear cause, multiple files | L (~100) | Deep investigation |
|
|
63
|
+
| No reproduction, architectural issue | XL | Research first |
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
Fix Estimate: [S/M/L/XL]
|
|
67
|
+
━━━━━━━━━━━━━━━━━━━━━━━
|
|
68
|
+
|
|
69
|
+
Complexity: [description]
|
|
70
|
+
Approach: [quick fix / systematic / deep investigation]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Phase 4: Reserve Files
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
bd_reservations({ reason: "Checking for conflicts before fix" });
|
|
77
|
+
bd_reserve({
|
|
78
|
+
paths: ["<files-to-investigate>"],
|
|
79
|
+
reason: "Fixing $ARGUMENTS",
|
|
80
|
+
ttl: 600,
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Phase 5: Investigation & Fix
|
|
85
|
+
|
|
86
|
+
### Quick Fix (S estimate or --quick)
|
|
87
|
+
|
|
88
|
+
1. Go directly to error location
|
|
89
|
+
2. Identify obvious cause
|
|
90
|
+
3. Make minimal fix
|
|
91
|
+
4. Run targeted test
|
|
92
|
+
5. Commit
|
|
93
|
+
|
|
94
|
+
### Systematic Debug (M/L estimate)
|
|
95
|
+
|
|
96
|
+
**Load skill:**
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
skill({ name: "systematic-debugging" });
|
|
100
|
+
```
|
|
14
101
|
|
|
15
102
|
Follow four phases:
|
|
16
103
|
|
|
17
|
-
1. Root
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
104
|
+
**1. Root Cause Investigation (NO fixes yet)**
|
|
105
|
+
|
|
106
|
+
- Read error location and surrounding code
|
|
107
|
+
- Trace data flow backward
|
|
108
|
+
- Check recent changes: `git log -p --since="1 week ago" -- <file>`
|
|
109
|
+
- Add logging/instrumentation if needed
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
Root Cause Hypothesis:
|
|
113
|
+
━━━━━━━━━━━━━━━━━━━━━
|
|
114
|
+
|
|
115
|
+
Cause: [what's actually wrong]
|
|
116
|
+
Evidence: [how we know]
|
|
117
|
+
Confidence: [High/Medium/Low]
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**2. Pattern Analysis**
|
|
121
|
+
|
|
122
|
+
- Is this a known pattern? Check gotchas.md
|
|
123
|
+
- Similar bugs in history? `git log --grep="fix" --oneline`
|
|
124
|
+
- Related code with same issue?
|
|
125
|
+
|
|
126
|
+
**3. Hypothesis Testing**
|
|
127
|
+
|
|
128
|
+
- Write a failing test that reproduces the bug
|
|
129
|
+
- Verify hypothesis by checking test fails for right reason
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npm test -- --grep "<bug-related-test>"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**4. Implementation with TDD**
|
|
136
|
+
|
|
137
|
+
- Fix the code
|
|
138
|
+
- Verify test now passes
|
|
139
|
+
- Run full test suite for regression
|
|
140
|
+
|
|
141
|
+
### Rollback Strategy
|
|
142
|
+
|
|
143
|
+
Before making changes, note rollback point:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
git stash # or
|
|
147
|
+
git rev-parse HEAD # Save current commit
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
If fix makes things worse:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
git checkout -- <file> # Revert single file
|
|
154
|
+
git stash pop # Restore stashed changes
|
|
155
|
+
git reset --hard <hash> # Nuclear option
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Phase 6: Verification
|
|
159
|
+
|
|
160
|
+
**Targeted verification:**
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
npm test -- --grep "<related-test>"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Regression check:**
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
npm test
|
|
170
|
+
npm run lint
|
|
171
|
+
npm run type-check
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
Verification:
|
|
176
|
+
━━━━━━━━━━━━━
|
|
177
|
+
|
|
178
|
+
Bug test: [✓ now passes]
|
|
179
|
+
Full tests: [✓/✗]
|
|
180
|
+
Lint: [✓/✗]
|
|
181
|
+
Types: [✓/✗]
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**If verification fails:** Iterate or rollback.
|
|
185
|
+
|
|
186
|
+
## Phase 7: Document Root Cause
|
|
187
|
+
|
|
188
|
+
Create observation for future reference:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
observation({
|
|
192
|
+
type: "bugfix",
|
|
193
|
+
title: "[Brief description of bug]",
|
|
194
|
+
content: `
|
|
195
|
+
## Root Cause
|
|
196
|
+
[What was actually wrong]
|
|
197
|
+
|
|
198
|
+
## Fix
|
|
199
|
+
[What we changed and why]
|
|
200
|
+
|
|
201
|
+
## Prevention
|
|
202
|
+
[How to avoid this in future]
|
|
203
|
+
`,
|
|
204
|
+
concepts: "[relevant keywords]",
|
|
205
|
+
files: "[affected files]",
|
|
206
|
+
bead_id: "<bead-id>",
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Phase 8: Update Memory
|
|
211
|
+
|
|
212
|
+
If this was a gotcha worth remembering:
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
memory -
|
|
216
|
+
update({
|
|
217
|
+
file: "project/gotchas",
|
|
218
|
+
content: `
|
|
219
|
+
## [Bug Title]
|
|
220
|
+
|
|
221
|
+
**Symptom:** [What you see]
|
|
222
|
+
**Cause:** [What's actually wrong]
|
|
223
|
+
**Fix:** [How to resolve]
|
|
224
|
+
**Prevention:** [How to avoid]
|
|
225
|
+
`,
|
|
226
|
+
mode: "append",
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Phase 9: Commit & Sync
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
git add <files>
|
|
234
|
+
git commit -m "fix(<scope>): <description>
|
|
235
|
+
|
|
236
|
+
Root cause: [brief explanation]
|
|
237
|
+
[bead-id if applicable]"
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Release locks and sync:
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
bd_release({ _: true });
|
|
244
|
+
bd_sync({ reason: "Fixed $ARGUMENTS" });
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Output
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
Fixed: $ARGUMENTS
|
|
251
|
+
━━━━━━━━━━━━━━━━━
|
|
252
|
+
|
|
253
|
+
Estimate: [S/M/L] (actual: [N] tool calls)
|
|
254
|
+
Root cause: [brief description]
|
|
255
|
+
|
|
256
|
+
Changes:
|
|
257
|
+
- [file:line] - [what changed]
|
|
258
|
+
|
|
259
|
+
Verification: All tests pass ✓
|
|
260
|
+
Observation: Created ✓
|
|
261
|
+
Gotcha: [Added to memory / Not needed]
|
|
262
|
+
|
|
263
|
+
Commit: [hash]
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**Next steps:**
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
If part of larger task:
|
|
270
|
+
/implement <bead-id> # Continue implementation
|
|
21
271
|
|
|
22
|
-
If
|
|
272
|
+
If standalone fix:
|
|
273
|
+
/finish <bead-id> # Close the bead
|
|
274
|
+
/pr <bead-id> # Create PR
|
|
275
|
+
```
|
|
@@ -1,48 +1,349 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Generate technical diagrams, flowcharts,
|
|
3
|
-
argument-hint: "<description> [type
|
|
2
|
+
description: Generate technical diagrams, flowcharts, and visual documentation
|
|
3
|
+
argument-hint: "<description> [--type=<type>] [--style=<style>] [--format=<format>] [--from-code]"
|
|
4
4
|
agent: vision
|
|
5
5
|
model: proxypal/gemini-3-flash-preview
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Generate Diagram: $ARGUMENTS
|
|
9
9
|
|
|
10
|
-
Generate technical diagrams and visual documentation.
|
|
10
|
+
Generate technical diagrams and visual documentation with Mermaid code output.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Parse Arguments
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
| Argument | Default | Options |
|
|
15
|
+
| ------------- | --------- | ------------------------------- |
|
|
16
|
+
| Description | required | What the diagram shows |
|
|
17
|
+
| `--type` | flowchart | See diagram types below |
|
|
18
|
+
| `--style` | clean | clean, sketch, formal, colorful |
|
|
19
|
+
| `--format` | both | png, svg, mermaid, both |
|
|
20
|
+
| `--size` | medium | simple, medium, complex |
|
|
21
|
+
| `--from-code` | false | Analyze codebase to generate |
|
|
22
|
+
| `--colors` | default | Brand colors or preset |
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Diagram Types
|
|
27
|
+
|
|
28
|
+
| Type | Description | Best For |
|
|
29
|
+
| -------------- | ---------------------------------------- | ----------------------- |
|
|
30
|
+
| `flowchart` | Process flows, decision trees | Workflows, algorithms |
|
|
31
|
+
| `sequence` | Interaction sequences, API calls | System interactions |
|
|
32
|
+
| `architecture` | System components, infrastructure | High-level design |
|
|
33
|
+
| `erd` | Entity relationship diagrams | Database design |
|
|
34
|
+
| `class` | Class diagrams, inheritance | OOP design |
|
|
35
|
+
| `state` | State machines, transitions | UI states, workflows |
|
|
36
|
+
| `mindmap` | Hierarchical concepts | Brainstorming, planning |
|
|
37
|
+
| `gantt` | Timeline, project schedule | Project planning |
|
|
38
|
+
| `wireframe` | UI layouts, screen mockups | UX design |
|
|
39
|
+
| `network` | Network topology | Infrastructure |
|
|
40
|
+
| `c4` | C4 model (context, container, component) | Architecture docs |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Workflow: AI vs Mermaid-First
|
|
45
|
+
|
|
46
|
+
### Use AI Generation When:
|
|
47
|
+
|
|
48
|
+
- Creating wireframes or visual mockups
|
|
49
|
+
- Need artistic/sketch style
|
|
50
|
+
- Complex visual that Mermaid can't express
|
|
51
|
+
|
|
52
|
+
### Use Mermaid-First When:
|
|
53
|
+
|
|
54
|
+
- Technical diagrams (flowchart, sequence, erd, class)
|
|
55
|
+
- Need precise control over structure
|
|
56
|
+
- Will iterate on the diagram
|
|
57
|
+
- Need version-controlled diagrams
|
|
58
|
+
|
|
59
|
+
**Recommendation:** For technical diagrams, this command generates Mermaid code that you can edit and render.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Mermaid Syntax Reference
|
|
64
|
+
|
|
65
|
+
### Flowchart
|
|
66
|
+
|
|
67
|
+
```mermaid
|
|
68
|
+
flowchart TD
|
|
69
|
+
A[Start] --> B{Decision?}
|
|
70
|
+
B -->|Yes| C[Action 1]
|
|
71
|
+
B -->|No| D[Action 2]
|
|
72
|
+
C --> E[End]
|
|
73
|
+
D --> E
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Shapes:** `[Rectangle]` `(Rounded)` `{Diamond}` `([Stadium])` `[[Subroutine]]`
|
|
77
|
+
**Directions:** `TD` (top-down), `LR` (left-right), `BT`, `RL`
|
|
78
|
+
|
|
79
|
+
### Sequence Diagram
|
|
80
|
+
|
|
81
|
+
```mermaid
|
|
82
|
+
sequenceDiagram
|
|
83
|
+
participant U as User
|
|
84
|
+
participant A as API
|
|
85
|
+
participant D as Database
|
|
86
|
+
|
|
87
|
+
U->>A: POST /login
|
|
88
|
+
A->>D: Query user
|
|
89
|
+
D-->>A: User data
|
|
90
|
+
A-->>U: JWT token
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Arrows:** `->>` (solid), `-->>` (dashed), `-x` (cross), `-)` (async)
|
|
94
|
+
|
|
95
|
+
### Entity Relationship
|
|
18
96
|
|
|
19
|
-
|
|
97
|
+
```mermaid
|
|
98
|
+
erDiagram
|
|
99
|
+
USER ||--o{ ORDER : places
|
|
100
|
+
ORDER ||--|{ LINE_ITEM : contains
|
|
101
|
+
PRODUCT ||--o{ LINE_ITEM : includes
|
|
20
102
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
103
|
+
USER {
|
|
104
|
+
int id PK
|
|
105
|
+
string email
|
|
106
|
+
string name
|
|
107
|
+
}
|
|
108
|
+
```
|
|
26
109
|
|
|
27
|
-
|
|
110
|
+
**Cardinality:** `||` (one), `o{` (zero or more), `|{` (one or more)
|
|
28
111
|
|
|
29
|
-
|
|
112
|
+
### Class Diagram
|
|
30
113
|
|
|
31
|
-
|
|
32
|
-
|
|
114
|
+
```mermaid
|
|
115
|
+
classDiagram
|
|
116
|
+
class User {
|
|
117
|
+
+String email
|
|
118
|
+
+String name
|
|
119
|
+
+login()
|
|
120
|
+
+logout()
|
|
121
|
+
}
|
|
122
|
+
class Admin {
|
|
123
|
+
+deleteUser()
|
|
124
|
+
}
|
|
125
|
+
User <|-- Admin
|
|
126
|
+
```
|
|
33
127
|
|
|
34
|
-
|
|
128
|
+
**Relationships:** `<|--` (inheritance), `*--` (composition), `o--` (aggregation)
|
|
129
|
+
|
|
130
|
+
### State Diagram
|
|
131
|
+
|
|
132
|
+
```mermaid
|
|
133
|
+
stateDiagram-v2
|
|
134
|
+
[*] --> Idle
|
|
135
|
+
Idle --> Loading : fetch
|
|
136
|
+
Loading --> Success : resolve
|
|
137
|
+
Loading --> Error : reject
|
|
138
|
+
Success --> Idle : reset
|
|
139
|
+
Error --> Idle : retry
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Gantt Chart
|
|
143
|
+
|
|
144
|
+
```mermaid
|
|
145
|
+
gantt
|
|
146
|
+
title Project Timeline
|
|
147
|
+
dateFormat YYYY-MM-DD
|
|
148
|
+
section Phase 1
|
|
149
|
+
Design :a1, 2024-01-01, 2w
|
|
150
|
+
Development :a2, after a1, 4w
|
|
151
|
+
section Phase 2
|
|
152
|
+
Testing :a3, after a2, 2w
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Mindmap
|
|
156
|
+
|
|
157
|
+
```mermaid
|
|
158
|
+
mindmap
|
|
159
|
+
root((Project))
|
|
160
|
+
Frontend
|
|
161
|
+
React
|
|
162
|
+
Tailwind
|
|
163
|
+
Backend
|
|
164
|
+
Node.js
|
|
165
|
+
PostgreSQL
|
|
166
|
+
DevOps
|
|
167
|
+
Docker
|
|
168
|
+
AWS
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Style Options
|
|
174
|
+
|
|
175
|
+
| Style | Description | Use Case |
|
|
176
|
+
| ---------- | ----------------------- | ---------------------------- |
|
|
177
|
+
| `clean` | Minimal, professional | Documentation, presentations |
|
|
178
|
+
| `sketch` | Hand-drawn appearance | Informal, brainstorming |
|
|
179
|
+
| `formal` | Box borders, structured | Enterprise, technical docs |
|
|
180
|
+
| `colorful` | Vibrant, color-coded | Marketing, education |
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Codebase Integration (--from-code)
|
|
185
|
+
|
|
186
|
+
Analyze actual code to generate diagrams:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Generate architecture from imports
|
|
190
|
+
/generate-diagram system architecture --from-code --type=architecture
|
|
191
|
+
|
|
192
|
+
# Generate ERD from models
|
|
193
|
+
/generate-diagram database schema --from-code --type=erd
|
|
194
|
+
|
|
195
|
+
# Generate class diagram from TypeScript
|
|
196
|
+
/generate-diagram class relationships --from-code --type=class
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**How it works:**
|
|
200
|
+
|
|
201
|
+
1. Scans relevant source files
|
|
202
|
+
2. Extracts structure (classes, functions, imports)
|
|
203
|
+
3. Generates Mermaid code representing actual codebase
|
|
204
|
+
4. Renders as diagram
|
|
205
|
+
|
|
206
|
+
---
|
|
35
207
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
208
|
+
## Examples by Type
|
|
209
|
+
|
|
210
|
+
### Flowchart
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# User authentication flow
|
|
214
|
+
/generate-diagram user login process with email verification --type=flowchart
|
|
215
|
+
|
|
216
|
+
# Algorithm
|
|
217
|
+
/generate-diagram binary search algorithm --type=flowchart --style=clean
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Sequence Diagram
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# API flow
|
|
224
|
+
/generate-diagram OAuth2 authentication flow between client, auth server, and resource server --type=sequence
|
|
225
|
+
|
|
226
|
+
# Microservice communication
|
|
227
|
+
/generate-diagram order processing across payment, inventory, and shipping services --type=sequence
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Architecture
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# System overview
|
|
234
|
+
/generate-diagram e-commerce platform with React frontend, Node API, and PostgreSQL --type=architecture
|
|
235
|
+
|
|
236
|
+
# Cloud infrastructure
|
|
237
|
+
/generate-diagram AWS deployment with ECS, RDS, and CloudFront --type=architecture --style=formal
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### ERD
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
# Database schema
|
|
244
|
+
/generate-diagram user management system with users, roles, and permissions --type=erd
|
|
245
|
+
|
|
246
|
+
# E-commerce
|
|
247
|
+
/generate-diagram product catalog with categories, variants, and inventory --type=erd
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### State Diagram
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# UI states
|
|
254
|
+
/generate-diagram form submission states from idle to loading to success or error --type=state
|
|
255
|
+
|
|
256
|
+
# Order lifecycle
|
|
257
|
+
/generate-diagram order status from pending through processing, shipped, delivered --type=state
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Size/Complexity Guidance
|
|
263
|
+
|
|
264
|
+
| Size | Elements | Description |
|
|
265
|
+
| --------- | ---------- | ---------------------------- |
|
|
266
|
+
| `simple` | 3-5 nodes | Quick sketch, single concept |
|
|
267
|
+
| `medium` | 6-12 nodes | Standard documentation |
|
|
268
|
+
| `complex` | 13+ nodes | Comprehensive system view |
|
|
269
|
+
|
|
270
|
+
**Tip:** Start simple, iterate to add detail.
|
|
271
|
+
|
|
272
|
+
---
|
|
40
273
|
|
|
41
274
|
## Output
|
|
42
275
|
|
|
43
|
-
|
|
276
|
+
### File Structure
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
.opencode/memory/design/diagrams/[name]/
|
|
280
|
+
├── diagram.png # Rendered image
|
|
281
|
+
├── diagram.svg # Vector version
|
|
282
|
+
├── diagram.mmd # Mermaid source code
|
|
283
|
+
└── README.md # Usage notes
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Inline Output
|
|
287
|
+
|
|
288
|
+
```markdown
|
|
289
|
+
## Generated Diagram
|
|
290
|
+
|
|
291
|
+
**Type:** sequence
|
|
292
|
+
**Description:** User authentication flow
|
|
293
|
+
|
|
294
|
+
### Mermaid Code
|
|
295
|
+
|
|
296
|
+
\`\`\`mermaid
|
|
297
|
+
sequenceDiagram
|
|
298
|
+
User->>Auth: Login request
|
|
299
|
+
Auth->>DB: Validate credentials
|
|
300
|
+
DB-->>Auth: User data
|
|
301
|
+
Auth-->>User: JWT token
|
|
302
|
+
\`\`\`
|
|
303
|
+
|
|
304
|
+
### Rendered
|
|
305
|
+
|
|
306
|
+
[PNG/SVG image displayed]
|
|
307
|
+
|
|
308
|
+
### Usage
|
|
309
|
+
|
|
310
|
+
- Embed in GitHub markdown (supports Mermaid natively)
|
|
311
|
+
- Use Mermaid Live Editor for modifications
|
|
312
|
+
- Export to PNG/SVG for presentations
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Rendering Options
|
|
318
|
+
|
|
319
|
+
| Platform | Mermaid Support |
|
|
320
|
+
| ------------ | -------------------- |
|
|
321
|
+
| GitHub | Native in markdown |
|
|
322
|
+
| GitLab | Native in markdown |
|
|
323
|
+
| Notion | Via code block |
|
|
324
|
+
| Confluence | Via plugin |
|
|
325
|
+
| VS Code | Via extension |
|
|
326
|
+
| Mermaid Live | https://mermaid.live |
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Limitations
|
|
331
|
+
|
|
332
|
+
| Limitation | Workaround |
|
|
333
|
+
| ------------------- | --------------------------------------------------- |
|
|
334
|
+
| Very large diagrams | Break into multiple smaller diagrams |
|
|
335
|
+
| Custom icons | Use external tool, embed as image |
|
|
336
|
+
| Precise positioning | Mermaid auto-layouts; use external tool for control |
|
|
337
|
+
| Complex styling | Basic theming only; export SVG for advanced styling |
|
|
338
|
+
| Wireframes | AI-generated image better than Mermaid |
|
|
339
|
+
|
|
340
|
+
---
|
|
44
341
|
|
|
45
|
-
|
|
46
|
-
- Mermaid code file (.mmd)
|
|
342
|
+
## Related Commands
|
|
47
343
|
|
|
48
|
-
|
|
344
|
+
| Need | Command |
|
|
345
|
+
| -------------------- | ------------------ |
|
|
346
|
+
| Analyze mockup | `/analyze-mockup` |
|
|
347
|
+
| Generate image | `/generate-image` |
|
|
348
|
+
| Review architecture | `/review-codebase` |
|
|
349
|
+
| Create documentation | `/summarize` |
|