Skip to content

Commit 2441b86

Browse files
hetpatel-11claude
andcommitted
feat: v0.1.6 — Codex live mode, canvas safety, brand rule, HTTP bridge canvas API
## Codex / agent terminal fixes - Fix Codex running in file mode when launched from Monet terminal - Add ZDOTDIR chain-load approach: writes ~/.../zdotdir/.zshenv/.zprofile/.zshrc that survive the login shell path_helper PATH rewrite in /etc/zprofile - Previously binDir was set in spawn env but zsh -l overwrote it; ZDOTDIR sources user rc files then re-prepends Monet bin at end, guaranteeing editorctl and agent wrappers stay on PATH - Codex wrapper now uses STRIPPED_PATH only to locate the real binary, then exec with original PATH so editorctl stays accessible in subshells - Both fixes are written fresh on every terminal:createSession call so all users get them automatically on first terminal open ## Canvas: HTTP bridge canvas API (Claude Code fallback) - Add canvas_run_paperjs, canvas_run_matterjs, canvas_get_frames, canvas_loading, canvas_done to the HTTP API bridge (localhost:51847) - Previously these were editorctl-only; Claude Code falling back to HTTP bridge had no way to run scripts or list frames, leading to incorrect canvas_update_frame workarounds and accidental canvas_clear calls ## Canvas: destruction safety - Add explicit DESTRUCTION WARNING to all generated agent context files (MONET_AGENT_CONTEXT.md, CLAUDE.md, AGENTS.md) and to CLAUDE.md/SKILL.md/ AGENT_CAPABILITIES.md: agents must NEVER call canvas_clear or canvas_delete_frame unless the user explicitly asks ## Canvas: full editorctl path fallback in generated context - Pass binDir through ensureAgentContextFiles → buildGuideBody/buildClaudeBody/ buildAgentsBody so generated MD files include the absolute editorctl path - Agents with broken PATH can use "/path/to/userData/bin/editorctl" directly instead of silently falling back to the HTTP bridge ## Canvas: brand/URL fetch rule - Add mandatory brand fetch rule to all agent context files: if the user's message contains any URL or domain, agents must curl the page and extract hex colors, fonts, and logo before writing any canvas code - Rule added to: buildGuideBody, buildClaudeBody, buildAgentsBody, .claude/settings.json UserPromptSubmit hook, CLAUDE.md, SKILL.md, AGENT_CAPABILITIES.md ## Design mode removal - Remove canvas_add_design_frame and canvas_update_design_frame from MCP server - Remove design mode from all canvas creation paths (UI, MCP, CLI, agent context) - Keep underlying DesignNode types for backward compat with saved artboards ## Canvas UI - Remove ⌘↵ hotkey label from canvas right panel editor toolbar ## Version bump: 0.1.5 → 0.1.6 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a96d452 commit 2441b86

17 files changed

Lines changed: 4339 additions & 316 deletions

File tree

.claude/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"hooks": [
77
{
88
"type": "command",
9-
"command": "bash -c 'TMPFILE=\"$TMPDIR/monet-active-view\"; if [ -f \"$TMPFILE\" ]; then VIEW=$(cat \"$TMPFILE\" 2>/dev/null); else EDITORCTL=\"/Users/hetpatel/Library/Application Support/monet/bin/editorctl\"; RAW=$(\"$EDITORCTL\" get-state 2>/dev/null); VIEW=$(echo \"$RAW\" | python3 -c \"import sys,json; d=json.load(sys.stdin); print(d.get(\\\"activeView\\\",\\\"editor\\\"))\" 2>/dev/null || echo \"editor\"); fi; if [ \"$VIEW\" = \"canvas\" ]; then echo \"[MONET] activeView=canvas — CANVAS MODE ACTIVE. Before creating any image or visual: ask the user — draw in canvas (canvas-run-paperjs/canvas-run-matterjs) or GPT image (generate-image + canvas-add-image)? Never skip this question.\"; else echo \"[MONET] activeView=editor — VIDEO EDITOR MODE. For visual requests: ask the user — draw in canvas or generate GPT image for the timeline? Use editorctl generate-image + canvas-add-image if image. Remotion OK for video assets.\"; fi'"
9+
"command": "bash -c 'TMPFILE=\"$TMPDIR/monet-active-view\"; if [ -f \"$TMPFILE\" ]; then VIEW=$(cat \"$TMPFILE\" 2>/dev/null); else EDITORCTL=\"/Users/hetpatel/Library/Application Support/monet/bin/editorctl\"; RAW=$(\"$EDITORCTL\" get-state 2>/dev/null); VIEW=$(echo \"$RAW\" | python3 -c \"import sys,json; d=json.load(sys.stdin); print(d.get(\\\"activeView\\\",\\\"editor\\\"))\" 2>/dev/null || echo \"editor\"); fi; if [ \"$VIEW\" = \"canvas\" ]; then echo \"[MONET] activeView=canvas — CANVAS MODE ACTIVE. STRICT RULE: You MUST ask the user to pick ONE of EXACTLY these three options before doing anything. Present them word-for-word as: (1) Paper.js — code drawing with vector graphics, (2) Matter.js — physics and animation, (3) GPT image 2 — AI-generated image. FORBIDDEN: Do NOT offer design layers, editable layers, Figma-style, node-based design, or any design-mode variant. There is NO design mode. Do NOT skip the question. Do NOT proceed without the user choosing one of the three. BRAND RULE — NO EXCEPTIONS: If the user message contains any URL or domain name, you MUST fetch the page and extract brand colors, fonts, and logo BEFORE writing any canvas code. Use: curl -sL <url> | grep -Eo (hex colors, fonts). Never guess brand colors. Hard-code exact values from the fetch.\"; else echo \"[MONET] activeView=editor — VIDEO EDITOR MODE. For visual requests: ask the user — draw in canvas (Paper.js or Matter.js) or generate GPT image 2 for the timeline? Use editorctl generate-image + canvas-add-image if image. Remotion OK for video assets. BRAND RULE: If user provides a URL/domain, fetch brand tokens first before generating anything visual.\"; fi'"
1010
}
1111
]
1212
}

