omp packages

@senad-d/drawme0.3.0

Pi extension for authoring, validating, and exporting editable draw.io diagrams from natural-language descriptions.

GitHub Actions Published 1 day ago MIT ~1.1K downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

DrawMe icon

pi package npm CI Quality Gate Status license

Natural-language diagrams for pi.
Turns a description into editable .drawio XML and exports it to PNG / SVG / PDF / JPG, including verified standalone animated SVG, with local rendering.


DrawMe is a native Pi extension for diagram authoring. Describe a diagram and Pi plans it, writes editable .drawio XML (or Mermaid when the CLI supports conversion), lints every source revision, critiques the rendered preview when the active model can view images, and exports the final deliverable — fully autonomously, with no human intervention once started.

Privacy: DrawMe renders diagrams locally. Your request, project source that Pi reads during authoring, and any attached preview or storyboard images may enter Pi's model context and be sent to your configured hosted model provider. A text-only model, or one whose image support is unknown, gets no image attachment.

DrawMe
DrawMe user flow: author, validate, review in four passes, correct, and export, with CLI and vision fallbacks
Install DrawMe: prerequisites, personal/project/one-invocation scope, CLI check, and first request
  • Natural-language authoring: flowcharts, architecture, UML, BPMN, ERD, C4, network, ML — as native .drawio, or as Mermaid with automatic layout on supported renderers.
  • Guided workflow: CLI detection, planning, authoring, validation, a gated multi-pass visual review (fit/sizing → element placement → connections → holistic confirmation), and final export run end to end from a single /drawme — no approval pauses.
  • Deterministic validation: a structural linter catches dangling edges, duplicate/reserved ids, malformed geometry, page/container overflow, inadequate margins, conservative readability defects, overlaps, and explicit edge-routing defects before you look at a pixel.
  • Vision-aware previews: verified PNG previews attach an image only when the active model can view it. Otherwise, review is structural. An image in the transcript is not a promise that its preview file remains on disk.
  • Exact shapes, not guesses: search 10k+ official AWS/Azure/GCP/Cisco/Kubernetes/UML/BPMN styles from a bundled local index.
  • Animated SVG: pop/slide entrances, connector draw-in, travelling dots, highlights, staggered cascades, persistent connector flow, and portable page sequences export as verified standalone SVG animation, with a storyboard, reduced-motion handling, and a static PNG fallback.
  • Editable source of truth: final PNG/SVG/PDF exports embed the diagram XML by default (JPG never does). DrawMe can repair an otherwise valid PNG with a truncated end chunk.

Security: Pi packages run with your full system permissions. DrawMe reads and writes diagram files and can launch the draw.io CLI or your OS file opener. Review SECURITY.md before installation.

Table of Contents


Implementation Status

This checkout implements the DrawMe core loop as a Pi extension:

  • Ten model-callable tools (drawio_check, drawio_export, drawio_animate, drawio_validate, drawio_fit_canvas, drawio_shapesearch, drawio_from_mermaid, drawio_layout, drawio_explain, drawio_open) and three commands (/drawme, /drawme-check, /drawme-export).
  • A guided /drawme workflow that steers authoring, validation after every edit, a gated multi-pass visual review, and autonomous final multi-format export.
  • Pure-TypeScript structural linting, -e PNG IEND repair, shape search over a bundled index, and diagram-to-Markdown description — no Python runtime required.
  • Native draw.io binary resolution across macOS/Linux/Windows/WSL, headless-Linux xvfb-run handling, and version-gated Mermaid conversion and ELK auto-layout.
  • Development gate: golden asset check, lint (including type and format checks), tests, and package contents check.

Extension Reference

docs/reference.md catalogs the extension's public surface — every command, tool option, default, output behavior, and functional limitation — for other projects and integrations that use DrawMe. It is documentation, not runtime input: the /drawme workflow and the registered tool descriptions carry the complete operational instructions themselves.

Quick Start

1) Install the draw.io desktop CLI

brew install --cask drawio            # macOS
# others: https://github.com/jgraph/drawio-desktop/releases  (Linux: prefer the .deb/.rpm, not snap)
drawio --version

2) Install the extension

cd /path/to/your/project
pi install npm:@senad-d/drawme

3) Start Pi and check the CLI

pi

Inside Pi:

/drawme-check

4) Draw something

/drawme a flowchart of a user login: enter credentials, validate, then success or retry

