glyphsmith 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/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "glyphsmith",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "bin": {
7
+ "glyphsmith": "dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "README.ja.md",
13
+ "LICENSE",
14
+ "skills",
15
+ "web"
16
+ ],
17
+ "scripts": {
18
+ "build": "node ../../scripts/build-cli.mjs",
19
+ "check-types": "tsc --noEmit",
20
+ "dev": "pnpm run build && node dist/index.js host --example playground",
21
+ "dev:icons": "pnpm run build && node dist/index.js host --example glyphsmith",
22
+ "prepack": "pnpm -w run build:cli"
23
+ },
24
+ "devDependencies": {
25
+ "@glyphsmith/ast": "workspace:*",
26
+ "@glyphsmith/mcp": "workspace:*",
27
+ "@glyphsmith/svg": "workspace:*",
28
+ "@repo/typescript-config": "workspace:*",
29
+ "@types/node": "^22",
30
+ "hono": "^4.12.23",
31
+ "typescript": "5.9.2"
32
+ }
33
+ }
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: glyphsmith
3
+ description: GlyphSmith project authoring, editing, MCP coordination, Geometry AST, patch workflows, examples, and CLI development guidance. Use when working with GlyphSmith projects, drawing or modifying SVG-equivalent geometry, configuring agent skills/MCP, or deciding whether to use MCP versus offline .gs.json edits.
4
+ ---
5
+
6
+ # GlyphSmith
7
+
8
+ Use this skill when working on a GlyphSmith project, especially through an active GlyphSmith MCP/editor session.
9
+
10
+ GlyphSmith is a Geometry AST based SVG editor. Treat SVG text as import/export format only.
11
+
12
+ ## Rules
13
+
14
+ * Read and write Geometry AST project data, not raw SVG strings.
15
+ * Prefer patch operations for small edits.
16
+ * Keep one page equivalent to one SVG document.
17
+ * Check `projectPrompt` before creating or editing generated artwork, and follow it as the project-wide art direction when present.
18
+ * Use MCP tools for an active editor session when they are available.
19
+ * Default rule: do not directly edit `.gs.json`.
20
+ * While the GlyphSmith CLI host or MCP server is running, always use MCP tools so the editor, revision, autosave, and WebSocket sync stay consistent.
21
+ * Direct `.gs.json` edits are fallback-only for offline workflows, such as examples, fixtures, migrations, or cases where no active editor/MCP host is available.
22
+ * If offline direct edits are unavoidable, preserve project/page metadata, make minimal Geometry AST changes, and avoid rewriting the whole project.
23
+
24
+ ## Related Skills
25
+
26
+ Use these focused GlyphSmith skills when the task needs their details:
27
+
28
+ * `glyphsmith-mcp`: active editor sessions, MCP resources/tools, patch application, selection, page operations, and SVG export through the host.
29
+ * `glyphsmith-ast`: Geometry AST schema, node fields, path segments, text, groups, and project/page structure.
30
+ * `glyphsmith-patch`: patch operation shapes and small edit patterns for Geometry AST changes.
31
+
32
+ For active editor work, prefer `glyphsmith-mcp` first, then load `glyphsmith-ast` or `glyphsmith-patch` only when schema or patch details are needed.
33
+
34
+ ## Examples
35
+
36
+ Examples are first-class projects:
37
+
38
+ ```txt
39
+ examples/playground.gs.json
40
+ examples/glyphsmith.gs.json
41
+ ```
42
+
43
+ Use `pnpm run dev` for the playground project.
44
+ Use `pnpm run dev:icons` for the official GlyphSmith icon set.
45
+ Do not hardcode assumptions about a specific example project.
46
+
47
+ ## Installation
48
+
49
+ Install GlyphSmith skills into agent skill directories with:
50
+
51
+ ```bash
52
+ glyphsmith skills install codex
53
+ glyphsmith skills install claude
54
+ ```
55
+
56
+ Use `glyphsmith skills install claude --project <project-dir>` for project-local Claude skills.
57
+
58
+ Register the default local MCP endpoint with:
59
+
60
+ ```bash
61
+ glyphsmith mcp install codex --url http://127.0.0.1:6202/mcp
62
+ glyphsmith mcp install claude --url http://127.0.0.1:6202/mcp
63
+ ```
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: glyphsmith-ast
3
+ description: GlyphSmith Geometry AST schema guidance for project files, pages, documents, groups, paths, segments, shapes, text nodes, styling fields, and SVG-compatible geometry. Use when inspecting or constructing Geometry AST data for GlyphSmith.
4
+ ---
5
+
6
+ # GlyphSmith AST
7
+
8
+ Use this skill when inspecting or changing GlyphSmith Geometry AST data.
9
+
10
+ ## Geometry AST
11
+
12
+ The project file is a `GlyphSmithProject`.
13
+
14
+ Do not directly edit `.gs.json` during an active GlyphSmith editor/MCP session. Use MCP tools for active sessions, and treat direct project-file edits as an offline fallback for examples, fixtures, or migrations.
15
+
16
+ ```txt
17
+ GlyphSmithProject
18
+ └ Page[]
19
+ └ GeometryDocument
20
+ └ GeometryNode tree
21
+ ```
22
+
23
+ Supported node concepts include groups, paths, rectangles, circles, ellipses, polygons, polylines, lines, and text.
24
+
25
+ Path geometry must be normalized into segments. Do not store only raw SVG path strings.
26
+
27
+ Groups are normal Geometry AST nodes:
28
+
29
+ ```json
30
+ {
31
+ "id": "group-1",
32
+ "type": "group",
33
+ "name": "Group",
34
+ "children": []
35
+ }
36
+ ```
37
+
38
+ Text is stored as plain text in `TextNode.text`, not as raw SVG markup.
39
+ Line breaks are represented with `\n`.
40
+
41
+ ```json
42
+ {
43
+ "id": "text-1",
44
+ "type": "text",
45
+ "x": 128,
46
+ "y": 160,
47
+ "text": "GlyphSmith\nIcon",
48
+ "fill": "#111827",
49
+ "fontFamily": "Inter, system-ui, sans-serif",
50
+ "fontSize": 24,
51
+ "fontWeight": "700",
52
+ "textAnchor": "middle"
53
+ }
54
+ ```
55
+
56
+ ## Segment Rules
57
+
58
+ Supported path segment concepts:
59
+
60
+ * Line
61
+ * Cubic Bezier
62
+ * Quadratic Bezier
63
+ * Arc
64
+
65
+ Spline-like editor tools may generate cubic Bezier geometry internally.
66
+
67
+ Segment shapes:
68
+
69
+ ```json
70
+ { "type": "line", "to": { "x": 240, "y": 160 } }
71
+ ```
72
+
73
+ ```json
74
+ {
75
+ "type": "quadratic",
76
+ "control": { "x": 180, "y": 80 },
77
+ "to": { "x": 320, "y": 160 }
78
+ }
79
+ ```
80
+
81
+ Stroke style supports SVG-style cap and join values:
82
+
83
+ ```json
84
+ {
85
+ "fill": "none",
86
+ "stroke": "#111827",
87
+ "strokeWidth": 32,
88
+ "strokeLinecap": "round",
89
+ "strokeLinejoin": "round"
90
+ }
91
+ ```
92
+
93
+ ```json
94
+ {
95
+ "type": "cubic",
96
+ "control1": { "x": 160, "y": 80 },
97
+ "control2": { "x": 320, "y": 280 },
98
+ "to": { "x": 400, "y": 160 }
99
+ }
100
+ ```
101
+
102
+ ```json
103
+ {
104
+ "type": "arc",
105
+ "rx": 96,
106
+ "ry": 96,
107
+ "xAxisRotation": 0,
108
+ "largeArc": false,
109
+ "sweep": true,
110
+ "to": { "x": 320, "y": 240 }
111
+ }
112
+ ```
@@ -0,0 +1,294 @@
1
+ ---
2
+ name: glyphsmith-mcp
3
+ description: GlyphSmith MCP workflow guidance for active editor sessions, local host endpoints, resources, tools, page/document reads, patch application, selection-aware edits, SVG export, and project save behavior. Use when a running GlyphSmith CLI host or MCP endpoint is available.
4
+ ---
5
+
6
+ # GlyphSmith MCP
7
+
8
+ Use this skill when an active GlyphSmith editor session exposes a local MCP endpoint.
9
+
10
+ ## Workflow
11
+
12
+ 1. Read the active project or page through MCP resources/tools.
13
+ 2. Generate small patch operations against Geometry AST.
14
+ 3. Apply patches through MCP.
15
+ 4. Re-read the affected document to confirm the result.
16
+
17
+ ## Rules
18
+
19
+ * Do not regenerate a whole SVG when a patch is enough.
20
+ * Do not edit raw SVG strings for active editor changes.
21
+ * Treat `.gs.json` as an implementation detail while the GlyphSmith CLI host is active.
22
+ * Do not directly edit `.gs.json` during active sessions. Use MCP tools so project revisions, autosave, and WebSocket clients stay synchronized.
23
+ * Prefer page-scoped operations.
24
+ * Keep comments as first-class instructions for agents.
25
+ * Before drawing or editing generated artwork, read `glyphsmith://project` or call `project_get` and follow `project.projectPrompt` when present.
26
+
27
+ ## Expected Local Host
28
+
29
+ The CLI starts the editor UI and host server locally.
30
+
31
+ ```txt
32
+ Editor: http://127.0.0.1:6201
33
+ Host: ws://127.0.0.1:6202/ws
34
+ MCP: http://127.0.0.1:6202/mcp
35
+ ```
36
+
37
+ If the default port is unavailable, use the actual MCP URL printed by the CLI.
38
+
39
+ For monorepo development with `pnpm run dev`, the same default ports are used:
40
+
41
+ ```txt
42
+ Editor: http://localhost:6201
43
+ Host: ws://localhost:6202/ws
44
+ MCP: http://localhost:6202/mcp
45
+ ```
46
+
47
+ `pnpm run dev` opens `examples/playground.gs.json`.
48
+ `pnpm run dev:icons` opens `examples/glyphsmith.gs.json`.
49
+
50
+ Register the endpoint with local agents when needed.
51
+
52
+ ```bash
53
+ glyphsmith mcp install codex --url http://127.0.0.1:6202/mcp
54
+ glyphsmith mcp install claude --url http://127.0.0.1:6202/mcp
55
+ ```
56
+
57
+ ## Resources
58
+
59
+ ```txt
60
+ glyphsmith://project
61
+ glyphsmith://pages
62
+ glyphsmith://active-document
63
+ glyphsmith://document/{pageId}
64
+ glyphsmith://comments
65
+ glyphsmith://selection
66
+ glyphsmith://skill-guide
67
+ ```
68
+
69
+ ## Tools
70
+
71
+ ```txt
72
+ project_get
73
+ pages_list
74
+ document_get
75
+ selection_get
76
+ comments_get
77
+ patch_apply
78
+ patches_apply
79
+ node_insert
80
+ node_update
81
+ node_delete
82
+ node_move
83
+ document_update
84
+ path_create
85
+ path_segment_append
86
+ path_segment_update
87
+ path_segment_delete
88
+ path_set_closed
89
+ page_add
90
+ page_duplicate
91
+ page_delete
92
+ page_set_active
93
+ svg_export
94
+ project_save
95
+ ```
96
+
97
+ Use `patch_apply` with `dryRun: true` before risky geometry changes.
98
+ Use `patches_apply` when drawing multiple shapes in one update.
99
+ Use `node_insert`, `node_update`, `node_delete`, and `node_move` for simple create/edit/delete/move operations.
100
+ Use `path_create` and `path_segment_*` for path drawing or segment-level curve edits.
101
+ Use `node_insert` / `node_update` for `text` and `group` nodes as normal Geometry AST nodes.
102
+ Pass `revision` when mutating if the current revision is known.
103
+ `glyphsmith://selection` reflects the current editor selection when the web editor is connected to the CLI host.
104
+
105
+ ## Drawing Workflow
106
+
107
+ When asked to draw SVG content:
108
+
109
+ 1. Call `project_get` or read `glyphsmith://project` to check `projectPrompt` and revision.
110
+ 2. Call `document_get` to read the active document when needed.
111
+ 3. Use `document_update` if the requested canvas size differs.
112
+ 4. Use `patches_apply` or `node_insert` to add Geometry AST nodes.
113
+ 5. Re-read with `document_get`.
114
+ 6. Use `svg_export` when the user asks for SVG output.
115
+
116
+ Example `patches_apply` arguments:
117
+
118
+ ```json
119
+ {
120
+ "revision": "<current-revision>",
121
+ "patches": [
122
+ {
123
+ "op": "updateDocument",
124
+ "changes": {
125
+ "width": 512,
126
+ "height": 512,
127
+ "name": "Simple Icon"
128
+ }
129
+ },
130
+ {
131
+ "op": "insert",
132
+ "parentId": "root",
133
+ "node": {
134
+ "id": "icon-bg",
135
+ "type": "rect",
136
+ "x": 48,
137
+ "y": 48,
138
+ "width": 416,
139
+ "height": 416,
140
+ "rx": 48,
141
+ "ry": 48,
142
+ "style": {
143
+ "fill": "#0f172a",
144
+ "stroke": "#38bdf8",
145
+ "strokeWidth": 8
146
+ }
147
+ }
148
+ },
149
+ {
150
+ "op": "insert",
151
+ "parentId": "root",
152
+ "node": {
153
+ "id": "icon-circle",
154
+ "type": "ellipse",
155
+ "cx": 256,
156
+ "cy": 256,
157
+ "rx": 120,
158
+ "ry": 120,
159
+ "style": {
160
+ "fill": "#22c55e",
161
+ "stroke": "none"
162
+ }
163
+ }
164
+ }
165
+ ]
166
+ }
167
+ ```
168
+
169
+ Example edit arguments:
170
+
171
+ ```json
172
+ {
173
+ "target": "icon-circle",
174
+ "changes": {
175
+ "rx": 96,
176
+ "ry": 96,
177
+ "style": {
178
+ "fill": "#f97316",
179
+ "stroke": "#fff7ed",
180
+ "strokeWidth": 6
181
+ }
182
+ }
183
+ }
184
+ ```
185
+
186
+ Example delete arguments:
187
+
188
+ ```json
189
+ {
190
+ "target": "icon-circle"
191
+ }
192
+ ```
193
+
194
+ ## Path Drawing
195
+
196
+ Create paths with normalized segments, not raw SVG `d` strings.
197
+
198
+ Example `path_create` arguments:
199
+
200
+ ```json
201
+ {
202
+ "id": "logo-curve",
203
+ "start": { "x": 96, "y": 320 },
204
+ "closed": false,
205
+ "style": {
206
+ "fill": "none",
207
+ "stroke": "#38bdf8",
208
+ "strokeWidth": 10
209
+ },
210
+ "segments": [
211
+ {
212
+ "type": "cubic",
213
+ "control1": { "x": 160, "y": 160 },
214
+ "control2": { "x": 320, "y": 480 },
215
+ "to": { "x": 416, "y": 280 }
216
+ }
217
+ ]
218
+ }
219
+ ```
220
+
221
+ Append a line segment:
222
+
223
+ ```json
224
+ {
225
+ "target": "logo-curve",
226
+ "segment": {
227
+ "type": "line",
228
+ "to": { "x": 448, "y": 360 }
229
+ }
230
+ }
231
+ ```
232
+
233
+ Append a quadratic segment:
234
+
235
+ ```json
236
+ {
237
+ "target": "logo-curve",
238
+ "segment": {
239
+ "type": "quadratic",
240
+ "control": { "x": 360, "y": 120 },
241
+ "to": { "x": 448, "y": 240 }
242
+ }
243
+ }
244
+ ```
245
+
246
+ Append an arc segment:
247
+
248
+ ```json
249
+ {
250
+ "target": "logo-curve",
251
+ "segment": {
252
+ "type": "arc",
253
+ "rx": 96,
254
+ "ry": 96,
255
+ "xAxisRotation": 0,
256
+ "largeArc": false,
257
+ "sweep": true,
258
+ "to": { "x": 320, "y": 384 }
259
+ }
260
+ }
261
+ ```
262
+
263
+ Replace the first segment:
264
+
265
+ ```json
266
+ {
267
+ "target": "logo-curve",
268
+ "index": 0,
269
+ "segment": {
270
+ "type": "cubic",
271
+ "control1": { "x": 128, "y": 180 },
272
+ "control2": { "x": 300, "y": 420 },
273
+ "to": { "x": 400, "y": 300 }
274
+ }
275
+ }
276
+ ```
277
+
278
+ Delete a segment:
279
+
280
+ ```json
281
+ {
282
+ "target": "logo-curve",
283
+ "index": 1
284
+ }
285
+ ```
286
+
287
+ Close a path:
288
+
289
+ ```json
290
+ {
291
+ "target": "logo-curve",
292
+ "closed": true
293
+ }
294
+ ```