@xenonbyte/da-vinci-workflow 0.2.4 → 0.2.6

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 (42) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +15 -9
  3. package/README.zh-CN.md +16 -9
  4. package/SKILL.md +45 -704
  5. package/docs/dv-command-reference.md +33 -5
  6. package/docs/execution-chain-migration.md +14 -3
  7. package/docs/maintainer-bootstrap.md +102 -0
  8. package/docs/pencil-rendering-workflow.md +1 -1
  9. package/docs/prompt-entrypoints.md +1 -0
  10. package/docs/skill-contract-maintenance.md +14 -0
  11. package/docs/skill-usage.md +31 -0
  12. package/docs/workflow-overview.md +40 -5
  13. package/docs/zh-CN/dv-command-reference.md +31 -5
  14. package/docs/zh-CN/maintainer-bootstrap.md +101 -0
  15. package/docs/zh-CN/pencil-rendering-workflow.md +1 -1
  16. package/docs/zh-CN/prompt-entrypoints.md +1 -0
  17. package/docs/zh-CN/skill-usage.md +30 -0
  18. package/docs/zh-CN/workflow-overview.md +38 -5
  19. package/lib/audit.js +19 -0
  20. package/lib/cli/helpers.js +104 -0
  21. package/lib/cli/lint-family.js +56 -0
  22. package/lib/cli/verify-family.js +79 -0
  23. package/lib/cli.js +143 -172
  24. package/lib/gate-utils.js +56 -0
  25. package/lib/install.js +134 -6
  26. package/lib/lint-bindings.js +41 -28
  27. package/lib/lint-spec.js +403 -109
  28. package/lib/lint-tasks.js +571 -21
  29. package/lib/maintainer-readiness.js +317 -0
  30. package/lib/planning-parsers.js +198 -2
  31. package/lib/planning-quality-utils.js +81 -0
  32. package/lib/planning-signal-freshness.js +205 -0
  33. package/lib/scaffold.js +454 -23
  34. package/lib/scope-check.js +751 -82
  35. package/lib/sidecars.js +396 -1
  36. package/lib/task-review.js +2 -1
  37. package/lib/utils.js +34 -0
  38. package/lib/verify.js +1160 -88
  39. package/lib/workflow-persisted-state.js +52 -32
  40. package/lib/workflow-state.js +1187 -249
  41. package/package.json +1 -1
  42. package/references/skill-workflow-detail.md +66 -0
package/SKILL.md CHANGED
@@ -29,742 +29,83 @@ That means:
29
29
  - treat checkpoints as internal execution guards, not approval steps
30
30
  - stop only when a true blocking condition exists
31
31
 
32
- Treat execution intent as `full-delivery` by default when the user asks to:
33
-
34
- - complete development
35
- - implement the generated design
36
- - redesign the whole product UI
37
- - finish the project or finish the refresh
38
-
39
- Do not stop at `tasks.md` in those cases.
40
-
41
- Continue automatically through:
42
-
43
- - mode selection
44
- - project visual-contract detection
45
- - requirement breakdown
46
- - page mapping
47
- - design input collection
48
- - design source registration
49
- - Pencil design work
50
- - page-to-Pencil binding
51
- - task generation
52
- - implementation
53
- - verification
54
-
55
- If `tasks.md` exists and the active request is `full-delivery`:
56
-
57
- - treat `task checkpoint` as the handoff into implementation, not as an end state
58
- - start Task Group 1 automatically after a `PASS`
59
- - start Task Group 1 automatically after a `WARN` unless the warning changes the truth of behavior, source mapping, or permissions
60
- - do not emit "next recommended step: start Task Group 1" as a terminal outcome
61
- - instead continue into code changes and report progress by task group
32
+ Treat execution intent as `full-delivery` by default when the user asks to complete/finish development.
33
+ Do not stop at `tasks.md` unless the user explicitly asks for planning-only behavior.
62
34
 
63
35
  Stop and ask only when:
64
36
 
65
37
  - the user explicitly interrupts
66
38
  - a missing input would materially change the result
67
- - an external permission, authentication step, or protected environment is required
39
+ - an external permission/authentication/protected environment step is required
68
40
  - source artifacts conflict badly enough that continuing would guess the truth
69
41
  - a destructive action would change the project baseline significantly
70
42
 
71
- Do not stop merely because:
72
-
73
- - some pages are still out of scope
74
- - a future follow-up spec may be needed for untouched behavior
75
- - a project-local `.pen` export is still pending for traceability, unless that missing file would make the active design source ambiguous
76
-
77
- Those are warnings unless they prevent safe implementation of the current in-scope work.
78
-
79
- ## Next-Step Recommendation Discipline
43
+ ## Route Discipline
80
44
 
81
- When Da Vinci reports a "next recommended step" or offers route suggestions, make the recommendation stateful rather than listing every possible command as if they were equally valid.
45
+ When Da Vinci reports a next recommended step”, keep it stateful and singular:
82
46
 
83
- Use this order:
84
-
85
- - if discovery or design-source artifacts are still missing, recommend the missing discovery or design work first
47
+ - if discovery or design-source artifacts are missing, recommend discovery/design work first
86
48
  - if design is still blocking, recommend `design`
87
- - if design is ready enough for implementation planning but `.da-vinci/changes/<change-id>/tasks.md` does not exist yet, recommend `tasks`
88
- - if `tasks.md` exists and `task checkpoint` is at least `PASS` or an explicitly accepted `WARN`, recommend `build`
89
- - if implementation is already underway or complete enough to check drift, recommend `verify`
49
+ - if design is ready but `tasks.md` does not exist, recommend `tasks`
50
+ - if `tasks.md` exists and task checkpoint is at least `PASS` (or accepted `WARN`), recommend `build`
51
+ - if implementation is underway or done enough to check drift, recommend `verify`
90
52
 
91
53
  Hard rules:
92
54
 