Pi checks the CLI, plans and writes the .drawio, validates every revision, critiques the rendered preview when the active model can view images (or reviews structurally when it cannot), and exports the final editable deliverable — all in one run, without asking for approval along the way.

Run from a source checkout

git clone https://github.com/senad-d/DrawMe.git
cd DrawMe
npm ci --ignore-scripts
npm run validate
pi --no-extensions -e .

Installation

Scope Command Notes
Global pi install npm:@senad-d/drawme Loads in every trusted Pi project.
Project-local pi install npm:@senad-d/drawme -l Writes to .pi/settings.json in the current project.
One run pi -e npm:@senad-d/drawme Try without changing settings.
Git pi install git:github.com/senad-d/DrawMe Install from Git; pin a tag or commit for a fixed version.
Local checkout pi --no-extensions -e . Develop or test this repository.

Commands

Command Description
/drawme <description> Kick off authoring, per-edit validation, the gated multi-pass visual review, and autonomous final export.
/drawme-check Report the detected CLI path, version, and Mermaid import and --layout support, or explain why the CLI is unavailable.
/drawme-export <file> [png|svg|animated-svg|pdf|jpg] One-shot final export of an existing .drawio. animated-svg verifies native connector flow or a portable native page sequence. For stored DrawMe motion, use drawio_animate with input and omit steps.

Tools

Registered for the model to call directly.

Tool Purpose
drawio_check Resolve the draw.io binary, version, and whether it supports Mermaid import and --layout.
drawio_export Export a .drawio to PNG/SVG/PDF/JPG. animated:true requires a final SVG, preserves connector flow, compiles portable page sequences, and verifies that the result actually contains animation. mode:"preview" gives a static, unembedded review PNG that fits within 2000px on both axes, with an image attachment when eligible. mode:"final" gives the deliverable (editable by default for PNG/SVG/PDF). See the export reference for sizing, naming, and cleanup rules.
drawio_animate Add motion to an existing page (pop and slide entrances, connector draw-in, travelling dots, highlights, dimming, staggered cascades) from typed steps, store it on the page, and export a verified animated SVG plus a storyboard PNG sampled from visual batch end states.
drawio_validate Deterministic lint for XML structure, geometry, page/container bounds, margins, overlap, explicit route-through/crossings, anchors facing away from their route, edge-label collisions, labels on connector lines, small fonts, and unchecked auto-routes. Likely direct-path obstructions for auto-routed edges are preview-review observations. The readability score reports route-through, crossings, overlaps, and anchors separately.
drawio_fit_canvas Fit each page's canvas to its content plus a margin (default 40px): grows cramped pages, tightens oversized ones, and shifts content to the margin origin — instead of shrinking or cramming elements. Deterministic, no CLI.
drawio_shapesearch Exact official style= strings for 10k+ AWS/Azure/GCP/Cisco/Kubernetes/UML/BPMN shapes, from a bundled local index. Use instead of guessing a style.
drawio_from_mermaid Convert exactly one Mermaid source (inline text or a .mmd file) to a native .drawio with automatic layout. Requires draw.io 30.2.4 or newer.
drawio_layout Re-place nodes / route edges with an ELK preset (verticalFlow, horizontalFlow, verticalTree, horizontalTree, radialTree, organic) for large graphs. Requires draw.io 30.2.4 or newer.
drawio_explain Describe an existing .drawio as structured Markdown (components by container, relations) — for READMEs/PR summaries or model read-back.
drawio_open Open a .drawio/export in the OS default app (draw.io desktop) for fine-tuning.

Architecture

DrawMe architecture: Pi turns a plain-language prompt into editable .drawio source. The DrawMe extension validates the diagram and uses draw.io Desktop to render shareable files locally.

Editable draw.io source

The extension factory in src/index.ts registers the tools and commands. Rendering, conversion, and layout launch the draw.io CLI on demand with an argument list rather than a shell; validation, shape search, and explanation run directly in the extension.

The /drawme Workflow

