@xenonbyte/da-vinci-workflow 0.1.14 → 0.1.16

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +20 -2
  2. package/README.md +41 -1
  3. package/README.zh-CN.md +42 -1
  4. package/SKILL.md +22 -0
  5. package/commands/claude/dv/design.md +8 -0
  6. package/commands/claude/dv/verify.md +2 -0
  7. package/commands/codex/prompts/dv-design.md +8 -0
  8. package/commands/codex/prompts/dv-verify.md +1 -0
  9. package/commands/gemini/dv/design.toml +8 -0
  10. package/commands/gemini/dv/verify.toml +1 -0
  11. package/docs/mcp-aware-gate-implementation.md +291 -0
  12. package/docs/mcp-aware-gate-tests.md +244 -0
  13. package/docs/mcp-aware-gate.md +246 -0
  14. package/docs/mode-use-cases.md +7 -1
  15. package/docs/prompt-presets/README.md +3 -0
  16. package/docs/prompt-presets/desktop-app.md +19 -1
  17. package/docs/prompt-presets/mobile-app.md +19 -1
  18. package/docs/prompt-presets/tablet-app.md +19 -1
  19. package/docs/prompt-presets/web-app.md +19 -1
  20. package/docs/visual-assist-presets/README.md +5 -0
  21. package/docs/workflow-examples.md +24 -5
  22. package/docs/zh-CN/mcp-aware-gate-implementation.md +290 -0
  23. package/docs/zh-CN/mcp-aware-gate-tests.md +244 -0
  24. package/docs/zh-CN/mcp-aware-gate.md +249 -0
  25. package/docs/zh-CN/mode-use-cases.md +15 -4
  26. package/docs/zh-CN/prompt-presets/README.md +3 -0
  27. package/docs/zh-CN/prompt-presets/desktop-app.md +19 -1
  28. package/docs/zh-CN/prompt-presets/mobile-app.md +19 -1
  29. package/docs/zh-CN/prompt-presets/tablet-app.md +19 -1
  30. package/docs/zh-CN/prompt-presets/web-app.md +19 -1
  31. package/docs/zh-CN/visual-assist-presets/README.md +5 -0
  32. package/docs/zh-CN/workflow-examples.md +24 -5
  33. package/lib/audit.js +348 -0
  34. package/lib/cli.js +142 -1
  35. package/lib/mcp-runtime-gate.js +342 -0
  36. package/lib/pen-persistence.js +326 -0
  37. package/lib/pencil-preflight.js +438 -0
  38. package/package.json +5 -2
  39. package/references/artifact-templates.md +28 -1
  40. package/references/checkpoints.md +75 -1
  41. package/references/design-inputs.md +2 -1
  42. package/references/pencil-design-to-code.md +16 -0
  43. package/scripts/fixtures/complex-sample.pen +295 -0
  44. package/scripts/test-mcp-runtime-gate.js +199 -0
  45. package/scripts/test-pen-persistence.js +110 -0
  46. package/scripts/test-pencil-preflight.js +153 -0
