agent-canvas 0.1.16 → 0.1.18
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/bin/agent-canvas.ts +3 -0
- package/bin/lib/commands/install.ts +7 -7
- package/bin/lib/commands/instructions.ts +66 -0
- package/bin/lib/instructions/component-callout.md +27 -0
- package/bin/lib/instructions/component-checklist.md +17 -0
- package/bin/lib/instructions/component-choice.md +27 -0
- package/bin/lib/instructions/component-codeblock.md +24 -0
- package/bin/lib/instructions/component-custom.md +34 -0
- package/bin/lib/instructions/component-diff.md +18 -0
- package/bin/lib/instructions/component-filepreview.md +15 -0
- package/bin/lib/instructions/component-image.md +17 -0
- package/bin/lib/instructions/component-item.md +43 -0
- package/bin/lib/instructions/component-markdown.md +33 -0
- package/bin/lib/instructions/component-mermaid.md +40 -0
- package/bin/lib/instructions/component-multichoice.md +19 -0
- package/bin/lib/instructions/component-note.md +11 -0
- package/bin/lib/instructions/component-priority.md +15 -0
- package/bin/lib/instructions/component-rangeinput.md +20 -0
- package/bin/lib/instructions/component-section.md +22 -0
- package/bin/lib/instructions/component-svg.md +31 -0
- package/bin/lib/instructions/component-table.md +21 -0
- package/bin/lib/instructions/component-usefeedback.md +33 -0
- package/bin/lib/instructions/component-userinput.md +17 -0
- package/bin/lib/instructions/flow-decision.md +53 -0
- package/bin/lib/instructions/flow-explain.md +47 -0
- package/bin/lib/instructions/flow-feature.md +188 -0
- package/bin/lib/instructions/flow-plan.md +106 -0
- package/bin/lib/instructions/flow-review.md +60 -0
- package/bin/lib/instructions/overview.md +173 -0
- package/bin/lib/instructions/theming.md +50 -0
- package/daemon/client/AnnotationSidebar.tsx +40 -20
- package/daemon/client/App.tsx +8 -1
- package/daemon/dist/client.js +35 -35
- package/daemon/src/compiler.ts +1 -0
- package/daemon/src/handlers/api.ts +3 -1
- package/daemon/src/server.ts +1 -1
- package/daemon/src/websocket.ts +62 -1
- package/package.json +1 -1
- package/skills/canvas/SKILL.md +9 -194
- package/skills/canvas/components.md +0 -403
- package/skills/canvas/flows.md +0 -406
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# DECISION Flow
|
|
2
|
+
|
|
3
|
+
**When**: User needs help choosing between options. "Should we use X or Y?", "What database?", "Monorepo or polyrepo?"
|
|
4
|
+
|
|
5
|
+
**Phases**: Single canvas, possibly follow-up for deeper comparison.
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
<Section title="Decision: [What needs to be decided]">
|
|
9
|
+
[Context — why this decision matters and what constraints exist.]
|
|
10
|
+
</Section>
|
|
11
|
+
|
|
12
|
+
<Section title="Option A: [Name]">
|
|
13
|
+
<Item label="Pros" badge="pro" badgeVariant="success">
|
|
14
|
+
[Benefits of this option.]
|
|
15
|
+
</Item>
|
|
16
|
+
<Item label="Cons" badge="con" badgeVariant="danger">
|
|
17
|
+
[Drawbacks.]
|
|
18
|
+
</Item>
|
|
19
|
+
<Item label="Effort" badge="effort" badgeVariant="info">
|
|
20
|
+
[Rough effort estimate.]
|
|
21
|
+
</Item>
|
|
22
|
+
</Section>
|
|
23
|
+
|
|
24
|
+
<Section title="Option B: [Name]">
|
|
25
|
+
<Item label="Pros" badge="pro" badgeVariant="success">
|
|
26
|
+
[Benefits.]
|
|
27
|
+
</Item>
|
|
28
|
+
<Item label="Cons" badge="con" badgeVariant="danger">
|
|
29
|
+
[Drawbacks.]
|
|
30
|
+
</Item>
|
|
31
|
+
<Item label="Effort" badge="effort" badgeVariant="info">
|
|
32
|
+
[Effort.]
|
|
33
|
+
</Item>
|
|
34
|
+
</Section>
|
|
35
|
+
|
|
36
|
+
<Section title="Comparison">
|
|
37
|
+
<Table headers={["Criteria", "Option A", "Option B"]} rows={[
|
|
38
|
+
["Performance", "---", "---"],
|
|
39
|
+
["Complexity", "---", "---"],
|
|
40
|
+
["Maintenance", "---", "---"],
|
|
41
|
+
]} />
|
|
42
|
+
</Section>
|
|
43
|
+
|
|
44
|
+
<Section title="Recommendation">
|
|
45
|
+
<Callout type="tip">
|
|
46
|
+
I recommend **Option A** because [reasoning].
|
|
47
|
+
However, if [condition], Option B would be better.
|
|
48
|
+
</Callout>
|
|
49
|
+
|
|
50
|
+
<Choice id="decision" label="Which direction?" required
|
|
51
|
+
options={["Go with Option A", "Go with Option B", "Need more info — I'll annotate questions"]} />
|
|
52
|
+
</Section>
|
|
53
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# EXPLAIN Flow
|
|
2
|
+
|
|
3
|
+
**When**: User wants to understand how something works. "Explain the auth system", "how does X work", "walk me through the architecture".
|
|
4
|
+
|
|
5
|
+
**Phases**: Usually a single canvas, occasionally a follow-up if the user has questions.
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
<Section title="How [System/Feature] Works">
|
|
9
|
+
[High-level overview in plain language.]
|
|
10
|
+
|
|
11
|
+
<Mermaid>{`
|
|
12
|
+
graph TD
|
|
13
|
+
A[Request] --> B{Auth?}
|
|
14
|
+
B -->|Yes| C[Process]
|
|
15
|
+
B -->|No| D[401]
|
|
16
|
+
`}</Mermaid>
|
|
17
|
+
</Section>
|
|
18
|
+
|
|
19
|
+
<Section title="Key Components">
|
|
20
|
+
<Item label="[Component name]" badge="core">
|
|
21
|
+
[What it does, where it lives.]
|
|
22
|
+
<FilePreview path="src/auth/middleware.ts" />
|
|
23
|
+
</Item>
|
|
24
|
+
|
|
25
|
+
<Item label="[Component name]" badge="core">
|
|
26
|
+
[Description.]
|
|
27
|
+
</Item>
|
|
28
|
+
</Section>
|
|
29
|
+
|
|
30
|
+
<Section title="Data Flow">
|
|
31
|
+
[Step-by-step walkthrough of how data moves through the system.]
|
|
32
|
+
|
|
33
|
+
<Mermaid>{`
|
|
34
|
+
sequenceDiagram
|
|
35
|
+
Client->>+API: POST /login
|
|
36
|
+
API->>+DB: Find user
|
|
37
|
+
DB-->>-API: User record
|
|
38
|
+
API-->>-Client: JWT token
|
|
39
|
+
`}</Mermaid>
|
|
40
|
+
</Section>
|
|
41
|
+
|
|
42
|
+
<Section title="Gotchas & Edge Cases">
|
|
43
|
+
<Item label="[Non-obvious thing]" badge="warning" badgeVariant="warning">
|
|
44
|
+
[Explanation of something surprising or easy to get wrong.]
|
|
45
|
+
</Item>
|
|
46
|
+
</Section>
|
|
47
|
+
```
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# FEATURE Flow
|
|
2
|
+
|
|
3
|
+
**When**: User wants something built but the requirements aren't fully clear.
|
|
4
|
+
|
|
5
|
+
**Phases**: Discovery → Requirements → Plan → [Implementation] → Summary
|
|
6
|
+
|
|
7
|
+
## Phase 1: Discovery (`discovery.jsx`)
|
|
8
|
+
|
|
9
|
+
Goal: understand scope, constraints, and user expectations.
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
<Section title="Discovery: [Feature Name]">
|
|
13
|
+
Let me understand what we're building before diving into implementation.
|
|
14
|
+
|
|
15
|
+
<Item label="My understanding so far" badge="context" badgeVariant="info">
|
|
16
|
+
[Summarize what you already know from the conversation and codebase exploration.]
|
|
17
|
+
</Item>
|
|
18
|
+
</Section>
|
|
19
|
+
|
|
20
|
+
<Section title="Scope & Direction">
|
|
21
|
+
<Choice id="scope" label="How broad should this be?" required
|
|
22
|
+
options={["Minimal — just the core", "Standard — core + common edge cases", "Comprehensive — production-ready with all edge cases"]} />
|
|
23
|
+
|
|
24
|
+
<UserInput id="must-have" label="What's the one thing this absolutely must do?" required />
|
|
25
|
+
<UserInput id="must-not" label="Anything I should explicitly avoid or not touch?" />
|
|
26
|
+
</Section>
|
|
27
|
+
|
|
28
|
+
<Section title="Technical Context">
|
|
29
|
+
<MultiChoice id="areas" label="Which areas will be affected?" required
|
|
30
|
+
options={["Database / models", "API / backend logic", "Frontend / UI", "Auth / permissions", "Infrastructure / deployment", "Tests"]} />
|
|
31
|
+
|
|
32
|
+
<UserInput id="constraints" label="Any technical constraints? (existing libs, patterns to follow, things to avoid)" />
|
|
33
|
+
</Section>
|
|
34
|
+
|
|
35
|
+
<Section title="Deep Dive (optional)">
|
|
36
|
+
I can do a thorough interview in specific areas before planning.
|
|
37
|
+
|
|
38
|
+
<MultiChoice id="interview-areas" label="Want me to interview you about any of these?"
|
|
39
|
+
options={["Backend architecture & data model", "API design & contracts", "UI/UX behavior & states", "Error handling & edge cases", "Performance & scaling", "Security", "Testing strategy"]} />
|
|
40
|
+
</Section>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If the user selects interview areas, push follow-up canvases with deep questions for each area. Example for "Backend architecture":
|
|
44
|
+
|
|
45
|
+
```jsx
|
|
46
|
+
<Section title="Backend Deep Dive">
|
|
47
|
+
<UserInput id="data-shape" label="Describe the data shape / entities involved" required />
|
|
48
|
+
<Choice id="mutation-pattern" label="How should mutations work?"
|
|
49
|
+
options={["Sync — mutate and return", "Async — queue and process", "Event-driven — publish and react"]} />
|
|
50
|
+
<UserInput id="invariants" label="What business rules / invariants must always hold?" />
|
|
51
|
+
<UserInput id="existing-patterns" label="Any existing patterns in the codebase I should follow?" />
|
|
52
|
+
</Section>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Phase 2: Requirements (`requirements.jsx`)
|
|
56
|
+
|
|
57
|
+
Goal: formalize what will be built. The user confirms or corrects before planning.
|
|
58
|
+
|
|
59
|
+
```jsx
|
|
60
|
+
<Section title="Requirements: [Feature Name]">
|
|
61
|
+
Based on our discovery, here's what I'll build.
|
|
62
|
+
|
|
63
|
+
<Callout type="info">
|
|
64
|
+
Review each requirement. Annotate anything that's wrong or missing.
|
|
65
|
+
</Callout>
|
|
66
|
+
</Section>
|
|
67
|
+
|
|
68
|
+
<Section title="Functional Requirements">
|
|
69
|
+
<Item id="req-1" label="[Requirement title]" badge="must-have" badgeVariant="danger">
|
|
70
|
+
[Detailed description.]
|
|
71
|
+
</Item>
|
|
72
|
+
<Item id="req-2" label="[Requirement title]" badge="should-have" badgeVariant="warning">
|
|
73
|
+
[Description.]
|
|
74
|
+
</Item>
|
|
75
|
+
<Item id="req-3" label="[Requirement title]" badge="nice-to-have" badgeVariant="info">
|
|
76
|
+
[Description.]
|
|
77
|
+
</Item>
|
|
78
|
+
</Section>
|
|
79
|
+
|
|
80
|
+
<Section title="Non-Functional Requirements">
|
|
81
|
+
<Item id="nfr-1" label="Performance">
|
|
82
|
+
[Expected throughput, latency constraints.]
|
|
83
|
+
</Item>
|
|
84
|
+
<Item id="nfr-2" label="Security">
|
|
85
|
+
[Auth model, data sensitivity.]
|
|
86
|
+
</Item>
|
|
87
|
+
</Section>
|
|
88
|
+
|
|
89
|
+
<Section title="Out of Scope">
|
|
90
|
+
Explicitly NOT doing in this iteration:
|
|
91
|
+
<Checklist items={[
|
|
92
|
+
{ label: "[Thing deliberately excluded]", checked: true },
|
|
93
|
+
{ label: "[Another exclusion]", checked: true }
|
|
94
|
+
]} />
|
|
95
|
+
</Section>
|
|
96
|
+
|
|
97
|
+
<Section title="Open Questions">
|
|
98
|
+
<UserInput id="open-1" label="[Question that emerged during discovery]" required />
|
|
99
|
+
</Section>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Phase 3: Plan (`plan.jsx`)
|
|
103
|
+
|
|
104
|
+
Goal: detailed implementation plan with file-level changes. The user approves before coding.
|
|
105
|
+
|
|
106
|
+
```jsx
|
|
107
|
+
<Section title="Implementation Plan: [Feature Name]">
|
|
108
|
+
[Brief summary — what, why, rough approach.]
|
|
109
|
+
|
|
110
|
+
<Item label="Estimated scope" badge="info">
|
|
111
|
+
[N files changed, M new files. Estimated N rounds of implementation.]
|
|
112
|
+
</Item>
|
|
113
|
+
</Section>
|
|
114
|
+
|
|
115
|
+
<Section title="Phase 1: [Phase name]">
|
|
116
|
+
[What this phase accomplishes and why it's first.]
|
|
117
|
+
|
|
118
|
+
<Item id="step-1" label="[Step description]" badge="todo">
|
|
119
|
+
[What exactly will change.]
|
|
120
|
+
<FilePreview path="src/relevant/file.ts" lines={[10, 30]} />
|
|
121
|
+
<Callout type="tip">
|
|
122
|
+
[Any non-obvious approach or tradeoff.]
|
|
123
|
+
</Callout>
|
|
124
|
+
</Item>
|
|
125
|
+
|
|
126
|
+
<Item id="step-2" label="[Step description]" badge="todo">
|
|
127
|
+
[Description with code example if helpful.]
|
|
128
|
+
<CodeBlock language="typescript">
|
|
129
|
+
// Proposed interface
|
|
130
|
+
interface AuthToken {
|
|
131
|
+
userId: string;
|
|
132
|
+
expiresAt: number;
|
|
133
|
+
}
|
|
134
|
+
</CodeBlock>
|
|
135
|
+
</Item>
|
|
136
|
+
</Section>
|
|
137
|
+
|
|
138
|
+
<Section title="Testing Strategy">
|
|
139
|
+
<Checklist items={[
|
|
140
|
+
{ label: "[Test case 1]", checked: false },
|
|
141
|
+
{ label: "[Test case 2]", checked: false }
|
|
142
|
+
]} />
|
|
143
|
+
</Section>
|
|
144
|
+
|
|
145
|
+
<Section title="Risks & Tradeoffs">
|
|
146
|
+
<Item label="[Risk]" badge="warning" badgeVariant="warning">
|
|
147
|
+
[Description and mitigation.]
|
|
148
|
+
</Item>
|
|
149
|
+
</Section>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Phase 4: Summary (`summary.jsx`)
|
|
153
|
+
|
|
154
|
+
Push AFTER implementation is complete. Always do this, even briefly. **After pushing the summary, start a background watch** — the user may want to provide feedback (follow-up requests, corrections, questions about what was done).
|
|
155
|
+
|
|
156
|
+
```jsx
|
|
157
|
+
<Section title="Implementation Summary: [Feature Name]">
|
|
158
|
+
<Item label="Status" badge="done" badgeVariant="success">
|
|
159
|
+
[One-line summary of what was accomplished.]
|
|
160
|
+
</Item>
|
|
161
|
+
</Section>
|
|
162
|
+
|
|
163
|
+
<Section title="What Was Done">
|
|
164
|
+
<Item id="done-1" label="[Change description]" badge="done" badgeVariant="success">
|
|
165
|
+
[Details of what was implemented and where.]
|
|
166
|
+
</Item>
|
|
167
|
+
</Section>
|
|
168
|
+
|
|
169
|
+
<Section title="Deviations from Plan">
|
|
170
|
+
[What changed during implementation and why.]
|
|
171
|
+
<Item id="dev-1" label="[What changed]" badge="changed" badgeVariant="warning">
|
|
172
|
+
[Why it deviated and what was done instead.]
|
|
173
|
+
</Item>
|
|
174
|
+
</Section>
|
|
175
|
+
|
|
176
|
+
<Section title="Manual Testing Needed">
|
|
177
|
+
<Callout type="warning">These need manual verification:</Callout>
|
|
178
|
+
<Checklist items={[
|
|
179
|
+
{ label: "[Thing to test manually]", checked: false },
|
|
180
|
+
]} />
|
|
181
|
+
</Section>
|
|
182
|
+
|
|
183
|
+
<Section title="Next Steps">
|
|
184
|
+
<Item id="next-1" label="[Follow-up task]" badge="todo">
|
|
185
|
+
[What should happen next, if anything.]
|
|
186
|
+
</Item>
|
|
187
|
+
</Section>
|
|
188
|
+
```
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# PLAN Flow
|
|
2
|
+
|
|
3
|
+
**When**: User has clear requirements — skip discovery. Go straight to planning.
|
|
4
|
+
|
|
5
|
+
**Phases**: Plan → [Implementation] → Summary
|
|
6
|
+
|
|
7
|
+
If during planning you realize requirements are ambiguous, pivot to a quick discovery round (see `flow-feature`).
|
|
8
|
+
|
|
9
|
+
## Phase 1: Plan (`plan.jsx`)
|
|
10
|
+
|
|
11
|
+
Goal: detailed implementation plan with file-level changes. The user approves before coding.
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
<Section title="Implementation Plan: [Feature Name]">
|
|
15
|
+
[Brief summary — what, why, rough approach.]
|
|
16
|
+
|
|
17
|
+
<Item label="Estimated scope" badge="info">
|
|
18
|
+
[N files changed, M new files. Estimated N rounds of implementation.]
|
|
19
|
+
</Item>
|
|
20
|
+
</Section>
|
|
21
|
+
|
|
22
|
+
<Section title="Phase 1: [Phase name]">
|
|
23
|
+
[What this phase accomplishes and why it's first.]
|
|
24
|
+
|
|
25
|
+
<Item id="step-1" label="[Step description]" badge="todo">
|
|
26
|
+
[What exactly will change.]
|
|
27
|
+
<FilePreview path="src/relevant/file.ts" lines={[10, 30]} />
|
|
28
|
+
<Callout type="tip">
|
|
29
|
+
[Any non-obvious approach or tradeoff.]
|
|
30
|
+
</Callout>
|
|
31
|
+
</Item>
|
|
32
|
+
|
|
33
|
+
<Item id="step-2" label="[Step description]" badge="todo">
|
|
34
|
+
[Description with code example if helpful.]
|
|
35
|
+
<CodeBlock language="typescript">
|
|
36
|
+
// Proposed interface
|
|
37
|
+
interface AuthToken {
|
|
38
|
+
userId: string;
|
|
39
|
+
expiresAt: number;
|
|
40
|
+
}
|
|
41
|
+
</CodeBlock>
|
|
42
|
+
</Item>
|
|
43
|
+
</Section>
|
|
44
|
+
|
|
45
|
+
<Section title="Testing Strategy">
|
|
46
|
+
<Checklist items={[
|
|
47
|
+
{ label: "[Test case 1]", checked: false },
|
|
48
|
+
{ label: "[Test case 2]", checked: false }
|
|
49
|
+
]} />
|
|
50
|
+
</Section>
|
|
51
|
+
|
|
52
|
+
<Section title="Risks & Tradeoffs">
|
|
53
|
+
<Item label="[Risk]" badge="warning" badgeVariant="warning">
|
|
54
|
+
[Description and mitigation.]
|
|
55
|
+
</Item>
|
|
56
|
+
</Section>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Phase 2: Summary (`summary.jsx`)
|
|
60
|
+
|
|
61
|
+
Push AFTER implementation is complete. Always do this, even briefly. **After pushing the summary, start a background watch** — the user may want to provide feedback (follow-up requests, corrections, questions about what was done).
|
|
62
|
+
|
|
63
|
+
```jsx
|
|
64
|
+
<Section title="Implementation Summary: [Feature Name]">
|
|
65
|
+
<Item label="Status" badge="done" badgeVariant="success">
|
|
66
|
+
[One-line summary of what was accomplished.]
|
|
67
|
+
</Item>
|
|
68
|
+
</Section>
|
|
69
|
+
|
|
70
|
+
<Section title="What Was Done">
|
|
71
|
+
<Item id="done-1" label="[Change description]" badge="done" badgeVariant="success">
|
|
72
|
+
[Details of what was implemented and where.]
|
|
73
|
+
</Item>
|
|
74
|
+
</Section>
|
|
75
|
+
|
|
76
|
+
<Section title="Deviations from Plan">
|
|
77
|
+
[What changed during implementation and why.]
|
|
78
|
+
<Item id="dev-1" label="[What changed]" badge="changed" badgeVariant="warning">
|
|
79
|
+
[Why it deviated and what was done instead.]
|
|
80
|
+
</Item>
|
|
81
|
+
</Section>
|
|
82
|
+
|
|
83
|
+
<Section title="Manual Testing Needed">
|
|
84
|
+
<Callout type="warning">These need manual verification:</Callout>
|
|
85
|
+
<Checklist items={[
|
|
86
|
+
{ label: "[Thing to test manually]", checked: false },
|
|
87
|
+
]} />
|
|
88
|
+
</Section>
|
|
89
|
+
|
|
90
|
+
<Section title="Next Steps">
|
|
91
|
+
<Item id="next-1" label="[Follow-up task]" badge="todo">
|
|
92
|
+
[What should happen next, if anything.]
|
|
93
|
+
</Item>
|
|
94
|
+
</Section>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Skipping & Combining
|
|
98
|
+
|
|
99
|
+
| Situation | Action |
|
|
100
|
+
|---|---|
|
|
101
|
+
| User said "just do it" with clear instructions | Implement directly, push summary after |
|
|
102
|
+
| Simple change (< 3 files) | Probably skip canvas entirely |
|
|
103
|
+
| User explicitly says "don't plan, just code" | Implement, push summary |
|
|
104
|
+
| Mid-flow user says "looks good, go ahead" | Skip remaining review rounds |
|
|
105
|
+
|
|
106
|
+
**Always push a summary after implementation** (unless trivially small) **and watch for feedback** — the user may want to respond with follow-ups or corrections.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# REVIEW Flow
|
|
2
|
+
|
|
3
|
+
**When**: User wants code review, architecture audit, security review, or similar.
|
|
4
|
+
|
|
5
|
+
**Phases**: Findings → (optional) Fix Plan → Summary
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
<Section title="Review: [What's Being Reviewed]">
|
|
9
|
+
[Scope of the review — what was examined, methodology.]
|
|
10
|
+
|
|
11
|
+
<Item label="Files reviewed" badge="scope" badgeVariant="info">
|
|
12
|
+
[List or count of what was examined.]
|
|
13
|
+
</Item>
|
|
14
|
+
</Section>
|
|
15
|
+
|
|
16
|
+
<Section title="Critical Issues">
|
|
17
|
+
<Item id="crit-1" label="[Issue title]" badge="critical" badgeVariant="danger">
|
|
18
|
+
[Description of the issue and its impact.]
|
|
19
|
+
<FilePreview path="src/auth.ts" lines={[42, 55]} />
|
|
20
|
+
<CodeBlock language="typescript">
|
|
21
|
+
// Proposed fix
|
|
22
|
+
if (!token) throw new UnauthorizedError();
|
|
23
|
+
</CodeBlock>
|
|
24
|
+
</Item>
|
|
25
|
+
</Section>
|
|
26
|
+
|
|
27
|
+
<Section title="Warnings">
|
|
28
|
+
<Item id="warn-1" label="[Issue title]" badge="warning" badgeVariant="warning">
|
|
29
|
+
[Description. Less severe but should be addressed.]
|
|
30
|
+
</Item>
|
|
31
|
+
</Section>
|
|
32
|
+
|
|
33
|
+
<Section title="Suggestions">
|
|
34
|
+
<Item id="sug-1" label="[Suggestion]" badge="suggestion" badgeVariant="info">
|
|
35
|
+
[Nice-to-have improvement. Not blocking.]
|
|
36
|
+
</Item>
|
|
37
|
+
</Section>
|
|
38
|
+
|
|
39
|
+
<Section title="What Looks Good">
|
|
40
|
+
<Item label="[Positive observation]" badge="good" badgeVariant="success">
|
|
41
|
+
[Call out things that are well-implemented. Important for balanced reviews.]
|
|
42
|
+
</Item>
|
|
43
|
+
</Section>
|
|
44
|
+
|
|
45
|
+
<Section title="Action Items">
|
|
46
|
+
<Checklist items={[
|
|
47
|
+
{ label: "[Fix critical-1: description]", checked: false },
|
|
48
|
+
{ label: "[Address warning-1: description]", checked: false },
|
|
49
|
+
{ label: "[Consider suggestion-1: description]", checked: false }
|
|
50
|
+
]} />
|
|
51
|
+
|
|
52
|
+
<Choice id="review-action" label="How should I proceed?" required
|
|
53
|
+
options={[
|
|
54
|
+
"Fix all critical + warnings",
|
|
55
|
+
"Fix critical only, I'll handle warnings",
|
|
56
|
+
"Don't fix anything, this was informational",
|
|
57
|
+
"Let me annotate which ones to fix"
|
|
58
|
+
]} />
|
|
59
|
+
</Section>
|
|
60
|
+
```
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Agent Canvas — Instruction Guide
|
|
2
|
+
|
|
3
|
+
Canvas opens a rich, annotatable document in the user's browser. You write JSX, the user reviews and annotates it like Google Docs, and feedback comes back as markdown.
|
|
4
|
+
|
|
5
|
+
Use it whenever structured visual communication beats inline chat: plans, reviews, decisions, explanations, discovery interviews.
|
|
6
|
+
|
|
7
|
+
**Note**: Replace all `<session-id>` references below with your actual canvas session ID (provided in the skill header).
|
|
8
|
+
|
|
9
|
+
## Core Workflow
|
|
10
|
+
|
|
11
|
+
### 1. Write JSX
|
|
12
|
+
|
|
13
|
+
Use the **Write** tool to create `.jsx` files in `.claude/agent-canvas/<session-id>/`:
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
// .claude/agent-canvas/<session-id>/plan.jsx
|
|
17
|
+
|
|
18
|
+
<Section title="Authentication Redesign">
|
|
19
|
+
A proposal to replace session-based auth with JWT tokens.
|
|
20
|
+
|
|
21
|
+
<Item id="current" label="Current state" badge="context" badgeVariant="info">
|
|
22
|
+
The app uses express-session with Redis store.
|
|
23
|
+
<FilePreview path="src/auth/session.ts" lines={[1, 45]} />
|
|
24
|
+
</Item>
|
|
25
|
+
|
|
26
|
+
<Item id="proposal" label="Proposed change" badge="proposal">
|
|
27
|
+
Switch to stateless JWT with refresh token rotation.
|
|
28
|
+
<Callout type="warning">This will invalidate all existing sessions.</Callout>
|
|
29
|
+
</Item>
|
|
30
|
+
</Section>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Components are auto-available — no imports needed. The file can be a JSX fragment (just tags) or a full module with `export default`.
|
|
34
|
+
|
|
35
|
+
### 2. Push
|
|
36
|
+
|
|
37
|
+
Push the directory to open all canvases in the browser:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
bunx agent-canvas push .claude/agent-canvas/<session-id>/ --session <session-id> --label "Implementation Plan"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
All `*.jsx` files in the directory are pushed as a snapshot. Each file appears as a separate tab. **Always show the `browserUrl` from the output to the user.**
|
|
44
|
+
|
|
45
|
+
Options:
|
|
46
|
+
- `--label <text>` — revision label shown in the UI
|
|
47
|
+
- `--response <text>` — short banner explaining how you addressed prior feedback (2-4 sentences, focus on "why" not "what")
|
|
48
|
+
|
|
49
|
+
### 3. Watch for feedback
|
|
50
|
+
|
|
51
|
+
Run the watch command **in the background** using the Bash tool's `run_in_background` parameter:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Use Bash tool with run_in_background: true
|
|
55
|
+
bunx agent-canvas watch --session <session-id>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
You will be **automatically notified** when the user submits feedback. Do NOT poll, sleep, or proactively check. Just stop and wait.
|
|
59
|
+
|
|
60
|
+
**Important**: The push → watch sequence is atomic. Never push without watching. After starting the background watch, do not continue with other work unless instructed.
|
|
61
|
+
|
|
62
|
+
### 4. Iterate
|
|
63
|
+
|
|
64
|
+
Use the **Edit** tool to modify existing JSX based on feedback — targeted edits, not full rewrites. Then push and watch again.
|
|
65
|
+
|
|
66
|
+
### 5. Fetch (non-blocking alternative)
|
|
67
|
+
|
|
68
|
+
If the user tells you they've already submitted feedback:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
bunx agent-canvas fetch --session <session-id>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Returns immediately — prints feedback if available, otherwise no output.
|
|
75
|
+
|
|
76
|
+
## Multiple Canvases
|
|
77
|
+
|
|
78
|
+
Use different files for different phases or concerns:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
.claude/agent-canvas/<session-id>/
|
|
82
|
+
discovery.jsx # Discovery interview
|
|
83
|
+
requirements.jsx # Requirements spec
|
|
84
|
+
plan.jsx # Implementation plan
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Write new files as phases progress, then push the directory. Previous files remain visible as context.
|
|
88
|
+
|
|
89
|
+
## File Location
|
|
90
|
+
|
|
91
|
+
All canvas files go in `.claude/agent-canvas/<session-id>/` within the project root. Add `.claude/agent-canvas/` to `.gitignore`.
|
|
92
|
+
|
|
93
|
+
## Components
|
|
94
|
+
|
|
95
|
+
All components are globally available in canvas JSX — no imports needed. For inline styling use `style={{ ... }}` — Tailwind is NOT available.
|
|
96
|
+
|
|
97
|
+
**Never hardcode hex colors** — use CSS variables: `var(--color-text-primary)`, `var(--color-bg-surface)`, `var(--color-accent-blue)`, etc.
|
|
98
|
+
|
|
99
|
+
### Layout
|
|
100
|
+
- **Section** — top-level collapsible grouping with serif heading. Props: `title`, `collapsed`
|
|
101
|
+
|
|
102
|
+
### Content
|
|
103
|
+
- **Item** — primary content block (tasks, findings, requirements). Props: `id`, `label`, `badge`, `badgeVariant`, `status`
|
|
104
|
+
- **CodeBlock** — syntax-highlighted code. Props: `language`
|
|
105
|
+
- **FilePreview** — project file preview. Props: `path`, `lines` ([start, end])
|
|
106
|
+
- **Markdown** — renders markdown content. Props: `file` (path) or children (inline markdown string)
|
|
107
|
+
- **ImageView** — displays an image. Props: `src`, `alt`, `caption`, `width`
|
|
108
|
+
- **Diff** — side-by-side diff view. Props: `before`, `after`, `language`
|
|
109
|
+
- **Table** — data table. Props: `headers`, `rows`
|
|
110
|
+
- **Checklist** — checkbox list. Props: `items` ([{ label, checked }])
|
|
111
|
+
- **Mermaid** — diagram rendering. Children: mermaid syntax string
|
|
112
|
+
- **Callout** — alert box. Props: `type` (info/warning/danger/tip)
|
|
113
|
+
- **Note** — soft aside for non-critical info
|
|
114
|
+
- **Priority** — inline priority badge. Props: `level` (high/medium/low)
|
|
115
|
+
|
|
116
|
+
### Interactive (User Input)
|
|
117
|
+
- **Choice** — single-select radio group. Props: `id`, `label`, `options`, `required`
|
|
118
|
+
- **MultiChoice** — multi-select checkboxes. Props: `id`, `label`, `options`, `required`
|
|
119
|
+
- **UserInput** — free text input. Props: `id`, `label`, `placeholder`, `required`
|
|
120
|
+
- **RangeInput** — numeric slider. Props: `id`, `label`, `min`, `max`, `minLabel`, `maxLabel`, `required`
|
|
121
|
+
|
|
122
|
+
### Advanced
|
|
123
|
+
- **useFeedback** — hook for custom components to contribute computed data to feedback
|
|
124
|
+
- **Custom components** — use `export default function Canvas()` module format to define helpers
|
|
125
|
+
|
|
126
|
+
Run `bunx agent-canvas instructions <topic>` for detailed docs on any component or flow.
|
|
127
|
+
|
|
128
|
+
## Choosing a Flow
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
User wants something built/changed?
|
|
132
|
+
├─ Vague request → FEATURE flow (discovery → requirements → plan → implement → summary)
|
|
133
|
+
├─ Clear request with specifics → PLAN flow (plan → implement → summary)
|
|
134
|
+
├─ Complete instructions → skip canvas, implement directly, optionally push summary
|
|
135
|
+
|
|
136
|
+
User wants to understand something? → EXPLAIN flow
|
|
137
|
+
User wants review/audit? → REVIEW flow
|
|
138
|
+
User wants to make a decision? → DECISION flow
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Adapt dynamically**: flows are guidelines, not rigid pipelines. Skip or combine phases when appropriate:
|
|
142
|
+
|
|
143
|
+
| Situation | Action |
|
|
144
|
+
|---|---|
|
|
145
|
+
| User gave a detailed spec | Skip to PLAN (skip discovery + requirements) |
|
|
146
|
+
| User said "just do it" with clear instructions | Implement directly, push summary after |
|
|
147
|
+
| Simple change (< 3 files) | Probably skip canvas entirely |
|
|
148
|
+
| User explicitly says "don't plan, just code" | Implement, push summary |
|
|
149
|
+
| Mid-flow user says "looks good, go ahead" | Skip remaining review rounds |
|
|
150
|
+
| Discovery reveals it's trivial | Collapse remaining phases into one canvas |
|
|
151
|
+
|
|
152
|
+
**Always push a summary after implementation** unless the change was trivially small (1-2 file edit).
|
|
153
|
+
|
|
154
|
+
## Flow Execution Pattern
|
|
155
|
+
|
|
156
|
+
1. **Determine flow** from user intent
|
|
157
|
+
2. **Announce** briefly: "I'll start with discovery, then create a detailed plan."
|
|
158
|
+
3. **Write canvas JSX** with the Write tool
|
|
159
|
+
4. **Push + show browserUrl** to the user
|
|
160
|
+
5. **IMMEDIATELY watch in background** — the push → watch sequence is atomic
|
|
161
|
+
6. **Read feedback** — check for annotations, answers, context files
|
|
162
|
+
7. **Edit and re-push + watch**, or advance to next phase
|
|
163
|
+
8. **After implementation**, push a summary canvas and **watch for feedback** — the user may want to respond
|
|
164
|
+
|
|
165
|
+
## Important Rules
|
|
166
|
+
|
|
167
|
+
- **Write** canvas files using the Write tool. Never use bash heredocs.
|
|
168
|
+
- **Edit** canvas files using the Edit tool. Never rewrite entire files.
|
|
169
|
+
- Every `<Item>` and interactive component needs a unique `id`.
|
|
170
|
+
- `<FilePreview path="...">` paths are relative to project root.
|
|
171
|
+
- Read any files the user added to context (listed under "Added context" in feedback).
|
|
172
|
+
- Always push a summary canvas after implementation, even if brief.
|
|
173
|
+
- When the user approves, confirm what you'll do next before proceeding.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Theming
|
|
2
|
+
|
|
3
|
+
Canvas supports light/dark themes. **Never hardcode hex colors** — use CSS variables in `style={{ }}`.
|
|
4
|
+
|
|
5
|
+
## CSS Variables
|
|
6
|
+
|
|
7
|
+
### Text
|
|
8
|
+
- `--color-text-primary` — main text
|
|
9
|
+
- `--color-text-secondary` — supporting text
|
|
10
|
+
- `--color-text-tertiary` — meta text, labels
|
|
11
|
+
- `--color-text-code` — inline code
|
|
12
|
+
- `--color-text-inverse` — text on dark backgrounds
|
|
13
|
+
|
|
14
|
+
### Backgrounds
|
|
15
|
+
- `--color-bg-base` — page background
|
|
16
|
+
- `--color-bg-surface` — card/section background
|
|
17
|
+
- `--color-bg-elevated` — floating elements
|
|
18
|
+
- `--color-bg-code` — code block background
|
|
19
|
+
- `--color-bg-input` — form input background
|
|
20
|
+
|
|
21
|
+
### Accents
|
|
22
|
+
- `--color-accent-green`, `--color-accent-green-muted`
|
|
23
|
+
- `--color-accent-amber`, `--color-accent-amber-muted`
|
|
24
|
+
- `--color-accent-red`, `--color-accent-red-muted`
|
|
25
|
+
- `--color-accent-blue`, `--color-accent-blue-muted`
|
|
26
|
+
|
|
27
|
+
### Borders
|
|
28
|
+
- `--color-border-subtle` — light separators
|
|
29
|
+
- `--color-border-medium` — visible borders
|
|
30
|
+
- `--color-border-hover` — interactive hover state
|
|
31
|
+
|
|
32
|
+
### Fonts
|
|
33
|
+
- `--font-heading` — section headings (Instrument Serif)
|
|
34
|
+
- `--font-body` — body text (Inter)
|
|
35
|
+
- `--font-mono` — code (JetBrains Mono)
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```jsx
|
|
40
|
+
<span style={{ color: 'var(--color-text-tertiary)', fontSize: '0.75rem' }}>meta text</span>
|
|
41
|
+
|
|
42
|
+
<div style={{
|
|
43
|
+
background: 'var(--color-bg-surface)',
|
|
44
|
+
border: '1px solid var(--color-border-subtle)',
|
|
45
|
+
borderRadius: '8px',
|
|
46
|
+
padding: '16px',
|
|
47
|
+
}}>
|
|
48
|
+
Custom styled container
|
|
49
|
+
</div>
|
|
50
|
+
```
|