pmx-canvas 0.1.18 → 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 (70) hide show
  1. package/CHANGELOG.md +128 -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 +8 -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/RELEASE.md +153 -0
  21. package/docs/bun-webview-integration.md +296 -0
  22. package/docs/cli.md +143 -0
  23. package/docs/evals/e2e-cli-coverage.md +61 -0
  24. package/docs/http-api.md +201 -0
  25. package/docs/mcp.md +137 -0
  26. package/docs/node-types.md +272 -0
  27. package/docs/plans/.gitkeep +0 -0
  28. package/docs/plans/plan-001-semantic-watch-mvp.md +335 -0
  29. package/docs/plans/plan-002-human-attention-layer-design-spec.md +679 -0
  30. package/docs/plans/plan-003-human-attention-layer-implementation-plan.md +572 -0
  31. package/docs/reactive-canvas-proposal.md +578 -0
  32. package/docs/release-review-0.1.0.md +38 -0
  33. package/docs/screenshot.png +0 -0
  34. package/docs/screenshots/demo-workbench-dark.png +0 -0
  35. package/docs/screenshots/demo-workbench-light.png +0 -0
  36. package/docs/screenshots/welcome-dark.png +0 -0
  37. package/docs/screenshots/welcome-light.png +0 -0
  38. package/docs/sdk.md +103 -0
  39. package/package.json +2 -1
  40. package/skills/pmx-canvas/SKILL.md +8 -0
  41. package/src/cli/agent.ts +167 -5
  42. package/src/client/App.tsx +20 -1
  43. package/src/client/canvas/AnnotationLayer.tsx +33 -12
  44. package/src/client/canvas/CanvasViewport.tsx +88 -7
  45. package/src/client/canvas/CommandPalette.tsx +1 -1
  46. package/src/client/canvas/ContextMenu.tsx +2 -2
  47. package/src/client/canvas/ExpandedNodeOverlay.tsx +7 -1
  48. package/src/client/icons.tsx +13 -0
  49. package/src/client/nodes/McpAppNode.tsx +12 -4
  50. package/src/client/state/canvas-store.ts +15 -5
  51. package/src/client/state/sse-bridge.ts +4 -3
  52. package/src/client/theme/global.css +35 -2
  53. package/src/client/types.ts +2 -1
  54. package/src/json-render/charts/components.tsx +41 -7
  55. package/src/json-render/charts/extra-components.tsx +13 -12
  56. package/src/json-render/renderer/index.tsx +1 -0
  57. package/src/json-render/server.ts +3 -1
  58. package/src/mcp/canvas-access.ts +25 -0
  59. package/src/mcp/server.ts +85 -27
  60. package/src/server/agent-context.ts +17 -0
  61. package/src/server/canvas-operations.ts +91 -38
  62. package/src/server/canvas-schema.ts +83 -3
  63. package/src/server/canvas-serialization.ts +9 -2
  64. package/src/server/canvas-state.ts +27 -9
  65. package/src/server/demo-state.json +1143 -0
  66. package/src/server/demo.ts +25 -777
  67. package/src/server/html-primitives.ts +990 -0
  68. package/src/server/index.ts +43 -2
  69. package/src/server/server.ts +140 -14
  70. package/src/server/spatial-analysis.ts +3 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,132 @@
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
+
79
+ ## [0.1.19] - 2026-05-05
80
+
81
+ Snapshot ergonomics and reference-doc distribution. Adds `before` /
82
+ `after` ISO timestamp filters on snapshot listing across CLI, HTTP,
83
+ and MCP, ships the `docs/` reference tree inside the npm tarball so
84
+ consumers see the same surface docs as the repo, and surfaces the
85
+ existing trace-field flags in `node update --help`. Also lands the
86
+ deflake of the MCP-app fullscreen reopen e2e (originally
87
+ `LRN-20260505-001`) — 9/20 → 50+/50 stability via a retry-on-stuck-
88
+ iframe helper.
89
+
90
+ ### Added
91
+
92
+ - **`pmx-canvas snapshot list --before / --after`.** Both flags
93
+ accept ISO 8601 timestamps and filter against `snapshot.createdAt`.
94
+ Same surface lands on `GET /api/canvas/snapshots?before=&after=`,
95
+ `RemoteCanvasAccess.listSnapshots()`, and the `canvas_list_snapshots`
96
+ MCP tool schema. The CLI help (`pmx-canvas snapshot list --help`)
97
+ now lists the new flags alongside `--limit`, `--query`, and
98
+ `--all`.
99
+ - **`docs/` shipped in the npm tarball.** The package `files`
100
+ allowlist now includes `docs/`, so consumers installing
101
+ `pmx-canvas` see the same `docs/cli.md`, `docs/http-api.md`,
102
+ `docs/mcp.md`, `docs/node-types.md`, and `docs/sdk.md` reference
103
+ files that ship in the repo.
104
+ - **`node update --help` advertises trace flags.** The CLI help now
105
+ documents `--tool-name` / `--toolName`, `--category`, `--status`,
106
+ `--duration`, `--result-summary` / `--resultSummary`, and `--error`
107
+ so agents discover trace-field updates without reading the source
108
+ or schema.
109
+
110
+ ### Fixed
111
+
112
+ - **MCP-app fullscreen reopen e2e is no longer flaky.** The
113
+ visibility check for the fixture editor used to race the ext-app
114
+ bridge handshake — if the iframe started parsing before the
115
+ parent registered its postMessage listener, the iframe's
116
+ `ui/initialize` request was lost and `app.connect()` hung. The
117
+ test now wraps the assertion in a retry-on-stuck-iframe helper
118
+ that closes and reopens the fullscreen overlay (each remount is
119
+ independent of the prior failed handshake), with three 5s
120
+ attempts to match the original 15s budget. Pass rate moved from
121
+ 9/20 to 50+/50 consecutive runs.
122
+
123
+ ### Internal
124
+
125
+ - Regression coverage for: snapshot list before/after filtering at
126
+ the canvas-state layer and through the CLI, snapshot list help
127
+ advertising the new flags, `node update --help` advertising
128
+ trace flags, the `docs/` allowlist entry surviving in
129
+ `package.json` for npm consumers, and the existing arrange
130
+ operation recording as a single undoable history entry.
131
+
6
132
  ## [0.1.18] - 2026-05-05
7
133
 
8
134
  Token-budget polish on top of 0.1.17. Full-mode MCP responses for
@@ -771,6 +897,8 @@ otherwise have to discover by trial and error.
771
897
  - Regression coverage for snapshot flat-`id` aliases on both MCP and
772
898
  HTTP surfaces, plus async / top-level-`await` WebView script bodies.
773
899
 
900
+ [0.1.20]: https://github.com/pskoett/pmx-canvas/releases/tag/v0.1.20
901
+ [0.1.19]: https://github.com/pskoett/pmx-canvas/releases/tag/v0.1.19
774
902
  [0.1.18]: https://github.com/pskoett/pmx-canvas/releases/tag/v0.1.18
775
903
  [0.1.17]: https://github.com/pskoett/pmx-canvas/releases/tag/v0.1.17
776
904
  [0.1.16]: https://github.com/pskoett/pmx-canvas/releases/tag/v0.1.16
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;