93
- - do not present `build` as a co-equal next step when `tasks.md` does not exist yet
94
- - do not present `build` as the primary next step immediately after design completion unless task generation is already done and implementation readiness is clear
95
- - if design is complete but more in-scope surfaces still need design work, `design` may remain an optional branch, but `tasks` stays the primary next step before `build`
96
- - if multiple commands are shown, clearly mark only one as the primary next step for the current workflow state
55
+ - do not present `build` as co-equal next step when `tasks.md` does not exist
56
+ - do not present `build` immediately after design completion when task generation is still missing
57
+ - if multiple commands are shown, clearly mark one primary route
97
58
 
98
59
  ## Invocation Model
99
60
 
100
61
  Canonical workflow name is `da-vinci`.
101
62
 
102
63
  - Codex preferred: `$da-vinci <request>`
103
- - Claude and Gemini preferred: `/da-vinci <request>` when platform adapters exist
104
- - For Codex helper intents, prefer natural-language patterns:
105
- - `$da-vinci use intake for <project situation>`
106
- - `$da-vinci use prompt for <known scenario>`
107
- - `$da-vinci use continue for <existing workflow state>`
108
- - Claude and Gemini helper routes remain:
109
- - `/dv:intake`, `/dv:prompt`, `/dv:continue`
110
- - Natural-language invocation remains the default path
111
-
112
- ## Prompt Entry Routes
113
-
114
- Use these helper actions when the user needs help entering or resuming the workflow:
115
-
116
- 1. `intake`
117
- - use when the user describes a project situation but does not know how to phrase the best Da Vinci request
118
- - output:
119
- - recommended mode
120
- - recommended delivery intent
121
- - one primary executable workflow prompt
122
- - one more conservative prompt when useful
123
- - one continuation prompt when the workflow is likely to pause
124
- - missing inputs that would materially change the result
125
- - `intake` should usually generate a main workflow prompt, not a `build`-only prompt
126
-
127
- 2. `prompt`
128
- - use when the user explicitly asks for a prompt template or scenario-specific prompt
129
- - generate one or more copy-ready prompts aligned to the stated scenario
130
- - keep prompts operational, not generic advice
131
-
132
- 3. `continue`
133
- - use when workflow artifacts already exist and the user needs to resume
134
- - inspect the current artifacts first
135
- - output:
136
- - detected workflow state
137
- - gaps or blockers
138
- - one executable continuation prompt
139
- - contextual recovery notes from recent checkpoint deltas when consistent with current artifacts
140
- - do not restart discovery if the artifacts already provide enough truth
141
- - do not default to `build` unless the project is clearly implementation-ready
142
- - determine route selection from artifact and checkpoint truth first; contextual deltas are auxiliary and must not override routing
143
- - if contextual deltas conflict with current artifacts, ignore them for routing and record the conflict
144
-
145
- ## V2 Mode Selection
146
-
147
- Select one workflow mode before producing artifacts.
148
-
149
- Supported modes:
64
+ - Claude/Gemini preferred: `/da-vinci <request>` when adapters exist
65
+ - Helper routes: `intake`, `prompt`, `continue`
150
66
 
151
- 1. `greenfield-spec`
152
- - use when the project starts from a clear product or page requirement
67
+ `intake` should usually produce a main workflow prompt, not a `build`-only prompt.
68
+ `continue` must inspect existing artifacts first and route from current truth instead of restarting discovery by default.
153
69
 
154
- 2. `greenfield-brainstorm`
155
- - use when the project starts from multiple rounds of raw ideas and needs synthesis first
70
+ ## Supported Modes
156
71
 
157
- 3. `redesign-from-code`
158
- - use when an existing product already has code and the UI must be redesigned globally or broadly
72
+ Select one mode before producing artifacts:
159
73
 
74
+ 1. `greenfield-spec`
75
+ 2. `greenfield-brainstorm`
76
+ 3. `redesign-from-code`
160
77
  4. `overhaul-from-code`
161
- - use when an existing product needs a broad system-level rewrite where flows, logic, information architecture, and UI may all change
162
-
163
78
  5. `feature-change`