AGENT_CAPABILITIES.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# What Claude Can Do in This Video Editor
22

3+
## ⚠️ CANVAS MODE — MANDATORY RULES (read this first)
4+
5+
When `activeView=canvas` is reported by the hook or `editorctl get-state`:
6+
7+
**There are EXACTLY 3 canvas options. No others exist.**
8+
1. **Paper.js** — code drawing with vector graphics (`canvas-run-paperjs`)
9+
2. **Matter.js** — physics and animation (`canvas-run-matterjs`)
10+
3. **GPT image 2** — AI-generated image (`generate-image` + `canvas-add-image`)
11+
12+
**REMOVED — do NOT offer these under any name:**
13+
- ~~Design mode~~ — removed
14+
- ~~Editable layers~~ — removed
15+
- ~~Figma-style layout~~ — removed
16+
- ~~Node-based design~~ — removed
17+
- ~~Direct canvas design~~ — removed
18+
19+
When the user asks for something visual in canvas mode, present ONLY these three options using these EXACT labels. Copy them verbatim. Do not invent a fourth option or rephrase option 1 as anything design-related.
20+
21+
---
22+
323
## 🎬 Complete Professional Video Editing Control
424

525
I now have **full control** of a professional-grade video editor through three interfaces:
@@ -91,6 +111,42 @@ Because I'm running inside the app's terminal with PTY access:
91111
- I can **test changes instantly** (make changes, rebuild, verify)
92112
- I have **full environment access** (FFmpeg, Node.js, file system)
93113