@@ -0,0 +1,244 @@
1
+ # MCP-Aware Gate Test Design
2
+
3
+ This document defines how to test the future MCP-aware gate implementation.
4
+
5
+ It is a design for validation coverage, not a test implementation.
6
+
7
+ ## Test Goal
8
+
9
+ Prove that the MCP-aware gate:
10
+
11
+ - blocks false runtime completion states
12
+ - does not replace filesystem audit
13
+ - does not misclassify healthy runtime design sessions
14
+ - behaves predictably when MCP runtime facts are incomplete
15
+
16
+ ## Test Layers
17
+
18
+ The test plan should cover three layers.
19
+
20
+ ### 1. Evaluator unit tests
21
+
22
+ Test the pure runtime-gate evaluator against synthetic snapshot inputs.
23
+
24
+ Why:
25
+
26
+ - fastest feedback
27
+ - deterministic
28
+ - does not depend on a live Pencil session
29
+
30
+ ### 2. Runtime integration tests
31
+
32
+ Test the runtime-gate caller against real or fixture-backed MCP responses.
33
+
34
+ Why:
35
+
36
+ - proves that active editor and node reads are interpreted correctly
37
+
38
+ ### 3. End-to-end workflow tests
39
+
40
+ Test that runtime gate and filesystem audit cooperate correctly in realistic workflow states.
41
+
42
+ Why:
43
+
44
+ - prevents regressions where runtime gate passes but completion still lies
45
+
46
+ ## Core Test Categories
47
+
48
+ ### A. Healthy runtime source convergence
49
+
50
+ Expected:
51
+
52
+ - active editor is a named project-local `.pen`
53
+ - registered `.pen` path matches
54
+ - shell-visible `.pen` exists
55
+ - result is `PASS`
56
+
57
+ ### B. Live editor still `new`
58
+
59
+ Expected:
60
+
61
+ - source convergence is `BLOCK`
62
+ - completion is blocked even if screens exist in the live editor
63
+
64
+ ### C. Registered `.pen` path missing on disk
65
+
66
+ Expected:
67
+
68
+ - source convergence or completion status becomes `BLOCK`
69
+ - runtime gate does not treat the live editor alone as sufficient
70
+
71
+ ### D. Live screens exist but are not persisted
72
+
73
+ Example:
74
+
75
+ - active editor contains `Splash`, `Home`, `SafeBox`
76
+ - shell-visible `.pen` does not exist
77
+
78
+ Expected:
79
+
80
+ - runtime gate can prove screens exist
81
+ - source convergence is still `BLOCK`
82
+
83
+ ### E. Claimed anchor id missing
84
+
85
+ Example:
86
+
87
+ - `pencil-design.md` claims `mCZ1G`
88
+ - current live editor does not contain `mCZ1G`
89
+
90
+ Expected:
91
+
92
+ - screen presence is `BLOCK`
93
+
94
+ ### F. Screenshot target missing
95
+
96
+ Expected:
97
+
98
+ - review execution is `BLOCK`
99
+
100
+ ### G. Review blockers ignored
101
+
102
+ Example:
103
+
104
+ - screenshot review records blocker-level layout-hygiene issues
105
+ - workflow still marks anchor as approved
106
+
107
+ Expected:
108
+
109
+ - review execution is `BLOCK`
110
+
111
+ ### H. Source mismatch with explicit reconciliation
112
+
113
+ Example:
114
+
115
+ - active editor path and registered path differ
116
+ - `pencil-design.md` records a documented reconciliation
117
+
118
+ Expected:
119
+
120
+ - evaluator returns `WARN` or `PASS` only if the reconciliation rules are satisfied
121
+
122
+ ### I. No new Pencil edits yet
123
+
124
+ Expected:
125
+
126
+ - runtime gate may return `WARN` or partial result
127
+ - must not fabricate full `PASS`
128
+
129
+ ### J. Pencil MCP unavailable
130
+
131
+ Expected:
132
+
133
+ - runtime gate reports unavailable or skipped state
134
+ - workflow does not treat runtime gate as passed
135
+ - filesystem audit remains usable
136
+
137
+ ## Required End-to-End Scenarios
138
+
139
+ ### Scenario 1: Real failure pattern from Cipher
140
+
141
+ State:
142
+
143
+ - active editor is `new`
144
+ - live screens exist
145
+ - `.da-vinci/designs/` is polluted
146
+ - no shell-visible `.pen`
147
+
148
+ Expected:
149
+
150
+ - runtime gate blocks completion
151
+ - filesystem completion audit also fails
152
+
153
+ ### Scenario 2: Healthy redesign completion
154
+
155
+ State:
156
+
157
+ - active editor is the registered `.pen`
158
+ - anchor ids exist
159
+ - screenshot review exists
160
+ - shell-visible `.pen` exists
161
+ - completion audit passes
162
+
163
+ Expected:
164
+
165
+ - runtime gate passes
166
+ - completion audit passes
167
+ - terminal completion is allowed
168
+
169
+ ### Scenario 3: Runtime pass, filesystem fail
170
+
171
+ State:
172
+
173
+ - active editor is healthy
174
+ - shell-visible `.pen` exists
175
+ - but `.da-vinci/designs/` contains extra PNG or markdown files
176
+
177
+ Expected:
178
+
179
+ - runtime gate may pass
180
+ - filesystem completion audit fails
181
+ - terminal completion is blocked
182
+
183
+ ### Scenario 4: Filesystem pass, runtime fail
184
+
185
+ State:
186
+
187
+ - shell-visible `.pen` exists
188
+ - files look healthy
189
+ - active editor is still `new` or points elsewhere
190
+
191
+ Expected:
192
+
193
+ - runtime gate fails
194
+ - completion is blocked
195
+
196
+ ## Assertions That Must Exist
197
+
198
+ For every runtime-gate result, tests should assert:
199
+
200
+ - final status
201
+ - per-layer status
202
+ - which blocking condition fired
203
+ - whether completion would be allowed
204
+ - whether artifact recording shape stays stable
205
+
206
+ ## Artifact Recording Tests
207
+
208
+ Verify that runtime gate output:
209
+
210
+ - appends to `pencil-design.md`
211
+ - does not create a new artifact family
212
+ - does not write into `.da-vinci/designs/`
213
+ - does not overwrite unrelated sections
214
+
215
+ ## Regression Cases
216
+
217
+ These regressions should be covered:
218
+
219
+ 1. runtime gate accidentally behaves like a CLI-only audit
220
+ 2. runtime gate silently treats `new` as acceptable
221
+ 3. runtime gate treats PNG exports as source evidence
222
+ 4. runtime gate passes when anchor ids are missing
223
+ 5. runtime gate is skipped but reported as passed
224
+ 6. runtime gate writes ad hoc markdown files outside the allowed artifact path
225
+
226
+ ## Recommended Test Matrix
227
+
228
+ Minimum matrix:
229
+
230
+ - form factor: mobile first
231
+ - design stage: first Pencil write / approved anchor / terminal completion
232
+ - source state: healthy / `new` / diverged / missing `.pen`
233
+ - screen state: present / missing / stale ids
234
+ - review state: reviewed / missing / blocker ignored
235
+
236
+ ## Exit Criteria
237
+
238
+ The implementation should not be considered ready unless all of the following are true:
239
+
240
+ 1. evaluator unit tests cover all blocker branches
241
+ 2. at least one runtime integration test proves live editor detection works
242
+ 3. the Cipher-like failure scenario is blocked
243
+ 4. a healthy redesign scenario passes
244
+ 5. runtime gate plus filesystem audit together prevent false terminal completion
@@ -0,0 +1,246 @@
1
+ # MCP-Aware Gate Proposal
2
+
3
+ This document defines a proposed MCP-aware runtime gate for Da Vinci.
4
+
5
+ It is intentionally a design document, not an implementation commitment.
6
+
7
+ ## Status
8
+
9
+ - Design status: proposed
10
+ - Validation status: partially validated from real runtime observations
11
+ - Implementation status: not started
12
+
13
+ ## Why This Exists
14
+
15
+ The current filesystem audit closes one important gap:
16
+
17
+ - it can prove whether the project-local `.pen` file exists on disk
18
+ - it can prove whether `.da-vinci/designs/` is polluted
19
+ - it can prove whether exported screenshots were misplaced
20
+
21
+ But it cannot prove live MCP state such as:
22
+
23
+ - whether the active Pencil editor is still `new`
24
+ - whether the claimed anchor surfaces actually exist in the active editor
25
+ - whether the active editor and the registered project-local `.pen` source have converged
26
+
27
+ Those facts only exist at runtime inside the MCP-backed design session.
28
+
29
+ ## Validated Feasibility
30
+
31
+ The following facts have already been validated as observable:
32
+
33
+ 1. The active Pencil editor can be read through MCP.
34
+ 2. The top-level live nodes can be read through MCP.
35
+ 3. Specific screen node ids can be read through MCP.
36
+ 4. The shell-visible project state can be read separately through normal filesystem access.
37
+
38
+ This means Da Vinci can already compare:
39
+
40
+ - live editor truth
41
+ - live screen truth
42
+ - filesystem truth
43
+
44
+ That comparison is enough to support a first MCP-aware runtime gate.
45
+
46
+ ## Non-Goals
47
+
48
+ This proposal does not attempt to:
49
+
50
+ - replace the filesystem `da-vinci audit`
51
+ - expose MCP state directly through the CLI
52
+ - auto-repair live editor state into a persisted `.pen` file
53
+ - make implementation depend on undocumented Pencil session behavior
54
+
55
+ ## Design Principles
56
+
57
+ 1. MCP-aware gate is runtime-only.
58
+ 2. Filesystem audit remains the terminal persistence gate.
59
+ 3. Runtime gate blocks false progress; it does not auto-heal state.
60
+ 4. The design should only rely on facts already observed to be readable.
61
+ 5. The design should degrade cleanly when Pencil MCP is unavailable.
62
+
63
+ ## Placement In The Workflow
64
+
65
+ The MCP-aware gate should sit in two places:
66
+
67
+ 1. After the first successful Pencil write on a redesign pass.
68
+ 2. Before any terminal `design complete` or `workflow complete` claim.
69
+
70
+ It should not run on every trivial design operation.
71
+
72
+ ## Proposed Gate Layers
73
+
74
+ ### 1. Source Convergence Gate
75
+
76
+ Purpose:
77
+
78
+ - determine whether the live editor, registered `.pen` path, and shell-visible `.pen` file agree well enough to treat the design source as traceable
79
+
80
+ Inputs:
81
+
82
+ - active Pencil editor state from MCP
83
+ - registered `.pen` path from `design-registry.md`
84
+ - shell-visible `.pen` path under `.da-vinci/designs/`
85
+
86
+ Blocking conditions:
87
+
88
+ - active editor is still an unnamed live editor such as `new`
89
+ - active editor does not match the registered project-local source and the mismatch is not explicitly reconciled
90
+ - shell-visible `.pen` file does not exist after live Pencil work has already happened
91
+ - runtime session appears to be using a different source than the registered project-local source
92
+
93
+ Result:
94
+
95
+ - `PASS`: source is converged
96
+ - `WARN`: source is intentionally deferred but still traceable
97
+ - `BLOCK`: source of truth is not stable enough to continue
98
+
99
+ ### 2. Screen Presence Gate
100
+
101
+ Purpose:
102
+
103
+ - verify that claimed anchor surfaces actually exist in the active live editor
104
+
105
+ Inputs:
106
+
107
+ - node ids or screen ids recorded in `pencil-design.md`
108
+ - current top-level or targeted node reads from MCP
109
+
110
+ Blocking conditions:
111
+
112
+ - claimed anchor screen cannot be found in the active editor
113
+ - screenshot node id does not resolve in the current live document
114
+ - the design claims more approved anchor surfaces than the current editor can account for
115
+
116
+ Result:
117
+
118
+ - `PASS`: claimed screens exist
119
+ - `WARN`: some naming drift exists but mapping is still recoverable
120
+ - `BLOCK`: claimed design output cannot be traced to the live document
121
+
122
+ ### 3. Review Execution Gate
123
+
124
+ Purpose:
125
+
126
+ - verify that screenshot review was performed on the live surfaces that are being treated as approved
127
+
128
+ Inputs:
129
+
130
+ - reviewed screen ids from `pencil-design.md`
131
+ - screenshot targets used in the current design session
132
+ - resolved form-factor layout hygiene profile
133
+
134
+ Blocking conditions:
135
+
136
+ - a surface is treated as approved without any live screenshot review
137
+ - screenshot review flagged blocker-level layout hygiene issues but the workflow still marked the surface as passed
138
+ - review artifacts refer to screens that are not present in the active editor
139
+
140
+ Result:
141
+
142
+ - `PASS`: reviewed surfaces match live runtime state
143
+ - `WARN`: review exists but needs follow-up before expansion
144
+ - `BLOCK`: approval claim is not trustworthy
145
+
146
+ ## Runtime Output Shape
147
+
148
+ The gate should not invent a new artifact family.
149
+
150
+ Instead, it should append a short runtime section to `pencil-design.md` or another already valid change artifact:
151
+
152
+ ```md
153
+ ## MCP Runtime Gate
154
+ - Time:
155
+ - Active editor:
156
+ - Registered `.pen` path:
157
+ - Shell-visible `.pen` path:
158
+ - Reviewed screen ids:
159
+ - Source convergence: PASS | WARN | BLOCK
160
+ - Screen presence: PASS | WARN | BLOCK
161
+ - Review execution: PASS | WARN | BLOCK
162
+ - Notes:
163
+ ```
164
+
165
+ This keeps runtime evidence attached to the design pass instead of scattering it into ad hoc files.
166
+
167
+ ## Relationship To Filesystem Audit
168
+
169
+ The two systems have different jobs.
170
+
171
+ ### MCP-aware runtime gate
172
+
173
+ - checks live editor truth
174
+ - checks live screen truth
175
+ - checks runtime/source convergence before false progress spreads
176
+
177
+ ### Filesystem audit
178
+
179
+ - checks persisted project truth
180
+ - checks directory hygiene
181
+ - checks completion integrity
182
+
183
+ Expected terminal rule:
184
+
185
+ - do not report completion unless MCP-aware runtime gate passes and filesystem completion audit passes
186
+
187
+ ## Why This Should Not Be A CLI Feature First
188
+
189
+ The current CLI can only read filesystem state.
190
+
191
+ It has no MCP transport, no session identity, and no direct access to the live Pencil editor.
192
+
193
+ That makes a CLI-only MCP-aware gate structurally unreliable.
194
+
195
+ For now, the MCP-aware gate should be treated as an agent-executed runtime checkpoint, not a standalone CLI audit mode.
196
+
197
+ ## Failure Modes To Avoid
198
+
199
+ 1. Treating `new` as if it were a persisted `.pen` path.
200
+ 2. Treating exported PNG files as design-source evidence.
201
+ 3. Treating node ids from an old live document as if they still describe the current active editor.
202
+ 4. Silently reconciling runtime/source mismatches without recording that reconciliation.
203
+ 5. Auto-writing a `.pen` file from live state without an explicit workflow rule.
204
+
205
+ ## Minimum Viable Implementation Scope
206
+
207
+ The first implementation should stay narrow.
208
+
209
+ It should only:
210
+
211
+ 1. read active editor state
212
+ 2. read claimed anchor screen ids
213
+ 3. compare those facts against `design-registry.md` and the shell-visible `.pen` file
214
+ 4. record structured PASS/WARN/BLOCK output
215
+ 5. block completion when runtime truth and filesystem truth diverge
216
+
217
+ It should not:
218
+
219
+ - attempt automatic reconstruction
220
+ - mutate design files on its own beyond structured checkpoint recording
221
+ - add a new CLI command for live runtime state
222
+
223
+ ## Open Questions
224
+
225
+ These questions remain open and should be answered during implementation design, not before:
226
+
227
+ 1. Which existing command route should own the runtime gate call?
228
+ 2. Should the runtime evidence live in `pencil-design.md` only, or also in `design-registry.md`?
229
+ 3. How should a reconciled editor-path mismatch be recorded without encouraging drift?
230
+ 4. Should the gate run once per approved anchor or once per design phase?
231
+
232
+ ## Recommendation
233
+
234
+ Proceed only with a narrow agent-executed MCP-aware runtime gate.
235
+
236
+ Do not expand it into:
237
+
238
+ - CLI transport work
239
+ - automatic persistence repair
240
+ - generalized MCP session management
241
+
242
+ The validated path is:
243
+
244
+ 1. keep filesystem `audit` as the persistence and completion backstop
245
+ 2. add a runtime MCP-aware gate for source convergence and live screen presence
246
+ 3. require both layers before terminal completion is allowed
@@ -138,7 +138,9 @@ Generate DA-VINCI.md, proposal, specs, page map, Pencil-backed launch pages, bin
138
138
 