/drawme injects a guided nine-step workflow that the model follows using the tools above:

  1. Check — the command resolves the CLI and sends one follow-up with the result, including conversion and layout support, and the packaged authoring references. Pi need not reread references already in the message; they do not contain project source.
  2. Plan — honor the requested view or choose one using the reader's question. For an existing implementation, read the relevant source before drawing and record the source location for each claim. Plan only a meaningful supported subset, note omissions, and explain what is missing instead of drawing if no useful subset is supported. For a conceptual diagram, work from the description without unrelated file reads. Motion requests plan an animated SVG plus a static fallback.
  3. Author — write editable uncompressed XML, or use supported Mermaid conversion or ELK layout when it preserves the chosen composition. Fit the finite canvas after authoring, conversion, or layout. Animation may use stored DrawMe motion, persistent connector flow, or portable native page sequences.
  4. Validate after every edit — fix all errors; fix each warning or record why it is reviewed and acceptable. An incomplete report is not clean. Malformed animation, dangling targets, invalid timing, and standalone-SVG-incompatible effects are diagnosed before export.
  5. Visual review in gated passes — with the preview image attached (one preview per page for multi-page files), the model runs three focused passes, each answering explicit questions on its own preview: fit and sizing (does the diagram fit its page; does the canvas or an element need resizing), element placement (is every element positioned correctly; is there a visibly better arrangement), and connections (is every connection correct, cleanly routed, symmetric where the layout is symmetric, and anchored to the middle of the facing element side where possible). A fourth holistic pass reads every label word for word, checks contrast, semantics, and the diagram type's own review checklist, and re-checks the earlier passes for regressions. Concrete defects to hunt (overlapping or clipped text, labels struck through by lines, floating endpoints, edges through unrelated shapes, …) are spelled out per pass, and each finding lands in a numbered ledger naming the affected cells and planned fix. Without an image, use validation and drawio_explain, then inspect the editable XML for relevant facts the explanation omits; report anything the file cannot establish without claiming visual review. On either path, compare implementation claims with the source before final export. Correct or remove unsupported claims and re-check affected claims after edits; if no validated version passes this check, report the limitation without delivering an implementation diagram, even at the correction limit.
  6. Fix and verify before the next pass — make a targeted edit and validate it. For visual findings, inspect a replacement preview; compare it with a prior image only when the tool reports a comparable attachment for that page. Without an image, repeat the structural checks instead. Record each verdict (fixed / not fixed / regressed). Start the next pass only when the current findings are fixed or explicitly accepted, except at the correction limit.
  7. Bound corrections — inspection previews do not count as retries. Allow at most eight edit → validation → verification cycles across the review. At the limit, stop editing, finish the remaining passes as inspection-only, and report each unresolved finding, its pass, and its last verdict.
  8. No human gate — the run never pauses for approval or feedback; if the user interrupts with feedback, it is handled as new critique findings and the run continues.
  9. Final export — after review, export the requested formats when supported (each page of a multi-page file separately). Without a renderer, deliver validated editable XML and report that no preview or final export was produced. Use drawio_animate for DrawMe motion or animated:true for native motion, and normally include a static PNG fallback. The final reply reports deliverables, animation verification, unresolved findings, and preview cleanup warnings. For an implementation view, it also names key source locations and relevant gaps.

Review each page, but don't count on keeping a file per page: a successful preview or final export may retire tracked previews for the same source, including other pages. DrawMe does not reconstruct preview tracking after restart. Transcript attachments are separate from files; see preview behavior.

Deterministic checks cover XML contracts, IDs/references, finite page and container bounds, outer margins, overlaps, explicit waypoint routes, edge-label placement, conservative font/wrapping cases, and pinned anchors that face away from their adjacent waypoint or auto-routed peer. Auto-routed edges remain renderer-dependent: validation warns that their route is unchecked and adds a focused observation when the direct connection line pierces a shape, but the preview remains the final arbiter. Rendered clipping and wrapping, contrast, typography at full-diagram scale, visual balance, and draw.io's automatic connector routes need rendered inspection, so the model critiques them only if a preview image is attached and reports them as unverified otherwise. Vision's job in the loop is to narrow every rendered defect down to specific cells (the authoring reference maps each defect to a source fix) and then to confirm from the replacement image that the defect is actually gone. A 2000px preview that makes labels unreadable requires a tighter/simpler layout, page splitting, or a focused re-export — it must never be accepted as-is.

Bundled References and Assets

These stay plain Markdown files for easy editing. /drawme embeds the diagram-types, XML-authoring, style presets, and (when conversion is supported) Mermaid references directly into its workflow message, so the model starts with them in context; the troubleshooting reference is read on demand when an export fails.

  • docs/reference.md — catalog of commands, tool options, defaults, output behavior, and limitations (documentation only; not read at runtime).
  • assets/references/xml-authoring.md — .drawio skeleton, cell/edge forms, containers, palette, spacing.
  • assets/references/diagram-types.md — purpose-led compositions and per-type notation presets.
  • assets/references/mermaid-authoring.md — Mermaid authoring for supported renderers.
  • assets/references/troubleshooting.md — export/render failure recovery.
  • assets/data/shape-index.json.gz — the vendored draw.io shape index behind drawio_shapesearch (see its notice).

