@agent-native/core 0.109.2 → 0.109.4

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 (334) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +16 -0
  3. package/corpus/core/docs/content/agent-native-toolkit.mdx +46 -13
  4. package/corpus/core/docs/content/locales/ar-SA/agent-native-toolkit.mdx +79 -55
  5. package/corpus/core/docs/content/locales/ar-SA/toolkit-capability-packages.mdx +21 -0
  6. package/corpus/core/docs/content/locales/ar-SA/toolkit-context-knowledge.mdx +12 -0
  7. package/corpus/core/docs/content/locales/ar-SA/toolkit-editors-canvases.mdx +17 -0
  8. package/corpus/core/docs/content/locales/de-DE/agent-native-toolkit.mdx +82 -54
  9. package/corpus/core/docs/content/locales/de-DE/toolkit-capability-packages.mdx +21 -0
  10. package/corpus/core/docs/content/locales/de-DE/toolkit-context-knowledge.mdx +12 -0
  11. package/corpus/core/docs/content/locales/de-DE/toolkit-editors-canvases.mdx +17 -0
  12. package/corpus/core/docs/content/locales/es-ES/agent-native-toolkit.mdx +81 -52
  13. package/corpus/core/docs/content/locales/es-ES/toolkit-capability-packages.mdx +21 -0
  14. package/corpus/core/docs/content/locales/es-ES/toolkit-context-knowledge.mdx +12 -0
  15. package/corpus/core/docs/content/locales/es-ES/toolkit-editors-canvases.mdx +21 -0
  16. package/corpus/core/docs/content/locales/fr-FR/agent-native-toolkit.mdx +84 -54
  17. package/corpus/core/docs/content/locales/fr-FR/toolkit-capability-packages.mdx +21 -0
  18. package/corpus/core/docs/content/locales/fr-FR/toolkit-context-knowledge.mdx +12 -0
  19. package/corpus/core/docs/content/locales/fr-FR/toolkit-editors-canvases.mdx +21 -0
  20. package/corpus/core/docs/content/locales/hi-IN/agent-native-toolkit.mdx +69 -62
  21. package/corpus/core/docs/content/locales/hi-IN/toolkit-capability-packages.mdx +21 -0
  22. package/corpus/core/docs/content/locales/hi-IN/toolkit-context-knowledge.mdx +12 -0
  23. package/corpus/core/docs/content/locales/hi-IN/toolkit-editors-canvases.mdx +17 -0
  24. package/corpus/core/docs/content/locales/ja-JP/agent-native-toolkit.mdx +69 -62
  25. package/corpus/core/docs/content/locales/ja-JP/toolkit-capability-packages.mdx +21 -0
  26. package/corpus/core/docs/content/locales/ja-JP/toolkit-context-knowledge.mdx +12 -0
  27. package/corpus/core/docs/content/locales/ja-JP/toolkit-editors-canvases.mdx +17 -0
  28. package/corpus/core/docs/content/locales/ko-KR/agent-native-toolkit.mdx +69 -62
  29. package/corpus/core/docs/content/locales/ko-KR/toolkit-capability-packages.mdx +21 -0
  30. package/corpus/core/docs/content/locales/ko-KR/toolkit-context-knowledge.mdx +12 -0
  31. package/corpus/core/docs/content/locales/ko-KR/toolkit-editors-canvases.mdx +17 -0
  32. package/corpus/core/docs/content/locales/pt-BR/agent-native-toolkit.mdx +82 -54
  33. package/corpus/core/docs/content/locales/pt-BR/toolkit-capability-packages.mdx +21 -0
  34. package/corpus/core/docs/content/locales/pt-BR/toolkit-context-knowledge.mdx +12 -0
  35. package/corpus/core/docs/content/locales/pt-BR/toolkit-editors-canvases.mdx +17 -0
  36. package/corpus/core/docs/content/locales/zh-CN/agent-native-toolkit.mdx +69 -62
  37. package/corpus/core/docs/content/locales/zh-CN/toolkit-capability-packages.mdx +21 -0
  38. package/corpus/core/docs/content/locales/zh-CN/toolkit-context-knowledge.mdx +12 -0
  39. package/corpus/core/docs/content/locales/zh-CN/toolkit-editors-canvases.mdx +17 -0
  40. package/corpus/core/docs/content/locales/zh-TW/agent-native-toolkit.mdx +69 -62
  41. package/corpus/core/docs/content/locales/zh-TW/toolkit-capability-packages.mdx +21 -0
  42. package/corpus/core/docs/content/locales/zh-TW/toolkit-context-knowledge.mdx +12 -0
  43. package/corpus/core/docs/content/locales/zh-TW/toolkit-editors-canvases.mdx +17 -0
  44. package/corpus/core/docs/content/toolkit-capability-packages.mdx +52 -0
  45. package/corpus/core/docs/content/toolkit-context-knowledge.mdx +46 -0
  46. package/corpus/core/docs/content/toolkit-editors-canvases.mdx +55 -0
  47. package/corpus/core/package.json +35 -34
  48. package/corpus/core/src/cli/create.ts +57 -15
  49. package/corpus/core/src/cli/package-lifecycle.ts +2 -0
  50. package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +2 -0
  51. package/corpus/core/src/client/context-xray/ContextMeter.tsx +31 -111
  52. package/corpus/core/src/client/context-xray/ContextSegmentRow.tsx +8 -111
  53. package/corpus/core/src/client/context-xray/ContextTreemap.tsx +6 -111
  54. package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +31 -391
  55. package/corpus/core/src/client/context-xray/SegmentProvenancePopover.tsx +4 -52
  56. package/corpus/core/src/client/context-xray/format.ts +0 -33
  57. package/corpus/core/src/client/require-session.tsx +19 -3
  58. package/corpus/core/src/client/rich-markdown-editor/index.ts +42 -57
  59. package/corpus/core/src/client/rich-markdown-editor/uploadEditorImage.ts +2 -1
  60. package/corpus/core/src/client/use-action.ts +145 -2
  61. package/corpus/core/src/client/use-session.ts +79 -48
  62. package/corpus/core/src/client/visual-style-controls.tsx +1 -1088
  63. package/corpus/core/src/collab/agent-identity.ts +5 -22
  64. package/corpus/core/src/collab/client.ts +1 -53
  65. package/corpus/core/src/db/client.ts +13 -7
  66. package/corpus/core/src/db/create-get-db.ts +20 -13
  67. package/corpus/core/src/db/request-telemetry.ts +154 -0
  68. package/corpus/core/src/integrations/index.ts +1 -0
  69. package/corpus/core/src/integrations/plugin.ts +9 -3
  70. package/corpus/core/src/integrations/remote-push-delivery-job.ts +48 -0
  71. package/corpus/core/src/integrations/remote-push-delivery.ts +370 -0
  72. package/corpus/core/src/integrations/remote-push-store.ts +275 -26
  73. package/corpus/core/src/server/better-auth-instance.ts +11 -3
  74. package/corpus/core/src/server/core-routes-plugin.ts +36 -14
  75. package/corpus/core/src/server/framework-request-handler.ts +11 -1
  76. package/corpus/core/src/server/http-response-telemetry.ts +233 -31
  77. package/corpus/core/src/styles/rich-markdown-editor.css +1 -510
  78. package/corpus/core/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +19 -0
  79. package/corpus/core/src/testing.ts +1 -1
  80. package/corpus/core/src/vite/client.ts +3 -0
  81. package/corpus/templates/clips/actions/finalize-recording.ts +3 -1
  82. package/corpus/templates/clips/actions/set-mobile-capture-state.ts +4 -1
  83. package/corpus/templates/clips/app/components/library/library-layout.tsx +1 -6
  84. package/corpus/templates/clips/changelog/2026-07-18-new-recording-is-now-emphasized-as-the-primary-action-in-the.md +6 -0
  85. package/corpus/templates/clips/changelog/2026-07-18-recordings-now-remain-safely-recoverable-until-the-stored-me.md +6 -0
  86. package/corpus/templates/content/app/components/editor/VisualEditor.tsx +5 -3
  87. package/corpus/templates/content/app/components/editor/extensions/DragHandle.tsx +4 -4
  88. package/corpus/templates/content/package.json +25 -25
  89. package/corpus/templates/design/app/components/design/TweaksPanel.tsx +2 -1
  90. package/corpus/templates/design/package.json +1 -1
  91. package/corpus/templates/mail/package.json +9 -9
  92. package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +2 -0
  93. package/corpus/templates/plan/app/components/editor/PlanDocumentEditor.tsx +8 -8
  94. package/corpus/templates/plan/app/components/editor/planSlashCommands.ts +6 -6
  95. package/corpus/templates/plan/app/components/plan/PlanImageNode.tsx +4 -7
  96. package/corpus/templates/plan/app/components/plan/PlanMarkdownEditor.tsx +6 -4
  97. package/corpus/templates/plan/app/components/plan/PlanVisualSurface.tsx +1 -1
  98. package/corpus/templates/plan/changelog/2026-07-18-visual-plans-now-open-on-wireframes-by-default-when-a-protot.md +6 -0
  99. package/corpus/templates/plan/package.json +3 -3
  100. package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +2 -2
  101. package/corpus/templates/slides/app/components/editor/TweaksPanel.tsx +2 -2
  102. package/corpus/templates/slides/package.json +13 -13
  103. package/corpus/templates/tasks/AGENTS.md +3 -0
  104. package/corpus/templates/tasks/actions/render-task-list-inline.ts +202 -0
  105. package/corpus/templates/tasks/changelog/2026-07-18-task-lists-can-now-appear-as-interactive-widgets-inline-in-c.md +6 -0
  106. package/corpus/templates/tasks/docs/features/f8-chat.mdx +2 -0
  107. package/corpus/templates/tasks/server/plugins/agent-chat.ts +2 -0
  108. package/dist/catalog.json +39 -1
  109. package/dist/cli/create.d.ts +10 -1
  110. package/dist/cli/create.d.ts.map +1 -1
  111. package/dist/cli/create.js +49 -16
  112. package/dist/cli/create.js.map +1 -1
  113. package/dist/cli/package-lifecycle.d.ts.map +1 -1
  114. package/dist/cli/package-lifecycle.js +2 -0
  115. package/dist/cli/package-lifecycle.js.map +1 -1
  116. package/dist/cli/skills-content/visual-plan-skill.d.ts +1 -1
  117. package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -1
  118. package/dist/cli/skills-content/visual-plan-skill.js +2 -0
  119. package/dist/cli/skills-content/visual-plan-skill.js.map +1 -1
  120. package/dist/client/context-xray/ContextMeter.d.ts.map +1 -1
  121. package/dist/client/context-xray/ContextMeter.js +8 -23
  122. package/dist/client/context-xray/ContextMeter.js.map +1 -1
  123. package/dist/client/context-xray/ContextSegmentRow.d.ts.map +1 -1
  124. package/dist/client/context-xray/ContextSegmentRow.js +3 -19
  125. package/dist/client/context-xray/ContextSegmentRow.js.map +1 -1
  126. package/dist/client/context-xray/ContextTreemap.d.ts.map +1 -1
  127. package/dist/client/context-xray/ContextTreemap.js +3 -54
  128. package/dist/client/context-xray/ContextTreemap.js.map +1 -1
  129. package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
  130. package/dist/client/context-xray/ContextXRayPanel.js +21 -163
  131. package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
  132. package/dist/client/context-xray/SegmentProvenancePopover.d.ts.map +1 -1
  133. package/dist/client/context-xray/SegmentProvenancePopover.js +3 -4
  134. package/dist/client/context-xray/SegmentProvenancePopover.js.map +1 -1
  135. package/dist/client/context-xray/format.d.ts +0 -4
  136. package/dist/client/context-xray/format.d.ts.map +1 -1
  137. package/dist/client/context-xray/format.js +0 -49
  138. package/dist/client/context-xray/format.js.map +1 -1
  139. package/dist/client/require-session.d.ts.map +1 -1
  140. package/dist/client/require-session.js +6 -3
  141. package/dist/client/require-session.js.map +1 -1
  142. package/dist/client/rich-markdown-editor/index.d.ts +1 -12
  143. package/dist/client/rich-markdown-editor/index.d.ts.map +1 -1
  144. package/dist/client/rich-markdown-editor/index.js +1 -12
  145. package/dist/client/rich-markdown-editor/index.js.map +1 -1
  146. package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts +1 -1
  147. package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts.map +1 -1
  148. package/dist/client/rich-markdown-editor/uploadEditorImage.js.map +1 -1
  149. package/dist/client/use-action.d.ts.map +1 -1
  150. package/dist/client/use-action.js +117 -1
  151. package/dist/client/use-action.js.map +1 -1
  152. package/dist/client/use-session.d.ts.map +1 -1
  153. package/dist/client/use-session.js +72 -50
  154. package/dist/client/use-session.js.map +1 -1
  155. package/dist/client/visual-style-controls.d.ts +1 -89
  156. package/dist/client/visual-style-controls.d.ts.map +1 -1
  157. package/dist/client/visual-style-controls.js +1 -498
  158. package/dist/client/visual-style-controls.js.map +1 -1
  159. package/dist/collab/agent-identity.d.ts +1 -14
  160. package/dist/collab/agent-identity.d.ts.map +1 -1
  161. package/dist/collab/agent-identity.js +1 -13
  162. package/dist/collab/agent-identity.js.map +1 -1
  163. package/dist/collab/awareness.d.ts +2 -2
  164. package/dist/collab/awareness.d.ts.map +1 -1
  165. package/dist/collab/client.d.ts +1 -19
  166. package/dist/collab/client.d.ts.map +1 -1
  167. package/dist/collab/client.js +1 -53
  168. package/dist/collab/client.js.map +1 -1
  169. package/dist/collab/struct-routes.d.ts +1 -1
  170. package/dist/db/client.d.ts.map +1 -1
  171. package/dist/db/client.js +7 -1
  172. package/dist/db/client.js.map +1 -1
  173. package/dist/db/create-get-db.d.ts +3 -6
  174. package/dist/db/create-get-db.d.ts.map +1 -1
  175. package/dist/db/create-get-db.js +9 -2
  176. package/dist/db/create-get-db.js.map +1 -1
  177. package/dist/db/request-telemetry.d.ts +23 -0
  178. package/dist/db/request-telemetry.d.ts.map +1 -0
  179. package/dist/db/request-telemetry.js +95 -0
  180. package/dist/db/request-telemetry.js.map +1 -0
  181. package/dist/integrations/index.d.ts +1 -0
  182. package/dist/integrations/index.d.ts.map +1 -1
  183. package/dist/integrations/index.js +1 -0
  184. package/dist/integrations/index.js.map +1 -1
  185. package/dist/integrations/plugin.d.ts.map +1 -1
  186. package/dist/integrations/plugin.js +8 -3
  187. package/dist/integrations/plugin.js.map +1 -1
  188. package/dist/integrations/remote-push-delivery-job.d.ts +4 -0
  189. package/dist/integrations/remote-push-delivery-job.d.ts.map +1 -0
  190. package/dist/integrations/remote-push-delivery-job.js +44 -0
  191. package/dist/integrations/remote-push-delivery-job.js.map +1 -0
  192. package/dist/integrations/remote-push-delivery.d.ts +11 -0
  193. package/dist/integrations/remote-push-delivery.d.ts.map +1 -0
  194. package/dist/integrations/remote-push-delivery.js +265 -0
  195. package/dist/integrations/remote-push-delivery.js.map +1 -0
  196. package/dist/integrations/remote-push-store.d.ts +33 -0
  197. package/dist/integrations/remote-push-store.d.ts.map +1 -1
  198. package/dist/integrations/remote-push-store.js +195 -26
  199. package/dist/integrations/remote-push-store.js.map +1 -1
  200. package/dist/notifications/routes.d.ts +3 -3
  201. package/dist/progress/routes.d.ts +1 -1
  202. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  203. package/dist/resources/handlers.d.ts +3 -3
  204. package/dist/secrets/routes.d.ts +9 -9
  205. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  206. package/dist/server/better-auth-instance.js +7 -3
  207. package/dist/server/better-auth-instance.js.map +1 -1
  208. package/dist/server/core-routes-plugin.d.ts +8 -0
  209. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  210. package/dist/server/core-routes-plugin.js +23 -8
  211. package/dist/server/core-routes-plugin.js.map +1 -1
  212. package/dist/server/framework-request-handler.d.ts.map +1 -1
  213. package/dist/server/framework-request-handler.js +9 -1
  214. package/dist/server/framework-request-handler.js.map +1 -1
  215. package/dist/server/http-response-telemetry.d.ts +3 -2
  216. package/dist/server/http-response-telemetry.d.ts.map +1 -1
  217. package/dist/server/http-response-telemetry.js +160 -27
  218. package/dist/server/http-response-telemetry.js.map +1 -1
  219. package/dist/server/transcribe-voice.d.ts +1 -1
  220. package/dist/styles/rich-markdown-editor.css +1 -510
  221. package/dist/templates/workspace-core/.agents/skills/tracking/SKILL.md +19 -0
  222. package/dist/testing.d.ts +1 -1
  223. package/dist/testing.d.ts.map +1 -1
  224. package/dist/testing.js +1 -1
  225. package/dist/testing.js.map +1 -1
  226. package/dist/vite/client.d.ts.map +1 -1
  227. package/dist/vite/client.js +3 -0
  228. package/dist/vite/client.js.map +1 -1
  229. package/docs/content/agent-native-toolkit.mdx +46 -13
  230. package/docs/content/locales/ar-SA/agent-native-toolkit.mdx +79 -55
  231. package/docs/content/locales/ar-SA/toolkit-capability-packages.mdx +21 -0
  232. package/docs/content/locales/ar-SA/toolkit-context-knowledge.mdx +12 -0
  233. package/docs/content/locales/ar-SA/toolkit-editors-canvases.mdx +17 -0
  234. package/docs/content/locales/de-DE/agent-native-toolkit.mdx +82 -54
  235. package/docs/content/locales/de-DE/toolkit-capability-packages.mdx +21 -0
  236. package/docs/content/locales/de-DE/toolkit-context-knowledge.mdx +12 -0
  237. package/docs/content/locales/de-DE/toolkit-editors-canvases.mdx +17 -0
  238. package/docs/content/locales/es-ES/agent-native-toolkit.mdx +81 -52
  239. package/docs/content/locales/es-ES/toolkit-capability-packages.mdx +21 -0
  240. package/docs/content/locales/es-ES/toolkit-context-knowledge.mdx +12 -0
  241. package/docs/content/locales/es-ES/toolkit-editors-canvases.mdx +21 -0
  242. package/docs/content/locales/fr-FR/agent-native-toolkit.mdx +84 -54
  243. package/docs/content/locales/fr-FR/toolkit-capability-packages.mdx +21 -0
  244. package/docs/content/locales/fr-FR/toolkit-context-knowledge.mdx +12 -0
  245. package/docs/content/locales/fr-FR/toolkit-editors-canvases.mdx +21 -0
  246. package/docs/content/locales/hi-IN/agent-native-toolkit.mdx +69 -62
  247. package/docs/content/locales/hi-IN/toolkit-capability-packages.mdx +21 -0
  248. package/docs/content/locales/hi-IN/toolkit-context-knowledge.mdx +12 -0
  249. package/docs/content/locales/hi-IN/toolkit-editors-canvases.mdx +17 -0
  250. package/docs/content/locales/ja-JP/agent-native-toolkit.mdx +69 -62
  251. package/docs/content/locales/ja-JP/toolkit-capability-packages.mdx +21 -0
  252. package/docs/content/locales/ja-JP/toolkit-context-knowledge.mdx +12 -0
  253. package/docs/content/locales/ja-JP/toolkit-editors-canvases.mdx +17 -0
  254. package/docs/content/locales/ko-KR/agent-native-toolkit.mdx +69 -62
  255. package/docs/content/locales/ko-KR/toolkit-capability-packages.mdx +21 -0
  256. package/docs/content/locales/ko-KR/toolkit-context-knowledge.mdx +12 -0
  257. package/docs/content/locales/ko-KR/toolkit-editors-canvases.mdx +17 -0
  258. package/docs/content/locales/pt-BR/agent-native-toolkit.mdx +82 -54
  259. package/docs/content/locales/pt-BR/toolkit-capability-packages.mdx +21 -0
  260. package/docs/content/locales/pt-BR/toolkit-context-knowledge.mdx +12 -0
  261. package/docs/content/locales/pt-BR/toolkit-editors-canvases.mdx +17 -0
  262. package/docs/content/locales/zh-CN/agent-native-toolkit.mdx +69 -62
  263. package/docs/content/locales/zh-CN/toolkit-capability-packages.mdx +21 -0
  264. package/docs/content/locales/zh-CN/toolkit-context-knowledge.mdx +12 -0
  265. package/docs/content/locales/zh-CN/toolkit-editors-canvases.mdx +17 -0
  266. package/docs/content/locales/zh-TW/agent-native-toolkit.mdx +69 -62
  267. package/docs/content/locales/zh-TW/toolkit-capability-packages.mdx +21 -0
  268. package/docs/content/locales/zh-TW/toolkit-context-knowledge.mdx +12 -0
  269. package/docs/content/locales/zh-TW/toolkit-editors-canvases.mdx +17 -0
  270. package/docs/content/toolkit-capability-packages.mdx +52 -0
  271. package/docs/content/toolkit-context-knowledge.mdx +46 -0
  272. package/docs/content/toolkit-editors-canvases.mdx +55 -0
  273. package/package.json +27 -26
  274. package/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +19 -0
  275. package/corpus/core/src/client/rich-markdown-editor/BubbleToolbar.tsx +0 -253
  276. package/corpus/core/src/client/rich-markdown-editor/CodeBlockNode.tsx +0 -258
  277. package/corpus/core/src/client/rich-markdown-editor/DragHandle.ts +0 -1437
  278. package/corpus/core/src/client/rich-markdown-editor/ImageExtension.ts +0 -306
  279. package/corpus/core/src/client/rich-markdown-editor/RichMarkdownEditor.tsx +0 -80
  280. package/corpus/core/src/client/rich-markdown-editor/RunId.ts +0 -61
  281. package/corpus/core/src/client/rich-markdown-editor/SharedRichEditor.tsx +0 -321
  282. package/corpus/core/src/client/rich-markdown-editor/SlashCommandMenu.tsx +0 -310
  283. package/corpus/core/src/client/rich-markdown-editor/extensions.ts +0 -402
  284. package/corpus/core/src/client/rich-markdown-editor/gfmDoc.ts +0 -92
  285. package/corpus/core/src/client/rich-markdown-editor/surgical-apply.ts +0 -192
  286. package/corpus/core/src/client/rich-markdown-editor/useCollabReconcile.ts +0 -590
  287. package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts +0 -37
  288. package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts.map +0 -1
  289. package/dist/client/rich-markdown-editor/BubbleToolbar.js +0 -171
  290. package/dist/client/rich-markdown-editor/BubbleToolbar.js.map +0 -1
  291. package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts +0 -49
  292. package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts.map +0 -1
  293. package/dist/client/rich-markdown-editor/CodeBlockNode.js +0 -127
  294. package/dist/client/rich-markdown-editor/CodeBlockNode.js.map +0 -1
  295. package/dist/client/rich-markdown-editor/DragHandle.d.ts +0 -97
  296. package/dist/client/rich-markdown-editor/DragHandle.d.ts.map +0 -1
  297. package/dist/client/rich-markdown-editor/DragHandle.js +0 -1066
  298. package/dist/client/rich-markdown-editor/DragHandle.js.map +0 -1
  299. package/dist/client/rich-markdown-editor/ImageExtension.d.ts +0 -63
  300. package/dist/client/rich-markdown-editor/ImageExtension.d.ts.map +0 -1
  301. package/dist/client/rich-markdown-editor/ImageExtension.js +0 -243
  302. package/dist/client/rich-markdown-editor/ImageExtension.js.map +0 -1
  303. package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts +0 -51
  304. package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts.map +0 -1
  305. package/dist/client/rich-markdown-editor/RichMarkdownEditor.js +0 -37
  306. package/dist/client/rich-markdown-editor/RichMarkdownEditor.js.map +0 -1
  307. package/dist/client/rich-markdown-editor/RunId.d.ts +0 -28
  308. package/dist/client/rich-markdown-editor/RunId.d.ts.map +0 -1
  309. package/dist/client/rich-markdown-editor/RunId.js +0 -60
  310. package/dist/client/rich-markdown-editor/RunId.js.map +0 -1
  311. package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +0 -110
  312. package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +0 -1
  313. package/dist/client/rich-markdown-editor/SharedRichEditor.js +0 -144
  314. package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +0 -1
  315. package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts +0 -41
  316. package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts.map +0 -1
  317. package/dist/client/rich-markdown-editor/SlashCommandMenu.js +0 -221
  318. package/dist/client/rich-markdown-editor/SlashCommandMenu.js.map +0 -1
  319. package/dist/client/rich-markdown-editor/extensions.d.ts +0 -178
  320. package/dist/client/rich-markdown-editor/extensions.d.ts.map +0 -1
  321. package/dist/client/rich-markdown-editor/extensions.js +0 -224
  322. package/dist/client/rich-markdown-editor/extensions.js.map +0 -1
  323. package/dist/client/rich-markdown-editor/gfmDoc.d.ts +0 -24
  324. package/dist/client/rich-markdown-editor/gfmDoc.d.ts.map +0 -1
  325. package/dist/client/rich-markdown-editor/gfmDoc.js +0 -83
  326. package/dist/client/rich-markdown-editor/gfmDoc.js.map +0 -1
  327. package/dist/client/rich-markdown-editor/surgical-apply.d.ts +0 -66
  328. package/dist/client/rich-markdown-editor/surgical-apply.d.ts.map +0 -1
  329. package/dist/client/rich-markdown-editor/surgical-apply.js +0 -147
  330. package/dist/client/rich-markdown-editor/surgical-apply.js.map +0 -1
  331. package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts +0 -110
  332. package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +0 -1
  333. package/dist/client/rich-markdown-editor/useCollabReconcile.js +0 -441
  334. package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"package-lifecycle.d.ts","sourceRoot":"","sources":["../../src/cli/package-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAK/C,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,0BAA0B,CAAC;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACxB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC7E,KAAK,CAAC,EAAE,OAAO,SAAS,CAAC;CAC1B;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B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,YAAY,GAAG,eAAe,GAAG,gBAAgB,CAAC;IAC1D,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE;QACb,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,gBAAgB,EAAE,MAAM,CAAC;QACzB,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,kBAAkB,EAAE,MAAM,EAAE,CAAC;QAC7B,aAAa,EAAE,MAAM,EAAE,CAAC;KACzB,CAAC;IACF,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACxC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAOD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,MAAM,CAAC,CAqDjB;AAaD,wBAAgB,qBAAqB,IAAI,MAAM,CAW9C;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,OAAO,SAAqB,GAClC,OAAO,CAAC,sBAAsB,CAAC,CAkFjC"}