139
139
  8. create `pencil-design.md`
140
140
  - record the generated Pencil screens
141
- - ensure the active design is materialized into the registered `.pen` path under `.da-vinci/designs/`
141
+ - if no registered project-local `.pen` exists yet, persist the first approved MCP snapshot into the registered `.pen` path under `.da-vinci/designs/`
142
+ - if a registered project-local `.pen` already exists, reopen it for continuity but overwrite it from the current MCP snapshot after material live edits
143
+ - keep screenshot exports under `.da-vinci/changes/<change-id>/exports/` rather than `.da-vinci/designs/`
142
144
 
143
145
  9. create `pencil-bindings.md`
144
146
  - map implementation pages to Pencil pages
@@ -156,6 +158,7 @@ Generate DA-VINCI.md, proposal, specs, page map, Pencil-backed launch pages, bin
156
158
  - `DA-VINCI.md` exists and is stable
157
159
  - every core page exists in `page-map.md`
158
160
  - every implementation page has a Pencil counterpart or an explicit exception
161
+ - the registered project-local `.pen` file is shell-visible and not just a live editor session
159
162
  - `task checkpoint` passes
160
163
 
161
164
  ### Best fit
@@ -353,8 +356,11 @@ Register the design sources, extract DA-VINCI.md from them, bind covered pages,
353
356
  - for complex products, get 1-3 anchor surfaces through screenshot review before expanding the rest of the redesign
