@xenonbyte/da-vinci-workflow 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/README.md +17 -0
- package/README.zh-CN.md +17 -0
- package/SKILL.md +13 -0
- package/commands/claude/dv/design.md +2 -0
- package/commands/claude/dv/verify.md +2 -0
- package/commands/codex/prompts/dv-design.md +2 -0
- package/commands/codex/prompts/dv-verify.md +1 -0
- package/commands/gemini/dv/design.toml +2 -0
- package/commands/gemini/dv/verify.toml +1 -0
- package/docs/mcp-aware-gate-implementation.md +291 -0
- package/docs/mcp-aware-gate-tests.md +244 -0
- package/docs/mcp-aware-gate.md +246 -0
- package/docs/mode-use-cases.md +2 -0
- package/docs/prompt-presets/desktop-app.md +3 -0
- package/docs/prompt-presets/mobile-app.md +3 -0
- package/docs/prompt-presets/tablet-app.md +3 -0
- package/docs/prompt-presets/web-app.md +3 -0
- package/docs/workflow-examples.md +9 -4
- package/docs/zh-CN/mcp-aware-gate-implementation.md +290 -0
- package/docs/zh-CN/mcp-aware-gate-tests.md +244 -0
- package/docs/zh-CN/mcp-aware-gate.md +249 -0
- package/docs/zh-CN/mode-use-cases.md +3 -0
- package/docs/zh-CN/prompt-presets/desktop-app.md +3 -0
- package/docs/zh-CN/prompt-presets/mobile-app.md +3 -0
- package/docs/zh-CN/prompt-presets/tablet-app.md +3 -0
- package/docs/zh-CN/prompt-presets/web-app.md +3 -0
- package/docs/zh-CN/workflow-examples.md +9 -4
- package/lib/audit.js +348 -0
- package/lib/cli.js +47 -1
- package/lib/mcp-runtime-gate.js +342 -0
- package/package.json +3 -2
- package/references/artifact-templates.md +26 -1
- package/references/checkpoints.md +66 -1
- package/references/design-inputs.md +2 -1
- package/references/pencil-design-to-code.md +8 -0
- package/scripts/test-mcp-runtime-gate.js +199 -0
|
@@ -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
|
package/docs/mode-use-cases.md
CHANGED
|
@@ -139,6 +139,7 @@ Generate DA-VINCI.md, proposal, specs, page map, Pencil-backed launch pages, bin
|
|
|
139
139
|
8. create `pencil-design.md`
|
|
140
140
|
- record the generated Pencil screens
|
|
141
141
|
- ensure the active design is materialized into the registered `.pen` path under `.da-vinci/designs/`
|
|
142
|
+
- keep screenshot exports under `.da-vinci/changes/<change-id>/exports/` rather than `.da-vinci/designs/`
|
|
142
143
|
|
|
143
144
|
9. create `pencil-bindings.md`
|
|
144
145
|
- map implementation pages to Pencil pages
|
|
@@ -156,6 +157,7 @@ Generate DA-VINCI.md, proposal, specs, page map, Pencil-backed launch pages, bin
|
|
|
156
157
|
- `DA-VINCI.md` exists and is stable
|
|
157
158
|
- every core page exists in `page-map.md`
|
|
158
159
|
- every implementation page has a Pencil counterpart or an explicit exception
|
|
160
|
+
- the registered project-local `.pen` file is shell-visible and not just a live editor session
|
|
159
161
|
- `task checkpoint` passes
|
|
160
162
|
|
|
161
163
|
### Best fit
|
|
@@ -41,12 +41,15 @@ Existing code is the behavior source of truth, not the layout truth.
|
|
|
41
41
|
Preserve current behavior, flows, integrations, and validation rules unless explicitly required otherwise.
|
|
42
42
|
Inventory primary workspaces, side panels, inspectors, dialogs, settings flows, overlays, and materially different states before broad Pencil work.
|
|
43
43
|
Decompose complex screens into primary surfaces, secondary surfaces, overlays, and implementation surfaces.
|
|
44
|
+
Create the required discovery and design-source artifacts in their standard locations before the first anchor surface.
|
|
44
45
|
Use the Visual Assist preferences declared in DA-VINCI.md.
|
|
45
46
|
Treat the resolved primary visual adapter as the first-pass design lead.
|
|
46
47
|
Use Pencil guides only as workspace constraints, not as the design direction.
|
|
47
48
|
Do not start with broad multi-screen scaffolding.
|
|
48
49
|
Design 1-3 anchor surfaces first, review screenshots, then expand.
|
|
49
50
|
Apply the form-factor-specific layout hygiene rules for desktop before passing screenshot review.
|
|
51
|
+
Write exported screenshots under `.da-vinci/changes/<change-id>/exports/` only.
|
|
52
|
+
Do not report completion if the registered `.pen` source exists only in memory or only as exported PNGs.
|
|
50
53
|
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
54
|
Persist project-local Pencil files under .da-vinci/designs/.
|
|
52
55
|
```
|
|
@@ -41,6 +41,7 @@ Existing code is the behavior source of truth, not the layout truth.
|
|
|
41
41
|
Preserve business logic, navigation, permissions, integrations, validations, and state transitions unless explicitly required otherwise.
|
|
42
42
|
Inventory activities, fragments, tabs, dialogs, bottom sheets, nested flows, overlays, and materially different states before broad Pencil work.
|
|
43
43
|
Decompose complex screens into subpages, overlays, materially different states, and implementation surfaces.
|
|
44
|
+
Create the required discovery and design-source artifacts in their standard locations before the first anchor surface.
|
|
44
45
|
Use the Visual Assist preferences declared in DA-VINCI.md.
|
|
45
46
|
Treat the resolved primary visual adapter as the first-pass design lead.
|
|
46
47
|
State the resolved primary visual adapter explicitly in the log and name any requested adapters that are unavailable.
|
|
@@ -54,6 +55,8 @@ Apply the form-factor-specific layout hygiene rules for mobile before passing sc
|
|
|
54
55
|
Use only Pencil-supported properties; do not use web-only props like flex or margin.
|
|
55
56
|
Verify the registered project-local `.pen` file exists as a shell-visible file after the first Pencil write.
|
|
56
57
|
Keep non-`.pen` workflow artifacts out of `.da-vinci/designs/`.
|
|
58
|
+
Write exported screenshots under `.da-vinci/changes/<change-id>/exports/` only.
|
|
59
|
+
Do not report completion if the registered `.pen` source exists only in memory or only as exported PNGs.
|
|
57
60
|
Define shared primitives from the approved anchor surfaces before broad page expansion.
|
|
58
61
|
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
62
|
Persist project-local Pencil files under .da-vinci/designs/.
|
|
@@ -41,12 +41,15 @@ Existing code is the behavior source of truth, not the layout truth.
|
|
|
41
41
|
Preserve current behavior, permissions, integrations, validations, and state transitions unless explicitly required otherwise.
|
|
42
42
|
Inventory split-pane regions, sidebars, expanded canvases, dialogs, sheets, orientation-driven changes, and materially different states before broad Pencil work.
|
|
43
43
|
Decompose complex pages into multi-region surfaces, overlays, materially different states, and implementation surfaces.
|
|
44
|
+
Create the required discovery and design-source artifacts in their standard locations before the first anchor surface.
|
|
44
45
|
Use the Visual Assist preferences declared in DA-VINCI.md.
|
|
45
46
|
Treat the resolved primary visual adapter as the first-pass design lead.
|
|
46
47
|
Use Pencil guides only as tablet-layout constraints, not as the design direction.
|
|
47
48
|
Do not start with broad multi-screen scaffolding.
|
|
48
49
|
Design 1-3 anchor surfaces first, review screenshots, then expand.
|
|
49
50
|
Apply the form-factor-specific layout hygiene rules for tablet before passing screenshot review.
|
|
51
|
+
Write exported screenshots under `.da-vinci/changes/<change-id>/exports/` only.
|
|
52
|
+
Do not report completion if the registered `.pen` source exists only in memory or only as exported PNGs.
|
|
50
53
|
Do not pass design checkpoint if the result collapses into a stretched phone layout, repeated placeholders, or weak multi-region hierarchy.
|
|
51
54
|
Persist project-local Pencil files under .da-vinci/designs/.
|
|
52
55
|
```
|
|
@@ -42,12 +42,15 @@ Preserve current business logic, routes, permissions, integrations, validations,
|
|
|
42
42
|
Inventory responsive product surfaces, marketing surfaces, authenticated areas, settings pages, dialogs, drawers, overlays, and materially different states before broad Pencil work.
|
|
43
43
|
Separate marketing-style surfaces from product-workflow surfaces when they require different visual treatment.
|
|
44
44
|
Decompose complex pages into subpages, overlays, materially different states, and implementation surfaces.
|
|
45
|
+
Create the required discovery and design-source artifacts in their standard locations before the first anchor surface.
|
|
45
46
|
Use the Visual Assist preferences declared in DA-VINCI.md.
|
|
46
47
|
Treat the resolved primary visual adapter as the first-pass design lead.
|
|
47
48
|
Use Pencil guides only as responsive layout constraints, not as the design direction.
|
|
48
49
|
Do not start with broad multi-screen scaffolding.
|
|
49
50
|
Design 1-3 anchor surfaces first, review screenshots, then expand.
|
|
50
51
|
Apply the form-factor-specific layout hygiene rules for web before passing screenshot review.
|
|
52
|
+
Write exported screenshots under `.da-vinci/changes/<change-id>/exports/` only.
|
|
53
|
+
Do not report completion if the registered `.pen` source exists only in memory or only as exported PNGs.
|
|
51
54
|
Do not pass design checkpoint if the result is a generic SaaS card grid, repeated placeholder scaffolds, or a recolor of the old interface.
|
|
52
55
|
Persist project-local Pencil files under .da-vinci/designs/.
|
|
53
56
|
```
|
|
@@ -83,10 +83,13 @@ Expected flow:
|
|
|
83
83
|
7. write the visual thesis, content plan, interaction thesis, and structural-delta notes for the anchor surfaces
|
|
84
84
|
8. create new or updated Pencil pages from fresh composition rather than a recolor of the old UI, preferring persistence under `.da-vinci/designs/`
|
|
85
85
|
9. verify the registered project-local `.pen` path becomes shell-visible immediately after the first successful Pencil write
|
|
86
|
-
10.
|
|
87
|
-
11.
|
|
88
|
-
12.
|
|
89
|
-
13.
|
|
86
|
+
10. if Pencil MCP is active, run the MCP runtime gate and record it in `pencil-design.md`
|
|
87
|
+
11. run `design-source checkpoint` to confirm the registered project-local `.pen` path, the active Pencil source, and the shell-visible file all agree
|
|
88
|
+
12. export screenshots only under `.da-vinci/changes/<change-id>/exports/`, never into `.da-vinci/designs/`
|
|
89
|
+
13. bind routes and pages to Pencil screens
|
|
90
|
+
14. generate tasks aligned to the redesign slices
|
|
91
|
+
15. run `da-vinci audit --mode completion --change <change-id> <project-path>` before any terminal completion claim
|
|
92
|
+
16. build and verify only after the completion gate can eventually pass
|
|
90
93
|
|
|
91
94
|
### Complex Android example
|
|
92
95
|
|
|
@@ -107,6 +110,8 @@ Do not treat screenshot analysis as an automatic pass if it reports hierarchy, s
|
|
|
107
110
|
Use only Pencil-supported properties; do not use web-only props like flex or margin.
|
|
108
111
|
Verify the registered project-local `.pen` file exists as a shell-visible file after the first Pencil write.
|
|
109
112
|
Keep `.da-vinci/designs/` reserved for `.pen` files only.
|
|
113
|
+
Write exported screenshots under `.da-vinci/changes/<change-id>/exports/` only.
|
|
114
|
+
Do not report completion if the `.pen` source exists only in memory or only as exported PNGs.
|
|
110
115
|
Do not pass design checkpoint if the result is just a skin-swap of the old UI.
|
|
111
116
|
```
|
|
112
117
|
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# MCP-Aware Gate 实现设计
|
|
2
|
+
|
|
3
|
+
这份文档把 MCP-aware gate 提案收敛成实现设计。
|
|
4
|
+
|
|
5
|
+
它仍然不是代码实现承诺。
|
|
6
|
+
|
|
7
|
+
## 范围
|
|
8
|
+
|
|
9
|
+
这份设计只覆盖第一版最小实现:
|
|
10
|
+
|
|
11
|
+
- runtime source convergence
|
|
12
|
+
- runtime screen presence
|
|
13
|
+
- runtime review execution
|
|
14
|
+
- runtime truth 和 filesystem truth 不一致时阻断完成态
|
|
15
|
+
|
|
16
|
+
不覆盖:
|
|
17
|
+
|
|
18
|
+
- 自动重建 `.pen`
|
|
19
|
+
- 通过 CLI 读取 live MCP 状态
|
|
20
|
+
- session persistence 或 transport 工程
|
|
21
|
+
|
|
22
|
+
## 设计目标
|
|
23
|
+
|
|
24
|
+
增加一个很窄的 runtime checkpoint,用来阻断 live editor 漂移造成的假完成态。
|
|
25
|
+
|
|
26
|
+
它应该能抓住这类情况:
|
|
27
|
+
|
|
28
|
+
- active editor 仍然是 `new`
|
|
29
|
+
- anchor screen 只存在于 live session
|
|
30
|
+
- 截图使用的 node id 在当前 editor 中不存在
|
|
31
|
+
- runtime 状态和 filesystem 状态没收敛时,工作流却声称完成
|
|
32
|
+
|
|
33
|
+
## 当前架构约束
|
|
34
|
+
|
|
35
|
+
当前架构已经具备:
|
|
36
|
+
|
|
37
|
+
- filesystem `audit`
|
|
38
|
+
- `references/checkpoints.md` 中的 checkpoint 规则
|
|
39
|
+
- `design-registry.md` 和 `pencil-design.md` 中的工件约束
|
|
40
|
+
- 通过 MCP 读取 active editor 和 live screen 的能力
|
|
41
|
+
|
|
42
|
+
当前架构还不具备:
|
|
43
|
+
|
|
44
|
+
- 直接从 CLI 读取 MCP runtime state 的能力
|
|
45
|
+
- 脱离当前 agent 上下文的稳定 session id
|
|
46
|
+
|
|
47
|
+
所以 MCP-aware gate 必须在 agent 工作流里执行,而不是由 CLI 接管。
|
|
48
|
+
|
|
49
|
+
## 实现挂载点
|
|
50
|
+
|
|
51
|
+
### 主挂载点
|
|
52
|
+
|
|
53
|
+
1. 第一次成功写入 Pencil 之后。
|
|
54
|
+
2. 任何 `design complete` 或 `workflow complete` 声明之前。
|
|
55
|
+
|
|
56
|
+
### 次挂载点
|
|
57
|
+
|
|
58
|
+
3. 当设计要从 anchor surface 扩张到更多页面前。
|
|
59
|
+
|
|
60
|
+
### 原因
|
|
61
|
+
|
|
62
|
+
- 第一次写入后执行:尽早抓到 `new` editor 漂移
|
|
63
|
+
- 完成前执行:阻止假完成
|
|
64
|
+
- 扩张前执行:防止弱 runtime 状态扩散到更多页面
|
|
65
|
+
|
|
66
|
+
## 归属阶段
|
|
67
|
+
|
|
68
|
+
runtime gate 应该归设计阶段所有,不归 CLI 所有。
|
|
69
|
+
|
|
70
|
+
也就是说:
|
|
71
|
+
|
|
72
|
+
- design route 在 Pencil MCP 可用时负责执行
|
|
73
|
+
- verify route 在声称设计完成时可以复查
|
|
74
|
+
- build route 不应该成为 runtime gate 的主要执行方
|
|
75
|
+
|
|
76
|
+
## 输入来源
|
|
77
|
+
|
|
78
|
+
### MCP 输入
|
|
79
|
+
|
|
80
|
+
必需:
|
|
81
|
+
|
|
82
|
+
- active editor state
|
|
83
|
+
- top-level nodes
|
|
84
|
+
- 声称完成的 anchor screen 对应节点
|
|
85
|
+
|
|
86
|
+
预期 MCP 操作:
|
|
87
|
+
|
|
88
|
+
- `pencil.get_editor_state`
|
|
89
|
+
- `pencil.batch_get`
|
|
90
|
+
|
|
91
|
+
### 文件系统输入
|
|
92
|
+
|
|
93
|
+
必需:
|
|
94
|
+
|
|
95
|
+
- shell 可见 `.pen`
|
|
96
|
+
- `design-registry.md` 中登记的 `.pen`
|
|
97
|
+
- `pencil-design.md` 中记录的 anchor / review / screenshot target
|
|
98
|
+
|
|
99
|
+
预期文件读取:
|
|
100
|
+
|
|
101
|
+
- 读取 `design-registry.md`
|
|
102
|
+
- 读取 `pencil-design.md`
|
|
103
|
+
- 检查登记的 `.pen` 是否真实存在
|
|
104
|
+
|
|
105
|
+
## Runtime Snapshot 模型
|
|
106
|
+
|
|
107
|
+
runtime gate 应先构造一个结构化 snapshot:
|
|
108
|
+
|
|
109
|
+
```md
|
|
110
|
+
runtime snapshot
|
|
111
|
+
- activeEditor
|
|
112
|
+
- topLevelScreenIds
|
|
113
|
+
- topLevelScreenNames
|
|
114
|
+
- registeredPenPath
|
|
115
|
+
- shellVisiblePenExists
|
|
116
|
+
- claimedAnchorIds
|
|
117
|
+
- claimedReviewedScreenIds
|
|
118
|
+
- reviewTargets
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
后续 evaluator 只依赖这份 snapshot。
|
|
122
|
+
|
|
123
|
+
这样实现就能在没有真实 Pencil session 的情况下做单元测试。
|
|
124
|
+
|
|
125
|
+
## 评估阶段
|
|
126
|
+
|
|
127
|
+
### Stage 1: Source Convergence
|
|
128
|
+
|
|
129
|
+
检查:
|
|
130
|
+
|
|
131
|
+
- active editor 不是 `new`
|
|
132
|
+
- `design-registry.md` 中存在登记的 `.pen`
|
|
133
|
+
- 登记的 `.pen` 在磁盘上真实存在
|
|
134
|
+
- active editor 和登记设计源没有明显分叉
|
|
135
|
+
|
|
136
|
+
结果规则:
|
|
137
|
+
|
|
138
|
+
- `PASS`:runtime source 和登记 source 已收敛
|
|
139
|
+
- `WARN`:还没产生新的 live edit,或在用已记录的延后 baseline
|
|
140
|
+
- `BLOCK`:runtime source 未命名、缺失,或已经分叉
|
|
141
|
+
|
|
142
|
+
### Stage 2: Screen Presence
|
|
143
|
+
|
|
144
|
+
检查:
|
|
145
|
+
|
|
146
|
+
- 声称完成的 anchor id 在 live MCP state 中存在
|
|
147
|
+
- 声称已 review 的 screen 在 live MCP state 中存在
|
|
148
|
+
- screenshot target 在当前文档中可解析
|
|
149
|
+
|
|
150
|
+
结果规则:
|
|
151
|
+
|
|
152
|
+
- `PASS`:声称完成的设计输出能追溯到 live editor
|
|
153
|
+
- `WARN`:screen 命名有漂移,但仍可恢复映射
|
|
154
|
+
- `BLOCK`:声称完成的 screen 或 target 无法解析
|
|
155
|
+
|
|
156
|
+
### Stage 3: Review Execution
|
|
157
|
+
|
|
158
|
+
检查:
|
|
159
|
+
|
|
160
|
+
- 每个已批准 anchor 都存在 reviewed screen id 或 screenshot target
|
|
161
|
+
- runtime review 记录和当前 live editor 对齐
|
|
162
|
+
- review blocker 没有被忽略
|
|
163
|
+
|
|
164
|
+
结果规则:
|
|
165
|
+
|
|
166
|
+
- `PASS`:runtime review 可信
|
|
167
|
+
- `WARN`:存在 review,但继续扩张前还需要回改
|
|
168
|
+
- `BLOCK`:当前批准结论缺乏 runtime 证据支撑
|
|
169
|
+
|
|
170
|
+
## 记录策略
|
|
171
|
+
|
|
172
|
+
不要新增一类全新工件。
|
|
173
|
+
|
|
174
|
+
应把结果追加到 `pencil-design.md`:
|
|
175
|
+
|
|
176
|
+
```md
|
|
177
|
+
## MCP Runtime Gate
|
|
178
|
+
- Time:
|
|
179
|
+
- Active editor:
|
|
180
|
+
- Registered `.pen` path:
|
|
181
|
+
- Shell-visible `.pen` path:
|
|
182
|
+
- Claimed anchor ids:
|
|
183
|
+
- Reviewed screen ids:
|
|
184
|
+
- Source convergence: PASS | WARN | BLOCK
|
|
185
|
+
- Screen presence: PASS | WARN | BLOCK
|
|
186
|
+
- Review execution: PASS | WARN | BLOCK
|
|
187
|
+
- Final runtime gate status: PASS | WARN | BLOCK
|
|
188
|
+
- Notes:
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 为什么选 `pencil-design.md`
|
|
192
|
+
|
|
193
|
+
- 它本来就记录 source path、screens、screenshots 和设计说明
|
|
194
|
+
- 它离 runtime 设计真相最近
|
|
195
|
+
- 避免引入新的临时工件,导致流程继续分叉
|
|
196
|
+
|
|
197
|
+
## 失败处理
|
|
198
|
+
|
|
199
|
+
当 runtime gate 返回 `BLOCK`:
|
|
200
|
+
|
|
201
|
+
- 不允许继续 broad multi-screen expansion
|
|
202
|
+
- 不允许声称 design complete
|
|
203
|
+
- 不允许声称 workflow complete
|
|
204
|
+
- 必须把不一致显式记录到 `pencil-design.md`
|
|
205
|
+
|
|
206
|
+
当 runtime gate 返回 `WARN`:
|
|
207
|
+
|
|
208
|
+
- 只有在不会造成 source ambiguity 的情况下才能继续
|
|
209
|
+
- 终态完成前仍要先解决或明确接受这个 warning
|
|
210
|
+
|
|
211
|
+
## 和 Filesystem Audit 的协作
|
|
212
|
+
|
|
213
|
+
顺序应该是:
|
|
214
|
+
|
|
215
|
+
1. 先跑 runtime gate
|
|
216
|
+
2. runtime gate 通过后,再跑 filesystem completion audit
|
|
217
|
+
3. 两层都通过,才能宣称完成
|
|
218
|
+
|
|
219
|
+
也就是:
|
|
220
|
+
|
|
221
|
+
1. runtime gate
|
|
222
|
+
2. filesystem completion audit
|
|
223
|
+
3. terminal completion claim
|
|
224
|
+
|
|
225
|
+
## 最小伪流程
|
|
226
|
+
|
|
227
|
+
```md
|
|
228
|
+
1. 第一次成功写入 Pencil
|
|
229
|
+
2. 通过 MCP 读取 active editor
|
|
230
|
+
3. 从 `pencil-design.md` 读取声称完成的 anchor ids
|
|
231
|
+
4. 从 `design-registry.md` 读取登记 `.pen`
|
|
232
|
+
5. 检查 shell-visible `.pen`
|
|
233
|
+
6. 读取 live anchor 节点
|
|
234
|
+
7. 评估 source convergence
|
|
235
|
+
8. 评估 screen presence
|
|
236
|
+
9. 在需要时评估 review execution
|
|
237
|
+
10. 把 runtime gate 结果追加到 `pencil-design.md`
|
|
238
|
+
11. 如果要声称终态完成,再跑 filesystem completion audit
|
|
239
|
+
12. 两层都过,才能输出完成
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## 边界决策
|
|
243
|
+
|
|
244
|
+
### 当 Pencil MCP 不可用
|
|
245
|
+
|
|
246
|
+
不要伪造 runtime gate。
|
|
247
|
+
|
|
248
|
+
应该:
|
|
249
|
+
|
|
250
|
+
- 记录 MCP runtime gate 无法执行
|
|
251
|
+
- 回退到 filesystem audit 和已知约束
|
|
252
|
+
- 但不能把 runtime gate 记成已通过
|
|
253
|
+
|
|
254
|
+
### 当还没有 anchor ids
|
|
255
|
+
|
|
256
|
+
第一次成功写入后,可以先跑一个缩减版 source-convergence-only check。
|
|
257
|
+
|
|
258
|
+
但不能假装 screen-presence 或 review-execution 已经完成。
|
|
259
|
+
|
|
260
|
+
### 当还没有新的 Pencil 修改
|
|
261
|
+
|
|
262
|
+
应返回 `WARN` 或 skip,而不是伪造 `PASS`。
|
|
263
|
+
|
|
264
|
+
## 非功能要求
|
|
265
|
+
|
|
266
|
+
第一版实现应该满足:
|
|
267
|
+
|
|
268
|
+
- deterministic
|
|
269
|
+
- artifact 记录是 append-only
|
|
270
|
+
- evaluator 可以针对 runtime snapshot 单独单元测试
|
|
271
|
+
- 不依赖 CLI transport 改造
|
|
272
|
+
|
|
273
|
+
## 实现步骤
|
|
274
|
+
|
|
275
|
+
建议顺序:
|
|
276
|
+
|
|
277
|
+
1. 先定义 runtime snapshot 结构
|
|
278
|
+
2. 再定义一个纯 evaluator
|
|
279
|
+
3. 增加一个把结果追加到 `pencil-design.md` 的 writer
|
|
280
|
+
4. 在 design-phase runtime checkpoint 中调用它
|
|
281
|
+
5. 把终态完成规则改成“runtime gate + filesystem audit”双通过
|
|
282
|
+
|
|
283
|
+
## 延后工作
|
|
284
|
+
|
|
285
|
+
第一版不要带上:
|
|
286
|
+
|
|
287
|
+
- 自动修复 editor/source mismatch
|
|
288
|
+
- 多 session 状态和解
|
|
289
|
+
- 面向 live runtime 的 CLI 命令
|
|
290
|
+
- 通用 checkpoint orchestration engine
|