164
- - use when an existing product needs a scoped requirement change, page addition, or page update
165
-
166
- If the user does not specify a mode:
167
-
168
- - choose `greenfield-spec` for new projects with clear requirements
169
- - choose `greenfield-brainstorm` for exploratory new product ideation
170
- - choose `redesign-from-code` for broad UI replacement on existing code
171
- - choose `overhaul-from-code` for broad existing-project rewrites where old code is no longer the full behavior truth
172
- - choose `feature-change` for incremental product work
173
-
174
- ## Design Input Collection
175
-
176
- Before generating new Pencil designs for a greenfield project, collect or infer:
177
-
178
- 0. project visual contract
179
- - detect whether `DA-VINCI.md` already exists
180
- - if it exists, treat it as the visual baseline for future pages
181
- - if it does not exist, generate it from stable user preferences, existing project signals, or inferred defaults before broad Pencil page generation
182
- - if it declares preferred visual adapters, treat them as optional design-assist preferences, not as behavior truth
183
-
184
- 1. product form factor
185
- - desktop software
186
- - web app
187
- - tablet
188
- - mobile app
189
-
190
- 2. design preference
191
- - visual tone
192
- - density
193
- - brand direction
194
- - light or dark preference
195
-
196
- 3. design constraints
197
- - existing brand rules
198
- - existing design system
199
- - responsive priority
200
- - delivery constraints
201
-
202
- Use this priority order:
203
-
204
- 1. `DA-VINCI.md`
205
- 2. existing workflow artifacts
206
- 3. project-local config or project codebase signals
207
- 4. explicit user answers
208
- 5. short clarification questions
209
-
210
- Do not repeatedly ask for inputs that are already stable in the artifacts.
211
-
212
- Treat visual adapters as optional design-assist layers.
213
-
214
- - resolve them from the user request first, then `DA-VINCI.md`, then locally available skills
215
- - do not assume cross-platform equivalence between near-name adapters such as `frontend-skill` and `frontend-design`; only resolve adapters that are explicitly named and actually installed in the current environment
216
- - record which requested adapters were available, which were unavailable, and which adapter became the resolved primary adapter
217
- - when `DA-VINCI.md` or the request declares `Preferred adapters`, the resolved primary adapter must actively lead first-pass design reasoning instead of being recorded only for traceability
218
- - when a resolved primary adapter is available, state that runtime resolution explicitly before the first anchor-screen design pass and let it drive the visual thesis, content plan, and interaction thesis
219
- - use them to improve visual contract quality, composition, hierarchy, spacing, and motion guidance
220
- - use Pencil guides and platform constraints as buildability aids only; they must not replace the resolved primary adapter as the art-direction source
221
- - do not let them redefine behavior, page truth, route truth, or acceptance rules
222
- - if a requested adapter is unavailable locally, continue with native Da Vinci design rules and record the fallback
223
-
224
- ## Default Workflow
225
-
226
- Run the workflow in this order:
227
-
228
- 1. Select the active mode
229
- 2. Build the correct source artifacts for that mode
230
- 3. Detect or generate `DA-VINCI.md` as the project visual contract
231
- 4. Collect design inputs, prefer project-local `.pen` files under `.da-vinci/designs/`, and register available design sources
232
- 5. Define or discover the project page map
233
- 6. Create or update Pencil designs for the required pages
234
- 7. Bind implementation pages to Pencil pages
235
- 8. Read Pencil design data through MCP
236
- 9. Generate implementation tasks
237
- 10. Implement code from requirements plus Pencil data
238
- 11. Verify behavior drift and design drift before closing the change
239
-
240
- Default completion rule:
241
-
242
- - if the request is `plan-only`, stop after planning artifacts
243
- - if the request is `design-only`, stop after design artifacts and bindings
244
- - otherwise assume `full-delivery` and continue through implementation and verification
245
-
246
- Do not report `design complete`, `workflow complete`, or any equivalent terminal state unless the completion gate in `references/checkpoints.md` is satisfied.
247
- When shell access is available, prefer `da-vinci audit --mode integrity <project-path>` during active workflow work and `da-vinci audit --mode completion --change <change-id> <project-path>` before any terminal completion claim.
248
-
249
- ## Pencil Generation Rules
250
-
251
- During active Pencil work:
252
-
253
- - do not begin anchor-surface generation until the required discovery and design-source artifacts exist in their standard locations for the active mode
254
- - keep `.da-vinci/designs/` reserved for project-local `.pen` files; do not write workflow markdown such as inventories, proposals, or checkpoints into that directory
255
- - on `redesign-from-code`, write a short structural-delta note for each anchor surface explaining how the new composition differs from the current XML or layout grouping
256
- - when shell access is available, preflight non-trivial `batch_design` operation strings before sending them to Pencil
257
- - prefer 12 or fewer operations on anchor-surface batches; if the same anchor surface rolls back twice, switch to micro-batches of 6 or fewer operations until a clean schema-safe pass succeeds
258
- - do not rely on headless interactive `save()` as the persistence truth; when live MCP edits exist, persist project-local `.pen` files from MCP-readable document snapshots
259
- - use the session wrapper commands on autonomous runs:
260
- `da-vinci pencil-session begin --project <project-path> --pen <path>`
261
- `da-vinci pencil-session persist --project <project-path> --pen <path> --nodes-file <batch-get-json> --variables-file <get-variables-json> --version <version>`
262
- `da-vinci pencil-session end --project <project-path> --pen <path> --nodes-file <batch-get-json> --variables-file <get-variables-json> --version <version>`
263
- - when multiple `.pen` sources exist (for example external backups), run `da-vinci check-pen-baseline --pen <project-pen> --baseline <other-pen>` before a new `pencil-session begin`
264
- - if baseline hashes diverge, do not treat the previous `persist` success as global freshness; confirm source priority explicitly (`--prefer-source`) and sync the chosen source into the project-local `.pen` before new edits
265
- - use `da-vinci sync-pen-source --from <preferred-source> --to <project-pen>` when an external source is selected as latest and must be materialized into the project-local baseline
266
- - before the first Pencil edit on a redesign pass, begin a Pencil session so the registered project-local `.pen` exists before editing and the global Pencil lock is held for that project
267
- - acquire the global Pencil lock before MCP write operations on a project and release it after the write phase so two projects do not compete for the same active editor
268
- - when a registered project-local `.pen` already exists, reopen it for continuity, but after material live edits persist a fresh MCP snapshot back to that same path instead of assuming live edits were flushed automatically
269
- - `da-vinci snapshot-pen` is a disk-to-disk utility for rebuilding an existing `.pen`; do not use it as live-edit persistence
270
- - use `da-vinci write-pen --output <path> --nodes-file <batch-get-json> --variables-file <get-variables-json> --version <version> --verify-open` to atomically write the registered project-local `.pen` from MCP snapshot data
271
- - after writing the project-local `.pen`, run `da-vinci check-pen-sync --pen <path> --nodes-file <batch-get-json> --variables-file <get-variables-json> --version <version>` before treating the disk source as current
272
- - completion audit expects a recorded Pencil session state under `.da-vinci/state/pencil-session.json`; do not bypass the session wrapper on autonomous runs
273
- - after the first successful Pencil write, verify that the registered project-local `.pen` path exists as a shell-visible file before treating the design source as persistent
274
- - after the first successful Pencil write, run `da-vinci audit --mode integrity <project-path>` when shell access is available before broad expansion continues
275
- - after the first successful Pencil write, run the MCP runtime gate when Pencil MCP is available and record the result in `pencil-design.md`
276
- - if the workflow already has a registered `.pen`, do not send Pencil write operations with an empty `filePath`
277
- - do not treat an unnamed live editor such as `new` as a persisted project design source; reconcile it to the registered project-local `.pen` path before the design pass is considered traceable
278
- - use only Pencil-supported properties; do not emit web- or CSS-only layout properties such as `flex` or `margin`
279
- - if unsupported Pencil properties cause repeated rolled-back batches on the same anchor surface, treat that pass as unstable and fix the schema usage before expanding further
280
- - after any rolled-back batch or structure-changing edit, refresh the live node structure before descendant-targeted follow-up operations; do not assume stale ids, bindings, or parent relationships are still valid
281
- - on complex redesigns, turn approved anchor surfaces into a small shared primitive family before broad page expansion
282
- - apply the resolved form-factor-specific layout hygiene profile before passing screenshot review on any anchor surface or other approval candidate
283
- - exported screenshots are review artifacts only; place them under `.da-vinci/changes/<change-id>/exports/` and never treat them as a substitute for the project-local `.pen` source
284
- - screenshot review is binding: if the review calls out hierarchy, spacing, clarity, inconsistency, or unresolved-placeholder issues, revise the screen before treating the checkpoint as `PASS`
285
- - screenshot review must record an explicit `PASS`, `WARN`, or `BLOCK` plus the concrete issue list and revision outcome; phrases such as "looks good" do not count as review evidence
286
- - if `DA-VINCI.md` declares `Design-supervisor reviewers`, run an explicit review pass with those reviewer skills on the approved anchor set, then persist the structured result with `da-vinci supervisor-review --project <project-path> --change <change-id> --run-reviewers --write` (or the compatibility alias `design-supervisor review --run-reviewers --write`)
287
- - keep `Design-supervisor reviewers` separate from `Preferred adapters`; adapters lead the design pass, reviewers judge whether the final style quality is strong enough to expand or implement
288
- - when `design-supervisor review` is active, review screenshots together with Pencil theme variables, `visual-thesis.md`, `content-plan.md`, and `interaction-thesis.md`; record `Configured reviewers`, `Executed reviewers`, `Review source`, explicit `PASS`/`WARN`/`BLOCK`, issue list, and revision outcome in `pencil-design.md`
289
- - do not hand-write ad-hoc headings such as `## Design-Supervisor Review (Round X Attempt)`; use `da-vinci supervisor-review --write` (or overwrite the canonical `## Design-Supervisor Review` block) so audit can consume structured evidence deterministically
290
- - if `DA-VINCI.md` sets `Require Supervisor Review: true`, treat missing, blocked, or unaccepted `design-supervisor review` as a blocker before broad expansion, implementation-task handoff, or terminal completion
291
-
292
- ## Load References On Demand
293
-
294
- Load only the reference that matches the current step:
295
-
296
- - Read `references/modes.md` when selecting or explaining a workflow mode
297
- - Read `references/artifact-templates.md` when creating or updating workflow artifacts
298
- - Read `references/checkpoints.md` when running or reporting checkpoints
299
- - Read `references/design-inputs.md` when collecting product form factor, style, and constraints
300
- - Read `references/layout-hygiene.md` when screenshot review or the design checkpoint needs form-factor-specific layout hygiene rules
301
- - Read `references/page-mapping.md` when defining project pages, Pencil pages, and route-to-screen bindings
302
- - Read `references/pencil-design-to-code.md` when turning Pencil data into implementation
303
- - Read `references/platform-adapters.md` when guiding users on Codex, Claude, or Gemini invocation patterns
304
- - Read `references/prompt-recipes.md` when generating intake, prompt, or continue helper outputs
305
-
306
- ## Default Artifacts
307
-
308
- Use these artifacts unless the project defines a different schema:
309
-
310
- 1. `.da-vinci/changes/<change-id>/brainstorm.md`
311
- 2. `.da-vinci/project-inventory.md`
312
- 3. `DA-VINCI.md`
313
- 4. `.da-vinci/changes/<change-id>/design-brief.md`
314
- 5. `.da-vinci/design-registry.md`
315
- 6. `.da-vinci/designs/`
316
- 7. `.da-vinci/page-map.md`
317
- 8. `.da-vinci/changes/<change-id>/proposal.md`
318
- 9. `.da-vinci/changes/<change-id>/specs/<capability>/spec.md`
319
- 10. `.da-vinci/changes/<change-id>/design.md`
320
- 11. `.da-vinci/changes/<change-id>/pencil-design.md`
321
- 12. `.da-vinci/changes/<change-id>/pencil-bindings.md`
322
- 13. `.da-vinci/changes/<change-id>/tasks.md`
323
- 14. `.da-vinci/changes/<change-id>/verification.md`
324
-
325
- Not every mode requires every artifact.
326
-
327
- Mode expectations:
328
-
329
- 1. `proposal.md`
330
- 2. `specs/<capability>/spec.md`
331
- 3. `design.md`
332
- 4. `pencil-design.md`
333
- 5. `tasks.md`
334
- 6. `verification.md`
335
-
336
- Optional artifacts:
337
-
338
- - `security-review.md`
339
- - `migration-plan.md`
340
- - `rollout-checklist.md`
341
-
342
- ## What Each Artifact Means
343
-
344
- - `brainstorm.md`: raw ideas, tensions, themes, and synthesis notes before specs are stable
345
- - `project-inventory.md`: discovered routes, pages, modules, and current UI patterns from an existing codebase
346
- - `DA-VINCI.md`: project-level visual contract for theme, color system, surface treatment, typography direction, and cross-page style rules
347
- - `design-brief.md`: form factor, visual direction, density, brand constraints, and UI preferences
348
- - `design-registry.md`: project-level `.pen` file inventory and active design sources
349
- - `.da-vinci/designs/`: project-local persisted Pencil sources such as `project-baseline.pen` or change-specific `.pen` files
350
- - `page-map.md`: canonical page list, page responsibilities, route mapping, and page states
351
- - `proposal.md`: scope, goal, non-goals, and success criteria
352
- - `spec.md`: behavior, states, inputs, outputs, edge cases, and acceptance rules
353
- - `design.md`: information architecture, page structure, interaction model, and component strategy
354
- - `pencil-design.md`: `.pen` file path, page mapping, selected screens, screenshots, and design notes
355
- - `pencil-bindings.md`: implementation route or component -> Pencil page or screen binding
356
- - `tasks.md`: implementation order and deliverable task groups
357
- - `verification.md`: requirement coverage, Pencil coverage, and drift findings
358
-
359
- ## Artifact Placement
360
-
361
- Use this placement model inside the target project:
362
-
363
- ### Project root
364
-
365
- - `DA-VINCI.md`
366
-
367
- Keep this file at the project root so the visual contract is easy to discover and reuse.
368
-
369
- ### Project-level workflow directory
370
-
371
- - `.da-vinci/project-inventory.md`
372
- - `.da-vinci/design-registry.md`
373
- - `.da-vinci/designs/`
374
- - `.da-vinci/page-map.md`
375
-
376
- These files describe project-wide facts that can outlive any one change.
377
-
378
- Recommended `.pen` persistence patterns:
379
-
380
- - `.da-vinci/designs/project-baseline.pen`
381
- - `.da-vinci/designs/<change-id>.pen`
382
- - `.da-vinci/designs/<change-id>/main.pen`
383
-
384
- ### Change-level workflow directory
385
-
386
- - `.da-vinci/changes/<change-id>/brainstorm.md`
387
- - `.da-vinci/changes/<change-id>/design-brief.md`
388
- - `.da-vinci/changes/<change-id>/proposal.md`
389
- - `.da-vinci/changes/<change-id>/design.md`
390
- - `.da-vinci/changes/<change-id>/pencil-design.md`
391
- - `.da-vinci/changes/<change-id>/pencil-bindings.md`
392
- - `.da-vinci/changes/<change-id>/tasks.md`
393
- - `.da-vinci/changes/<change-id>/verification.md`
394
- - `.da-vinci/changes/<change-id>/specs/<capability>/spec.md`
395
-
396
- These files belong to one concrete delivery effort and should not clutter the project root.
397
-
398
- ## Mode-Specific Artifact Flow
399
-
400
- Use these minimum flows:
401
-
402
- ### `greenfield-spec`
403
-
404
- `DA-VINCI` -> `.da-vinci/changes/<change-id>/design-brief` -> `.da-vinci/changes/<change-id>/proposal` -> `.da-vinci/changes/<change-id>/specs` -> `.da-vinci/page-map` -> `.da-vinci/design-registry` -> `.da-vinci/changes/<change-id>/design` -> `.da-vinci/changes/<change-id>/pencil-design` -> `.da-vinci/changes/<change-id>/pencil-bindings` -> `.da-vinci/changes/<change-id>/tasks` -> `.da-vinci/changes/<change-id>/verification`
405
-
406
- ### `greenfield-brainstorm`
407
-
408
- `.da-vinci/changes/<change-id>/brainstorm` -> `DA-VINCI` -> `.da-vinci/changes/<change-id>/design-brief` -> `.da-vinci/changes/<change-id>/proposal` -> `.da-vinci/changes/<change-id>/specs` -> `.da-vinci/page-map` -> `.da-vinci/design-registry` -> `.da-vinci/changes/<change-id>/design` -> `.da-vinci/changes/<change-id>/pencil-design` -> `.da-vinci/changes/<change-id>/pencil-bindings` -> `.da-vinci/changes/<change-id>/tasks` -> `.da-vinci/changes/<change-id>/verification`
409
-
410
- ### `redesign-from-code`
411
-
412
- `.da-vinci/project-inventory` -> `DA-VINCI` -> `.da-vinci/design-registry` -> `.da-vinci/changes/<change-id>/proposal` -> `.da-vinci/changes/<change-id>/specs` -> `.da-vinci/page-map` -> `.da-vinci/changes/<change-id>/design` -> `.da-vinci/changes/<change-id>/pencil-design` -> `.da-vinci/changes/<change-id>/pencil-bindings` -> `.da-vinci/changes/<change-id>/tasks` -> `.da-vinci/changes/<change-id>/verification`
413
-
414
- For broad refreshes, treat `.da-vinci/changes/<change-id>/specs/` as a redesign-slice directory, not as a single-file location.
415
-
416
- ### `overhaul-from-code`
417
-
418
- `.da-vinci/project-inventory` -> `.da-vinci/changes/<change-id>/proposal` -> `.da-vinci/changes/<change-id>/migration-contract` -> `.da-vinci/changes/<change-id>/specs` -> `.da-vinci/page-map` -> `DA-VINCI` -> `.da-vinci/design-registry` -> `.da-vinci/changes/<change-id>/design-brief` -> `.da-vinci/changes/<change-id>/design` -> `.da-vinci/changes/<change-id>/pencil-design` -> `.da-vinci/changes/<change-id>/pencil-bindings` -> `.da-vinci/changes/<change-id>/tasks` -> `.da-vinci/changes/<change-id>/verification`
419
-
420
- For broad overhauls, treat `.da-vinci/changes/<change-id>/specs/` as an overhaul-slice directory and keep `migration-contract.md` singular for preserve/revise/retire decisions.
421
-
422
- ### `feature-change`
423
-
424
- `.da-vinci/changes/<change-id>/proposal` -> `.da-vinci/changes/<change-id>/specs` -> `.da-vinci/page-map` for affected pages -> `DA-VINCI` -> `.da-vinci/design-registry` -> `.da-vinci/changes/<change-id>/design` -> `.da-vinci/changes/<change-id>/pencil-design` delta -> `.da-vinci/changes/<change-id>/pencil-bindings` delta -> `.da-vinci/changes/<change-id>/tasks` -> `.da-vinci/changes/<change-id>/verification`
425
-
426
- ## Requirement Breakdown Rules
427
-
428
- Before designing or coding:
429
-
430
- - Split the request into pages, flows, states, and data dependencies
431
- - Identify which parts are visual, behavioral, and integration-related
432
- - Separate must-have scope from later improvements
433
- - Call out risky areas early: auth, permissions, uploads, payments, admin flows, secrets, migrations
434
-
435
- If the active mode is `greenfield-brainstorm`:
436
-
437
- - synthesize repeated ideas into stable product direction first
438
- - identify contradictions before writing specs
439
- - move unresolved ideas into open questions instead of treating them as requirements
440
-
441
- If the active mode is `redesign-from-code`:
442
-
443
- - inventory current routes, pages, and modules before redefining page structure
444
- - distinguish preserved behavior from replaced presentation
445
- - treat existing code as behavior truth and implementation-surface discovery, not as a visual-layout baseline
446
- - default to fresh visual composition unless the user explicitly asks to preserve the current layout skeleton
447
- - partition specs by redesign slice when one oversized `ui-refresh` spec would hide important implementation boundaries
448
-
449
- If the active mode is `overhaul-from-code`:
450
-
451
- - inventory current routes, pages, modules, key flows, integrations, and permission boundaries before redefining the target product
452
- - treat existing code as reference evidence and migration baseline rather than the final target behavior truth
453
- - classify current system areas into `preserve`, `revise`, `retire`, and `unknown` in `migration-contract.md`
454
- - stabilize new `proposal.md` and `specs/` before broad Pencil design or implementation
455
- - update `page-map.md` to reflect the new target page set, not only the old route tree
456
- - route verify failures back to `migration-contract.md`, `page-map.md`, or specs when overhaul truth is still unstable
457
-
458
- ## Spec Partitioning Rules
459
-
460
- Do not default to one oversized `ui-refresh` spec for broad redesign work.
461
-
462
- For `redesign-from-code`:
463
-
464
- - keep one overall `proposal.md`
465
- - keep one project-level `DA-VINCI.md`
466
- - keep one project-level `project-inventory.md`
467
- - keep one project-level `design-registry.md`
468
- - keep one project-level `page-map.md`
469
- - split `specs/` by redesign slice when the refresh is broad
470
-
471
- Preferred redesign slices:
472
79
 
