@senad-d/drawme 0.1.2 → 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.
@@ -13,12 +13,12 @@ This document defines the extension's public functionality, options, defaults, d
13
13
  3. Use DrawMe tools for draw.io CLI operations; do not invoke `drawio` through a shell.
14
14
  4. Use `drawio_shapesearch` instead of guessing official shape styles.
15
15
  5. Keep hand-authored XML uncompressed and structurally valid.
16
- 6. Run `drawio_validate` and fix all errors before export.
17
- 7. Use `drawio_export` with `mode: "preview"` for visual inspection and `mode: "final"` for deliverables.
18
- 8. Inspect every tool's text result. Several tools return failure text rather than throwing a tool-call error.
19
- 9. Offer `drawio_open` for manual fine-tuning; call it only when the user wants a desktop application opened.
20
-
21
- DrawMe performs all extension operations locally. It does not provide network-based rendering, icon downloads, or browser fallbacks.
16
+ 6. Run `drawio_validate` after every source edit. Fix every error; fix each warning or explicitly record why it was reviewed and accepted.
17
+ 7. Inspect one visual category at a time in this order: canvas/composition, nodes/typography, connectors, semantics/polish, then a holistic regression check.
18
+ 8. Use `drawio_export` with `mode: "preview"` for visual inspection. A successful PNG preview returns both text/metadata and the actual image; the text path remains the fallback when a model or run mode cannot consume images.
19
+ 9. Require explicit user approval before `mode: "final"`. Each successful preview export removes the previous preview file for the same source, leaving only the latest; a successful final export removes that remaining preview. Cleanup warnings do not invalidate the new export.
20
+ 10. Inspect every tool's text result. Several tools return failure text rather than throwing a tool-call error.
21
+ 11. Offer `drawio_open` for manual fine-tuning; call it only when the user wants a desktop application opened.
22
22
 
23
23
  ## Functional availability
24
24
 
@@ -43,7 +43,7 @@ Commands are user-facing shortcuts. Agents should use model-callable tools when
43
43
 
44
44
  | Command | Functionality |
45
45
  | --- | --- |
46
- | `/drawme <description>` | Starts the full diagram creation workflow: check, plan, author, validate, preview, review, and final export. |
46
+ | `/drawme <description>` | Starts the full workflow: check, plan, author, validate, focused quality passes, holistic regression review, approval, and final export. |
47
47
  | `/drawme-check` | Displays the detected draw.io path and version, or reports that the CLI is unavailable. |
48
48
  | `/drawme-export <file> [png\|svg\|pdf\|jpg]` | Performs a final export of an existing `.drawio`; format defaults to PNG. |
49
49
 
@@ -123,10 +123,11 @@ Additional behavior:
123
123
  - An explicit `width` replaces raster scaling.
124
124
  - `scale` is ignored in preview mode and for vector formats.
125
125
  - `transparent` has no effect outside PNG.
126
- - Preview mode defaults to unembedded output suitable for vision inspection.
127
- - Final PNG, SVG, and PDF default to embedded/editable output.
126
+ - Preview mode defaults to unembedded output suitable for vision inspection. A successful PNG preview tool result contains its normal text/metadata block followed by an `image/png` base64 image block. Text-only models and non-image run modes still receive the usable output path.
127
+ - Final exports stay text-only; final PNG, SVG, and PDF default to embedded/editable output.
128
128
  - JPG cannot carry editable XML; never set `embed: true` for JPG.
129
129
  - Embedded PNG exports are checked for draw.io's known truncated IEND chunk and repaired automatically when necessary.
130
+ - Every successful preview output is tracked, including explicit `output` paths. After a replacement preview exists, the tool automatically removes the previous preview file for the same source, so only the latest artifact remains. The first successful final export removes that remaining preview. Cleanup failures are returned as warnings without invalidating the new export.
130
131
  - Headless Linux handling is automatic, including `xvfb-run`, GPU disabling, and the root sandbox flag.
131
132
 
132
133
  #### Use
@@ -152,7 +153,7 @@ drawio_export({
152
153
  })
