@senad-d/drawme 0.1.3 → 0.1.4
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 +6 -2
- package/README.md +20 -16
- package/assets/references/troubleshooting.md +2 -2
- package/assets/references/xml-authoring.md +25 -1
- package/docs/agent-guide.md +53 -48
- package/docs/visual-review-implementation-tasks.md +271 -0
- package/example/drawme-how-it-works.drawio +32 -26
- package/example/drawme-installation-guide.drawio +27 -21
- package/package.json +1 -1
- package/src/drawio.ts +67 -15
- package/src/index.ts +26 -8
- package/src/validate.ts +516 -127
- package/src/workflow.ts +27 -12
package/src/workflow.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maximum number of automatic source-correction retries across all visual
|
|
3
|
+
* quality passes. The five required inspection passes do not consume retries;
|
|
4
|
+
* one targeted edit → validation → replacement preview cycle consumes one.
|
|
5
|
+
*/
|
|
6
|
+
export const AUTOMATIC_CORRECTION_LIMIT = 5;
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Builds the message the `/drawme` command injects to drive the diagram
|
|
3
|
-
* workflow. It steers the model through
|
|
4
|
-
*
|
|
10
|
+
* workflow. It steers the model through authoring, deterministic validation,
|
|
11
|
+
* focused visual quality passes, human approval, and final export.
|
|
5
12
|
*/
|
|
6
13
|
export function drawmeWorkflow(description: string, refDir: string, agentReferencePath: string): string {
|
|
7
14
|
const quoted = description.replaceAll("\n", "\n> ");
|
|
@@ -18,20 +25,28 @@ export function drawmeWorkflow(description: string, refDir: string, agentReferen
|
|
|
18
25
|
"",
|
|
19
26
|
"Produce a `.drawio` file and export it, following the workflow below. For anything that touches the draw.io CLI, use the DrawMe tools — do NOT shell out to `drawio` yourself.",
|
|
20
27
|
"",
|
|
21
|
-
"1. **Check** — call `drawio_check` once
|
|
22
|
-
"2. **Plan** — choose the diagram type, shapes, relationships, and layout direction (LR or TB). For a specific type (ERD, UML class, sequence, C4, architecture, ML/DL, flowchart, SysML, BPMN, network, swimlane), read `" +
|
|
28
|
+
"1. **Check** — call `drawio_check` once and note the version. v30+ unlocks Mermaid conversion and the auto-layout pass. If the CLI is unavailable, still author and validate the `.drawio` XML, tell the user how to install draw.io or open the source, and skip conversion, layout, previews, visual quality passes, and exports.",
|
|
29
|
+
"2. **Plan** — choose the diagram type, shapes, relationships, page/canvas dimensions, and layout direction (LR or TB). For a specific type (ERD, UML class, sequence, C4, architecture, ML/DL, flowchart, SysML, BPMN, network, swimlane), read `" +
|
|
23
30
|
refDir +
|
|
24
|
-
"/diagram-types.md`. If it is a standard type with no custom styling
|
|
31
|
+
"/diagram-types.md`. If it is a standard type with no custom styling and the CLI is v30+, prefer concise Mermaid converted with `drawio_from_mermaid`; read `" +
|
|
25
32
|
refDir +
|
|
26
33
|
"/mermaid-authoring.md`.",
|
|
27
|
-
"3. **Author** — for hand-written
|
|
34
|
+
"3. **Author** — for hand-written XML, first read `" +
|
|
28
35
|
refDir +
|
|
29
|
-
"/xml-authoring.md
|
|
30
|
-
"4. **Validate** — call `drawio_validate`
|
|
31
|
-
"5. **
|
|
36
|
+
"/xml-authoring.md`. Keep XML uncompressed; never reuse ids `0`/`1`; give every edge `<mxGeometry relative=\"1\" as=\"geometry\"/>`; use `drawio_shapesearch` rather than guessing exact vendor/UML/BPMN/cloud styles. For large graphs (>~15 nodes) on v30+, hand-write nodes and use `drawio_layout`. Treat every write, edit, Mermaid conversion, and layout result as a source edit.",
|
|
37
|
+
"4. **Validate after every source edit** — call `drawio_validate` immediately after authoring and after every later XML edit, Mermaid conversion, or layout operation. Fix all errors before previewing. Every warning must be either fixed or recorded explicitly as reviewed and acceptable with a reason; unresolved or unreviewed warnings block final export.",
|
|
38
|
+
"5. **Run focused visual quality passes in order** — handle exactly one category at a time. For each pass: export its named PNG preview, inspect only that category and its acceptance checks, make targeted source edits if needed, validate, then replace/re-export that pass preview before advancing. Preview results include the image when supported; the reported path remains the fallback for text-only models or run modes. Each successful preview export automatically removes the previous preview file for the same source, so only the latest review image remains. Use these predictable outputs beside `<name>.drawio`:",
|
|
39
|
+
" 1. **Canvas and composition** → `<name>.review-canvas.png`: page bounds, outer margins, clipping, excessive empty space, aspect ratio, major alignment, and overall balance.",
|
|
40
|
+
" 2. **Nodes and typography** → `<name>.review-nodes.png`: shape overlap, label clipping/wrapping, readable font size, contrast, padding, sizing, and alignment. If a full-diagram 2000px preview makes labels unreadable, simplify, resize, split pages, or use a focused review rather than assuming the typography passes.",
|
|
41
|
+
" 3. **Connectors** → `<name>.review-connectors.png`: endpoints, arrowheads, stacked lines, crossings, routes through unrelated elements, labels, and routing corridors.",
|
|
42
|
+
" 4. **Semantics and final polish** → `<name>.review-semantics.png`: requested components and relationships, hierarchy, consistency, legends, grouping, and remaining regressions.",
|
|
43
|
+
" 5. **Holistic regression check** → `<name>.review.png`: recheck every earlier category and confirm later fixes introduced no regression. This pass is mandatory after all focused passes and after any user-feedback edit; it is the one review image retained for approval.",
|
|
44
|
+
`6. **Correction limit** — the five required inspection passes do not count against the limit. Across the whole automatic review, allow at most ${AUTOMATIC_CORRECTION_LIMIT} correction retries; one retry is one targeted source-edit → \`drawio_validate\` → replacement-preview cycle. Count retries explicitly. If the limit is reached with a finding unresolved, stop automatic editing, identify the failing category, ask for focused user feedback, and offer \`drawio_open\`; never loop indefinitely.`,
|
|
45
|
+
"7. **Human review and approval** — present the final holistic preview plus validation status and any reviewed/accepted warning reasons. Apply user feedback as a targeted edit, validate it, rerun the affected focused pass, then rerun the holistic regression preview. Ask for and receive explicit user approval before any `mode: \"final\"` export.",
|
|
46
|
+
"8. **Final export** — only after explicit approval, call `drawio_export` with `mode: \"final\"` for each requested format (default PNG; SVG/PDF/JPG on request). The first successful final export removes the one remaining latest preview for the same source; do not delete previews yourself or report it as a retained output. Report the `.drawio` source and every final path, retained reviewed warnings, and cleanup warnings. Offer `drawio_open` for fine-tuning.",
|
|
47
|
+
"",
|
|
48
|
+
"Failure handling: if export fails, read `" +
|
|
32
49
|
refDir +
|
|
33
|
-
"/troubleshooting.md`.",
|
|
34
|
-
"6. **Review** — show the PNG to the user, apply targeted XML edits from their feedback, and re-preview until they approve.",
|
|
35
|
-
"7. **Final export** — call `drawio_export` with `mode: \"final\"` for each requested format (default PNG; SVG/PDF/JPG on request). The first successful final export automatically removes preview artifacts created for the same source; do not delete them yourself or report them as retained outputs. Report the `.drawio` source path and every final exported file path, and offer to open the source in the desktop app with `drawio_open` for fine-tuning.",
|
|
50
|
+
"/troubleshooting.md`. On draw.io below v30, use hand-authored XML instead of Mermaid conversion or ELK layout, but keep validation, focused previews, approval, requested-format handling, and final cleanup unchanged.",
|
|
36
51
|
].join("\n");
|
|
37
52
|
}
|