473
- - `shared-shell`
474
- - `core-pages`
475
- - `settings-and-secondary`
476
- - `admin-or-restricted`
477
- - `reference-gap-pages`
80
+ If user input does not specify a mode, infer from project reality:
478
81
 
479
- Split broad redesign work into multiple spec slices when one or more of these are true:
82
+ - new clear requirements -> `greenfield-spec`
83
+ - exploratory ideation -> `greenfield-brainstorm`
84
+ - broad UI replacement on existing code -> `redesign-from-code`
85
+ - broad existing-project rewrite of flows/logic/IA/UI -> `overhaul-from-code`
86
+ - scoped incremental change -> `feature-change`
480
87
 
481
- - the refresh covers more than five canonical pages
482
- - the refresh spans more than two top-level route groups or page families
483
- - the redesign includes both shared-shell changes and page-content changes
484
- - prior HTML or Pencil references cover only part of the product surface
485
- - different page groups carry different layout, density, or access constraints
88
+ ## Design-Supervisor Gate
486
89
 
487
- One redesign spec is acceptable when the refresh is mostly cosmetic, narrow, or limited to a small product surface.
90
+ Core contract reminders:
488
91
 
489
- Do not split page-by-page unless the product is unusually fragmented. Prefer implementable redesign slices over raw page counts.
92
+ - `Design-supervisor reviewers` are reviewer gates, not visual adapters.
93
+ - reviewer configuration and `design-supervisor review` evidence must remain explicit in workflow artifacts.
94
+ - when supervisor review is required, missing/blocked/unaccepted review is a blocker before terminal completion.
490
95
 
