bytespost-canvas 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 bytespost
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # bytespost-canvas
2
+
3
+ > Local CLI + MCP server for the [bytespost canvas](https://app.bytespost.com) — drive a running canvas tab from your terminal or any AI agent (Claude Code, Cursor, etc.).
4
+
5
+ ## What it is
6
+
7
+ `bytespost-canvas` runs a tiny localhost daemon (HTTP + WebSocket hub) that bridges your terminal / AI agent and a canvas tab open in your browser. Once the daemon is up and the canvas tab is connected:
8
+
9
+ - The CLI sends commands (draw a rectangle, capture a screenshot, query the document, set selection, …).
10
+ - The daemon relays them over WebSocket to the canvas page.
11
+ - The page executes them in the live editor and streams back results (node IDs, PNG bytes, JSON document state).
12
+
13
+ It also exposes an **MCP (Model Context Protocol) stdio server** so AI agents that speak MCP can talk to your canvas with no glue code.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ # Global install — gives you the `canvas` binary
19
+ npm install -g bytespost-canvas
20
+
21
+ # Or run without installing
22
+ npx bytespost-canvas --help
23
+ ```
24
+
25
+ Three binaries ship, all aliasing the same CLI: `canvas`, `canvas-bridge`, `canvasd`.
26
+
27
+ ## Quick start
28
+
29
+ ```bash
30
+ # 1. Start the daemon (it stays in the foreground)
31
+ canvas serve
32
+
33
+ # 2. In your browser, open https://app.bytespost.com and edit any project.
34
+ # The page auto-connects to the daemon on http://127.0.0.1:7777.
35
+
36
+ # 3. From any other terminal, run commands
37
+ canvas ls # list connected tabs
38
+ canvas screenshot -o canvas.png # capture the active tab
39
+ canvas draw rect --x 100 --y 100 --width 200 --height 120 --fill "#7c3aed"
40
+ canvas document get # dump the IR JSON
41
+ canvas select set --node-id <id> # set selection
42
+ ```
43
+
44
+ `canvas <command> --help` prints command-specific flags. `canvas --json` returns stable machine-readable JSON for any command — pipe straight into `jq`.
45
+
46
+ ## MCP mode (for Claude Code / Cursor / any MCP client)
47
+
48
+ ```bash
49
+ canvas mcp # speaks MCP over stdio
50
+ ```
51
+
52
+ Register it in your AI agent's MCP config. Sample for Claude Code:
53
+
54
+ ```jsonc
55
+ // ~/.claude/config.json
56
+ {
57
+ "mcpServers": {
58
+ "canvas": {
59
+ "command": "canvas",
60
+ "args": ["mcp"]
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ The agent then sees tools for every canvas command (`canvas_draw_rect`, `canvas_screenshot`, `canvas_document_get`, …) and can compose them autonomously.
67
+
68
+ ## Commands
69
+
70
+ | Command | What it does |
71
+ |---|---|
72
+ | `serve` / `start` | Run the daemon (foreground). |
73
+ | `mcp` | Run an MCP stdio server. |
74
+ | `status` / `health` | Daemon + connected-tab health. |
75
+ | `ls` | List open canvas tabs. |
76
+ | `tab info` | Show tab metadata. |
77
+ | `document get` | Dump the full document IR. |
78
+ | `document nodes` | List node IDs by type / filter. |
79
+ | `draw` | Create a node from a JSON spec. |
80
+ | `draw rect / frame / text / line` | Convenience helpers for the common shapes. |
81
+ | `node get / update / delete` | Read or mutate a single node. |
82
+ | `select set / clear` | Drive the selection. |
83
+ | `viewport screenshot` / `screenshot` | PNG bytes of the active tab. |
84
+ | `viewport fit / zoom` | Pan/zoom the camera. |
85
+ | `building` | Building-3D plugin shortcuts (wall / slab / window / door / …). |
86
+
87
+ ## Configuration
88
+
89
+ - Daemon port: `CANVAS_BRIDGE_PORT` (default `7777`).
90
+ - All commands accept `--tab <id>` when multiple canvas tabs are connected; with exactly one, it's optional.
91
+
92
+ ## Architecture (one sentence)
93
+
94
+ ```
95
+ your CLI ──HTTP──> daemon ──WebSocket──> canvas tab in browser
96
+
97
+ └── MCP stdio (for AI agents)
98
+ ```
99
+
100
+ ## License
101
+
102
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * canvas-bridge CLI (SLICE 1 + 2).
4
+ *
5
+ * canvas-bridge serve start the daemon (blocks)
6
+ * canvas-bridge health GET /v1/health, print JSON
7
+ * canvas-bridge ls GET /v1/tabs
8
+ * canvas-bridge screenshot -o <file> GET /v1/screenshot, write PNG
9
+ * canvas-bridge draw <json|file> POST /v1/draw, print {nodeIds}
10
+ * canvas-bridge draw rect --x ... POST /v1/draw with a typed spec
11
+ *
12
+ * `draw` takes either an inline JSON string (a `{nodes:[...]}` body, or a bare
13
+ * array of specs) or a path to a .json file containing the same.
14
+ *
15
+ * Talks to the daemon over plain localhost HTTP. Intentionally tiny.
16
+ */
17
+ export {};