Skip to content

dongzhigang13305312738-art/paper-skills / excalidraw-skill

excalidraw-skill

Verified

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://localhost:3000).

scripts/import-elements.cjs

View on GitHub
#!/usr/bin/env node
/* eslint-disable no-console */

const fs = require("node:fs");

const DEFAULT_URL = process.env.EXPRESS_SERVER_URL || "http://localhost:3000";

function usage() {
  console.error(
    [
      "Usage:",
      "  node scripts/import-elements.cjs --in <file> [--mode batch|sync] [--url <canvasUrl>]",
      "",
      "Modes:",
      "  batch  POST /api/elements/batch    (append; creates elements)",
      "  sync   POST /api/elements/sync     (overwrite; clears then writes)",
    ].join("\n"),
  );
  process.exit(2);
}

function parseArgs(argv) {
  const out = { url: DEFAULT_URL, inFile: null, mode: "batch" };
  for (let i = 0; i < argv.length; i++) {
    const a = argv[i];
    if (a === "--url") out.url = argv[++i];
    else if (a === "--in") out.inFile = argv[++i];
    else if (a === "--mode") out.mode = argv[++i];
  }
  return out;
}

function readElementsFromFile(inFile) {
  const raw = fs.readFileSync(inFile, "utf8");
  const data = JSON.parse(raw);
  if (Array.isArray(data)) return data;
  if (data && Array.isArray(data.elements)) return data.elements;
  throw new Error('Input file must be an array, or an object with an "elements" array');
}

async function main() {
  if (typeof fetch !== "function") {
    throw new Error("This script requires Node 18+ (global fetch).");
  }

  const { url, inFile, mode } = parseArgs(process.argv.slice(2));
  if (!inFile) usage();
  if (mode !== "batch" && mode !== "sync") usage();

  const elements = readElementsFromFile(inFile);
  const baseUrl = url.replace(/\/$/, "");

  let endpoint;
  let body;
  if (mode === "batch") {
    endpoint = `${baseUrl}/api/elements/batch`;
    body = { elements };
  } else {
    endpoint = `${baseUrl}/api/elements/sync`;
    body = { elements, timestamp: new Date().toISOString() };
  }

  const res = await fetch(endpoint, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(body),
  });

  const json = await res.json().catch(() => null);
  if (!res.ok || !json || json.success !== true) {
    throw new Error(`Failed to import elements: ${res.status} ${res.statusText} ${json?.error ? `- ${json.error}` : ""}`);
  }

  const count = json.count ?? json.elements?.length ?? elements.length;
  console.log(`Imported ${count} elements (${mode})`);
}

main().catch((err) => {
  console.error(err?.stack || String(err));
  process.exit(1);
});
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall