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.
Files changed (41) hide show
  1. package/bin/agent-canvas.ts +3 -0
  2. package/bin/lib/commands/install.ts +7 -7
  3. package/bin/lib/commands/instructions.ts +66 -0
  4. package/bin/lib/instructions/component-callout.md +27 -0
  5. package/bin/lib/instructions/component-checklist.md +17 -0
  6. package/bin/lib/instructions/component-choice.md +27 -0
  7. package/bin/lib/instructions/component-codeblock.md +24 -0
  8. package/bin/lib/instructions/component-custom.md +34 -0
  9. package/bin/lib/instructions/component-diff.md +18 -0
  10. package/bin/lib/instructions/component-filepreview.md +15 -0
  11. package/bin/lib/instructions/component-image.md +17 -0
  12. package/bin/lib/instructions/component-item.md +43 -0
  13. package/bin/lib/instructions/component-markdown.md +33 -0
  14. package/bin/lib/instructions/component-mermaid.md +40 -0
  15. package/bin/lib/instructions/component-multichoice.md +19 -0
  16. package/bin/lib/instructions/component-note.md +11 -0
  17. package/bin/lib/instructions/component-priority.md +15 -0
  18. package/bin/lib/instructions/component-rangeinput.md +20 -0
  19. package/bin/lib/instructions/component-section.md +22 -0
  20. package/bin/lib/instructions/component-svg.md +31 -0
  21. package/bin/lib/instructions/component-table.md +21 -0
  22. package/bin/lib/instructions/component-usefeedback.md +33 -0
  23. package/bin/lib/instructions/component-userinput.md +17 -0
  24. package/bin/lib/instructions/flow-decision.md +53 -0
  25. package/bin/lib/instructions/flow-explain.md +47 -0
  26. package/bin/lib/instructions/flow-feature.md +188 -0
  27. package/bin/lib/instructions/flow-plan.md +106 -0
  28. package/bin/lib/instructions/flow-review.md +60 -0
  29. package/bin/lib/instructions/overview.md +173 -0
  30. package/bin/lib/instructions/theming.md +50 -0
  31. package/daemon/client/AnnotationSidebar.tsx +40 -20
  32. package/daemon/client/App.tsx +8 -1
  33. package/daemon/dist/client.js +35 -35
  34. package/daemon/src/compiler.ts +1 -0
  35. package/daemon/src/handlers/api.ts +3 -1
  36. package/daemon/src/server.ts +1 -1
  37. package/daemon/src/websocket.ts +62 -1
  38. package/package.json +1 -1
  39. package/skills/canvas/SKILL.md +9 -194
  40. package/skills/canvas/components.md +0 -403
  41. package/skills/canvas/flows.md +0 -406