354
357
  - for each anchor surface, explain briefly how the new composition differs from the current layout grouping
355
358
  - do not auto-pass screenshot review if the analysis reports hierarchy, spacing, clarity, inconsistency, or unresolved-placeholder issues
359
+ - do not record screenshot review as "looks good" without an explicit `PASS`, `WARN`, or `BLOCK`, issue list, and revision outcome
356
360
  - define a small shared primitive family from the approved anchor surfaces before broad page expansion
357
361
  - use only Pencil-supported properties; do not rely on web-only props such as `flex` or `margin`
362
+ - preflight non-trivial `batch_design` operation strings when shell access is available
363
+ - if the same anchor surface rolls back twice, switch to micro-batches of 6 or fewer operations until a clean schema-safe pass succeeds
358
364
 
359
365
  For redesign work:
360
366
 
@@ -13,6 +13,8 @@ Recommended flow:
13
13
  3. choose the prompt variant that matches project complexity and delivery intent
14
14
  4. copy both into your workflow setup
15
15
  5. tighten the prompt further only when the project has unusual truth sources or platform constraints
16
+ 6. when Pencil MCP is active, prefer the redesign prompts that explicitly require an MCP runtime gate plus a completion audit before terminal completion claims
17
+ 7. for project-local `.pen` persistence, prefer prompts that distinguish first-run snapshot creation from resume/overwrite persistence instead of relying on interactive `save()`
16
18
 
