excalidrop 0.1.1

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 (234) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +411 -0
  3. package/dist/cli.d.ts +24 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +533 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/frontend/assets/Assistant-Bold-gm-uSS1B.woff2 +0 -0
  8. package/dist/frontend/assets/Assistant-Medium-DrcxCXg3.woff2 +0 -0
  9. package/dist/frontend/assets/Assistant-Regular-DVxZuzxb.woff2 +0 -0
  10. package/dist/frontend/assets/Assistant-SemiBold-SCI4bEL9.woff2 +0 -0
  11. package/dist/frontend/assets/Tableau10-B-NsZVaP.js +1 -0
  12. package/dist/frontend/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
  13. package/dist/frontend/assets/advancedFormat-bKUmsig-.js +1 -0
  14. package/dist/frontend/assets/ar-SA-G6X2FPQ2-C7K_UR3P.js +10 -0
  15. package/dist/frontend/assets/arc-BI_FJWE7.js +1 -0
  16. package/dist/frontend/assets/array-BKyUJesY.js +1 -0
  17. package/dist/frontend/assets/az-AZ-76LH7QW2-PkhuRuSr.js +1 -0
  18. package/dist/frontend/assets/band-dPffDWoQ.js +1 -0
  19. package/dist/frontend/assets/bg-BG-XCXSNQG7-CgLRSYTl.js +5 -0
  20. package/dist/frontend/assets/blockDiagram-38ab4fdb-BFdBRYSn.js +118 -0
  21. package/dist/frontend/assets/blockDiagram-68f4deed-Ynbqr7bQ.js +118 -0
  22. package/dist/frontend/assets/bn-BD-2XOGV67Q-CEvkU0mz.js +5 -0
  23. package/dist/frontend/assets/c4Diagram-15b5d702-Dm7F1Pn_.js +10 -0
  24. package/dist/frontend/assets/c4Diagram-3d4e48cf-COkK-e67.js +10 -0
  25. package/dist/frontend/assets/ca-ES-6MX7JW3Y-DzP6q9bE.js +8 -0
  26. package/dist/frontend/assets/channel-BqCiG5n3.js +1 -0
  27. package/dist/frontend/assets/classDiagram-70f12bd4-CRzulwvH.js +2 -0
  28. package/dist/frontend/assets/classDiagram-d40c83e7-DNbA-n-a.js +2 -0
  29. package/dist/frontend/assets/classDiagram-v2-d5a6b087-l-GglywH.js +2 -0
  30. package/dist/frontend/assets/classDiagram-v2-f2320105-B_TY1zoc.js +2 -0
  31. package/dist/frontend/assets/clone-B6Jqcrku.js +1 -0
  32. package/dist/frontend/assets/createText-2e5e7dd3-DB_k52Pn.js +5 -0
  33. package/dist/frontend/assets/createText-d213de94-D-G49giw.js +5 -0
  34. package/dist/frontend/assets/cs-CZ-2BRQDIVT-Bf4TOzpR.js +11 -0
  35. package/dist/frontend/assets/cytoscape-cose-bilkent-DQYypj0P.js +331 -0
  36. package/dist/frontend/assets/da-DK-5WZEPLOC-jO-5kyXb.js +5 -0
  37. package/dist/frontend/assets/de-DE-XR44H4JA-BkNXWOVh.js +8 -0
  38. package/dist/frontend/assets/directory-open-01563666-DWU9wJ6I.js +1 -0
  39. package/dist/frontend/assets/directory-open-4ed118d0-BzWybGaI.js +1 -0
  40. package/dist/frontend/assets/edges-332bd1c7-CVvMtkTa.js +4 -0
  41. package/dist/frontend/assets/edges-e0da2a9e-DQBAvC8-.js +4 -0
  42. package/dist/frontend/assets/el-GR-BZB4AONW-Dv7Y9hMk.js +10 -0
  43. package/dist/frontend/assets/elk.bundled-YVS3PsMH.js +26 -0
  44. package/dist/frontend/assets/erDiagram-880f2ed8-BjBeR38f.js +51 -0
  45. package/dist/frontend/assets/erDiagram-9861fffd-B2Bi3R45.js +51 -0
  46. package/dist/frontend/assets/es-ES-U4NZUMDT-CWhs0SQY.js +9 -0
  47. package/dist/frontend/assets/eu-ES-A7QVB2H4-BfkFwc3e.js +11 -0
  48. package/dist/frontend/assets/fa-IR-HGAKTJCU-BgWzSj46.js +8 -0
  49. package/dist/frontend/assets/fi-FI-Z5N7JZ37-CUyvkum-.js +6 -0
  50. package/dist/frontend/assets/file-open-002ab408-DIuFHtCF.js +1 -0
  51. package/dist/frontend/assets/file-open-7c801643-684qeFg4.js +1 -0
  52. package/dist/frontend/assets/file-save-3189631c-x92wctJd.js +1 -0
  53. package/dist/frontend/assets/file-save-745eba88-Bb9F9Kg7.js +1 -0
  54. package/dist/frontend/assets/flowDb-7c981674-BSZyyVBf.js +10 -0
  55. package/dist/frontend/assets/flowDb-956e92f1-BC3-CLkF.js +10 -0
  56. package/dist/frontend/assets/flowDiagram-66a62f08-H57DAvmM.js +4 -0
  57. package/dist/frontend/assets/flowDiagram-cbd28bf7-Bw4Z2nBD.js +4 -0
  58. package/dist/frontend/assets/flowDiagram-v2-96b9c2cf-CBjbm_oB.js +1 -0
  59. package/dist/frontend/assets/flowDiagram-v2-ffc7f31a-CoQufPp2.js +1 -0
  60. package/dist/frontend/assets/flowchart-elk-definition-36e2d292-1kZNdf3X.js +114 -0
  61. package/dist/frontend/assets/flowchart-elk-definition-4a651766-DDhG2Esi.js +114 -0
  62. package/dist/frontend/assets/fr-FR-RHASNOE6-7xzoRwbd.js +9 -0
  63. package/dist/frontend/assets/ganttDiagram-04f9e578-CtUSsXCz.js +257 -0
  64. package/dist/frontend/assets/ganttDiagram-c361ad54-K42AklFY.js +257 -0
  65. package/dist/frontend/assets/gitGraphDiagram-21fc4d3e-uW6XA6Y6.js +70 -0
  66. package/dist/frontend/assets/gitGraphDiagram-72cf32ee-CCNbhnBg.js +70 -0
  67. package/dist/frontend/assets/gl-ES-HMX3MZ6V-CXuDDwNP.js +10 -0
  68. package/dist/frontend/assets/graph-CYOmcSYN.js +1 -0
  69. package/dist/frontend/assets/graph-o42dOfI7.js +1 -0
  70. package/dist/frontend/assets/he-IL-6SHJWFNN-O9dzh9EM.js +10 -0
  71. package/dist/frontend/assets/hi-IN-IWLTKZ5I-DlrOXhWs.js +4 -0
  72. package/dist/frontend/assets/hu-HU-A5ZG7DT2-C3eNg-uI.js +7 -0
  73. package/dist/frontend/assets/id-ID-SAP4L64H-6iM4pI5c.js +10 -0
  74. package/dist/frontend/assets/image-blob-reduce.esm-B6b2_-a4.js +7 -0
  75. package/dist/frontend/assets/index-3862675e-DrvLhypC.js +1 -0
  76. package/dist/frontend/assets/index-6079d271-BgVTRqg2.js +1 -0
  77. package/dist/frontend/assets/index-BRA5OktX.css +1 -0
  78. package/dist/frontend/assets/index-D-cr7jpJ.js +349 -0
  79. package/dist/frontend/assets/index-DGmpr33w.js +3 -0
  80. package/dist/frontend/assets/index-HkUXslJy.js +87 -0
  81. package/dist/frontend/assets/infoDiagram-4a4f5b27-ZxmAcaW1.js +7 -0
  82. package/dist/frontend/assets/infoDiagram-f8f76790-Bn-PhiFG.js +7 -0
  83. package/dist/frontend/assets/init-Gi6I4Gst.js +1 -0
  84. package/dist/frontend/assets/it-IT-JPQ66NNP-B26NQzGp.js +11 -0
  85. package/dist/frontend/assets/ja-JP-DBVTYXUO-CB0fvnYJ.js +8 -0
  86. package/dist/frontend/assets/journeyDiagram-29694f62-ggDKs06f.js +139 -0
  87. package/dist/frontend/assets/journeyDiagram-49397b02-pdDS-n-z.js +139 -0
  88. package/dist/frontend/assets/kaa-6HZHGXH3-YNdBdcwJ.js +1 -0
  89. package/dist/frontend/assets/kab-KAB-ZGHBKWFO-D86pwZO0.js +8 -0
  90. package/dist/frontend/assets/katex-ChWnQ-fc.js +261 -0
  91. package/dist/frontend/assets/kk-KZ-P5N5QNE5-CpG5oheM.js +1 -0
  92. package/dist/frontend/assets/km-KH-HSX4SM5Z-DYOZ3Azw.js +11 -0
  93. package/dist/frontend/assets/ko-KR-MTYHY66A-BHorm6lC.js +9 -0
  94. package/dist/frontend/assets/ku-TR-6OUDTVRD-CM9RgEHv.js +9 -0
  95. package/dist/frontend/assets/layout-CCtkxrAf.js +1 -0
  96. package/dist/frontend/assets/layout-DW9Qf-At.js +1 -0
  97. package/dist/frontend/assets/line-DvZfgg9P.js +1 -0
  98. package/dist/frontend/assets/linear-FwFrGRfa.js +1 -0
  99. package/dist/frontend/assets/lt-LT-XHIRWOB4-DvriKXBj.js +3 -0
  100. package/dist/frontend/assets/lv-LV-5QDEKY6T-DzQpwk87.js +7 -0
  101. package/dist/frontend/assets/mindmap-definition-ac74a2e8-DsRo8f2w.js +95 -0
  102. package/dist/frontend/assets/mindmap-definition-fc14e90a-dQ9reluI.js +95 -0
  103. package/dist/frontend/assets/mr-IN-CRQNXWMA-C7RzxxP5.js +13 -0
  104. package/dist/frontend/assets/my-MM-5M5IBNSE-B-RRuy29.js +1 -0
  105. package/dist/frontend/assets/nb-NO-T6EIAALU-B47x16Ik.js +10 -0
  106. package/dist/frontend/assets/nl-NL-IS3SIHDZ-BxAKoQne.js +8 -0
  107. package/dist/frontend/assets/nn-NO-6E72VCQL-dfpbEDSZ.js +8 -0
  108. package/dist/frontend/assets/oc-FR-POXYY2M6-gv6geBjV.js +8 -0
  109. package/dist/frontend/assets/ordinal-Cboi1Yqb.js +1 -0
  110. package/dist/frontend/assets/pa-IN-N4M65BXN-CY30-qH7.js +4 -0
  111. package/dist/frontend/assets/path-CbwjOpE9.js +1 -0
  112. package/dist/frontend/assets/pica-DWYGHLQV.js +7 -0
  113. package/dist/frontend/assets/pie-CDiWh1rj.js +1 -0
  114. package/dist/frontend/assets/pieDiagram-421022e6-Bgy-duyf.js +35 -0
  115. package/dist/frontend/assets/pieDiagram-8a3498a8-DH7FsbPK.js +35 -0
  116. package/dist/frontend/assets/pl-PL-T2D74RX3-TrHugsIA.js +9 -0
  117. package/dist/frontend/assets/pt-BR-5N22H2LF-CJxdFp9c.js +9 -0
  118. package/dist/frontend/assets/pt-PT-UZXXM6DQ-CB-1q6YJ.js +9 -0
  119. package/dist/frontend/assets/quadrantDiagram-0957ecba-DcwYI1oi.js +7 -0
  120. package/dist/frontend/assets/quadrantDiagram-120e2f19-CvHU5a9v.js +7 -0
  121. package/dist/frontend/assets/requirementDiagram-23d650b8-tdagN8HP.js +52 -0
  122. package/dist/frontend/assets/requirementDiagram-deff3bca-BMGM-fSI.js +52 -0
  123. package/dist/frontend/assets/ro-RO-JPDTUUEW-DQq9DBOd.js +11 -0
  124. package/dist/frontend/assets/roundRect-0PYZxl1G.js +1 -0
  125. package/dist/frontend/assets/ru-RU-B4JR7IUQ-CWX32rfh.js +9 -0
  126. package/dist/frontend/assets/sankeyDiagram-04a897e0-3i6zWpY2.js +8 -0
  127. package/dist/frontend/assets/sankeyDiagram-23345273-ncj1Ol7S.js +8 -0
  128. package/dist/frontend/assets/sankeyLinkHorizontal-DgqkLiUE.js +1 -0
  129. package/dist/frontend/assets/selectAll-DJwesbwT.js +1 -0
  130. package/dist/frontend/assets/sequenceDiagram-17ac3bff-ChyKKRZA.js +122 -0
  131. package/dist/frontend/assets/sequenceDiagram-704730f1-D57_wP9k.js +122 -0
  132. package/dist/frontend/assets/si-LK-N5RQ5JYF-Lkc5ZxyG.js +1 -0
  133. package/dist/frontend/assets/sk-SK-C5VTKIMK-DyvYXjqZ.js +6 -0
  134. package/dist/frontend/assets/sl-SI-NN7IZMDC-D_MvP9Rh.js +6 -0
  135. package/dist/frontend/assets/stateDiagram-587899a1-OjFTnFLS.js +1 -0
  136. package/dist/frontend/assets/stateDiagram-9c5f0230-BzU36S5C.js +1 -0
  137. package/dist/frontend/assets/stateDiagram-v2-51a3dcff-CfX1qo7U.js +1 -0
  138. package/dist/frontend/assets/stateDiagram-v2-d93cdb3a-BH7Ud4sU.js +1 -0
  139. package/dist/frontend/assets/styles-2ab5d517-CA8x9Nh5.js +116 -0
  140. package/dist/frontend/assets/styles-5f03d8d2-BnO2pLhV.js +160 -0
  141. package/dist/frontend/assets/styles-6aaf32cf-COnot1ea.js +207 -0
  142. package/dist/frontend/assets/styles-9a916d00-C3QkBgTF.js +160 -0
  143. package/dist/frontend/assets/styles-c10674c1-CPAG2_rr.js +116 -0
  144. package/dist/frontend/assets/styles-edf9a4b0-B8Q9fyu0.js +207 -0
  145. package/dist/frontend/assets/subset-shared.chunk.js +84 -0
  146. package/dist/frontend/assets/subset-worker.chunk.js +1 -0
  147. package/dist/frontend/assets/sv-SE-XGPEYMSR-t6voGQSI.js +10 -0
  148. package/dist/frontend/assets/svgDrawCommon-08f97a94-CdT21LWf.js +1 -0
  149. package/dist/frontend/assets/svgDrawCommon-3ba9043b-D1MU7jAE.js +1 -0
  150. package/dist/frontend/assets/ta-IN-2NMHFXQM-7VmfDDyV.js +9 -0
  151. package/dist/frontend/assets/th-TH-HPSO5L25-B5rLEY9P.js +2 -0
  152. package/dist/frontend/assets/timeline-definition-7e6b55e7-BIcL44O_.js +61 -0
  153. package/dist/frontend/assets/timeline-definition-85554ec2-TgrYYwpU.js +61 -0
  154. package/dist/frontend/assets/tr-TR-DEFEU3FU-0CgOHXTn.js +7 -0
  155. package/dist/frontend/assets/uk-UA-QMV73CPH-CzSFsIsx.js +6 -0
  156. package/dist/frontend/assets/union-CnQAJu0l.js +1 -0
  157. package/dist/frontend/assets/vi-VN-M7AON7JQ-Bhx3rYU9.js +5 -0
  158. package/dist/frontend/assets/xml-BOsq7VnW.js +1 -0
  159. package/dist/frontend/assets/xychartDiagram-b6496bcd-BMKDop6v.js +7 -0
  160. package/dist/frontend/assets/xychartDiagram-e933f94c-DAWithrN.js +7 -0
  161. package/dist/frontend/assets/zh-CN-LNUGB5OW-Br52_wH4.js +10 -0
  162. package/dist/frontend/assets/zh-HK-E62DVLB3-Cj6mnIQ9.js +1 -0
  163. package/dist/frontend/assets/zh-TW-RAJ6MFWO-yLEsVBbC.js +9 -0
  164. package/dist/frontend/assets/zipObject-BeXj5PVd.js +1 -0
  165. package/dist/frontend/index.html +339 -0
  166. package/dist/index.d.ts +4 -0
  167. package/dist/index.d.ts.map +1 -0
  168. package/dist/index.js +2305 -0
  169. package/dist/index.js.map +1 -0
  170. package/dist/remote.d.ts +4 -0
  171. package/dist/remote.d.ts.map +1 -0
  172. package/dist/remote.js +133 -0
  173. package/dist/remote.js.map +1 -0
  174. package/dist/server.d.ts +4 -0
  175. package/dist/server.d.ts.map +1 -0
  176. package/dist/server.js +1217 -0
  177. package/dist/server.js.map +1 -0
  178. package/dist/target.d.ts +41 -0
  179. package/dist/target.d.ts.map +1 -0
  180. package/dist/target.js +244 -0
  181. package/dist/target.js.map +1 -0
  182. package/dist/types.d.ts +228 -0
  183. package/dist/types.d.ts.map +1 -0
  184. package/dist/types.js +53 -0
  185. package/dist/types.js.map +1 -0
  186. package/dist/utils/auth.d.ts +15 -0
  187. package/dist/utils/auth.d.ts.map +1 -0
  188. package/dist/utils/auth.js +68 -0
  189. package/dist/utils/auth.js.map +1 -0
  190. package/dist/utils/github.d.ts +26 -0
  191. package/dist/utils/github.d.ts.map +1 -0
  192. package/dist/utils/github.js +111 -0
  193. package/dist/utils/github.js.map +1 -0
  194. package/dist/utils/logger.d.ts +4 -0
  195. package/dist/utils/logger.d.ts.map +1 -0
  196. package/dist/utils/logger.js +25 -0
  197. package/dist/utils/logger.js.map +1 -0
  198. package/dist/utils/r2store.d.ts +19 -0
  199. package/dist/utils/r2store.d.ts.map +1 -0
  200. package/dist/utils/r2store.js +75 -0
  201. package/dist/utils/r2store.js.map +1 -0
  202. package/frontend/index.html +338 -0
  203. package/frontend/src/App.tsx +1091 -0
  204. package/frontend/src/main.tsx +15 -0
  205. package/frontend/src/utils/ghSync.ts +171 -0
  206. package/frontend/src/utils/mermaidConverter.ts +49 -0
  207. package/frontend/src/utils/webmcp.ts +285 -0
  208. package/package.json +101 -0
  209. package/scripts/check-local-bind.mjs +164 -0
  210. package/scripts/postinstall.mjs +23 -0
  211. package/scripts/publish-pages.sh +39 -0
  212. package/scripts/seed-r2.mjs +9 -0
  213. package/skills/excalidraw-skill/SKILL.md +303 -0
  214. package/skills/excalidraw-skill/evals/evals.json +23 -0
  215. package/skills/excalidraw-skill/references/cheatsheet.md +142 -0
  216. package/skills/excalidraw-skill/scripts/clear-canvas.cjs +38 -0
  217. package/skills/excalidraw-skill/scripts/create-element.cjs +68 -0
  218. package/skills/excalidraw-skill/scripts/delete-element.cjs +48 -0
  219. package/skills/excalidraw-skill/scripts/export-elements.cjs +53 -0
  220. package/skills/excalidraw-skill/scripts/healthcheck.cjs +35 -0
  221. package/skills/excalidraw-skill/scripts/import-elements.cjs +81 -0
  222. package/skills/excalidraw-skill/scripts/update-element.cjs +70 -0
  223. package/src/cli.ts +559 -0
  224. package/src/index.ts +2557 -0
  225. package/src/remote.ts +96 -0
  226. package/src/server.ts +1349 -0
  227. package/src/target.ts +208 -0
  228. package/src/types.ts +338 -0
  229. package/src/utils/auth.ts +61 -0
  230. package/src/utils/github.ts +93 -0
  231. package/src/utils/logger.ts +35 -0
  232. package/src/utils/r2store.ts +76 -0
  233. package/tsconfig.json +50 -0
  234. package/vite.config.js +37 -0
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from 'node:child_process';
4
+ import { basename, dirname, join } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+ const repoRoot = join(__dirname, '..');
10
+ const serverPath = join(repoRoot, 'dist', 'server.js');
11
+ const runtime = process.env.CANVAS_RUNTIME || process.execPath;
12
+ const runtimeName = basename(runtime).toLowerCase();
13
+ const runtimeArgs = runtimeName.includes('bun') ? ['run', serverPath] : [serverPath];
14
+ const port = Number(process.env.PORT || 32000 + Math.floor(Math.random() * 2000));
15
+ const startupTimeoutMs = 5000;
16
+ const duplicateExitTimeoutMs = 2500;
17
+
18
+ function spawnCanvas(host) {
19
+ const env = {
20
+ ...process.env,
21
+ PORT: String(port),
22
+ LOG_LEVEL: 'error',
23
+ };
24
+ if (host) {
25
+ env.HOST = host;
26
+ } else {
27
+ delete env.HOST;
28
+ }
29
+
30
+ return spawn(runtime, runtimeArgs, {
31
+ cwd: repoRoot,
32
+ env,
33
+ stdio: ['ignore', 'pipe', 'pipe'],
34
+ });
35
+ }
36
+
37
+ function collectOutput(child) {
38
+ let output = '';
39
+ child.stdout.on('data', chunk => {
40
+ output += chunk.toString();
41
+ });
42
+ child.stderr.on('data', chunk => {
43
+ output += chunk.toString();
44
+ });
45
+ return () => output.trim();
46
+ }
47
+
48
+ async function endpointResponds(url, timeoutMs = 500) {
49
+ const controller = new AbortController();
50
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
51
+ try {
52
+ const response = await fetch(url, { signal: controller.signal });
53
+ return response.ok;
54
+ } catch {
55
+ return false;
56
+ } finally {
57
+ clearTimeout(timeout);
58
+ }
59
+ }
60
+
61
+ async function waitForHealth(url, timeoutMs, child, getOutput) {
62
+ const start = Date.now();
63
+ while (Date.now() - start < timeoutMs) {
64
+ if (child && (child.exitCode !== null || child.signalCode !== null)) {
65
+ const status = child.exitCode !== null ? `exit code ${child.exitCode}` : `signal ${child.signalCode}`;
66
+ const output = getOutput ? getOutput() : '';
67
+ throw new Error(`Canvas server exited before health check with ${status}.${output ? `\n${output}` : ''}`);
68
+ }
69
+ if (await endpointResponds(url)) {
70
+ return;
71
+ }
72
+ await new Promise(resolve => setTimeout(resolve, 100));
73
+ }
74
+ throw new Error(`Timed out waiting for ${url}`);
75
+ }
76
+
77
+ function waitForExit(child, timeoutMs) {
78
+ return new Promise(resolve => {
79
+ const timeout = setTimeout(() => {
80
+ cleanup();
81
+ resolve(null);
82
+ }, timeoutMs);
83
+
84
+ const onExit = (code, signal) => {
85
+ cleanup();
86
+ resolve({ code, signal });
87
+ };
88
+
89
+ const cleanup = () => {
90
+ clearTimeout(timeout);
91
+ child.off('exit', onExit);
92
+ };
93
+
94
+ child.once('exit', onExit);
95
+ });
96
+ }
97
+
98
+ async function killChild(child) {
99
+ if (child.exitCode !== null || child.signalCode !== null) return;
100
+ child.kill('SIGTERM');
101
+ const exit = await waitForExit(child, 1000);
102
+ if (!exit) {
103
+ child.kill('SIGKILL');
104
+ }
105
+ }
106
+
107
+ let first;
108
+ let second;
109
+ let bindAll;
110
+
111
+ try {
112
+ first = spawnCanvas();
113
+ const firstOutput = collectOutput(first);
114
+
115
+ await waitForHealth(`http://127.0.0.1:${port}/health`, startupTimeoutMs, first, firstOutput);
116
+
117
+ if (await endpointResponds(`http://[::1]:${port}/health`)) {
118
+ throw new Error('Default canvas server should not listen on IPv6 loopback.');
119
+ }
120
+
121
+ second = spawnCanvas();
122
+ const secondOutput = collectOutput(second);
123
+ const duplicateExit = await waitForExit(second, duplicateExitTimeoutMs);
124
+
125
+ if (!duplicateExit) {
126
+ throw new Error('Second canvas server stayed running on the same local port.');
127
+ }
128
+ if (duplicateExit.code === 0) {
129
+ throw new Error('Second canvas server exited successfully instead of failing.');
130
+ }
131
+
132
+ bindAll = spawnCanvas('::');
133
+ const bindAllOutput = collectOutput(bindAll);
134
+ const bindAllExit = await waitForExit(bindAll, duplicateExitTimeoutMs);
135
+
136
+ if (!bindAllExit) {
137
+ throw new Error('Canvas server with HOST=:: stayed running while a loopback server was active.');
138
+ }
139
+ if (bindAllExit.code === 0) {
140
+ throw new Error('Canvas server with HOST=:: exited successfully instead of failing.');
141
+ }
142
+
143
+ console.log(
144
+ `Local bind check passed on port ${port} using ${runtimeName}: ` +
145
+ 'default bind is IPv4 loopback only, duplicate startup fails, and HOST=:: is guarded.'
146
+ );
147
+
148
+ await killChild(first);
149
+ if (process.env.DEBUG_BIND_CHECK && firstOutput()) {
150
+ console.error(firstOutput());
151
+ }
152
+ if (process.env.DEBUG_BIND_CHECK && secondOutput()) {
153
+ console.error(secondOutput());
154
+ }
155
+ if (process.env.DEBUG_BIND_CHECK && bindAllOutput()) {
156
+ console.error(bindAllOutput());
157
+ }
158
+ } catch (error) {
159
+ if (bindAll) await killChild(bindAll);
160
+ if (second) await killChild(second);
161
+ if (first) await killChild(first);
162
+ console.error((error instanceof Error) ? error.message : String(error));
163
+ process.exit(1);
164
+ }
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ // Postinstall hint for `npm i -D excalidrop`.
3
+ // Print-only: npm blocks interactive stdin during postinstall, so the actual
4
+ // setup (port pick + agent install) happens via `npx excalidrop init`.
5
+ if (process.env.EXCALIDROP_NO_POSTINSTALL) process.exit(0);
6
+
7
+ console.log(`
8
+ excalidrop installed.
9
+
10
+ Remote canvas (recommended — GitHub-backed, works on any repo):
11
+
12
+ npx excalidrop setup
13
+
14
+ checks gh auth, publishes the viewer to gh-pages, prints the app-install
15
+ link and verifies the site is live. Then tell your agent:
16
+
17
+ switch_remote { target: "<your Pages URL>" }
18
+
19
+ Local canvas instead:
20
+
21
+ npx excalidrop init # picks a free port, offers AI-agent install
22
+ npx excalidrop up
23
+ `);
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+ # Zero-config publish: auto-detects repo from git remote, enables Pages via gh.
3
+ # Usage: ./scripts/publish-pages.sh (or npx excalidrop publish)
4
+ set -euo pipefail
5
+ PKG_DIR="$(cd "$(dirname "$0")/.." && pwd)"
6
+ REPO="${REPO_SLUG:-$(git config --get remote.origin.url | sed -E -e 's/\.git$//' -e 's#.*github.com[:/]##')}"
7
+ echo "Repo: $REPO"
8
+ WORK=$(mktemp -d)
9
+ trap "rm -rf $WORK" EXIT
10
+ npm --prefix "$PKG_DIR" run build:frontend >/dev/null
11
+ git clone --depth 1 --branch gh-pages "git@github.com:${REPO}.git" "$WORK" 2>/dev/null || { git init -b gh-pages "$WORK"; git -C "$WORK" remote add origin "git@github.com:${REPO}.git"; }
12
+ cp -r "$PKG_DIR/dist/frontend/"* "$WORK"/
13
+ cp "$PKG_DIR/canvas.excalidraw" "$WORK"/ 2>/dev/null || echo '{"type":"excalidraw","version":2,"elements":[]}' > "$WORK/canvas.excalidraw"
14
+ git -C "$WORK" add -A && git -C "$WORK" -c user.name=excalidrop -c user.email=excalidrop@local commit -m "excalidrop: publish viewer" --allow-empty && git -C "$WORK" push origin gh-pages --force
15
+ # Seed `main` on empty repos and keep it the default branch.
16
+ # Without this, gh-pages is the only branch and GitHub makes it the default.
17
+ # Never touch the default branch of repos that already have a `main`.
18
+ if ! gh api "repos/${REPO}/git/ref/heads/main" >/dev/null 2>&1; then
19
+ SEED=$(mktemp -d)
20
+ git init -b main "$SEED" >/dev/null
21
+ # Empty commit only: main must exist so it stays the default branch,
22
+ # but setup puts NO files there (no canvas, no README). The canvas
23
+ # lives on gh-pages until the agent's first draw commits it.
24
+ git -C "$SEED" -c user.name=excalidrop -c user.email=excalidrop@local commit --allow-empty -m "init main" --quiet
25
+ git -C "$SEED" remote add origin "git@github.com:${REPO}.git"
26
+ git -C "$SEED" push origin main >/dev/null
27
+ rm -rf "$SEED"
28
+ if [ "$(gh api "repos/${REPO}" --jq '.default_branch' 2>/dev/null)" != "main" ]; then
29
+ gh api "repos/${REPO}" -X PATCH -f default_branch=main >/dev/null
30
+ fi
31
+ fi
32
+ # Point Pages at the gh-pages branch (PUT works whether Pages is on or off)
33
+ CUR="$(gh api "repos/${REPO}/pages" --jq '.source.branch' 2>/dev/null || echo none)"
34
+ if [ "$CUR" = "none" ]; then
35
+ gh api "repos/${REPO}/pages" -X POST -f build_type=legacy -f 'source[branch]=gh-pages' -f 'source[path]=/' >/dev/null
36
+ elif [ "$CUR" != "gh-pages" ]; then
37
+ gh api "repos/${REPO}/pages" -X PUT -f build_type=legacy -f 'source[branch]=gh-pages' -f 'source[path]=/' >/dev/null
38
+ fi
39
+ echo "Pages: https://$(echo "$REPO" | tr '[:upper:]' '[:lower:]' | cut -d/ -f1).github.io/$(echo "$REPO" | cut -d/ -f2)/"
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ // Seeds canvas.excalidraw into R2 so Pages + API share state. No-op without creds.
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ const root = path.resolve(process.cwd(), '../..');
6
+ const sceneFile = path.join(root, 'canvas.excalidraw');
7
+ if (!fs.existsSync(sceneFile)) { console.log('no canvas.excalidraw, skipping'); process.exit(0); }
8
+ if (!process.env.CLOUDFLARER2TOKEN && !process.env.R2_ACCESS_KEY_ID) { console.log('no R2 creds, skipping'); process.exit(0); }
9
+ console.log('R2 seed: credentials present; server lazy-loads/persists at runtime. OK');
@@ -0,0 +1,303 @@
1
+ ---
2
+ name: excalidraw-skill
3
+ description: Programmatic canvas toolkit for creating, editing, and refining Excalidraw diagrams via MCP tools with real-time canvas sync. Use when an agent needs to (1) draw or lay out diagrams on a live canvas, (2) iteratively refine diagrams using describe_scene and get_canvas_screenshot to see its own work, (3) export/import .excalidraw files or PNG/SVG images, (4) save/restore canvas snapshots, (5) convert Mermaid to Excalidraw, or (6) perform element-level CRUD, alignment, distribution, grouping, duplication, and locking. Requires a running canvas server (EXPRESS_SERVER_URL, default http://127.0.0.1:3000).
4
+ ---
5
+
6
+ # Excalidraw Skill
7
+
8
+ ## Step 0: Determine Connection Mode
9
+
10
+ Two modes are available. Try MCP first — it has more capabilities.
11
+
12
+ **MCP mode** (preferred): If `excalidraw/batch_create_elements` and other `excalidraw/*` tools appear in your tool list, use them directly. MCP tools handle label and arrow binding format automatically.
13
+
14
+ **REST API mode** (fallback): If MCP tools aren't available, use HTTP endpoints at `http://127.0.0.1:3000`. See the cheatsheet for REST payloads. Note the format differences in the table below — REST and MCP accept slightly different field names.
15
+
16
+ **Neither works?** Tell the user:
17
+ > The Excalidraw canvas server is not running. To set up:
18
+ > 1. `git clone https://github.com/yctimlin/mcp_excalidraw && cd mcp_excalidraw`
19
+ > 2. `npm ci && npm run build`
20
+ > 3. `PORT=3000 npm run canvas`
21
+ > 4. Open `http://127.0.0.1:3000` in a browser
22
+ > 5. (Recommended) Install the MCP server:
23
+ > `claude mcp add excalidraw -s user -e EXPRESS_SERVER_URL=http://127.0.0.1:3000 -- node /path/to/mcp_excalidraw/dist/index.js`
24
+
25
+ ### MCP vs REST API Quick Reference
26
+
27
+ | Operation | MCP Tool | REST API Equivalent |
28
+ |-----------|----------|-------------------|
29
+ | Create elements | `batch_create_elements` | `POST /api/elements/batch` |
30
+ | Get all elements | `query_elements` | `GET /api/elements` |
31
+ | Get one element | `get_element` | `GET /api/elements/:id` |
32
+ | Update element | `update_element` | `PUT /api/elements/:id` |
33
+ | Delete element | `delete_element` | `DELETE /api/elements/:id` |
34
+ | Clear canvas | `clear_canvas` | `DELETE /api/elements/clear` |
35
+ | Describe scene | `describe_scene` | `GET /api/elements` (parse manually) |
36
+ | Export scene | `export_scene` | `GET /api/elements` (save to file) |
37
+ | Import scene | `import_scene` | `POST /api/elements/sync` |
38
+ | Snapshot | `snapshot_scene` | `POST /api/snapshots` |
39
+ | Restore snapshot | `restore_snapshot` | `GET /api/snapshots/:name` then `POST /api/elements/sync` |
40
+ | Screenshot | `get_canvas_screenshot` | `POST /api/export/image` (needs browser) |
41
+ | Viewport | `set_viewport` | `POST /api/viewport` (needs browser) |
42
+ | Export image | `export_to_image` | `POST /api/export/image` (needs browser) |
43
+ | Export URL | `export_to_excalidraw_url` | Only via MCP |
44
+
45
+ ### Format Differences Between Modes (Critical)
46
+
47
+ 1. **Labels**: MCP accepts `"text": "My Label"` on shapes (auto-converts). REST requires `"label": {"text": "My Label"}`.
48
+ 2. **Arrow binding**: MCP accepts `startElementId`/`endElementId`. REST requires `"start": {"id": "..."}` / `"end": {"id": "..."}`.
49
+ 3. **fontFamily**: Must be a string (e.g. `"1"`) or omit entirely. Never pass a number.
50
+ 4. **Updating labels via REST**: Re-include `"label"` in the PUT body to ensure it renders correctly after updates.
51
+
52
+ ---
53
+
54
+ ## Coordinate System
55
+
56
+ The canvas uses a 2D coordinate grid: **(0, 0) is the origin**, **x increases rightward**, **y increases downward**. Plan your layout before writing any JSON.
57
+
58
+ **General spacing guidelines:**
59
+ - Vertical spacing between tiers: 80–120px (enough that arrows don't crowd labels)
60
+ - Horizontal spacing between siblings: 40–60px minimum
61
+ - Shape width: `max(160, labelCharCount * 9)` to prevent text truncation
62
+ - Shape height: 60px single-line, 80px two-line labels
63
+ - Background/zone padding: 50px on all sides around contained elements
64
+
65
+ ---
66
+
67
+ ## Layout Anti-Patterns (Critical for Complex Diagrams)
68
+
69
+ These are the most common mistakes that produce unreadable diagrams. Avoid all of them.
70
+
71
+ ### 1. Do NOT use `label.text` (or `text`) on large background zone rectangles
72
+
73
+ When you put a label on a background rectangle, Excalidraw creates a bound text element centered in the middle of that shape — right where your service boxes will be placed. The text overlaps everything inside the zone and cannot be repositioned.
74
+
75
+ **Wrong:**
76
+ ```json
77
+ {"id": "vpc-zone", "type": "rectangle", "x": 50, "y": 50, "width": 800, "height": 400, "text": "VPC (10.0.0.0/16)"}
78
+ ```
79
+
80
+ **Right — use a free-standing text element anchored at the top of the zone:**
81
+ ```json
82
+ {"id": "vpc-zone", "type": "rectangle", "x": 50, "y": 50, "width": 800, "height": 400, "backgroundColor": "#e3f2fd"},
83
+ {"id": "vpc-label", "type": "text", "x": 70, "y": 60, "width": 300, "height": 30, "text": "VPC (10.0.0.0/16)", "fontSize": 18, "fontWeight": "bold"}
84
+ ```
85
+
86
+ The free-standing text element sits at the top corner of the zone and doesn't interfere with elements placed inside.
87
+
88
+ ### 2. Avoid cross-zone arrows in complex diagrams
89
+
90
+ An arrow from an element in one layout zone to an element in a distant zone will draw a long diagonal line crossing through everything in between. In a multi-zone infra diagram this produces an unreadable tangle of spaghetti.
91
+
92
+ **Design rule:** Keep arrows within the same zone or tier. To show cross-zone relationships, use annotation text or separate the zones so their edges are adjacent (no elements between them), and route the arrow along the edge.
93
+
94
+ If you must connect across zones, use an elbowed arrow that travels along the perimeter — never through the middle of another zone.
95
+
96
+ ### 3. Use arrow labels sparingly
97
+
98
+ Arrow labels are placed at the midpoint of the arrow. On short arrows, they overlap the shapes at both ends. On crowded diagrams, they collide with nearby elements.
99
+
100
+ - Only add an arrow label when the relationship name is genuinely essential (e.g., protocol, port number, data direction).
101
+ - If you're adding a label to every arrow, reconsider — it usually adds visual noise, not clarity.
102
+ - Keep arrow labels to ≤ 12 characters. Prefer omitting them entirely on dense diagrams.
103
+
104
+ ---
105
+
106
+ ## Quality: Why It Matters (and How to Check)
107
+
108
+ Excalidraw diagrams are visual communication. If text is cut off, elements overlap, or arrows cross through unrelated shapes, the diagram becomes confusing and unprofessional — it defeats the whole purpose of drawing it. So after every batch of elements, verify before adding more.
109
+
110
+ ### Quality Checklist
111
+
112
+ After each `batch_create_elements` / `POST /api/elements/batch`, take a screenshot and check:
113
+
114
+ 1. **Text truncation** — Is all label text fully visible? Truncated text means the shape is too small. Increase `width` and/or `height`.
115
+ 2. **Overlap** — Do any shapes share the same space? Background zones must fully contain children with padding.
116
+ 3. **Arrow crossing** — Do arrows cut through unrelated elements? If yes, route them around using curved or elbowed arrows (see Arrow Routing below).
117
+ 4. **Arrow-label overlap** — Arrow labels sit at the midpoint. If they overlap a shape, shorten the label or adjust the arrow path.
118
+ 5. **Spacing** — At least 40px gap between elements. Cramped layouts are hard to read.
119
+ 6. **Readability** — Font size ≥ 16 for body text, ≥ 20 for titles.
120
+ 7. **Zone label placement** — If you used `text`/`label.text` on a background zone rectangle, the zone label will be centered in the middle of the zone, overlapping everything inside. Fix: delete the bound text element and add a free-standing text element at the top of the zone instead (see Layout Anti-Patterns above).
121
+
122
+ If you find any issue: **stop, fix it, re-screenshot, then continue.** Say "I see [issue], fixing it" rather than glossing over problems. Only proceed once all checks pass.
123
+
124
+ ---
125
+
126
+ ## Workflow: Drawing a New Diagram
127
+
128
+ ### Mermaid vs. Direct Creation — Which to Use?
129
+
130
+ **Use `create_from_mermaid`** when: the user already has a Mermaid diagram, or the structure maps cleanly to a flowchart/sequence/ER diagram with standard Mermaid syntax. It's fast and handles conversion automatically, though you get less control over exact layout.
131
+
132
+ **Use `batch_create_elements` directly** when: you need precise layout control, the diagram type doesn't map to Mermaid well (e.g., custom architecture, annotated cloud diagrams), or you want elements positioned in a specific coordinate grid.
133
+
134
+ ### MCP Mode
135
+
136
+ 1. Call `read_diagram_guide` for design best practices (colors, fonts, anti-patterns).
137
+ 2. Plan your coordinate grid on paper/in comments — map out tiers and x-positions before writing JSON.
138
+ 3. Optional: `clear_canvas` to start fresh.
139
+ 4. Use `batch_create_elements` — create shapes and arrows in one call. Custom `id` fields (e.g. `"id": "auth-svc"`) make later updates easy.
140
+ 5. Set shape widths using `max(160, labelLength * 9)`. Use `text` field for labels.
141
+ 6. Bind arrows with `startElementId` / `endElementId` — they auto-route to element edges.
142
+ 7. `set_viewport` with `scrollToContent: true` to auto-fit.
143
+ 8. `get_canvas_screenshot` → run Quality Checklist → fix issues before next iteration.
144
+
145
+ **MCP element + arrow example:**
146
+ ```json
147
+ {"elements": [
148
+ {"id": "lb", "type": "rectangle", "x": 300, "y": 50, "width": 180, "height": 60, "text": "Load Balancer"},
149
+ {"id": "svc-a", "type": "rectangle", "x": 100, "y": 200, "width": 160, "height": 60, "text": "Web Server 1"},
150
+ {"id": "svc-b", "type": "rectangle", "x": 450, "y": 200, "width": 160, "height": 60, "text": "Web Server 2"},
151
+ {"id": "db", "type": "rectangle", "x": 275, "y": 350, "width": 210, "height": 60, "text": "PostgreSQL"},
152
+ {"type": "arrow", "x": 0, "y": 0, "startElementId": "lb", "endElementId": "svc-a"},
153
+ {"type": "arrow", "x": 0, "y": 0, "startElementId": "lb", "endElementId": "svc-b"},
154
+ {"type": "arrow", "x": 0, "y": 0, "startElementId": "svc-a", "endElementId": "db"},
155
+ {"type": "arrow", "x": 0, "y": 0, "startElementId": "svc-b", "endElementId": "db"}
156
+ ]}
157
+ ```
158
+
159
+ ### REST API Mode
160
+
161
+ 1. Plan your coordinate grid first.
162
+ 2. Optional: `curl -X DELETE http://127.0.0.1:3000/api/elements/clear`
163
+ 3. Create elements using `POST /api/elements/batch`. Use `"label": {"text": "..."}` for labels.
164
+ 4. Bind arrows with `"start": {"id": "..."}` / `"end": {"id": "..."}`.
165
+ 5. Verify with `POST /api/export/image` → save PNG → run Quality Checklist.
166
+
167
+ **REST API element + arrow example:**
168
+ ```bash
169
+ curl -X POST http://127.0.0.1:3000/api/elements/batch \
170
+ -H "Content-Type: application/json" \
171
+ -d '{
172
+ "elements": [
173
+ {"id": "svc-a", "type": "rectangle", "x": 100, "y": 100, "width": 160, "height": 60, "label": {"text": "Service A"}},
174
+ {"id": "svc-b", "type": "rectangle", "x": 400, "y": 100, "width": 160, "height": 60, "label": {"text": "Service B"}},
175
+ {"type": "arrow", "x": 0, "y": 0, "start": {"id": "svc-a"}, "end": {"id": "svc-b"}, "label": {"text": "calls"}}
176
+ ]
177
+ }'
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Arrow Routing — Avoid Overlaps
183
+
184
+ Straight arrows can cross through elements in complex diagrams. Use curved or elbowed arrows when needed:
185
+
186
+ **Curved arrows** (smooth arc over obstacles):
187
+ ```json
188
+ {
189
+ "type": "arrow", "x": 100, "y": 100,
190
+ "points": [[0, 0], [50, -40], [200, 0]],
191
+ "roundness": {"type": 2}
192
+ }
193
+ ```
194
+ The intermediate waypoint `[50, -40]` lifts the arrow upward. `roundness: {type: 2}` makes it smooth.
195
+
196
+ **Elbowed arrows** (right-angle / L-shaped routing):
197
+ ```json
198
+ {
199
+ "type": "arrow", "x": 100, "y": 100,
200
+ "points": [[0, 0], [0, -50], [200, -50], [200, 0]],
201
+ "elbowed": true
202
+ }
203
+ ```
204
+
205
+ **When to use which:**
206
+ - Fan-out (one source → many targets): curved arrows with waypoints spread to avoid overlapping
207
+ - Cross-lane (connecting to side panels): elbowed arrows that go up, then across, then down
208
+ - Long horizontal connections: curved arrows with a slight vertical offset
209
+
210
+ **Rule:** If an arrow would pass through an unrelated shape, add a waypoint to route around it.
211
+
212
+ **Points format**: Both `[[x, y], ...]` tuples and `[{"x": ..., "y": ...}]` objects are accepted; both are normalized automatically.
213
+
214
+ ---
215
+
216
+ ## Workflow: Iterative Refinement
217
+
218
+ Using `describe_scene` and `get_canvas_screenshot` together is what makes this skill powerful.
219
+
220
+ - **`describe_scene`** → returns structured text: element IDs, types, positions, labels, connections. Use this when you need to know *what's on the canvas* before making programmatic updates (find IDs, understand bounding boxes).
221
+ - **`get_canvas_screenshot`** → returns a PNG image of the actual rendered canvas. Use this for *visual quality verification* — it shows you exactly what the user sees, including truncation, overlap, and arrow routing.
222
+
223
+ **Feedback loop (MCP):**
224
+ ```
225
+ batch_create_elements
226
+ → get_canvas_screenshot → "text truncated on auth-svc"
227
+ → update_element (increase width) → get_canvas_screenshot → "overlap between auth-svc and rate-limiter"
228
+ → update_element (reposition) → get_canvas_screenshot → "all checks pass"
229
+ → proceed
230
+ ```
231
+
232
+ **Feedback loop (REST):**
233
+ ```
234
+ POST /api/elements/batch
235
+ → POST /api/export/image → save PNG → evaluate
236
+ → PUT /api/elements/:id (fix issues) → re-screenshot → evaluate
237
+ → proceed
238
+ ```
239
+
240
+ ---
241
+
242
+ ## Workflow: Refine an Existing Diagram
243
+
244
+ 1. `describe_scene` to understand current state — note element IDs and positions.
245
+ 2. Identify elements by `id` or label text (not by x/y coordinates — they change).
246
+ 3. `update_element` to resize/recolor/move; `delete_element` to remove.
247
+ 4. `get_canvas_screenshot` to confirm the change looks right.
248
+ 5. If updates fail: check the ID exists with `get_element`; check it's not locked with `unlock_elements`.
249
+
250
+ ---
251
+
252
+ ## Workflow: Mermaid Conversion
253
+
254
+ For converting existing Mermaid diagrams to Excalidraw:
255
+
256
+ **MCP mode:**
257
+ ```
258
+ create_from_mermaid(mermaidDiagram: "graph TD\n A --> B\n B --> C")
259
+ ```
260
+ After conversion, call `set_viewport` with `scrollToContent: true` and `get_canvas_screenshot` to verify layout. If the auto-layout is poor (nodes crowded, edges crossing), identify problem elements with `describe_scene` and reposition with `update_element`.
261
+
262
+ **REST mode:**
263
+ ```bash
264
+ curl -X POST http://127.0.0.1:3000/api/elements/from-mermaid \
265
+ -H "Content-Type: application/json" \
266
+ -d '{"mermaid": "graph TD\n A --> B\n B --> C"}'
267
+ ```
268
+
269
+ ---
270
+
271
+ ## Workflow: File I/O
272
+
273
+ - Export to `.excalidraw`: `export_scene` with optional `filePath`
274
+ - Import from `.excalidraw`: `import_scene` with `mode: "replace"` or `"merge"`
275
+ - Export to image: `export_to_image` with `format: "png"` or `"svg"` (requires browser open)
276
+ - Share link: `export_to_excalidraw_url` — encrypts scene, returns shareable excalidraw.com URL
277
+ - CLI export: `node scripts/export-elements.cjs --out diagram.elements.json`
278
+ - CLI import: `node scripts/import-elements.cjs --in diagram.elements.json --mode batch|sync`
279
+
280
+ ## Workflow: Snapshots
281
+
282
+ 1. `snapshot_scene` with a name before risky changes.
283
+ 2. Make changes, evaluate with `describe_scene` / `get_canvas_screenshot`.
284
+ 3. `restore_snapshot` to roll back if needed.
285
+
286
+ ## Workflow: Duplication
287
+
288
+ `duplicate_elements` with `elementIds` and optional `offsetX`/`offsetY` (default: 20, 20). Useful for repeated patterns or copying layouts.
289
+
290
+ ## Error Recovery
291
+
292
+ - **Elements not appearing?** Check `describe_scene` — they may have been created off-screen. Use `set_viewport` with `scrollToContent: true`.
293
+ - **Arrow not connecting?** Verify element IDs with `get_element`. Make sure `startElementId`/`endElementId` (MCP) or `start.id`/`end.id` (REST) match existing element IDs.
294
+ - **Canvas in a bad state?** `snapshot_scene` first, then `clear_canvas` and rebuild. Or `restore_snapshot` to go back.
295
+ - **Element won't update?** It may be locked — call `unlock_elements` first.
296
+ - **Layout looking wrong after import?** Use `describe_scene` to inspect actual positions, then batch-update positions.
297
+ - **Duplicate text elements / element count doubling?** The frontend has an auto-sync timer that periodically sends the full Excalidraw scene back to the server (overwriting). Excalidraw internally generates a bound text element for every shape that has `label.text`. If you clear and re-send elements, Excalidraw may re-inject its cached bound texts, causing duplicates. To clean up: (1) use `query_elements` / `GET /api/elements` to find elements of `type: "text"` with a `containerId`; (2) delete the unwanted ones with `delete_element`; (3) wait a few seconds for auto-sync to settle before exporting. The safest approach is to **never put labels on background zone rectangles** — use free-standing text elements instead.
298
+
299
+ ---
300
+
301
+ ## References
302
+
303
+ - `references/cheatsheet.md`: Complete MCP tool list (26 tools) + REST API endpoints + payload shapes.
@@ -0,0 +1,23 @@
1
+ {
2
+ "skill_name": "excalidraw-skill",
3
+ "evals": [
4
+ {
5
+ "id": 0,
6
+ "prompt": "Draw a CI/CD pipeline architecture diagram on the Excalidraw canvas with these components: GitHub (source), GitHub Actions (CI), Docker Registry (artifact store), and Kubernetes Cluster (deployment target). Use arrows to show the flow from left to right. Make sure labels fit inside each box and nothing overlaps.",
7
+ "expected_output": "A clean diagram with 4 labeled boxes, left-to-right flow arrows connecting them, no overlapping elements, and all text fully visible inside shapes.",
8
+ "files": []
9
+ },
10
+ {
11
+ "id": 1,
12
+ "prompt": "Convert this Mermaid flowchart to an Excalidraw diagram:\n```\ngraph TD\n A[User] -->|HTTP Request| B[Load Balancer]\n B --> C[Web Server 1]\n B --> D[Web Server 2]\n C --> E[(Database)]\n D --> E\n```\nAfter converting, take a screenshot and verify the layout looks clean.",
13
+ "expected_output": "A valid Excalidraw diagram with all 5 nodes and arrows matching the Mermaid structure, verified with a screenshot.",
14
+ "files": []
15
+ },
16
+ {
17
+ "id": 2,
18
+ "prompt": "Create a simple diagram on the Excalidraw canvas with two rectangles: 'Auth Service' and 'User DB', connected by an arrow labeled 'queries'. Then refine it: add a third box 'Redis Cache' positioned between the two services, connect Auth Service to Redis Cache with a 'cache hit' arrow. Verify visually that all labels are visible and no arrows cross awkwardly.",
19
+ "expected_output": "A 3-element diagram with Auth Service → Redis Cache → (and both connected back to) User DB, with clean arrows, visible labels, and a screenshot confirming the final state.",
20
+ "files": []
21
+ }
22
+ ]
23
+ }