153
154
  ```
154
155
 
155
- Use a distinct `output` for each format or page. Never present a preview artifact as the final deliverable when a final export was requested.
156
+ Use a distinct `output` for each format or page. Never present a preview artifact as the final deliverable when a final export was requested. Do not manually delete superseded or final-review previews; the tool replaces and cleans them automatically.
156
157
 
157
158
  ---
158
159
 
@@ -174,34 +175,39 @@ Errors include:
174
175
  - vertices or edges reusing reserved root IDs `0` or `1`;
175
176
  - references to missing parents;
176
177
  - edge references to missing sources or targets;
177
- - missing or invalid vertex geometry.
178
+ - missing or invalid vertex geometry;
179
+ - missing edge geometry, or edge geometry without both `relative="1"` and `as="geometry"`.
178
180
 
179
- Warnings include:
181
+ Actionable warnings include:
180
182
 
181
- - non-positive vertex dimensions;
182
- - negative vertex positions;
183
+ - non-positive vertex dimensions and negative vertex positions;
183
184
  - overlapping sibling leaf vertices;
184
- - explicitly waypointed edges routed through unrelated vertices;
185
- - explicitly waypointed edges crossing one another;
185
+ - visible children extending outside parent containers (relative ports and edge labels are excluded);
186
+ - content outside finite page boundaries or below the 20px minimum outer margin;
187
+ - a canvas conservatively detected as substantially larger than its visible content;
188
+ - very small explicit label fonts and long labels in narrow nodes without wrapping;
189
+ - explicitly waypointed edges routed through unrelated vertices or crossing one another;
186
190
  - compressed pages that cannot be inspected.
187
191
 
188
- The result also includes a readability score:
192
+ Informational observations identify checks intentionally skipped for infinite canvases or omitted/invalid page dimensions. All normal-page diagnostics are page-specific. Content bounds account for nested container offsets, visible nodes/containers, explicit waypoints, and separately sized edge labels on resolvable explicit routes where practical.
193
+
194
+ The result text and details also include a readability score:
189
195
 
190
196
  - route through vertex: 20 points;
191
197
  - edge crossing: 10 points;
192
198
  - overlap: 5 points.
193
199
 
194
- Lower is better, but scores are meaningful only when comparing layout variants of the same graph.
200
+ Lower is better, but scores are meaningful only when comparing layout variants of the same graph. Canvas, containment, and typography warnings do not change this established score. The text result separately reports error, unresolved-warning, and observation counts.
195
201
 
196
202
  #### Use
197
203
 
198
- Fix every error and rerun validation. Investigate warnings before preview.
204
+ Fix every error and rerun validation. Fix each warning or record an explicit reviewed-and-acceptable reason before final export. Informational observations do not require correction.
199
205
 
200
206
  ```text
201
207
  drawio_validate({ "input": "architecture.drawio" })
202
208
  ```
203
209
 
204
- Validation is structural rather than visual. It cannot guarantee readable labels, correct semantic content, valid rendering of a guessed shape, color contrast, visual balance, or clear auto-routed edges. It does not replace preview inspection.
210
+ Validation is structural rather than rendered. Its static typography checks are deliberately conservative: it cannot guarantee label fit, correct semantic content, valid rendering of a guessed shape, color contrast, visual balance, or clear auto-routed edges. It does not replace focused preview inspection.
205
211
 
206
212
  ---
207
213
 
@@ -248,7 +254,7 @@ drawio_from_mermaid({
248
254
  })
249
255
  ```
250
256
 
251
- Continue with validation, preview, visual inspection, and final export.
257
+ Continue with validation, the ordered focused visual passes, holistic regression review, explicit approval, and final export.
252
258
 
253
259
  ---
254
260
 
@@ -397,7 +403,7 @@ Choose:
397
403
  - groups or containers;
398
404
  - top-to-bottom or left-to-right direction;
399
405
  - Mermaid or XML authoring mode;
400
- - source path, pages, and final formats.
406
+ - source path, finite page dimensions (or an intentional infinite canvas), pages, and final formats.
401
407
 
402
408
  Call `drawio_shapesearch` during planning whenever an exact library shape is required.
