@senad-d/drawme 0.2.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.
@@ -1,273 +0,0 @@
1
- # Visual Review and Fixing Implementation Tasks
2
-
3
- > **Historical checklist — not current operating instructions.** This records an earlier design, including its obsolete two-round review and human approval gate. The current `/drawme` workflow allows up to eight correction retries and does not pause for approval. See the [current extension reference](reference.md#commands) and the [workflow in the README](../README.md#the-drawme-workflow).
4
-
5
- ## Original goal
6
-
7
- 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.
8
-
9
- ## Gaps at the time
10
-
11
- - `/drawme` injects guidance for the model; it is not an enforced workflow or state machine.
12
- - The current self-check asks the model to inspect every visual concern at once and caps automatic review at two rounds.
13
- - `drawio_export` reports a preview path as text, so the model must independently remember to read the PNG with vision.
14
- - The injected workflow does not explicitly revalidate after every visual edit.
15
- - Validator errors block progress, but warnings do not have a clear resolution or acceptance gate.
16
- - Canvas validation only catches negative positions. It does not compare content bounds with `pageWidth` or `pageHeight`.
17
- - Connector analysis only covers explicitly waypointed routes, and missing edge geometry is not currently rejected.
18
- - Text size, clipping, wrapping, contrast, and rendered edge routes remain primarily visual concerns.
19
- - Review limits conflict: the main workflow allows two automatic rounds while troubleshooting guidance refers to five rounds.
20
-
21
- ## Decisions
22
-
23
- - Replace the broad review step with focused, ordered quality passes.
24
- - Keep the first implementation agent-driven rather than introducing a full extension state machine.
25
- - Strengthen deterministic validation where geometry can be checked reliably; leave rendered typography and automatic edge routing to vision review.
26
- - Revalidate after every source edit, regardless of whether the edit came from automatic review or user feedback.
27
- - Preserve a final human approval step before final export.
28
- - Keep preview dimensions within model vision limits, but explicitly assess whether full-diagram scaling makes labels unreadable.
29
-
30
- ## Focused review sequence
31
-
32
- 1. **Canvas and composition**
33
- - Check page bounds, content margins, clipping, excessive empty space, aspect ratio, major alignment, and overall balance.
34
- 2. **Nodes and typography**
35
- - Check shape overlap, label clipping, wrapping, font readability, contrast, padding, sizing, and alignment.
36
- 3. **Connectors**
37
- - Check endpoints, arrowheads, line stacking, crossings, routes through unrelated elements, connector labels, and routing corridors.
38
- 4. **Semantics and final polish**
39
- - Check requested components and relationships, visual hierarchy, consistency, legends, grouping, and remaining regressions.
40
- 5. **Holistic regression check**
41
- - Confirm that fixes from later passes did not reintroduce failures from earlier passes.
42
-
43
- Each focused pass must follow: preview, inspect one category, make targeted edits if needed, validate, and re-preview before advancing.
44
-
45
- ## Implementation tasks
46
-
47
- ### 1. Refactor the injected `/drawme` workflow
48
-
49
- Files:
50
-
51
- - `src/workflow.ts`
52
- - `tests/integration.test.ts`, or a new focused workflow test file
53
-
54
- Tasks:
55
-
56
- - [x] Replace the current broad two-round self-check with the focused review sequence above.
57
- - [x] Tell the model to handle one review category at a time instead of attempting every visual concern in one pass.
58
- - [x] Require `drawio_validate` after every XML or Mermaid-converted `.drawio` edit.
59
- - [x] Require every validation warning to be fixed or explicitly recorded as reviewed and acceptable before final export.
60
- - [x] Define one consistent automatic correction limit and use it in every reference. Count passes and correction retries unambiguously.
61
- - [x] Stop automatic correction at the configured limit and request focused user feedback or offer `drawio_open` instead of looping indefinitely.
62
- - [x] Require a final holistic regression preview after all focused passes.
63
- - [x] Require explicit user approval before `mode: "final"` exports.
64
- - [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.
65
- - [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.
66
-
67
- Acceptance criteria:
68
-
69
- - The generated workflow names every focused pass and its acceptance checks.
70
- - Every correction path returns through validation before another preview.
71
- - The workflow has no conflicting two-round/five-round language.
72
- - Tests verify the ordering, revalidation requirement, approval gate, and correction limit.
73
-
74
- ### 2. Attach preview images to preview tool results
75
-
76
- Files:
77
-
78
- - `src/index.ts`
79
- - `src/drawio.ts` if preview result metadata needs to change
80
- - `tests/integration.test.ts`
81
- - `tests/drawio.test.ts` as appropriate
82
-
83
- Tasks:
84
-
85
- - [x] Keep the existing text result with the output path and export metadata.
86
- - [x] For a successful PNG preview, read the generated file and add an `ImageContent` block to the tool result.
87
- - [x] Use MIME type `image/png` and base64 data in the Pi-supported tool-result format.
88
- - [x] Return image content only for successful preview PNGs; preserve text-only failure behavior.
89
- - [x] Avoid attaching final embedded exports unless there is a documented need.
90
- - [x] Confirm behavior when the selected model or run mode cannot consume images; the text path must remain a usable fallback.
91
- - [x] Keep preview tracking, but remove each superseded same-source preview after its replacement succeeds.
92
- - [x] Add tests for text-plus-image preview results, MIME type, and failure results without image blocks.
93
-
94
- Acceptance criteria:
95
-
96
- - The model receives the actual preview in the same tool result and no longer depends solely on a separate file-read call.
97
- - Existing export callers and cleanup tests continue to pass.
98
-
99
- ### 3. Strengthen deterministic structural validation
100
-
101
- Files:
102
-
103
- - `src/validate.ts`
104
- - `src/index.ts`
105
- - `tests/validate.test.ts`
106
-
107
- #### 3.1 Edge geometry
108
-
109
- - [x] Report an error when an edge lacks an `mxGeometry` child.
110
- - [x] Report an error when edge geometry does not have `relative="1"` and `as="geometry"` as required by the authoring contract.
111
- - [x] Add regression tests for valid and invalid edge geometry.
112
-
113
- #### 3.2 Canvas and content bounds
114
-
115
- - [x] Parse page settings from each `mxGraphModel`, including `page`, `pageWidth`, `pageHeight`, and `pageScale` where relevant.
116
- - [x] Define and document behavior when page dimensions are omitted.
117
- - [x] Compute absolute visible-content bounds, including nested container offsets.
118
- - [x] Include visible vertices, containers, edge labels, and explicit waypoints where practical.
119
- - [x] Warn when content extends beyond the left, top, right, or bottom page boundary.
120
- - [x] Warn when a child visibly extends beyond its parent container, excluding intentional border ports and relative edge labels.
121
- - [x] Warn when content has less than the documented minimum outer margin.
122
- - [x] Add a conservative warning for a canvas that is substantially larger than its content and produces excessive empty space.
123
- - [x] Keep diagnostics page-specific for multi-page files.
124
- - [x] Add tests for right/bottom overflow, nested overflow, valid margins, omitted page dimensions, and multi-page files.
125
-
126
- #### 3.3 Readability diagnostics
127
-
128
- - [x] Surface the existing readability score in the tool's text output, not only in result details.
129
- - [x] Extend the score with canvas or containment findings only if weights are documented and remain comparable across variants of the same graph.
130
- - [x] Investigate conservative static checks for labeled-node wrapping, very small explicit fonts, and obviously insufficient geometry.
131
- - [x] Add only checks with acceptable false-positive behavior; keep uncertain typography judgments in the visual pass.
132
- - [x] Clearly separate errors, actionable warnings, and informational observations.
133
-
134
- Acceptance criteria:
135
-
136
- - A shape beyond `pageWidth` or `pageHeight` no longer validates without a warning.
137
- - Missing edge geometry is rejected before export.
138
- - Existing clean examples remain free of unexpected warnings, or intentional warnings are documented and corrected.
139
- - Tool output makes the readability score and unresolved warning count visible to the model.
140
-
141
- ### 4. Improve authoring guidance for canvas and readability
142
-
143
- Files:
144
-
145
- - `assets/references/xml-authoring.md`
146
- - `assets/references/troubleshooting.md`
147
- - `assets/references/diagram-types.md` only where type-specific guidance is needed
148
- - `.golden.sha256`
149
-
150
- Tasks:
151
-
152
- - [x] Add explicit page attributes to the XML skeleton or document when an infinite/non-page canvas is appropriate.
153
- - [x] Explain how to calculate content bounds and choose `pageWidth` and `pageHeight` with consistent outer margins.
154
- - [x] Add guidance for resizing the canvas after layout changes.
155
- - [x] Define recommended minimum body and connector-label sizes while documenting legitimate exceptions such as compact ports.
156
- - [x] Add guidance for node padding, wrapping, line count, and long-label sizing.
157
- - [x] Explain that a 2000px full-diagram preview can make dense diagrams unreadable and should trigger layout simplification, page splitting, or focused review.
158
- - [x] Replace the conflicting troubleshooting iteration limit with the workflow's chosen limit.
159
- - [x] Update the golden hash intentionally after changing files under `assets/` and document why it changed.
160
-
161
- Acceptance criteria:
162
-
163
- - A model following the XML reference can produce an appropriately sized canvas without guessing.
164
- - Guidance and runtime workflow use identical review terminology and limits.
165
-
166
- ### 5. Keep only the latest review artifact and dispose of it safely
167
-
168
- Files:
169
-
170
- - `src/workflow.ts`
171
- - `src/drawio.ts`
172
- - `tests/drawio.test.ts`
173
-
174
- Tasks:
175
-
176
- - [x] Define predictable names for focused review artifacts.
177
- - [x] Remove the prior same-source preview only after its replacement export succeeds.
178
- - [x] Keep the previous preview when a replacement export fails.
179
- - [x] Serialize exports per source so concurrent preview calls cannot leave multiple latest artifacts.
180
- - [x] Confirm that the first successful final export removes the remaining latest preview.
181
- - [x] Preserve the final output if it resolves to the latest preview path.
182
- - [x] Report cleanup warnings without invalidating a successful replacement or final export.
183
- - [x] Add or update tests for focused preview replacement and cleanup behavior.
184
-
185
- Acceptance criteria:
186
-
187
- - Only the latest successful preview file for a source remains after each review iteration.
188
- - No review artifact remains after a successful final export unless cleanup explicitly reports a failure.
189
-
190
- ### 6. Update public documentation and the workflow example
191
-
192
- Files:
193
-
194
- - `README.md`
195
- - `docs/reference.md`
196
- - `CHANGELOG.md`
197
- - `example/drawme-how-it-works.drawio`
198
- - `example/drawme-how-it-works.drawio.png`
199
-
200
- Tasks:
201
-
202
- - [x] Replace the seven-step overview's broad review wording with the focused quality-pass workflow.
203
- - [x] Document which findings are deterministic and which require vision.
204
- - [x] Document that preview results include the image when implemented.
205
- - [x] Document validation-warning resolution and the final approval gate.
206
- - [ ] Update the workflow diagram to show the focused passes and regression check.
207
- - [ ] Validate and export the updated example with the DrawMe tools.
208
- - [x] Add an Unreleased changelog entry describing the quality-review improvements.
209
-
210
- Acceptance criteria:
211
-
212
- - Runtime guidance, agent reference, README, troubleshooting, and example diagram describe the same workflow.
213
-
214
- ### 7. Add scenario and regression coverage
215
-
216
- Files:
217
-
218
- - `tests/validate.test.ts`
219
- - `tests/drawio.test.ts`
220
- - `tests/integration.test.ts`
221
- - New fixtures under `tests/fixtures/` if needed
222
-
223
- Tasks:
224
-
225
- - [x] Add a diagram whose content exceeds the right and bottom canvas boundaries.
226
- - [x] Add a nested-container overflow case.
227
- - [x] Add missing and malformed edge-geometry cases.
228
- - [x] Add long-label and small-font cases for any accepted static readability checks.
229
- - [x] Add a dense but valid graph that demonstrates limits of waypoint-only connector analysis.
230
- - [x] Verify preview tool results contain an image block when the real CLI is available.
231
- - [x] Verify failure text never includes a stale image block.
232
- - [x] Verify workflow prompt construction and focused pass ordering without requiring the CLI.
233
- - [x] Keep real-CLI tests skippable when draw.io is unavailable.
234
-
235
- Acceptance criteria:
236
-
237
- - Every new behavior has deterministic regression coverage.
238
- - Visual limitations that cannot be asserted automatically are documented in test names or fixture notes.
239
-
240
- ### 8. Perform manual workflow verification
241
-
242
- Tasks:
243
-
244
- - [ ] Run `npm run validate`.
245
- - [ ] Run `/drawme` for a small five-node flowchart and verify the focused passes do not create unnecessary edits.
246
- - [ ] Run `/drawme` for a wide architecture diagram and verify canvas fit and preview readability.
247
- - [ ] Run `/drawme` for a dense graph with multiple connectors and verify connector review is isolated from typography review.
248
- - [ ] Run `/drawme` with long labels and nested containers.
249
- - [ ] Verify behavior on draw.io below version 30, where Mermaid conversion and ELK layout are unavailable.
250
- - [ ] Verify user feedback after automatic review triggers a targeted edit, revalidation, focused recheck, and final regression preview.
251
- - [ ] Verify final export removes all review previews and reports only retained deliverables.
252
-
253
- Acceptance criteria:
254
-
255
- - All automated checks pass.
256
- - The tested workflows require no manual intervention before the human approval step unless the documented correction limit is reached.
257
-
258
- ## Suggested implementation order
259
-
260
- 1. Workflow refactor and workflow-prompt tests.
261
- 2. Preview image attachment and export-result tests.
262
- 3. Edge-geometry and canvas-bound validation.
263
- 4. Authoring references and consistent limits.
264
- 5. Public documentation and workflow example.
265
- 6. Full automated and manual verification.
266
-
267
- ## Out of scope for the first implementation
268
-
269
- - A separate vision model or nested model call inside the extension.
270
- - Full OCR or pixel-level text measurement in TypeScript.
271
- - Perfect deterministic analysis of draw.io's automatic edge routing.
272
- - Arbitrary draw.io CLI flags or unbounded preview dimensions.
273
- - A persistent workflow state machine unless prompt-driven focused passes remain unreliable after these changes.