491
- For `overhaul-from-code`:
492
-
493
- - keep one overall `proposal.md`
494
- - keep one `migration-contract.md`
495
- - keep one project-level `DA-VINCI.md`
496
- - keep one project-level `project-inventory.md`
497
- - keep one project-level `design-registry.md`
498
- - keep one project-level `page-map.md`
499
- - split `specs/` by overhaul slice when the rewrite spans multiple implementation or migration boundaries
500
-
501
- Preferred overhaul slices:
502
-
503
- - `shell-and-navigation`
504
- - `core-flows`
505
- - `account-and-settings`
506
- - `legacy-migration`
507
- - `admin-or-restricted`
508
-
509
- ## Design Source Rules
510
-
511
- Use `design-registry.md` as the project-level inventory of `.pen` sources.
512
-
513
- Use `.da-vinci/designs/` as the default project-local location for persisted Pencil files when the workflow creates or updates them.
514
-
515
- Treat the project-local `.pen` path recorded in `design-registry.md` as workflow-owned state.
516
-
517
- - users may provide external references or existing `.pen` files
518
- - the workflow, not the user, resolves and maintains the preferred project-local `.pen` path
519
- - do not treat `design-registry.md` as a user-authored config file
520
-
521
- Resolve one exact project-local target before broad Pencil work begins:
522
-
523
- - `.da-vinci/designs/project-baseline.pen` for shared baseline reconstruction
524
- - `.da-vinci/designs/<change-id>.pen` for change-specific redesign work
525
- - `.da-vinci/designs/<change-id>/main.pen` only when the project truly needs a nested design bundle
526
-
527
- Use `DA-VINCI.md` as the project-level visual source of truth for:
528
-
529
- - theme and palette
530
- - background and surface treatment
531
- - typography direction
532
- - component tone
533
- - rules for cross-page consistency
534
- - optional visual adapter preferences
535
-
536
- Treat visual adapters as optional helpers for presentation quality only.
537
-
538
- - they may refine `DA-VINCI.md`, `design.md`, and `pencil-design.md`
539
- - they must not override behavior truth from requirements or existing code
540
- - they must not replace `page-map.md`, `design-registry.md`, or `pencil-bindings.md`
541
-
542
- When a relevant mapping already exists:
543
-
544
- - iterate on the mapped Pencil source
545
- - prefer the project-local `.pen` file under `.da-vinci/designs/` when one is already registered
546
- - do not create a new design baseline unless there is a reason
547
- - do not silently keep designing in an unrelated active Pencil document when `design-registry.md` already names a preferred path
548
-
549
- When `DA-VINCI.md` already exists:
550
-
551
- - use it as the baseline visual contract
552
- - do not regenerate visual direction from scratch unless the change explicitly rebrands or resets the product style
553
- - if it declares preferred visual adapters, try to resolve them without blocking the workflow
554
-
555
- When page-to-Pencil bindings already exist:
556
-
557
- - update the mapped Pencil page for the affected implementation page
558
- - keep the exact `.pen` file path recorded in `design-registry.md`
559
- - if the active Pencil editor path differs from that recorded path, switch to the recorded path or explicitly reconstruct the project-local file before continuing
560
-
561
- When project mappings do not exist but existing code exists:
562
-
563
- - treat the current project as the baseline source
564
- - reconstruct `project-inventory.md`
565
- - reconstruct `page-map.md`
566
- - create or rebuild `design-registry.md`
567
- - resolve the exact project-local `.pen` target path before broad Pencil work starts
568
- - generate a new Pencil baseline only after the inventory is stable
569
- - materialize that baseline into the resolved `.da-vinci/designs/` path and record the exact file in `design-registry.md`
570
-
571
- When neither mappings nor usable design sources exist:
572
-
573
- - state that the project is entering baseline reconstruction
574
- - create a new Pencil baseline from the current local source of truth
575
- - generate `DA-VINCI.md` from inferred or user-provided design rules before generating many unrelated pages
576
- - persist the resulting `.pen` file at the resolved `.da-vinci/designs/` path and record that exact path in `design-registry.md`
577
-
578
- When a Pencil session cannot yet be exported locally:
579
-
580
- - record the live or external source in `design-registry.md`
581
- - reconstruct and write the project-local `.pen` file from MCP-readable document data before closing mapping or implementation work
582
- - if the project-local file still cannot be materialized, record the reason and treat the missing file as a checkpoint issue instead of silently continuing
583
-
584
- When visual adapters are requested:
585
-
586
- - resolve them from local availability when possible
587
- - choose one primary adapter when multiple helpers are available
588
- - record the requested adapters, resolved primary adapter, any secondary helpers, and fallback status in `design-registry.md`
589
- - treat the resolved primary adapter as the design lead for the first Pencil pass, especially on anchor screens and quality-critical surfaces
590
- - if `Require Adapter: true` and the requested adapter is unavailable, treat that as a blocker instead of silently downgrading the visual bar
591
- - continue with native Da Vinci design rules when no adapter is available unless the user explicitly requires a specific adapter
592
-
593
- If the request is too vague to design or implement safely, ask a short clarification question before generating artifacts.
594
-
595
- ## Surface Decomposition Rules
596
-
597
- Do not treat one implementation container as one design surface by default.
598
-
599
- For complex products, decompose by:
600
-
601
- - canonical page
602
- - subpage
603
- - state
604
- - overlay
605
- - shared shell region
606
- - implementation surface such as activity, fragment, tab, bottom sheet, dialog, or full-screen mode
607
-
608
- When an Android screen contains multiple fragments, tabs, nested flows, or materially different states:
609
-
610
- - split them into distinct design surfaces in `page-map.md`
611
- - give each meaningful state or subpage its own Pencil target when the layout materially changes
612
- - avoid collapsing them into one overloaded redesign screen
613
-
614
- One implementation page may legitimately map to:
615
-
616
- - multiple Pencil screens
617
- - multiple states of one Pencil page
618
- - one shared shell plus several detail surfaces
619
-
620
- Treat surface decomposition as required when visual structure changes materially across states or subflows.
621
-
622
- ## Pencil Design Rules
623
-
624
- Use Pencil as a structured UI source, not as a static image source.
625
-
626
- When creating or editing Pencil designs:
627
-
628
- - Build the pages required by the current scope, not an abstract moodboard
629
- - follow `page-map.md` as the canonical page list
630
- - follow `design-brief.md` for form factor and visual direction when it exists
631
- - use the workflow-owned `.pen` path from `design-registry.md` as the active design target
632
- - do not keep designing in whichever Pencil document happens to be open unless it already matches the registered project-local path
633
- - use the resolved visual adapter, when available, for composition, hierarchy, restraint, and motion guidance
634
- - on complex redesigns, design only 1-3 anchor surfaces first before broad multi-screen generation
635
- - make each anchor surface fully composed with real hierarchy and content structure before expanding the rest of the product
636
- - before broad page generation, write a visual thesis, a content plan, and an interaction thesis for the current surface
637
- - use screenshot review after each anchor surface and revise before cloning or expanding variants
638
- - Keep page names, section names, and labels aligned with the specs
639
- - Make important states explicit when they change implementation: empty, loading, success, error, restricted, unavailable
640
- - Prefer layout clarity and information hierarchy over decorative complexity
641
- - Reject generic UI patterns such as dashboard-card mosaics, weak visual anchors, decorative clutter, or motion with no hierarchy value
642
- - reject placeholder-heavy scaffolds; unresolved placeholder rectangles are not acceptable substitutes for real screen composition
643
- - For `redesign-from-code`, redesign from page responsibilities and state decomposition, not by recoloring or slightly rearranging the old UI
644
- - After changes, inspect the result visually before treating it as implementation-ready
645
-
646
- When multiple pages exist:
647
-
648
- - derive the remaining pages from approved anchor surfaces and shared primitives rather than from an empty repeated template
649
- - keep one canonical Pencil page or screen per implementation page
650
- - record the `.pen` file in `design-registry.md`
651
- - record the mapping in `pencil-bindings.md`
652
- - ensure the active Pencil design is materialized into the registered `.da-vinci/designs/` file before closing design work
653
-
654
- ## Pencil MCP Rules
655
-
656
- When Pencil is available through MCP:
657
-
658
- - Prefer the project-local `.pen` file under `.da-vinci/designs/` when one is registered
659
- - Treat the registered `.pen` path as authoritative; do not rely on the current active editor if its path does not match `design-registry.md`
660
- - If the registered file exists, read and edit that exact file
661
- - If the registered file does not yet exist, create or reconstruct the project-local file before treating the design pass as traceable
662
- - Read the active `.pen` file and page structure before coding
663
- - read the bound Pencil page for the current implementation page
664
- - Use Pencil data to extract layout, text, hierarchy, panels, buttons, and content regions
665
- - Use screenshots only as a secondary visual check
666
- - Treat Pencil as the design data source for presentation, spacing, and layout grouping
667
- - Before mapping or implementation closes, verify both:
668
- - the `.pen` path is readable through MCP
669
- - the same path exists as a shell-visible file inside the project
670
- - Before broad expansion or terminal completion, run the MCP runtime gate:
671
- - evaluate source convergence from the active editor, registered `.pen` path, and shell-visible `.pen` file
672
- - evaluate screen presence for claimed anchor and review target ids
673
- - evaluate review execution for approved surfaces
674
- - append the runtime gate result to `pencil-design.md`
675
-
676
- When Pencil is not available:
677
-
678
- - State that the design-backed path is unavailable
679
- - Fall back to requirements-first implementation and note the missing design constraint
680
-
681
- ## Implementation Rules
682
-
683
- When generating code:
684
-
685
- - Use requirements to determine behavior, states, conditions, and semantics
686
- - Use Pencil to determine layout, section ordering, visual grouping, copy placement, and styling intent
687
- - use `pencil-bindings.md` to decide which Pencil page or screen maps to the page being implemented
688
- - Do not invent interaction behavior from design alone
689
- - Do not ignore Pencil structure when writing markup
690
- - Keep code organized by page sections and reusable UI blocks when that mapping is clear
691
-
692
- For frontend work:
693
-
694
- - Prefer `HTML + Tailwind`, `React + Tailwind`, or the project's existing frontend stack
695
- - Preserve the dominant page structure from Pencil
696
- - Match spacing and hierarchy before polishing effects
697
-
698
- ## Checkpoints
699
-
700
- Run these checkpoints:
701
-
702
- 1. `discovery checkpoint`
703
- - after `brainstorm.md`, `project-inventory.md`, or `design-brief.md`
704
- - verify the mode-specific starting material is stable enough to move into specs and design work
705
-
706
- 2. `spec checkpoint`
707
- - after requirements and page scope are defined
708
- - verify page scope, states, and behavior coverage
709
-
710
- 3. `design checkpoint`
711
- - after Pencil design exists, before implementation tasks are locked
712
- - verify the design covers the required pages, states, and key interactions
713
-
714
- 4. `design-source checkpoint`
715
- - after `design-registry.md` resolves the preferred project-local `.pen` path and active Pencil work exists
716
- - verify the registered `.pen` path, the active Pencil editor, and shell-visible persistence agree before mapping continues
717
-
718
- 5. `mapping checkpoint`
719
- - after `design-registry.md` and `pencil-bindings.md`
720
- - verify implementation pages and Pencil pages are bound correctly
721
-
722
- 6. `task checkpoint`
723
- - before implementation starts
724
- - verify tasks cover both requirements and Pencil-backed UI work
725
-
726
- 7. `execution checkpoint`
727
- - after each top-level task group during implementation
728
- - verify code still matches requirements and Pencil structure
729
-
730
- Checkpoint states:
731
-
732
- - `PASS`
733
- - `WARN`
734
- - `BLOCK`
735
-
736
- Checkpoint handling:
737
-
738
- - `PASS`: continue automatically
739
- - `WARN`: record the issue and continue automatically
740
- - `BLOCK`: stop, report the blocker, and ask only if the blocker cannot be resolved from existing artifacts
741
- - contextual-delta issues: warn and continue; do not treat missing/stale contextual notes as standalone blockers
742
-
743
- ## Drift Policy
744
-
745
- Treat these as drift:
746
-
747
- - Requirement changed but Pencil was not updated
748
- - Page map changed but Pencil bindings were not updated
749
- - Design registry changed but downstream bindings were not updated
750
- - Pencil changed but implementation tasks were not updated
751
- - Code behavior exceeds the approved scope
752
- - Code layout or content structure diverges materially from Pencil without a recorded reason
753
-
754
- When drift is found:
755
-
756
- - Update the source artifact first
757
- - Then continue implementation
758
-
759
- ## Output Format
96
+ ## Load References On Demand
760
97
 
