@agent-native/core 0.115.1 → 0.115.3

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 (40) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +12 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/agent/production-agent.ts +17 -0
  5. package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +19 -2
  6. package/corpus/core/src/client/blocks/library/wireframe.tsx +3 -1
  7. package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +19 -2
  8. package/corpus/templates/plan/AGENTS.md +10 -0
  9. package/corpus/templates/plan/actions/create-prototype-plan.ts +27 -3
  10. package/corpus/templates/plan/actions/get-plan-blocks.ts +1 -1
  11. package/corpus/templates/plan/actions/update-visual-plan.ts +3 -2
  12. package/corpus/templates/plan/app/components/plan/PlanContentRenderer.tsx +18 -4
  13. package/corpus/templates/plan/app/components/plan/PlanVisualSurface.tsx +10 -3
  14. package/corpus/templates/plan/app/components/plan/wireframe/Wireframe.tsx +3 -1
  15. package/corpus/templates/plan/app/i18n/en-US.ts +6 -0
  16. package/corpus/templates/plan/app/lib/create-plan-routing.ts +39 -0
  17. package/corpus/templates/plan/app/pages/PlansPage.tsx +31 -107
  18. package/corpus/templates/plan/changelog/2026-07-22-high-fidelity-mockup-requests-now-preserve-branded-css-use-d.md +6 -0
  19. package/corpus/templates/plan/shared/plan-content.ts +110 -2
  20. package/dist/agent/production-agent.d.ts.map +1 -1
  21. package/dist/agent/production-agent.js +14 -0
  22. package/dist/agent/production-agent.js.map +1 -1
  23. package/dist/cli/skills-content/visual-plan-skill.d.ts +1 -1
  24. package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -1
  25. package/dist/cli/skills-content/visual-plan-skill.js +19 -2
  26. package/dist/cli/skills-content/visual-plan-skill.js.map +1 -1
  27. package/dist/client/blocks/library/wireframe.d.ts.map +1 -1
  28. package/dist/client/blocks/library/wireframe.js +3 -2
  29. package/dist/client/blocks/library/wireframe.js.map +1 -1
  30. package/dist/collab/awareness.d.ts +2 -2
  31. package/dist/collab/awareness.d.ts.map +1 -1
  32. package/dist/collab/routes.d.ts +2 -2
  33. package/dist/observability/routes.d.ts +5 -5
  34. package/dist/progress/routes.d.ts +1 -1
  35. package/dist/secrets/routes.d.ts +9 -9
  36. package/dist/server/transcribe-voice.d.ts +1 -1
  37. package/package.json +3 -3
  38. package/src/agent/production-agent.ts +17 -0
  39. package/src/cli/skills-content/visual-plan-skill.ts +19 -2
  40. package/src/client/blocks/library/wireframe.tsx +3 -1
package/corpus/README.md CHANGED
@@ -30,4 +30,4 @@ rg -n "defineAction|useActionQuery" node_modules/@agent-native/core/corpus
30
30
 
31
31
  - core files: 1527
32
32
  - toolkit files: 144
33
- - template files: 6367
33
+ - template files: 6369
@@ -1,5 +1,17 @@
1
1
  # @agent-native/core
2
2
 
3
+ ## 0.115.3
4
+
5
+ ### Patch Changes
6
+
7
+ - a841109: Teach visual-plan agents to create and promote full-fidelity design surfaces without losing scoped CSS or duplicating an existing plan.
8
+
9
+ ## 0.115.2
10
+
11
+ ### Patch Changes
12
+
13
+ - f0601ec: Collapse duplicate assistant tool-call ids in the shared agent loop so providers do not reject replayed tool-call history.
14
+
3
15
  ## 0.115.1
4
16
 
5
17
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.115.1",
3
+ "version": "0.115.3",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -3087,6 +3087,21 @@ function normalizeToolCallInputForHistory(
3087
3087
  return { rawInput: input };
3088
3088
  }
3089
3089
 