17
19
  Available presets:
18
20
 
@@ -26,6 +28,7 @@ Design rule:
26
28
  - prompt presets define workflow intent, decomposition rules, and truth-source handling
27
29
  - visual-assist presets define UI-design helper preferences
28
30
  - form-factor-specific layout hygiene remains a separate hard gate that screenshot review must apply before a screen passes
31
+ - MCP runtime gate and `da-vinci audit --mode completion ...` remain workflow gates, not `Visual Assist` configuration
29
32
  - use both together for the strongest result
30
33
 
31
34
  Each scene preset should now include:
@@ -28,6 +28,9 @@ Existing code is the behavior source of truth, not the layout truth.
28
28
  Preserve current behavior, flows, integrations, and validation rules unless explicitly required otherwise.
29
29
  Inventory the current workspaces, dialogs, overlays, and important states before Pencil work.
30
30
  Use the Visual Assist preferences declared in DA-VINCI.md.
31
+ If no registered project-local `.pen` exists yet, persist the first approved MCP snapshot under `.da-vinci/designs/` instead of relying on interactive `save()`.
32
+ If Pencil MCP is active, run the MCP runtime gate after the first successful Pencil write and record it in `pencil-design.md`.
33
+ Before reporting `design complete` or `workflow complete`, require both the MCP runtime gate and `da-vinci audit --mode completion --change <change-id> <project-path>` to pass.
31
34
  Do not pass design checkpoint if the result is just a boxed-up recolor of the old UI or if workspace hierarchy remains unclear.
