@agent-native/core 0.37.2 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/README.md +19 -6
  2. package/dist/action.d.ts +60 -2
  3. package/dist/action.d.ts.map +1 -1
  4. package/dist/action.js +6 -2
  5. package/dist/action.js.map +1 -1
  6. package/dist/agent/production-agent.d.ts +12 -6
  7. package/dist/agent/production-agent.d.ts.map +1 -1
  8. package/dist/agent/production-agent.js +161 -11
  9. package/dist/agent/production-agent.js.map +1 -1
  10. package/dist/agent/types.d.ts +2 -0
  11. package/dist/agent/types.d.ts.map +1 -1
  12. package/dist/agent/types.js.map +1 -1
  13. package/dist/catalog.json +2 -2
  14. package/dist/cli/connect.d.ts.map +1 -1
  15. package/dist/cli/connect.js +15 -0
  16. package/dist/cli/connect.js.map +1 -1
  17. package/dist/cli/index.js +10 -6
  18. package/dist/cli/index.js.map +1 -1
  19. package/dist/cli/plan-publish-store.d.ts +52 -0
  20. package/dist/cli/plan-publish-store.d.ts.map +1 -0
  21. package/dist/cli/plan-publish-store.js +103 -0
  22. package/dist/cli/plan-publish-store.js.map +1 -0
  23. package/dist/cli/skills.d.ts +29 -0
  24. package/dist/cli/skills.d.ts.map +1 -1
  25. package/dist/cli/skills.js +1349 -544
  26. package/dist/cli/skills.js.map +1 -1
  27. package/dist/cli/templates-meta.js +12 -12
  28. package/dist/cli/templates-meta.js.map +1 -1
  29. package/dist/client/AssistantChat.d.ts +3 -1
  30. package/dist/client/AssistantChat.d.ts.map +1 -1
  31. package/dist/client/AssistantChat.js +65 -15
  32. package/dist/client/AssistantChat.js.map +1 -1
  33. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  34. package/dist/client/MultiTabAssistantChat.js +20 -2
  35. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  36. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  37. package/dist/client/agent-chat-adapter.js +12 -0
  38. package/dist/client/agent-chat-adapter.js.map +1 -1
  39. package/dist/client/agent-engine-key.d.ts +24 -0
  40. package/dist/client/agent-engine-key.d.ts.map +1 -0
  41. package/dist/client/agent-engine-key.js +49 -0
  42. package/dist/client/agent-engine-key.js.map +1 -0
  43. package/dist/client/analytics.d.ts.map +1 -1
  44. package/dist/client/analytics.js +34 -0
  45. package/dist/client/analytics.js.map +1 -1
  46. package/dist/client/blocks/BlockView.d.ts +26 -0
  47. package/dist/client/blocks/BlockView.d.ts.map +1 -0
  48. package/dist/client/blocks/BlockView.js +24 -0
  49. package/dist/client/blocks/BlockView.js.map +1 -0
  50. package/dist/client/blocks/SchemaBlockEditor.d.ts +25 -0
  51. package/dist/client/blocks/SchemaBlockEditor.d.ts.map +1 -0
  52. package/dist/client/blocks/SchemaBlockEditor.js +72 -0
  53. package/dist/client/blocks/SchemaBlockEditor.js.map +1 -0
  54. package/dist/client/blocks/agent.d.ts +30 -0
  55. package/dist/client/blocks/agent.d.ts.map +1 -0
  56. package/dist/client/blocks/agent.js +61 -0
  57. package/dist/client/blocks/agent.js.map +1 -0
  58. package/dist/client/blocks/index.d.ts +34 -0
  59. package/dist/client/blocks/index.d.ts.map +1 -0
  60. package/dist/client/blocks/index.js +42 -0
  61. package/dist/client/blocks/index.js.map +1 -0
  62. package/dist/client/blocks/library/checklist.config.d.ts +36 -0
  63. package/dist/client/blocks/library/checklist.config.d.ts.map +1 -0
  64. package/dist/client/blocks/library/checklist.config.js +25 -0
  65. package/dist/client/blocks/library/checklist.config.js.map +1 -0
  66. package/dist/client/blocks/library/checklist.d.ts +26 -0
  67. package/dist/client/blocks/library/checklist.d.ts.map +1 -0
  68. package/dist/client/blocks/library/checklist.js +76 -0
  69. package/dist/client/blocks/library/checklist.js.map +1 -0
  70. package/dist/client/blocks/library/code-tabs.config.d.ts +36 -0
  71. package/dist/client/blocks/library/code-tabs.config.d.ts.map +1 -0
  72. package/dist/client/blocks/library/code-tabs.config.js +30 -0
  73. package/dist/client/blocks/library/code-tabs.config.js.map +1 -0
  74. package/dist/client/blocks/library/code-tabs.d.ts +3 -0
  75. package/dist/client/blocks/library/code-tabs.d.ts.map +1 -0
  76. package/dist/client/blocks/library/code-tabs.js +165 -0
  77. package/dist/client/blocks/library/code-tabs.js.map +1 -0
  78. package/dist/client/blocks/library/html.config.d.ts +37 -0
  79. package/dist/client/blocks/library/html.config.d.ts.map +1 -0
  80. package/dist/client/blocks/library/html.config.js +46 -0
  81. package/dist/client/blocks/library/html.config.js.map +1 -0
  82. package/dist/client/blocks/library/html.d.ts +21 -0
  83. package/dist/client/blocks/library/html.d.ts.map +1 -0
  84. package/dist/client/blocks/library/html.js +69 -0
  85. package/dist/client/blocks/library/html.js.map +1 -0
  86. package/dist/client/blocks/library/table.config.d.ts +30 -0
  87. package/dist/client/blocks/library/table.config.d.ts.map +1 -0
  88. package/dist/client/blocks/library/table.config.js +22 -0
  89. package/dist/client/blocks/library/table.config.js.map +1 -0
  90. package/dist/client/blocks/library/table.d.ts +8 -0
  91. package/dist/client/blocks/library/table.d.ts.map +1 -0
  92. package/dist/client/blocks/library/table.js +107 -0
  93. package/dist/client/blocks/library/table.js.map +1 -0
  94. package/dist/client/blocks/library/tabs.config.d.ts +56 -0
  95. package/dist/client/blocks/library/tabs.config.d.ts.map +1 -0
  96. package/dist/client/blocks/library/tabs.config.js +36 -0
  97. package/dist/client/blocks/library/tabs.config.js.map +1 -0
  98. package/dist/client/blocks/library/tabs.d.ts +20 -0
  99. package/dist/client/blocks/library/tabs.d.ts.map +1 -0
  100. package/dist/client/blocks/library/tabs.js +123 -0
  101. package/dist/client/blocks/library/tabs.js.map +1 -0
  102. package/dist/client/blocks/mdx.d.ts +74 -0
  103. package/dist/client/blocks/mdx.d.ts.map +1 -0
  104. package/dist/client/blocks/mdx.js +205 -0
  105. package/dist/client/blocks/mdx.js.map +1 -0
  106. package/dist/client/blocks/provider.d.ts +25 -0
  107. package/dist/client/blocks/provider.d.ts.map +1 -0
  108. package/dist/client/blocks/provider.js +19 -0
  109. package/dist/client/blocks/provider.js.map +1 -0
  110. package/dist/client/blocks/registry.d.ts +24 -0
  111. package/dist/client/blocks/registry.d.ts.map +1 -0
  112. package/dist/client/blocks/registry.js +50 -0
  113. package/dist/client/blocks/registry.js.map +1 -0
  114. package/dist/client/blocks/schema-form/introspect.d.ts +31 -0
  115. package/dist/client/blocks/schema-form/introspect.d.ts.map +1 -0
  116. package/dist/client/blocks/schema-form/introspect.js +164 -0
  117. package/dist/client/blocks/schema-form/introspect.js.map +1 -0
  118. package/dist/client/blocks/server.d.ts +22 -0
  119. package/dist/client/blocks/server.d.ts.map +1 -0
  120. package/dist/client/blocks/server.js +25 -0
  121. package/dist/client/blocks/server.js.map +1 -0
  122. package/dist/client/blocks/types.d.ts +212 -0
  123. package/dist/client/blocks/types.d.ts.map +1 -0
  124. package/dist/client/blocks/types.js +5 -0
  125. package/dist/client/blocks/types.js.map +1 -0
  126. package/dist/client/composer/ComposerPlusMenu.js +10 -1
  127. package/dist/client/composer/ComposerPlusMenu.js.map +1 -1
  128. package/dist/client/guided-questions.d.ts +68 -0
  129. package/dist/client/guided-questions.d.ts.map +1 -1
  130. package/dist/client/guided-questions.js +158 -3
  131. package/dist/client/guided-questions.js.map +1 -1
  132. package/dist/client/index.d.ts +5 -1
  133. package/dist/client/index.d.ts.map +1 -1
  134. package/dist/client/index.js +15 -1
  135. package/dist/client/index.js.map +1 -1
  136. package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts +37 -0
  137. package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts.map +1 -0
  138. package/dist/client/rich-markdown-editor/BubbleToolbar.js +161 -0
  139. package/dist/client/rich-markdown-editor/BubbleToolbar.js.map +1 -0
  140. package/dist/client/rich-markdown-editor/ImageExtension.d.ts +63 -0
  141. package/dist/client/rich-markdown-editor/ImageExtension.d.ts.map +1 -0
  142. package/dist/client/rich-markdown-editor/ImageExtension.js +242 -0
  143. package/dist/client/rich-markdown-editor/ImageExtension.js.map +1 -0
  144. package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts +51 -0
  145. package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts.map +1 -0
  146. package/dist/client/rich-markdown-editor/RichMarkdownEditor.js +37 -0
  147. package/dist/client/rich-markdown-editor/RichMarkdownEditor.js.map +1 -0
  148. package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +61 -0
  149. package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +1 -0
  150. package/dist/client/rich-markdown-editor/SharedRichEditor.js +121 -0
  151. package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +1 -0
  152. package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts +36 -0
  153. package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts.map +1 -0
  154. package/dist/client/rich-markdown-editor/SlashCommandMenu.js +193 -0
  155. package/dist/client/rich-markdown-editor/SlashCommandMenu.js.map +1 -0
  156. package/dist/client/rich-markdown-editor/extensions.d.ts +166 -0
  157. package/dist/client/rich-markdown-editor/extensions.d.ts.map +1 -0
  158. package/dist/client/rich-markdown-editor/extensions.js +222 -0
  159. package/dist/client/rich-markdown-editor/extensions.js.map +1 -0
  160. package/dist/client/rich-markdown-editor/index.d.ts +9 -0
  161. package/dist/client/rich-markdown-editor/index.d.ts.map +1 -0
  162. package/dist/client/rich-markdown-editor/index.js +9 -0
  163. package/dist/client/rich-markdown-editor/index.js.map +1 -0
  164. package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts +18 -0
  165. package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts.map +1 -0
  166. package/dist/client/rich-markdown-editor/uploadEditorImage.js +57 -0
  167. package/dist/client/rich-markdown-editor/uploadEditorImage.js.map +1 -0
  168. package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts +91 -0
  169. package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +1 -0
  170. package/dist/client/rich-markdown-editor/useCollabReconcile.js +342 -0
  171. package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +1 -0
  172. package/dist/client/track.d.ts +25 -0
  173. package/dist/client/track.d.ts.map +1 -0
  174. package/dist/client/track.js +53 -0
  175. package/dist/client/track.js.map +1 -0
  176. package/dist/client/use-action.d.ts.map +1 -1
  177. package/dist/client/use-action.js +6 -0
  178. package/dist/client/use-action.js.map +1 -1
  179. package/dist/client/use-session.d.ts +3 -2
  180. package/dist/client/use-session.d.ts.map +1 -1
  181. package/dist/client/use-session.js +3 -2
  182. package/dist/client/use-session.js.map +1 -1
  183. package/dist/deploy/build.d.ts +5 -0
  184. package/dist/deploy/build.d.ts.map +1 -1
  185. package/dist/deploy/build.js +67 -1
  186. package/dist/deploy/build.js.map +1 -1
  187. package/dist/extensions/schema.d.ts +1 -1
  188. package/dist/mcp/build-server.d.ts.map +1 -1
  189. package/dist/mcp/build-server.js +9 -2
  190. package/dist/mcp/build-server.js.map +1 -1
  191. package/dist/mcp/server.d.ts +1 -1
  192. package/dist/mcp/server.d.ts.map +1 -1
  193. package/dist/mcp/server.js +35 -2
  194. package/dist/mcp/server.js.map +1 -1
  195. package/dist/provider-api/index.d.ts +1 -1
  196. package/dist/provider-api/index.d.ts.map +1 -1
  197. package/dist/scripts/docs/search.d.ts.map +1 -1
  198. package/dist/scripts/docs/search.js +5 -2
  199. package/dist/scripts/docs/search.js.map +1 -1
  200. package/dist/scripts/runner.d.ts.map +1 -1
  201. package/dist/scripts/runner.js +16 -3
  202. package/dist/scripts/runner.js.map +1 -1
  203. package/dist/server/action-discovery.d.ts.map +1 -1
  204. package/dist/server/action-discovery.js +2 -0
  205. package/dist/server/action-discovery.js.map +1 -1
  206. package/dist/server/action-routes.d.ts.map +1 -1
  207. package/dist/server/action-routes.js +30 -4
  208. package/dist/server/action-routes.js.map +1 -1
  209. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  210. package/dist/server/agent-chat-plugin.js +65 -19
  211. package/dist/server/agent-chat-plugin.js.map +1 -1
  212. package/dist/server/agent-teams.d.ts.map +1 -1
  213. package/dist/server/agent-teams.js +8 -1
  214. package/dist/server/agent-teams.js.map +1 -1
  215. package/dist/server/agents-bundle.d.ts +27 -1
  216. package/dist/server/agents-bundle.d.ts.map +1 -1
  217. package/dist/server/agents-bundle.js +41 -3
  218. package/dist/server/agents-bundle.js.map +1 -1
  219. package/dist/server/auth.d.ts.map +1 -1
  220. package/dist/server/auth.js +76 -3
  221. package/dist/server/auth.js.map +1 -1
  222. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  223. package/dist/server/core-routes-plugin.js +60 -0
  224. package/dist/server/core-routes-plugin.js.map +1 -1
  225. package/dist/server/onboarding-html.d.ts.map +1 -1
  226. package/dist/server/onboarding-html.js +160 -22
  227. package/dist/server/onboarding-html.js.map +1 -1
  228. package/dist/server/sentry.d.ts.map +1 -1
  229. package/dist/server/sentry.js +6 -0
  230. package/dist/server/sentry.js.map +1 -1
  231. package/dist/server/social-og-image.d.ts +2 -1
  232. package/dist/server/social-og-image.d.ts.map +1 -1
  233. package/dist/server/social-og-image.js +24 -4
  234. package/dist/server/social-og-image.js.map +1 -1
  235. package/dist/sharing/schema.d.ts +1 -1
  236. package/dist/styles/agent-native.css +1 -0
  237. package/dist/styles/rich-markdown-editor.css +439 -0
  238. package/dist/templates/default/.agents/skills/actions/SKILL.md +4 -1
  239. package/dist/templates/default/.agents/skills/security/SKILL.md +13 -4
  240. package/dist/templates/default/.agents/skills/storing-data/SKILL.md +15 -3
  241. package/dist/templates/default/AGENTS.md +1 -0
  242. package/dist/templates/default/DEVELOPING.md +2 -0
  243. package/dist/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +10 -3
  244. package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +98 -10
  245. package/dist/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +45 -3
  246. package/dist/templates/workspace-core/.agents/skills/address-feedback/SKILL.md +2 -0
  247. package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +37 -4
  248. package/dist/templates/workspace-core/.agents/skills/automations/SKILL.md +9 -4
  249. package/dist/templates/workspace-core/.agents/skills/capture-learnings/SKILL.md +2 -0
  250. package/dist/templates/workspace-core/.agents/skills/client-methods/SKILL.md +106 -0
  251. package/dist/templates/workspace-core/.agents/skills/client-methods/references/legacy-client-fetch-audit-2026-06-03.md +53 -0
  252. package/dist/templates/workspace-core/.agents/skills/client-side-routing/SKILL.md +2 -0
  253. package/dist/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +62 -61
  254. package/dist/templates/workspace-core/.agents/skills/context-xray/SKILL.md +47 -0
  255. package/dist/templates/workspace-core/.agents/skills/create-skill/SKILL.md +28 -0
  256. package/dist/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +52 -1
  257. package/dist/templates/workspace-core/.agents/skills/extension-points/SKILL.md +2 -0
  258. package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +95 -433
  259. package/dist/templates/workspace-core/.agents/skills/extensions/references/api.md +285 -0
  260. package/dist/templates/workspace-core/.agents/skills/extensions/references/examples.md +259 -0
  261. package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +398 -0
  262. package/dist/templates/workspace-core/.agents/skills/external-agents/references/mcp-apps-embedding.md +157 -0
  263. package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +17 -0
  264. package/dist/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +13 -2
  265. package/dist/templates/workspace-core/.agents/skills/mvp-followup/SKILL.md +51 -0
  266. package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +14 -4
  267. package/dist/templates/workspace-core/.agents/skills/onboarding/SKILL.md +13 -1
  268. package/dist/templates/workspace-core/.agents/skills/portability/SKILL.md +27 -5
  269. package/dist/templates/workspace-core/.agents/skills/qa/SKILL.md +24 -8
  270. package/dist/templates/workspace-core/.agents/skills/real-time-collab/SKILL.md +53 -7
  271. package/dist/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +43 -10
  272. package/dist/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +2 -0
  273. package/dist/templates/workspace-core/.agents/skills/secrets/SKILL.md +43 -14
  274. package/dist/templates/workspace-core/.agents/skills/security/SKILL.md +50 -1
  275. package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +4 -2
  276. package/dist/templates/workspace-core/.agents/skills/server-plugins/SKILL.md +11 -1
  277. package/dist/templates/workspace-core/.agents/skills/shadcn-ui/SKILL.md +15 -0
  278. package/dist/templates/workspace-core/.agents/skills/sharing/SKILL.md +5 -1
  279. package/dist/templates/workspace-core/.agents/skills/storing-data/SKILL.md +48 -19
  280. package/dist/templates/workspace-core/.agents/skills/tracking/SKILL.md +7 -3
  281. package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +13 -6
  282. package/dist/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +236 -0
  283. package/dist/templates/workspace-core/AGENTS.md +5 -1
  284. package/dist/templates/workspace-root/AGENTS.md +5 -2
  285. package/dist/tracking/route.d.ts +43 -0
  286. package/dist/tracking/route.d.ts.map +1 -0
  287. package/dist/tracking/route.js +85 -0
  288. package/dist/tracking/route.js.map +1 -0
  289. package/dist/vite/client.d.ts.map +1 -1
  290. package/dist/vite/client.js +15 -0
  291. package/dist/vite/client.js.map +1 -1
  292. package/docs/content/a2a-protocol.md +18 -4
  293. package/docs/content/actions.md +87 -0
  294. package/docs/content/agent-mentions.md +2 -1
  295. package/docs/content/authentication.md +2 -1
  296. package/docs/content/client.md +64 -13
  297. package/docs/content/cloneable-saas.md +1 -1
  298. package/docs/content/code-agents-ui.md +17 -11
  299. package/docs/content/context-awareness.md +23 -28
  300. package/docs/content/creating-templates.md +1 -1
  301. package/docs/content/drop-in-agent.md +2 -0
  302. package/docs/content/getting-started.md +2 -2
  303. package/docs/content/key-concepts.md +2 -2
  304. package/docs/content/messaging.md +57 -15
  305. package/docs/content/migration-workbench.md +1 -1
  306. package/docs/content/multi-app-workspace.md +1 -1
  307. package/docs/content/multi-tenancy.md +17 -15
  308. package/docs/content/real-time-collaboration.md +1 -1
  309. package/docs/content/recurring-jobs.md +1 -1
  310. package/docs/content/security.md +2 -2
  311. package/docs/content/server.md +4 -4
  312. package/docs/content/skills-guide.md +30 -0
  313. package/docs/content/template-analytics.md +2 -2
  314. package/docs/content/template-assets.md +17 -1
  315. package/docs/content/template-brain.md +2 -2
  316. package/docs/content/template-calendar.md +1 -1
  317. package/docs/content/template-clips.md +3 -3
  318. package/docs/content/template-content.md +2 -2
  319. package/docs/content/template-design.md +2 -2
  320. package/docs/content/template-dispatch.md +3 -3
  321. package/docs/content/template-forms.md +14 -2
  322. package/docs/content/template-mail.md +1 -3
  323. package/docs/content/template-plan.md +118 -0
  324. package/docs/content/template-slides.md +5 -4
  325. package/docs/content/template-starter.md +4 -4
  326. package/docs/content/template-videos.md +6 -11
  327. package/docs/content/tracking.md +21 -1
  328. package/docs/content/visual-plans.md +72 -0
  329. package/docs/content/workspace.md +9 -9
  330. package/package.json +26 -11
  331. package/src/templates/default/.agents/skills/actions/SKILL.md +4 -1
  332. package/src/templates/default/.agents/skills/security/SKILL.md +13 -4
  333. package/src/templates/default/.agents/skills/storing-data/SKILL.md +15 -3
  334. package/src/templates/default/AGENTS.md +1 -0
  335. package/src/templates/default/DEVELOPING.md +2 -0
  336. package/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +10 -3
  337. package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +98 -10
  338. package/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +45 -3
  339. package/src/templates/workspace-core/.agents/skills/address-feedback/SKILL.md +2 -0
  340. package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +37 -4
  341. package/src/templates/workspace-core/.agents/skills/automations/SKILL.md +9 -4
  342. package/src/templates/workspace-core/.agents/skills/capture-learnings/SKILL.md +2 -0
  343. package/src/templates/workspace-core/.agents/skills/client-methods/SKILL.md +106 -0
  344. package/src/templates/workspace-core/.agents/skills/client-methods/references/legacy-client-fetch-audit-2026-06-03.md +53 -0
  345. package/src/templates/workspace-core/.agents/skills/client-side-routing/SKILL.md +2 -0
  346. package/src/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +62 -61
  347. package/src/templates/workspace-core/.agents/skills/context-xray/SKILL.md +47 -0
  348. package/src/templates/workspace-core/.agents/skills/create-skill/SKILL.md +28 -0
  349. package/src/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +52 -1
  350. package/src/templates/workspace-core/.agents/skills/extension-points/SKILL.md +2 -0
  351. package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +95 -433
  352. package/src/templates/workspace-core/.agents/skills/extensions/references/api.md +285 -0
  353. package/src/templates/workspace-core/.agents/skills/extensions/references/examples.md +259 -0
  354. package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +398 -0
  355. package/src/templates/workspace-core/.agents/skills/external-agents/references/mcp-apps-embedding.md +157 -0
  356. package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +17 -0
  357. package/src/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +13 -2
  358. package/src/templates/workspace-core/.agents/skills/mvp-followup/SKILL.md +51 -0
  359. package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +14 -4
  360. package/src/templates/workspace-core/.agents/skills/onboarding/SKILL.md +13 -1
  361. package/src/templates/workspace-core/.agents/skills/portability/SKILL.md +27 -5
  362. package/src/templates/workspace-core/.agents/skills/qa/SKILL.md +24 -8
  363. package/src/templates/workspace-core/.agents/skills/real-time-collab/SKILL.md +53 -7
  364. package/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +43 -10
  365. package/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +2 -0
  366. package/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +43 -14
  367. package/src/templates/workspace-core/.agents/skills/security/SKILL.md +50 -1
  368. package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +4 -2
  369. package/src/templates/workspace-core/.agents/skills/server-plugins/SKILL.md +11 -1
  370. package/src/templates/workspace-core/.agents/skills/shadcn-ui/SKILL.md +15 -0
  371. package/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +5 -1
  372. package/src/templates/workspace-core/.agents/skills/storing-data/SKILL.md +48 -19
  373. package/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +7 -3
  374. package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +13 -6
  375. package/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +236 -0
  376. package/src/templates/workspace-core/AGENTS.md +5 -1
  377. package/src/templates/workspace-root/AGENTS.md +5 -2
