@geohar/opencode-svg-mcp 0.4.3 → 0.5.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/instructions.txt +54 -14
- package/package.json +1 -1
package/instructions.txt
CHANGED
|
@@ -1,16 +1,56 @@
|
|
|
1
1
|
# Diagrams & SVGs (svg-mcp)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
<!-- Canonical reach-for-svg-mcp directive. Copy into your global
|
|
4
|
+
$CLAUDE_CONFIG_DIR/CLAUDE.md, or let an svg-mcp plugin inject it each session
|
|
5
|
+
(the plugins symlink this file). It directs *approach*; the MCP tool
|
|
6
|
+
descriptions carry the mechanics. -->
|
|
7
|
+
|
|
8
|
+
Three rules. Each fires on a **cue you can catch yourself in the middle of**, not on a
|
|
9
|
+
topic you have to remember to think about. That's deliberate: you will not remember to
|
|
10
|
+
"use the tools" — but you can notice yourself about to type a `<` .
|
|
11
|
+
|
|
12
|
+
### 1. About to write `<svg`, or hand-edit XML inside one? That's the cue.
|
|
13
|
+
|
|
14
|
+
Writing markup by hand is the wrong move **even when the shape looks trivial** — that's
|
|
15
|
+
exactly when it feels justified, and it skips the only part that matters: seeing the
|
|
16
|
+
result. At that exact moment:
|
|
17
|
+
|
|
18
|
+
| your next move was | do this instead |
|
|
19
|
+
|---|---|
|
|
20
|
+
| write `<svg>`/`<path>`/`<rect>` markup for something new | `create_document`, then the `add_*` primitives — `boolean` for union/difference/intersection, plus gradients / filters / transforms |
|
|
21
|
+
| hand-patch the markup of an SVG you have | `import_svg` → `find` / `describe_node` to locate → `edit_*` / `apply_*` / `delete_node` |
|
|
22
|
+
| hand a result back after building it | `export_render` (or `render_document`) and **actually look at the image** first |
|
|
23
|
+
|
|
24
|
+
Construct → render → see → iterate. **The loop is the product, not the XML.** One pass
|
|
25
|
+
without rendering isn't a faster version of this — it's a different, worse thing.
|
|
26
|
+
|
|
27
|
+
**Catch yourself:** if you're about to show or save SVG source you have never rendered,
|
|
28
|
+
you are guessing at your own output. Render it, look, *then* hand it over.
|
|
29
|
+
|
|
30
|
+
### 2. About to place boxes, arrows, bars, or rows by coordinate? Declare, don't draw.
|
|
31
|
+
|
|
32
|
+
Hand-computing positions for structured content is the diagram version of hand-writing
|
|
33
|
+
markup — it feels precise and produces drift, overlaps, and arrows through boxes. The
|
|
34
|
+
cue is reaching for `add_rect` + `add_line` to represent *things and relationships*:
|
|
35
|
+
|
|
36
|
+
| you're about to | do this instead |
|
|
37
|
+
|---|---|
|
|
38
|
+
| draw an architecture / flowchart / pipeline from rects and lines | `add_diagram_node(kind, label)` + `add_diagram_edge(source, target, kind)` + `add_diagram_container(members)`, then `layout_diagram` — zero coordinates |
|
|
39
|
+
| hand-place bars, axes, tick labels (or shell out to matplotlib for a small figure) | `add_chart(kind, data)` — bar/line/donut/scatter/sparkline, scales and margins derived from the data |
|
|
40
|
+
| lay out rows of text as a grid | `add_table(rows, header)` — column widths measured, numerics right-aligned |
|
|
41
|
+
| pick colors and fonts shape by shape | `load_theme` first and say what things ARE (`role=`, `kind=`); the theme paints them. Read the guidance the load returns — it's the house style speaking |
|
|
42
|
+
| annotate or key the result | `add_callout(target, text)` (points at ids, survives reflow), `add_legend()` (generated from what the document uses) |
|
|
43
|
+
|
|
44
|
+
After moving, resizing, or deleting diagram nodes: **`reflow()`** — one call re-routes
|
|
45
|
+
edges, re-anchors callouts, and re-fits containers. Layout is opt-in; it never reruns
|
|
46
|
+
behind your back.
|
|
47
|
+
|
|
48
|
+
### 3. More than a couple of tool calls? Start the preview and say so.
|
|
49
|
+
|
|
50
|
+
Cue: you can tell the build will take more than two or three calls. Call `start_preview`
|
|
51
|
+
**at the start**, not when you're done, and put the exact URL in your reply unprompted:
|
|
52
|
+
"Live preview: <url> — it refreshes on every change."
|
|
53
|
+
|
|
54
|
+
The reason is timing, not courtesy. Someone watching the drawing take shape can redirect
|
|
55
|
+
you mid-build; the same person handed a finished image can only accept it or ask for the
|
|
56
|
+
whole thing again. A preview URL shared at the end has none of that value.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geohar/opencode-svg-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "OpenCode plugin: run the svg-mcp MCP server via sharedserver and register its endpoint with OpenCode. Stands down when a combiner already serves svg-mcp.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|