32
35
  Persist project-local Pencil files under .da-vinci/designs/.
33
36
  ```
@@ -41,12 +44,22 @@ Existing code is the behavior source of truth, not the layout truth.
41
44
  Preserve current behavior, flows, integrations, and validation rules unless explicitly required otherwise.
42
45
  Inventory primary workspaces, side panels, inspectors, dialogs, settings flows, overlays, and materially different states before broad Pencil work.
43
46
  Decompose complex screens into primary surfaces, secondary surfaces, overlays, and implementation surfaces.
47
+ Create the required discovery and design-source artifacts in their standard locations before the first anchor surface.
44
48
  Use the Visual Assist preferences declared in DA-VINCI.md.
45
49
  Treat the resolved primary visual adapter as the first-pass design lead.
46
50
  Use Pencil guides only as workspace constraints, not as the design direction.
47
51
  Do not start with broad multi-screen scaffolding.
48
52
  Design 1-3 anchor surfaces first, review screenshots, then expand.
49
53
  Apply the form-factor-specific layout hygiene rules for desktop before passing screenshot review.
54
+ Before non-trivial `batch_design` calls, preflight the Pencil operations when shell access is available.
55
+ If the same anchor surface rolls back twice, switch to micro-batches of 6 or fewer operations until a clean schema-safe pass succeeds.
56
+ Run `da-vinci audit --mode integrity <project-path>` after the first successful Pencil write before broad expansion continues.
57
+ If Pencil MCP is active, run the MCP runtime gate after the first successful Pencil write and record it in `pencil-design.md`.
58
+ If no registered project-local `.pen` exists yet, persist the first approved MCP snapshot under `.da-vinci/designs/`; if one already exists, reopen it for continuity but overwrite it from the current MCP snapshot after material live edits.
59
+ Write exported screenshots under `.da-vinci/changes/<change-id>/exports/` only.
60
+ Record screenshot review with explicit `PASS` / `WARN` / `BLOCK`, issue list, and revision outcome; "looks good" is not enough.
61
+ Do not report completion if the registered `.pen` source exists only in memory or only as exported PNGs.
62
+ Before reporting `design complete` or `workflow complete`, require both the MCP runtime gate and `da-vinci audit --mode completion --change <change-id> <project-path>` to pass.
50
63
  Do not pass design checkpoint if the result is a repeated placeholder scaffold, flat panel soup, or a recolor of the old desktop shell.
51
64
  Persist project-local Pencil files under .da-vinci/designs/.
52
65
  ```