114+
## Brand Aesthetic from a URL
115+
116+
> **MANDATORY — NO EXCEPTIONS**: Any URL or domain in the user's message triggers a required fetch step. Run the commands below, extract the brand tokens, and only then write canvas/design code. Do not use assumed or memorized brand colors even for well-known brands. If the fetch fails, ask the user for the hex values — never guess.
117+
118+
```bash
119+
# Extract CSS tokens
120+
curl -sL "<url>" | grep -Eo '(#[0-9a-fA-F]{3,8}|font-family:[^;"}]+|font-size:[^;"}]+|border-radius:[^;"}]+)' | sort -u | head -60
121+
# Find logo
122+
curl -sL "<url>" | grep -Eo '(src|href)="[^"]*logo[^"]*"' | head -10
123+
curl -sL "<url>" | grep 'og:image'
124+
```
125+
126+
Pull out: background/surface colors, primary/accent colors, text colors, font families, font sizes, border radii, spacing, shadows, and the logo. Use those exact values — never substitute defaults. See `CLAUDE.md` for the full extraction table and logo guidance.
127+
128+
---
129+
130+
## Canvas — Matter.js & Paper.js Frames
131+
132+
Live interactive frames can be placed on the canvas using physics (Matter.js) or vector graphics (Paper.js).
133+
134+
```bash
135+
editorctl canvas-add-frame "My Frame" 390 844 matterjs # create a Matter.js frame
136+
editorctl canvas-run-matterjs <frameId> "<script>" # apply/update the physics script
137+
editorctl canvas-frames # list all frame IDs
138+
editorctl canvas-done # dismiss loading overlay
139+
```
140+
141+
### Matter.js script rules (violations produce a blank canvas)
142+
1. **Use `document.querySelector('canvas')`** — never `element: document.body` in `Render.create`; that spawns an invisible second canvas.
143+
2. **`Runner.run(Runner.create(), engine)`** — always two arguments; single-arg form does nothing in 0.20.0.
144+
3. **Self-contained scripts** (own engine + rAF loop): declare your own `const engine`, drive with `Engine.update()` + `requestAnimationFrame`. Do NOT also call `Render.run`/`Runner.run`.
145+
4. **Body-only scripts** (use template's engine): do NOT declare `const engine`, `let engine`, or `const { Engine } = Matter` — the template pre-declares these with `var`; redeclaring with `const`/`let` is a SyntaxError.
146+
5. **Never mix patterns** — a script that both borrows template globals AND calls `Render.run` will double-loop and appear frozen.
147+
148+
See `SKILL.md`_Canvas — Matter.js Physics Frames_ for full examples and `CLAUDE.md` for the authoritative pattern reference.
149+
94150
## Remotion — React Video Composition
95151

96152
Remotion is installed for creating animated videos programmatically with React.

CLAUDE.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
# Monet — Claude Agent Guide
22

3+
## ⚠️ CANVAS MODE — MANDATORY RULES (read this first)
4+
5+
When `activeView=canvas` is reported by the hook or `editorctl get-state`:
6+
7+
**There are EXACTLY 3 canvas options. No others exist.**
8+
1. **Paper.js** — code drawing with vector graphics (`canvas-run-paperjs`)
9+
2. **Matter.js** — physics and animation (`canvas-run-matterjs`)
10+
3. **GPT image 2** — AI-generated image (`generate-image` + `canvas-add-image`)
11+
12+
**REMOVED — do NOT offer these under any name:**
13+
- ~~Design mode~~ — removed
14+
- ~~Editable layers~~ — removed
15+
- ~~Figma-style layout~~ — removed
16+
- ~~Node-based design~~ — removed
17+
- ~~Direct canvas design~~ — removed
18+
19+
When the user asks for something visual in canvas mode, present ONLY these three options using these EXACT labels. Copy them verbatim. Do not invent a fourth option or rephrase option 1 as anything design-related.
20+
21+
## ⚠️ BRAND RULE — NO EXCEPTIONS (applies to ALL canvas work)
22+
23+
**If the user's message contains ANY URL or domain name (e.g. `spotify.com`, `https://linear.app`, `notion.so`), you MUST fetch that page and extract brand tokens BEFORE writing a single line of canvas/design code.**
24+
25+
Do not use assumed or memorized brand colors. Do not skip this step even if you think you know the brand. **Fetch first, design second — every time.**
26+
27+
```bash
28+
# Step 1 — extract colors, fonts, border-radius
29+
curl -sL "<url>" | grep -Eo '(#[0-9a-fA-F]{3,8}|font-family:[^;"}]+|font-size:[^;"}]+|border-radius:[^;"}]+)' | sort -u | head -60
30+
31+
# Step 2 — find logo
32+
curl -sL "<url>" | grep -Eo '(src|href)="[^"]*logo[^"]*"' | head -10
33+
curl -sL "<url>" | grep 'og:image'
34+
```
35+
36+
Extract and hard-code before coding: background & surface colors, primary/accent colors, text colors, font families, font sizes/weights, border radius, and logo. Never guess — if fetch fails, tell the user and ask them to paste the hex values.
37+
38+
---
39+
340
Monet is an Electron video editor with terminal-first AI agent control. You have three interfaces:
441
1. **MCP tools** (`video_editor_*`) — live timeline control via the MCP server
542
2. **CLI** (`editorctl`) — direct commands from this terminal
@@ -72,6 +109,131 @@ npx remotion render remotion/src/index.ts TitleCard out.mp4 --props '{"title":"H
72109
- Rendered videos land in `remotion-renders/` as MP4 — drag into the Monet timeline or use `video_editor_render_remotion` which auto-imports.
73110
- Zod schemas on compositions let you pass typed props from MCP.
74111

112+
## Brand Aesthetic from a URL
113+
114+
> **MANDATORY — NO EXCEPTIONS**
115+
> If the user's message contains any URL or domain name (e.g. `spotify.com`, `https://linear.app`, `notion.so`), you **MUST** fetch that page and extract its brand tokens **before writing a single line of canvas/design code**. Do not use assumed or memorized brand colors. Do not skip this step even if you think you know the brand. Fetch first, design second — every time.
116+
117+
```bash
118+
# Step 1 — fetch HTML and extract CSS tokens
119+
curl -sL "<url>" | grep -Eo '(#[0-9a-fA-F]{3,8}|font-family:[^;"}]+|font-size:[^;"}]+|border-radius:[^;"}]+)' | sort -u | head -60
120+
121+
# Step 2 — find logo
122+
curl -sL "<url>" | grep -Eo '(src|href)="[^"]*logo[^"]*"' | head -10
123+
curl -sL "<url>" | grep 'og:image'
124+
```
125+
126+
Or use the WebFetch / browser tool to read the live page and its `<style>` tags / inline CSS.
127+
128+
**Extract and note before coding:**
129+
| Token | Where to look |
130+
|-------|--------------|
131+
| Background & surface colors | `background`, `background-color`, CSS variables like `--bg`, `--surface` |
132+
| Primary / accent colors | Buttons, links, active states, `--primary`, `--accent` |
133+
| Text colors | `color` on `body`, headings, muted text |
134+
| Font families | `font-family` on `body` or headings |
135+
| Font sizes & weights | `font-size`, `font-weight` on headlines vs body |
136+
| Border radius | Cards, buttons, avatars |
137+
| Spacing scale | Padding/margin on cards and containers |
138+
| Shadows | `box-shadow` values |
139+
| **Logo** | `<img>` with `logo` in src/alt/class, inline `<svg>` in header/nav, `og:image` meta tag |
140+
141+
**Also extract the logo.** The logo shape, color usage, and style (wordmark vs icon vs combination) tells you the brand's visual weight and personality. Use it to:
142+
- Match the exact brand colors (logos are the ground truth — more reliable than CSS variables)
143+
- Reproduce the logo mark as a canvas shape (e.g. a simplified SVG path drawn with `ctx`) when it adds authenticity to the frame
144+
- Set the tone: a geometric minimal logo = clean spacing + sans-serif; a bold serif logo = heavier weights + tighter layout
145+
146+
```bash
147+
# Find logo URLs in the page
148+
curl -sL "<url>" | grep -Eo '(src|href)="[^"]*logo[^"]*"' | head -10
149+
curl -sL "<url>" | grep -Eo 'content="[^"]*og:image[^"]*"' | head -5
150+
# Or look at the og:image meta directly
151+
curl -sL "<url>" | grep 'og:image'
152+
```
153+
154+
**Then hard-code those exact values** into the Matter.js / Paper.js / HTML script.
155+
156+
> **Never use assumed/memorized brand colors when a URL was provided.** If the fetch fails, tell the user and ask them to paste the hex values — do not fall back to guessing.
157+
158+
---
159+
160+
## Canvas — Matter.js Physics Frames
161+
162+
Use `canvas_run_matterjs` (MCP) or `editorctl canvas-run-matterjs <frameId> "<script>"` (CLI) to place a live physics scene on the canvas.
163+
164+
### Two valid script patterns — pick ONE, never mix
165+
166+
#### Pattern A — Self-contained (recommended for rich UIs)
167+
The script creates and owns the engine, render loop, and runner. Use this when you need custom drawing (Canvas 2D API), manual `Engine.update`, or `requestAnimationFrame`.
168+
169+
```js
170+
// ✅ Pattern A — self-contained
171+
const { Engine, Bodies, Composite, Mouse, MouseConstraint, Events } = Matter;
172+
const W = 390, H = 844;
173+
const engine = Engine.create({ gravity: { y: 1.5 } });
174+
const canvas = document.querySelector('canvas'); // always use THIS — do NOT create a new one
175+
canvas.width = W; canvas.height = H;
176+
const ctx = canvas.getContext('2d');
177+
178+
// add bodies, set up mouse, etc.
179+
const ground = Bodies.rectangle(W/2, H+25, W, 50, { isStatic: true });
180+
Composite.add(engine.world, [ground]);
181+
182+
function loop() {
183+
Engine.update(engine, 1000/60);
184+
ctx.clearRect(0, 0, W, H);
185+
// draw everything with ctx here
186+
requestAnimationFrame(loop);
187+
}
188+
loop();
189+
```
190+
191+
#### Pattern B — Simple bodies only (for quick physics scenes)
192+
Do NOT declare `engine`, `render`, `runner`, or Matter vars — the template provides them. Just add bodies and configure gravity. The template handles `Render.run` and `Runner.run`.
193+
194+
```js
195+
// ✅ Pattern B — template-managed (engine, render, width, height are already declared)
196+
var ground = Bodies.rectangle(width/2, height+25, width, 50, { isStatic: true, render: { fillStyle: '#334155' } });
197+
var ball = Bodies.circle(width/2, 50, 30, { restitution: 0.8, render: { fillStyle: '#5b82f7' } });
198+
Composite.add(engine.world, [ground, ball]);
199+
engine.gravity.y = 1;
200+
```
201+
202+
### Rules — read before writing any Matter.js script
203+
204+
| Rule | Why |
205+
|------|-----|
206+
| **Never use `element: document.body` in `Render.create`** | Creates a hidden second canvas; the visible canvas stays blank |
207+
| **If using Pattern B, never declare `const engine` or `let engine`** | Conflicts with the template's `var engine` → SyntaxError → blank canvas |
208+
| **If using Pattern A, never also call `Render.run` / `Runner.run` from Pattern B setup** | Double render loop = glitchy or invisible output |
209+
| **Always use `document.querySelector('canvas')` for the canvas element** | The iframe has exactly one canvas; this is always the right one |
210+
| **`Runner.run` requires TWO args: `Runner.run(Runner.create(), engine)`** | Matter.js 0.20.0 — single-arg `Runner.run(engine)` silently does nothing |
211+
| **Wrap custom draw logic in `Events.on(render, 'afterRender', ...)` when using Pattern B** | Lets Matter.js Render handle the rAF loop while you overlay custom 2D drawing |
212+
213+
### Available globals in Pattern B scripts
214+
```
215+
engine render width height
216+
Engine Render Runner Bodies Composite World
217+
Body Events Constraint Mouse MouseConstraint
218+
```
219+
220+
### Common mistake — mixing patterns (broken)
221+
```js
222+
// ❌ BROKEN — declares const engine (conflicts with template's var engine)
223+
const { Engine, Bodies } = Matter; // SyntaxError: can't redeclare
224+
const engine = Engine.create(); // never reached
225+
const canvas = document.querySelector('canvas');
226+
Render.create({ element: document.body }); // creates invisible second canvas
227+
```
228+
229+
### Canvas CLI commands
230+
```bash
231+
editorctl canvas-add-frame "My Frame" 390 844 matterjs # create new frame
232+
editorctl canvas-run-matterjs <frameId> "$(cat script.js)" # apply script
233+
editorctl canvas-frames # list frames + IDs
234+
editorctl canvas-done # clear loading overlay
235+
```
236+
75237
## Other editor capabilities
76238

77239
See `AGENT_CAPABILITIES.md` for the full MCP tool list and `SKILL.md` for detailed API reference.

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ On first launch, Monet asks for:
173173

174174
Claude Code and Codex installation help is shown next to the terminal when needed, instead of blocking onboarding.
175175

176+
### Codex sandbox
177+
178+
Monet's embedded terminal automatically launches Codex with `-s danger-full-access` so that `editorctl` can reach the live app API on `localhost:51847`. Without this flag, Codex's default `read-only` sandbox blocks outbound localhost connections and every `editorctl` command falls back to file mode.
179+
180+
This flag is injected by Monet's wrapper script (written to `userData/bin/codex` on each terminal start) and **only applies when Codex is launched from inside Monet**. Codex sessions started from any other terminal are unaffected.
181+
176182
## What Agents Can Do
177183

178184
Through the embedded terminal, `editorctl`, API bridge, and MCP surfaces, agents can operate **both** the video editor and the design canvas.
@@ -193,7 +199,7 @@ Through the embedded terminal, `editorctl`, API bridge, and MCP surfaces, agents
193199

194200
### Monet Canvas
195201

196-
- create artboard frames in `html`, `paperjs`, or `matterjs` mode
202+
- create artboard frames in `paperjs`, `matterjs`, or `html` mode
197203
- run any Paper.js script (vector graphics, animation, generative art)
198204
- run any Matter.js scene (2D physics simulations)
199205
- inject inline HTML/CSS/JS for arbitrary web-native designs
@@ -220,7 +226,8 @@ editorctl get-state
220226
editorctl search-segments "terminal workflow"
221227
editorctl export /tmp/monet-export.mp4 high 1080p mp4
222228

223-
# Canvas — draw a Spider-Verse glitch with Paper.js
229+
# Canvas — Paper.js, Matter.js, or raw HTML
230+
editorctl canvas-add-frame "Paper Layout" 1440 900 paperjs
224231
editorctl canvas-add-frame "Glitch" 1280 720 paperjs
225232
editorctl canvas-frames
226233
editorctl canvas-run-paperjs <id> "var c = new Path.Circle({ center: view.center, radius: 100, fillColor: '#7aa2f7' });"

0 commit comments

Comments
 (0)