@agent-native/core 0.136.4 → 0.137.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/clips/.agents/skills/recording/SKILL.md +53 -0
  3. package/corpus/templates/clips/actions/import-loom-recording.ts +7 -0
  4. package/corpus/templates/clips/actions/lib/loom-import-job.ts +24 -4
  5. package/corpus/templates/clips/app/components/import-menu.tsx +109 -0
  6. package/corpus/templates/clips/app/components/library/library-grid.tsx +8 -18
  7. package/corpus/templates/clips/app/components/library/library-layout.tsx +14 -50
  8. package/corpus/templates/clips/app/components/library/sort-menu.tsx +20 -6
  9. package/corpus/templates/clips/app/components/recorder/pre-record-panel.tsx +10 -34
  10. package/corpus/templates/clips/app/routes/_app.library._index.tsx +0 -2
  11. package/corpus/templates/clips/changelog/2026-08-03-restart-during-a-recording-now-immediately-starts-a-fresh-ta.md +6 -0
  12. package/corpus/templates/clips/changelog/2026-08-04-cleaner-library-controls-with-an-icon-only-sort-button.md +6 -0
  13. package/corpus/templates/clips/changelog/2026-08-04-upload-and-loom-imports-now-live-under-one-import-menu.md +6 -0
  14. package/corpus/templates/clips/desktop/src/app.tsx +81 -30
  15. package/corpus/templates/clips/desktop/src/lib/recorder.ts +436 -158
  16. package/corpus/templates/clips/server/lib/post-finalize-dispatch.ts +14 -1
  17. package/corpus/templates/clips/server/plugins/auth.ts +9 -0
  18. package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +13 -0
  19. package/corpus/templates/content/actions/_database-utils.ts +6 -0
  20. package/corpus/templates/content/actions/bind-content-database-source-field.ts +273 -97
  21. package/corpus/templates/content/actions/change-content-database-source-role.ts +65 -29
  22. package/corpus/templates/content/actions/configure-document-property.ts +113 -32
  23. package/corpus/templates/content/actions/delete-content-database.ts +5 -7
  24. package/corpus/templates/content/actions/delete-document-property.ts +109 -62
  25. package/corpus/templates/content/actions/delete-document.ts +178 -36
  26. package/corpus/templates/content/actions/duplicate-database-item.ts +27 -0
  27. package/corpus/templates/content/actions/duplicate-database-items.ts +31 -1
  28. package/corpus/templates/content/actions/permanently-delete-document.ts +4 -6
  29. package/corpus/templates/content/actions/remove-database-items.ts +13 -0
  30. package/corpus/templates/content/actions/set-document-property.ts +69 -1
  31. package/corpus/templates/content/actions/upsert-database-item-by-key.ts +814 -0
  32. package/corpus/templates/content/parity/matrix.md +1 -1
  33. package/corpus/templates/content/parity/matrix.ts +1 -0
  34. package/corpus/templates/content/server/db/schema.ts +27 -0
  35. package/corpus/templates/content/server/plugins/db.ts +24 -0
  36. package/corpus/templates/design/app/components/design/BreakpointBar.tsx +122 -114
  37. package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +2 -2
  38. package/corpus/templates/design/app/components/design/EditPanel.tsx +68 -34
  39. package/corpus/templates/design/app/components/design/KeyboardShortcutsPanel.tsx +78 -4
  40. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +8 -0
  41. package/corpus/templates/design/app/components/design/QuestionFlow.tsx +5 -2
  42. package/corpus/templates/design/app/components/design/edit-panel/panel-primitives.tsx +10 -9
  43. package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +31 -69
  44. package/corpus/templates/design/app/components/design/inspector/design-icons.tsx +80 -106
  45. package/corpus/templates/design/app/components/design/multi-screen/types.ts +4 -0
  46. package/corpus/templates/design/app/hooks/use-editor-preferences.ts +75 -0
  47. package/corpus/templates/design/app/i18n-data.ts +8 -0
  48. package/corpus/templates/design/app/i18n-keyboard-shortcuts.ts +61 -0
  49. package/corpus/templates/design/app/pages/design-editor/editor-preferences.ts +98 -0
  50. package/corpus/templates/design/app/pages/design-editor/nudge-intent.ts +491 -0
  51. package/corpus/templates/design/app/pages/design-editor/paste-placement.ts +133 -0
  52. package/corpus/templates/design/app/pages/design-editor/png-export-render.ts +8 -0
  53. package/corpus/templates/design/app/pages/design-editor/selection-state.ts +5 -12
  54. package/corpus/templates/design/changelog/2026-08-03-arrow-keys-now-reorder-a-layer-inside-an-auto-layout-frame.md +6 -0
  55. package/corpus/templates/design/changelog/2026-08-03-auto-layout-flow-icons-show-the-direction-at-a-glance-instea.md +6 -0
  56. package/corpus/templates/design/changelog/2026-08-03-auto-layout-icons-share-one-outlined-square-style-so-flow-ga.md +6 -0
  57. package/corpus/templates/design/changelog/2026-08-03-export-has-a-named-preview-section-you-can-expand-replacing-.md +6 -0
  58. package/corpus/templates/design/changelog/2026-08-03-export-preview-shows-the-selected-element-instead-of-the-who.md +6 -0
  59. package/corpus/templates/design/changelog/2026-08-03-inspector-sections-show-an-expand-indicator-so-it-is-clear-w.md +6 -0
  60. package/corpus/templates/design/changelog/2026-08-03-paste-lands-inside-a-selected-frame-instead-of-beside-it.md +6 -0
  61. package/corpus/templates/design/changelog/2026-08-03-the-add-breakpoint-button-sits-outside-the-breakpoint-select.md +6 -0
  62. package/corpus/templates/design/changelog/2026-08-03-the-agent-s-follow-up-questions-keep-space-below-the-continu.md +6 -0
  63. package/corpus/templates/design/changelog/2026-08-03-the-agent-s-follow-up-questions-share-the-chat-panel-s-backg.md +6 -0
  64. package/corpus/templates/design/changelog/2026-08-03-the-export-panel-no-longer-stacks-a-duplicate-export-block-o.md +6 -0
  65. package/corpus/templates/design/changelog/2026-08-03-the-text-tool-uses-a-t-icon-matching-the-letter-it-inserts.md +6 -0
  66. package/corpus/templates/factory/.env.example +17 -0
  67. package/corpus/templates/factory/AGENTS.md +27 -17
  68. package/corpus/templates/factory/README.md +19 -9
  69. package/corpus/templates/factory/actions/get-slack-feedback-context.ts +90 -0
  70. package/corpus/templates/factory/actions/get-triage-config.ts +14 -3
  71. package/corpus/templates/factory/actions/govern-agent-native-pull-request.ts +386 -0
  72. package/corpus/templates/factory/actions/list-factory-automations.ts +53 -0
  73. package/corpus/templates/factory/actions/list-triage-items.ts +7 -2
  74. package/corpus/templates/factory/actions/poll-github-sources.ts +203 -0
  75. package/corpus/templates/factory/actions/poll-sentry-errors.ts +161 -0
  76. package/corpus/templates/factory/actions/poll-slack-channel.ts +4 -2
  77. package/corpus/templates/factory/actions/run-factory-automation.ts +42 -0
  78. package/corpus/templates/factory/actions/save-factory-automation.ts +69 -0
  79. package/corpus/templates/factory/actions/save-triage-config.ts +28 -2
  80. package/corpus/templates/factory/actions/start-builder-for-item.ts +411 -0
  81. package/corpus/templates/factory/app/components/factory/FactoryCanvas.tsx +14 -3
  82. package/corpus/templates/factory/app/components/ui/checkbox.tsx +1 -0
  83. package/corpus/templates/factory/app/hooks/use-navigation-state.ts +7 -0
  84. package/corpus/templates/factory/app/i18n/en-US.ts +35 -1
  85. package/corpus/templates/factory/app/routes/factory.tsx +462 -9
  86. package/corpus/templates/factory/changelog/2026-08-04-added-organization-owned-factory-automations-for-slack-bug-t.md +6 -0
  87. package/corpus/templates/factory/changelog/2026-08-04-automation-editor-controls-and-model-picker.md +6 -0
  88. package/corpus/templates/factory/netlify.toml +2 -2
  89. package/corpus/templates/factory/server/connectors/credentials.ts +6 -5
  90. package/corpus/templates/factory/server/connectors/slack.ts +133 -5
  91. package/corpus/templates/factory/server/db/schema.ts +6 -0
  92. package/corpus/templates/factory/server/lib/require-factory-automation.ts +65 -0
  93. package/corpus/templates/factory/server/plugins/agent-chat.ts +29 -11
  94. package/corpus/templates/factory/server/plugins/auth.ts +1 -0
  95. package/corpus/templates/factory/server/plugins/factory-migrations.ts +12 -0
  96. package/corpus/templates/factory/server/plugins/factory-scheduler-job.ts +218 -67
  97. package/corpus/templates/factory/server/triage/builder-executor.ts +4 -0
  98. package/corpus/templates/factory/server/triage/contracts.ts +14 -1
  99. package/corpus/templates/factory/server/triage/github-client.ts +404 -0
  100. package/corpus/templates/factory/server/triage/metadata.ts +44 -0
  101. package/corpus/templates/factory/server/triage/pr-babysit.ts +5 -5
  102. package/corpus/templates/factory/server/triage/pr-policy.ts +144 -0
  103. package/corpus/templates/factory/server/triage/sentry-client.ts +180 -0
  104. package/corpus/templates/factory/server/triage/slack-client.ts +43 -0
  105. package/corpus/templates/factory/server/triage/slack-poller.ts +9 -2
  106. package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +27 -0
  107. package/corpus/templates/plan/.agents/skills/visual-plan/references/canvas.md +14 -4
  108. package/corpus/templates/plan/.agents/skills/visual-plan/references/wireframe.md +7 -0
  109. package/corpus/templates/plan/.agents/skills/visual-recap/references/wireframe.md +7 -0
  110. package/corpus/templates/plan/actions/create-plan-design.ts +8 -6
  111. package/corpus/templates/plan/actions/create-prototype-plan.ts +8 -6
  112. package/corpus/templates/plan/actions/create-ui-plan.ts +7 -7
  113. package/corpus/templates/plan/actions/get-plan-blocks.ts +7 -1
  114. package/corpus/templates/plan/actions/validate-plan-input.ts +39 -0
  115. package/corpus/templates/plan/app/components/plan/CanvasArea.tsx +167 -11
  116. package/corpus/templates/plan/app/i18n/en-US.ts +1 -0
  117. package/corpus/templates/plan/changelog/2026-08-04-canvas-zoom-controls-now-explain-the-command-ctrl-plus-scrol.md +6 -0
  118. package/corpus/templates/plan/changelog/2026-08-04-pinch-to-zoom-is-now-supported-on-touchscreens-in-visual-pla.md +6 -0
  119. package/corpus/templates/plan/shared/plan-content.ts +17 -2
  120. package/dist/cli/skills-content/canvas.d.ts +3 -3
  121. package/dist/cli/skills-content/canvas.js +16 -5
  122. package/dist/cli/skills-content/visual-plan-skill.d.ts +1 -1
  123. package/dist/cli/skills-content/visual-plan-skill.js +27 -0
  124. package/dist/cli/skills-content/wireframe.d.ts +2 -2
  125. package/dist/cli/skills-content/wireframe.js +7 -0
  126. package/dist/client/AgentPanel.js +23 -8
  127. package/dist/client/api-path.d.ts +6 -0
  128. package/dist/client/api-path.js +55 -0
  129. package/dist/client/onboarding/FirstRunOnboarding.d.ts +3 -0
  130. package/dist/client/onboarding/FirstRunOnboarding.js +93 -0
  131. package/dist/client/onboarding/first-run-enabled.d.ts +2 -0
  132. package/dist/client/onboarding/first-run-enabled.js +9 -0
  133. package/dist/client/onboarding/index.d.ts +2 -1
  134. package/dist/client/onboarding/index.js +1 -0
  135. package/dist/client/onboarding/use-onboarding.d.ts +6 -1
  136. package/dist/client/onboarding/use-onboarding.js +32 -1
  137. package/dist/client/route-state.js +10 -0
  138. package/dist/client/settings/SecretsSection.js +32 -8
  139. package/dist/collab/struct-routes.d.ts +1 -1
  140. package/dist/connections/catalog.d.ts +4 -4
  141. package/dist/connections/catalog.js +3 -3
  142. package/dist/db/index.d.ts +1 -1
  143. package/dist/db/index.js +1 -1
  144. package/dist/localization/default-messages.d.ts +5 -0
  145. package/dist/localization/default-messages.js +5 -0
  146. package/dist/mcp/screen-memory-stdio.d.ts +7 -7
  147. package/dist/observability/routes.d.ts +3 -3
  148. package/dist/onboarding/app-profile.d.ts +4 -0
  149. package/dist/onboarding/app-profile.js +378 -0
  150. package/dist/onboarding/index.d.ts +2 -1
  151. package/dist/onboarding/index.js +1 -0
  152. package/dist/onboarding/plugin.d.ts +2 -0
  153. package/dist/onboarding/plugin.js +21 -1
  154. package/dist/onboarding/types.d.ts +19 -0
  155. package/dist/progress/routes.d.ts +1 -1
  156. package/dist/provider-api/actions/custom-provider-registration.d.ts +9 -9
  157. package/dist/provider-api/actions/provider-api.d.ts +12 -12
  158. package/dist/secrets/routes.d.ts +2 -2
  159. package/dist/secrets/routes.js +41 -17
  160. package/dist/server/auth.js +21 -1
  161. package/dist/server/better-auth-instance.d.ts +3 -2
  162. package/dist/server/better-auth-instance.js +9 -7
  163. package/dist/server/email-markdown.js +3 -8
  164. package/dist/server/transcribe-voice.d.ts +1 -1
  165. package/dist/shared/first-run-onboarding.d.ts +3 -0
  166. package/dist/shared/first-run-onboarding.js +3 -0
  167. package/dist/triggers/index.d.ts +3 -0
  168. package/dist/triggers/index.js +5 -0
  169. package/docs/content/cross-app-sso.mdx +26 -0
  170. package/package.json +1 -1
@@ -77,6 +77,18 @@ type WorldPoint = {
77
77
  y: number;
78
78
  };
79
79
 