@@ -63,6 +76,9 @@ Decompose complex screens into real design surfaces before Pencil work.
63
76
  Use the Visual Assist preferences declared in DA-VINCI.md.
64
77
  If the product is complex, design 1-3 anchor surfaces first, review screenshots, then expand.
65
78
  Stop after DA-VINCI.md, design-registry.md, page-map.md, proposal.md, specs, design.md, pencil-design.md, pencil-bindings.md, and tasks.md.
79
+ If no registered project-local `.pen` exists yet, persist the first approved MCP snapshot under `.da-vinci/designs/` instead of relying on interactive `save()`.
80
+ If Pencil MCP is active, run the MCP runtime gate after the first successful Pencil write and record it in `pencil-design.md`.
81
+ Before reporting `design complete`, require both the MCP runtime gate and `da-vinci audit --mode completion --change <change-id> <project-path>` to pass.
66
82
  Do not start code changes yet.
67
83
  ```
68
84
 
@@ -73,8 +89,10 @@ $da-vinci use continue for this existing desktop-product redesign workflow.
73
89
 
74
90
  Use the existing Da Vinci artifacts in this project.
75
91
  Do not restart discovery unless an artifact is missing or clearly wrong.
76
- Keep the registered project-local Pencil source under .da-vinci/designs/ as the design source of truth.
92
+ Keep the registered project-local Pencil source under .da-vinci/designs/ as the design source of truth. Reopen that file for continuity, but after material live edits persist a fresh MCP snapshot back to the same path instead of assuming interactive `save()` flushed it.
77
93
  If the redesign is complex, continue from the approved anchor surfaces instead of restarting broad scaffolding.
94
+ If Pencil MCP is active and this session performs new Pencil writes, rerun the MCP runtime gate and record the refreshed result in `pencil-design.md`.
95
+ Before reporting `design complete` or `workflow complete`, require both the MCP runtime gate and `da-vinci audit --mode completion --change <change-id> <project-path>` to pass.
78
96
  Continue into the next unfinished stage and do not stop at tasks.md when the active intent is full-delivery.
79
97
  ```
80
98
 
@@ -28,6 +28,9 @@ Existing code is the behavior source of truth, not the layout truth.
28
28
  Preserve business logic, navigation, permissions, integrations, validations, and state transitions unless explicitly required otherwise.
29
29
  Inventory the current screens and important states before Pencil work.
30
30
  Use the Visual Assist preferences declared in DA-VINCI.md.
31
+ If no registered project-local `.pen` exists yet, persist the first approved MCP snapshot under `.da-vinci/designs/` instead of relying on interactive `save()`.
32
+ If Pencil MCP is active, run the MCP runtime gate after the first successful Pencil write and record it in `pencil-design.md`.
33
+ Before reporting `design complete` or `workflow complete`, require both the MCP runtime gate and `da-vinci audit --mode completion --change <change-id> <project-path>` to pass.
31
34
  Do not pass design checkpoint if the result is a skin-swap of the old UI, a generic card grid, or a weak mobile hierarchy.
32
35
  Persist project-local Pencil files under .da-vinci/designs/.
