pmx-canvas 0.1.19 → 0.1.20

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 (57) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/Readme.md +19 -6
  3. package/dist/canvas/global.css +35 -2
  4. package/dist/canvas/index.js +70 -69
  5. package/dist/json-render/index.js +109 -109
  6. package/dist/types/client/canvas/CanvasViewport.d.ts +1 -1
  7. package/dist/types/client/icons.d.ts +2 -0
  8. package/dist/types/client/state/canvas-store.d.ts +2 -0
  9. package/dist/types/client/types.d.ts +2 -1
  10. package/dist/types/json-render/charts/components.d.ts +5 -1
  11. package/dist/types/json-render/renderer/index.d.ts +1 -0
  12. package/dist/types/json-render/server.d.ts +1 -0
  13. package/dist/types/mcp/canvas-access.d.ts +3 -0
  14. package/dist/types/server/canvas-operations.d.ts +4 -0
  15. package/dist/types/server/canvas-schema.d.ts +19 -3
  16. package/dist/types/server/canvas-serialization.d.ts +1 -0
  17. package/dist/types/server/canvas-state.d.ts +6 -2
  18. package/dist/types/server/html-primitives.d.ts +34 -0
  19. package/dist/types/server/index.d.ts +19 -0
  20. package/docs/cli.md +4 -1
  21. package/docs/http-api.md +10 -0
  22. package/docs/mcp.md +6 -4
  23. package/docs/node-types.md +30 -2
  24. package/docs/screenshot.png +0 -0
  25. package/docs/sdk.md +11 -0
  26. package/package.json +1 -1
  27. package/skills/pmx-canvas/SKILL.md +8 -0
  28. package/src/cli/agent.ts +150 -5
  29. package/src/client/App.tsx +20 -1
  30. package/src/client/canvas/AnnotationLayer.tsx +33 -12
  31. package/src/client/canvas/CanvasViewport.tsx +88 -7
  32. package/src/client/canvas/CommandPalette.tsx +1 -1
  33. package/src/client/canvas/ContextMenu.tsx +2 -2
  34. package/src/client/canvas/ExpandedNodeOverlay.tsx +7 -1
  35. package/src/client/icons.tsx +13 -0
  36. package/src/client/nodes/McpAppNode.tsx +12 -4
  37. package/src/client/state/canvas-store.ts +15 -5
  38. package/src/client/state/sse-bridge.ts +4 -3
  39. package/src/client/theme/global.css +35 -2
  40. package/src/client/types.ts +2 -1
  41. package/src/json-render/charts/components.tsx +41 -7
  42. package/src/json-render/charts/extra-components.tsx +13 -12
  43. package/src/json-render/renderer/index.tsx +1 -0
  44. package/src/json-render/server.ts +3 -1
  45. package/src/mcp/canvas-access.ts +23 -0
  46. package/src/mcp/server.ts +83 -27
  47. package/src/server/agent-context.ts +17 -0
  48. package/src/server/canvas-operations.ts +91 -38
  49. package/src/server/canvas-schema.ts +83 -3
  50. package/src/server/canvas-serialization.ts +9 -2
  51. package/src/server/canvas-state.ts +9 -4
  52. package/src/server/demo-state.json +1143 -0
  53. package/src/server/demo.ts +25 -777
  54. package/src/server/html-primitives.ts +990 -0
  55. package/src/server/index.ts +43 -2
  56. package/src/server/server.ts +138 -14
  57. package/src/server/spatial-analysis.ts +3 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,79 @@
3
3
  All notable changes to `pmx-canvas` are documented here. This project follows