761
- After meaningful work, report:
98
+ Load only the reference that matches the active stage:
762
99
 
763
- 1. changed files
764
- 2. active mode
765
- 3. current workflow state
766
- 4. next recommended step
767
- 5. blockers or drift
100
+ - Read `references/modes.md` when selecting or explaining a workflow mode.
101
+ - Read `references/artifact-templates.md` when creating/updating workflow artifacts.
102
+ - Read `references/checkpoints.md` when running/reporting checkpoints.
103
+ - Read `references/design-inputs.md` when collecting form factor/style/constraints.
104
+ - Read `references/layout-hygiene.md` for screenshot review and layout hygiene decisions.
105
+ - Read `references/page-mapping.md` when defining project pages, Pencil pages, and bindings.
106
+ - Read `references/pencil-design-to-code.md` when turning Pencil data into implementation.
107
+ - Read `references/platform-adapters.md` for Codex/Claude/Gemini invocation patterns.
108
+ - Read `references/prompt-recipes.md` for `intake`/`prompt`/`continue` helper output generation.
109
+ - Read `references/skill-workflow-detail.md` for stage-specific operational detail moved out of this core file.
768
110
 
769
- Keep updates concise and operational.
770
- Make `next recommended step` follow the state rules above; do not list `build` next to `tasks` as if they were equivalent when task generation has not happened yet.
111
+ The core file is intentionally short. If a rule is stage-specific, it belongs in a referenced owner document, not in the core contract.