@@ -0,0 +1,193 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
3
+ import { cn } from "../utils.js";
4
+ import { pickAndInsertImage } from "./ImageExtension.js";
5
+ /**
6
+ * The default block commands — Plan's current set. Apps pass their own `items`
7
+ * (typically `[...DEFAULT_SLASH_COMMANDS, ...extra]`) to extend it.
8
+ */
9
+ export const DEFAULT_SLASH_COMMANDS = [
10
+ {
11
+ title: "Text",
12
+ description: "Plain text block",
13
+ icon: "T",
14
+ action: (editor) => editor.chain().focus().setParagraph().run(),
15
+ },
16
+ {
17
+ title: "Heading 1",
18
+ description: "Large heading",
19
+ icon: "H1",
20
+ action: (editor) => editor.chain().focus().toggleHeading({ level: 1 }).run(),
21
+ },
22
+ {
23
+ title: "Heading 2",
24
+ description: "Section heading",
25
+ icon: "H2",
26
+ action: (editor) => editor.chain().focus().toggleHeading({ level: 2 }).run(),
27
+ },
28
+ {
29
+ title: "Heading 3",
30
+ description: "Subheading",
31
+ icon: "H3",
32
+ action: (editor) => editor.chain().focus().toggleHeading({ level: 3 }).run(),
33
+ },
34
+ {
35
+ title: "Bulleted list",
36
+ description: "Unordered list",
37
+ icon: "-",
38
+ action: (editor) => editor.chain().focus().toggleBulletList().run(),
39
+ },
40
+ {
41
+ title: "Numbered list",
42
+ description: "Ordered list",
43
+ icon: "1.",
44
+ action: (editor) => editor.chain().focus().toggleOrderedList().run(),
45
+ },
46
+ {
47
+ title: "To-do list",
48
+ description: "Checklist items",
49
+ icon: "[]",
50
+ action: (editor) => editor.chain().focus().toggleTaskList().run(),
51
+ },
52
+ {
53
+ title: "Quote",
54
+ description: "Block quote",
55
+ icon: '"',
56
+ action: (editor) => editor.chain().focus().toggleBlockquote().run(),
57
+ },
58
+ {
59
+ title: "Code block",
60
+ description: "Code snippet",
61
+ icon: "<>",
62
+ action: (editor) => editor.chain().focus().toggleCodeBlock().run(),
63
+ },
64
+ {
65
+ title: "Divider",
66
+ description: "Horizontal rule",
67
+ icon: "-",
68
+ action: (editor) => editor.chain().focus().setHorizontalRule().run(),
69
+ },
70
+ {
71
+ title: "Table",
72
+ description: "Three by three table",
73
+ icon: "tbl",
74
+ action: (editor) => editor
75
+ .chain()
76
+ .focus()
77
+ .insertTable({ rows: 3, cols: 3, withHeaderRow: true })
78
+ .run(),
79
+ },
80
+ ];
81
+ /**
82
+ * Build the `/image` slash command for the shared image block. Requires the
83
+ * editor to mount the shared image extension (`features.image`) and an
84
+ * {@link ImageUploadFn}; the command opens a native file picker and uploads +
85
+ * inserts the chosen image(s). Add it to the list an app passes to
86
+ * {@link SlashCommandMenu} (e.g. `[...DEFAULT_SLASH_COMMANDS, createImageSlashCommand(upload)]`).
87
+ */
88
+ export function createImageSlashCommand(upload) {
89
+ return {
90
+ title: "Image",
91
+ description: "Upload an image",
92
+ icon: "img",
93
+ action: (editor) => pickAndInsertImage(editor.view, upload),
94
+ };
95
+ }
96
+ /**
97
+ * The shared "/" block-insert menu. Detects a `/query` at the caret, filters the
98
+ * provided command list, and renders a fixed-position picker with keyboard
99
+ * navigation. Extracted from the inline plan menu so apps share one
100
+ * implementation and only swap the command list.
101
+ */
102
+ export function SlashCommandMenu({ editor, items = DEFAULT_SLASH_COMMANDS, }) {
103
+ const [isOpen, setIsOpen] = useState(false);
104
+ const [query, setQuery] = useState("");
105
+ const [selectedIndex, setSelectedIndex] = useState(0);
106
+ const [position, setPosition] = useState(null);
107
+ const slashPosRef = useRef(null);
108
+ const filteredCommands = useMemo(() => items.filter((cmd) => cmd.title.toLowerCase().includes(query.toLowerCase()) ||
109
+ cmd.description.toLowerCase().includes(query.toLowerCase())), [items, query]);
110
+ const close = useCallback(() => {
111
+ setIsOpen(false);
112
+ setQuery("");
113
+ slashPosRef.current = null;
114
+ }, []);
115
+ const executeCommand = useCallback((command) => {
116
+ if (slashPosRef.current !== null) {
117
+ const { from } = editor.state.selection;
118
+ editor
119
+ .chain()
120
+ .focus()
121
+ .deleteRange({ from: slashPosRef.current, to: from })
122
+ .run();
123
+ }
124
+ command.action(editor);
125
+ close();
126
+ }, [close, editor]);
127
+ useEffect(() => {
128
+ const handleKeyDown = (event) => {
129
+ if (!isOpen)
130
+ return;
131
+ if (event.key === "ArrowDown") {
132
+ event.preventDefault();
133
+ setSelectedIndex((index) => (index + 1) % filteredCommands.length);
134
+ }
135
+ else if (event.key === "ArrowUp") {
136
+ event.preventDefault();
137
+ setSelectedIndex((index) => (index - 1 + filteredCommands.length) % filteredCommands.length);
138
+ }
139
+ else if (event.key === "Enter") {
140
+ event.preventDefault();
141
+ const command = filteredCommands[selectedIndex];
142
+ if (command)
143
+ executeCommand(command);
144
+ }
145
+ else if (event.key === "Escape") {
146
+ close();
147
+ }
148
+ };
149
+ document.addEventListener("keydown", handleKeyDown, true);
150
+ return () => document.removeEventListener("keydown", handleKeyDown, true);
151
+ }, [close, executeCommand, filteredCommands, isOpen, selectedIndex]);
152
+ useEffect(() => {
153
+ const handleTransaction = () => {
154
+ const { state } = editor;
155
+ const { from } = state.selection;
156
+ const textBefore = state.doc.textBetween(Math.max(0, from - 32), from, "\n");
157
+ const slashMatch = textBefore.match(/\/([a-zA-Z0-9]*)$/);
158
+ if (!slashMatch) {
159
+ if (isOpen)
160
+ close();
161
+ return;
162
+ }
163
+ const slashStart = from - slashMatch[0].length;
164
+ slashPosRef.current = slashStart;
165
+ setQuery(slashMatch[1]);
166
+ setSelectedIndex(0);
167
+ const coords = editor.view.coordsAtPos(from);
168
+ const menuHeight = 320;
169
+ const spaceBelow = window.innerHeight - coords.bottom;
170
+ const flipUp = spaceBelow < menuHeight && coords.top > menuHeight;
171
+ setPosition({
172
+ top: flipUp ? coords.top : coords.bottom + 4,
173
+ left: Math.min(coords.left, window.innerWidth - 250),
174
+ flipUp,
175
+ });
176
+ setIsOpen(true);
177
+ };
178
+ editor.on("transaction", handleTransaction);
179
+ return () => {
180
+ editor.off("transaction", handleTransaction);
181
+ };
182
+ }, [close, editor, isOpen]);
183
+ if (!isOpen || !position || filteredCommands.length === 0)
184
+ return null;
185
+ return (_jsxs("div", { className: "an-rich-md-slash-menu", style: {
186
+ position: "fixed",
187
+ ...(position.flipUp
188
+ ? { bottom: window.innerHeight - position.top + 4 }
189
+ : { top: position.top }),
190
+ left: position.left,
191
+ }, "data-plan-interactive": true, children: [_jsx("div", { className: "an-rich-md-slash-heading", children: "Blocks" }), filteredCommands.map((command, index) => (_jsxs("button", { type: "button", className: cn("an-rich-md-slash-item", index === selectedIndex && "an-rich-md-slash-item--active"), onMouseEnter: () => setSelectedIndex(index), onMouseDown: (event) => event.preventDefault(), onClick: () => executeCommand(command), children: [_jsx("span", { className: "an-rich-md-slash-icon", children: command.icon }), _jsxs("span", { children: [_jsx("span", { className: "an-rich-md-slash-title", children: command.title }), _jsx("span", { className: "an-rich-md-slash-description", children: command.description })] })] }, command.title)))] }));
192
+ }
193
+ //# sourceMappingURL=SlashCommandMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SlashCommandMenu.js","sourceRoot":"","sources":["../../../src/client/rich-markdown-editor/SlashCommandMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,O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CAAC,WAAW,GAAG,QAAQ,CAAC,GAAG,GAAG,CAAC,EAAE;gBACnD,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;YAC1B,IAAI,EAAE,QAAQ,CAAC,IAAI;SACH,4CAIpB,cAAK,SAAS,EAAC,0BAA0B,uBAAa,EACrD,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CACxC,kBAEE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,EAAE,CACX,uBAAuB,EACvB,KAAK,KAAK,aAAa,IAAI,+BAA+B,CAC3D,EACD,YAAY,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAC3C,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,EAC9C,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,aAEtC,eAAM,SAAS,EAAC,uBAAuB,YAAE,OAAO,CAAC,IAAI,GAAQ,EAC7D,2BACE,eAAM,SAAS,EAAC,wBAAwB,YAAE,OAAO,CAAC,KAAK,GAAQ,EAC/D,eAAM,SAAS,EAAC,8BAA8B,YAC3C,OAAO,CAAC,WAAW,GACf,IACF,KAhBF,OAAO,CAAC,KAAK,CAiBX,CACV,CAAC,IACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n} from \"react\";\nimport type { Editor } from \"@tiptap/react\";\nimport { cn } from \"../utils.js\";\nimport { pickAndInsertImage, type ImageUploadFn } from \"./ImageExtension.js\";\n\n/** A single slash-menu block command. Apps can extend the default list. */\nexport interface SlashCommandItem {\n title: string;\n description: string;\n /** Short text glyph shown in the menu (T, H1, tbl, …). */\n icon: string;\n action: (editor: Editor) => void;\n}\n\n/**\n * The default block commands — Plan's current set. Apps pass their own `items`\n * (typically `[...DEFAULT_SLASH_COMMANDS, ...extra]`) to extend it.\n */\nexport const DEFAULT_SLASH_COMMANDS: SlashCommandItem[] = [\n {\n title: \"Text\",\n description: \"Plain text block\",\n icon: \"T\",\n action: (editor) => editor.chain().focus().setParagraph().run(),\n },\n {\n title: \"Heading 1\",\n description: \"Large heading\",\n icon: \"H1\",\n action: (editor) =>\n editor.chain().focus().toggleHeading({ level: 1 }).run(),\n },\n {\n title: \"Heading 2\",\n description: \"Section heading\",\n icon: \"H2\",\n action: (editor) =>\n editor.chain().focus().toggleHeading({ level: 2 }).run(),\n },\n {\n title: \"Heading 3\",\n description: \"Subheading\",\n icon: \"H3\",\n action: (editor) =>\n editor.chain().focus().toggleHeading({ level: 3 }).run(),\n },\n {\n title: \"Bulleted list\",\n description: \"Unordered list\",\n icon: \"-\",\n action: (editor) => editor.chain().focus().toggleBulletList().run(),\n },\n {\n title: \"Numbered list\",\n description: \"Ordered list\",\n icon: \"1.\",\n action: (editor) => editor.chain().focus().toggleOrderedList().run(),\n },\n {\n title: \"To-do list\",\n description: \"Checklist items\",\n icon: \"[]\",\n action: (editor) => editor.chain().focus().toggleTaskList().run(),\n },\n {\n title: \"Quote\",\n description: \"Block quote\",\n icon: '\"',\n action: (editor) => editor.chain().focus().toggleBlockquote().run(),\n },\n {\n title: \"Code block\",\n description: \"Code snippet\",\n icon: \"<>\",\n action: (editor) => editor.chain().focus().toggleCodeBlock().run(),\n },\n {\n title: \"Divider\",\n description: \"Horizontal rule\",\n icon: \"-\",\n action: (editor) => editor.chain().focus().setHorizontalRule().run(),\n },\n {\n title: \"Table\",\n description: \"Three by three table\",\n icon: \"tbl\",\n action: (editor) =>\n editor\n .chain()\n .focus()\n .insertTable({ rows: 3, cols: 3, withHeaderRow: true })\n .run(),\n },\n];\n\n/**\n * Build the `/image` slash command for the shared image block. Requires the\n * editor to mount the shared image extension (`features.image`) and an\n * {@link ImageUploadFn}; the command opens a native file picker and uploads +\n * inserts the chosen image(s). Add it to the list an app passes to\n * {@link SlashCommandMenu} (e.g. `[...DEFAULT_SLASH_COMMANDS, createImageSlashCommand(upload)]`).\n */\nexport function createImageSlashCommand(\n upload: ImageUploadFn,\n): SlashCommandItem {\n return {\n title: \"Image\",\n description: \"Upload an image\",\n icon: \"img\",\n action: (editor) => pickAndInsertImage(editor.view, upload),\n };\n}\n\nexport interface SlashCommandMenuProps {\n editor: Editor;\n /** Block command list. Defaults to {@link DEFAULT_SLASH_COMMANDS}. */\n items?: SlashCommandItem[];\n}\n\n/**\n * The shared \"/\" block-insert menu. Detects a `/query` at the caret, filters the\n * provided command list, and renders a fixed-position picker with keyboard\n * navigation. Extracted from the inline plan menu so apps share one\n * implementation and only swap the command list.\n */\nexport function SlashCommandMenu({\n editor,\n items = DEFAULT_SLASH_COMMANDS,\n}: SlashCommandMenuProps) {\n const [isOpen, setIsOpen] = useState(false);\n const [query, setQuery] = useState(\"\");\n const [selectedIndex, setSelectedIndex] = useState(0);\n const [position, setPosition] = useState<{\n top: number;\n left: number;\n flipUp: boolean;\n } | null>(null);\n const slashPosRef = useRef<number | null>(null);\n\n const filteredCommands = useMemo(\n () =>\n items.filter(\n (cmd) =>\n cmd.title.toLowerCase().includes(query.toLowerCase()) ||\n cmd.description.toLowerCase().includes(query.toLowerCase()),\n ),\n [items, query],\n );\n\n const close = useCallback(() => {\n setIsOpen(false);\n setQuery(\"\");\n slashPosRef.current = null;\n }, []);\n\n const executeCommand = useCallback(\n (command: SlashCommandItem) => {\n if (slashPosRef.current !== null) {\n const { from } = editor.state.selection;\n editor\n .chain()\n .focus()\n .deleteRange({ from: slashPosRef.current, to: from })\n .run();\n }\n command.action(editor);\n close();\n },\n [close, editor],\n );\n\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (!isOpen) return;\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n setSelectedIndex((index) => (index + 1) % filteredCommands.length);\n } else if (event.key === \"ArrowUp\") {\n event.preventDefault();\n setSelectedIndex(\n (index) =>\n (index - 1 + filteredCommands.length) % filteredCommands.length,\n );\n } else if (event.key === \"Enter\") {\n event.preventDefault();\n const command = filteredCommands[selectedIndex];\n if (command) executeCommand(command);\n } else if (event.key === \"Escape\") {\n close();\n }\n };\n document.addEventListener(\"keydown\", handleKeyDown, true);\n return () => document.removeEventListener(\"keydown\", handleKeyDown, true);\n }, [close, executeCommand, filteredCommands, isOpen, selectedIndex]);\n\n useEffect(() => {\n const handleTransaction = () => {\n const { state } = editor;\n const { from } = state.selection;\n const textBefore = state.doc.textBetween(\n Math.max(0, from - 32),\n from,\n \"\\n\",\n );\n const slashMatch = textBefore.match(/\\/([a-zA-Z0-9]*)$/);\n if (!slashMatch) {\n if (isOpen) close();\n return;\n }\n\n const slashStart = from - slashMatch[0].length;\n slashPosRef.current = slashStart;\n setQuery(slashMatch[1]);\n setSelectedIndex(0);\n const coords = editor.view.coordsAtPos(from);\n const menuHeight = 320;\n const spaceBelow = window.innerHeight - coords.bottom;\n const flipUp = spaceBelow < menuHeight && coords.top > menuHeight;\n setPosition({\n top: flipUp ? coords.top : coords.bottom + 4,\n left: Math.min(coords.left, window.innerWidth - 250),\n flipUp,\n });\n setIsOpen(true);\n };\n\n editor.on(\"transaction\", handleTransaction);\n return () => {\n editor.off(\"transaction\", handleTransaction);\n };\n }, [close, editor, isOpen]);\n\n if (!isOpen || !position || filteredCommands.length === 0) return null;\n\n return (\n <div\n className=\"an-rich-md-slash-menu\"\n style={\n {\n position: \"fixed\",\n ...(position.flipUp\n ? { bottom: window.innerHeight - position.top + 4 }\n : { top: position.top }),\n left: position.left,\n } as CSSProperties\n }\n data-plan-interactive\n >\n <div className=\"an-rich-md-slash-heading\">Blocks</div>\n {filteredCommands.map((command, index) => (\n <button\n key={command.title}\n type=\"button\"\n className={cn(\n \"an-rich-md-slash-item\",\n index === selectedIndex && \"an-rich-md-slash-item--active\",\n )}\n onMouseEnter={() => setSelectedIndex(index)}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => executeCommand(command)}\n >\n <span className=\"an-rich-md-slash-icon\">{command.icon}</span>\n <span>\n <span className=\"an-rich-md-slash-title\">{command.title}</span>\n <span className=\"an-rich-md-slash-description\">\n {command.description}\n </span>\n </span>\n </button>\n ))}\n </div>\n );\n}\n"]}
@@ -0,0 +1,166 @@
1
+ import type { Extension, Node, Mark } from "@tiptap/core";
2
+ import type { StarterKitOptions } from "@tiptap/starter-kit";
3
+ import { Markdown } from "tiptap-markdown";
4
+ import type { Doc as YDoc } from "yjs";
5
+ import type { Awareness } from "y-protocols/awareness";
6
+ import { type ImageUploadFn } from "./ImageExtension.js";
7
+ /**
8
+ * Markdown dialect the editor parses/serializes.
9
+ *
10
+ * - `gfm` — GitHub-Flavored Markdown. No raw HTML passthrough. The byte-stable
11
+ * serialization used by Plans (see RichMarkdownEditor.roundtrip.spec.ts).
12
+ * - `nfm` — the Notion-Flavored Markdown superset used by the Content editor,
13
+ * which opts into inline HTML so Notion-specific blocks round-trip.
14
+ */
15
+ export type RichMarkdownDialect = "gfm" | "nfm";
16
+ /**
17
+ * Editor preset. Schema-neutral today (both presets share the base schema),
18
+ * but threaded through so an app can branch schema/behavior per preset without
19
+ * a new factory. The collab/markdown wiring is preset-independent.
20
+ */
21
+ export type RichMarkdownEditorPreset = "plan" | "content";
22
+ /** User info used to label this client's collaborative cursor. */
23
+ export interface RichMarkdownCollabUser {
24
+ name: string;
25
+ color: string;
26
+ email?: string;
27
+ }
28
+ /** Optional collaborative-editing inputs for the shared editor. */
29
+ export interface SharedEditorCollab {
30
+ /**
31
+ * Yjs document for collaborative editing. When present the editor binds the
32
+ * shared {@link Collaboration} (+ {@link CollaborationCaret} when awareness
33
+ * is set) extensions and StarterKit's built-in undo/redo is disabled (Yjs
34
+ * owns history). When absent the editor is a controlled `value`/`onChange`
35
+ * editor.
36
+ */
37
+ ydoc?: YDoc | null;
38
+ /** Shared awareness instance for live multi-user cursors. */
39
+ awareness?: Awareness | null;
40
+ /** Current user info for the collaborative cursor label. */
41
+ user?: RichMarkdownCollabUser | null;
42
+ }
43
+ /** Toggle the optional base extensions on/off per app. All default to `true`. */
44
+ export interface SharedEditorFeatures {
45
+ /** GFM pipe tables (Table + TableRow + TableHeader + TableCell). */
46
+ tables?: boolean;
47
+ /** Task / checklist lists (TaskList + TaskItem). */
48
+ tasks?: boolean;
49
+ /** Inline links (the `Link` mark). When off, links fall back to plain text. */
50
+ link?: boolean;
51
+ /** Fenced code blocks. Disabling lets an app inject its own code-block node. */
52
+ codeBlock?: boolean;
53
+ /**
54
+ * The built-in {@link Placeholder} extension. Default `true`. Apps that need a
55
+ * bespoke placeholder resolver (per-node-type labels, ancestor-aware text)
56
+ * disable this and supply their own Placeholder via `extraExtensions`.
57
+ */
58
+ placeholder?: boolean;
59
+ /**
60
+ * The built-in dialect-keyed {@link Markdown} serializer. Default `true`.
61
+ * Apps with a custom serializer (e.g. Content's NFM converter, which does NOT
62
+ * round-trip through tiptap-markdown's storage) disable this and own the
63
+ * serialize/parse pipeline themselves. The Markdown extension is still added
64
+ * so paste/clipboard transforms work — disable it only when supplying your own
65
+ * Markdown configuration via the {@link CreateSharedEditorExtensionsOptions.markdown}
66
+ * option instead.
67
+ */
68
+ markdown?: boolean;
69
+ /**
70
+ * The shared block-level image node (`@tiptap/extension-image`). Default
71
+ * `false` so existing embedders are unchanged. When `true`, images
72
+ * serialize to GFM `![alt](src)` (source-syncable) and — when an
73
+ * {@link CreateSharedEditorExtensionsOptions.onImageUpload} function is
74
+ * supplied — paste / drop of local image files uploads through it. Content
75
+ * leaves this off and injects its own richer image node via
76
+ * `extraExtensions`, so the two never collide.
77
+ */
78
+ image?: boolean;
79
+ }
80
+ export interface CreateSharedEditorExtensionsOptions {
81
+ /** Markdown dialect; selects the keyed {@link Markdown} config. */
82
+ dialect?: RichMarkdownDialect;
83
+ /** Preset hook (schema-neutral today). */
84
+ preset?: RichMarkdownEditorPreset;
85
+ /** Empty-block placeholder text (headings get their own labels). */
86
+ placeholder?: string;
87
+ /** Toggle individual base extensions. */
88
+ features?: SharedEditorFeatures;
89
+ /**
90
+ * Extra StarterKit options merged over the shared defaults. Lets an app turn
91
+ * off StarterKit nodes it replaces (Content swaps in its own paragraph /
92
+ * blockquote / code block) or pass a custom dropcursor, while still sharing
93
+ * the rest of the StarterKit base + the collab undo/redo gating. The shared
94
+ * defaults (`heading` levels 1-4, `link: false`, the default dropcursor, and
95
+ * `undoRedo: false` in collab mode) are applied first and can be overridden
96
+ * key-by-key here.
97
+ */
98
+ starterKit?: Partial<StarterKitOptions>;
99
+ /**
100
+ * Custom {@link Markdown} configuration. Replaces the dialect-keyed config from
101
+ * {@link MARKDOWN_DIALECT_CONFIG} when provided. Only used when
102
+ * `features.markdown !== false`; apps that own the whole markdown pipeline (no
103
+ * tiptap-markdown serialization at all) should set `features.markdown: false`
104
+ * and add their own configured Markdown extension via `extraExtensions`.
105
+ */
106
+ markdown?: Parameters<typeof Markdown.configure>[0];
107
+ /**
108
+ * App-specific extensions (Notion nodes, media, drag handles, comment
109
+ * anchors, etc.) appended LAST so they bind over the shared base schema and
110
+ * the optional Collaboration extensions still mount after them.
111
+ */
112
+ extraExtensions?: Array<Extension | Node | Mark>;
113
+ /** Optional collaborative-editing wiring. */
114
+ collab?: SharedEditorCollab | null;
115
+ /**
116
+ * Injectable image uploader for the shared image block. Only used when
117
+ * `features.image` is on. Turns a picked / pasted / dropped image File into a
118
+ * hosted `{ src, alt? }`. Plans pass `uploadEditorImage` (the framework
119
+ * `upload-image` action). When omitted, the image block still renders and
120
+ * round-trips `![alt](src)` markdown but cannot ingest local files.
121
+ */
122
+ onImageUpload?: ImageUploadFn | null;
123
+ }
124
+ /**
125
+ * tiptap-markdown configuration, keyed by dialect. This is the single source of
126
+ * truth for how each dialect parses/serializes markdown so the editor component
127
+ * and the round-trip fidelity test can never drift apart.
128
+ *
129
+ * tiptap-markdown re-serializes the whole document on every edit, so the goal
130
+ * for GFM is `serialize(parse(markdown)) === markdown` for the markdown plans
131
+ * actually contain. We deliberately keep tiptap-markdown's own defaults
132
+ * (`bulletListMarker: "-"`, `tightLists: true`, `linkify: false`,
133
+ * `breaks: false`) because those produce the most byte-stable GFM. See
134
+ * RichMarkdownEditor.roundtrip.spec.ts for the pinned corpus.
135
+ *
136
+ * NFM (Content) opts into inline HTML passthrough (`html: true`) so
137
+ * Notion-specific blocks survive a markdown round-trip; the rest mirrors the
138
+ * Content editor's existing `Markdown.configure` call.
139
+ */
140
+ export declare const MARKDOWN_DIALECT_CONFIG: Record<RichMarkdownDialect, Parameters<typeof Markdown.configure>[0]>;
141
+ /**
142
+ * The ONE editor extension factory shared by every embedder (Plans today,
143
+ * Content next). It assembles the base Tiptap schema (StarterKit + Placeholder
144
+ * + Link + tasks + tables + code block), the dialect-keyed {@link Markdown}
145
+ * serializer, the optional Collaboration stack, and finally any app-specific
146
+ * `extraExtensions`.
147
+ *
148
+ * Ordering matters:
149
+ * 1. Base schema (StarterKit first so its nodes/marks register; `starterKit`
150
+ * overrides let an app disable replaced nodes / swap the dropcursor).
151
+ * 2. dialect-keyed Markdown serializer (suppressible via `features.markdown`
152
+ * for apps that own the whole serialize/parse pipeline, e.g. Content's NFM).
153
+ * 3. `extraExtensions` (Notion/media/etc.) — appended before Collaboration so
154
+ * apps can extend the schema and Collaboration still binds over the full
155
+ * schema.
156
+ * 4. Collaboration (+ CollaborationCaret) LAST so they bind over everything.
157
+ *
158
+ * Content (the NFM editor) drives this factory with `features.placeholder` and
159
+ * `features.markdown` off, `features.tasks/tables/link` off where it ships its
160
+ * own, a `starterKit` override disabling paragraph/blockquote/codeBlock, and all
161
+ * Notion/media/fidelity nodes + its own Markdown(NFM)/Placeholder via
162
+ * `extraExtensions` — so it shares the StarterKit base + the collab wiring while
163
+ * owning its byte-identical NFM serializer.
164
+ */
165
+ export declare function createSharedEditorExtensions({ dialect, preset: _preset, placeholder, features, starterKit, markdown, extraExtensions, collab, onImageUpload, }?: CreateSharedEditorExtensionsOptions): Array<Extension | Node | Mark>;
166
+ //# sourceMappingURL=extensions.d.ts.map
@@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AS,GAAG,IAAI,GAAG,IAAI,CAAC,CA2H3E"}
@@ -0,0 +1,222 @@
1
+ import StarterKit from "@tiptap/starter-kit";
2
+ import Placeholder from "@tiptap/extension-placeholder";
3
+ import Link from "@tiptap/extension-link";
4
+ import TaskList from "@tiptap/extension-task-list";
5
+ import TaskItem from "@tiptap/extension-task-item";
6
+ import { Table } from "@tiptap/extension-table";
7
+ import { TableRow } from "@tiptap/extension-table-row";
8
+ import { TableCell } from "@tiptap/extension-table-cell";
9
+ import { TableHeader } from "@tiptap/extension-table-header";
10
+ import { Markdown } from "tiptap-markdown";
11
+ import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight";
12
+ import { createLowlight } from "lowlight";
13
+ import bash from "highlight.js/lib/languages/bash";
14
+ import css from "highlight.js/lib/languages/css";
15
+ import javascript from "highlight.js/lib/languages/javascript";
16
+ import json from "highlight.js/lib/languages/json";
17
+ import markdown from "highlight.js/lib/languages/markdown";
18
+ import python from "highlight.js/lib/languages/python";
19
+ import sql from "highlight.js/lib/languages/sql";
20
+ import typescript from "highlight.js/lib/languages/typescript";
21
+ import xml from "highlight.js/lib/languages/xml";
22
+ import yaml from "highlight.js/lib/languages/yaml";
23
+ import Collaboration from "@tiptap/extension-collaboration";
24
+ import CollaborationCaret from "@tiptap/extension-collaboration-caret";
25
+ /**
26
+ * Shared lowlight instance for the editor's syntax-highlighted code blocks. A
27
+ * curated grammar set (aliases like ts/tsx, js/jsx, html, sh, py, yml, md come
28
+ * for free from each grammar) keeps the editor bundle lean while matching the
29
+ * languages the read-side Shiki surfaces (`code-tabs`) support. highlight.js is
30
+ * synchronous, which is what a live ProseMirror editor needs — Shiki is async
31
+ * and only used for read-only render paths.
32
+ */
33
+ const codeLowlight = createLowlight({
34
+ bash,
35
+ css,
36
+ javascript,
37
+ json,
38
+ markdown,
39
+ python,
40
+ sql,
41
+ typescript,
42
+ xml,
43
+ yaml,
44
+ });
45
+ import { createImageExtension } from "./ImageExtension.js";
46
+ /**
47
+ * tiptap-markdown configuration, keyed by dialect. This is the single source of
48
+ * truth for how each dialect parses/serializes markdown so the editor component
49
+ * and the round-trip fidelity test can never drift apart.
50
+ *
51
+ * tiptap-markdown re-serializes the whole document on every edit, so the goal
52
+ * for GFM is `serialize(parse(markdown)) === markdown` for the markdown plans
53
+ * actually contain. We deliberately keep tiptap-markdown's own defaults
54
+ * (`bulletListMarker: "-"`, `tightLists: true`, `linkify: false`,
55
+ * `breaks: false`) because those produce the most byte-stable GFM. See
56
+ * RichMarkdownEditor.roundtrip.spec.ts for the pinned corpus.
57
+ *
58
+ * NFM (Content) opts into inline HTML passthrough (`html: true`) so
59
+ * Notion-specific blocks survive a markdown round-trip; the rest mirrors the
60
+ * Content editor's existing `Markdown.configure` call.
61
+ */
62
+ export const MARKDOWN_DIALECT_CONFIG = {
63
+ gfm: {
64
+ // GFM plans are the common case and must never gain raw HTML as a second
65
+ // representation.
66
+ html: false,
67
+ // Keep tiptap-markdown's defaults that minimise first-edit normalisation
68
+ // churn (see roundtrip spec). Listed explicitly so the contract is
69
+ // self-documenting rather than relying on the package defaults.
70
+ bulletListMarker: "-",
71
+ tightLists: true,
72
+ linkify: false,
73
+ breaks: false,
74
+ transformPastedText: true,
75
+ transformCopiedText: true,
76
+ },
77
+ nfm: {
78
+ // NFM is a superset that allows inline HTML so Notion blocks round-trip.
79
+ html: true,
80
+ transformPastedText: true,
81
+ transformCopiedText: true,
82
+ },
83
+ };
84
+ const DEFAULT_FEATURES = {
85
+ tables: true,
86
+ tasks: true,
87
+ link: true,
88
+ codeBlock: true,
89
+ placeholder: true,
90
+ markdown: true,
91
+ // Off by default: only Plans opt in today. Content injects its own richer
92
+ // image node via `extraExtensions` and must not get a second `image` node.
93
+ image: false,
94
+ };
95
+ /**
96
+ * The ONE editor extension factory shared by every embedder (Plans today,
97
+ * Content next). It assembles the base Tiptap schema (StarterKit + Placeholder
98
+ * + Link + tasks + tables + code block), the dialect-keyed {@link Markdown}
99
+ * serializer, the optional Collaboration stack, and finally any app-specific
100
+ * `extraExtensions`.
101
+ *
102
+ * Ordering matters:
103
+ * 1. Base schema (StarterKit first so its nodes/marks register; `starterKit`
104
+ * overrides let an app disable replaced nodes / swap the dropcursor).
105
+ * 2. dialect-keyed Markdown serializer (suppressible via `features.markdown`
106
+ * for apps that own the whole serialize/parse pipeline, e.g. Content's NFM).
107
+ * 3. `extraExtensions` (Notion/media/etc.) — appended before Collaboration so
108
+ * apps can extend the schema and Collaboration still binds over the full
109
+ * schema.
110
+ * 4. Collaboration (+ CollaborationCaret) LAST so they bind over everything.
111
+ *
112
+ * Content (the NFM editor) drives this factory with `features.placeholder` and
113
+ * `features.markdown` off, `features.tasks/tables/link` off where it ships its
114
+ * own, a `starterKit` override disabling paragraph/blockquote/codeBlock, and all
115
+ * Notion/media/fidelity nodes + its own Markdown(NFM)/Placeholder via
116
+ * `extraExtensions` — so it shares the StarterKit base + the collab wiring while
117
+ * owning its byte-identical NFM serializer.
118
+ */
119
+ export function createSharedEditorExtensions({ dialect = "gfm",
120
+ // `preset` is accepted and forwarded for future preset-specific schema
121
+ // branches; it is currently schema-neutral.
122
+ preset: _preset = "plan", placeholder = "Type '/' for commands...", features, starterKit, markdown, extraExtensions = [], collab = null, onImageUpload = null, } = {}) {
123
+ const feat = { ...DEFAULT_FEATURES, ...(features ?? {}) };
124
+ const ydoc = collab?.ydoc ?? null;
125
+ const awareness = collab?.awareness ?? null;
126
+ const user = collab?.user ?? null;
127
+ const exts = [
128
+ StarterKit.configure({
129
+ heading: { levels: [1, 2, 3, 4] },
130
+ link: false,
131
+ // StarterKit's plain code block is always disabled; when enabled we add the
132
+ // syntax-highlighting `CodeBlockLowlight` (same `codeBlock` node) below.
133
+ codeBlock: false,
134
+ dropcursor: { color: "hsl(var(--ring))", width: 2 },
135
+ // Yjs owns undo/redo when Collaboration is active; the StarterKit history
136
+ // plugin and the CRDT cannot both track undo without corrupting state.
137
+ ...(ydoc ? { undoRedo: false } : {}),
138
+ // App overrides last so embedders can disable replaced nodes (paragraph,
139
+ // blockquote, code block) or swap the dropcursor while keeping the shared
140
+ // base + the collab undo/redo gating above.
141
+ ...(starterKit ?? {}),
142
+ }),
143
+ ];
144
+ // Syntax-highlighted code block (replaces StarterKit's plain one) only when the
145
+ // embedder opts in via `features.codeBlock`. Content disables it and ships its
146
+ // own code node, so this affects Plans (and future opt-in apps) alone.
147
+ if (feat.codeBlock) {
148
+ exts.push(CodeBlockLowlight.configure({
149
+ lowlight: codeLowlight,
150
+ defaultLanguage: null,
151
+ }));
152
+ }
153
+ if (feat.placeholder) {
154
+ exts.push(Placeholder.configure({
155
+ placeholder: ({ node }) => {
156
+ if (node.type.name === "heading") {
157
+ const level = node.attrs.level;
158
+ if (level === 1)
159
+ return "Heading 1";
160
+ if (level === 2)
161
+ return "Heading 2";
162
+ if (level === 3)
163
+ return "Heading 3";
164
+ return "Heading 4";
165
+ }
166
+ return placeholder;
167
+ },
168
+ showOnlyWhenEditable: true,
169
+ showOnlyCurrent: true,
170
+ }));
171
+ }
172
+ if (feat.link) {
173
+ exts.push(Link.configure({
174
+ openOnClick: false,
175
+ HTMLAttributes: { class: "an-rich-md-link" },
176
+ }));
177
+ }
178
+ if (feat.tasks) {
179
+ exts.push(TaskList.configure({
180
+ HTMLAttributes: { class: "an-rich-md-task-list" },
181
+ }), TaskItem.configure({ nested: true }));
182
+ }
183
+ if (feat.tables) {
184
+ exts.push(Table.configure({
185
+ resizable: false,
186
+ HTMLAttributes: { class: "an-rich-md-table" },
187
+ }), TableRow, TableHeader, TableCell);
188
+ }
189
+ if (feat.markdown) {
190
+ exts.push(Markdown.configure(markdown ?? MARKDOWN_DIALECT_CONFIG[dialect]));
191
+ }
192
+ // Shared block-level image node. The node is named `image`, so when
193
+ // `features.markdown` is on, tiptap-markdown serializes it through its
194
+ // built-in `defaultMarkdownSerializer.nodes.image` fallback → `![alt](src)`
195
+ // (no width-as-HTML override here, so GFM stays byte-stable and
196
+ // source-syncable). With an `onImageUpload` it accepts paste/drop uploads.
197
+ if (feat.image) {
198
+ exts.push(createImageExtension({ onImageUpload }));
199
+ }
200
+ // App-specific extensions (Notion/media/drag handles/comments). Appended
201
+ // before Collaboration so they can extend the schema and Collaboration binds
202
+ // over the full set.
203
+ if (extraExtensions.length > 0) {
204
+ exts.push(...extraExtensions);
205
+ }
206
+ // Collaborative editing via the shared Y.Doc. Markdown stays the canonical
207
+ // saved representation (onChange serializes it); the Y.Doc is transient live
208
+ // state only. Appended last so it binds over the configured schema above.
209
+ if (ydoc) {
210
+ exts.push(Collaboration.configure({ document: ydoc }));
211
+ // Live multi-user cursors. Only mounted alongside a Y.Doc so the standalone
212
+ // controlled editor (today's plan/content behavior) is untouched.
213
+ if (awareness) {
214
+ exts.push(CollaborationCaret.configure({
215
+ provider: { awareness },
216
+ user: user ?? { name: "Anonymous", color: "#999" },
217
+ }));
218
+ }
219
+ }
220
+ return exts;
221
+ }
222
+ //# sourceMappingURL=extensions.js.map