80
+ type ClientPoint = {
81
+ x: number;
82
+ y: number;
83
+ };
84
+
85
+ type PinchGesture = {
86
+ pointerIds: [number, number];
87
+ startDistance: number;
88
+ startMidpoint: ClientPoint;
89
+ startView: CanvasView;
90
+ };
91
+
80
92
  type PendingMarkup = {
81
93
  mode: "text" | "callout";
82
94
  origin: WorldPoint;
@@ -140,6 +152,10 @@ export function CanvasArea({
140
152
  [canvas.viewport?.pan?.x, canvas.viewport?.pan?.y, canvas.viewport?.zoom],
141
153
  );
142
154
  const [view, setView] = useState<CanvasView>(initialView);
155
+ const viewRef = useRef(view);
156
+ viewRef.current = view;
157
+ const activePointersRef = useRef(new Map<number, ClientPoint>());
158
+ const pinchGestureRef = useRef<PinchGesture | null>(null);
143
159
  const [drag, setDrag] = useState<{
144
160
  pointerId: number;
145
161
  startX: number;
@@ -581,8 +597,48 @@ export function CanvasArea({
581
597
  const onPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {
582
598
  if (event.button !== 0 && event.button !== 1) return;
583
599
  const target = event.target as HTMLElement;
600
+ const activePointers = activePointersRef.current;
584
601
  // Don't start a pan when grabbing interactive chrome (zoom controls etc.).
585
- if (event.button === 0 && target.closest("[data-plan-interactive]")) return;
602
+ if (
603
+ event.button === 0 &&
604
+ target.closest("[data-plan-interactive]") &&
605
+ activePointers.size === 0
606
+ ) {
607
+ return;
608
+ }
609
+ activePointers.set(event.pointerId, {
610
+ x: event.clientX,
611
+ y: event.clientY,
612
+ });
613
+ if (activePointers.size >= 2) {
614
+ const pointerIds = Array.from(activePointers.keys()).slice(0, 2) as [
615
+ number,
616
+ number,
617
+ ];
618
+ const first = activePointers.get(pointerIds[0]);
619
+ const second = activePointers.get(pointerIds[1]);
620
+ if (!first || !second) return;
621
+ const rect = viewportRef.current?.getBoundingClientRect();
622
+ const startMidpoint = getMidpoint(first, second);
623
+ pinchGestureRef.current = {
624
+ pointerIds,
625
+ startDistance: getDistance(first, second),
626
+ startMidpoint: rect
627
+ ? {
628
+ x: startMidpoint.x - rect.left,
629
+ y: startMidpoint.y - rect.top,
630
+ }
631
+ : startMidpoint,
632
+ startView: viewRef.current,
633
+ };
634
+ setDrag(null);
635
+ setDraftCallout(null);
636
+ setPendingMarkup(null);
637
+ event.preventDefault();
638
+ event.stopPropagation();
639
+ event.currentTarget.setPointerCapture(event.pointerId);
640
+ return;
641
+ }
586
642
  if (!isEditableShortcutTarget(target)) {
587
643
  event.currentTarget.focus({ preventScroll: true });
588
644
  }
@@ -674,6 +730,37 @@ export function CanvasArea({
674
730
  onPointerDown={onPointerDown}
675
731
  onKeyDown={onViewportKeyDown}
676
732
  onPointerMove={(event) => {
733
+ const activePointer = activePointersRef.current.get(event.pointerId);
734
+ if (activePointer) {
735
+ activePointer.x = event.clientX;
736
+ activePointer.y = event.clientY;
737
+ }
738
+ const pinchGesture = pinchGestureRef.current;
739
+ if (pinchGesture) {
740
+ const first = activePointersRef.current.get(
741
+ pinchGesture.pointerIds[0],
742
+ );
743
+ const second = activePointersRef.current.get(
744
+ pinchGesture.pointerIds[1],
745
+ );
746
+ const rect = viewportRef.current?.getBoundingClientRect();
747
+ if (!first || !second || !rect) return;
748
+ const midpoint = getMidpoint(first, second);
749
+ const currentMidpoint = {
750
+ x: midpoint.x - rect.left,
751
+ y: midpoint.y - rect.top,
752
+ };
753
+ updateView(() =>
754
+ viewForPinchGesture({
755
+ gesture: pinchGesture,
756
+ currentDistance: getDistance(first, second),
757
+ currentMidpoint,
758
+ }),
759
+ );
760
+ event.preventDefault();
761
+ event.stopPropagation();
762
+ return;
763
+ }
677
764
  if (draftCallout?.pointerId === event.pointerId) {
678
765
  const point = clientPointToWorld(event);
679
766
  if (!point) return;
@@ -697,6 +784,28 @@ export function CanvasArea({
697
784
  }));
698
785
  }}
699
786
  onPointerUp={(event) => {
787
+ activePointersRef.current.delete(event.pointerId);
788
+ if (pinchGestureRef.current) {
789
+ event.preventDefault();
790
+ event.stopPropagation();
791
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) {
792
+ event.currentTarget.releasePointerCapture(event.pointerId);
793
+ }
794
+ const remaining = Array.from(
795
+ activePointersRef.current.entries(),
796
+ )[0];
797
+ pinchGestureRef.current = null;
798
+ if (remaining) {
799
+ setDrag({
800
+ pointerId: remaining[0],
801
+ startX: remaining[1].x,
802
+ startY: remaining[1].y,
803
+ panX: viewRef.current.pan.x,
804
+ panY: viewRef.current.pan.y,
805
+ });
806
+ }
807
+ return;
808
+ }
700
809
  if (draftCallout?.pointerId === event.pointerId) {
701
810
  const point = clientPointToWorld(event) ?? draftCallout.current;
702
811
  event.preventDefault();
@@ -722,7 +831,9 @@ export function CanvasArea({
722
831
  setDrag(null);
723
832
  }
724
833
  }}
725
- onPointerCancel={() => {
834
+ onPointerCancel={(event) => {
835
+ activePointersRef.current.delete(event.pointerId);
836
+ pinchGestureRef.current = null;
726
837
  setDraftCallout(null);
727
838
  setDrag(null);
728
839
  }}
@@ -838,6 +949,7 @@ export function CanvasArea({
838
949
  <div
839
950
  className="plan-canvas-zoom absolute bottom-3 left-3 z-10 flex items-center gap-0.5 rounded-lg border border-plan-line bg-plan-chrome p-0.5 shadow-md backdrop-blur"
840
951
  data-plan-interactive
952
+ title={t("raw.canvas.zoomHint")}
841
953
  >
842
954
  <Button
843
955
  type="button"
@@ -912,6 +1024,18 @@ function surfaceOf(frame: PlanArtboard): PlanWireframeSurface {
912
1024
  return frame.surface ?? frame.wireframe?.surface ?? "desktop";
913
1025
  }
914
1026
 
1027
+ /**
1028
+ * Keep the surface width stable while allowing long screens to reserve a
1029
+ * taller, non-scrolling artboard in canvas mode.
1030
+ */
1031
+ export function canvasFrameSize(frame: PlanArtboard) {
1032
+ const preset = SURFACE_SIZE[surfaceOf(frame)];
1033
+ return {
1034
+ width: preset.width,
1035
+ height: Math.max(preset.height, frame.height ?? preset.height),
1036
+ };
1037
+ }
1038
+
915
1039
  function sameCanvasView(a: CanvasView, b: CanvasView) {
916
1040
  return (
917
1041
  Math.abs(a.zoom - b.zoom) < 0.0001 &&
@@ -980,11 +1104,9 @@ function layoutArtboards(frames: PlanArtboard[]): PlanArtboard[] {
980
1104
 
981
1105
  return frames.map((frame) => {
982
1106
  const surface = surfaceOf(frame);
983
- const preset = SURFACE_SIZE[surface];
984
- // SURFACE owns the footprint/aspect ignore any model-supplied width/height
985
- // so a popover is always ~square and can never render "too wide".
986
- const width = preset.width;
987
- const height = preset.height;
1107
+ // Surface owns the width/aspect. A larger explicit height is the
1108
+ // non-scrolling escape hatch for long HTML screens on the canvas.
1109
+ const { width, height } = canvasFrameSize(frame);
988
1110
 
989
1111
  if (frame.x !== undefined || frame.y !== undefined) {
990
1112
  return {
@@ -1038,10 +1160,7 @@ function CanvasArtboard({
1038
1160
  onDesignElementSelect?: (selection: DesignElementSelection) => void;
1039
1161
  }) {
1040
1162
  const surface = surfaceOf(frame);
1041
- const preset = SURFACE_SIZE[surface];
1042
- // SURFACE-locked footprint (see layoutArtboards) — model width/height ignored.
1043
- const width = preset.width;
1044
- const height = preset.height;
1163
+ const { width, height } = canvasFrameSize(frame);
1045
1164
  const label = frame.label ?? block?.title;
1046
1165
  // Report the frame's real rendered height so board connectors can anchor to
1047
1166
  // the content box (frames are capped at `height` but usually shorter).
@@ -2280,6 +2399,43 @@ function connectorRoute(
2280
2399
  };
2281
2400
  }
2282
2401
 
2402
+ export function viewForPinchGesture(input: {
2403
+ gesture: PinchGesture;
2404
+ currentDistance: number;
2405
+ currentMidpoint: ClientPoint;
2406
+ }): CanvasView {
2407
+ const { gesture, currentDistance, currentMidpoint } = input;
2408
+ const nextZoom = clamp(
2409
+ gesture.startView.zoom * (currentDistance / gesture.startDistance),
2410
+ MIN_ZOOM,
2411
+ MAX_ZOOM,
2412
+ );
2413
+ const worldX =
2414
+ (gesture.startMidpoint.x - gesture.startView.pan.x) /
2415
+ gesture.startView.zoom;
2416
+ const worldY =
2417
+ (gesture.startMidpoint.y - gesture.startView.pan.y) /
2418
+ gesture.startView.zoom;
2419
+ return {
2420
+ zoom: nextZoom,
2421
+ pan: {
2422
+ x: currentMidpoint.x - worldX * nextZoom,
2423
+ y: currentMidpoint.y - worldY * nextZoom,
2424
+ },
2425
+ };
2426
+ }
2427
+
2428
+ function getMidpoint(first: ClientPoint, second: ClientPoint): ClientPoint {
2429
+ return {
2430
+ x: (first.x + second.x) / 2,
2431
+ y: (first.y + second.y) / 2,
2432
+ };
2433
+ }
2434
+
2435
+ function getDistance(first: ClientPoint, second: ClientPoint) {
2436
+ return Math.max(Math.hypot(first.x - second.x, first.y - second.y), 1);
2437
+ }
2438
+
2283
2439
  function distance(a: WorldPoint, b: WorldPoint) {
2284
2440
  return Math.hypot(a.x - b.x, a.y - b.y);
2285
2441
  }
@@ -157,6 +157,7 @@ const messages = {
157
157
  artboardCanvas: "Plan artboard canvas",
158
158
  zoomIn: "Zoom in",
159
159
  zoomOut: "Zoom out",
160
+ zoomHint: "Hold ⌘/Ctrl and scroll to zoom",
160
161
  markupSaveFailed: "Couldn't save markup. Try again.",
161
162
  },
162
163
  document: {
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: improved
3
+ date: 2026-08-04
4
+ ---
5
+
6
+ Canvas zoom controls now explain the Command/Ctrl plus scroll shortcut
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: improved
3
+ date: 2026-08-04
4
+ ---
5
+
6
+ Pinch to zoom is now supported on touchscreens in visual plan canvases
@@ -1495,12 +1495,27 @@ export const questionFormDataSchema: z.ZodType<PlanQuestionFormBlock["data"]> =
1495
1495
  submitLabel: z.string().trim().max(400).optional(),
1496
1496
  });
1497
1497
 
1498
+ /**
1499
+ * Rich-text stores Markdown as runtime text. A fully escaped one-line payload
1500
+ * ("### Heading\\n\\nBody") renders as one giant heading, so reject that shape at
1501
+ * the shared schema instead of persisting a document that only looks valid.
1502
+ * Escapes are still fine when they occur alongside real line breaks, such as
1503
+ * an intentional `\\n` inside a code example.
1504
+ */
1505
+ const planMarkdownSchema = z
1506
+ .string()
1507
+ .max(100_000)
1508
+ .refine(
1509
+ (value) => value.includes("\n") || !value.includes("\\n"),
1510
+ "Rich-text Markdown must use actual line breaks, not a fully escaped `\\n` string.",
1511
+ );
1512
+
1498
1513
  export const planBlockSchema: z.ZodType<PlanBlock> = z.lazy(() =>
1499
1514
  z.discriminatedUnion("type", [
1500
1515
  baseBlockSchema.extend({
1501
1516
  type: z.literal("rich-text"),
1502
1517
  data: z.object({
1503
- markdown: z.string().max(100_000),
1518
+ markdown: planMarkdownSchema,
1504
1519
  }),
1505
1520
  }),
1506
1521
  baseBlockSchema.extend({
@@ -2758,7 +2773,7 @@ const planContentPatchUnion = z.discriminatedUnion("op", [
2758
2773
  op: z.literal("update-rich-text"),
2759
2774
  blockId: idSchema,
2760
2775
  title: z.string().trim().min(1).max(180).optional(),
2761
- markdown: z.string().max(100_000).optional(),
2776
+ markdown: planMarkdownSchema.optional(),
2762
2777
  }),
2763
2778
  z.object({
2764
2779
  op: z.literal("update-custom-html"),
@@ -1,4 +1,4 @@
1
- export declare const CANVAS_SURFACE_CORE = "<!-- SHARED-CORE:canvas-surface START -->\n\n**The coordinate rule.** The `surface` locks each artboard's footprint and\naspect \u2014 never set artboard width/height and never use coordinates inside the\nwireframe HTML; board-level artboard `x`/`y` IS allowed when it creates clear\nlanes. Let canvas auto-placement handle simple one-row boards.\n\n**Lay out mixed canvases in lanes.** When a canvas contains broad browser /\ndesktop frames plus compact `mobile`, `popover`, or `panel` surfaces, do not put\neverything in one horizontal strip. Use board-level artboard `x`/`y` to reserve\nlanes with generous empty space: main flow on one row, compact surfaces in their\nown column or row, and loading/error states in a lower row. Keep at least 96px\nbetween rendered artboard rectangles plus room for annotation gutters; when a\nbroad browser/desktop frame sits beside a compact panel/popover, leave at least\n160px so frame borders, labels, and hover controls never touch. Connect only\nneighboring steps; never draw a long connector that skips across unrelated\nframes. Connector labels must sit in open canvas space. If the label would touch\nor cross either artboard, remove the label and explain the transition with a\nnearby annotation instead. Before handoff, inspect the top canvas at default zoom\nand move any frame whose label, connector, or annotation crosses another frame.\n\n**Board-unit spacing defaults.** The canvas coordinate system uses approximately 2 board units per screen pixel. `browser` frames occupy roughly 700 \u00D7 600 board units; `desktop` frames roughly 900 \u00D7 700 board units. Apply these minimum x/y gaps when placing frames explicitly \u2014 any less and frames will touch or overlap:\n\n- x-gap between `browser` frames: **\u2265 1100** (700-unit frame + 400-unit gutter)\n- x-gap between `desktop` frames: **\u2265 1300** (900-unit frame + 400-unit gutter)\n- y-gap between rows of any surface: **\u2265 1400** (includes frame height + section header + buffer)\n\nWhen in doubt, use larger values \u2014 the canvas auto-zooms to fit everything.\n\n**Canvas annotations are designer notes on the artboard.** When a top canvas is\npresent, sprinkle design-review notes near the frames they explain: a short\nheading, supporting text, and bullets \u2014 plain text layers, never bordered or\nshadowed cards, and never a box around a frame. The renderer spaces notes away\nfrom frames, so place each note by the frame it describes. Use an arrow only to\npoint at one specific control or transition; for a broad frame-level note, write\ntext beside the frame with no connector. Connectors are for real sequences only \u2014\nnever fake \"Step 1 \u2192 Step 2\" lines between independent states.\n\n**Do not create overlapping annotations.** Anchor each ordinary note to the\nframe it explains with `targetId` + `placement` (top/right/bottom/left), and\nomit `type` or use `type: \"note\"`. The renderer parks notes in a gutter beside\nthe frame and lays them out automatically. Do not use `type: \"callout\"`,\n`type: \"text\"`, `type: \"arrow\"`, x/y, or points for ordinary notes; those are\nfreeform review-markup layers and must be reserved for intentional markup in\nopen canvas space. Reserve arrows for a note that must point at one specific\ncontrol inside a frame; a note that simply sits beside its frame needs no arrow.\n\n**Patching.** Edit one wireframe, canvas annotation, diagram, or block with targeted `contentPatches`\n(for example `patch-wireframe-html`, `patch-diagram-html`, `update-block`,\n`replace-blocks`, `update-canvas-annotation`) rather\nthan regenerating the whole plan. `contentPatches` are part of the public MCP\naction schema, so Claude Code, Codex, Cursor, and other hosts can make surgical\nedits. If an agent is working from exported source files, use\n`read-visual-plan-source` / `patch-visual-plan-source`: `plan.mdx` holds\nfrontmatter plus markdown/document blocks, `canvas.mdx` holds\n`<DesignBoard>/<Section>/<Artboard>/<Screen>/<Annotation>/<Connector>`, and the\npatch action normalizes the MDX back into the same JSON runtime model. JSON is\nthe canonical runtime shape; MDX is the repo-friendly authoring/export surface.\nIn the browser, humans edit `rich-text` prose inline; agents should still use\n`update-rich-text` content patches or source patches for prose, and use\ncomments/structured patches for canvas, artboard, wireframe, and diagram edits.\nNever send a partial top-level `content` object as a shortcut to add a canvas,\nframe, or block: `content` is a full structured replacement, so omitted blocks\nor surfaces can disappear. If a full replacement is truly unavoidable, read the\ncomplete source/JSON first, include every existing block and surface in the new\npayload, and verify the source/export immediately after the update.\n\n**Never emit a titled artboard with no interior wireframe content.** Every artboard\nyou place on the canvas must carry an `html` wireframe or reference a wireframe\nblock via `blockId`; when using `blockId`, the referenced `wireframe` /\n`legacy-wireframe` block must remain in the plan. If you remove a duplicate\nwireframe from the document body, first move its `data` inline onto the\ncorresponding `content.canvas.frames[*].wireframe` / `legacyWireframe`. A\nlabel-only frame or a frame pointing at a deleted block renders empty and is\nrejected at parse time. If you only have a title, write it as a section header or\nannotation, not an empty artboard.\n\n**UI mockups belong in the top visual review area.** Static UI/product visuals\nlive on the canvas; multi-step UI flows get both canvas wireframes and a\nprototype. When the user asks for a mockup, UI state, loading state, layout,\nscreen, or visual comparison, make the canvas the primary home for that static\nvisual. When the user asks for a prototype or the plan contains a sequence the\nreviewer must feel, keep the canvas artboards and add `content.prototype` so the\ntop surface shows Wireframes / Prototype tabs. Architecture/code diagrams stay\ninline in the document (the SKILL.md Visual Surface Choice section owns that\nrule) unless the user explicitly asks for a spatial board. Document blocks\ncan explain, compare, or map implementation, but they should not host the\nprimary UI mockup or prototype just because `custom-html`, screenshots, or prose\nare easier to produce. If the canvas/prototype surface cannot represent the\nrequested UI fidelity, still keep the closest top-surface representation and\ncall out or extend the needed renderer capability. A skeleton/loading mockup\nalso lives in a canvas artboard \u2014 never move a mockup out of the canvas.\n\n**Storyboards are canvas artifacts, not document diagrams.** When the requested\noutput is a product flow, onboarding journey, \"light storyboard\", or canvas\nwireframe, author the flow as multiple top-canvas artboards with real screen\ncontent and neighboring connectors. Keep document-body `diagram` blocks for\narchitecture and mechanics that are not themselves user-visible screens. A\nstoryboard made from a single inline HTML diagram is the wrong surface.\n\nFor abstract product concepts, use the canvas to create the first \"I get it\"\nmoment: one real app state near the top showing how the concept appears to a\nuser, followed by separate annotations or diagrams for mechanics. Do not make\nthe first artboard a hybrid of app UI and architecture notes; the app screen\nshould be inspectable as product UI on its own.\n\n**Legacy kit tree.** Older plans set a `screen` array of `{ el, ...props }` kit\nnodes instead of `html`; the renderer still accepts and displays it so saved\nplans round-trip, but new plans emit `html`. Do not author fresh kit-tree\nscreens, and do not put nested kit components such as `<FrameScreen>`, `<Card>`,\n`<Row>`, `<Title>`, or `<Btn>` inside a canvas `<Screen>`. A new canvas artboard\nwith kit-tree children is a defect: replace it with\n`<Screen surface=\"...\" html={...} />` using the HTML wireframe rules. The HTML\npath is the one that gets the renderer-owned surface sizing, theme tokens,\nsketch/clean toggle, and safe text layout used by good document-body\nwireframes. Likewise, old or imported plans may carry coordinate-based regions\nor free-float x/y on notes; those are legacy escape hatches the renderer still\nshows but you must never produce. The gutter parks notes by `targetId` +\n`placement`, and the coordinate rule at the top of this file governs all\nnew-plan placement.\n\n<!-- SHARED-CORE:canvas-surface END -->";
2
- export declare const CANVAS_REFERENCE_MD = "# Canvas & artboard placement \u2014 single source of truth\n\nThis file is the canonical guide for how the visual-plan canvas works: artboard\nplacement, lane layout, annotations, patching, and the legacy kit tree. Read it\nin full before authoring or editing any canvas/artboard content; do not author\ncanvas layouts from memory or paraphrase these rules per mode.\n\n<!-- SHARED-CORE:canvas-surface START -->\n\n**The coordinate rule.** The `surface` locks each artboard's footprint and\naspect \u2014 never set artboard width/height and never use coordinates inside the\nwireframe HTML; board-level artboard `x`/`y` IS allowed when it creates clear\nlanes. Let canvas auto-placement handle simple one-row boards.\n\n**Lay out mixed canvases in lanes.** When a canvas contains broad browser /\ndesktop frames plus compact `mobile`, `popover`, or `panel` surfaces, do not put\neverything in one horizontal strip. Use board-level artboard `x`/`y` to reserve\nlanes with generous empty space: main flow on one row, compact surfaces in their\nown column or row, and loading/error states in a lower row. Keep at least 96px\nbetween rendered artboard rectangles plus room for annotation gutters; when a\nbroad browser/desktop frame sits beside a compact panel/popover, leave at least\n160px so frame borders, labels, and hover controls never touch. Connect only\nneighboring steps; never draw a long connector that skips across unrelated\nframes. Connector labels must sit in open canvas space. If the label would touch\nor cross either artboard, remove the label and explain the transition with a\nnearby annotation instead. Before handoff, inspect the top canvas at default zoom\nand move any frame whose label, connector, or annotation crosses another frame.\n\n**Board-unit spacing defaults.** The canvas coordinate system uses approximately 2 board units per screen pixel. `browser` frames occupy roughly 700 \u00D7 600 board units; `desktop` frames roughly 900 \u00D7 700 board units. Apply these minimum x/y gaps when placing frames explicitly \u2014 any less and frames will touch or overlap:\n\n- x-gap between `browser` frames: **\u2265 1100** (700-unit frame + 400-unit gutter)\n- x-gap between `desktop` frames: **\u2265 1300** (900-unit frame + 400-unit gutter)\n- y-gap between rows of any surface: **\u2265 1400** (includes frame height + section header + buffer)\n\nWhen in doubt, use larger values \u2014 the canvas auto-zooms to fit everything.\n\n**Canvas annotations are designer notes on the artboard.** When a top canvas is\npresent, sprinkle design-review notes near the frames they explain: a short\nheading, supporting text, and bullets \u2014 plain text layers, never bordered or\nshadowed cards, and never a box around a frame. The renderer spaces notes away\nfrom frames, so place each note by the frame it describes. Use an arrow only to\npoint at one specific control or transition; for a broad frame-level note, write\ntext beside the frame with no connector. Connectors are for real sequences only \u2014\nnever fake \"Step 1 \u2192 Step 2\" lines between independent states.\n\n**Do not create overlapping annotations.** Anchor each ordinary note to the\nframe it explains with `targetId` + `placement` (top/right/bottom/left), and\nomit `type` or use `type: \"note\"`. The renderer parks notes in a gutter beside\nthe frame and lays them out automatically. Do not use `type: \"callout\"`,\n`type: \"text\"`, `type: \"arrow\"`, x/y, or points for ordinary notes; those are\nfreeform review-markup layers and must be reserved for intentional markup in\nopen canvas space. Reserve arrows for a note that must point at one specific\ncontrol inside a frame; a note that simply sits beside its frame needs no arrow.\n\n**Patching.** Edit one wireframe, canvas annotation, diagram, or block with targeted `contentPatches`\n(for example `patch-wireframe-html`, `patch-diagram-html`, `update-block`,\n`replace-blocks`, `update-canvas-annotation`) rather\nthan regenerating the whole plan. `contentPatches` are part of the public MCP\naction schema, so Claude Code, Codex, Cursor, and other hosts can make surgical\nedits. If an agent is working from exported source files, use\n`read-visual-plan-source` / `patch-visual-plan-source`: `plan.mdx` holds\nfrontmatter plus markdown/document blocks, `canvas.mdx` holds\n`<DesignBoard>/<Section>/<Artboard>/<Screen>/<Annotation>/<Connector>`, and the\npatch action normalizes the MDX back into the same JSON runtime model. JSON is\nthe canonical runtime shape; MDX is the repo-friendly authoring/export surface.\nIn the browser, humans edit `rich-text` prose inline; agents should still use\n`update-rich-text` content patches or source patches for prose, and use\ncomments/structured patches for canvas, artboard, wireframe, and diagram edits.\nNever send a partial top-level `content` object as a shortcut to add a canvas,\nframe, or block: `content` is a full structured replacement, so omitted blocks\nor surfaces can disappear. If a full replacement is truly unavoidable, read the\ncomplete source/JSON first, include every existing block and surface in the new\npayload, and verify the source/export immediately after the update.\n\n**Never emit a titled artboard with no interior wireframe content.** Every artboard\nyou place on the canvas must carry an `html` wireframe or reference a wireframe\nblock via `blockId`; when using `blockId`, the referenced `wireframe` /\n`legacy-wireframe` block must remain in the plan. If you remove a duplicate\nwireframe from the document body, first move its `data` inline onto the\ncorresponding `content.canvas.frames[*].wireframe` / `legacyWireframe`. A\nlabel-only frame or a frame pointing at a deleted block renders empty and is\nrejected at parse time. If you only have a title, write it as a section header or\nannotation, not an empty artboard.\n\n**UI mockups belong in the top visual review area.** Static UI/product visuals\nlive on the canvas; multi-step UI flows get both canvas wireframes and a\nprototype. When the user asks for a mockup, UI state, loading state, layout,\nscreen, or visual comparison, make the canvas the primary home for that static\nvisual. When the user asks for a prototype or the plan contains a sequence the\nreviewer must feel, keep the canvas artboards and add `content.prototype` so the\ntop surface shows Wireframes / Prototype tabs. Architecture/code diagrams stay\ninline in the document (the SKILL.md Visual Surface Choice section owns that\nrule) unless the user explicitly asks for a spatial board. Document blocks\ncan explain, compare, or map implementation, but they should not host the\nprimary UI mockup or prototype just because `custom-html`, screenshots, or prose\nare easier to produce. If the canvas/prototype surface cannot represent the\nrequested UI fidelity, still keep the closest top-surface representation and\ncall out or extend the needed renderer capability. A skeleton/loading mockup\nalso lives in a canvas artboard \u2014 never move a mockup out of the canvas.\n\n**Storyboards are canvas artifacts, not document diagrams.** When the requested\noutput is a product flow, onboarding journey, \"light storyboard\", or canvas\nwireframe, author the flow as multiple top-canvas artboards with real screen\ncontent and neighboring connectors. Keep document-body `diagram` blocks for\narchitecture and mechanics that are not themselves user-visible screens. A\nstoryboard made from a single inline HTML diagram is the wrong surface.\n\nFor abstract product concepts, use the canvas to create the first \"I get it\"\nmoment: one real app state near the top showing how the concept appears to a\nuser, followed by separate annotations or diagrams for mechanics. Do not make\nthe first artboard a hybrid of app UI and architecture notes; the app screen\nshould be inspectable as product UI on its own.\n\n**Legacy kit tree.** Older plans set a `screen` array of `{ el, ...props }` kit\nnodes instead of `html`; the renderer still accepts and displays it so saved\nplans round-trip, but new plans emit `html`. Do not author fresh kit-tree\nscreens, and do not put nested kit components such as `<FrameScreen>`, `<Card>`,\n`<Row>`, `<Title>`, or `<Btn>` inside a canvas `<Screen>`. A new canvas artboard\nwith kit-tree children is a defect: replace it with\n`<Screen surface=\"...\" html={...} />` using the HTML wireframe rules. The HTML\npath is the one that gets the renderer-owned surface sizing, theme tokens,\nsketch/clean toggle, and safe text layout used by good document-body\nwireframes. Likewise, old or imported plans may carry coordinate-based regions\nor free-float x/y on notes; those are legacy escape hatches the renderer still\nshows but you must never produce. The gutter parks notes by `targetId` +\n`placement`, and the coordinate rule at the top of this file governs all\nnew-plan placement.\n\n<!-- SHARED-CORE:canvas-surface END -->\n";
3
- export declare const CANVAS_REFERENCE_POINTER = "The canvas is the single source of truth for static UI mockups: the `surface`\nlocks each artboard's footprint, mixed surfaces lay out\nin lanes, annotations are plain-text designer notes anchored by\n`targetId`/`placement`, and edits are surgical `contentPatches`. Before\nauthoring or editing ANY canvas, artboard, or annotation, READ\n`references/canvas.md` in this skill directory \u2014 it is the single source of truth\nfor canvas/artboard mechanics. Do not author canvas layouts from memory.";
1
+ export declare const CANVAS_SURFACE_CORE = "<!-- SHARED-CORE:canvas-surface START -->\n\n**The coordinate rule.** The `surface` sets each artboard's default footprint\nand width \u2014 never set width or use coordinates inside the wireframe HTML.\nBoard-level artboard `x`/`y` IS allowed when it creates clear lanes. A\nlarger explicit artboard `height` is allowed when the screen's content needs\nmore vertical room; canvas frames do not scroll, so reserve enough height to\nshow the entire UI. Let canvas auto-placement handle simple one-row boards.\n\n**Lay out mixed canvases in lanes.** When a canvas contains broad browser /\ndesktop frames plus compact `mobile`, `popover`, or `panel` surfaces, do not put\neverything in one horizontal strip. Use board-level artboard `x`/`y` to reserve\nlanes with generous empty space: main flow on one row, compact surfaces in their\nown column or row, and loading/error states in a lower row. Keep at least 96px\nbetween rendered artboard rectangles plus room for annotation gutters; when a\nbroad browser/desktop frame sits beside a compact panel/popover, leave at least\n160px so frame borders, labels, and hover controls never touch. Connect only\nneighboring steps; never draw a long connector that skips across unrelated\nframes. Connector labels must sit in open canvas space. If the label would touch\nor cross either artboard, remove the label and explain the transition with a\nnearby annotation instead. Before handoff, inspect the top canvas at default zoom\nand move any frame whose label, connector, or annotation crosses another frame.\n\n**Board-unit spacing defaults.** The canvas coordinate system uses approximately 2 board units per screen pixel. `browser` frames occupy roughly 700 \u00D7 600 board units; `desktop` frames roughly 900 \u00D7 700 board units. Apply these minimum x/y gaps when placing frames explicitly \u2014 any less and frames will touch or overlap:\n\n- x-gap between `browser` frames: **\u2265 1100** (700-unit frame + 400-unit gutter)\n- x-gap between `desktop` frames: **\u2265 1300** (900-unit frame + 400-unit gutter)\n- y-gap between rows of any surface: **\u2265 1400** (includes frame height + section header + buffer)\n\nWhen in doubt, use larger values \u2014 the canvas auto-zooms to fit everything.\n\n**Full-content artboards.** Canvas frames are pan/zoom surfaces, not scroll\ncontainers. Keep wireframe HTML in natural document flow without an inner\nscroll region or fixed child height. If the screen is taller than the default\nsurface preset, set the artboard's `height` to the measured content height plus\nbreathing room; keep the surface width unchanged. Before handoff, inspect the\nbottom edge of every artboard at default zoom and confirm no control, row, or\nfooter is clipped.\n\n**Canvas annotations are designer notes on the artboard.** When a top canvas is\npresent, sprinkle design-review notes near the frames they explain: a short\nheading, supporting text, and bullets \u2014 plain text layers, never bordered or\nshadowed cards, and never a box around a frame. The renderer spaces notes away\nfrom frames, so place each note by the frame it describes. Use an arrow only to\npoint at one specific control or transition; for a broad frame-level note, write\ntext beside the frame with no connector. Connectors are for real sequences only \u2014\nnever fake \"Step 1 \u2192 Step 2\" lines between independent states.\n\n**Do not create overlapping annotations.** Anchor each ordinary note to the\nframe it explains with `targetId` + `placement` (top/right/bottom/left), and\nomit `type` or use `type: \"note\"`. The renderer parks notes in a gutter beside\nthe frame and lays them out automatically. Do not use `type: \"callout\"`,\n`type: \"text\"`, `type: \"arrow\"`, x/y, or points for ordinary notes; those are\nfreeform review-markup layers and must be reserved for intentional markup in\nopen canvas space. Reserve arrows for a note that must point at one specific\ncontrol inside a frame; a note that simply sits beside its frame needs no arrow.\n\n**Patching.** Edit one wireframe, canvas annotation, diagram, or block with targeted `contentPatches`\n(for example `patch-wireframe-html`, `patch-diagram-html`, `update-block`,\n`replace-blocks`, `update-canvas-annotation`) rather\nthan regenerating the whole plan. `contentPatches` are part of the public MCP\naction schema, so Claude Code, Codex, Cursor, and other hosts can make surgical\nedits. If an agent is working from exported source files, use\n`read-visual-plan-source` / `patch-visual-plan-source`: `plan.mdx` holds\nfrontmatter plus markdown/document blocks, `canvas.mdx` holds\n`<DesignBoard>/<Section>/<Artboard>/<Screen>/<Annotation>/<Connector>`, and the\npatch action normalizes the MDX back into the same JSON runtime model. JSON is\nthe canonical runtime shape; MDX is the repo-friendly authoring/export surface.\nIn the browser, humans edit `rich-text` prose inline; agents should still use\n`update-rich-text` content patches or source patches for prose, and use\ncomments/structured patches for canvas, artboard, wireframe, and diagram edits.\nNever send a partial top-level `content` object as a shortcut to add a canvas,\nframe, or block: `content` is a full structured replacement, so omitted blocks\nor surfaces can disappear. If a full replacement is truly unavoidable, read the\ncomplete source/JSON first, include every existing block and surface in the new\npayload, and verify the source/export immediately after the update.\n\n**Never emit a titled artboard with no interior wireframe content.** Every artboard\nyou place on the canvas must carry an `html` wireframe or reference a wireframe\nblock via `blockId`; when using `blockId`, the referenced `wireframe` /\n`legacy-wireframe` block must remain in the plan. If you remove a duplicate\nwireframe from the document body, first move its `data` inline onto the\ncorresponding `content.canvas.frames[*].wireframe` / `legacyWireframe`. A\nlabel-only frame or a frame pointing at a deleted block renders empty and is\nrejected at parse time. If you only have a title, write it as a section header or\nannotation, not an empty artboard.\n\n**UI mockups belong in the top visual review area.** Static UI/product visuals\nlive on the canvas; multi-step UI flows get both canvas wireframes and a\nprototype. When the user asks for a mockup, UI state, loading state, layout,\nscreen, or visual comparison, make the canvas the primary home for that static\nvisual. When the user asks for a prototype or the plan contains a sequence the\nreviewer must feel, keep the canvas artboards and add `content.prototype` so the\ntop surface shows Wireframes / Prototype tabs. Architecture/code diagrams stay\ninline in the document (the SKILL.md Visual Surface Choice section owns that\nrule) unless the user explicitly asks for a spatial board. Document blocks\ncan explain, compare, or map implementation, but they should not host the\nprimary UI mockup or prototype just because `custom-html`, screenshots, or prose\nare easier to produce. If the canvas/prototype surface cannot represent the\nrequested UI fidelity, still keep the closest top-surface representation and\ncall out or extend the needed renderer capability. A skeleton/loading mockup\nalso lives in a canvas artboard \u2014 never move a mockup out of the canvas.\n\n**Storyboards are canvas artifacts, not document diagrams.** When the requested\noutput is a product flow, onboarding journey, \"light storyboard\", or canvas\nwireframe, author the flow as multiple top-canvas artboards with real screen\ncontent and neighboring connectors. Keep document-body `diagram` blocks for\narchitecture and mechanics that are not themselves user-visible screens. A\nstoryboard made from a single inline HTML diagram is the wrong surface.\n\nFor abstract product concepts, use the canvas to create the first \"I get it\"\nmoment: one real app state near the top showing how the concept appears to a\nuser, followed by separate annotations or diagrams for mechanics. Do not make\nthe first artboard a hybrid of app UI and architecture notes; the app screen\nshould be inspectable as product UI on its own.\n\n**Legacy kit tree.** Older plans set a `screen` array of `{ el, ...props }` kit\nnodes instead of `html`; the renderer still accepts and displays it so saved\nplans round-trip, but new plans emit `html`. Do not author fresh kit-tree\nscreens, and do not put nested kit components such as `<FrameScreen>`, `<Card>`,\n`<Row>`, `<Title>`, or `<Btn>` inside a canvas `<Screen>`. A new canvas artboard\nwith kit-tree children is a defect: replace it with\n`<Screen surface=\"...\" html={...} />` using the HTML wireframe rules. The HTML\npath is the one that gets the renderer-owned surface sizing, theme tokens,\nsketch/clean toggle, and safe text layout used by good document-body\nwireframes. Likewise, old or imported plans may carry coordinate-based regions\nor free-float x/y on notes; those are legacy escape hatches the renderer still\nshows but you must never produce. The gutter parks notes by `targetId` +\n`placement`, and the coordinate rule at the top of this file governs all\nnew-plan placement.\n\n<!-- SHARED-CORE:canvas-surface END -->";
2
+ export declare const CANVAS_REFERENCE_MD = "# Canvas & artboard placement \u2014 single source of truth\n\nThis file is the canonical guide for how the visual-plan canvas works: artboard\nplacement, lane layout, annotations, patching, and the legacy kit tree. Read it\nin full before authoring or editing any canvas/artboard content; do not author\ncanvas layouts from memory or paraphrase these rules per mode.\n\n<!-- SHARED-CORE:canvas-surface START -->\n\n**The coordinate rule.** The `surface` sets each artboard's default footprint\nand width \u2014 never set width or use coordinates inside the wireframe HTML.\nBoard-level artboard `x`/`y` IS allowed when it creates clear lanes. A\nlarger explicit artboard `height` is allowed when the screen's content needs\nmore vertical room; canvas frames do not scroll, so reserve enough height to\nshow the entire UI. Let canvas auto-placement handle simple one-row boards.\n\n**Lay out mixed canvases in lanes.** When a canvas contains broad browser /\ndesktop frames plus compact `mobile`, `popover`, or `panel` surfaces, do not put\neverything in one horizontal strip. Use board-level artboard `x`/`y` to reserve\nlanes with generous empty space: main flow on one row, compact surfaces in their\nown column or row, and loading/error states in a lower row. Keep at least 96px\nbetween rendered artboard rectangles plus room for annotation gutters; when a\nbroad browser/desktop frame sits beside a compact panel/popover, leave at least\n160px so frame borders, labels, and hover controls never touch. Connect only\nneighboring steps; never draw a long connector that skips across unrelated\nframes. Connector labels must sit in open canvas space. If the label would touch\nor cross either artboard, remove the label and explain the transition with a\nnearby annotation instead. Before handoff, inspect the top canvas at default zoom\nand move any frame whose label, connector, or annotation crosses another frame.\n\n**Board-unit spacing defaults.** The canvas coordinate system uses approximately 2 board units per screen pixel. `browser` frames occupy roughly 700 \u00D7 600 board units; `desktop` frames roughly 900 \u00D7 700 board units. Apply these minimum x/y gaps when placing frames explicitly \u2014 any less and frames will touch or overlap:\n\n- x-gap between `browser` frames: **\u2265 1100** (700-unit frame + 400-unit gutter)\n- x-gap between `desktop` frames: **\u2265 1300** (900-unit frame + 400-unit gutter)\n- y-gap between rows of any surface: **\u2265 1400** (includes frame height + section header + buffer)\n\nWhen in doubt, use larger values \u2014 the canvas auto-zooms to fit everything.\n\n**Full-content artboards.** Canvas frames are pan/zoom surfaces, not scroll\ncontainers. Keep wireframe HTML in natural document flow without an inner\nscroll region or fixed child height. If the screen is taller than the default\nsurface preset, set the artboard's `height` to the measured content height plus\nbreathing room; keep the surface width unchanged. Before handoff, inspect the\nbottom edge of every artboard at default zoom and confirm no control, row, or\nfooter is clipped.\n\n**Canvas annotations are designer notes on the artboard.** When a top canvas is\npresent, sprinkle design-review notes near the frames they explain: a short\nheading, supporting text, and bullets \u2014 plain text layers, never bordered or\nshadowed cards, and never a box around a frame. The renderer spaces notes away\nfrom frames, so place each note by the frame it describes. Use an arrow only to\npoint at one specific control or transition; for a broad frame-level note, write\ntext beside the frame with no connector. Connectors are for real sequences only \u2014\nnever fake \"Step 1 \u2192 Step 2\" lines between independent states.\n\n**Do not create overlapping annotations.** Anchor each ordinary note to the\nframe it explains with `targetId` + `placement` (top/right/bottom/left), and\nomit `type` or use `type: \"note\"`. The renderer parks notes in a gutter beside\nthe frame and lays them out automatically. Do not use `type: \"callout\"`,\n`type: \"text\"`, `type: \"arrow\"`, x/y, or points for ordinary notes; those are\nfreeform review-markup layers and must be reserved for intentional markup in\nopen canvas space. Reserve arrows for a note that must point at one specific\ncontrol inside a frame; a note that simply sits beside its frame needs no arrow.\n\n**Patching.** Edit one wireframe, canvas annotation, diagram, or block with targeted `contentPatches`\n(for example `patch-wireframe-html`, `patch-diagram-html`, `update-block`,\n`replace-blocks`, `update-canvas-annotation`) rather\nthan regenerating the whole plan. `contentPatches` are part of the public MCP\naction schema, so Claude Code, Codex, Cursor, and other hosts can make surgical\nedits. If an agent is working from exported source files, use\n`read-visual-plan-source` / `patch-visual-plan-source`: `plan.mdx` holds\nfrontmatter plus markdown/document blocks, `canvas.mdx` holds\n`<DesignBoard>/<Section>/<Artboard>/<Screen>/<Annotation>/<Connector>`, and the\npatch action normalizes the MDX back into the same JSON runtime model. JSON is\nthe canonical runtime shape; MDX is the repo-friendly authoring/export surface.\nIn the browser, humans edit `rich-text` prose inline; agents should still use\n`update-rich-text` content patches or source patches for prose, and use\ncomments/structured patches for canvas, artboard, wireframe, and diagram edits.\nNever send a partial top-level `content` object as a shortcut to add a canvas,\nframe, or block: `content` is a full structured replacement, so omitted blocks\nor surfaces can disappear. If a full replacement is truly unavoidable, read the\ncomplete source/JSON first, include every existing block and surface in the new\npayload, and verify the source/export immediately after the update.\n\n**Never emit a titled artboard with no interior wireframe content.** Every artboard\nyou place on the canvas must carry an `html` wireframe or reference a wireframe\nblock via `blockId`; when using `blockId`, the referenced `wireframe` /\n`legacy-wireframe` block must remain in the plan. If you remove a duplicate\nwireframe from the document body, first move its `data` inline onto the\ncorresponding `content.canvas.frames[*].wireframe` / `legacyWireframe`. A\nlabel-only frame or a frame pointing at a deleted block renders empty and is\nrejected at parse time. If you only have a title, write it as a section header or\nannotation, not an empty artboard.\n\n**UI mockups belong in the top visual review area.** Static UI/product visuals\nlive on the canvas; multi-step UI flows get both canvas wireframes and a\nprototype. When the user asks for a mockup, UI state, loading state, layout,\nscreen, or visual comparison, make the canvas the primary home for that static\nvisual. When the user asks for a prototype or the plan contains a sequence the\nreviewer must feel, keep the canvas artboards and add `content.prototype` so the\ntop surface shows Wireframes / Prototype tabs. Architecture/code diagrams stay\ninline in the document (the SKILL.md Visual Surface Choice section owns that\nrule) unless the user explicitly asks for a spatial board. Document blocks\ncan explain, compare, or map implementation, but they should not host the\nprimary UI mockup or prototype just because `custom-html`, screenshots, or prose\nare easier to produce. If the canvas/prototype surface cannot represent the\nrequested UI fidelity, still keep the closest top-surface representation and\ncall out or extend the needed renderer capability. A skeleton/loading mockup\nalso lives in a canvas artboard \u2014 never move a mockup out of the canvas.\n\n**Storyboards are canvas artifacts, not document diagrams.** When the requested\noutput is a product flow, onboarding journey, \"light storyboard\", or canvas\nwireframe, author the flow as multiple top-canvas artboards with real screen\ncontent and neighboring connectors. Keep document-body `diagram` blocks for\narchitecture and mechanics that are not themselves user-visible screens. A\nstoryboard made from a single inline HTML diagram is the wrong surface.\n\nFor abstract product concepts, use the canvas to create the first \"I get it\"\nmoment: one real app state near the top showing how the concept appears to a\nuser, followed by separate annotations or diagrams for mechanics. Do not make\nthe first artboard a hybrid of app UI and architecture notes; the app screen\nshould be inspectable as product UI on its own.\n\n**Legacy kit tree.** Older plans set a `screen` array of `{ el, ...props }` kit\nnodes instead of `html`; the renderer still accepts and displays it so saved\nplans round-trip, but new plans emit `html`. Do not author fresh kit-tree\nscreens, and do not put nested kit components such as `<FrameScreen>`, `<Card>`,\n`<Row>`, `<Title>`, or `<Btn>` inside a canvas `<Screen>`. A new canvas artboard\nwith kit-tree children is a defect: replace it with\n`<Screen surface=\"...\" html={...} />` using the HTML wireframe rules. The HTML\npath is the one that gets the renderer-owned surface sizing, theme tokens,\nsketch/clean toggle, and safe text layout used by good document-body\nwireframes. Likewise, old or imported plans may carry coordinate-based regions\nor free-float x/y on notes; those are legacy escape hatches the renderer still\nshows but you must never produce. The gutter parks notes by `targetId` +\n`placement`, and the coordinate rule at the top of this file governs all\nnew-plan placement.\n\n<!-- SHARED-CORE:canvas-surface END -->\n";
3
+ export declare const CANVAS_REFERENCE_POINTER = "The canvas is the single source of truth for static UI mockups: the `surface`\nsets each artboard's default footprint and width, while an explicit taller\n`height` keeps long non-scrolling screens fully visible; mixed surfaces lay out\nin lanes, annotations are plain-text designer notes anchored by\n`targetId`/`placement`, and edits are surgical `contentPatches`. Before\nauthoring or editing ANY canvas, artboard, or annotation, READ\n`references/canvas.md` in this skill directory \u2014 it is the single source of truth\nfor canvas/artboard mechanics. Do not author canvas layouts from memory.";
4
4
  //# sourceMappingURL=canvas.d.ts.map
@@ -2,10 +2,12 @@
2
2
  // (visual-recap renders standalone wireframes, not a canvas).
3
3
  export const CANVAS_SURFACE_CORE = `<!-- SHARED-CORE:canvas-surface START -->
4
4
 
5
- **The coordinate rule.** The \`surface\` locks each artboard's footprint and
6
- aspect — never set artboard width/height and never use coordinates inside the
7
- wireframe HTML; board-level artboard \`x\`/\`y\` IS allowed when it creates clear
8
- lanes. Let canvas auto-placement handle simple one-row boards.
5
+ **The coordinate rule.** The \`surface\` sets each artboard's default footprint
6
+ and width — never set width or use coordinates inside the wireframe HTML.
7
+ Board-level artboard \`x\`/\`y\` IS allowed when it creates clear lanes. A
8
+ larger explicit artboard \`height\` is allowed when the screen's content needs
9
+ more vertical room; canvas frames do not scroll, so reserve enough height to
10
+ show the entire UI. Let canvas auto-placement handle simple one-row boards.
9
11
 
10
12
  **Lay out mixed canvases in lanes.** When a canvas contains broad browser /
11
13
  desktop frames plus compact \`mobile\`, \`popover\`, or \`panel\` surfaces, do not put
@@ -29,6 +31,14 @@ and move any frame whose label, connector, or annotation crosses another frame.
29
31
 
30
32
  When in doubt, use larger values — the canvas auto-zooms to fit everything.
31
33
 
34
+ **Full-content artboards.** Canvas frames are pan/zoom surfaces, not scroll
35
+ containers. Keep wireframe HTML in natural document flow without an inner
36
+ scroll region or fixed child height. If the screen is taller than the default
37
+ surface preset, set the artboard's \`height\` to the measured content height plus
38
+ breathing room; keep the surface width unchanged. Before handoff, inspect the
39
+ bottom edge of every artboard at default zoom and confirm no control, row, or
40
+ footer is clipped.
41
+
32
42
  **Canvas annotations are designer notes on the artboard.** When a top canvas is
33
43
  present, sprinkle design-review notes near the frames they explain: a short
34
44
  heading, supporting text, and bullets — plain text layers, never bordered or
@@ -143,7 +153,8 @@ ${CANVAS_SURFACE_CORE}
143
153
  // files so the SKILL.md stays lean (progressive disclosure); the agent loads the
144
154
  // detail on demand.
145
155
  export const CANVAS_REFERENCE_POINTER = `The canvas is the single source of truth for static UI mockups: the \`surface\`
146
- locks each artboard's footprint, mixed surfaces lay out
156
+ sets each artboard's default footprint and width, while an explicit taller
157
+ \`height\` keeps long non-scrolling screens fully visible; mixed surfaces lay out
147
158
  in lanes, annotations are plain-text designer notes anchored by
148
159
  \`targetId\`/\`placement\`, and edits are surgical \`contentPatches\`. Before
149
160
  authoring or editing ANY canvas, artboard, or annotation, READ
@@ -1,2 +1,2 @@
1
- export declare const VISUAL_PLANS_SKILL_MD = "---\nname: visual-plan\ndescription: >-\n Turn ordinary text plans into rich interactive visual plans with diagrams,\n file maps, annotated code, open questions, and UI/prototype review when\n useful.\nmetadata:\n visibility: exported\n---\n\n# Agent-Native Plans\n\nAgent-Native Plans is structured visual planning mode for coding agents. Build\nthe plan you would normally write in Markdown, but as a scannable document with\neditable blocks mixed in: inline diagrams, code snippets,\nopen questions, and an optional top visual review area (wireframe canvas, live\nprototype, or both in tabs). Architecture and backend plans stay document-only;\nUI and product plans start with the top canvas/prototype (the Visual Surface\nChoice section owns that rule).\n\n`/visual-plan` is the packaged command and main entry point. Choose the review\nmode from the task: UI-first when the work is primarily product UI and review\nshould start with screens, prototype-first when review should start with a\nfunctional live prototype, design-first when review needs full-fidelity branded\nscreens, or visual-intake when the user explicitly wants a questionnaire before\nplanning. When a Codex, Claude Code, Markdown, or pasted plan already exists,\n`/visual-plan` uses that source plan as the starting point and builds the review\nsurface from it instead of starting over.\n\n## When To Use\n\nCreate or adapt a visual plan whenever the plan would be better as a reviewable\nartifact than a chat paragraph. This includes modest work such as a single UI\nsurface with states, a small workflow, a before/after product change, or a\ncomponent/API/data-shape decision that needs alignment, plus larger multi-file,\nambiguous, long-running, risky, or UI-heavy work. Use it when architecture /\ndata flow / UI direction / options / open questions would benefit from inline\ndiagrams or structured blocks, when the user needs to react to a direction\nbefore you implement, or when an existing text plan needs a richer review\nsurface.\n\n## Plan Discipline\n\n- **Gate thoughtfully.** A visual plan is a richer review surface, not only a\n tool for giant projects. Use it when the user needs to see, compare, comment\n on, or approve a direction before code, even for a modest UI/state/workflow\n change. Skip it for truly trivial, unambiguous work \u2014 typos, one-line fixes, a\n single well-specified function, anything whose diff you could describe in one\n sentence \u2014 and just make the change. Never pad a plan with filler and never\n ship a single-step plan.\n- **Research before you draft.** Read the real files, actions, schema, and\n patterns first; name actual files, symbols, and data shapes instead of\n inventing them. Check existing `actions/` before proposing endpoints and prefer\n named client helpers over raw fetch. Delegate wide exploration to a sub-agent.\n Lead with reuse: for each step, name what it reuses \u2014 existing actions, schema,\n components, helpers \u2014 before what it adds, so the plan explains the genuinely new\n delta instead of redescribing what already exists.\n- **Decide the hard-to-reverse bets first.** For non-trivial backend, data, or API\n work, sketch where the feature is headed, then call out the decisions that are\n expensive to undo once data or callers depend on them \u2014 wire format, public ids,\n data-model shape, auth and ownership boundaries \u2014 and get those right in the plan\n even if most of the feature ships later. Then scope to the smallest first cut that\n proves the approach without foreclosing it, stating both what is in and what is\n explicitly deferred.\n- **Keep examples at the right altitude.** When the user's idea is a broad\n framework, product, or operating-model change, do not collapse it into the\n first concrete example, provider, or sync path they mention. Separate the core\n abstraction from motivating examples and app/provider adapters. Use examples\n to make the plan legible, but label them as examples unless they are the whole\n requested scope.\n- **Publish standalone plans.** If the user pasted, referenced, or already has a\n Codex / Claude Code / Markdown plan, treat it as source material, but rewrite\n the published plan as a clean standalone proposal. Preserve the source plan's\n useful intent and codebase facts, label inferred visuals as inferred, and avoid\n revision language such as \"preserve the prior plan\", \"do not drop the old\n idea\", \"unlike the previous version\", or \"this revision changes...\". A reader\n who never saw the chat or earlier drafts should understand the plan.\n- **Make the first read concrete.** If the plan is meant to be shared with\n someone outside the chat, or if the concept is abstract, lead near the top with\n one concrete product example before mode tables, architecture, or roadmaps. For\n UI-capable concepts, that usually means a top-canvas app state that shows the\n real user workflow in product terms. Do not rely on phrases that only make\n sense in conversation, and do not frame the plan as \"not the old idea\"; state\n the positive model directly.\n- **Planning is read-only.** Make no source edits while building or reviewing the\n plan. Start editing only after the user approves the direction.\n- **Clarify vs. assume.** Do not ask how to build it \u2014 explore and present the\n approach and options in the plan. Ask a clarifying question only when an\n ambiguity would change the design and you cannot resolve it from the code; use\n the host agent's normal ask-user-question flow and batch 2-4 high-leverage\n questions before finalizing. Do not call `create-visual-questions` for\n ordinary clarification or preflight; reserve it for the visual-intake mode when\n the user explicitly asks for a visual intake questionnaire. Otherwise state the\n assumption explicitly and proceed, and keep anything unresolved in the plan's\n single bottom `question-form` Open Questions block. For complex plans, do a\n final open-question pass before handoff: if a decision would affect\n architecture, scope, UX, data shape, or rollout, either decide it in the plan\n with rationale or put it in that bottom form with a recommended default.\n- **The plan is the approval gate.** After surfacing it, ask the user to review\n and approve before you write code, and name which files/areas the work touches.\n Presenting the plan and requesting sign-off is the approval step \u2014 do not ask a\n separate \"does this look good?\" question.\n- **The document is the source of truth, not the chat.** When scope shifts,\n update the plan with `update-visual-plan` rather than only changing course in\n chat, and make the updated document stand alone. Do not describe the update as\n a correction to an earlier draft inside the plan itself. Re-read the approved\n plan before major steps.\n\n## Create A Structured Agent-Native Plan \u2014 Never Inline\n\nThe deliverable is ALWAYS a structured Agent-Native Plan, not a chat-only plan.\nThe hosted Plan MCP connector (`plan` server, or legacy `agent-native-plans`) is\nthe default collaboration and commenting surface; it is not a reason to reject\nthe planning pattern as an external dependency or rented layer. Plans are\nportable source artifacts (`plan.mdx`, optional `canvas.mdx` /\n`prototype.mdx`, JSON, and HTML export), and ownership-sensitive workflows can\nuse local-files mode or a self-hosted/custom Plan app URL without abandoning the\nskill's review discipline. Do not advise the user to skip `/visual-plan` because\nthe default surface is hosted; choose the right Plan mode for the user's\nownership, privacy, sharing, and branding needs.\n\nBy default, create the plan via the Plan MCP connector and NEVER hand it over as\ninline chat content \u2014 no Markdown prose, ASCII sketch, table, or fenced\nwireframe. If the `plan` (or legacy `agent-native-plans`) tools are not visible,\ndiscover them through the host's `tool_search` first; if they are still missing,\nSTOP and give the user the client-specific reconnect step rather than improvising\nan inline plan. Before publishing, or whenever a connector or auth error appears,\nREAD `references/connection.md` in this skill directory \u2014 it is the single source\nof truth for the never-inline rule, connector discovery, and the per-client\nreconnect steps. Local-files privacy mode (after Tool Guidance) is the exception.\n\n## Core Workflow\n\nThis section describes the default hosted Plan MCP workflow. If\n`AGENT_NATIVE_PLANS_MODE=local-files` is set, or the user asks for fully local\nfiles/no hosted Plan writes, use **Local-Files Privacy Mode** instead; carry\nforward only the code-research and plan-composition guidance here.\n\n1. Follow the host agent's normal planning flow: inspect the codebase, delegate\n wide exploration when useful, gather the info needed, and ask native\n clarifying questions as needed before generating the plan. If a source plan\n already exists, gather its exact text from the user's paste, a referenced\n file, or recent visible agent context; do not invent source text.\n2. Call `get-plan-blocks` for the authoritative block catalog \u2014 do not author\n from memorized tags. Then call the mode-matched create tool:\n `create-visual-plan` for document-first plans (architecture, backend, data,\n refactor, API), `create-ui-plan` for UI-first plans, `create-prototype-plan`\n for prototype-first plans, `create-plan-design` for design-first plans,\n `create-visual-questions` only when the user explicitly asks for a visual\n intake questionnaire. When a source plan already exists,\n pass it as `planText` and preserve the original plan's useful intent while\n producing a standalone plan document, not a revision memo.\n3. For UI/product plans, compose the top canvas first with the primary\n wireframes and annotated states, then write the document with native blocks\n (see `references/canvas.md` and `references/document-quality.md`). For\n broad product architecture plans with a user-facing implication, add a\n concrete \"what this looks like in the app\" visual before the abstract\n architecture or mode tables. Keep the document close to the standalone\n Markdown plan the agent would normally output. If an existing plan was\n provided, carry forward the right facts and decisions without referring to\n the previous draft or explaining how this version differs. For non-visual\n plans, skip the top visual surface (Visual Surface Choice below owns the rule)\n and put `diagram`, `data-model`,\n `api-endpoint`, `diff`, `file-tree`, `code`, and `annotated-code` blocks\n directly next to the relevant prose.\n Wide document layout is renderer-owned and intentionally allowlisted: only\n literal code-review surfaces (`diff`, `annotated-code`) and `tabs` blocks\n with vertical orientation or diff-like children break out wider than prose.\n Keep `api-endpoint`, `openapi-spec`, `data-model`, `json-explorer`,\n `wireframe`, question, and `custom-html` blocks in normal document flow unless\n their own renderer says otherwise.\n4. Surface the returned Plans link or inline MCP App and ask the user to review.\n Always include the actual URL in chat so the next step is a click in CLI or\n other text-only hosts. When the host exposes an embedded browser/preview panel\n and a tool can open arbitrary URLs there, open the returned plan URL\n automatically for convenient review \u2014 a convenience and smoke test, never the\n only handoff or the access\n model. Plans should load out of the box for the local agent and local browser\n session; if a signed-in embedded browser cannot read a local plan that an\n anonymous/tool check can read, fix the app/action ownership or access path\n rather than patching one plan by hand. For high-stakes plans (architecture,\n backend, data, multi-file, or risky), also kick off the self-review pass in\n **Self-Review Before Handoff** while the user reads, instead of blocking the\n handoff on it.\n5. For hosted plans, call `get-plan-feedback` before editing, after review,\n after any long pause,\n and before the final response. Treat `anchorDetails`, resolver intent, recent\n review events, and any focused screenshots from browser handoff as the source\n of truth for exactly what changed and exactly what each comment points at.\n6. For hosted plans, apply changes with `update-visual-plan`, preferring\n targeted `contentPatches`.\n Treat the top-level `content` payload as a full replacement, not a merge; do\n not send a partial `content` object to add a canvas or one block. If a full\n replacement or `replace-blocks` is unavoidable, call `get-visual-plan`\n immediately before the write, pass its `plan.updatedAt` as\n `expectedUpdatedAt`, and carry forward every existing block and visual\n surface. Never reuse a revision from an earlier read or feedback payload.\n For source-control friendly edits, use granular `patch-visual-plan-source`\n operations against the MDX files instead of regenerating the plan;\n `replace-file` is also destructive and requires the same fresh\n `expectedUpdatedAt` fence.\n7. After every hosted-plan write, call `get-visual-plan` again and compare the\n persisted text, block IDs/counts, canvas frames, and prototype with the\n intended result. A successful mutation response is not proof that unrelated\n content survived. If the edit addressed agent-targeted feedback, only after\n this verification call `resolve-plan-comment` for the thread and\n `consume-plan-feedback` for its comments; do both so addressed feedback is\n neither visibly open nor returned as pending work.\n8. For hosted plans, export with `export-visual-plan` only when the user wants a\n shareable receipt or repo-check-in artifacts.\n\n## Self-Review Before Handoff\n\nThis adversarial self-review pass is opt-in, not default: run it only for\nhigh-stakes plans \u2014 irreversible migrations, security-sensitive work, or when\nthe user explicitly asks for extra rigor \u2014 and skip it otherwise. It roughly\ndoubles the cost of plan generation, so the default for small, UI-only,\nsingle-decision, or ordinary plans is to skip it, not to run it. Keep the pass\ncheap and non-blocking when it does run:\n\n- **Surface the plan first, review concurrently.** Post the link and let the user\n start reading, then run the review in parallel \u2014 never make the user wait on it.\n- **Review the written plan; do not re-research.** Critique the plan text and its\n own blocks. The grounding was already done while drafting, so the review checks\n the output instead of re-exploring the repo.\n- **Spawn one skeptical reviewer** whose only job is to find what is weak, missing,\n or wrong \u2014 not to praise. Point it at: hard-to-reverse decisions made implicitly\n or not at all (wire format, public ids, data-model shape, auth, ownership); steps\n not anchored in real files or symbols; a menu of options where the plan should\n commit to one; obvious missing decisions (\"what happens when X?\", \"why not Y?\");\n and padding or single-step filler.\n- **Fix vs. ask.** Apply clear-cut fixes yourself with `update-visual-plan`\n `contentPatches` \u2014 vague non-goals, unanchored claims, an obvious missing\n decision. Route genuine judgment calls back to the user instead: add them to the\n bottom `question-form` Open Questions block or batch them into the normal\n ask-user-question flow. Do not silently decide them.\n- **Do not surprise the user mid-read.** On a large plan, apply the patches before\n the editor loads; otherwise note briefly that a self-review is running so the\n plan changing under them is expected. When you next respond, summarize what the\n review changed and what it surfaced for the user to decide.\n\n## Visual Surface Choice\n\nChoose the surface before creating the plan or after reading the source plan. Do\nnot add visual chrome by default:\n\nFor UI/product plans, the top canvas is usually the primary review surface. Put\nthe first meaningful wireframes there, not buried as document-body blocks. Use\nmultiple canvas artboards when states matter, such as the default view, an\noverflow menu or popover, a side panel, loading, or error. Put short annotations\nbeside frames with `targetId` plus `placement`; keep implementation details,\ntradeoffs, file maps, data contracts, risks, and verification in the document\nbody below the canvas.\n\nWhen the user asks for a flow, storyboard, journey, wireframe, canvas, or \"what\nthis looks like\", treat that as a canvas-first request. Make one artboard per\nuser-visible state, connect only adjacent transitions, and use short canvas\nannotations for the product notes. Do not substitute a document-body `diagram`\nblock for the requested storyboard just because HTML diagrams are faster to\nwrite; diagrams belong below the canvas for backend mechanics, architecture, or\ndata-flow explanation.\n\nKeep product wireframes and explanatory/meta diagrams separate. Start with pure\nscreens that look like the app state under discussion, without callout prose or\narchitecture notes embedded inside the UI. Put arrows, labels, contracts, data\nflow, and mode explanations in separate annotations, separate canvas diagrams,\nor the document body.\n\nWhen the plan touches an existing app, inspect the current shell/components\nbefore drawing. The first artboard should look like the real app at the same\ndensity: existing sidebars, toolbar placement, overflow menus, app chrome, and\nframework agent chrome stay in their real places. Model secondary surfaces as\nseparate states, such as a top-right overflow popover, sheet, panel, loading\nstate, or separate AgentSidebar, rather than inventing a permanent inspector or\nfolding framework chrome into the product UI.\n\n- **No visual surface** for architecture-only, backend-only, data migration,\n copy-only, or otherwise non-visual plans. Do not use the top canvas for\n architecture diagrams, dependency maps, file plans, API contracts, or\n data-flow-only reviews. Use a strong document with local inline diagrams\n only when relationships need a visual explanation, usually one spatial diagram\n per recommendation or decision. Prefer grouped regions, layers, quadrants,\n matrices, or before/after panels over a single-axis chain unless the\n relationship is truly sequential.\n- **Canvas only** for one static screen, a before/after comparison, a component\n state, a small popover, or a visual direction that does not require clicking.\n Put those wireframes in `content.canvas` and omit `content.prototype`.\n- **Canvas + prototype** for multi-step UI flows, onboarding, wizards,\n review/approval flows, navigation changes, or anything where the reviewer\n needs to operate the behavior. Keep the static wireframes in\n `content.canvas`, add the aligned functional prototype in\n `content.prototype`, and rely on the top visual tabs to switch between them.\n When both surfaces are present, open the Wireframes tab by default; the\n prototype remains available as the interactive follow-up view.\n- **Prototype-first** when the user asks to operate the UI or when interaction is\n the main question. Use `create-prototype-plan`, which still preserves static\n mocks where useful.\n\nFor mixed canvas + prototype plans, reuse the same real labels, app statuses,\nand screen ids across both surfaces. The canvas is the inspectable static reference;\nthe prototype is the interactive version of that same flow, not a separate\ndesign direction.\n\nTreat \u201Chigher fidelity,\u201D \u201Cpixel-accurate,\u201D \u201Cpolished mockup,\u201D \u201Cproduction-like,\u201D\n\u201Creal design,\u201D and \u201Cnot a sketch/wireframe\u201D as design-first language even when\nthe request also says \u201Cmockup.\u201D For a new plan, use `create-plan-design`. For\nan existing plan, keep the same plan id and call `update-visual-plan` with a\n`set-visual-render-mode` patch using `renderMode: \"design\"` plus the upgraded\nscreen HTML/CSS in the same update. Ground the result in the real app shell,\ntokens, typography, spacing, and states, and add stable `data-design-id`\ntargets. Put scoped styles in each screen's `css` field, never in a `<style>`\ntag. The viewer-local Clean toggle only changes one browser's wireframe\npreference; it is not a fidelity upgrade. Do not create a duplicate plan to\nhandle a fidelity follow-up.\n\n## Wireframe quality \u2014 read `references/wireframe.md`\n\nUI recap/plan wireframes must meet a strict quality bar \u2014 full-width chrome,\npinned bottom bars, real product content, before/after comparability, the right\n`surface` preset, `--wf-*` tokens instead of hex, and no `<html>`/`<style>`/font\ntags. Before authoring ANY wireframe / `<Screen>` / `WireframeBlock`, READ\n`references/wireframe.md` in this skill directory \u2014 it is the single source of\ntruth for HTML wireframe quality, shared word for word with `/visual-plan`\nand `/visual-recap`. Do not author wireframes from memory.\n\n## Canvas \u2014 read `references/canvas.md`\n\nThe canvas is the single source of truth for static UI mockups: the `surface`\nlocks each artboard's footprint, mixed surfaces lay out\nin lanes, annotations are plain-text designer notes anchored by\n`targetId`/`placement`, and edits are surgical `contentPatches`. Before\nauthoring or editing ANY canvas, artboard, or annotation, READ\n`references/canvas.md` in this skill directory \u2014 it is the single source of truth\nfor canvas/artboard mechanics. Do not author canvas layouts from memory.\nCanvas artboards use the same HTML wireframe path as document-body\n`WireframeBlock` screens: author `<Screen surface=\"...\" html={...} />` with a\nsemantic HTML fragment. Do not author fresh kit-tree children such as\n`<FrameScreen>`, `<Card>`, `<Row>`, or `<Btn>` inside canvas `<Screen>` tags;\nthose are legacy compatibility markup for old plans and produce brittle canvas\nlayouts.\n\n## Document quality \u2014 read `references/document-quality.md`\n\nThe document is a serious technical plan, not marketing: outcome-first,\nprose-first, self-contained, built from the right native blocks, with open\nquestions in a single bottom `question-form` and a pre-handoff visual check.\nBefore authoring the plan document, READ `references/document-quality.md` in this\nskill directory \u2014 it is the single source of truth for the document quality bar.\nDo not write the document from memory.\n\n## Good vs. bad exemplar \u2014 read `references/exemplar.md`\n\nFor a worked example of the bar \u2014 a great UI-first plan and `/visual-plan`, plus\nthe anti-patterns to avoid \u2014 READ `references/exemplar.md` in this skill\ndirectory before authoring a plan.\n\n## Tool Guidance\n\n- `create-visual-plan`: start one structured visual plan per agent task/run, or\n import an existing text plan by passing `planText`; `content` may include no\n visual surface, canvas only, or canvas + prototype.\n- `create-ui-plan`: start a UI-first plan when the work is primarily product UI.\n- `create-prototype-plan`: start a prototype-first plan with a functional top\n review surface. If the interaction itself must also be high fidelity, set each\n screen's `renderMode` to `design` and pass scoped styles through `css`;\n otherwise use `create-plan-design` for design-first review.\n- `create-plan-design`: start a full-fidelity branded Design-tab plan with an\n optional matching Prototype tab.\n- `convert-visual-plan-to-prototype`: convert an existing HTML wireframe canvas\n into a prototype plan.\n- `create-visual-questions`: use only when the user explicitly asks for a visual\n intake questionnaire, not as `/visual-plan` preflight.\n- `update-visual-plan`: revise content, status, or comments with targeted\n `contentPatches` (see Core Workflow steps 6-7). Use\n `set-visual-render-mode` with `renderMode: \"design\"` when promoting an\n existing plan to high fidelity, together with deliberate screen HTML/CSS;\n render mode alone only removes sketch treatment. `replace-blocks` and full\n `content` replacement require `expectedUpdatedAt` from a fresh\n `get-visual-plan` call.\n- `read-visual-plan-source`: read the normalized plan as `plan.mdx`,\n optional `canvas.mdx`, optional `.plan-state.json`, and JSON.\n- `patch-visual-plan-source`: apply granular MDX AST patches by stable block,\n artboard, annotation, component, or wireframe-node id. Prefer those targeted\n operations; `replace-file` requires `expectedUpdatedAt` from a fresh\n `get-visual-plan` call.\n- `import-visual-plan-source`: create or replace a plan from an MDX folder.\n- `get-visual-plan`: read the current structured plan, exported HTML,\n annotations, and `plan.updatedAt`; it also returns the MDX folder for source\n workflows. Re-read immediately before a destructive write for its concurrency\n fence and again after every write to verify persisted state.\n- `get-plan-feedback`: read unconsumed human feedback. Use it frequently; it\n returns grouped threads, exact anchor details, expected resolver, and recent\n review-event payloads so agents can act only on the comments meant for them.\n- `get-plan-blocks`: resolve block tags before authoring \u2014 do not memorize tags;\n call this first to get the authoritative tag names, required fields, and prop\n shapes from the live block registry.\n- `export-visual-plan`: export HTML, Markdown fallback, structured JSON, and MDX\n files for repo check-in.\n\nWhen the user critiques a plan's look or structure, fix the renderer or this\nskill \u2014 never hand-edit one stored plan. Turn feedback into better guidance.\n\n## Local-Files Privacy Mode \u2014 read `references/local-files.md`\n\nWhen the user wants no hosted Plan database writes \u2014 no DB writes, no Plan MCP\npublish, fully local/offline/private planning, repo-owned source-controlled\nartifacts, or `AGENT_NATIVE_PLANS_MODE=local-files` \u2014 do not call any hosted Plan\ntool except the schema-only `get-plan-blocks` catalog lookup. Author a local MDX\nfolder and\npreview it with `plan local check` / `plan local serve` / `plan local verify`.\nBefore using local-files mode, READ `references/local-files.md` in this skill\ndirectory \u2014 it is the single source of truth for the full contract (catalog\nlookup, MDX folder layout, the local bridge commands, and the hosted tools you\nmust not call). Carry forward only the code-research and plan-composition\nguidance from Core Workflow; everything hosted is replaced by the local bridge.\n\n## Interpreting comment anchors\n\nThis section applies to hosted plans with `get-plan-feedback` /\n`update-visual-plan`. In local-files mode, do not call hosted feedback or update\ntools; interpret file/chat feedback directly, edit the MDX files, rerun the\nlocal bridge check/serve/verify command, and report the new local URL.\n\n`get-plan-feedback` returns rich anchors \u2014 read them before acting on any comment.\n\n- **Coordinate frames.** `targetX`/`targetY` are percentages *within* the\n element named by `targetSelector`/`targetKind`. Bare `x`/`y` are percentages\n of the whole plan document. `canvasX`/`canvasY` are raw board-world pixels on\n the design canvas (board size given when available).\n- **Wireframe pins.** Anchors on wireframes include `targetNodeId` and\n `targetNodePath` (e.g. `card > list > listItem \"Acme Inc\"`) identifying the\n exact kit node. Use `targetNodeId` directly with wireframe node patch ops;\n use `data-design-id` values from design artboards with\n `update-design-element-style`. Prefer the node id/path over raw coordinates;\n fall back to coordinates plus the focused screenshot (red ring marks the exact\n point) only when no node id is present.\n- **Text quotes.** Resolve `textQuote` against current prose using\n `contextBefore`/`contextAfter` for disambiguation. If `ambiguous: true`, ask\n the user \u2014 do not guess which occurrence is meant.\n- **Detached comments.** `get-plan-feedback` flags threads whose quoted text no\n longer exists as `detached` (in `detachedThreads`). Reconcile these against\n rewritten content \u2014 never silently drop them.\n- **Routing.** `resolutionTarget` is the only routing signal: act on `agent`,\n treat `human` as context only. `@mentions` are people to notify, never a\n routing signal.\n- **Two-axis state.** Mark every ingested comment as consumed\n (`consumedCommentIds` on `update-visual-plan`). Set `status=resolved` only on\n agent-targeted comments you actually addressed; leave human-targeted comments\n open. When an edit addresses feedback, first re-read the persisted plan and\n verify the requested change. Only then call `resolve-plan-comment` for the\n addressed thread and `consume-plan-feedback` for its comments; never mark\n addressed feedback along only one axis.\n\n## Visibility & Sharing\n\nUse `set-resource-visibility` to change who can see a plan (e.g. public, login,\nor org-scoped). Use `share-resource` to grant specific users or roles access\nby email or role. Gate visibility before sharing any plan that covers\nunreleased or private work \u2014 default to the narrowest scope that meets the\nreview need.\n\n## Setup & Authentication\n\nThere are two ways into Plans.\n\n**Coding agent (CLI).** Install once with the Agent-Native CLI. The command\ninstalls the Plans skills, registers the hosted Plans MCP connector, and runs\nauth/setup for the selected local client(s) in the same step (a one-time browser\nsign-in at setup \u2014 this is intended), so the first tool call in that client does\nnot hit an OAuth wall:\n\n```bash\nnpx @agent-native/core@latest skills add visual-plans\n```\n\nAfter that, `/visual-plan`, `/visual-recap`, and `/visualize-repo` are the\ninstalled slash commands. If you only need one command, use\n`skills add visual-plan`, `skills add visual-recap`, or\n`skills add visualize-repo` instead. The other planning modes\n(`create-ui-plan`, `create-prototype-plan`, `create-plan-design`,\n`create-visual-questions`) are MCP tools reachable from `/visual-plan`, not\nseparate slash commands. Pass `--no-connect` to register the connector without\nauthenticating, then run\n`npx @agent-native/core@latest connect https://plan.agent-native.com --client all`\nwhenever you are ready, or choose a narrower `--client`. Auth and MCP tool\nloading are per client config/session.\n\n**Browser (people you share with).** Open the Plans editor and create & edit\nwith no sign-up \u2014 you work as a guest. Sign in only when you want to save or\nshare; signing in claims the plans you made as a guest into your account.\n\nSharing and commenting require an account: public/shared plans are viewable by\nanyone with the link, but commenting on them needs an agent-native account.\n\nFor fully offline, no-account use, run the Plans app locally and sync plans to\nyour repo as MDX. This local mode is a separate advanced path, not the default\nhosted flow.\n\nFor repo-wide visual docs, run\n`npx @agent-native/core@latest visualize-repo --open` to create/update\n`agent-native.json`, seed `.agent-native/visual-docs/repo-overview`, and open\nthe local bridge.\n\nIf a Plans tool returns `needs auth`, `Unauthorized`, or `Session terminated`, do\nnot keep retrying it \u2014 stop and give the user the per-client reconnect step from\n`references/connection.md`, then continue once the connector is available.\n\nHosted default: connect `https://plan.agent-native.com/mcp`. Do\nnot put shared secrets in skill files.\n";
1
+ export declare const VISUAL_PLANS_SKILL_MD = "---\nname: visual-plan\ndescription: >-\n Turn ordinary text plans into rich interactive visual plans with diagrams,\n file maps, annotated code, open questions, and UI/prototype review when\n useful.\nmetadata:\n visibility: exported\n---\n\n# Agent-Native Plans\n\nAgent-Native Plans is structured visual planning mode for coding agents. Build\nthe plan you would normally write in Markdown, but as a scannable document with\neditable blocks mixed in: inline diagrams, code snippets,\nopen questions, and an optional top visual review area (wireframe canvas, live\nprototype, or both in tabs). Architecture and backend plans stay document-only;\nUI and product plans start with the top canvas/prototype (the Visual Surface\nChoice section owns that rule).\n\n`/visual-plan` is the packaged command and main entry point. Choose the review\nmode from the task: UI-first when the work is primarily product UI and review\nshould start with screens, prototype-first when review should start with a\nfunctional live prototype, design-first when review needs full-fidelity branded\nscreens, or visual-intake when the user explicitly wants a questionnaire before\nplanning. When a Codex, Claude Code, Markdown, or pasted plan already exists,\n`/visual-plan` uses that source plan as the starting point and builds the review\nsurface from it instead of starting over.\n\n## When To Use\n\nCreate or adapt a visual plan whenever the plan would be better as a reviewable\nartifact than a chat paragraph. This includes modest work such as a single UI\nsurface with states, a small workflow, a before/after product change, or a\ncomponent/API/data-shape decision that needs alignment, plus larger multi-file,\nambiguous, long-running, risky, or UI-heavy work. Use it when architecture /\ndata flow / UI direction / options / open questions would benefit from inline\ndiagrams or structured blocks, when the user needs to react to a direction\nbefore you implement, or when an existing text plan needs a richer review\nsurface.\n\n## Plan Discipline\n\n- **Gate thoughtfully.** A visual plan is a richer review surface, not only a\n tool for giant projects. Use it when the user needs to see, compare, comment\n on, or approve a direction before code, even for a modest UI/state/workflow\n change. Skip it for truly trivial, unambiguous work \u2014 typos, one-line fixes, a\n single well-specified function, anything whose diff you could describe in one\n sentence \u2014 and just make the change. Never pad a plan with filler and never\n ship a single-step plan.\n- **Research before you draft.** Read the real files, actions, schema, and\n patterns first; name actual files, symbols, and data shapes instead of\n inventing them. Check existing `actions/` before proposing endpoints and prefer\n named client helpers over raw fetch. Delegate wide exploration to a sub-agent.\n Lead with reuse: for each step, name what it reuses \u2014 existing actions, schema,\n components, helpers \u2014 before what it adds, so the plan explains the genuinely new\n delta instead of redescribing what already exists.\n- **Decide the hard-to-reverse bets first.** For non-trivial backend, data, or API\n work, sketch where the feature is headed, then call out the decisions that are\n expensive to undo once data or callers depend on them \u2014 wire format, public ids,\n data-model shape, auth and ownership boundaries \u2014 and get those right in the plan\n even if most of the feature ships later. Then scope to the smallest first cut that\n proves the approach without foreclosing it, stating both what is in and what is\n explicitly deferred.\n- **Keep examples at the right altitude.** When the user's idea is a broad\n framework, product, or operating-model change, do not collapse it into the\n first concrete example, provider, or sync path they mention. Separate the core\n abstraction from motivating examples and app/provider adapters. Use examples\n to make the plan legible, but label them as examples unless they are the whole\n requested scope.\n- **Publish standalone plans.** If the user pasted, referenced, or already has a\n Codex / Claude Code / Markdown plan, treat it as source material, but rewrite\n the published plan as a clean standalone proposal. Preserve the source plan's\n useful intent and codebase facts, label inferred visuals as inferred, and avoid\n revision language such as \"preserve the prior plan\", \"do not drop the old\n idea\", \"unlike the previous version\", or \"this revision changes...\". A reader\n who never saw the chat or earlier drafts should understand the plan.\n- **Make the first read concrete.** If the plan is meant to be shared with\n someone outside the chat, or if the concept is abstract, lead near the top with\n one concrete product example before mode tables, architecture, or roadmaps. For\n UI-capable concepts, that usually means a top-canvas app state that shows the\n real user workflow in product terms. Do not rely on phrases that only make\n sense in conversation, and do not frame the plan as \"not the old idea\"; state\n the positive model directly.\n- **Planning is read-only.** Make no source edits while building or reviewing the\n plan. Start editing only after the user approves the direction.\n- **Clarify vs. assume.** Do not ask how to build it \u2014 explore and present the\n approach and options in the plan. Ask a clarifying question only when an\n ambiguity would change the design and you cannot resolve it from the code; use\n the host agent's normal ask-user-question flow and batch 2-4 high-leverage\n questions before finalizing. Do not call `create-visual-questions` for\n ordinary clarification or preflight; reserve it for the visual-intake mode when\n the user explicitly asks for a visual intake questionnaire. Otherwise state the\n assumption explicitly and proceed, and keep anything unresolved in the plan's\n single bottom `question-form` Open Questions block. For complex plans, do a\n final open-question pass before handoff: if a decision would affect\n architecture, scope, UX, data shape, or rollout, either decide it in the plan\n with rationale or put it in that bottom form with a recommended default.\n- **The plan is the approval gate.** After surfacing it, ask the user to review\n and approve before you write code, and name which files/areas the work touches.\n Presenting the plan and requesting sign-off is the approval step \u2014 do not ask a\n separate \"does this look good?\" question.\n- **The document is the source of truth, not the chat.** When scope shifts,\n update the plan with `update-visual-plan` rather than only changing course in\n chat, and make the updated document stand alone. Do not describe the update as\n a correction to an earlier draft inside the plan itself. Re-read the approved\n plan before major steps.\n\n## Create A Structured Agent-Native Plan \u2014 Never Inline\n\nThe deliverable is ALWAYS a structured Agent-Native Plan, not a chat-only plan.\nThe hosted Plan MCP connector (`plan` server, or legacy `agent-native-plans`) is\nthe default collaboration and commenting surface; it is not a reason to reject\nthe planning pattern as an external dependency or rented layer. Plans are\nportable source artifacts (`plan.mdx`, optional `canvas.mdx` /\n`prototype.mdx`, JSON, and HTML export), and ownership-sensitive workflows can\nuse local-files mode or a self-hosted/custom Plan app URL without abandoning the\nskill's review discipline. Do not advise the user to skip `/visual-plan` because\nthe default surface is hosted; choose the right Plan mode for the user's\nownership, privacy, sharing, and branding needs.\n\nBy default, create the plan via the Plan MCP connector and NEVER hand it over as\ninline chat content \u2014 no Markdown prose, ASCII sketch, table, or fenced\nwireframe. If the `plan` (or legacy `agent-native-plans`) tools are not visible,\ndiscover them through the host's `tool_search` first; if they are still missing,\nSTOP and give the user the client-specific reconnect step rather than improvising\nan inline plan. Before publishing, or whenever a connector or auth error appears,\nREAD `references/connection.md` in this skill directory \u2014 it is the single source\nof truth for the never-inline rule, connector discovery, and the per-client\nreconnect steps. Local-files privacy mode (after Tool Guidance) is the exception.\n\n## Core Workflow\n\nThis section describes the default hosted Plan MCP workflow. If\n`AGENT_NATIVE_PLANS_MODE=local-files` is set, or the user asks for fully local\nfiles/no hosted Plan writes, use **Local-Files Privacy Mode** instead; carry\nforward only the code-research and plan-composition guidance here.\n\n1. Follow the host agent's normal planning flow: inspect the codebase, delegate\n wide exploration when useful, gather the info needed, and ask native\n clarifying questions as needed before generating the plan. If a source plan\n already exists, gather its exact text from the user's paste, a referenced\n file, or recent visible agent context; do not invent source text.\n2. Call `get-plan-blocks` for the authoritative block catalog \u2014 do not author\n from memorized tags. Then call the mode-matched create tool:\n `create-visual-plan` for document-first plans (architecture, backend, data,\n refactor, API), `create-ui-plan` for UI-first plans, `create-prototype-plan`\n for prototype-first plans, `create-plan-design` for design-first plans,\n `create-visual-questions` only when the user explicitly asks for a visual\n intake questionnaire. When a source plan already exists,\n pass it as `planText` and preserve the original plan's useful intent while\n producing a standalone plan document, not a revision memo.\n3. For UI/product plans, compose the top canvas first with the primary\n wireframes and annotated states, then write the document with native blocks\n (see `references/canvas.md` and `references/document-quality.md`). For\n broad product architecture plans with a user-facing implication, add a\n concrete \"what this looks like in the app\" visual before the abstract\n architecture or mode tables. Keep the document close to the standalone\n Markdown plan the agent would normally output. If an existing plan was\n provided, carry forward the right facts and decisions without referring to\n the previous draft or explaining how this version differs. For non-visual\n plans, skip the top visual surface (Visual Surface Choice below owns the rule)\n and put `diagram`, `data-model`,\n `api-endpoint`, `diff`, `file-tree`, `code`, and `annotated-code` blocks\n directly next to the relevant prose.\n Wide document layout is renderer-owned and intentionally allowlisted: only\n literal code-review surfaces (`diff`, `annotated-code`) and `tabs` blocks\n with vertical orientation or diff-like children break out wider than prose.\n Keep `api-endpoint`, `openapi-spec`, `data-model`, `json-explorer`,\n `wireframe`, question, and `custom-html` blocks in normal document flow unless\n their own renderer says otherwise.\n4. Surface the returned Plans link or inline MCP App and ask the user to review.\n Always include the actual URL in chat so the next step is a click in CLI or\n other text-only hosts. When the host exposes an embedded browser/preview panel\n and a tool can open arbitrary URLs there, open the returned plan URL\n automatically for convenient review \u2014 a convenience and smoke test, never the\n only handoff or the access\n model. Plans should load out of the box for the local agent and local browser\n session; if a signed-in embedded browser cannot read a local plan that an\n anonymous/tool check can read, fix the app/action ownership or access path\n rather than patching one plan by hand. For high-stakes plans (architecture,\n backend, data, multi-file, or risky), also kick off the self-review pass in\n **Self-Review Before Handoff** while the user reads, instead of blocking the\n handoff on it.\n5. For hosted plans, call `get-plan-feedback` before editing, after review,\n after any long pause,\n and before the final response. Treat `anchorDetails`, resolver intent, recent\n review events, and any focused screenshots from browser handoff as the source\n of truth for exactly what changed and exactly what each comment points at.\n6. For hosted plans, apply changes with `update-visual-plan`, preferring\n targeted `contentPatches`.\n Treat the top-level `content` payload as a full replacement, not a merge; do\n not send a partial `content` object to add a canvas or one block. If a full\n replacement or `replace-blocks` is unavoidable, call `get-visual-plan`\n immediately before the write, pass its `plan.updatedAt` as\n `expectedUpdatedAt`, and carry forward every existing block and visual\n surface. Never reuse a revision from an earlier read or feedback payload.\n For source-control friendly edits, use granular `patch-visual-plan-source`\n operations against the MDX files instead of regenerating the plan;\n `replace-file` is also destructive and requires the same fresh\n `expectedUpdatedAt` fence.\n7. After every hosted-plan write, call `get-visual-plan` again and compare the\n persisted text, block IDs/counts, canvas frames, and prototype with the\n intended result. A successful mutation response is not proof that unrelated\n content survived. If the edit addressed agent-targeted feedback, only after\n this verification call `resolve-plan-comment` for the thread and\n `consume-plan-feedback` for its comments; do both so addressed feedback is\n neither visibly open nor returned as pending work.\n8. For hosted plans, export with `export-visual-plan` only when the user wants a\n shareable receipt or repo-check-in artifacts.\n\n## Self-Review Before Handoff\n\nThis adversarial self-review pass is opt-in, not default: run it only for\nhigh-stakes plans \u2014 irreversible migrations, security-sensitive work, or when\nthe user explicitly asks for extra rigor \u2014 and skip it otherwise. It roughly\ndoubles the cost of plan generation, so the default for small, UI-only,\nsingle-decision, or ordinary plans is to skip it, not to run it. Keep the pass\ncheap and non-blocking when it does run:\n\n- **Surface the plan first, review concurrently.** Post the link and let the user\n start reading, then run the review in parallel \u2014 never make the user wait on it.\n- **Review the written plan; do not re-research.** Critique the plan text and its\n own blocks. The grounding was already done while drafting, so the review checks\n the output instead of re-exploring the repo.\n- **Spawn one skeptical reviewer** whose only job is to find what is weak, missing,\n or wrong \u2014 not to praise. Point it at: hard-to-reverse decisions made implicitly\n or not at all (wire format, public ids, data-model shape, auth, ownership); steps\n not anchored in real files or symbols; a menu of options where the plan should\n commit to one; obvious missing decisions (\"what happens when X?\", \"why not Y?\");\n and padding or single-step filler.\n- **Fix vs. ask.** Apply clear-cut fixes yourself with `update-visual-plan`\n `contentPatches` \u2014 vague non-goals, unanchored claims, an obvious missing\n decision. Route genuine judgment calls back to the user instead: add them to the\n bottom `question-form` Open Questions block or batch them into the normal\n ask-user-question flow. Do not silently decide them.\n- **Do not surprise the user mid-read.** On a large plan, apply the patches before\n the editor loads; otherwise note briefly that a self-review is running so the\n plan changing under them is expected. When you next respond, summarize what the\n review changed and what it surfaced for the user to decide.\n\n## Visual Surface Choice\n\nChoose the surface before creating the plan or after reading the source plan. Do\nnot add visual chrome by default:\n\nFor UI/product plans, the top canvas is usually the primary review surface. Put\nthe first meaningful wireframes there, not buried as document-body blocks. Use\nmultiple canvas artboards when states matter, such as the default view, an\noverflow menu or popover, a side panel, loading, or error. Put short annotations\nbeside frames with `targetId` plus `placement`; keep implementation details,\ntradeoffs, file maps, data contracts, risks, and verification in the document\nbody below the canvas.\n\nWhen the user asks for a flow, storyboard, journey, wireframe, canvas, or \"what\nthis looks like\", treat that as a canvas-first request. Make one artboard per\nuser-visible state, connect only adjacent transitions, and use short canvas\nannotations for the product notes. Do not substitute a document-body `diagram`\nblock for the requested storyboard just because HTML diagrams are faster to\nwrite; diagrams belong below the canvas for backend mechanics, architecture, or\ndata-flow explanation.\n\nKeep product wireframes and explanatory/meta diagrams separate. Start with pure\nscreens that look like the app state under discussion, without callout prose or\narchitecture notes embedded inside the UI. Put arrows, labels, contracts, data\nflow, and mode explanations in separate annotations, separate canvas diagrams,\nor the document body.\n\nWhen the plan touches an existing app, inspect the current shell/components\nbefore drawing. The first artboard should look like the real app at the same\ndensity: existing sidebars, toolbar placement, overflow menus, app chrome, and\nframework agent chrome stay in their real places. Model secondary surfaces as\nseparate states, such as a top-right overflow popover, sheet, panel, loading\nstate, or separate AgentSidebar, rather than inventing a permanent inspector or\nfolding framework chrome into the product UI.\n\n- **No visual surface** for architecture-only, backend-only, data migration,\n copy-only, or otherwise non-visual plans. Do not use the top canvas for\n architecture diagrams, dependency maps, file plans, API contracts, or\n data-flow-only reviews. Use a strong document with local inline diagrams\n only when relationships need a visual explanation, usually one spatial diagram\n per recommendation or decision. Prefer grouped regions, layers, quadrants,\n matrices, or before/after panels over a single-axis chain unless the\n relationship is truly sequential.\n- **Canvas only** for one static screen, a before/after comparison, a component\n state, a small popover, or a visual direction that does not require clicking.\n Put those wireframes in `content.canvas` and omit `content.prototype`.\n- **Canvas + prototype** for multi-step UI flows, onboarding, wizards,\n review/approval flows, navigation changes, or anything where the reviewer\n needs to operate the behavior. Keep the static wireframes in\n `content.canvas`, add the aligned functional prototype in\n `content.prototype`, and rely on the top visual tabs to switch between them.\n When both surfaces are present, open the Wireframes tab by default; the\n prototype remains available as the interactive follow-up view.\n- **Default to wireframes.** A clean, minimal UI, a high UX bar, or references\n to Linear/Vercel describe the content and density bar; they do not request\n full-fidelity design mode. Use renderer-owned wireframes unless the user\n explicitly asks for branded, pixel-accurate, production-like, or full visual\n design. This keeps every canvas screen inspectable and its full content visible.\n- **Prototype-first** when the user asks to operate the UI or when interaction is\n the main question. Use `create-prototype-plan`, which still preserves static\n mocks where useful.\n\nFor mixed canvas + prototype plans, reuse the same real labels, app statuses,\nand screen ids across both surfaces. The canvas is the inspectable static reference;\nthe prototype is the interactive version of that same flow, not a separate\ndesign direction.\n\nTreat \u201Chigher fidelity,\u201D \u201Cpixel-accurate,\u201D \u201Cpolished mockup,\u201D \u201Cproduction-like,\u201D\n\u201Creal design,\u201D and \u201Cnot a sketch/wireframe\u201D as design-first language even when\nthe request also says \u201Cmockup.\u201D For a new plan, use `create-plan-design`. For\nan existing plan, keep the same plan id and call `update-visual-plan` with a\n`set-visual-render-mode` patch using `renderMode: \"design\"` plus the upgraded\nscreen HTML/CSS in the same update. Ground the result in the real app shell,\ntokens, typography, spacing, and states, and add stable `data-design-id`\ntargets. Put scoped styles in each screen's `css` field, never in a `<style>`\ntag. The viewer-local Clean toggle only changes one browser's wireframe\npreference; it is not a fidelity upgrade. Do not create a duplicate plan to\nhandle a fidelity follow-up.\n\n## Wireframe quality \u2014 read `references/wireframe.md`\n\nUI recap/plan wireframes must meet a strict quality bar \u2014 full-width chrome,\npinned bottom bars, real product content, before/after comparability, the right\n`surface` preset, `--wf-*` tokens instead of hex, and no `<html>`/`<style>`/font\ntags. Before authoring ANY wireframe / `<Screen>` / `WireframeBlock`, READ\n`references/wireframe.md` in this skill directory \u2014 it is the single source of\ntruth for HTML wireframe quality, shared word for word with `/visual-plan`\nand `/visual-recap`. Do not author wireframes from memory.\n\n## Canvas \u2014 read `references/canvas.md`\n\nThe canvas is the single source of truth for static UI mockups: the `surface`\nlocks each artboard's footprint, mixed surfaces lay out\nin lanes, annotations are plain-text designer notes anchored by\n`targetId`/`placement`, and edits are surgical `contentPatches`. Before\nauthoring or editing ANY canvas, artboard, or annotation, READ\n`references/canvas.md` in this skill directory \u2014 it is the single source of truth\nfor canvas/artboard mechanics. Do not author canvas layouts from memory.\nCanvas artboards use the same HTML wireframe path as document-body\n`WireframeBlock` screens: author `<Screen surface=\"...\" html={...} />` with a\nsemantic HTML fragment. Do not author fresh kit-tree children such as\n`<FrameScreen>`, `<Card>`, `<Row>`, or `<Btn>` inside canvas `<Screen>` tags;\nthose are legacy compatibility markup for old plans and produce brittle canvas\nlayouts.\n\n## Document quality \u2014 read `references/document-quality.md`\n\nThe document is a serious technical plan, not marketing: outcome-first,\nprose-first, self-contained, built from the right native blocks, with open\nquestions in a single bottom `question-form` and a pre-handoff visual check.\nBefore authoring the plan document, READ `references/document-quality.md` in this\nskill directory \u2014 it is the single source of truth for the document quality bar.\nDo not write the document from memory.\n\n## Good vs. bad exemplar \u2014 read `references/exemplar.md`\n\nFor a worked example of the bar \u2014 a great UI-first plan and `/visual-plan`, plus\nthe anti-patterns to avoid \u2014 READ `references/exemplar.md` in this skill\ndirectory before authoring a plan.\n\n## Authoring invariants\n\nTreat these as data-integrity checks, not optional polish:\n\n- `content` is a complete replacement. Pass either `content` or the mode's\n convenience arrays (`screens`/`transitions` or `states`/`components`),\n never both. The create actions reject mixed sources so a second payload cannot\n silently discard CSS, frames, or document blocks.\n- A design screen's scoped `css` is part of the artifact. Keep it on both the\n prototype screen and its matching canvas frame, and use renderer-owned\n `--wf-*` tokens for portable color and typography.\n- Rich-text `data.markdown` must contain actual runtime line breaks. Do not\n hand a plan a one-line Markdown value containing literal `\\n` escape text,\n which renders the whole section as one heading. Escaped newlines are fine in\n code examples when the surrounding Markdown still has real line breaks.\n- Canvas artboards do not scroll. Keep wireframe HTML in natural flow and set a\n larger frame `height` when a screen exceeds the surface preset; preserve the\n surface width and inspect the bottom edge at default zoom before handoff.\n- After every hosted write, re-read the structured content and inspect the live\n Plan surface. A valid JSON payload is not proof that CSS loaded or Markdown\n rendered into the intended heading, paragraph, and list structure.\n\n## Tool Guidance\n\n- `create-visual-plan`: start one structured visual plan per agent task/run, or\n import an existing text plan by passing `planText`; `content` may include no\n visual surface, canvas only, or canvas + prototype.\n- `create-ui-plan`: start a UI-first plan when the work is primarily product UI.\n- `create-prototype-plan`: start a prototype-first plan with a functional top\n review surface. If the interaction itself must also be high fidelity, set each\n screen's `renderMode` to `design` and pass scoped styles through `css`;\n otherwise use `create-plan-design` for design-first review.\n- `create-plan-design`: start a full-fidelity branded Design-tab plan with an\n optional matching Prototype tab.\n- `convert-visual-plan-to-prototype`: convert an existing HTML wireframe canvas\n into a prototype plan.\n- `create-visual-questions`: use only when the user explicitly asks for a visual\n intake questionnaire, not as `/visual-plan` preflight.\n- `update-visual-plan`: revise content, status, or comments with targeted\n `contentPatches` (see Core Workflow steps 6-7). Use\n `set-visual-render-mode` with `renderMode: \"design\"` when promoting an\n existing plan to high fidelity, together with deliberate screen HTML/CSS;\n render mode alone only removes sketch treatment. `replace-blocks` and full\n `content` replacement require `expectedUpdatedAt` from a fresh\n `get-visual-plan` call.\n- `read-visual-plan-source`: read the normalized plan as `plan.mdx`,\n optional `canvas.mdx`, optional `.plan-state.json`, and JSON.\n- `patch-visual-plan-source`: apply granular MDX AST patches by stable block,\n artboard, annotation, component, or wireframe-node id. Prefer those targeted\n operations; `replace-file` requires `expectedUpdatedAt` from a fresh\n `get-visual-plan` call.\n- `import-visual-plan-source`: create or replace a plan from an MDX folder.\n- `get-visual-plan`: read the current structured plan, exported HTML,\n annotations, and `plan.updatedAt`; it also returns the MDX folder for source\n workflows. Re-read immediately before a destructive write for its concurrency\n fence and again after every write to verify persisted state.\n- `get-plan-feedback`: read unconsumed human feedback. Use it frequently; it\n returns grouped threads, exact anchor details, expected resolver, and recent\n review-event payloads so agents can act only on the comments meant for them.\n- `get-plan-blocks`: resolve block tags before authoring \u2014 do not memorize tags;\n call this first to get the authoritative tag names, required fields, and prop\n shapes from the live block registry.\n- `export-visual-plan`: export HTML, Markdown fallback, structured JSON, and MDX\n files for repo check-in.\n\nWhen the user critiques a plan's look or structure, fix the renderer or this\nskill \u2014 never hand-edit one stored plan. Turn feedback into better guidance.\n\n## Local-Files Privacy Mode \u2014 read `references/local-files.md`\n\nWhen the user wants no hosted Plan database writes \u2014 no DB writes, no Plan MCP\npublish, fully local/offline/private planning, repo-owned source-controlled\nartifacts, or `AGENT_NATIVE_PLANS_MODE=local-files` \u2014 do not call any hosted Plan\ntool except the schema-only `get-plan-blocks` catalog lookup. Author a local MDX\nfolder and\npreview it with `plan local check` / `plan local serve` / `plan local verify`.\nBefore using local-files mode, READ `references/local-files.md` in this skill\ndirectory \u2014 it is the single source of truth for the full contract (catalog\nlookup, MDX folder layout, the local bridge commands, and the hosted tools you\nmust not call). Carry forward only the code-research and plan-composition\nguidance from Core Workflow; everything hosted is replaced by the local bridge.\n\n## Interpreting comment anchors\n\nThis section applies to hosted plans with `get-plan-feedback` /\n`update-visual-plan`. In local-files mode, do not call hosted feedback or update\ntools; interpret file/chat feedback directly, edit the MDX files, rerun the\nlocal bridge check/serve/verify command, and report the new local URL.\n\n`get-plan-feedback` returns rich anchors \u2014 read them before acting on any comment.\n\n- **Coordinate frames.** `targetX`/`targetY` are percentages *within* the\n element named by `targetSelector`/`targetKind`. Bare `x`/`y` are percentages\n of the whole plan document. `canvasX`/`canvasY` are raw board-world pixels on\n the design canvas (board size given when available).\n- **Wireframe pins.** Anchors on wireframes include `targetNodeId` and\n `targetNodePath` (e.g. `card > list > listItem \"Acme Inc\"`) identifying the\n exact kit node. Use `targetNodeId` directly with wireframe node patch ops;\n use `data-design-id` values from design artboards with\n `update-design-element-style`. Prefer the node id/path over raw coordinates;\n fall back to coordinates plus the focused screenshot (red ring marks the exact\n point) only when no node id is present.\n- **Text quotes.** Resolve `textQuote` against current prose using\n `contextBefore`/`contextAfter` for disambiguation. If `ambiguous: true`, ask\n the user \u2014 do not guess which occurrence is meant.\n- **Detached comments.** `get-plan-feedback` flags threads whose quoted text no\n longer exists as `detached` (in `detachedThreads`). Reconcile these against\n rewritten content \u2014 never silently drop them.\n- **Routing.** `resolutionTarget` is the only routing signal: act on `agent`,\n treat `human` as context only. `@mentions` are people to notify, never a\n routing signal.\n- **Two-axis state.** Mark every ingested comment as consumed\n (`consumedCommentIds` on `update-visual-plan`). Set `status=resolved` only on\n agent-targeted comments you actually addressed; leave human-targeted comments\n open. When an edit addresses feedback, first re-read the persisted plan and\n verify the requested change. Only then call `resolve-plan-comment` for the\n addressed thread and `consume-plan-feedback` for its comments; never mark\n addressed feedback along only one axis.\n\n## Visibility & Sharing\n\nUse `set-resource-visibility` to change who can see a plan (e.g. public, login,\nor org-scoped). Use `share-resource` to grant specific users or roles access\nby email or role. Gate visibility before sharing any plan that covers\nunreleased or private work \u2014 default to the narrowest scope that meets the\nreview need.\n\n## Setup & Authentication\n\nThere are two ways into Plans.\n\n**Coding agent (CLI).** Install once with the Agent-Native CLI. The command\ninstalls the Plans skills, registers the hosted Plans MCP connector, and runs\nauth/setup for the selected local client(s) in the same step (a one-time browser\nsign-in at setup \u2014 this is intended), so the first tool call in that client does\nnot hit an OAuth wall:\n\n```bash\nnpx @agent-native/core@latest skills add visual-plans\n```\n\nAfter that, `/visual-plan`, `/visual-recap`, and `/visualize-repo` are the\ninstalled slash commands. If you only need one command, use\n`skills add visual-plan`, `skills add visual-recap`, or\n`skills add visualize-repo` instead. The other planning modes\n(`create-ui-plan`, `create-prototype-plan`, `create-plan-design`,\n`create-visual-questions`) are MCP tools reachable from `/visual-plan`, not\nseparate slash commands. Pass `--no-connect` to register the connector without\nauthenticating, then run\n`npx @agent-native/core@latest connect https://plan.agent-native.com --client all`\nwhenever you are ready, or choose a narrower `--client`. Auth and MCP tool\nloading are per client config/session.\n\n**Browser (people you share with).** Open the Plans editor and create & edit\nwith no sign-up \u2014 you work as a guest. Sign in only when you want to save or\nshare; signing in claims the plans you made as a guest into your account.\n\nSharing and commenting require an account: public/shared plans are viewable by\nanyone with the link, but commenting on them needs an agent-native account.\n\nFor fully offline, no-account use, run the Plans app locally and sync plans to\nyour repo as MDX. This local mode is a separate advanced path, not the default\nhosted flow.\n\nFor repo-wide visual docs, run\n`npx @agent-native/core@latest visualize-repo --open` to create/update\n`agent-native.json`, seed `.agent-native/visual-docs/repo-overview`, and open\nthe local bridge.\n\nIf a Plans tool returns `needs auth`, `Unauthorized`, or `Session terminated`, do\nnot keep retrying it \u2014 stop and give the user the per-client reconnect step from\n`references/connection.md`, then continue once the connector is available.\n\nHosted default: connect `https://plan.agent-native.com/mcp`. Do\nnot put shared secrets in skill files.\n";
2
2
  //# sourceMappingURL=visual-plan-skill.d.ts.map