4
4
  [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## [0.1.20] - 2026-05-06
7
+
8
+ A bigger feature release. Adds 18 reusable HTML communication
9
+ primitives (choice grids, plans, review sheets, system maps, design
10
+ sheets, decks, explainers, status reports, throwaway editors…) so
11
+ agents can stop reaching for long markdown for structured artifacts,
12
+ introduces text annotations alongside the existing pen/eraser, makes
13
+ expanded mcp-app/webpage/json-render/graph viewers stretch to fill
14
+ the overlay, fixes grid arrange to respect grouped children, and
15
+ extracts the project-tour demo to a declarative JSON seed.
16
+
17
+ ### Added
18
+
19
+ - **`canvas_add_html_primitive` and 18 communication primitives.**
20
+ A new MCP tool plus CLI `html primitive add` / `html primitive
21
+ schema` and HTTP `POST /api/canvas/node` with `{type:
22
+ "html-primitive", kind, data}` (or the alternative `{type:
23
+ "html", primitive: kind, data}`) generate sandboxed `html` nodes
24
+ from named primitives: `choice-grid`, `plan-timeline`,
25
+ `review-sheet`, `pr-writeup`, `system-map`, `code-walkthrough`,
26
+ `design-sheet`, `component-gallery`, `interaction-prototype`,
27
+ `flowchart`, `deck`, `illustration-set`, `explainer`,
28
+ `status-report`, `incident-report`, `triage-board`,
29
+ `config-editor`, `prompt-tuner`. The MCP canvas now exposes 42
30
+ tools (was 41). `canvas_describe_schema` adds an `htmlPrimitives`
31
+ array describing each primitive's data shape.
32
+ - **Text annotations.** The annotation toolbar gains a third tool
33
+ alongside pen and eraser. Text annotations render as SVG `<text>`
34
+ using the `--c-annotation` token, persist alongside freehand
35
+ strokes (`type: 'text'` on `CanvasAnnotation`), and route through
36
+ the same HTTP create/delete + canvas-state undo/redo paths as the
37
+ freehand layer.
38
+ - **Declarative demo seed (`src/server/demo-state.json`).** The
39
+ project-tour demo is now a 28KB JSON snapshot loaded by a small
40
+ `demo.ts` shim, replacing the 800-line imperative seed. Editing
41
+ the tour is now a JSON edit, and the unit tests exercise the
42
+ loader and verify a stable grouped layout.
43
+ - **Install section in the README.** Documents `bunx pmx-canvas`,
44
+ `bun add -g pmx-canvas`, `bun add pmx-canvas` (for the SDK), and
45
+ `npm install -g pmx-canvas`, plus the Bun-on-PATH caveat (the
46
+ CLI uses a `#!/usr/bin/env bun` shebang). (Released as commits
47
+ `f9449e5`, `fe0843c`.)
48
+
49
+ ### Changed
50
+
51
+ - **Expanded mcp-app / webpage / json-render / graph viewers
52
+ stretch to fill the overlay.** `ExpandedNodeOverlay` now wraps
53
+ embedded viewers in a flex container, json-render and graph
54
+ viewers receive `?display=expanded` in the URL plus a
55
+ `window.__PMX_CANVAS_JSON_RENDER_DISPLAY__` global, and a new
56
+ `useChartFrameHeight()` hook computes available content height
57
+ dynamically. Expanded charts no longer leave a white band at the
58
+ bottom of the overlay.
59
+ - **Grid arrange preserves grouped child offsets.** The arrange
60
+ algorithm in the new shared `auto-arrange.ts` excludes grouped
61
+ children from translation. Previously the parent group was moved
62
+ *and* the child was moved relative to it, double-translating the
63
+ child off-screen. Undo restores the original positions exactly.
64
+ - **CommandPalette gains a "New note" markdown shortcut.** Quick-
65
+ add a `markdown` node from the palette with the standard
66
+ 520×360 default size.
67
+
68
+ ### Internal
69
+
70
+ - Regression coverage for: HTML primitive CLI/MCP creation
71
+ producing searchable html nodes with primitive metadata, text
72
+ annotation persistence and HTTP create/delete, grid arrange
73
+ preserving grouped child offsets through the operation and its
74
+ undo, declarative demo seed loading into a stable grouped layout,
75
+ graph chart-height absent unless explicitly provided, and
76
+ expanded graph nodes stretching content to the overlay frame
77
+ (e2e), plus pen and text annotations starting over nodes (e2e).
78
+
6
79
  ## [0.1.19] - 2026-05-05
7
80
 
8
81
  Snapshot ergonomics and reference-doc distribution. Adds `before` /
@@ -824,6 +897,7 @@ otherwise have to discover by trial and error.
824
897
  - Regression coverage for snapshot flat-`id` aliases on both MCP and
825
898
  HTTP surfaces, plus async / top-level-`await` WebView script bodies.
826
899
 
900
+ [0.1.20]: https://github.com/pskoett/pmx-canvas/releases/tag/v0.1.20
827
901
  [0.1.19]: https://github.com/pskoett/pmx-canvas/releases/tag/v0.1.19
828
902
  [0.1.18]: https://github.com/pskoett/pmx-canvas/releases/tag/v0.1.18
829
903
  [0.1.17]: https://github.com/pskoett/pmx-canvas/releases/tag/v0.1.17
package/Readme.md CHANGED
@@ -65,7 +65,7 @@ the canvas durable rather than throwaway.
65
65
 
66
66
  ### 06 / Any agent
67
67
 
68
- Harness-agnostic. Drive the canvas from [MCP](docs/mcp.md) (41 tools,
68
+ Harness-agnostic. Drive the canvas from [MCP](docs/mcp.md) (42 tools,
69
69
  8 resources, change notifications), the [CLI](docs/cli.md), the
70
70
  [HTTP API](docs/http-api.md), or the [Bun SDK](docs/sdk.md). Works with
71
71
  Claude Code, GitHub Copilot CLI, Codex, Cursor, Windsurf, or any agent
@@ -78,22 +78,35 @@ that can spawn an MCP stdio server, call a CLI, or hit an HTTP endpoint.
78
78
  The published SDK entrypoint is Bun-first. Node.js consumers should use the
79
79
  CLI, MCP server, or HTTP API.
80
80
 
81
+ ## Install
82
+
83
+ ```bash
84
+ bunx pmx-canvas # Run without installing (recommended for one-off use)
85
+ bun add -g pmx-canvas # Install globally — exposes the `pmx-canvas` command
86
+ bun add pmx-canvas # Install into a project (needed for the Bun SDK)
87
+ npm install -g pmx-canvas # npm works too — still requires Bun on PATH to run
88
+ ```
89
+
90
+ `pmx-canvas` is Bun-first: the CLI is a TypeScript file with a `#!/usr/bin/env bun`
91
+ shebang, so Bun must be installed even when you fetch the package via npm or pnpm.
92
+
93
+ To work on the canvas itself, clone the repo — see [Development](#development).
94
+
81
95
  ## Quick start
82
96
 
83
97
  ### Run the canvas
84
98
 
85
99
  ```bash
86
100
  bunx pmx-canvas # Start canvas, open browser
87
- bunx pmx-canvas --demo # Start with the project-tour demo board
101
+ bunx pmx-canvas --demo # Start with the saved dashboard demo board
88
102
  bunx pmx-canvas --no-open # Headless (good for daemons / CI)
89
103
  bunx pmx-canvas --mcp # Run as MCP server (stdio)
90
104
  bunx pmx-canvas --help # All commands
91
105
  ```
92
106
 
93
107
  The canvas opens at `http://localhost:4313`. Try `--demo` first — it seeds a
94
- project tour with grouped markdown, status, file, image, webpage,
95
- json-render, graph, html, Excalidraw diagram, and MCP App nodes connected by
96
- labeled edges.
108
+ saved dashboard with grouped OKR notes, graph panels, context pins, and labeled
109
+ edges.
97
110
 
98
111
  ### Connect your agent (MCP)
99
112
 
@@ -143,7 +156,7 @@ the agent can read `canvas://skills` and pull in companion skills
143
156
  the three-tier visual matrix (json-render → html → web-artifact)
144
157
  - **[CLI reference](docs/cli.md)** — full command surface, daemon mode,
145
158
  watch streams, WebView automation
146
- - **[MCP reference](docs/mcp.md)** — 41 tools, 8 resources, change
159
+ - **[MCP reference](docs/mcp.md)** — 42 tools, 8 resources, change
147
160
  notifications, node-type routing
148
161
  - **[HTTP API](docs/http-api.md)** — REST endpoints, SSE, batch operations
149
162
  - **[Bun SDK](docs/sdk.md)** — `createCanvas()` for TypeScript on Bun
@@ -392,6 +392,19 @@ body,
392
392
  margin: 0.4em 0;
393
393
  color: var(--c-muted);
394
394
  }
395
+
396
+ .canvas-node .node-body ul,
397
+ .canvas-node .node-body ol {
398
+ margin: 0.4em 0;
399
+ padding-left: 0.25em;
400
+ list-style-position: inside;
401
+ }
402
+
403
+ .canvas-node .node-body li {
404
+ margin: 0.2em 0;
405
+ padding-left: 0.15em;
406
+ }
407
+
395
408
  .canvas-node .node-body a {
396
409
  color: var(--c-accent);
397
410
  text-decoration: none;
@@ -1481,14 +1494,14 @@ body,
1481
1494
  height: 1px;
1482
1495
  overflow: visible;
1483
1496
  pointer-events: none;
1484
- z-index: 45;
1497
+ z-index: 9000;
1485
1498
  }
1486
1499
 
1487
1500
  .annotation-capture-layer {
1488
1501
  position: absolute;
1489
1502
  inset: 0;
1490
1503
  z-index: 9996;
1491
- pointer-events: none;
1504
+ pointer-events: auto;
1492
1505
  background: color-mix(in srgb, var(--c-accent) 5%, transparent);
1493
1506
  }
1494
1507
 
@@ -1496,6 +1509,26 @@ body,
1496
1509
  background: color-mix(in srgb, var(--c-danger) 6%, transparent);
1497
1510
  }
1498
1511
 
1512
+ .annotation-capture-layer.text {
1513
+ background: color-mix(in srgb, var(--c-annotation) 4%, transparent);
1514
+ }
1515
+
1516
+ .annotation-text-input {
1517
+ position: absolute;
1518
+ z-index: 9997;
1519
+ min-width: 120px;
1520
+ max-width: min(560px, calc(100% - 24px));
1521
+ padding: 2px 4px;
1522
+ border: 1px solid var(--c-annotation);
1523
+ border-radius: 4px;
1524
+ background: color-mix(in srgb, var(--c-bg) 72%, transparent);
1525
+ color: var(--c-annotation);
1526
+ font-family: var(--font);
1527
+ font-weight: 700;
1528
+ line-height: 1.15;
1529
+ outline: none;
1530
+ }
1531
+
1499
1532
  /* ── Drop Zone (file drag-and-drop) ─────────────────────────── */
1500
1533
  .drop-zone-overlay {
1501
1534
  position: absolute;