@@ -1,403 +0,0 @@
1
- # Component Reference
2
-
3
- All components are available globally in canvas JSX — no imports needed.
4
- For inline styling use `style={{ ... }}`. Tailwind classes are NOT available.
5
-
6
- ## Theming
7
-
8
- **Never hardcode hex colors** — canvas supports light/dark themes. Use CSS variables in `style={{ }}`:
9
-
10
- - **Text:** `--color-text-primary`, `--color-text-secondary`, `--color-text-tertiary`, `--color-text-code`, `--color-text-inverse`
11
- - **Backgrounds:** `--color-bg-base`, `--color-bg-surface`, `--color-bg-elevated`, `--color-bg-code`, `--color-bg-input`
12
- - **Accents:** `--color-accent-{green,amber,red,blue}`, `--color-accent-{green,amber,red,blue}-muted`
13
- - **Borders:** `--color-border-subtle`, `--color-border-medium`, `--color-border-hover`
14
- - **Fonts:** `--font-heading`, `--font-body`, `--font-mono`
15
-
16
- ```jsx
17
- <span style={{ color: 'var(--color-text-tertiary)', fontSize: '0.75rem' }}>meta text</span>
18
- ```
19
-
20
- ---
21
-
22
- ## Layout
23
-
24
- ### `<Section title="string">`
25
-
26
- Top-level grouping. Rendered as a serif heading with generous spacing.
27
- Collapsible (chevron appears on hover). Children are the section body.
28
-
29
- ```jsx
30
- <Section title="Phase 1: Data Migration">
31
- A brief description of this section.
32
-
33
- {/* Items, callouts, code blocks, diagrams, etc. */}
34
- </Section>
35
- ```
36
-
37
- **Props:**
38
- - `title` (string, required) — section heading, rendered in Instrument Serif
39
- - `collapsed` (boolean, default false) — start collapsed
40
-
41
- ---
42
-
43
- ### `<Item id="string" label="string">`
44
-
45
- The primary content block. A flexible card-like row used for tasks, findings, requirements, observations, options — anything that has a title and details.
46
-
47
- Previously called "Task" — Item is the generalized version. It's a labeled sub-section with an optional status dot, badge, and children for details.
48
-
49
- ```jsx
50
- {/* As a plan task */}
51
- <Item id="migrate-db" label="Run database migration" badge="todo">
52
- Execute the migration script against staging first.
53
- <CodeBlock language="bash">npm run migrate:staging</CodeBlock>
54
- </Item>
55
-
56
- {/* As a review finding */}
57
- <Item id="finding-1" label="Missing null check in auth handler" badge="critical" badgeVariant="danger">
58
- The handler doesn't check for missing tokens.
59
- <FilePreview path="src/auth.ts" lines={[42, 48]} />
60
- </Item>
61
-
62
- {/* As a requirement */}
63
- <Item id="req-auth" label="JWT authentication" badge="must-have" badgeVariant="danger">
64
- All API endpoints must require a valid JWT token.
65
- </Item>
66
-
67
- {/* As an architecture component */}
68
- <Item label="API Gateway" badge="core" badgeVariant="info">
69
- Routes requests to downstream services. Handles rate limiting.
70
- </Item>
71
- ```
72
-
73
- **Props:**
74
- - `id` (string) — unique ID. Required if the item should be individually addressable in feedback. Optional for informational items.
75
- - `label` (string, required) — item title, rendered in Inter 600
76
- - `badge` (string) — short label shown as a small tag. Freeform text.
77
- - `badgeVariant` ("default" | "success" | "warning" | "danger" | "info") — badge color. Default is neutral gray.
78
- - `status` ("todo" | "done" | "blocked" | "in-progress") — shows a colored dot. Alternative to badge for plan-style items.
79
-
80
- **Badge vs Status**: Use `status` for things with a workflow state (tasks in a plan). Use `badge` for categorical labels (requirement priority, review severity, component type). You can use both on the same Item if needed.
81
-
82
- **Children**: Any content — text, components, code blocks, file previews, nested items. Rendered indented under the label.
83
-
84
- ---
85
-
86
- ## Code & Files
87
-
88
- ### `<FilePreview path="string">`
89
-
90
- Shows a syntax-highlighted preview of a project file. The daemon serves the file content from the project root.
91
-
92
- ```jsx
93
- <FilePreview path="src/auth/middleware.ts" />
94
- <FilePreview path="src/auth/middleware.ts" lines={[42, 87]} />
95
- ```
96
-
97
- **Props:**
98
- - `path` (string, required) — relative to project root
99
- - `lines` ([number, number]) — line range to show. Omit for full file.
100
-
101
- ### `<CodeBlock language="string">`
102
-
103
- Inline code block with syntax highlighting. For code that's part of the narrative, not from a file on disk.
104
-
105
- ```jsx
106
- <CodeBlock language="typescript">
107
- interface User {
108
- id: string;
109
- email: string;
110
- }
111
- </CodeBlock>
112
- ```
113
-
114
- **Props:**
115
- - `language` (string) — syntax highlighting language
116
-
117
- ### `<Markdown>`
118
-
119
- Renders markdown content with full GFM support (headings, lists, tables, code blocks, links, etc.). Two modes:
120
-
121
- **Inline source** — markdown as children:
122
- ```jsx
123
- <Markdown>{`
124
- # Summary
125
-
126
- This is **bold** and *italic*. Here's a list:
127
-
128
- - First item
129
- - Second item
130
- - Nested item
131
-
132
- \`\`\`typescript
133
- const x = 42;
134
- \`\`\`
135
- `}</Markdown>
136
- ```
137
-
138
- **File reference** — loads file content at compile time:
139
- ```jsx
140
- <Markdown file="docs/architecture.md" />
141
- <Markdown file="CHANGELOG.md" />
142
- ```
143
-
144
- **Props:**
145
- - `file` (string) — path relative to project root. Content is resolved at compile time.
146
- - Children (string) — inline markdown source. Used when `file` is not specified.
147
-
148
- ### `<ImageView src="string">`
149
-
150
- Displays an image from the project directory.
151
-
152
- ```jsx
153
- <ImageView src="docs/architecture.png" />
154
- <ImageView src="screenshots/before.png" alt="Before refactor" caption="Current state" width={600} />
155
- ```
156
-
157
- ### `<Diff before="string" after="string">`
158
-
159
- Shows a diff view between two code snippets.
160
-
161
- ```jsx
162
- <Diff language="typescript"
163
- before={`function auth(req) {\n return true;\n}`}
164
- after={`function auth(req) {\n const token = req.headers.authorization;\n if (!token) throw new Error('Unauthorized');\n return verify(token);\n}`}
165
- />
166
- ```
167
-
168
- **Props:**
169
- - `before` (string, required) — original code
170
- - `after` (string, required) — modified code
171
- - `language` (string) — syntax highlighting language
172
-
173
- ---
174
-
175
- ## Content
176
-
177
- ### `<Callout type="string">`
178
-
179
- Highlighted information block. Background-tinted, no border.
180
-
181
- ```jsx
182
- <Callout type="warning">
183
- This will invalidate all existing sessions. Plan a maintenance window.
184
- </Callout>
185
- ```
186
-
187
- **Props:**
188
- - `type` ("info" | "warning" | "danger" | "tip") — determines color and icon
189
-
190
- ### `<Note>`
191
-
192
- Softer than Callout. For asides, context, non-critical info.
193
-
194
- ```jsx
195
- <Note>
196
- This pattern is also used in the payment service — see src/payments/auth.ts.
197
- </Note>
198
- ```
199
-
200
- ### `<Priority level="string" />`
201
-
202
- Inline badge. Use inside Item labels or body text.
203
-
204
- ```jsx
205
- <Item label="Fix the race condition">
206
- <Priority level="high" /> This causes data corruption under load.
207
- </Item>
208
- ```
209
-
210
- **Props:**
211
- - `level` ("high" | "medium" | "low")
212
-
213
- ---
214
-
215
- ## Data Display
216
-
217
- ### `<Table headers={[...]} rows={[[...], ...]} />`
218
-
219
- Simple data table.
220
-
221
- ```jsx
222
- <Table
223
- headers={["Endpoint", "Method", "Auth"]}
224
- rows={[
225
- ["/users", "GET", "Required"],
226
- ["/users/:id", "PUT", "Owner only"],
227
- ["/health", "GET", "None"],
228
- ]}
229
- />
230
- ```
231
-
232
- ### `<Checklist items={[...]} />`
233
-
234
- Visual checklist. Read-only display (feedback via annotations).
235
-
236
- ```jsx
237
- <Checklist items={[
238
- { label: "Run migration on staging", checked: true },
239
- { label: "Verify data integrity", checked: false },
240
- { label: "Update API docs", checked: false },
241
- ]} />
242
- ```
243
-
244
- ### `<Mermaid>`
245
-
246
- Renders a Mermaid diagram. Supports flowchart, sequence, ER, gantt, pie, etc.
247
- The daemon bundles mermaid.js with a custom dark theme matching Canvas colors.
248
-
249
- ```jsx
250
- <Mermaid>{`
251
- graph TD
252
- A[Client] -->|HTTP| B(API Gateway)
253
- B --> C{Auth?}
254
- C -->|Valid| D[Service]
255
- C -->|Invalid| E[401 Response]
256
- `}</Mermaid>
257
- ```
258
-
259
- For complex diagrams, prefer Mermaid over raw SVG. Use raw `<svg>` only when Mermaid can't express what you need (custom visual layouts, non-standard diagrams).
260
-
261
- ---
262
-
263
- ## Interactive (User Input)
264
-
265
- Interactive components collect structured responses. They appear in feedback as `[component-id]: value`. Each has an optional "Add note" affordance for extra context.
266
-
267
- ### `<Choice id="string" label="string" options={[...]} />`
268
-
269
- Single-select radio group.
270
-
271
- ```jsx
272
- <Choice id="db-choice" label="Which database?" required
273
- options={["PostgreSQL", "SQLite", "MongoDB"]} />
274
- ```
275
-
276
- ### `<MultiChoice id="string" label="string" options={[...]} />`
277
-
278
- Multi-select checkboxes.
279
-
280
- ```jsx
281
- <MultiChoice id="affected-areas" label="Which areas need changes?" required
282
- options={["Models", "API", "Frontend", "Tests"]} />
283
- ```
284
-
285
- ### `<UserInput id="string" label="string" />`
286
-
287
- Free text input.
288
-
289
- ```jsx
290
- <UserInput id="constraints" label="Any constraints I should know about?"
291
- placeholder="e.g. must work with existing Redis setup" required />
292
- ```
293
-
294
- ### `<RangeInput id="string" label="string" />`
295
-
296
- Slider for numeric ranges or scales.
297
-
298
- ```jsx
299
- <RangeInput id="effort-tolerance" label="How much refactoring is acceptable?"
300
- min={1} max={5} minLabel="Minimal changes" maxLabel="Full rewrite OK" required />
301
- ```
302
-
303
- **Common props for all interactive components:**
304
- - `id` (string, required) — unique, used as key in feedback
305
- - `label` (string, required) — question text
306
- - `required` (boolean) — prevents submit until answered
307
- - `placeholder` (string) — hint text (UserInput only)
308
-
309
- ---
310
-
311
- ## Programmatic Feedback — `useFeedback`
312
-
313
- Hook for custom components to contribute computed/derived data to the feedback response. Use when built-in interactive components (`Choice`, `UserInput`, etc.) don't cover your needs.
314
-
315
- ```jsx
316
- useFeedback(id: string, markdown: string, options?: { label?: string; required?: boolean })
317
- ```
318
-
319
- **Props:**
320
- - `id` (string, required) — unique feedback entry identifier
321
- - `markdown` (string, required) — markdown included in feedback, re-evaluated each render
322
- - `options.label` — display label in feedback preview
323
- - `options.required` — blocks submit while markdown is empty
324
-
325
- Registers on mount, updates on change, unregisters on unmount.
326
-
327
- ```jsx
328
- function ProConList() {
329
- const [pros, setPros] = React.useState(["Fast builds"]);
330
- const [cons, setCons] = React.useState(["New runtime"]);
331
-
332
- useFeedback(
333
- "pro-con",
334
- `**Pros:** ${pros.join(", ")}\n**Cons:** ${cons.join(", ")}`,
335
- { label: "Pro/Con Analysis" },
336
- );
337
-
338
- return <div>{/* UI for managing pros/cons */}</div>;
339
- }
340
- ```
341
-
342
- ---
343
-
344
- ## Custom Components
345
-
346
- When you use the full module format (`export default function Canvas()`), you can define custom helper components:
347
-
348
- ```jsx
349
- function Metric({ label, value, trend }) {
350
- const color = trend === 'up' ? 'var(--color-accent-green)' : trend === 'down' ? 'var(--color-accent-red)' : 'var(--color-text-secondary)';
351
- return (
352
- <div style={{ display: 'flex', gap: 12, alignItems: 'baseline' }}>
353
- <span style={{ color: 'var(--color-text-tertiary)', fontSize: '0.75rem' }}>{label}</span>
354
- <span style={{ color, fontSize: '1.25rem', fontWeight: 600 }}>{value}</span>
355
- </div>
356
- );
357
- }
358
-
359
- export default function Canvas() {
360
- return (
361
- <Section title="Performance Summary">
362
- <Metric label="P95 Latency" value="42ms" trend="down" />
363
- <Metric label="Error Rate" value="0.3%" trend="up" />
364
- <Metric label="Throughput" value="1.2k rps" trend="up" />
365
- </Section>
366
- );
367
- }
368
- ```
369
-
370
- Standard components remain available without import even in full module format.
371
-
372
- ---
373
-
374
- ## Diagrams with Raw SVG
375
-
376
- For custom visuals that Mermaid can't express, write `<svg>` directly.
377
- Use CSS variables for colors to match the theme automatically:
378
-
379
- ```jsx
380
- <svg viewBox="0 0 400 200" style={{ width: '100%', maxWidth: 400 }}>
381
- <rect x="10" y="10" width="120" height="50" rx="8"
382
- fill="var(--color-accent-blue-muted)" stroke="var(--color-accent-blue)" strokeOpacity="0.3" />
383
- <text x="70" y="40" textAnchor="middle" fill="var(--color-text-primary)" fontSize="13"
384
- fontFamily="var(--font-body)">API Gateway</text>
385
-
386
- <line x1="130" y1="35" x2="180" y2="35" stroke="var(--color-text-tertiary)" strokeWidth="1.5"
387
- markerEnd="url(#arrow)" />
388
-
389
- <rect x="180" y="10" width="120" height="50" rx="8"
390
- fill="var(--color-accent-green-muted)" stroke="var(--color-accent-green)" strokeOpacity="0.3" />
391
- <text x="240" y="40" textAnchor="middle" fill="var(--color-text-primary)" fontSize="13"
392
- fontFamily="var(--font-body)">Auth Service</text>
393
-
394
- <defs>
395
- <marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6"
396
- orient="auto-start-reverse">
397
- <path d="M 0 0 L 10 5 L 0 10 z" fill="var(--color-text-tertiary)" />
398
- </marker>
399
- </defs>
400
- </svg>
401
- ```
402
-
403
- Keep SVG diagrams simple. For anything with more than ~5 nodes, prefer Mermaid.