403
409
 
@@ -411,6 +417,7 @@ For XML, use an uncompressed `<mxGraphModel>`. The minimum authoring contract is
411
417
  - reserve IDs `0` and `1` for those root cells;
412
418
  - assign every other cell a unique ID and valid parent;
413
419
  - assign every vertex positive geometry;
420
+ - use explicit `page="1"`, `pageScale="1"`, `pageWidth`, and `pageHeight` for deliverables, sized to visible content with at least 20px outer margin (40px recommended); use `page="0"` only for an intentional infinite canvas;
414
421
  - assign every edge valid source and target IDs;
415
422
  - include `<mxGeometry relative="1" as="geometry" />` in every edge;
416
423
  - escape XML attribute characters and use `&#xa;` for label line breaks;
@@ -419,40 +426,36 @@ For XML, use an uncompressed `<mxGraphModel>`. The minimum authoring contract is
419
426
 
420
427
  For large XML graphs on draw.io 30+, run `drawio_layout` and continue using its returned path.
421
428
 
422
- ### 4. Validate
429
+ ### 4. Validate after every source edit
423
430
 
424
- Run `drawio_validate` on the exact source that will be exported. Fix every error and rerun validation. Assess warnings before continuing.
431
+ Run `drawio_validate` immediately after initial authoring, Mermaid conversion, layout, and every later XML/source edit. Fix every error before previewing. Every warning must be fixed or explicitly recorded as reviewed and acceptable with a reason; unresolved or unreviewed warnings block final export.
425
432
 
426
- ### 5. Preview and inspect
433
+ ### 5. Focused visual quality passes
427
434
 
428
- Export a PNG with:
435
+ Inspect exactly one category at a time and keep this order. For each pass, export its predictable PNG, inspect only its listed acceptance checks, make a targeted source correction if needed, validate, then replace/re-export that pass preview before advancing:
429
436
 
430
- ```text
431
- drawio_export({ "input": "<source>.drawio", "mode": "preview" })
432
- ```
437
+ 1. **Canvas and composition** — `<name>.review-canvas.png`: page bounds, margins, clipping, excessive empty space, aspect ratio, major alignment, and balance.
438
+ 2. **Nodes and typography** — `<name>.review-nodes.png`: overlap, clipping, wrapping, font readability, contrast, padding, sizing, and alignment.
439
+ 3. **Connectors** — `<name>.review-connectors.png`: endpoints, arrowheads, line stacking, crossings, routes through unrelated elements, connector labels, and routing corridors.
440
+ 4. **Semantics and final polish** — `<name>.review-semantics.png`: requested components/relationships, hierarchy, consistency, legends, grouping, and remaining regressions.
441
+ 5. **Holistic regression check** — `<name>.review.png`: recheck all prior categories and confirm later fixes introduced no regression. This is the one review image retained for approval.
433
442
 
434
- Read the PNG with vision and verify:
443
+ A successful PNG preview result already includes the image block. If the selected model/run mode cannot consume it, use the text path to read or present the artifact. When a new preview for the same source succeeds, the prior preview file is removed automatically; at any point only the latest review artifact should remain. A full-diagram preview is capped at 2000px; if that scaling makes labels unreadable, tighten/simplify the layout, split pages, or use focused review rather than approving unreadable typography.
435
444
 
436
- - requested components and relations are present;
437
- - labels are readable and not clipped;
438
- - nodes do not overlap or leave the canvas;
439
- - edges connect the intended endpoints;
440
- - arrowheads and decision labels are visible;
441
- - edges do not stack, cross unnecessarily, or route through unrelated nodes;
442
- - grouping, alignment, spacing, contrast, and hierarchy are clear.
445
+ The five required inspection passes do not consume correction retries. Allow at most **5 automatic correction retries total** across the workflow. One retry is exactly one targeted source edit → `drawio_validate` → replacement preview cycle. Count retries explicitly. At the limit, stop automatic editing, identify the unresolved category, request focused feedback, and offer `drawio_open` instead of looping.
443
446
 
