@senad-d/drawme 0.3.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -4,7 +4,11 @@ All notable changes to this project are documented here. The format is based on
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
5
5
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [Unreleased]
7
+ ## [0.4.0] - 2026-12-06
8
+
9
+ ### Added
10
+
11
+ - `drawio_guide` returns the packaged authoring guides to agents that start without `/drawme`.
8
12
 
9
13
  ### Changed
10
14
 
@@ -12,6 +16,7 @@ All notable changes to this project are documented here. The format is based on
12
16
 
13
17
  ### Fixed
14
18
 
19
+ - The Linux desktop opener invokes `/usr/bin/xdg-open` directly instead of resolving the launcher on `PATH`.
15
20
  - Explicit raster sizes are now subject to the 6,000,000-pixel budget, including the border. `drawio_export` exposes `width` only; `height` is internal. See the [export reference](docs/reference.md#drawio_export) for format-specific sizing.
16
21
 
17
22
  ## [0.3.0] - 2026-12-02
package/README.md CHANGED
@@ -51,6 +51,7 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
51
51
 
52
52
  - [Implementation Status](#implementation-status)
53
53
  - [Extension Reference](#extension-reference)
54
+ - [Diagram views](#diagram-views)
54
55
  - [Quick Start](#quick-start)
55
56
  - [Installation](#installation)
56
57
  - [Commands](#commands)
@@ -71,7 +72,7 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
71
72
 
72
73
  This checkout implements the DrawMe core loop as a Pi extension:
73
74
 
74
- - 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`).
75
+ - Eleven 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`, `drawio_guide`) and three commands (`/drawme`, `/drawme-check`, `/drawme-export`).
75
76
  - A guided `/drawme` workflow that steers authoring, validation after every edit, a gated multi-pass visual review, and autonomous final multi-format export.
76
77
  - Pure-TypeScript structural linting, `-e` PNG IEND repair, shape search over a bundled index, and diagram-to-Markdown description — no Python runtime required.
77
78
  - Native draw.io binary resolution across macOS/Linux/Windows/WSL, headless-Linux `xvfb-run` handling, and version-gated Mermaid conversion and ELK auto-layout.
@@ -81,6 +82,14 @@ This checkout implements the DrawMe core loop as a Pi extension:
81
82
 
82
83
  [`docs/reference.md`](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.
83
84
 
85
+ ## Diagram views
86
+
87
+ - **Architecture overview** — what each part does and how the parts interact.
88
+ - **Request/sequence flow** — what happens during one request, in order.
89
+ - **Data model** — which records exist and how they relate.
90
+ - **Deployment** — where the running parts live and how they connect.
91
+ - **User flow** — what a person can do and what they see next.
92
+
84
93
  ## Quick Start
85
94
 
86
95
  ### 1) Install the draw.io desktop CLI
@@ -162,6 +171,7 @@ Registered for the model to call directly.
162
171
  | `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**. |
163
172
  | `drawio_explain` | Describe an existing `.drawio` as structured Markdown (components by container, relations) — for READMEs/PR summaries or model read-back. |
164
173
  | `drawio_open` | Open a `.drawio`/export in the OS default app (draw.io desktop) for fine-tuning. |
174
+ | `drawio_guide` | Return the packaged authoring guides `/drawme` pre-loads (diagram types, XML authoring, style presets, Mermaid authoring, troubleshooting), for agents that author without the command. |
165
175
 
166
176
  ## Architecture
167
177
 
package/docs/reference.md CHANGED
@@ -18,6 +18,7 @@ Always read the result text. These prefixes indicate failure even if the tool ca
18
18
  | `drawio_shapesearch` | No | No |
19
19
  | `drawio_explain` | No | No |
20
20
  | `drawio_open` | No CLI check; requires an OS file handler | No |
21
+ | `drawio_guide` | No | No |
21
22
  | `drawio_export` | Yes | No |
22
23
  | `drawio_animate` | Yes | No |
23
24
  | `drawio_from_mermaid` | Yes | Yes |
@@ -472,7 +473,7 @@ Platform behavior:
472
473
 
473
474
  - macOS: `open`;
474
475
  - Windows: the system file-association helper, without `cmd.exe`;
475
- - Linux: `xdg-open`.
476
+ - Linux: `/usr/bin/xdg-open` (requires the system `xdg-utils` package; does not look up the launcher on `PATH`).
476
477
 
477
478
  Use it when the user requests desktop review or accepts an offer to fine-tune the source manually. Opening a document is a user-visible side effect.
478
479
 
@@ -480,6 +481,24 @@ Use it when the user requests desktop review or accepts an offer to fine-tune th
480
481
  drawio_open({ "path": "architecture.drawio" })
481
482
  ```
482
483
 
484
+ ---
485
+
486
+ ### `drawio_guide`
487
+
488
+ Returns the packaged authoring guides as Markdown, the same files `/drawme` pre-loads. Use it when a run starts without `/drawme`, such as an agent given its task by another program.
489
+
490
+ #### Options
491
+
492
+ | Option | Type | Required | Description |
493
+ | --- | --- | --- | --- |
494
+ | `topics` | string[] | Yes | One or more of `diagram-types`, `xml-authoring`, `style-presets`, `mermaid-authoring`, `troubleshooting`. Repeated topics are returned once. |
495
+
496
+ Each guide starts with a `# Guide: <topic>` heading. A guide that cannot be read is reported in its section as `Guide failed:` with the path.
497
+
498
+ ```text
499
+ drawio_guide({ "topics": ["diagram-types", "xml-authoring", "style-presets"] })
500
+ ```
501
+
483
502
  ## Authoring-mode selection
484
503
 
485
504
  | Requirement | Recommended path |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@senad-d/drawme",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Pi extension for authoring, validating, and exporting editable draw.io diagrams from natural-language descriptions.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * Tools: drawio_check · drawio_export · drawio_animate · drawio_validate
8
8
  * drawio_fit_canvas · drawio_from_mermaid · drawio_layout · drawio_shapesearch
9
- * drawio_explain · drawio_open
9
+ * drawio_explain · drawio_open · drawio_guide
10
10
  * Commands: /drawme · /drawme-check · /drawme-export
11
11
  */
12
12
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
@@ -45,6 +45,23 @@ import { MAX_STORYBOARD_FRAMES } from "./storyboard";
45
45
  const HERE = dirname(fileURLToPath(import.meta.url));
46
46
  const REF_DIR = resolve(HERE, "..", "assets", "references");
47
47
 
48
+ const GUIDE_TOPICS = {
49
+ "diagram-types": "diagram-types.md",
50
+ "xml-authoring": "xml-authoring.md",
51
+ "style-presets": "style-presets.md",
52
+ "mermaid-authoring": "mermaid-authoring.md",
53
+ troubleshooting: "troubleshooting.md",
54
+ } as const;
55
+ type GuideTopic = keyof typeof GUIDE_TOPICS;
56
+
57
+ async function readReference(name: string): Promise<string | null> {
58
+ try {
59
+ return await readFile(resolve(REF_DIR, name), "utf8");
60
+ } catch {
61
+ return null;
62
+ }
63
+ }
64
+
48
65
  const FORMATS = ["png", "svg", "pdf", "jpg"] as const satisfies readonly ExportFormat[];
49
66
  const MODES = ["preview", "final"] as const satisfies readonly ExportMode[];
50
67
  const FORMAT = Type.Union(FORMATS.map((format) => Type.Literal(format)));
@@ -473,6 +490,30 @@ export default function drawme(pi: ExtensionAPI): void {
473
490
  },
474
491
  });
475
492
 
493
+ pi.registerTool({
494
+ name: "drawio_guide",
495
+ label: "draw.io: guide",
496
+ description:
497
+ "Return DrawMe's packaged authoring guides, the same ones /drawme pre-loads: diagram-types (choose a view; composition, label, and review rules per notation), xml-authoring (file skeleton, sizing, containers, connectors, anchors, defect→fix recipes, layout), style-presets (Light/Dark/Multi-color themes and motion design), mermaid-authoring (syntax for drawio_from_mermaid), and troubleshooting (export and platform failures). Read once before authoring when /drawme did not start the run.",
498
+ promptSnippet: "Read DrawMe's authoring guides (view selection, XML authoring, style presets) before writing a diagram.",
499
+ parameters: Type.Object({
500
+ topics: Type.Array(Type.Union(Object.keys(GUIDE_TOPICS).map((topic) => Type.Literal(topic))), {
501
+ minItems: 1,
502
+ description: "Guides to return: diagram-types, xml-authoring, style-presets, mermaid-authoring, troubleshooting",
503
+ }),
504
+ }),
505
+ async execute(_id, params) {
506
+ const topics = [...new Set(params.topics as GuideTopic[])];
507
+ const sections = await Promise.all(topics.map(async (topic) => {
508
+ const content = await readReference(GUIDE_TOPICS[topic]);
509
+ return content === null
510
+ ? `# Guide: ${topic}\n\nGuide failed: could not read ${resolve(REF_DIR, GUIDE_TOPICS[topic])}`
511
+ : `# Guide: ${topic}\n\n${content.trim()}`;
512
+ }));
513
+ return textResult(sections.join("\n\n---\n\n"), { topics });
514
+ },
515
+ });
516
+
476
517
  pi.registerCommand("drawme", {
477
518
  description: "Generate a .drawio diagram from a natural-language description",
478
519
  handler: async (args, ctx) => {
@@ -481,13 +522,6 @@ export default function drawme(pi: ExtensionAPI): void {
481
522
  ctx.ui.notify("Usage: /drawme <description of the diagram to create>", "info");
482
523
  return;
483
524
  }
484
- const readReference = async (name: string): Promise<string | null> => {
485
- try {
486
- return await readFile(resolve(REF_DIR, name), "utf8");
487
- } catch {
488
- return null;
489
- }
490
- };
491
525
  const cli = await resolveBinary();
492
526
  pi.sendUserMessage(
493
527
  drawmeWorkflow(desc, REF_DIR, cli, {
package/src/renderer.ts CHANGED
@@ -308,7 +308,7 @@ function launchXdgOpen(document: string): Promise<void> {
308
308
  return new Promise((resolve, reject) => {
309
309
  let child;
310
310
  try {
311
- child = spawn(operation, [document], { detached: true, stdio: "ignore" });
311
+ child = spawn("/usr/bin/xdg-open", [document], { detached: true, stdio: "ignore" });
312
312
  } catch (error) {
313
313
  reject(failure(startFailure(operation, error)));
314
314
  return;