Requirements and Compatibility

  • Node.js ≥ 22.19.
  • draw.io desktop CLI on PATH (or a known app path). On WSL, install a native Linux draw.io renderer inside WSL; the Windows executable is not supported there. See CLI discovery for custom installations.
  • draw.io 30.2.4 or newer for Mermaid conversion and ELK layout; 32.4.1 or newer for exports or animations that explicitly pass pageIndex. The indexed-export requirement does not apply when pageIndex is omitted.
  • Headless Linux: install Xvfb (xvfb-run) if no display is present. Run Pi as an unprivileged user; DrawMe refuses to run the renderer as root.

Security

DrawMe works with diagram files and may launch the draw.io CLI, xvfb-run on headless Linux, or the OS file opener. Pi extensions inherit the permissions of the Pi process, so install only packages you trust. See SECURITY.md for runtime and dependency details.

Examples

Editable sources and rendered examples live in example/. The showcase spans three presets: Multi-color for the user journey (blue authoring, purple quality, green delivery), Dark for the animated AWS architecture, and Light for the installation and reference diagrams. All use deliberate typography, native shapes, generous spacing, and explicitly routed connectors.

Example Editable source Render
Multi-color user journey, four review passes, and CLI/vision fallbacks Source PNG
Light installation guide: scopes, trust, CLI check, and first request Source PNG
Architecture and responsibilities of all ten tools Source PNG
Structural gates and bounded, pass-by-pass correction Source PNG
Dark AWS architecture: transactional outbox, SNS/SQS fan-out, consumers, and dead letters Source Animated SVG · PNG · Storyboard
Git branching and merges (classic, retained example) Source PNG

Animated example — Dark

Animated order processing: publish committed outbox events, fan out to fulfillment and notifications, then persist shipments and send email

This Dark-theme showcase uses 13 official AWS4 components across four zones, including API Gateway, Lambda, DynamoDB, SNS, SQS, and SES. Its verified standalone SVG demonstrates pop/slide entrances, connector draw-in, travelling dots, highlights, and staggered reveals in a 12.56-second loop. Reduced-motion viewers see the static diagram. If your SVG host sanitizes animation, use the PNG fallback. The storyboard shows sampled visual states, not temporal playback.

Development

npm ci --ignore-scripts   # install the locked dependency set
npm run validate          # golden check + lint + tests + package contents check

See the contributor guide for the full gate and asset-update conventions.

Individual checks:

npm run typecheck         # tsc --noEmit
npm run lint:eslint       # eslint . --max-warnings=0
npm run format:check      # LF endings, no trailing whitespace, final newline, valid JSON
npm run check:golden      # SHA-256 integrity of bundled assets (--update to re-baseline)
npm test                  # vitest run
npm run check:pack        # verify package contents
npm run coverage          # vitest run --coverage
pi --no-extensions -e .   # load this checkout in Pi

Source layout:

  • src/index.ts — registers the tools and commands.
  • src/drawio.ts — export orchestration and the facade for renderer, export policy, and editable import.
  • src/renderer.ts, src/export-plan.ts, src/editable-import.ts — CLI discovery and invocation, export planning, and Mermaid conversion/ELK layout.
  • src/animation.ts — native animation analysis, portable page-sequence compilation, reduced-motion CSS, and animated-SVG verification.
  • src/validate.ts — structural and animation linter.
  • src/shapesearch.ts — shape search over the bundled index.
  • src/explain.ts — diagram-to-Markdown describer.
  • src/dom.ts — shared xmldom helpers used by validate/explain.
  • src/png.ts — -e PNG IEND repair.
  • src/workflow.ts — the guidance /drawme injects.

Publishing

DrawMe publishes to npm as @senad-d/drawme through the Publish to npm workflow. Run it from the repository's exact default branch, not from a tag.

Before a release, a repository administrator must verify in GitHub settings that the npm environment uses Selected branches and tags with exactly one branch rule: the literal default branch name. Do not allow tag rules, wildcards, or other branches. The workflow's environment: npm declaration does not verify those settings.

License

MIT — see LICENSE.