444
- Make targeted source corrections, validate again, and re-preview. Limit automatic visual correction to two rounds before requesting focused feedback or offering desktop fine-tuning.
447
+ ### 6. Human approval and final export
445
448
 
446
- ### 6. Final export
449
+ Present the holistic preview, validation status, and reasons for any reviewed/accepted warnings. User feedback triggers a targeted edit, validation, the affected focused pass, and another holistic regression preview. Receive explicit user approval before calling `drawio_export` with `mode: "final"`.
447
450
 
448
- After visual review, export each requested format and page with `mode: "final"`. Report:
451
+ After approval, export each requested format and page. The first successful final export automatically removes the one remaining latest preview for that source. Report:
449
452
 
450
453
  - source `.drawio` path;
451
- - validation status and retained warnings;
452
- - preview path when relevant;
454
+ - validation status and reasons for retained reviewed warnings;
455
+ - focused-pass and holistic-regression outcomes;
453
456
  - every final output path and format;
454
457
  - whether each output embeds editable XML;
455
- - any unavailable or skipped functionality.
458
+ - preview cleanup warnings, plus any unavailable or skipped functionality.
456
459
 
457
460
  ## Existing-diagram workflows
458
461
 
@@ -469,9 +472,9 @@ Use `drawio_validate` directly. A CLI check is unnecessary unless an export will
469
472
  1. Preserve the original unless replacement was requested.
470
473
  2. Explain and inspect the source.
471
474
  3. Make the smallest targeted XML change.
472
- 4. Validate the edited source.
473
- 5. Preview and compare the requested behavior visually.
474
- 6. Export to a new path unless in-place replacement was requested.
475
+ 4. Validate the edited source and resolve/review every warning.
476
+ 5. Rerun the affected focused preview, then a holistic regression preview.
477
+ 6. Obtain explicit approval and export to a new path unless in-place replacement was requested.
475
478
 
476
479
  Do not blindly edit compressed pages. The validator and explainer cannot inspect them; they must first be saved as uncompressed XML through a compatible editor.
477
480
 
@@ -488,7 +491,7 @@ Use `drawio_layout` only for XML-authored or existing native diagrams on draw.io
488
491
  - `.drawio` is always the canonical editable source.
489
492
  - Final PNG, SVG, and PDF embed XML by default and can be reopened in draw.io where supported.
490
493
  - JPG cannot embed XML.
491
- - Preview PNG is intentionally clean and unembedded for vision compatibility.
494
+ - Preview PNG is intentionally clean and unembedded for vision compatibility. Its successful tool result includes the actual image plus a text-path fallback. Each successful replacement removes the prior same-source preview file, and final export removes the latest remaining preview.
492
495
  - A final embedded PNG normally uses the `.drawio.png` double extension.
493
496
  - Multi-page exports should use `pageIndex` and explicit unique output names.
494
497
  - `drawio_explain` returns Markdown as text; it does not write a documentation file.
@@ -499,12 +502,13 @@ Use `drawio_layout` only for XML-authored or existing native diagrams on draw.io
499
502
 
500
503
  - Validation cannot inspect compressed pages.
501
504
  - Explanation cannot describe compressed pages.
502
- - Structural validation cannot replace visual inspection.
503
- - Route-through and crossing analysis is limited to edges with explicit waypoints.
505
+ - Deterministic validation cannot replace focused visual inspection; rendered clipping, wrapping, contrast, and automatic routes remain vision concerns.
506
+ - Removing a superseded preview file does not rewrite Pi session history: image blocks already stored in earlier tool-result messages can remain visible in the transcript even though only the latest preview file remains on disk.
507
+ - Route-through and crossing analysis is limited to edges with explicit waypoints; dense auto-routed graphs can validate without connector-route warnings.
504
508
  - Shape search covers bundled official draw.io shapes, not arbitrary third-party logos.
505
509
  - Mermaid conversion cannot express all draw.io styles, containers, routing, or multi-page behavior.
506
510
  - ELK layout accepts only the six registered presets; arbitrary JSON layouts are not exposed.