3090
+ function dedupeAssistantToolCallsById(
3091
+ content: import("./engine/types.js").EngineContentPart[],
3092
+ ): import("./engine/types.js").EngineContentPart[] {
3093
+ const seenToolCallIds = new Set<string>();
3094
+ const deduped: import("./engine/types.js").EngineContentPart[] = [];
3095
+ for (const part of content) {
3096
+ if (part.type === "tool-call") {
3097
+ if (seenToolCallIds.has(part.id)) continue;
3098
+ seenToolCallIds.add(part.id);
3099
+ }
3100
+ deduped.push(part);
3101
+ }
3102
+ return deduped;
3103
+ }
3104
+
3090
3105
  function toolInputSchemaErrorResult(
3091
3106
  toolName: string,
3092
3107
  input: unknown,
@@ -3996,6 +4011,8 @@ export async function runAgentLoop(opts: {
3996
4011
  }
3997
4012
  }
3998
4013
 
4014
+ assistantContent = dedupeAssistantToolCallsById(assistantContent);
4015
+
3999
4016
  const assistantContentForHistory = assistantContent.map((part) =>
4000
4017
  part.type === "tool-call"
4001
4018
  ? {
@@ -301,6 +301,18 @@ and screen ids across both surfaces. The canvas is the inspectable static refere
301
301
  the prototype is the interactive version of that same flow, not a separate
302
302
  design direction.
303
303
 
304
+ Treat “higher fidelity,” “pixel-accurate,” “polished mockup,” “production-like,”
305
+ “real design,” and “not a sketch/wireframe” as design-first language even when
306
+ the request also says “mockup.” For a new plan, use \`create-plan-design\`. For
307
+ an existing plan, keep the same plan id and call \`update-visual-plan\` with a
308
+ \`set-visual-render-mode\` patch using \`renderMode: "design"\` plus the upgraded
309
+ screen HTML/CSS in the same update. Ground the result in the real app shell,
310
+ tokens, typography, spacing, and states, and add stable \`data-design-id\`
311
+ targets. Put scoped styles in each screen's \`css\` field, never in a \`<style>\`
312
+ tag. The viewer-local Clean toggle only changes one browser's wireframe
313
+ preference; it is not a fidelity upgrade. Do not create a duplicate plan to
314
+ handle a fidelity follow-up.
315
+
304
316
  ## Wireframe quality — read \`references/wireframe.md\`
305
317
 
306
318
  UI recap/plan wireframes must meet a strict quality bar — full-width chrome,
@@ -349,7 +361,9 @@ directory before authoring a plan.
349
361
  visual surface, canvas only, or canvas + prototype.
350
362
  - \`create-ui-plan\`: start a UI-first plan when the work is primarily product UI.
351
363
  - \`create-prototype-plan\`: start a prototype-first plan with a functional top
352
- review surface.
364
+ review surface. If the interaction itself must also be high fidelity, set each
365
+ screen's \`renderMode\` to \`design\` and pass scoped styles through \`css\`;
366
+ otherwise use \`create-plan-design\` for design-first review.
353
367
  - \`create-plan-design\`: start a full-fidelity branded Design-tab plan with an
354
368
  optional matching Prototype tab.
355
369
  - \`convert-visual-plan-to-prototype\`: convert an existing HTML wireframe canvas
@@ -357,7 +371,10 @@ directory before authoring a plan.
357
371
  - \`create-visual-questions\`: use only when the user explicitly asks for a visual
358
372
  intake questionnaire, not as \`/visual-plan\` preflight.
359
373
  - \`update-visual-plan\`: revise content, status, or comments with targeted
360
- \`contentPatches\` (see Core Workflow steps 6-7). \`replace-blocks\` and full
374
+ \`contentPatches\` (see Core Workflow steps 6-7). Use
375
+ \`set-visual-render-mode\` with \`renderMode: "design"\` when promoting an
376
+ existing plan to high fidelity, together with deliberate screen HTML/CSS;
377
+ render mode alone only removes sketch treatment. \`replace-blocks\` and full
361
378
  \`content\` replacement require \`expectedUpdatedAt\` from a fresh
362
379
  \`get-visual-plan\` call.
363
380
  - \`read-visual-plan-source\`: read the normalized plan as \`plan.mdx\`,
@@ -142,7 +142,7 @@ function ArtboardFrame({
142
142
  const fitRef = useRef<HTMLDivElement>(null);
143
143
  const isDark = useIsDark();
144
144
  const theme: "light" | "dark" = isDark ? "dark" : "light";
145
- const style = useWireframeStyle();
145
+ const preferredStyle = useWireframeStyle();
146
146
  const preset = SURFACE_PRESETS[surface] ?? SURFACE_PRESETS.desktop;
147
147
  const width = canvasWidth ?? preset.width;
148
148
  // AUTO-HEIGHT: with no explicit `canvasSize` the artboard height is driven by
@@ -164,6 +164,7 @@ function ArtboardFrame({
164
164
  fixedHeight ?? null,
165
165
  );
166
166
  const designMode = renderMode === "design";
167
+ const style = designMode ? "clean" : preferredStyle;
167
168
  const sketchy = !designMode && style === "sketchy" && !skeleton;
168
169
  const roughEnabled = sketchy && roughOverlay;
169
170
  const frameBorder = skeleton
@@ -409,6 +410,7 @@ function KitArtboard({
409
410
  surface={data.surface}
410
411
  compact={compact}
411
412
  skeleton={data.skeleton}
413
+ renderMode={data.renderMode}
412
414
  showFrame={showFrame}
413
415
  selector="[data-rough]"
414
416
  caption={data.caption}
@@ -301,6 +301,18 @@ and screen ids across both surfaces. The canvas is the inspectable static refere
301
301
  the prototype is the interactive version of that same flow, not a separate
302
302
  design direction.
303
303
 
304
+ Treat “higher fidelity,” “pixel-accurate,” “polished mockup,” “production-like,”
305
+ “real design,” and “not a sketch/wireframe” as design-first language even when
306
+ the request also says “mockup.” For a new plan, use `create-plan-design`. For
307
+ an existing plan, keep the same plan id and call `update-visual-plan` with a
308
+ `set-visual-render-mode` patch using `renderMode: "design"` plus the upgraded
309
+ screen HTML/CSS in the same update. Ground the result in the real app shell,
310
+ tokens, typography, spacing, and states, and add stable `data-design-id`
311
+ targets. Put scoped styles in each screen's `css` field, never in a `<style>`
312
+ tag. The viewer-local Clean toggle only changes one browser's wireframe
313
+ preference; it is not a fidelity upgrade. Do not create a duplicate plan to
314
+ handle a fidelity follow-up.
315
+
304
316
  ## Wireframe quality — read `references/wireframe.md`
305
317
 
306
318
  UI recap/plan wireframes must meet a strict quality bar — full-width chrome,
@@ -349,7 +361,9 @@ directory before authoring a plan.
349
361
  visual surface, canvas only, or canvas + prototype.
350
362
  - `create-ui-plan`: start a UI-first plan when the work is primarily product UI.
351
363
  - `create-prototype-plan`: start a prototype-first plan with a functional top
352
- review surface.
364
+ review surface. If the interaction itself must also be high fidelity, set each
365
+ screen's `renderMode` to `design` and pass scoped styles through `css`;
366
+ otherwise use `create-plan-design` for design-first review.
353
367
  - `create-plan-design`: start a full-fidelity branded Design-tab plan with an
354
368
  optional matching Prototype tab.
355
369
  - `convert-visual-plan-to-prototype`: convert an existing HTML wireframe canvas
@@ -357,7 +371,10 @@ directory before authoring a plan.
357
371
  - `create-visual-questions`: use only when the user explicitly asks for a visual
358
372
  intake questionnaire, not as `/visual-plan` preflight.
359
373
  - `update-visual-plan`: revise content, status, or comments with targeted
360
- `contentPatches` (see Core Workflow steps 6-7). `replace-blocks` and full
374
+ `contentPatches` (see Core Workflow steps 6-7). Use
375
+ `set-visual-render-mode` with `renderMode: "design"` when promoting an
376
+ existing plan to high fidelity, together with deliberate screen HTML/CSS;
377
+ render mode alone only removes sketch treatment. `replace-blocks` and full
361
378
  `content` replacement require `expectedUpdatedAt` from a fresh
362
379
  `get-visual-plan` call.
363
380
  - `read-visual-plan-source`: read the normalized plan as `plan.mdx`,
@@ -104,6 +104,16 @@ Design tab as the visual source of truth and the Prototype tab as the same
104
104
  direction made interactive. (`create-plan-design` is an MCP tool reached from
105
105
  `/visual-plan`, not a separate slash command.)
106
106
 
107
+ Treat “higher fidelity,” “pixel-accurate,” “polished mockup,” “production-like,”
108
+ “real design,” and “not a sketch/wireframe” as design-first requests, even when
109
+ the prompt also says “mockup.” For an existing plan, do not create a duplicate:
110
+ call `update-visual-plan` on the same plan id with a
111
+ `set-visual-render-mode` patch using `renderMode: "design"`, and replace or patch
112
+ the affected screen HTML/CSS in the same update. Put scoped styles in each
113
+ screen's `css` field, never in `<style>` tags. Merely switching the viewer-local
114
+ Clean toggle removes rough.js for one browser but does not create a high-fidelity
115
+ artifact.
116
+
107
117
  Use `/visual-recap` when the user wants a high-level review surface for a PR,
108
118
  commit, branch, or git diff that already changed. Recaps are reverse plans:
109
119
  derive blocks from the real diff, call `create-visual-recap` with the recap
@@ -46,6 +46,9 @@ const prototypeSurfaceSchema = z.enum([
46
46
  "panel",
47
47
  "browser",
48
48
  ]);
49
+ const prototypeRenderModeSchema = z.enum(["wireframe", "design"]);
50
+ const boundedPrototypeHtml = (value: string) =>
51
+ !/<\/?(?:html|head|body|script|style)\b/i.test(value);
49
52
 
50
53
  const prototypeScreenSchema = z.object({
51
54
  id: z.string().optional().describe("Stable screen id"),
@@ -55,11 +58,32 @@ const prototypeScreenSchema = z.object({
55
58
  .optional()
56
59
  .describe("What the reviewer should inspect on this screen"),
57
60
  surface: prototypeSurfaceSchema.optional().default("browser"),
61
+ renderMode: prototypeRenderModeSchema
62
+ .optional()
63
+ .describe(
64
+ 'Set to "design" for polished, high-fidelity, production-like, or branded screens. Design mode persists on the artifact and disables the rough.js treatment for every viewer.',
65
+ ),
58
66
  html: z
59
67
  .string()
68
+ .max(40_000)
69
+ .refine(boundedPrototypeHtml, {
70
+ message:
71
+ "Prototype HTML must be a bounded fragment without html/head/body/script/style tags. Put scoped styles in the css field.",
72
+ })
73
+ .optional()
74
+ .describe(
75
+ 'Bounded semantic HTML fragment for a real interactive prototype. Use safe Alpine-like directives (x-data, x-model, x-for, x-text, x-show, :class, @click, @keydown.enter) for local behavior; use data-goto="screen-id" only for true screen/route changes. Never include html/body/script/style tags; put visual styling in css.',
76
+ ),
77
+ css: z
78
+ .string()
79
+ .max(20_000)
80
+ .refine(boundedPrototypeHtml, {
81
+ message:
82
+ "Prototype CSS must not include document, script, or style tags.",
83
+ })
60
84
  .optional()
61
85
  .describe(
62
- 'Bounded semantic HTML fragment for a real interactive prototype. Use safe Alpine-like directives (x-data, x-model, x-for, x-text, x-show, :class, @click, @keydown.enter) for local behavior; use data-goto="screen-id" only for true screen/route changes. Never include html/body/script/style tags.',
86
+ "Scoped CSS for this screen. Required when the request is high fidelity: use real codebase or brand tokens, deliberate typography, spacing, color, and state styling instead of embedding a style tag in html.",
63
87
  ),
64
88
  state: z
65
89
  .array(
@@ -112,7 +136,7 @@ const createPrototypePlanSchema = z.object({
112
136
  .optional()
113
137
  .default([])
114
138
  .describe(
115
- "Prototype screens. Default to one functional screen when local UI behavior is enough; use 2-4 screens only for true routes/steps. Screen HTML should include working local controls, inputs, toggles, lists, filters, or lightweight flows where relevant.",
139
+ 'Prototype screens. Default to one functional screen when local UI behavior is enough; use 2-4 screens only for true routes/steps. Screen HTML should include working local controls, inputs, toggles, lists, filters, or lightweight flows where relevant. For higher-fidelity requests, prefer create-plan-design; when the interaction itself requires a polished prototype, set each screen renderMode to "design" and pass its styling in css.',
116
140
  ),
117
141
  transitions: z
118
142
  .array(prototypeTransitionSchema)
@@ -143,7 +167,7 @@ const createPrototypePlanSchema = z.object({
143
167
 
144
168
  export default defineAction({
145
169
  description:
146
- "Create a plan whose primary review surface is a running interactive prototype. For a document-first plan use create-visual-plan; for a UI-first wireframe canvas use create-ui-plan; for a recap of an existing diff use create-visual-recap; for full-fidelity branded design use create-plan-design. Prototype screen HTML uses safe Alpine-like directives for local state and data-goto for screen navigation only. Publish via this tool; never deliver the plan as inline chat text.",
170
+ 'Create a plan whose primary review surface is a running interactive prototype. For a document-first plan use create-visual-plan; for a UI-first wireframe canvas use create-ui-plan; for a recap of an existing diff use create-visual-recap; for full-fidelity branded design use create-plan-design. Prototype screen HTML uses safe Alpine-like directives for local state and data-goto for screen navigation only. If a functional prototype must also be high fidelity, set renderMode to "design" and put scoped styles in css; never embed style tags in html because they are rejected. Publish via this tool; never deliver the plan as inline chat text.',
147
171
  schema: createPrototypePlanSchema.refine(
148
172
  (args) => Boolean(args.brief || args.goal),
149
173
  { message: "Either brief or goal is required." },
@@ -49,7 +49,7 @@ const AUTHORING_RULES_NOTE = `
49
49
 
50
50
  **API endpoints**: keep \`api-endpoint\` and \`openapi-spec\` blocks in normal single-column document flow. Use \`columns\` only for an explicit before/after contract comparison.
51
51
 
52
- **renderMode**: leave unset or set to \`wireframe\` unless a design-only editable mock is required.\``;
52
+ **Visual fidelity and renderMode**: leave \`renderMode\` unset or set it to \`wireframe\` for normal wireframes. “Higher fidelity,” “pixel-accurate,” “polished mockup,” “production-like,” “real design,” or “not a sketch/wireframe” requires \`renderMode: "design"\`, substantial branded HTML/CSS grounded in the real app, and stable \`data-design-id\` targets. Put scoped styles in the wireframe/prototype \`css\` field — never in a \`<style>\` tag. On an existing plan, update the same plan id with \`set-visual-render-mode\` plus the upgraded HTML/CSS; do not create a duplicate. The viewer-local Clean toggle is not a fidelity upgrade.\``;
53
53
 
54
54
  /**
55
55
  * Expose the live plan block vocabulary to the agent. The list is generated from
@@ -112,6 +112,7 @@ function contentPatchTargetId(patch: PlanContentPatch) {
112
112
  if ("blockId" in patch) return patch.blockId;
113
113
  if ("screenId" in patch) return patch.screenId;
114
114
  if (patch.op === "set-metadata") return "plan-metadata";
115
+ if (patch.op === "set-visual-render-mode") return "visual-render-mode";
115
116
  if (patch.op === "set-prototype" || patch.op === "remove-prototype") {
116
117
  return "prototype";
117
118
  }
@@ -451,7 +452,7 @@ function contentPatchDetails(input: {
451
452
  const CONTENT_DESCRIPTION =
452
453
  "Destructive full structured content replacement. Read the latest plan first and pass its updatedAt as expectedUpdatedAt. Prefer granular contentPatches for ordinary edits; use this only for intentional broad restructuring.";
453
454
  const CONTENT_PATCHES_DESCRIPTION =
454
- "Targeted structured content edits addressed by stable id. Prefer granular operations for live plans. The destructive replace-blocks operation requires expectedUpdatedAt from a fresh read. patch-visual-plan-source is only for exported MDX folders. Supported ops: set-metadata for title/brief, set-prototype / remove-prototype / update-prototype-screen / patch-prototype-html for live prototype surfaces; update-block / replace-block, update-rich-text, patch-wireframe-html, patch-diagram-html, update-wireframe-node, replace-wireframe-screen, update-canvas-frame, update-canvas-annotation / append-canvas-annotation, append-block / remove-block, update-custom-html.";
455
+ "Targeted structured content edits addressed by stable id. Prefer granular operations for live plans. The destructive replace-blocks operation requires expectedUpdatedAt from a fresh read. patch-visual-plan-source is only for exported MDX folders. Supported ops: set-metadata for title/brief; set-visual-render-mode to persist `design` (high fidelity, authored CSS, no rough.js for any viewer) or `wireframe` across canvas, linked blocks, and prototype screens; set-prototype / remove-prototype / update-prototype-screen / patch-prototype-html for live prototype surfaces; update-block / replace-block, update-rich-text, patch-wireframe-html, patch-diagram-html, update-wireframe-node, replace-wireframe-screen, update-canvas-frame, update-canvas-annotation / append-canvas-annotation, append-block / remove-block, update-custom-html. A fidelity upgrade must also replace or patch the existing screen HTML/CSS with deliberate branded design; changing render mode alone only removes the sketch treatment.";
455
456
 
456
457
  // Named so `agentInputSchema` below can `.extend()` it with compact
457
458
  // `content`/`contentPatches` fields instead of duplicating every other key.
@@ -528,7 +529,7 @@ const updateVisualPlanSchema = z.object({
528
529
 
529
530
  export default defineAction({
530
531
  description:
531
- "Update an Agent-Native Plan's structured content blocks, prototype screens, sections, comments, or status. Prefer contentPatches for targeted edits. Use full content only for broad restructuring. Works on plans and recaps alike when you have editor access; with viewer access (common on PR recaps published by CI) only comment-only calls succeed — to change a recap you cannot edit, publish a replacement with create-visual-recap instead of retrying this call.",
532
+ "Update an Agent-Native Plan's structured content blocks, prototype screens, visual fidelity, sections, comments, or status. Prefer contentPatches for targeted edits. When a user asks for higher fidelity on an existing plan, update that same plan in place: use set-visual-render-mode with design and provide polished screen HTML/CSS in the same call instead of creating a duplicate plan or only toggling the viewer-local clean style. Use full content only for broad restructuring. Works on plans and recaps alike when you have editor access; with viewer access (common on PR recaps published by CI) only comment-only calls succeed — to change a recap you cannot edit, publish a replacement with create-visual-recap instead of retrying this call.",
532
533
  schema: updateVisualPlanSchema,
533
534
  // ADVERTISED-ONLY: same top-level shape, but `content`/`contentPatches`
534
535
  // swap the deep per-block-type union for a compact `type`-enum stand-in.
@@ -652,10 +652,24 @@ export function PlanContentRenderer({
652
652
  hiddenChangedFileBlockIds,
653
653
  hideChangedFiles,
654
654
  ]);
655
- const blockLookup = useMemo(
656
- () => new Map(content.blocks.map((block) => [block.id, block])),
657
- [content.blocks],
658
- );
655
+ const blockLookup = useMemo(() => {
656
+ const blocks = new Map<string, PlanBlock>();
657
+ const visit = (block: PlanBlock) => {
658
+ blocks.set(block.id, block);
659
+ if (block.type === "tabs") {
660
+ for (const tab of block.data.tabs) {
661
+ for (const child of tab.blocks) visit(child);
662
+ }
663
+ }
664
+ if (block.type === "columns") {
665
+ for (const column of block.data.columns) {
666
+ for (const child of column.blocks) visit(child);
667
+ }
668
+ }
669
+ };
670
+ for (const block of content.blocks) visit(block);
671
+ return blocks;
672
+ }, [content.blocks]);
659
673
  const fileToBlockIdMap = useMemo<Map<string, string>>(() => {
660
674
  if (!isRecap) return new Map();
661
675
  const map = new Map<string, string>();
@@ -60,7 +60,7 @@ export function PlanVisualSurface({
60
60
  onDesignElementStyleChange,
61
61
  }: PlanVisualSurfaceProps) {
62
62
  const t = useT();
63
- const designCanvas = isDesignCanvas(canvas);
63
+ const designCanvas = isDesignCanvas(canvas, blockLookup);
64
64
  const [selectedDesignElement, setSelectedDesignElement] =
65
65
  useState<DesignElementSelection | null>(null);
66
66
  const selectedDesignElementKey = selectedDesignElement
@@ -226,10 +226,17 @@ export function PlanVisualSurface({
226
226
  return null;
227
227
  }
228
228
 
229
- function isDesignCanvas(canvas: PlanContent["canvas"] | undefined) {
229
+ function isDesignCanvas(
230
+ canvas: PlanContent["canvas"] | undefined,
231
+ blockLookup: Map<string, PlanBlock>,
232
+ ) {
230
233
  return Boolean(
231
234
  canvas?.mode === "design" ||
232
- canvas?.frames.some((frame) => frame.wireframe?.renderMode === "design"),
235
+ canvas?.frames.some((frame) => {
236
+ if (frame.wireframe) return frame.wireframe.renderMode === "design";
237
+ const block = frame.blockId ? blockLookup.get(frame.blockId) : undefined;
238
+ return block?.type === "wireframe" && block.data.renderMode === "design";
239
+ }),
233
240
  );
234
241
  }
235
242
 
@@ -194,7 +194,7 @@ function ArtboardFrame({
194
194
  const fitRef = useRef<HTMLDivElement>(null);
195
195
  const { resolvedTheme } = useTheme();
196
196
  const theme: "light" | "dark" = resolvedTheme === "dark" ? "dark" : "light";
197
- const style = useWireframeStyle();
197
+ const preferredStyle = useWireframeStyle();
198
198
  const preset = SURFACE_PRESETS[surface] ?? SURFACE_PRESETS.desktop;
199
199
  const height = canvasSize ?? preset.height;
200
200
  const width = canvasWidth ?? preset.width;
@@ -202,6 +202,7 @@ function ArtboardFrame({
202
202
  const maxFrameWidth = compact ? preset.width * baseScale : width;
203
203
  const [fitScale, setFitScale] = useState(baseScale);
204
204
  const designMode = renderMode === "design";
205
+ const style = designMode ? "clean" : preferredStyle;
205
206
  const sketchy = !designMode && style === "sketchy" && !skeleton;
206
207
  const roughEnabled = sketchy && roughOverlay;
207
208
  const paper = designMode
@@ -560,6 +561,7 @@ function KitWireframe({
560
561
  canvasSize={canvasSize}
561
562
  canvasWidth={canvasWidth}
562
563
  skeleton={data.skeleton}
564
+ renderMode={data.renderMode}
563
565
  showFrame={showFrame}
564
566
  selector="[data-rough]"
565
567
  caption={data.caption}
@@ -564,6 +564,10 @@ const messages = {
564
564
  label: "UI flow",
565
565
  description: "UI flow - wireframes and states",
566
566
  },
567
+ design: {
568
+ label: "High-fidelity design",
569
+ description: "High-fidelity design - polished branded screens",
570
+ },
567
571
  questions: {
568
572
  label: "Visual questions",
569
573
  description: "Visual questions - explicit intake",
@@ -587,6 +591,8 @@ const messages = {
587
591
  "# Implementation plan\n\nPaste the existing Codex or Claude Code plan here and turn it into a visual review document.",
588
592
  },
589
593
  assessment: {
594
+ design:
595
+ "Auto detected a high-fidelity request; the agent will create polished branded screens.",
590
596
  ui: "Auto detected UI states or flows; the agent will make a wireframe-first plan.",
591
597
  visual:
592
598
  "Auto will ask the agent for a rich technical plan with diagrams and implementation detail.",
@@ -0,0 +1,39 @@
1
+ export type CreatePlanKind = "auto" | "design" | "ui" | "questions" | "visual";
2
+ export type ResolvedPlanKind = Exclude<CreatePlanKind, "auto">;
3
+ export type AutoPlanKind = Exclude<ResolvedPlanKind, "questions">;
4
+
5
+ export function isProbablyImportedPlan(prompt: string) {
6
+ const trimmed = prompt.trim();
7
+ const lines = trimmed.split(/\r?\n/).filter((line) => line.trim());
8
+ if (trimmed.length > 900 && lines.length > 8) return true;
9
+ const hasHeading = lines.some((line) => /^#{1,4}\s+\S/.test(line.trim()));
10
+ const checklistCount = lines.filter((line) =>
11
+ /^[-*]\s+\[[ x]\]\s+\S/i.test(line.trim()),
12
+ ).length;
13
+ const taskCount = lines.filter((line) =>
14
+ /^([-*]|\d+[.)])\s+\S/.test(line.trim()),
15
+ ).length;
16
+ const hasPlanLanguage =
17
+ /\b(implementation plan|acceptance criteria|milestones?|phases?|risks?|open questions?|test plan)\b/i.test(
18
+ trimmed,
19
+ );
20
+ return (
21
+ trimmed.includes("```") ||
22
+ (hasHeading && (taskCount >= 3 || hasPlanLanguage)) ||
23
+ (checklistCount >= 2 && trimmed.length > 220)
24
+ );
25
+ }
26
+
27
+ export function assessPlanPrompt(prompt: string): { kind: AutoPlanKind } {
28
+ const highFidelity =
29
+ /\b(high(?:er)?[- ]fidelity|full[- ]fidelity|hi[- ]fi|polished(?: mockups?)?|production[- ](?:like|ready)|pixel[- ](?:perfect|accurate)|brand(?:ed|[- ]aware)|real design|not (?:a )?(?:sketch(?:y)?|wireframe)|beyond (?:the )?(?:sketch|wireframe))\b/i.test(
30
+ prompt,
31
+ );
32
+ if (highFidelity) return { kind: "design" };
33
+
34
+ const uiDirection =
35
+ /\b(ui|screen|screens|layout|wireframe|mockup|form factor|mobile|desktop|responsive|nav|sidebar|flow|redesign|empty state|loading state|error state)\b/i.test(
36
+ prompt,
37
+ );
38
+ return { kind: uiDirection ? "ui" : "visual" };
39
+ }
@@ -239,6 +239,11 @@ import {
239
239
  type PlanAccessStatusResponse,
240
240
  type PublishVisualPlanResult,
241
241
  } from "@/hooks/use-plans";
242
+ import {
243
+ assessPlanPrompt,
244
+ isProbablyImportedPlan,
245
+ type CreatePlanKind,
246
+ } from "@/lib/create-plan-routing";
242
247
  import {
243
248
  getDesktopPlanFiles,
244
249
  type DesktopPlanFilesFolder,
@@ -1596,9 +1601,9 @@ function buildPlanAgentContext(input: {
1596
1601
  : [
1597
1602
  "Fast iteration workflow:",
1598
1603
  "1. Call get-visual-plan with this plan ID to read structured content, exported HTML, sections, comments, and activity.",
1599
- "2. Prefer update-visual-plan contentPatches for targeted edits. Examples: update-rich-text for copy, patch-prototype-html / update-prototype-screen for live prototype states, update-wireframe-node for one kit-tree node, update-canvas-frame for frame layout, append-canvas-annotation / update-canvas-annotation for canvas markup, append-block/remove-block for document changes, or replace-block for a single block. Use full content only for broad restructuring. Use html only when preserving or importing a legacy standalone HTML artifact.",
1604
+ '2. Prefer update-visual-plan contentPatches for targeted edits. Examples: update-rich-text for copy, patch-prototype-html / update-prototype-screen for live prototype states, update-wireframe-node for one kit-tree node, update-canvas-frame for frame layout, append-canvas-annotation / update-canvas-annotation for canvas markup, append-block/remove-block for document changes, or replace-block for a single block. When the user asks for higher fidelity, polished mockups, production-like UI, real design, or anything "not sketchy," update this same plan in place: rewrite the relevant screen HTML/CSS and include set-visual-render-mode with renderMode design. Do not create a second plan, put CSS in style tags, or treat the viewer-local Clean toggle as a fidelity upgrade. Use full content only for broad restructuring. Use html only when preserving or importing a legacy standalone HTML artifact.',
1600
1605
  "3. Preserve the user's existing annotation comments and intent unless the user asks to remove or resolve them.",
1601
- "4. Keep the output as a refined document with rich text, tables, sketch diagrams, wireframes, implementation maps, code tabs, and bounded custom HTML fragments.",
1606
+ "4. Match the requested fidelity: ordinary UI planning can use sketch diagrams and wireframes; high-fidelity requests need the persisted Design surface with deliberate branded HTML/CSS and stable data-design-id targets.",
1602
1607
  "5. After applying feedback, keep the plan scannable, editable, and serious instead of turning it into a marketing page.",
1603
1608
  "6. Work the actionable agent comments first. Treat human-review comments as FYI/questions/approval items; do not silently resolve those unless the user explicitly asks.",
1604
1609
  "7. When visual screenshots are attached, each crop is centered near a comment marker and has a red ring on the exact commented point. Use the comment IDs and anchor details below to connect screenshots to threads. If a visual comment is listed as overflow, rely on its anchorDetails/coordinates and call get-plan-feedback for the full manifest.",
@@ -8323,93 +8328,6 @@ const CREATE_PLAN_PROMPTS = [
8323
8328
  },
8324
8329
  ] as const;
8325
8330
 
8326
- type CreatePlanKind = "auto" | "ui" | "questions" | "visual";
8327
- type ResolvedPlanKind = Exclude<CreatePlanKind, "auto">;
8328
- type AutoPlanKind = Exclude<ResolvedPlanKind, "questions">;
8329
-
8330
- function isProbablyImportedPlan(prompt: string) {
8331
- const trimmed = prompt.trim();
8332
- const lines = trimmed.split(/\r?\n/).filter((line) => line.trim());
8333
- if (trimmed.length > 900 && lines.length > 8) return true;
8334
- const hasHeading = lines.some((line) => /^#{1,4}\s+\S/.test(line.trim()));
8335
- const checklistCount = lines.filter((line) =>
8336
- /^[-*]\s+\[[ x]\]\s+\S/i.test(line.trim()),
8337
- ).length;
8338
- const taskCount = lines.filter((line) =>
8339
- /^([-*]|\d+[.)])\s+\S/.test(line.trim()),
8340
- ).length;
8341
- const hasPlanLanguage =
8342
- /\b(implementation plan|acceptance criteria|milestones?|phases?|risks?|open questions?|test plan)\b/i.test(
8343
- trimmed,
8344
- );
8345
- return (
8346
- trimmed.includes("```") ||
8347
- (hasHeading && (taskCount >= 3 || hasPlanLanguage)) ||
8348
- (checklistCount >= 2 && trimmed.length > 220)
8349
- );
8350
- }
8351
-
8352
- function assessPlanPrompt(prompt: string): {
8353
- kind: AutoPlanKind;
8354
- } {
8355
- let score = 0;
8356
- let ambiguitySignals = 0;
8357
-
8358
- const wantsExploration =
8359
- /\b(ask questions|questions first|intake first|show me options|explore options|help me choose|not sure|unsure|which direction|compare)\b/i.test(
8360
- prompt,
8361
- );
8362
- const exactOrTrivial =
8363
- /\b(typo|copy tweak|one line|single file|exactly|no questions|don't ask|dont ask|just implement)\b/i.test(
8364
- prompt,
8365
- );
8366
- const uiDirection =
8367
- /\b(ui|screen|screens|layout|wireframe|mockup|form factor|mobile|desktop|responsive|nav|sidebar|flow|redesign|empty state|loading state|error state)\b/i.test(
8368
- prompt,
8369
- );
8370
- const multipleApproaches =
8371
- /\b(option|variant|alternative|tradeoff|approach|architecture|data model|permission|auth|integration|migration|state machine)\b/i.test(
8372
- prompt,
8373
- );
8374
- const newSurface =
8375
- /\b(new surface|multi-screen|workflow|journey|end-to-end|dashboard|settings|checkout|onboarding|review flow)\b/i.test(
8376
- prompt,
8377
- );
8378
- const risky =
8379
- /\b(auth|permission|billing|migration|schema|integration|oauth|webhook|security|role|privacy|external)\b/i.test(
8380
- prompt,
8381
- );
8382
-
8383
- if (uiDirection) {
8384
- score += 2;
8385
- ambiguitySignals += 1;
8386
- }
8387
- if (multipleApproaches) {
8388
- score += 2;
8389
- ambiguitySignals += 1;
8390
- }
8391
- if (newSurface) score += 1;
8392
- if (risky) score += 1;
8393
- if (
8394
- wantsExploration ||
8395
- /\b(best|better|improve|explore|direction|choose)\b/i.test(prompt)
8396
- ) {
8397
- score += 1;
8398
- ambiguitySignals += 1;
8399
- }
8400
- if (exactOrTrivial) score -= 3;
8401
-
8402
- if (uiDirection) {
8403
- return {
8404
- kind: "ui",
8405
- };
8406
- }
8407
-
8408
- return {
8409
- kind: "visual",
8410
- };
8411
- }
8412
-
8413
8331
  function sourceOptionDisplayLabel(
8414
8332
  source: PlanSource,
8415
8333
  t: ReturnType<typeof useT>,
@@ -8440,11 +8358,13 @@ function buildCreatePlanAgentMessage({
8440
8358
  planKind === "auto" ? assessPlanPrompt(prompt).kind : planKind;
8441
8359
  const routing = imported
8442
8360
  ? "Build from this existing plan while preserving its intent."
8443
- : resolvedPlanKind === "ui"
8444
- ? "Create a UI-first plan with AI-authored wireframes and state coverage."
8445
- : resolvedPlanKind === "questions"
8446
- ? "Create visual intake questions before generating the final plan."
8447
- : "Create a general visual plan with diagrams and implementation detail.";
8361
+ : resolvedPlanKind === "design"
8362
+ ? "Create a design-first plan with full-fidelity branded screens. Use create-plan-design, ground the result in the real app shell and design tokens, and treat the Design tab as the visual source of truth."
8363
+ : resolvedPlanKind === "ui"
8364
+ ? "Create a UI-first plan with AI-authored wireframes and state coverage."
8365
+ : resolvedPlanKind === "questions"
8366
+ ? "Create visual intake questions before generating the final plan."
8367
+ : "Create a general visual plan with diagrams and implementation detail.";
8448
8368
 
8449
8369
  return [
8450
8370
  "Create an Agent-Native Plan from this request.",
@@ -8452,7 +8372,7 @@ function buildCreatePlanAgentMessage({
8452
8372
  routing,
8453
8373
  `Source/provenance: ${sourceOptionDisplayLabel(source, t)}.`,
8454
8374
  "",
8455
- "Use the Plan actions after you have enough substance. Generate the wireframes, diagrams, implementation map, review prompts, and concrete file/symbol notes yourself. Do not use placeholder file names, generic scaffold text, or browser-generated fallback sections as the final plan content.",
8375
+ "Use the Plan actions after you have enough substance. Generate the requested review surface, diagrams, implementation map, review prompts, and concrete file/symbol notes yourself. Do not use placeholder file names, generic scaffold text, or browser-generated fallback sections as the final plan content.",
8456
8376
  "After creating the plan, open the plan link for review.",
8457
8377
  "",
8458
8378
  "Request:",
@@ -8595,11 +8515,13 @@ function CreatePlanDialog({
8595
8515
  ),
8596
8516
  })
8597
8517
  : planKindDisplayLabel("auto", t)
8598
- : planKind === "ui"
8599
- ? planKindDisplayLabel("ui", t)
8600
- : planKind === "questions"
8601
- ? planKindDisplayLabel("questions", t)
8602
- : planKindDisplayLabel("visual", t)}
8518
+ : planKind === "design"
8519
+ ? planKindDisplayLabel("design", t)
8520
+ : planKind === "ui"
8521
+ ? planKindDisplayLabel("ui", t)
8522
+ : planKind === "questions"
8523
+ ? planKindDisplayLabel("questions", t)
8524
+ : planKindDisplayLabel("visual", t)}
8603
8525
  </span>
8604
8526
  <IconChevronDown
8605
8527
  className={cn(
@@ -8643,13 +8565,12 @@ function CreatePlanDialog({
8643
8565
  value={planKind}
8644
8566
  onValueChange={(value) =>
8645
8567
  setPlanKind(
8646
- value === "auto"
8647
- ? "auto"
8648
- : value === "visual"
8649
- ? "visual"
8650
- : value === "questions"
8651
- ? "questions"
8652
- : "ui",
8568
+ value === "auto" ||
8569
+ value === "design" ||
8570
+ value === "visual" ||
8571
+ value === "questions"
8572
+ ? value
8573
+ : "ui",
8653
8574
  )
8654
8575
  }
8655
8576
  >
@@ -8665,6 +8586,9 @@ function CreatePlanDialog({
8665
8586
  <SelectItem value="ui">
8666
8587
  {t("plansPage.create.kindOptions.ui.description")}
8667
8588
  </SelectItem>
8589
+ <SelectItem value="design">
8590
+ {t("plansPage.create.kindOptions.design.description")}
8591
+ </SelectItem>
8668
8592
  <SelectItem value="questions">
8669
8593
  {t(
8670
8594
  "plansPage.create.kindOptions.questions.description",