@@ -66,6 +66,8 @@ function flagValue(args, name) {
66
66
  }
67
67
  export function packageLifecycleUsage() {
68
68
  return [
69
+ "Install-on-demand Toolkit capability module lifecycle:",
70
+ "",
69
71
  "Usage:",
70
72
  " agent-native package inspect <package> [--root <dir>] [--app <name>] [--json]",
71
73
  " agent-native package add <package> [--root <dir>] [--app <name>] [--apply] [--json]",
@@ -1 +1 @@
1
- {"version":3,"file":"package-lifecycle.js","sourceRoot":"","sources":["../../src/cli/package-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,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,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,IAAY;IAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxC,OAAO,KAAK,IAAI,GAAG,CAAC;AACtB,CAAC","sourcesContent":["import { spawnSync } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nimport {\n assertAgentNativePackageManifest,\n type AgentNativePackageManifest,\n} from \"../package-lifecycle/manifest.js\";\n\nexport interface PackageLifecycleIO {\n out(message: string): void;\n err(message: string): void;\n}\n\nexport interface LoadedLifecyclePackage {\n manifest: AgentNativePackageManifest;\n packageVersion: string;\n packageDir: string;\n packageJson: Record<string, unknown>;\n cleanup?: () => void;\n}\n\nexport interface PackageLifecycleRuntime {\n cwd?: string;\n io?: PackageLifecycleIO;\n loadPackage?: (name: string, cwd: string) => Promise<LoadedLifecyclePackage>;\n spawn?: typeof spawnSync;\n}\n\ninterface Change {\n path: string;\n action: \"create\" | \"update\" | \"noop\";\n kind:\n | \"dependency\"\n | \"action\"\n | \"schema\"\n | \"skill\"\n | \"provenance\"\n | \"eject\"\n | \"workspace\";\n content?: string | Buffer;\n}\n\nexport interface PackageLifecycleReport {\n command: \"inspect\" | \"add\" | \"eject\";\n package: string;\n packageVersion: string;\n manifestVersion: number;\n targetRoot: string;\n layout: \"standalone\" | \"workspace-app\" | \"workspace-root\";\n apply: boolean;\n compatible: boolean;\n contributions: {\n actions: string[];\n schemaEntryPoint: string;\n skills: string[];\n requiredSecretKeys: string[];\n peerProviders: string[];\n };\n changes: Array<Omit<Change, \"content\">>;\n collisions: string[];\n warnings: string[];\n}\n\nconst defaultIO: PackageLifecycleIO = {\n out: (message) => console.log(message),\n err: (message) => console.error(message),\n};\n\nexport async function runPackageLifecycle(\n args: string[],\n runtime: PackageLifecycleRuntime = {},\n): Promise<number> {\n const io = runtime.io ?? defaultIO;\n const command = args[0];\n const packageName = args[1];\n if (!isCommand(command) || !packageName) {\n io.err(packageLifecycleUsage());\n return 1;\n }\n const json = args.includes(\"--json\");\n const apply = args.includes(\"--apply\");\n if (apply && command === \"inspect\") {\n io.err(\"package inspect is always read-only; remove --apply\");\n return 1;\n }\n const cwd = path.resolve(\n flagValue(args, \"--root\") ?? runtime.cwd ?? process.cwd(),\n );\n let loaded: LoadedLifecyclePackage | undefined;\n try {\n loaded = await (runtime.loadPackage\n ? runtime.loadPackage(packageName, cwd)\n : loadLifecyclePackage(packageName, cwd, runtime.spawn ?? spawnSync));\n if (loaded.manifest.name !== packageName) {\n throw new Error(\n `Manifest name ${loaded.manifest.name} does not match requested package ${packageName}`,\n );\n }\n const target = resolveTarget(cwd, flagValue(args, \"--app\"));\n const planned =\n command === \"eject\"\n ? planEject(loaded, target.root, target.layout)\n : planAdd(loaded, target.root, target.layout, command === \"inspect\");\n const report = reportFor(command, loaded, target, apply, planned);\n if (report.collisions.length > 0) {\n report.compatible = false;\n }\n if (json) io.out(JSON.stringify(report, null, 2));\n else io.out(formatReport(report));\n if (!report.compatible) return 1;\n if (command === \"inspect\" || !apply) return 0;\n\n await applyTransaction(\n target.root,\n planned.changes.filter((change) => change.action !== \"noop\"),\n runtime.spawn ?? spawnSync,\n );\n return 0;\n } catch (error) {\n io.err(error instanceof Error ? error.message : String(error));\n return 1;\n } finally {\n loaded?.cleanup?.();\n }\n}\n\nfunction isCommand(\n value: string | undefined,\n): value is \"inspect\" | \"add\" | \"eject\" {\n return value === \"inspect\" || value === \"add\" || value === \"eject\";\n}\n\nfunction flagValue(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n\nexport function packageLifecycleUsage(): string {\n return [\n \"Usage:\",\n \" agent-native package inspect <package> [--root <dir>] [--app <name>] [--json]\",\n \" agent-native package add <package> [--root <dir>] [--app <name>] [--apply] [--json]\",\n \" agent-native package eject <package> [--root <dir>] [--app <name>] [--apply] [--json]\",\n \"\",\n \"add and eject are dry-run by default; pass --apply to write and run the package manager.\",\n ].join(\"\\n\");\n}\n\nexport async function loadLifecyclePackage(\n name: string,\n cwd: string,\n spawn: typeof spawnSync = spawnSync,\n): Promise<LoadedLifecyclePackage> {\n const packageJsonPath = findInstalledPackageJson(name, cwd);\n if (packageJsonPath) {\n return loadStaticPackageDirectory(name, path.dirname(packageJsonPath));\n }\n if (!/^(@[a-z0-9._-]+\\/)?[a-z0-9._-]+$/.test(name)) {\n throw new Error(`Invalid package name: ${name}`);\n }\n const stage = fs.mkdtempSync(\n path.join(os.tmpdir(), \"agent-native-package-inspect-\"),\n );\n try {\n const packed = spawn(\n \"npm\",\n [\"pack\", name, \"--ignore-scripts\", \"--json\", \"--pack-destination\", stage],\n { cwd, encoding: \"utf8\", stdio: \"pipe\" },\n );\n if (packed.status !== 0) {\n throw new Error(`Unable to download package metadata for '${name}'`);\n }\n const entries = JSON.parse(String(packed.stdout || \"[]\")) as Array<{\n filename?: string;\n }>;\n const filename = entries[0]?.filename;\n if (!filename || path.basename(filename) !== filename) {\n throw new Error(\n `npm pack returned an invalid archive name for '${name}'`,\n );\n }\n const archive = path.join(stage, filename);\n const listed = spawn(\"tar\", [\"-tzf\", archive], {\n cwd,\n encoding: \"utf8\",\n stdio: \"pipe\",\n });\n if (listed.status !== 0) {\n throw new Error(`Unable to list package archive for '${name}'`);\n }\n const archiveEntries = String(listed.stdout || \"\")\n .split(/\\r?\\n/)\n .filter(Boolean);\n if (\n archiveEntries.length === 0 ||\n archiveEntries.some(\n (entry) =>\n entry.includes(\"\\\\\") ||\n entry.startsWith(\"/\") ||\n !entry.startsWith(\"package/\") ||\n entry.split(\"/\").includes(\"..\"),\n )\n ) {\n throw new Error(`Package archive for '${name}' contains an unsafe path`);\n }\n const extracted = spawn(\n \"tar\",\n [\n \"-xzf\",\n archive,\n \"-C\",\n stage,\n \"--no-same-owner\",\n \"--no-same-permissions\",\n ],\n {\n cwd,\n encoding: \"utf8\",\n stdio: \"pipe\",\n },\n );\n if (extracted.status !== 0) {\n throw new Error(`Unable to inspect package archive for '${name}'`);\n }\n const loaded = loadStaticPackageDirectory(\n name,\n path.join(stage, \"package\"),\n );\n loaded.cleanup = () => fs.rmSync(stage, { recursive: true, force: true });\n return loaded;\n } catch (error) {\n fs.rmSync(stage, { recursive: true, force: true });\n throw error;\n }\n}\n\nfunction loadStaticPackageDirectory(\n name: string,\n packageDir: string,\n): LoadedLifecyclePackage {\n const packageJsonPath = path.join(packageDir, \"package.json\");\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\")) as {\n name?: string;\n version?: string;\n agentNativeManifest?: string;\n [key: string]: unknown;\n };\n if (packageJson.name !== name) {\n throw new Error(\n `Installed package name ${String(packageJson.name)} does not match ${name}`,\n );\n }\n if (!packageJson.version) {\n throw new Error(`Package '${name}' has no version`);\n }\n if (\n !/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/.test(\n packageJson.version,\n )\n ) {\n throw new Error(`Package '${name}' has an invalid version`);\n }\n const relativeManifest = packageJson.agentNativeManifest;\n if (!relativeManifest || path.isAbsolute(relativeManifest)) {\n throw new Error(\n `Package '${name}' does not declare a static agentNativeManifest`,\n );\n }\n const manifestPath = path.resolve(packageDir, relativeManifest);\n if (\n manifestPath !== packageDir &&\n !manifestPath.startsWith(`${path.resolve(packageDir)}${path.sep}`)\n ) {\n throw new Error(`Package '${name}' manifest escapes the package directory`);\n }\n const manifestStat = fs.lstatSync(manifestPath);\n if (!manifestStat.isFile() || manifestStat.isSymbolicLink()) {\n throw new Error(`Package '${name}' static manifest must be a regular file`);\n }\n const realPackageDir = fs.realpathSync(packageDir);\n const realManifestPath = fs.realpathSync(manifestPath);\n if (!realManifestPath.startsWith(`${realPackageDir}${path.sep}`)) {\n throw new Error(\n `Package '${name}' static manifest escapes the package directory`,\n );\n }\n const manifest = JSON.parse(fs.readFileSync(manifestPath, \"utf8\"));\n assertAgentNativePackageManifest(manifest);\n if (manifest.name !== name) {\n throw new Error(`Manifest name ${manifest.name} does not match ${name}`);\n }\n return {\n manifest,\n packageVersion: packageJson.version,\n packageDir,\n packageJson,\n };\n}\n\nfunction findInstalledPackageJson(name: string, from: string): string | null {\n let dir = from;\n while (true) {\n const candidate = path.join(dir, \"node_modules\", name, \"package.json\");\n if (fs.existsSync(candidate)) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\nfunction resolveTarget(\n root: string,\n appName?: string,\n): { root: string; layout: PackageLifecycleReport[\"layout\"] } {\n const packageJsonPath = path.join(root, \"package.json\");\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(`Target root has no package.json: ${root}`);\n }\n const pkg = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n const workspace =\n typeof pkg?.[\"agent-native\"]?.workspaceCore === \"string\" &&\n fs.existsSync(path.join(root, \"apps\"));\n if (!workspace) return { root, layout: \"standalone\" };\n if (!appName) {\n return { root, layout: \"workspace-root\" };\n }\n if (!/^[a-z0-9][a-z0-9-]*$/.test(appName)) {\n throw new Error(`Invalid workspace app name: ${appName}`);\n }\n const appRoot = path.join(root, \"apps\", appName);\n if (!fs.existsSync(path.join(appRoot, \"package.json\"))) {\n throw new Error(`Workspace app not found: ${appRoot}`);\n }\n return { root: appRoot, layout: \"workspace-app\" };\n}\n\nfunction planAdd(\n loaded: LoadedLifecyclePackage,\n targetRoot: string,\n layout: PackageLifecycleReport[\"layout\"],\n inspectOnly: boolean,\n): { changes: Change[]; collisions: string[]; warnings: string[] } {\n const { manifest, packageDir } = loaded;\n const collisions: string[] = [];\n const warnings: string[] = [];\n if (layout === \"workspace-root\") {\n collisions.push(\"Workspace root is ambiguous; pass --app <name> for add\");\n return { changes: [], collisions, warnings };\n }\n const packageJsonPath = path.join(targetRoot, \"package.json\");\n const pkg = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n pkg.dependencies ??= {};\n const wantedRange = `^${loaded.packageVersion}`;\n const currentRange = pkg.dependencies[manifest.name];\n if (currentRange !== wantedRange && currentRange !== \"workspace:*\") {\n pkg.dependencies[manifest.name] = wantedRange;\n }\n const changes: Change[] = [\n textChange(\n targetRoot,\n packageJsonPath,\n `${JSON.stringify(pkg, null, 2)}\\n`,\n \"dependency\",\n ),\n ];\n for (const action of manifest.actions) {\n const target = path.join(targetRoot, \"actions\", `${action}.ts`);\n const content = `export { default } from \"${manifest.name}/actions/${action}\";\\n`;\n changes.push(\n collisionCheckedText(targetRoot, target, content, \"action\", collisions),\n );\n }\n\n const schemaPath = path.join(targetRoot, \"server\", \"db\", \"schema.ts\");\n if (!fs.existsSync(schemaPath)) {\n collisions.push(\n `Required schema file is missing: ${relative(targetRoot, schemaPath)}`,\n );\n } else {\n const current = fs.readFileSync(schemaPath, \"utf8\");\n const marker = `// agent-native-package:${manifest.name}`;\n const contribution = `${marker}\\nexport * from \"${manifest.schemaEntryPoint}\";`;\n if (current.includes(marker) && !current.includes(contribution)) {\n collisions.push(\n \"Existing package-owned schema block has unexpected content\",\n );\n }\n const next = current.includes(contribution)\n ? current\n : `${current.trimEnd()}\\n\\n${contribution}\\n`;\n changes.push(textChange(targetRoot, schemaPath, next, \"schema\"));\n }\n\n const ownedPaths: string[] = [];\n for (const skill of manifest.docs.skills) {\n const source = path.join(packageDir, \"docs\", \"skills\", skill);\n if (!fs.existsSync(source)) {\n collisions.push(`Manifest skill source is missing: docs/skills/${skill}`);\n continue;\n }\n for (const sourceFile of walkFiles(source)) {\n const target = path.join(\n targetRoot,\n \".agents\",\n \"skills\",\n skill,\n path.relative(source, sourceFile),\n );\n changes.push(\n collisionCheckedBuffer(\n targetRoot,\n target,\n fs.readFileSync(sourceFile),\n \"skill\",\n collisions,\n ),\n );\n ownedPaths.push(relative(targetRoot, target));\n }\n }\n const provenancePath = path.join(\n targetRoot,\n \".agent-native\",\n \"packages\",\n `${manifest.name.replaceAll(\"/\", \"__\")}.json`,\n );\n const provenance = {\n manifestVersion: manifest.manifestVersion,\n package: manifest.name,\n version: loaded.packageVersion,\n actions: manifest.actions,\n schemaEntryPoint: manifest.schemaEntryPoint,\n skills: manifest.docs.skills,\n files: ownedPaths.sort(),\n };\n changes.push(\n textChange(\n targetRoot,\n provenancePath,\n `${JSON.stringify(provenance, null, 2)}\\n`,\n \"provenance\",\n ),\n );\n if (inspectOnly)\n warnings.push(\"inspect is read-only; shown changes are the add plan\");\n return { changes, collisions, warnings };\n}\n\nfunction planEject(\n loaded: LoadedLifecyclePackage,\n targetRoot: string,\n layout: PackageLifecycleReport[\"layout\"],\n): { changes: Change[]; collisions: string[]; warnings: string[] } {\n const collisions: string[] = [];\n const warnings: string[] = [];\n if (loaded.manifest.name !== \"@agent-native/scheduling\") {\n collisions.push(\"Eject currently supports only @agent-native/scheduling\");\n return { changes: [], collisions, warnings };\n }\n if (!loaded.manifest.eject) {\n collisions.push(\"Package manifest does not declare eject metadata\");\n return { changes: [], collisions, warnings };\n }\n const workspaceRoot =\n layout === \"workspace-app\" ? path.resolve(targetRoot, \"../..\") : targetRoot;\n const pnpmWorkspace = path.join(workspaceRoot, \"pnpm-workspace.yaml\");\n if (!fs.existsSync(pnpmWorkspace)) {\n collisions.push(\n \"Eject currently requires an existing pnpm workspace; refusing to create a workspace:* dependency for another package manager\",\n );\n return { changes: [], collisions, warnings };\n }\n const targetDir = path.join(\n workspaceRoot,\n loaded.manifest.eject.targetDirectory,\n );\n if (fs.existsSync(targetDir)) {\n collisions.push(\n `Eject target already exists: ${relative(workspaceRoot, targetDir)}`,\n );\n return { changes: [], collisions, warnings };\n }\n const sourceRoot = path.join(\n loaded.packageDir,\n loaded.manifest.eject.sourceRoot,\n );\n if (!fs.existsSync(sourceRoot)) {\n collisions.push(\n `Published eject source is missing: ${loaded.manifest.eject.sourceRoot}`,\n );\n return { changes: [], collisions, warnings };\n }\n const changes: Change[] = [];\n for (const source of walkFiles(sourceRoot)) {\n const target = path.join(\n targetDir,\n \"src\",\n path.relative(sourceRoot, source),\n );\n changes.push({\n path: target,\n action: \"create\",\n kind: \"eject\",\n content: fs.readFileSync(source),\n });\n }\n for (const name of [\"tsconfig.json\", \"agent-native.package.json\"]) {\n const source = path.join(loaded.packageDir, name);\n if (fs.existsSync(source)) {\n changes.push({\n path: path.join(targetDir, name),\n action: \"create\",\n kind: \"eject\",\n content: fs.readFileSync(source),\n });\n }\n }\n changes.push({\n path: path.join(targetDir, \"package.json\"),\n action: \"create\",\n kind: \"eject\",\n content: `${JSON.stringify(\n normalizeEjectedPackageJson(loaded.packageJson, workspaceRoot),\n null,\n 2,\n )}\\n`,\n });\n const consumerPackageJson = path.join(targetRoot, \"package.json\");\n const consumer = JSON.parse(fs.readFileSync(consumerPackageJson, \"utf8\"));\n consumer.dependencies ??= {};\n consumer.dependencies[loaded.manifest.name] = \"workspace:*\";\n changes.push(\n textChange(\n workspaceRoot,\n consumerPackageJson,\n `${JSON.stringify(consumer, null, 2)}\\n`,\n \"dependency\",\n ),\n );\n if (fs.existsSync(pnpmWorkspace)) {\n const text = fs.readFileSync(pnpmWorkspace, \"utf8\");\n if (!text.includes(\"packages/*\") && !text.includes(\"packages/**\")) {\n collisions.push(\n \"pnpm-workspace.yaml does not include packages/*; refusing to rewrite YAML\",\n );\n }\n } else {\n changes.push({\n path: pnpmWorkspace,\n action: \"create\",\n kind: \"workspace\",\n content: 'packages:\\n - \"packages/*\"\\n',\n });\n }\n warnings.push(\n \"Imports keep the canonical @agent-native/scheduling specifier; workspace resolution switches them to the local package.\",\n );\n return { changes, collisions, warnings };\n}\n\nfunction normalizeEjectedPackageJson(\n input: Record<string, unknown>,\n workspaceRoot: string,\n): Record<string, unknown> {\n const output = structuredClone(input) as Record<string, any>;\n for (const field of [\"dependencies\", \"devDependencies\", \"peerDependencies\"]) {\n const dependencies = output[field] as Record<string, unknown> | undefined;\n if (!dependencies) continue;\n for (const [name, range] of Object.entries(dependencies)) {\n if (\n typeof range !== \"string\" ||\n (!range.startsWith(\"workspace:\") && !range.startsWith(\"catalog:\"))\n ) {\n continue;\n }\n const installed = findInstalledPackageJson(name, workspaceRoot);\n if (!installed) {\n throw new Error(\n `Cannot normalize ${field}.${name}; the installed dependency version is unavailable`,\n );\n }\n const version = JSON.parse(fs.readFileSync(installed, \"utf8\")).version;\n if (!version)\n throw new Error(`Installed dependency ${name} has no version`);\n dependencies[name] = `^${version}`;\n }\n }\n return output;\n}\n\nfunction collisionCheckedText(\n root: string,\n target: string,\n content: string,\n kind: Change[\"kind\"],\n collisions: string[],\n): Change {\n return collisionCheckedBuffer(\n root,\n target,\n Buffer.from(content),\n kind,\n collisions,\n );\n}\n\nfunction collisionCheckedBuffer(\n root: string,\n target: string,\n content: Buffer,\n kind: Change[\"kind\"],\n collisions: string[],\n): Change {\n if (!fs.existsSync(target)) {\n return { path: target, action: \"create\", kind, content };\n }\n const current = fs.readFileSync(target);\n if (current.equals(content)) return { path: target, action: \"noop\", kind };\n collisions.push(`Refusing to overwrite ${relative(root, target)}`);\n return { path: target, action: \"noop\", kind };\n}\n\nfunction textChange(\n root: string,\n target: string,\n content: string,\n kind: Change[\"kind\"],\n): Change {\n if (!fs.existsSync(target))\n return { path: target, action: \"create\", kind, content };\n return {\n path: target,\n action: fs.readFileSync(target, \"utf8\") === content ? \"noop\" : \"update\",\n kind,\n content,\n };\n}\n\nfunction walkFiles(root: string): string[] {\n const files: string[] = [];\n for (const entry of fs.readdirSync(root, { withFileTypes: true })) {\n const full = path.join(root, entry.name);\n if (entry.isSymbolicLink())\n throw new Error(`Refusing package symlink: ${full}`);\n if (entry.isDirectory()) files.push(...walkFiles(full));\n else if (entry.isFile()) files.push(full);\n }\n return files.sort();\n}\n\nfunction reportFor(\n command: PackageLifecycleReport[\"command\"],\n loaded: LoadedLifecyclePackage,\n target: { root: string; layout: PackageLifecycleReport[\"layout\"] },\n apply: boolean,\n planned: { changes: Change[]; collisions: string[]; warnings: string[] },\n): PackageLifecycleReport {\n const { manifest } = loaded;\n return {\n command,\n package: manifest.name,\n packageVersion: loaded.packageVersion,\n manifestVersion: manifest.manifestVersion,\n targetRoot: target.root,\n layout: target.layout,\n apply,\n compatible: planned.collisions.length === 0,\n contributions: {\n actions: manifest.actions,\n schemaEntryPoint: manifest.schemaEntryPoint,\n skills: manifest.docs.skills,\n requiredSecretKeys: manifest.requiredSecrets.map((secret) => secret.key),\n peerProviders: manifest.peerProviders,\n },\n changes: planned.changes.map(({ path: file, action, kind }) => ({\n path: relative(target.root, file),\n action,\n kind,\n })),\n collisions: planned.collisions,\n warnings: planned.warnings,\n };\n}\n\nfunction formatReport(report: PackageLifecycleReport): string {\n const lines = [\n `# ${report.command} ${report.package}@${report.packageVersion}`,\n `Manifest: v${report.manifestVersion}`,\n `Target: ${report.targetRoot} (${report.layout})`,\n `Mode: ${report.apply ? \"apply\" : \"dry-run\"}`,\n `Compatible: ${report.compatible ? \"yes\" : \"no\"}`,\n \"\",\n `Actions: ${report.contributions.actions.length}`,\n `Schema: ${report.contributions.schemaEntryPoint}`,\n `Skills: ${report.contributions.skills.join(\", \") || \"none\"}`,\n `Required secret keys: ${report.contributions.requiredSecretKeys.join(\", \") || \"none\"}`,\n `Peer providers: ${report.contributions.peerProviders.join(\", \") || \"none\"}`,\n \"\",\n \"Changes:\",\n ...report.changes.map(\n (change) =>\n ` ${change.action.padEnd(6)} ${change.path} (${change.kind})`,\n ),\n ];\n if (report.collisions.length) {\n lines.push(\n \"\",\n \"Collisions:\",\n ...report.collisions.map((item) => ` - ${item}`),\n );\n }\n if (report.warnings.length) {\n lines.push(\"\", \"Notes:\", ...report.warnings.map((item) => ` - ${item}`));\n }\n if (!report.apply && report.command !== \"inspect\") {\n lines.push(\"\", \"Dry-run only. Re-run with --apply to write these changes.\");\n }\n return lines.join(\"\\n\");\n}\n\nasync function applyTransaction(\n root: string,\n changes: Change[],\n spawn: typeof spawnSync,\n): Promise<void> {\n const stage = fs.mkdtempSync(path.join(root, \".agent-native-package-stage-\"));\n const snapshots = new Map<string, Buffer | null>();\n const installRoot = findPackageManagerRoot(root);\n const lockfiles = [\"pnpm-lock.yaml\", \"package-lock.json\", \"yarn.lock\"].map(\n (name) => path.join(installRoot, name),\n );\n try {\n for (const change of changes) {\n snapshots.set(\n change.path,\n fs.existsSync(change.path) ? fs.readFileSync(change.path) : null,\n );\n const staged = path.join(stage, String(snapshots.size));\n fs.writeFileSync(staged, change.content!);\n }\n for (const lockfile of lockfiles) {\n snapshots.set(\n lockfile,\n fs.existsSync(lockfile) ? fs.readFileSync(lockfile) : null,\n );\n }\n let index = 0;\n for (const change of changes) {\n index += 1;\n fs.mkdirSync(path.dirname(change.path), { recursive: true });\n fs.renameSync(path.join(stage, String(index)), change.path);\n }\n const packageManager = detectPackageManager(installRoot);\n const result = spawn(packageManager, [\"install\"], {\n cwd: installRoot,\n stdio: \"inherit\",\n });\n if (result.status !== 0) {\n throw new Error(\n `${packageManager} install failed with status ${result.status}`,\n );\n }\n } catch (error) {\n for (const [file, snapshot] of [...snapshots.entries()].reverse()) {\n if (snapshot === null) fs.rmSync(file, { force: true, recursive: true });\n else {\n fs.mkdirSync(path.dirname(file), { recursive: true });\n fs.writeFileSync(file, snapshot);\n }\n }\n for (const change of [...changes].reverse()) {\n removeEmptyParents(path.dirname(change.path), root);\n }\n throw error;\n } finally {\n fs.rmSync(stage, { recursive: true, force: true });\n }\n}\n\nfunction removeEmptyParents(directory: string, stop: string): void {\n let current = directory;\n const boundary = path.resolve(stop);\n while (current.startsWith(`${boundary}${path.sep}`)) {\n try {\n if (fs.readdirSync(current).length > 0) return;\n fs.rmdirSync(current);\n } catch {\n return;\n }\n current = path.dirname(current);\n }\n}\n\nfunction detectPackageManager(root: string): \"pnpm\" | \"yarn\" | \"npm\" {\n if (fs.existsSync(path.join(root, \"pnpm-lock.yaml\"))) return \"pnpm\";\n if (fs.existsSync(path.join(root, \"yarn.lock\"))) return \"yarn\";\n return \"npm\";\n}\n\nfunction findPackageManagerRoot(from: string): string {\n let dir = from;\n while (true) {\n if (\n fs.existsSync(path.join(dir, \"pnpm-lock.yaml\")) ||\n fs.existsSync(path.join(dir, \"yarn.lock\")) ||\n fs.existsSync(path.join(dir, \"package-lock.json\"))\n ) {\n return dir;\n }\n const parent = path.dirname(dir);\n if (parent === dir) return from;\n dir = parent;\n }\n}\n\nfunction relative(root: string, file: string): string {\n const value = path.relative(root, file);\n return value || \".\";\n}\n"]}
1
+ {"version":3,"file":"package-lifecycle.js","sourceRoot":"","sources":["../../src/cli/package-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,gCAAgC,GAEjC,MAAM,kCAAkC,CAAC;AAyD1C,MAAM,SAAS,GAAuB;IACpC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IACtC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;CACzC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAc,EACd,OAAO,GAA4B,EAAE;IAErC,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,SAAS,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACxC,EAAE,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAChC,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,IAAI,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AgB,CAAC,CAAC;YAC/C,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YAC1C,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC,EAClD,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QAChC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,IAAY;IAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxC,OAAO,KAAK,IAAI,GAAG,CAAC;AACtB,CAAC","sourcesContent":["import { spawnSync } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nimport {\n assertAgentNativePackageManifest,\n type AgentNativePackageManifest,\n} from \"../package-lifecycle/manifest.js\";\n\nexport interface PackageLifecycleIO {\n out(message: string): void;\n err(message: string): void;\n}\n\nexport interface LoadedLifecyclePackage {\n manifest: AgentNativePackageManifest;\n packageVersion: string;\n packageDir: string;\n packageJson: Record<string, unknown>;\n cleanup?: () => void;\n}\n\nexport interface PackageLifecycleRuntime {\n cwd?: string;\n io?: PackageLifecycleIO;\n loadPackage?: (name: string, cwd: string) => Promise<LoadedLifecyclePackage>;\n spawn?: typeof spawnSync;\n}\n\ninterface Change {\n path: string;\n action: \"create\" | \"update\" | \"noop\";\n kind:\n | \"dependency\"\n | \"action\"\n | \"schema\"\n | \"skill\"\n | \"provenance\"\n | \"eject\"\n | \"workspace\";\n content?: string | Buffer;\n}\n\nexport interface PackageLifecycleReport {\n command: \"inspect\" | \"add\" | \"eject\";\n package: string;\n packageVersion: string;\n manifestVersion: number;\n targetRoot: string;\n layout: \"standalone\" | \"workspace-app\" | \"workspace-root\";\n apply: boolean;\n compatible: boolean;\n contributions: {\n actions: string[];\n schemaEntryPoint: string;\n skills: string[];\n requiredSecretKeys: string[];\n peerProviders: string[];\n };\n changes: Array<Omit<Change, \"content\">>;\n collisions: string[];\n warnings: string[];\n}\n\nconst defaultIO: PackageLifecycleIO = {\n out: (message) => console.log(message),\n err: (message) => console.error(message),\n};\n\nexport async function runPackageLifecycle(\n args: string[],\n runtime: PackageLifecycleRuntime = {},\n): Promise<number> {\n const io = runtime.io ?? defaultIO;\n const command = args[0];\n const packageName = args[1];\n if (!isCommand(command) || !packageName) {\n io.err(packageLifecycleUsage());\n return 1;\n }\n const json = args.includes(\"--json\");\n const apply = args.includes(\"--apply\");\n if (apply && command === \"inspect\") {\n io.err(\"package inspect is always read-only; remove --apply\");\n return 1;\n }\n const cwd = path.resolve(\n flagValue(args, \"--root\") ?? runtime.cwd ?? process.cwd(),\n );\n let loaded: LoadedLifecyclePackage | undefined;\n try {\n loaded = await (runtime.loadPackage\n ? runtime.loadPackage(packageName, cwd)\n : loadLifecyclePackage(packageName, cwd, runtime.spawn ?? spawnSync));\n if (loaded.manifest.name !== packageName) {\n throw new Error(\n `Manifest name ${loaded.manifest.name} does not match requested package ${packageName}`,\n );\n }\n const target = resolveTarget(cwd, flagValue(args, \"--app\"));\n const planned =\n command === \"eject\"\n ? planEject(loaded, target.root, target.layout)\n : planAdd(loaded, target.root, target.layout, command === \"inspect\");\n const report = reportFor(command, loaded, target, apply, planned);\n if (report.collisions.length > 0) {\n report.compatible = false;\n }\n if (json) io.out(JSON.stringify(report, null, 2));\n else io.out(formatReport(report));\n if (!report.compatible) return 1;\n if (command === \"inspect\" || !apply) return 0;\n\n await applyTransaction(\n target.root,\n planned.changes.filter((change) => change.action !== \"noop\"),\n runtime.spawn ?? spawnSync,\n );\n return 0;\n } catch (error) {\n io.err(error instanceof Error ? error.message : String(error));\n return 1;\n } finally {\n loaded?.cleanup?.();\n }\n}\n\nfunction isCommand(\n value: string | undefined,\n): value is \"inspect\" | \"add\" | \"eject\" {\n return value === \"inspect\" || value === \"add\" || value === \"eject\";\n}\n\nfunction flagValue(args: string[], name: string): string | undefined {\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n\nexport function packageLifecycleUsage(): string {\n return [\n \"Install-on-demand Toolkit capability module lifecycle:\",\n \"\",\n \"Usage:\",\n \" agent-native package inspect <package> [--root <dir>] [--app <name>] [--json]\",\n \" agent-native package add <package> [--root <dir>] [--app <name>] [--apply] [--json]\",\n \" agent-native package eject <package> [--root <dir>] [--app <name>] [--apply] [--json]\",\n \"\",\n \"add and eject are dry-run by default; pass --apply to write and run the package manager.\",\n ].join(\"\\n\");\n}\n\nexport async function loadLifecyclePackage(\n name: string,\n cwd: string,\n spawn: typeof spawnSync = spawnSync,\n): Promise<LoadedLifecyclePackage> {\n const packageJsonPath = findInstalledPackageJson(name, cwd);\n if (packageJsonPath) {\n return loadStaticPackageDirectory(name, path.dirname(packageJsonPath));\n }\n if (!/^(@[a-z0-9._-]+\\/)?[a-z0-9._-]+$/.test(name)) {\n throw new Error(`Invalid package name: ${name}`);\n }\n const stage = fs.mkdtempSync(\n path.join(os.tmpdir(), \"agent-native-package-inspect-\"),\n );\n try {\n const packed = spawn(\n \"npm\",\n [\"pack\", name, \"--ignore-scripts\", \"--json\", \"--pack-destination\", stage],\n { cwd, encoding: \"utf8\", stdio: \"pipe\" },\n );\n if (packed.status !== 0) {\n throw new Error(`Unable to download package metadata for '${name}'`);\n }\n const entries = JSON.parse(String(packed.stdout || \"[]\")) as Array<{\n filename?: string;\n }>;\n const filename = entries[0]?.filename;\n if (!filename || path.basename(filename) !== filename) {\n throw new Error(\n `npm pack returned an invalid archive name for '${name}'`,\n );\n }\n const archive = path.join(stage, filename);\n const listed = spawn(\"tar\", [\"-tzf\", archive], {\n cwd,\n encoding: \"utf8\",\n stdio: \"pipe\",\n });\n if (listed.status !== 0) {\n throw new Error(`Unable to list package archive for '${name}'`);\n }\n const archiveEntries = String(listed.stdout || \"\")\n .split(/\\r?\\n/)\n .filter(Boolean);\n if (\n archiveEntries.length === 0 ||\n archiveEntries.some(\n (entry) =>\n entry.includes(\"\\\\\") ||\n entry.startsWith(\"/\") ||\n !entry.startsWith(\"package/\") ||\n entry.split(\"/\").includes(\"..\"),\n )\n ) {\n throw new Error(`Package archive for '${name}' contains an unsafe path`);\n }\n const extracted = spawn(\n \"tar\",\n [\n \"-xzf\",\n archive,\n \"-C\",\n stage,\n \"--no-same-owner\",\n \"--no-same-permissions\",\n ],\n {\n cwd,\n encoding: \"utf8\",\n stdio: \"pipe\",\n },\n );\n if (extracted.status !== 0) {\n throw new Error(`Unable to inspect package archive for '${name}'`);\n }\n const loaded = loadStaticPackageDirectory(\n name,\n path.join(stage, \"package\"),\n );\n loaded.cleanup = () => fs.rmSync(stage, { recursive: true, force: true });\n return loaded;\n } catch (error) {\n fs.rmSync(stage, { recursive: true, force: true });\n throw error;\n }\n}\n\nfunction loadStaticPackageDirectory(\n name: string,\n packageDir: string,\n): LoadedLifecyclePackage {\n const packageJsonPath = path.join(packageDir, \"package.json\");\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\")) as {\n name?: string;\n version?: string;\n agentNativeManifest?: string;\n [key: string]: unknown;\n };\n if (packageJson.name !== name) {\n throw new Error(\n `Installed package name ${String(packageJson.name)} does not match ${name}`,\n );\n }\n if (!packageJson.version) {\n throw new Error(`Package '${name}' has no version`);\n }\n if (\n !/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/.test(\n packageJson.version,\n )\n ) {\n throw new Error(`Package '${name}' has an invalid version`);\n }\n const relativeManifest = packageJson.agentNativeManifest;\n if (!relativeManifest || path.isAbsolute(relativeManifest)) {\n throw new Error(\n `Package '${name}' does not declare a static agentNativeManifest`,\n );\n }\n const manifestPath = path.resolve(packageDir, relativeManifest);\n if (\n manifestPath !== packageDir &&\n !manifestPath.startsWith(`${path.resolve(packageDir)}${path.sep}`)\n ) {\n throw new Error(`Package '${name}' manifest escapes the package directory`);\n }\n const manifestStat = fs.lstatSync(manifestPath);\n if (!manifestStat.isFile() || manifestStat.isSymbolicLink()) {\n throw new Error(`Package '${name}' static manifest must be a regular file`);\n }\n const realPackageDir = fs.realpathSync(packageDir);\n const realManifestPath = fs.realpathSync(manifestPath);\n if (!realManifestPath.startsWith(`${realPackageDir}${path.sep}`)) {\n throw new Error(\n `Package '${name}' static manifest escapes the package directory`,\n );\n }\n const manifest = JSON.parse(fs.readFileSync(manifestPath, \"utf8\"));\n assertAgentNativePackageManifest(manifest);\n if (manifest.name !== name) {\n throw new Error(`Manifest name ${manifest.name} does not match ${name}`);\n }\n return {\n manifest,\n packageVersion: packageJson.version,\n packageDir,\n packageJson,\n };\n}\n\nfunction findInstalledPackageJson(name: string, from: string): string | null {\n let dir = from;\n while (true) {\n const candidate = path.join(dir, \"node_modules\", name, \"package.json\");\n if (fs.existsSync(candidate)) return candidate;\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\nfunction resolveTarget(\n root: string,\n appName?: string,\n): { root: string; layout: PackageLifecycleReport[\"layout\"] } {\n const packageJsonPath = path.join(root, \"package.json\");\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(`Target root has no package.json: ${root}`);\n }\n const pkg = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n const workspace =\n typeof pkg?.[\"agent-native\"]?.workspaceCore === \"string\" &&\n fs.existsSync(path.join(root, \"apps\"));\n if (!workspace) return { root, layout: \"standalone\" };\n if (!appName) {\n return { root, layout: \"workspace-root\" };\n }\n if (!/^[a-z0-9][a-z0-9-]*$/.test(appName)) {\n throw new Error(`Invalid workspace app name: ${appName}`);\n }\n const appRoot = path.join(root, \"apps\", appName);\n if (!fs.existsSync(path.join(appRoot, \"package.json\"))) {\n throw new Error(`Workspace app not found: ${appRoot}`);\n }\n return { root: appRoot, layout: \"workspace-app\" };\n}\n\nfunction planAdd(\n loaded: LoadedLifecyclePackage,\n targetRoot: string,\n layout: PackageLifecycleReport[\"layout\"],\n inspectOnly: boolean,\n): { changes: Change[]; collisions: string[]; warnings: string[] } {\n const { manifest, packageDir } = loaded;\n const collisions: string[] = [];\n const warnings: string[] = [];\n if (layout === \"workspace-root\") {\n collisions.push(\"Workspace root is ambiguous; pass --app <name> for add\");\n return { changes: [], collisions, warnings };\n }\n const packageJsonPath = path.join(targetRoot, \"package.json\");\n const pkg = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n pkg.dependencies ??= {};\n const wantedRange = `^${loaded.packageVersion}`;\n const currentRange = pkg.dependencies[manifest.name];\n if (currentRange !== wantedRange && currentRange !== \"workspace:*\") {\n pkg.dependencies[manifest.name] = wantedRange;\n }\n const changes: Change[] = [\n textChange(\n targetRoot,\n packageJsonPath,\n `${JSON.stringify(pkg, null, 2)}\\n`,\n \"dependency\",\n ),\n ];\n for (const action of manifest.actions) {\n const target = path.join(targetRoot, \"actions\", `${action}.ts`);\n const content = `export { default } from \"${manifest.name}/actions/${action}\";\\n`;\n changes.push(\n collisionCheckedText(targetRoot, target, content, \"action\", collisions),\n );\n }\n\n const schemaPath = path.join(targetRoot, \"server\", \"db\", \"schema.ts\");\n if (!fs.existsSync(schemaPath)) {\n collisions.push(\n `Required schema file is missing: ${relative(targetRoot, schemaPath)}`,\n );\n } else {\n const current = fs.readFileSync(schemaPath, \"utf8\");\n const marker = `// agent-native-package:${manifest.name}`;\n const contribution = `${marker}\\nexport * from \"${manifest.schemaEntryPoint}\";`;\n if (current.includes(marker) && !current.includes(contribution)) {\n collisions.push(\n \"Existing package-owned schema block has unexpected content\",\n );\n }\n const next = current.includes(contribution)\n ? current\n : `${current.trimEnd()}\\n\\n${contribution}\\n`;\n changes.push(textChange(targetRoot, schemaPath, next, \"schema\"));\n }\n\n const ownedPaths: string[] = [];\n for (const skill of manifest.docs.skills) {\n const source = path.join(packageDir, \"docs\", \"skills\", skill);\n if (!fs.existsSync(source)) {\n collisions.push(`Manifest skill source is missing: docs/skills/${skill}`);\n continue;\n }\n for (const sourceFile of walkFiles(source)) {\n const target = path.join(\n targetRoot,\n \".agents\",\n \"skills\",\n skill,\n path.relative(source, sourceFile),\n );\n changes.push(\n collisionCheckedBuffer(\n targetRoot,\n target,\n fs.readFileSync(sourceFile),\n \"skill\",\n collisions,\n ),\n );\n ownedPaths.push(relative(targetRoot, target));\n }\n }\n const provenancePath = path.join(\n targetRoot,\n \".agent-native\",\n \"packages\",\n `${manifest.name.replaceAll(\"/\", \"__\")}.json`,\n );\n const provenance = {\n manifestVersion: manifest.manifestVersion,\n package: manifest.name,\n version: loaded.packageVersion,\n actions: manifest.actions,\n schemaEntryPoint: manifest.schemaEntryPoint,\n skills: manifest.docs.skills,\n files: ownedPaths.sort(),\n };\n changes.push(\n textChange(\n targetRoot,\n provenancePath,\n `${JSON.stringify(provenance, null, 2)}\\n`,\n \"provenance\",\n ),\n );\n if (inspectOnly)\n warnings.push(\"inspect is read-only; shown changes are the add plan\");\n return { changes, collisions, warnings };\n}\n\nfunction planEject(\n loaded: LoadedLifecyclePackage,\n targetRoot: string,\n layout: PackageLifecycleReport[\"layout\"],\n): { changes: Change[]; collisions: string[]; warnings: string[] } {\n const collisions: string[] = [];\n const warnings: string[] = [];\n if (loaded.manifest.name !== \"@agent-native/scheduling\") {\n collisions.push(\"Eject currently supports only @agent-native/scheduling\");\n return { changes: [], collisions, warnings };\n }\n if (!loaded.manifest.eject) {\n collisions.push(\"Package manifest does not declare eject metadata\");\n return { changes: [], collisions, warnings };\n }\n const workspaceRoot =\n layout === \"workspace-app\" ? path.resolve(targetRoot, \"../..\") : targetRoot;\n const pnpmWorkspace = path.join(workspaceRoot, \"pnpm-workspace.yaml\");\n if (!fs.existsSync(pnpmWorkspace)) {\n collisions.push(\n \"Eject currently requires an existing pnpm workspace; refusing to create a workspace:* dependency for another package manager\",\n );\n return { changes: [], collisions, warnings };\n }\n const targetDir = path.join(\n workspaceRoot,\n loaded.manifest.eject.targetDirectory,\n );\n if (fs.existsSync(targetDir)) {\n collisions.push(\n `Eject target already exists: ${relative(workspaceRoot, targetDir)}`,\n );\n return { changes: [], collisions, warnings };\n }\n const sourceRoot = path.join(\n loaded.packageDir,\n loaded.manifest.eject.sourceRoot,\n );\n if (!fs.existsSync(sourceRoot)) {\n collisions.push(\n `Published eject source is missing: ${loaded.manifest.eject.sourceRoot}`,\n );\n return { changes: [], collisions, warnings };\n }\n const changes: Change[] = [];\n for (const source of walkFiles(sourceRoot)) {\n const target = path.join(\n targetDir,\n \"src\",\n path.relative(sourceRoot, source),\n );\n changes.push({\n path: target,\n action: \"create\",\n kind: \"eject\",\n content: fs.readFileSync(source),\n });\n }\n for (const name of [\"tsconfig.json\", \"agent-native.package.json\"]) {\n const source = path.join(loaded.packageDir, name);\n if (fs.existsSync(source)) {\n changes.push({\n path: path.join(targetDir, name),\n action: \"create\",\n kind: \"eject\",\n content: fs.readFileSync(source),\n });\n }\n }\n changes.push({\n path: path.join(targetDir, \"package.json\"),\n action: \"create\",\n kind: \"eject\",\n content: `${JSON.stringify(\n normalizeEjectedPackageJson(loaded.packageJson, workspaceRoot),\n null,\n 2,\n )}\\n`,\n });\n const consumerPackageJson = path.join(targetRoot, \"package.json\");\n const consumer = JSON.parse(fs.readFileSync(consumerPackageJson, \"utf8\"));\n consumer.dependencies ??= {};\n consumer.dependencies[loaded.manifest.name] = \"workspace:*\";\n changes.push(\n textChange(\n workspaceRoot,\n consumerPackageJson,\n `${JSON.stringify(consumer, null, 2)}\\n`,\n \"dependency\",\n ),\n );\n if (fs.existsSync(pnpmWorkspace)) {\n const text = fs.readFileSync(pnpmWorkspace, \"utf8\");\n if (!text.includes(\"packages/*\") && !text.includes(\"packages/**\")) {\n collisions.push(\n \"pnpm-workspace.yaml does not include packages/*; refusing to rewrite YAML\",\n );\n }\n } else {\n changes.push({\n path: pnpmWorkspace,\n action: \"create\",\n kind: \"workspace\",\n content: 'packages:\\n - \"packages/*\"\\n',\n });\n }\n warnings.push(\n \"Imports keep the canonical @agent-native/scheduling specifier; workspace resolution switches them to the local package.\",\n );\n return { changes, collisions, warnings };\n}\n\nfunction normalizeEjectedPackageJson(\n input: Record<string, unknown>,\n workspaceRoot: string,\n): Record<string, unknown> {\n const output = structuredClone(input) as Record<string, any>;\n for (const field of [\"dependencies\", \"devDependencies\", \"peerDependencies\"]) {\n const dependencies = output[field] as Record<string, unknown> | undefined;\n if (!dependencies) continue;\n for (const [name, range] of Object.entries(dependencies)) {\n if (\n typeof range !== \"string\" ||\n (!range.startsWith(\"workspace:\") && !range.startsWith(\"catalog:\"))\n ) {\n continue;\n }\n const installed = findInstalledPackageJson(name, workspaceRoot);\n if (!installed) {\n throw new Error(\n `Cannot normalize ${field}.${name}; the installed dependency version is unavailable`,\n );\n }\n const version = JSON.parse(fs.readFileSync(installed, \"utf8\")).version;\n if (!version)\n throw new Error(`Installed dependency ${name} has no version`);\n dependencies[name] = `^${version}`;\n }\n }\n return output;\n}\n\nfunction collisionCheckedText(\n root: string,\n target: string,\n content: string,\n kind: Change[\"kind\"],\n collisions: string[],\n): Change {\n return collisionCheckedBuffer(\n root,\n target,\n Buffer.from(content),\n kind,\n collisions,\n );\n}\n\nfunction collisionCheckedBuffer(\n root: string,\n target: string,\n content: Buffer,\n kind: Change[\"kind\"],\n collisions: string[],\n): Change {\n if (!fs.existsSync(target)) {\n return { path: target, action: \"create\", kind, content };\n }\n const current = fs.readFileSync(target);\n if (current.equals(content)) return { path: target, action: \"noop\", kind };\n collisions.push(`Refusing to overwrite ${relative(root, target)}`);\n return { path: target, action: \"noop\", kind };\n}\n\nfunction textChange(\n root: string,\n target: string,\n content: string,\n kind: Change[\"kind\"],\n): Change {\n if (!fs.existsSync(target))\n return { path: target, action: \"create\", kind, content };\n return {\n path: target,\n action: fs.readFileSync(target, \"utf8\") === content ? \"noop\" : \"update\",\n kind,\n content,\n };\n}\n\nfunction walkFiles(root: string): string[] {\n const files: string[] = [];\n for (const entry of fs.readdirSync(root, { withFileTypes: true })) {\n const full = path.join(root, entry.name);\n if (entry.isSymbolicLink())\n throw new Error(`Refusing package symlink: ${full}`);\n if (entry.isDirectory()) files.push(...walkFiles(full));\n else if (entry.isFile()) files.push(full);\n }\n return files.sort();\n}\n\nfunction reportFor(\n command: PackageLifecycleReport[\"command\"],\n loaded: LoadedLifecyclePackage,\n target: { root: string; layout: PackageLifecycleReport[\"layout\"] },\n apply: boolean,\n planned: { changes: Change[]; collisions: string[]; warnings: string[] },\n): PackageLifecycleReport {\n const { manifest } = loaded;\n return {\n command,\n package: manifest.name,\n packageVersion: loaded.packageVersion,\n manifestVersion: manifest.manifestVersion,\n targetRoot: target.root,\n layout: target.layout,\n apply,\n compatible: planned.collisions.length === 0,\n contributions: {\n actions: manifest.actions,\n schemaEntryPoint: manifest.schemaEntryPoint,\n skills: manifest.docs.skills,\n requiredSecretKeys: manifest.requiredSecrets.map((secret) => secret.key),\n peerProviders: manifest.peerProviders,\n },\n changes: planned.changes.map(({ path: file, action, kind }) => ({\n path: relative(target.root, file),\n action,\n kind,\n })),\n collisions: planned.collisions,\n warnings: planned.warnings,\n };\n}\n\nfunction formatReport(report: PackageLifecycleReport): string {\n const lines = [\n `# ${report.command} ${report.package}@${report.packageVersion}`,\n `Manifest: v${report.manifestVersion}`,\n `Target: ${report.targetRoot} (${report.layout})`,\n `Mode: ${report.apply ? \"apply\" : \"dry-run\"}`,\n `Compatible: ${report.compatible ? \"yes\" : \"no\"}`,\n \"\",\n `Actions: ${report.contributions.actions.length}`,\n `Schema: ${report.contributions.schemaEntryPoint}`,\n `Skills: ${report.contributions.skills.join(\", \") || \"none\"}`,\n `Required secret keys: ${report.contributions.requiredSecretKeys.join(\", \") || \"none\"}`,\n `Peer providers: ${report.contributions.peerProviders.join(\", \") || \"none\"}`,\n \"\",\n \"Changes:\",\n ...report.changes.map(\n (change) =>\n ` ${change.action.padEnd(6)} ${change.path} (${change.kind})`,\n ),\n ];\n if (report.collisions.length) {\n lines.push(\n \"\",\n \"Collisions:\",\n ...report.collisions.map((item) => ` - ${item}`),\n );\n }\n if (report.warnings.length) {\n lines.push(\"\", \"Notes:\", ...report.warnings.map((item) => ` - ${item}`));\n }\n if (!report.apply && report.command !== \"inspect\") {\n lines.push(\"\", \"Dry-run only. Re-run with --apply to write these changes.\");\n }\n return lines.join(\"\\n\");\n}\n\nasync function applyTransaction(\n root: string,\n changes: Change[],\n spawn: typeof spawnSync,\n): Promise<void> {\n const stage = fs.mkdtempSync(path.join(root, \".agent-native-package-stage-\"));\n const snapshots = new Map<string, Buffer | null>();\n const installRoot = findPackageManagerRoot(root);\n const lockfiles = [\"pnpm-lock.yaml\", \"package-lock.json\", \"yarn.lock\"].map(\n (name) => path.join(installRoot, name),\n );\n try {\n for (const change of changes) {\n snapshots.set(\n change.path,\n fs.existsSync(change.path) ? fs.readFileSync(change.path) : null,\n );\n const staged = path.join(stage, String(snapshots.size));\n fs.writeFileSync(staged, change.content!);\n }\n for (const lockfile of lockfiles) {\n snapshots.set(\n lockfile,\n fs.existsSync(lockfile) ? fs.readFileSync(lockfile) : null,\n );\n }\n let index = 0;\n for (const change of changes) {\n index += 1;\n fs.mkdirSync(path.dirname(change.path), { recursive: true });\n fs.renameSync(path.join(stage, String(index)), change.path);\n }\n const packageManager = detectPackageManager(installRoot);\n const result = spawn(packageManager, [\"install\"], {\n cwd: installRoot,\n stdio: \"inherit\",\n });\n if (result.status !== 0) {\n throw new Error(\n `${packageManager} install failed with status ${result.status}`,\n );\n }\n } catch (error) {\n for (const [file, snapshot] of [...snapshots.entries()].reverse()) {\n if (snapshot === null) fs.rmSync(file, { force: true, recursive: true });\n else {\n fs.mkdirSync(path.dirname(file), { recursive: true });\n fs.writeFileSync(file, snapshot);\n }\n }\n for (const change of [...changes].reverse()) {\n removeEmptyParents(path.dirname(change.path), root);\n }\n throw error;\n } finally {\n fs.rmSync(stage, { recursive: true, force: true });\n }\n}\n\nfunction removeEmptyParents(directory: string, stop: string): void {\n let current = directory;\n const boundary = path.resolve(stop);\n while (current.startsWith(`${boundary}${path.sep}`)) {\n try {\n if (fs.readdirSync(current).length > 0) return;\n fs.rmdirSync(current);\n } catch {\n return;\n }\n current = path.dirname(current);\n }\n}\n\nfunction detectPackageManager(root: string): \"pnpm\" | \"yarn\" | \"npm\" {\n if (fs.existsSync(path.join(root, \"pnpm-lock.yaml\"))) return \"pnpm\";\n if (fs.existsSync(path.join(root, \"yarn.lock\"))) return \"yarn\";\n return \"npm\";\n}\n\nfunction findPackageManagerRoot(from: string): string {\n let dir = from;\n while (true) {\n if (\n fs.existsSync(path.join(dir, \"pnpm-lock.yaml\")) ||\n fs.existsSync(path.join(dir, \"yarn.lock\")) ||\n fs.existsSync(path.join(dir, \"package-lock.json\"))\n ) {\n return dir;\n }\n const parent = path.dirname(dir);\n if (parent === dir) return from;\n dir = parent;\n }\n}\n\nfunction relative(root: string, file: string): string {\n const value = path.relative(root, file);\n return value || \".\";\n}\n"]}
@@ -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- **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\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.\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). `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- **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\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.\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). `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
@@ -1 +1 @@
1
- {"version":3,"file":"visual-plan-skill.d.ts","sourceRoot":"","sources":["../../../src/cli/skills-content/visual-plan-skill.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,+j7BA0ejC,CAAC"}
1
+ {"version":3,"file":"visual-plan-skill.d.ts","sourceRoot":"","sources":["../../../src/cli/skills-content/visual-plan-skill.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,4s7BA4ejC,CAAC"}
@@ -290,6 +290,8 @@ folding framework chrome into the product UI.
290
290
  needs to operate the behavior. Keep the static wireframes in
291
291
  \`content.canvas\`, add the aligned functional prototype in
292
292
  \`content.prototype\`, and rely on the top visual tabs to switch between them.
293
+ When both surfaces are present, open the Wireframes tab by default; the
294
+ prototype remains available as the interactive follow-up view.
293
295
  - **Prototype-first** when the user asks to operate the UI or when interaction is
294
296
  the main question. Use \`create-prototype-plan\`, which still preserves static
295
297
  mocks where useful.
@@ -1 +1 @@
1
- {"version":3,"file":"visual-plan-skill.js","sourceRoot":"","sources":["../../../src/cli/skills-content/visual-plan-skill.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0epC,CAAC","sourcesContent":["export 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 — typos, one-line fixes, a\n single well-specified function, anything whose diff you could describe in one\n sentence — 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 — existing actions, schema,\n components, helpers — 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 — wire format, public ids,\n data-model shape, auth and ownership boundaries — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — irreversible migrations, security-sensitive work, or when\nthe user explicitly asks for extra rigor — 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 — 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 — 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\\` — 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- **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\n## Wireframe quality — read \\`references/wireframe.md\\`\n\nUI recap/plan wireframes must meet a strict quality bar — 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 — 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 — 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 — 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 — 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 — 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 — read \\`references/exemplar.md\\`\n\nFor a worked example of the bar — a great UI-first plan and \\`/visual-plan\\`, plus\nthe anti-patterns to avoid — 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.\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). \\`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 — 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 — never hand-edit one stored plan. Turn feedback into better guidance.\n\n## Local-Files Privacy Mode — read \\`references/local-files.md\\`\n\nWhen the user wants no hosted Plan database writes — no DB writes, no Plan MCP\npublish, fully local/offline/private planning, repo-owned source-controlled\nartifacts, or \\`AGENT_NATIVE_PLANS_MODE=local-files\\` — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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`;\n"]}
1
+ {"version":3,"file":"visual-plan-skill.js","sourceRoot":"","sources":["../../../src/cli/skills-content/visual-plan-skill.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4epC,CAAC","sourcesContent":["export 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 — typos, one-line fixes, a\n single well-specified function, anything whose diff you could describe in one\n sentence — 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 — existing actions, schema,\n components, helpers — 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 — wire format, public ids,\n data-model shape, auth and ownership boundaries — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — irreversible migrations, security-sensitive work, or when\nthe user explicitly asks for extra rigor — 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 — 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 — 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\\` — 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\n## Wireframe quality — read \\`references/wireframe.md\\`\n\nUI recap/plan wireframes must meet a strict quality bar — 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 — 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 — 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 — 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 — 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 — 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 — read \\`references/exemplar.md\\`\n\nFor a worked example of the bar — a great UI-first plan and \\`/visual-plan\\`, plus\nthe anti-patterns to avoid — 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.\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). \\`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 — 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 — never hand-edit one stored plan. Turn feedback into better guidance.\n\n## Local-Files Privacy Mode — read \\`references/local-files.md\\`\n\nWhen the user wants no hosted Plan database writes — no DB writes, no Plan MCP\npublish, fully local/offline/private planning, repo-owned source-controlled\nartifacts, or \\`AGENT_NATIVE_PLANS_MODE=local-files\\` — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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`;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMeter.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/ContextMeter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,8BAA8B,CAAC;AA4DtC,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,QAAQ,EAAE,gBAAgB,EAC1B,OAAc,GACf,EAAE;IACD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,sCAkIA"}
1
+ {"version":3,"file":"ContextMeter.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/ContextMeter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,8BAA8B,CAAC;AActC,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,QAAQ,EAAE,gBAAgB,EAC1B,OAAc,GACf,EAAE;IACD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,sCA+FA"}