33
36
  ```
@@ -41,6 +44,7 @@ Existing code is the behavior source of truth, not the layout truth.
41
44
  Preserve business logic, navigation, permissions, integrations, validations, and state transitions unless explicitly required otherwise.
42
45
  Inventory activities, fragments, tabs, dialogs, bottom sheets, nested flows, overlays, and materially different states before broad Pencil work.
43
46
  Decompose complex screens into subpages, overlays, materially different states, and implementation surfaces.
47
+ Create the required discovery and design-source artifacts in their standard locations before the first anchor surface.
44
48
  Use the Visual Assist preferences declared in DA-VINCI.md.
45
49
  Treat the resolved primary visual adapter as the first-pass design lead.
46
50
  State the resolved primary visual adapter explicitly in the log and name any requested adapters that are unavailable.
@@ -51,9 +55,18 @@ Design 1-3 anchor surfaces first, review screenshots, then expand.
51
55
  For each anchor surface, explain how the new composition differs structurally from the current layout.
52
56
  Do not treat screenshot analysis as an automatic pass if it reports hierarchy, spacing, clarity, or inconsistency issues.
53
57
  Apply the form-factor-specific layout hygiene rules for mobile before passing screenshot review.
58
+ Before non-trivial `batch_design` calls, preflight the Pencil operations when shell access is available.
59
+ If the same anchor surface rolls back twice, switch to micro-batches of 6 or fewer operations until a clean schema-safe pass succeeds.
54
60
  Use only Pencil-supported properties; do not use web-only props like flex or margin.
55
61
  Verify the registered project-local `.pen` file exists as a shell-visible file after the first Pencil write.
62
+ Run `da-vinci audit --mode integrity <project-path>` after that first successful Pencil write before broad expansion continues.
63
+ If Pencil MCP is active, run the MCP runtime gate after the first successful Pencil write and record it in `pencil-design.md`.
64
+ If no registered project-local `.pen` exists yet, persist the first approved MCP snapshot under `.da-vinci/designs/`; if one already exists, reopen it for continuity but overwrite it from the current MCP snapshot after material live edits.
56
65
  Keep non-`.pen` workflow artifacts out of `.da-vinci/designs/`.
66
+ Write exported screenshots under `.da-vinci/changes/<change-id>/exports/` only.
67
+ Record screenshot review with explicit `PASS` / `WARN` / `BLOCK`, issue list, and revision outcome; "looks good" is not enough.
68
+ Do not report completion if the registered `.pen` source exists only in memory or only as exported PNGs.
69
+ Before reporting `design complete` or `workflow complete`, require both the MCP runtime gate and `da-vinci audit --mode completion --change <change-id> <project-path>` to pass.
57
70
  Define shared primitives from the approved anchor surfaces before broad page expansion.
58
71
  Do not pass design checkpoint if the result is a skin-swap of the old UI, a generic card grid, repeated placeholder templates, or weak visual anchors.
59
72
  Persist project-local Pencil files under .da-vinci/designs/.
@@ -71,6 +84,9 @@ Decompose complex screens into real design surfaces before Pencil work.
71
84
  Use the Visual Assist preferences declared in DA-VINCI.md.
72
85
  If the app is complex, design 1-3 anchor surfaces first, review screenshots, then expand.
73
86
  Stop after DA-VINCI.md, design-registry.md, page-map.md, proposal.md, specs, design.md, pencil-design.md, pencil-bindings.md, and tasks.md.
87
+ If no registered project-local `.pen` exists yet, persist the first approved MCP snapshot under `.da-vinci/designs/` instead of relying on interactive `save()`.
88
+ If Pencil MCP is active, run the MCP runtime gate after the first successful Pencil write and record it in `pencil-design.md`.
89
+ Before reporting `design complete`, require both the MCP runtime gate and `da-vinci audit --mode completion --change <change-id> <project-path>` to pass.
74
90
  Do not start code changes yet.
75
91
  ```
76
92
 
@@ -81,8 +97,10 @@ $da-vinci use continue for this existing mobile-app redesign workflow.
81
97
 
82
98
  Use the existing Da Vinci artifacts in this project.
83
99
  Do not restart discovery unless an artifact is missing or clearly wrong.
84
- Keep the registered project-local Pencil source under .da-vinci/designs/ as the design source of truth.
100
+ Keep the registered project-local Pencil source under .da-vinci/designs/ as the design source of truth. Reopen that file for continuity, but after material live edits persist a fresh MCP snapshot back to the same path instead of assuming interactive `save()` flushed it.
85
101
  If the redesign is complex, keep the anchor-first flow until the design checkpoint passes.
102
+ If Pencil MCP is active and this session performs new Pencil writes, rerun the MCP runtime gate and record the refreshed result in `pencil-design.md`.
103
+ Before reporting `design complete` or `workflow complete`, require both the MCP runtime gate and `da-vinci audit --mode completion --change <change-id> <project-path>` to pass.
86
104
  Continue into the next unfinished stage and do not stop at tasks.md when the active intent is full-delivery.
87
105
  ```
88
106