507
- - The extension does not expose XML compression/decompression, Python generators, browser editor fallbacks, icon downloads, or arbitrary draw.io CLI arguments.
511
+ - The extension does not expose XML compression/decompression, Python generators, or arbitrary draw.io CLI arguments.
508
512
  - A failed operation may be returned as text beginning with `Export failed`, `Layout failed`, `Mermaid conversion failed`, `Explain failed`, or `Open failed`. Treat that result as failure.
509
513
 
510
514
  ## Authoring references
@@ -516,4 +520,4 @@ Use these packaged references when additional notation or XML detail is needed:
516
520
  - [`../assets/references/mermaid-authoring.md`](../assets/references/mermaid-authoring.md) — Mermaid syntax and conversion guidance;
517
521
  - [`../assets/references/troubleshooting.md`](../assets/references/troubleshooting.md) — rendering and platform failure patterns.
518
522
 
519
- Some inherited reference text mentions upstream Python scripts or direct CLI commands. Those references provide background authoring knowledge only. They do not add extension functionality. Agents must use the registered DrawMe tools and options documented here.
523
+ Use the registered DrawMe tools and options documented here rather than invoking the draw.io CLI directly.
@@ -0,0 +1,271 @@
1
+ # Visual Review and Fixing Implementation Tasks
2
+
3
+ ## Goal
4
+
5
+ Make DrawMe's automatic review loop reliably catch and correct canvas, layout, typography, element-overlap, and connector problems before asking for user approval or creating final exports.
6
+
7
+ ## Current gaps
8
+
9
+ - `/drawme` injects guidance for the model; it is not an enforced workflow or state machine.
10
+ - The current self-check asks the model to inspect every visual concern at once and caps automatic review at two rounds.
11
+ - `drawio_export` reports a preview path as text, so the model must independently remember to read the PNG with vision.
12
+ - The injected workflow does not explicitly revalidate after every visual edit.
13
+ - Validator errors block progress, but warnings do not have a clear resolution or acceptance gate.
14
+ - Canvas validation only catches negative positions. It does not compare content bounds with `pageWidth` or `pageHeight`.
15
+ - Connector analysis only covers explicitly waypointed routes, and missing edge geometry is not currently rejected.
16
+ - Text size, clipping, wrapping, contrast, and rendered edge routes remain primarily visual concerns.
17
+ - Review limits conflict: the main workflow allows two automatic rounds while troubleshooting guidance refers to five rounds.
18
+
19
+ ## Decisions
20
+
21
+ - Replace the broad review step with focused, ordered quality passes.
22
+ - Keep the first implementation agent-driven rather than introducing a full extension state machine.
23
+ - Strengthen deterministic validation where geometry can be checked reliably; leave rendered typography and automatic edge routing to vision review.
24
+ - Revalidate after every source edit, regardless of whether the edit came from automatic review or user feedback.
25
+ - Preserve a final human approval step before final export.
26
+ - Keep preview dimensions within model vision limits, but explicitly assess whether full-diagram scaling makes labels unreadable.
27
+
28
+ ## Focused review sequence
29
+
30
+ 1. **Canvas and composition**
31
+ - Check page bounds, content margins, clipping, excessive empty space, aspect ratio, major alignment, and overall balance.
32
+ 2. **Nodes and typography**
33
+ - Check shape overlap, label clipping, wrapping, font readability, contrast, padding, sizing, and alignment.
34
+ 3. **Connectors**
35
+ - Check endpoints, arrowheads, line stacking, crossings, routes through unrelated elements, connector labels, and routing corridors.
36
+ 4. **Semantics and final polish**
37
+ - Check requested components and relationships, visual hierarchy, consistency, legends, grouping, and remaining regressions.
38
+ 5. **Holistic regression check**
39
+ - Confirm that fixes from later passes did not reintroduce failures from earlier passes.
40
+
41
+ Each focused pass must follow: preview, inspect one category, make targeted edits if needed, validate, and re-preview before advancing.
42
+
43
+ ## Implementation tasks
44
+
45
+ ### 1. Refactor the injected `/drawme` workflow
46
+
47
+ Files:
48
+
49
+ - `src/workflow.ts`
50
+ - `tests/integration.test.ts`, or a new focused workflow test file
51
+
52
+ Tasks:
53
+
54
+ - [x] Replace the current broad two-round self-check with the focused review sequence above.
55
+ - [x] Tell the model to handle one review category at a time instead of attempting every visual concern in one pass.
56
+ - [x] Require `drawio_validate` after every XML or Mermaid-converted `.drawio` edit.
57
+ - [x] Require every validation warning to be fixed or explicitly recorded as reviewed and acceptable before final export.
58
+ - [x] Define one consistent automatic correction limit and use it in every reference. Count passes and correction retries unambiguously.
59
+ - [x] Stop automatic correction at the configured limit and request focused user feedback or offer `drawio_open` instead of looping indefinitely.
60
+ - [x] Require a final holistic regression preview after all focused passes.
61
+ - [x] Require explicit user approval before `mode: "final"` exports.
62
+ - [x] Use distinct preview output names to identify focused passes, for example `.review-canvas.png` and `.review-connectors.png`, while retaining only the latest file.
63
+ - [x] Preserve the existing behavior for unavailable CLIs, draw.io versions below 30, and requested formats; keep only the latest successful preview and clean it after final export.
64
+
65
+ Acceptance criteria:
66
+
67
+ - The generated workflow names every focused pass and its acceptance checks.
68
+ - Every correction path returns through validation before another preview.
69
+ - The workflow has no conflicting two-round/five-round language.
70
+ - Tests verify the ordering, revalidation requirement, approval gate, and correction limit.
71
+
72
+ ### 2. Attach preview images to preview tool results
73
+
74
+ Files:
75
+
76
+ - `src/index.ts`
77
+ - `src/drawio.ts` if preview result metadata needs to change
78
+ - `tests/integration.test.ts`
79
+ - `tests/drawio.test.ts` as appropriate
80
+
81
+ Tasks:
82
+
83
+ - [x] Keep the existing text result with the output path and export metadata.
84
+ - [x] For a successful PNG preview, read the generated file and add an `ImageContent` block to the tool result.
85
+ - [x] Use MIME type `image/png` and base64 data in the Pi-supported tool-result format.
86
+ - [x] Return image content only for successful preview PNGs; preserve text-only failure behavior.
87
+ - [x] Avoid attaching final embedded exports unless there is a documented need.
88
+ - [x] Confirm behavior when the selected model or run mode cannot consume images; the text path must remain a usable fallback.
89
+ - [x] Keep preview tracking, but remove each superseded same-source preview after its replacement succeeds.
90
+ - [x] Add tests for text-plus-image preview results, MIME type, and failure results without image blocks.
91
+
92
+ Acceptance criteria:
93
+
94
+ - The model receives the actual preview in the same tool result and no longer depends solely on a separate file-read call.
95
+ - Existing export callers and cleanup tests continue to pass.
96
+
97
+ ### 3. Strengthen deterministic structural validation
98
+
99
+ Files:
100
+
101
+ - `src/validate.ts`
102
+ - `src/index.ts`
103
+ - `tests/validate.test.ts`
104
+
105
+ #### 3.1 Edge geometry
106
+
107
+ - [x] Report an error when an edge lacks an `mxGeometry` child.
108
+ - [x] Report an error when edge geometry does not have `relative="1"` and `as="geometry"` as required by the authoring contract.
109
+ - [x] Add regression tests for valid and invalid edge geometry.
110
+
111
+ #### 3.2 Canvas and content bounds
112
+
113
+ - [x] Parse page settings from each `mxGraphModel`, including `page`, `pageWidth`, `pageHeight`, and `pageScale` where relevant.
114
+ - [x] Define and document behavior when page dimensions are omitted.
115
+ - [x] Compute absolute visible-content bounds, including nested container offsets.
116
+ - [x] Include visible vertices, containers, edge labels, and explicit waypoints where practical.
117
+ - [x] Warn when content extends beyond the left, top, right, or bottom page boundary.
118
+ - [x] Warn when a child visibly extends beyond its parent container, excluding intentional border ports and relative edge labels.
119
+ - [x] Warn when content has less than the documented minimum outer margin.
120
+ - [x] Add a conservative warning for a canvas that is substantially larger than its content and produces excessive empty space.
121
+ - [x] Keep diagnostics page-specific for multi-page files.
122
+ - [x] Add tests for right/bottom overflow, nested overflow, valid margins, omitted page dimensions, and multi-page files.
123
+
124
+ #### 3.3 Readability diagnostics
125
+
126
+ - [x] Surface the existing readability score in the tool's text output, not only in result details.
127
+ - [x] Extend the score with canvas or containment findings only if weights are documented and remain comparable across variants of the same graph.
128
+ - [x] Investigate conservative static checks for labeled-node wrapping, very small explicit fonts, and obviously insufficient geometry.
129
+ - [x] Add only checks with acceptable false-positive behavior; keep uncertain typography judgments in the visual pass.
130
+ - [x] Clearly separate errors, actionable warnings, and informational observations.
131
+
132
+ Acceptance criteria:
133
+
134
+ - A shape beyond `pageWidth` or `pageHeight` no longer validates without a warning.
135
+ - Missing edge geometry is rejected before export.
136
+ - Existing clean examples remain free of unexpected warnings, or intentional warnings are documented and corrected.
137
+ - Tool output makes the readability score and unresolved warning count visible to the model.
138
+
139
+ ### 4. Improve authoring guidance for canvas and readability
140
+
141
+ Files:
142
+
143
+ - `assets/references/xml-authoring.md`
144
+ - `assets/references/troubleshooting.md`
145
+ - `assets/references/diagram-types.md` only where type-specific guidance is needed
146
+ - `.golden.sha256`
147
+
148
+ Tasks:
149
+
150
+ - [x] Add explicit page attributes to the XML skeleton or document when an infinite/non-page canvas is appropriate.
151
+ - [x] Explain how to calculate content bounds and choose `pageWidth` and `pageHeight` with consistent outer margins.
152
+ - [x] Add guidance for resizing the canvas after layout changes.
153
+ - [x] Define recommended minimum body and connector-label sizes while documenting legitimate exceptions such as compact ports.
154
+ - [x] Add guidance for node padding, wrapping, line count, and long-label sizing.
155
+ - [x] Explain that a 2000px full-diagram preview can make dense diagrams unreadable and should trigger layout simplification, page splitting, or focused review.
156
+ - [x] Replace the conflicting troubleshooting iteration limit with the workflow's chosen limit.
157
+ - [x] Update the golden hash intentionally after changing files under `assets/` and document why it changed.
158
+
159
+ Acceptance criteria:
160
+
161
+ - A model following the XML reference can produce an appropriately sized canvas without guessing.
162
+ - Guidance and runtime workflow use identical review terminology and limits.
163
+
164
+ ### 5. Keep only the latest review artifact and dispose of it safely
165
+
166
+ Files:
167
+
168
+ - `src/workflow.ts`
169
+ - `src/drawio.ts`
170
+ - `tests/drawio.test.ts`
171
+
172
+ Tasks:
173
+
174
+ - [x] Define predictable names for focused review artifacts.
175
+ - [x] Remove the prior same-source preview only after its replacement export succeeds.
176
+ - [x] Keep the previous preview when a replacement export fails.
177
+ - [x] Serialize exports per source so concurrent preview calls cannot leave multiple latest artifacts.
178
+ - [x] Confirm that the first successful final export removes the remaining latest preview.
179
+ - [x] Preserve the final output if it resolves to the latest preview path.
180
+ - [x] Report cleanup warnings without invalidating a successful replacement or final export.
181
+ - [x] Add or update tests for focused preview replacement and cleanup behavior.
182
+
183
+ Acceptance criteria:
184
+
185
+ - Only the latest successful preview file for a source remains after each review iteration.
186
+ - No review artifact remains after a successful final export unless cleanup explicitly reports a failure.
187
+
188
+ ### 6. Update public documentation and the workflow example
189
+
190
+ Files:
191
+
192
+ - `README.md`
193
+ - `docs/agent-guide.md`
194
+ - `CHANGELOG.md`
195
+ - `example/drawme-how-it-works.drawio`
196
+ - `example/drawme-how-it-works.drawio.png`
197
+
198
+ Tasks:
199
+
200
+ - [x] Replace the seven-step overview's broad review wording with the focused quality-pass workflow.
201
+ - [x] Document which findings are deterministic and which require vision.
202
+ - [x] Document that preview results include the image when implemented.
203
+ - [x] Document validation-warning resolution and the final approval gate.
204
+ - [ ] Update the workflow diagram to show the focused passes and regression check.
205
+ - [ ] Validate and export the updated example with the DrawMe tools.
206
+ - [x] Add an Unreleased changelog entry describing the quality-review improvements.
207
+
208
+ Acceptance criteria:
209
+
210
+ - Runtime guidance, agent reference, README, troubleshooting, and example diagram describe the same workflow.
211
+
212
+ ### 7. Add scenario and regression coverage
213
+
214
+ Files:
215
+
216
+ - `tests/validate.test.ts`
217
+ - `tests/drawio.test.ts`
218
+ - `tests/integration.test.ts`
219
+ - New fixtures under `tests/fixtures/` if needed
220
+
221
+ Tasks:
222
+
223
+ - [x] Add a diagram whose content exceeds the right and bottom canvas boundaries.
224
+ - [x] Add a nested-container overflow case.
225
+ - [x] Add missing and malformed edge-geometry cases.
226
+ - [x] Add long-label and small-font cases for any accepted static readability checks.
227
+ - [x] Add a dense but valid graph that demonstrates limits of waypoint-only connector analysis.
228
+ - [x] Verify preview tool results contain an image block when the real CLI is available.
229
+ - [x] Verify failure text never includes a stale image block.
230
+ - [x] Verify workflow prompt construction and focused pass ordering without requiring the CLI.
231
+ - [x] Keep real-CLI tests skippable when draw.io is unavailable.
232
+
233
+ Acceptance criteria:
234
+
235
+ - Every new behavior has deterministic regression coverage.
236
+ - Visual limitations that cannot be asserted automatically are documented in test names or fixture notes.
237
+
238
+ ### 8. Perform manual workflow verification
239
+
240
+ Tasks:
241
+
242
+ - [ ] Run `npm run validate`.
243
+ - [ ] Run `/drawme` for a small five-node flowchart and verify the focused passes do not create unnecessary edits.
244
+ - [ ] Run `/drawme` for a wide architecture diagram and verify canvas fit and preview readability.
245
+ - [ ] Run `/drawme` for a dense graph with multiple connectors and verify connector review is isolated from typography review.
246
+ - [ ] Run `/drawme` with long labels and nested containers.
247
+ - [ ] Verify behavior on draw.io below version 30, where Mermaid conversion and ELK layout are unavailable.
248
+ - [ ] Verify user feedback after automatic review triggers a targeted edit, revalidation, focused recheck, and final regression preview.
249
+ - [ ] Verify final export removes all review previews and reports only retained deliverables.
250
+
251
+ Acceptance criteria:
252
+
253
+ - All automated checks pass.
254
+ - The tested workflows require no manual intervention before the human approval step unless the documented correction limit is reached.
255
+
256
+ ## Suggested implementation order
257
+
258
+ 1. Workflow refactor and workflow-prompt tests.
259
+ 2. Preview image attachment and export-result tests.
260
+ 3. Edge-geometry and canvas-bound validation.
261
+ 4. Authoring references and consistent limits.
262
+ 5. Public documentation and workflow example.
263
+ 6. Full automated and manual verification.
264
+
265
+ ## Out of scope for the first implementation
266
+
267
+ - A separate vision model or nested model call inside the extension.
268
+ - Full OCR or pixel-level text measurement in TypeScript.
269
+ - Perfect deterministic analysis of draw.io's automatic edge routing.
270
+ - Arbitrary draw.io CLI flags or unbounded preview dimensions.
271
+ - A persistent workflow state machine unless prompt-driven focused passes remain unreliable after these changes.