@agent-native/core 0.37.3 → 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 -4
  24. package/dist/cli/skills.d.ts.map +1 -1
  25. package/dist/cli/skills.js +851 -275
  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
@@ -19,11 +19,33 @@
19
19
  *
20
20
  * Result is cached in module scope so it's only computed once per cold start.
21
21
  */
22
+ export const DEFAULT_SKILL_SCOPE = "both";
22
23
  const EMPTY = { agentsMd: "", workspaceAgentsMd: "", skills: {} };
23
24
  let cached = null;
25
+ /**
26
+ * Coerce a raw frontmatter `scope` value into a known `SkillScope`. Unknown,
27
+ * empty, or malformed values fall back to the default (`both`) so a typo never
28
+ * silently hides a skill from the runtime agent. Optionally warns once per
29
+ * distinct bad value to aid debugging without spamming logs.
30
+ */
31
+ const warnedBadScopes = new Set();
32
+ export function normalizeSkillScope(raw) {
33
+ if (!raw)
34
+ return DEFAULT_SKILL_SCOPE;
35
+ const value = raw.trim().toLowerCase();
36
+ if (value === "runtime" || value === "dev" || value === "both") {
37
+ return value;
38
+ }
39
+ if (value && !warnedBadScopes.has(value)) {
40
+ warnedBadScopes.add(value);
41
+ console.warn(`[agents-bundle] Unknown skill scope "${raw}" — treating as "${DEFAULT_SKILL_SCOPE}". Valid values: runtime, dev, both.`);
42
+ }
43
+ return DEFAULT_SKILL_SCOPE;
44
+ }
24
45
  /**
25
46
  * Parse the YAML frontmatter at the top of a skill file.
26
- * Only pulls out `name` and `description` — deliberately simple, no YAML lib.
47
+ * Only pulls out `name`, `description`, and `scope` — deliberately simple, no
48
+ * YAML lib.
27
49
  * Handles:
28
50
  * - Inline: `description: Some text`
29
51
  * - Folded scalar: `description: >-\n multi\n line` → "multi line"
@@ -76,6 +98,8 @@ export function parseSkillFrontmatter(content) {
76
98
  result.name = value;
77
99
  else if (key === "description" && value)
78
100
  result.description = value;
101
+ else if (key === "scope" && value)
102
+ result.scope = normalizeSkillScope(value);
79
103
  }
80
104
  return result;
81
105
  }
@@ -134,7 +158,11 @@ function readSkillsDir(skillsDir, rootForRelative, out, skipExistingNames) {
134
158
  catch { }
135
159
  extraFiles.sort();
136
160
  out[name] = {
137
- meta: { name, description: meta.description ?? "" },
161
+ meta: {
162
+ name,
163
+ description: meta.description ?? "",
164
+ scope: meta.scope ?? DEFAULT_SKILL_SCOPE,
165
+ },
138
166
  content,
139
167
  dir: path.relative(rootForRelative, skillDirAbs).replace(/\\/g, "/"),
140
168
  extraFiles,
@@ -255,8 +283,18 @@ export async function loadAgentsBundle() {
255
283
  * no bash; templates that need skill content at runtime should inline the
256
284
  * critical parts directly in `AGENTS.md`.
257
285
  */
286
+ /**
287
+ * Skills visible to the agent-native RUNTIME agent. Excludes `scope: dev`
288
+ * skills (those are for the human's coding agent only). Skills with no scope,
289
+ * `scope: runtime`, or `scope: both` are all included. Use this anywhere the
290
+ * runtime agent's view of skills is built (prompt block + docs-search) so a
291
+ * dev-scoped skill is invisible to the runtime agent everywhere.
292
+ */
293
+ export function getRuntimeSkills(bundle) {
294
+ return Object.values(bundle.skills).filter((skill) => skill.meta.scope !== "dev");
295
+ }
258
296
  export function generateSkillsPromptBlock(bundle) {
259
- const entries = Object.values(bundle.skills);
297
+ const entries = getRuntimeSkills(bundle);
260
298
  if (entries.length === 0)
261
299
  return "";
262
300
  const lines = entries.map((s) => {
@@ -1 +1 @@
1
- {"version":3,"file":"agents-bundle.js","sourceRoot":"","sources":["../../src/server/agents-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA8CH,MAAM,KAAK,GAAiB,EAAE,QAAQ,EAAE,EAAE,EAAE,iBAAiB,EAAE,EA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AO,MAAM,CAAC;IAChB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAoB;IAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEpC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC9B,MAAM,MAAM,GACV,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;YACrB,CAAC,CAAC,oBAAoB,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YAChD,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,IAAI,CAAC,WAAW,IAAI,kBAAkB,GAAG,MAAM,EAAE,CAAC;IACxG,CAAC,CAAC,CAAC;IAEH,OAAO;;;;;;;;EAQP,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;UACR,CAAC;AACX,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,wBAAwB;IACtC,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Agents bundle — loads AGENTS.md and .agents/skills/ from the template.\n * The legacy singular .agent/skills/ directory is also accepted as an alias.\n *\n * This is the single source of truth the framework's agent uses to mirror what\n * Claude Code / Codex / any other agent would see when running locally in the\n * repo. The filesystem is the canonical source; this module is just a loader\n * that works both in dev (direct fs read) and production (content bundled at\n * build time via the `virtual:agents-bundle` Vite plugin).\n *\n * Resolution order inside `loadAgentsBundle()`:\n * 1. Virtual module (`virtual:agents-bundle`) — inlined at build time by the\n * framework's Vite plugin. This is the ONLY path that works on edge\n * runtimes (Cloudflare Workers) where `readFileSync` doesn't exist.\n * 2. Filesystem fallback — `process.cwd()/AGENTS.md` +\n * `process.cwd()/.agents/skills/` (or legacy `.agent/skills/`). Only reliable in local dev and Node\n * production (`agent-native start`); not on Netlify/Vercel/CF at runtime.\n * 3. Empty bundle — everything silently returns empty strings.\n *\n * Result is cached in module scope so it's only computed once per cold start.\n */\n\nexport interface SkillMeta {\n name: string;\n description: string;\n}\n\nexport interface Skill {\n meta: SkillMeta;\n /** Contents of SKILL.md (the entry file of the skill). */\n content: string;\n /**\n * Filesystem path to the skill directory, relative to the template root\n * (e.g. `.agents/skills/create-deck`). The agent can read any file here via\n * bash in dev — skills are folders, not single files, and may contain\n * supporting assets, scripts, or additional markdown.\n */\n dir: string;\n /**\n * Files inside the skill directory (relative to the skill dir), excluding\n * `SKILL.md`. Lets the agent know what else is available without a separate\n * `ls` call. Empty array if the skill is single-file.\n */\n extraFiles: string[];\n}\n\nexport interface AgentsBundle {\n /** Contents of the template's AGENTS.md (empty string if missing). */\n agentsMd: string;\n /**\n * Contents of the workspace core's AGENTS.md, if the app is inside an\n * enterprise monorepo with a `workspaceCore` configured. Empty string\n * otherwise. Sits between the framework system prompt and the template's\n * AGENTS.md in the instruction stack.\n */\n workspaceAgentsMd?: string;\n /**\n * Map from skill name → skill content. Contains skills merged from the\n * workspace core layer (if present) and the template layer. On name\n * collision, the template's version wins so apps can override a shared\n * enterprise skill by dropping a same-named file under\n * `.agents/skills/<name>/`.\n */\n skills: Record<string, Skill>;\n}\n\nconst EMPTY: AgentsBundle = { agentsMd: \"\", workspaceAgentsMd: \"\", skills: {} };\n\nlet cached: AgentsBundle | null = null;\n\n/**\n * Parse the YAML frontmatter at the top of a skill file.\n * Only pulls out `name` and `description` — deliberately simple, no YAML lib.\n * Handles:\n * - Inline: `description: Some text`\n * - Folded scalar: `description: >-\\n multi\\n line` → \"multi line\"\n * - Literal scalar: `description: |\\n multi\\n line` → \"multi\\nline\"\n */\nexport function parseSkillFrontmatter(content: string): Partial<SkillMeta> {\n const match = content.match(/^---\\r?\\n([\\s\\S]+?)\\r?\\n---/);\n if (!match) return {};\n const lines = match[1].split(/\\r?\\n/);\n const result: Partial<SkillMeta> = {};\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n const keyMatch = line.match(/^([a-zA-Z_][a-zA-Z0-9_-]*):\\s*(.*)$/);\n if (!keyMatch) continue;\n const [, key, valueRaw] = keyMatch;\n const trimmed = valueRaw.trim();\n\n const isFolded = trimmed === \">\" || trimmed === \">-\";\n const isLiteral = trimmed === \"|\" || trimmed === \"|-\";\n\n let value: string;\n if (isFolded || isLiteral) {\n // Collect subsequent indented lines (at least one leading space).\n const block: string[] = [];\n let j = i + 1;\n while (j < lines.length) {\n const next = lines[j];\n if (next.length === 0) {\n block.push(\"\");\n j++;\n continue;\n }\n if (!/^\\s/.test(next)) break;\n block.push(next.replace(/^\\s+/, \"\"));\n j++;\n }\n // Trim trailing blank lines\n while (block.length > 0 && block[block.length - 1] === \"\") block.pop();\n value = isFolded\n ? block.filter((l) => l !== \"\").join(\" \")\n : block.join(\"\\n\");\n i = j - 1;\n } else {\n value = trimmed;\n }\n\n if (key === \"name\" && value) result.name = value;\n else if (key === \"description\" && value) result.description = value;\n }\n\n return result;\n}\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nconst TEMPLATE_SKILLS_DIRS = [\n path.join(\".agents\", \"skills\"),\n path.join(\".agent\", \"skills\"),\n] as const;\n\n/**\n * Paths to a workspace-core's agent resources, for merging into a template's\n * bundle. All fields optional — pass null for any missing piece.\n */\nexport interface WorkspaceAgentsSource {\n /** Absolute path to the workspace core's skills/ directory. */\n skillsDir: string | null;\n /** Absolute path to the workspace core's AGENTS.md. */\n agentsMdPath: string | null;\n /** Root dir (used to compute `dir` paths for workspace-core skills). */\n rootDir: string;\n}\n\n/**\n * Read one skills directory into a `Record<string, Skill>`. Extracted so\n * both the template and workspace-core paths can reuse it. `dirPrefix` is\n * the display path that will be reported to the agent (e.g.\n * `.agents/skills/<name>` for templates, or\n * `<workspace-shared-package>/.agents/skills/<name>` for the workspace layer).\n */\nfunction readSkillsDir(\n skillsDir: string,\n rootForRelative: string,\n out: Record<string, Skill>,\n skipExistingNames: boolean,\n): void {\n if (!fs.existsSync(skillsDir)) return;\n const entries = fs.readdirSync(skillsDir, { withFileTypes: true });\n for (const entry of entries) {\n if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;\n const skillDirAbs = path.join(skillsDir, entry.name);\n const skillFile = path.join(skillDirAbs, \"SKILL.md\");\n try {\n const realSkillFile = fs.realpathSync(skillFile);\n if (!fs.existsSync(realSkillFile)) continue;\n const content = fs.readFileSync(realSkillFile, \"utf-8\");\n const meta = parseSkillFrontmatter(content);\n const name = meta.name ?? entry.name;\n if (skipExistingNames && out[name]) continue; // Template wins\n\n const extraFiles: string[] = [];\n try {\n const walk = (subdir: string, prefix: string) => {\n for (const e of fs.readdirSync(subdir, { withFileTypes: true })) {\n const abs = path.join(subdir, e.name);\n const rel = prefix ? `${prefix}/${e.name}` : e.name;\n if (e.isDirectory() || e.isSymbolicLink()) {\n try {\n const stat = fs.statSync(abs);\n if (stat.isDirectory()) walk(abs, rel);\n } catch {}\n } else if (e.isFile() && e.name !== \"SKILL.md\") {\n extraFiles.push(rel);\n }\n }\n };\n walk(skillDirAbs, \"\");\n } catch {}\n extraFiles.sort();\n\n out[name] = {\n meta: { name, description: meta.description ?? \"\" },\n content,\n dir: path.relative(rootForRelative, skillDirAbs).replace(/\\\\/g, \"/\"),\n extraFiles,\n };\n } catch {\n // Skip unreadable skills\n }\n }\n}\n\n/**\n * Read AGENTS.md + all skills directly from the filesystem rooted at `cwd`.\n * Optionally also reads a workspace-core's AGENTS.md and skills directory\n * and merges them in (template wins on name collisions). Used by both the\n * Vite plugin (at build time) and the runtime fallback (in dev / Node prod).\n *\n * Synchronous — the Vite plugin's load hook calls it inline during the build.\n */\nexport function readAgentsBundleFromFs(\n cwd: string,\n workspaceSource: WorkspaceAgentsSource | null = null,\n): AgentsBundle {\n let agentsMd = \"\";\n try {\n const agentsMdPath = path.join(cwd, \"AGENTS.md\");\n if (fs.existsSync(agentsMdPath)) {\n agentsMd = fs.readFileSync(agentsMdPath, \"utf-8\");\n }\n } catch {}\n\n let workspaceAgentsMd = \"\";\n if (workspaceSource?.agentsMdPath) {\n try {\n if (fs.existsSync(workspaceSource.agentsMdPath)) {\n workspaceAgentsMd = fs.readFileSync(\n workspaceSource.agentsMdPath,\n \"utf-8\",\n );\n }\n } catch {}\n }\n\n // Merge skills: template first (so its entries are authoritative), then\n // workspace-core with skipExistingNames=true so same-named skills don't\n // overwrite the template's. `.agents/skills` is canonical; `.agent/skills`\n // is accepted as a legacy alias and does not override canonical skills.\n const skills: Record<string, Skill> = {};\n for (const [index, relSkillsDir] of TEMPLATE_SKILLS_DIRS.entries()) {\n try {\n readSkillsDir(path.join(cwd, relSkillsDir), cwd, skills, index > 0);\n } catch {}\n }\n\n if (workspaceSource?.skillsDir) {\n try {\n readSkillsDir(\n workspaceSource.skillsDir,\n workspaceSource.rootDir,\n skills,\n true,\n );\n } catch {}\n }\n\n return { agentsMd, workspaceAgentsMd, skills };\n}\n\n/**\n * Load the agents bundle. Returns a cached result on subsequent calls.\n * Tries the virtual module first (works everywhere, including edge), then\n * falls back to filesystem reads from `process.cwd()` — which, when a\n * workspace core is present, also merges in the workspace core's skills\n * and AGENTS.md.\n */\nexport async function loadAgentsBundle(): Promise<AgentsBundle> {\n if (cached) return cached;\n\n // 1. Try the Vite-emitted virtual module. This is the path that works on\n // every deployment target because the content is inlined at build time.\n // The Vite plugin itself is responsible for merging workspace-core\n // content into the bundle it emits.\n try {\n // @ts-expect-error — virtual module is resolved at build time by our\n // Vite plugin; nothing exists at this path on disk.\n const mod = await import(\"virtual:agents-bundle\");\n if (mod && mod.default) {\n cached = mod.default as AgentsBundle;\n return cached;\n }\n } catch {\n // Virtual module not available — fall through to filesystem.\n }\n\n // 2. Filesystem fallback — works in dev / Node prod. If a workspace core\n // is present in the ancestor chain, merge its skills + AGENTS.md in.\n try {\n let workspaceSource: WorkspaceAgentsSource | null = null;\n try {\n const { getWorkspaceCoreExports } =\n await import(\"../deploy/workspace-core.js\");\n const ws = await getWorkspaceCoreExports(process.cwd());\n if (ws) {\n workspaceSource = {\n skillsDir: ws.skillsDir,\n agentsMdPath: ws.agentsMdPath,\n rootDir: ws.packageDir,\n };\n }\n } catch {\n // workspace-core discovery isn't available (e.g. edge runtime).\n }\n cached = readAgentsBundleFromFs(process.cwd(), workspaceSource);\n return cached;\n } catch {\n cached = EMPTY;\n return cached;\n }\n}\n\n/**\n * Generate the `<skills>` block to inject into the system prompt.\n *\n * Skills are folders at `.agents/skills/<name>/` (or legacy\n * `.agent/skills/<name>/`) containing a `SKILL.md` entry file plus any number\n * of supporting files (additional markdown, examples, images, scripts). This\n * block lists what's available and how to read them.\n *\n * In dev mode the agent has bash access and reads skills via `cat` — exactly\n * like running `claude` locally in the repo. In production mode the agent has\n * no bash; templates that need skill content at runtime should inline the\n * critical parts directly in `AGENTS.md`.\n */\nexport function generateSkillsPromptBlock(bundle: AgentsBundle): string {\n const entries = Object.values(bundle.skills);\n if (entries.length === 0) return \"\";\n\n const lines = entries.map((s) => {\n const extras =\n s.extraFiles.length > 0\n ? ` (also contains: ${s.extraFiles.join(\", \")})`\n : \"\";\n return `- \\`${s.meta.name}\\` at \\`${s.dir}/\\` — ${s.meta.description || \"(no description)\"}${extras}`;\n });\n\n return `<skills>\nThe following skills live in the repo, usually at \\`.agents/skills/<name>/\\` (legacy \\`.agent/skills/<name>/\\` is also supported). Each skill is a folder containing a \\`SKILL.md\\` entry file and sometimes supporting files. Read a skill BEFORE starting a task it applies to.\n\nTo read a skill in dev mode (when you have bash access):\n \\`bash(command=\"cat <skill-dir>/SKILL.md\")\\`\n \\`bash(command=\"ls <skill-dir>/\")\\` to see all files in the folder\n\nAvailable skills:\n${lines.join(\"\\n\")}\n</skills>`;\n}\n\n/** For tests — reset the module cache. */\nexport function __resetAgentsBundleCache(): void {\n cached = null;\n}\n"]}
1
+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AC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,KAAK,CACtC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAoB;IAC5D,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEpC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC9B,MAAM,MAAM,GACV,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;YACrB,CAAC,CAAC,oBAAoB,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YAChD,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,IAAI,CAAC,WAAW,IAAI,kBAAkB,GAAG,MAAM,EAAE,CAAC;IACxG,CAAC,CAAC,CAAC;IAEH,OAAO;;;;;;;;EAQP,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;UACR,CAAC;AACX,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,wBAAwB;IACtC,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Agents bundle — loads AGENTS.md and .agents/skills/ from the template.\n * The legacy singular .agent/skills/ directory is also accepted as an alias.\n *\n * This is the single source of truth the framework's agent uses to mirror what\n * Claude Code / Codex / any other agent would see when running locally in the\n * repo. The filesystem is the canonical source; this module is just a loader\n * that works both in dev (direct fs read) and production (content bundled at\n * build time via the `virtual:agents-bundle` Vite plugin).\n *\n * Resolution order inside `loadAgentsBundle()`:\n * 1. Virtual module (`virtual:agents-bundle`) — inlined at build time by the\n * framework's Vite plugin. This is the ONLY path that works on edge\n * runtimes (Cloudflare Workers) where `readFileSync` doesn't exist.\n * 2. Filesystem fallback — `process.cwd()/AGENTS.md` +\n * `process.cwd()/.agents/skills/` (or legacy `.agent/skills/`). Only reliable in local dev and Node\n * production (`agent-native start`); not on Netlify/Vercel/CF at runtime.\n * 3. Empty bundle — everything silently returns empty strings.\n *\n * Result is cached in module scope so it's only computed once per cold start.\n */\n\n/**\n * Where a skill is meant to be used:\n * - `runtime` — only the in-app agent at runtime (not the human's coding agent).\n * - `dev` — only the human's development/coding agent (e.g. Claude Code).\n * EXCLUDED from the runtime agent's prompt block and docs-search.\n * - `both` — loaded everywhere. This is the default when `scope` is absent\n * or set to an unrecognized value (fully backward compatible).\n */\nexport type SkillScope = \"runtime\" | \"dev\" | \"both\";\n\nexport const DEFAULT_SKILL_SCOPE: SkillScope = \"both\";\n\nexport interface SkillMeta {\n name: string;\n description: string;\n /**\n * Audience for the skill. Defaults to `both` when the SKILL.md frontmatter\n * omits `scope` or specifies an unknown value. `dev`-scoped skills are hidden\n * from the runtime agent everywhere (prompt block + docs-search).\n */\n scope: SkillScope;\n}\n\nexport interface Skill {\n meta: SkillMeta;\n /** Contents of SKILL.md (the entry file of the skill). */\n content: string;\n /**\n * Filesystem path to the skill directory, relative to the template root\n * (e.g. `.agents/skills/create-deck`). The agent can read any file here via\n * bash in dev — skills are folders, not single files, and may contain\n * supporting assets, scripts, or additional markdown.\n */\n dir: string;\n /**\n * Files inside the skill directory (relative to the skill dir), excluding\n * `SKILL.md`. Lets the agent know what else is available without a separate\n * `ls` call. Empty array if the skill is single-file.\n */\n extraFiles: string[];\n}\n\nexport interface AgentsBundle {\n /** Contents of the template's AGENTS.md (empty string if missing). */\n agentsMd: string;\n /**\n * Contents of the workspace core's AGENTS.md, if the app is inside an\n * enterprise monorepo with a `workspaceCore` configured. Empty string\n * otherwise. Sits between the framework system prompt and the template's\n * AGENTS.md in the instruction stack.\n */\n workspaceAgentsMd?: string;\n /**\n * Map from skill name → skill content. Contains skills merged from the\n * workspace core layer (if present) and the template layer. On name\n * collision, the template's version wins so apps can override a shared\n * enterprise skill by dropping a same-named file under\n * `.agents/skills/<name>/`.\n */\n skills: Record<string, Skill>;\n}\n\nconst EMPTY: AgentsBundle = { agentsMd: \"\", workspaceAgentsMd: \"\", skills: {} };\n\nlet cached: AgentsBundle | null = null;\n\n/**\n * Coerce a raw frontmatter `scope` value into a known `SkillScope`. Unknown,\n * empty, or malformed values fall back to the default (`both`) so a typo never\n * silently hides a skill from the runtime agent. Optionally warns once per\n * distinct bad value to aid debugging without spamming logs.\n */\nconst warnedBadScopes = new Set<string>();\nexport function normalizeSkillScope(raw: string | undefined): SkillScope {\n if (!raw) return DEFAULT_SKILL_SCOPE;\n const value = raw.trim().toLowerCase();\n if (value === \"runtime\" || value === \"dev\" || value === \"both\") {\n return value;\n }\n if (value && !warnedBadScopes.has(value)) {\n warnedBadScopes.add(value);\n console.warn(\n `[agents-bundle] Unknown skill scope \"${raw}\" — treating as \"${DEFAULT_SKILL_SCOPE}\". Valid values: runtime, dev, both.`,\n );\n }\n return DEFAULT_SKILL_SCOPE;\n}\n\n/**\n * Parse the YAML frontmatter at the top of a skill file.\n * Only pulls out `name`, `description`, and `scope` — deliberately simple, no\n * YAML lib.\n * Handles:\n * - Inline: `description: Some text`\n * - Folded scalar: `description: >-\\n multi\\n line` → \"multi line\"\n * - Literal scalar: `description: |\\n multi\\n line` → \"multi\\nline\"\n */\nexport function parseSkillFrontmatter(content: string): Partial<SkillMeta> {\n const match = content.match(/^---\\r?\\n([\\s\\S]+?)\\r?\\n---/);\n if (!match) return {};\n const lines = match[1].split(/\\r?\\n/);\n const result: Partial<SkillMeta> = {};\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n const keyMatch = line.match(/^([a-zA-Z_][a-zA-Z0-9_-]*):\\s*(.*)$/);\n if (!keyMatch) continue;\n const [, key, valueRaw] = keyMatch;\n const trimmed = valueRaw.trim();\n\n const isFolded = trimmed === \">\" || trimmed === \">-\";\n const isLiteral = trimmed === \"|\" || trimmed === \"|-\";\n\n let value: string;\n if (isFolded || isLiteral) {\n // Collect subsequent indented lines (at least one leading space).\n const block: string[] = [];\n let j = i + 1;\n while (j < lines.length) {\n const next = lines[j];\n if (next.length === 0) {\n block.push(\"\");\n j++;\n continue;\n }\n if (!/^\\s/.test(next)) break;\n block.push(next.replace(/^\\s+/, \"\"));\n j++;\n }\n // Trim trailing blank lines\n while (block.length > 0 && block[block.length - 1] === \"\") block.pop();\n value = isFolded\n ? block.filter((l) => l !== \"\").join(\" \")\n : block.join(\"\\n\");\n i = j - 1;\n } else {\n value = trimmed;\n }\n\n if (key === \"name\" && value) result.name = value;\n else if (key === \"description\" && value) result.description = value;\n else if (key === \"scope\" && value)\n result.scope = normalizeSkillScope(value);\n }\n\n return result;\n}\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nconst TEMPLATE_SKILLS_DIRS = [\n path.join(\".agents\", \"skills\"),\n path.join(\".agent\", \"skills\"),\n] as const;\n\n/**\n * Paths to a workspace-core's agent resources, for merging into a template's\n * bundle. All fields optional — pass null for any missing piece.\n */\nexport interface WorkspaceAgentsSource {\n /** Absolute path to the workspace core's skills/ directory. */\n skillsDir: string | null;\n /** Absolute path to the workspace core's AGENTS.md. */\n agentsMdPath: string | null;\n /** Root dir (used to compute `dir` paths for workspace-core skills). */\n rootDir: string;\n}\n\n/**\n * Read one skills directory into a `Record<string, Skill>`. Extracted so\n * both the template and workspace-core paths can reuse it. `dirPrefix` is\n * the display path that will be reported to the agent (e.g.\n * `.agents/skills/<name>` for templates, or\n * `<workspace-shared-package>/.agents/skills/<name>` for the workspace layer).\n */\nfunction readSkillsDir(\n skillsDir: string,\n rootForRelative: string,\n out: Record<string, Skill>,\n skipExistingNames: boolean,\n): void {\n if (!fs.existsSync(skillsDir)) return;\n const entries = fs.readdirSync(skillsDir, { withFileTypes: true });\n for (const entry of entries) {\n if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;\n const skillDirAbs = path.join(skillsDir, entry.name);\n const skillFile = path.join(skillDirAbs, \"SKILL.md\");\n try {\n const realSkillFile = fs.realpathSync(skillFile);\n if (!fs.existsSync(realSkillFile)) continue;\n const content = fs.readFileSync(realSkillFile, \"utf-8\");\n const meta = parseSkillFrontmatter(content);\n const name = meta.name ?? entry.name;\n if (skipExistingNames && out[name]) continue; // Template wins\n\n const extraFiles: string[] = [];\n try {\n const walk = (subdir: string, prefix: string) => {\n for (const e of fs.readdirSync(subdir, { withFileTypes: true })) {\n const abs = path.join(subdir, e.name);\n const rel = prefix ? `${prefix}/${e.name}` : e.name;\n if (e.isDirectory() || e.isSymbolicLink()) {\n try {\n const stat = fs.statSync(abs);\n if (stat.isDirectory()) walk(abs, rel);\n } catch {}\n } else if (e.isFile() && e.name !== \"SKILL.md\") {\n extraFiles.push(rel);\n }\n }\n };\n walk(skillDirAbs, \"\");\n } catch {}\n extraFiles.sort();\n\n out[name] = {\n meta: {\n name,\n description: meta.description ?? \"\",\n scope: meta.scope ?? DEFAULT_SKILL_SCOPE,\n },\n content,\n dir: path.relative(rootForRelative, skillDirAbs).replace(/\\\\/g, \"/\"),\n extraFiles,\n };\n } catch {\n // Skip unreadable skills\n }\n }\n}\n\n/**\n * Read AGENTS.md + all skills directly from the filesystem rooted at `cwd`.\n * Optionally also reads a workspace-core's AGENTS.md and skills directory\n * and merges them in (template wins on name collisions). Used by both the\n * Vite plugin (at build time) and the runtime fallback (in dev / Node prod).\n *\n * Synchronous — the Vite plugin's load hook calls it inline during the build.\n */\nexport function readAgentsBundleFromFs(\n cwd: string,\n workspaceSource: WorkspaceAgentsSource | null = null,\n): AgentsBundle {\n let agentsMd = \"\";\n try {\n const agentsMdPath = path.join(cwd, \"AGENTS.md\");\n if (fs.existsSync(agentsMdPath)) {\n agentsMd = fs.readFileSync(agentsMdPath, \"utf-8\");\n }\n } catch {}\n\n let workspaceAgentsMd = \"\";\n if (workspaceSource?.agentsMdPath) {\n try {\n if (fs.existsSync(workspaceSource.agentsMdPath)) {\n workspaceAgentsMd = fs.readFileSync(\n workspaceSource.agentsMdPath,\n \"utf-8\",\n );\n }\n } catch {}\n }\n\n // Merge skills: template first (so its entries are authoritative), then\n // workspace-core with skipExistingNames=true so same-named skills don't\n // overwrite the template's. `.agents/skills` is canonical; `.agent/skills`\n // is accepted as a legacy alias and does not override canonical skills.\n const skills: Record<string, Skill> = {};\n for (const [index, relSkillsDir] of TEMPLATE_SKILLS_DIRS.entries()) {\n try {\n readSkillsDir(path.join(cwd, relSkillsDir), cwd, skills, index > 0);\n } catch {}\n }\n\n if (workspaceSource?.skillsDir) {\n try {\n readSkillsDir(\n workspaceSource.skillsDir,\n workspaceSource.rootDir,\n skills,\n true,\n );\n } catch {}\n }\n\n return { agentsMd, workspaceAgentsMd, skills };\n}\n\n/**\n * Load the agents bundle. Returns a cached result on subsequent calls.\n * Tries the virtual module first (works everywhere, including edge), then\n * falls back to filesystem reads from `process.cwd()` — which, when a\n * workspace core is present, also merges in the workspace core's skills\n * and AGENTS.md.\n */\nexport async function loadAgentsBundle(): Promise<AgentsBundle> {\n if (cached) return cached;\n\n // 1. Try the Vite-emitted virtual module. This is the path that works on\n // every deployment target because the content is inlined at build time.\n // The Vite plugin itself is responsible for merging workspace-core\n // content into the bundle it emits.\n try {\n // @ts-expect-error — virtual module is resolved at build time by our\n // Vite plugin; nothing exists at this path on disk.\n const mod = await import(\"virtual:agents-bundle\");\n if (mod && mod.default) {\n cached = mod.default as AgentsBundle;\n return cached;\n }\n } catch {\n // Virtual module not available — fall through to filesystem.\n }\n\n // 2. Filesystem fallback — works in dev / Node prod. If a workspace core\n // is present in the ancestor chain, merge its skills + AGENTS.md in.\n try {\n let workspaceSource: WorkspaceAgentsSource | null = null;\n try {\n const { getWorkspaceCoreExports } =\n await import(\"../deploy/workspace-core.js\");\n const ws = await getWorkspaceCoreExports(process.cwd());\n if (ws) {\n workspaceSource = {\n skillsDir: ws.skillsDir,\n agentsMdPath: ws.agentsMdPath,\n rootDir: ws.packageDir,\n };\n }\n } catch {\n // workspace-core discovery isn't available (e.g. edge runtime).\n }\n cached = readAgentsBundleFromFs(process.cwd(), workspaceSource);\n return cached;\n } catch {\n cached = EMPTY;\n return cached;\n }\n}\n\n/**\n * Generate the `<skills>` block to inject into the system prompt.\n *\n * Skills are folders at `.agents/skills/<name>/` (or legacy\n * `.agent/skills/<name>/`) containing a `SKILL.md` entry file plus any number\n * of supporting files (additional markdown, examples, images, scripts). This\n * block lists what's available and how to read them.\n *\n * In dev mode the agent has bash access and reads skills via `cat` — exactly\n * like running `claude` locally in the repo. In production mode the agent has\n * no bash; templates that need skill content at runtime should inline the\n * critical parts directly in `AGENTS.md`.\n */\n/**\n * Skills visible to the agent-native RUNTIME agent. Excludes `scope: dev`\n * skills (those are for the human's coding agent only). Skills with no scope,\n * `scope: runtime`, or `scope: both` are all included. Use this anywhere the\n * runtime agent's view of skills is built (prompt block + docs-search) so a\n * dev-scoped skill is invisible to the runtime agent everywhere.\n */\nexport function getRuntimeSkills(bundle: AgentsBundle): Skill[] {\n return Object.values(bundle.skills).filter(\n (skill) => skill.meta.scope !== \"dev\",\n );\n}\n\nexport function generateSkillsPromptBlock(bundle: AgentsBundle): string {\n const entries = getRuntimeSkills(bundle);\n if (entries.length === 0) return \"\";\n\n const lines = entries.map((s) => {\n const extras =\n s.extraFiles.length > 0\n ? ` (also contains: ${s.extraFiles.join(\", \")})`\n : \"\";\n return `- \\`${s.meta.name}\\` at \\`${s.dir}/\\` — ${s.meta.description || \"(no description)\"}${extras}`;\n });\n\n return `<skills>\nThe following skills live in the repo, usually at \\`.agents/skills/<name>/\\` (legacy \\`.agent/skills/<name>/\\` is also supported). Each skill is a folder containing a \\`SKILL.md\\` entry file and sometimes supporting files. Read a skill BEFORE starting a task it applies to.\n\nTo read a skill in dev mode (when you have bash access):\n \\`bash(command=\"cat <skill-dir>/SKILL.md\")\\`\n \\`bash(command=\"ls <skill-dir>/\")\\` to see all files in the folder\n\nAvailable skills:\n${lines.join(\"\\n\")}\n</skills>`;\n}\n\n/** For tests — reset the module cache. */\nexport function __resetAgentsBundleCache(): void {\n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1C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAmBD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,QAWd;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,2BAA2B,QAOnC;AAmGD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,CAG5C;AAyuBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAY5E;AAsID,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAS7E;AAimCD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,KAAK,EACV,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,OAAO,CAAC,CAqKlB;AAMD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAMzE"}
@@ -446,6 +446,77 @@ async function getBearerLegacySession(event) {
446
446
  const email = await getSessionEmail(bearerToken);
447
447
  return email ? { email, token: bearerToken } : null;
448
448
  }
449
+ /**
450
+ * Verify a connect-minted MCP OAuth access token presented as
451
+ * `Authorization: Bearer <jwt>` and resolve it to a session.
452
+ *
453
+ * `agent-native connect` mints this token for the local Plans publish flow and
454
+ * POSTs it to the HOSTED action route
455
+ * `/_agent-native/actions/import-visual-plan-source`. That token is audience-
456
+ * bound to the app's MCP resource (`{appUrl}/_agent-native/mcp`), not to the
457
+ * legacy `sessions` table — so the legacy bearer lookup above never matches it.
458
+ * Reuse the MCP surface's canonical `verifyAuth` here so the HTTP action surface
459
+ * honors EXACTLY the tokens the MCP endpoint honors: same signature check, same
460
+ * audience binding to THIS app's resource, same connect-token revocation gate.
461
+ * It resolves to the same `{ userEmail, orgId }` identity the MCP path uses, so
462
+ * downstream `accessFilter` / ownable-data scoping is identical.
463
+ *
464
+ * `allowDevOpen: false` and the `userEmail` guard ensure an invalid token (or a
465
+ * bare ACCESS_TOKEN with no owner hint) never escalates to an unauthenticated
466
+ * or unscoped identity on this path — it strictly adds acceptance of verified,
467
+ * audience-bound caller tokens, nothing more.
468
+ */
469
+ async function getMcpOAuthBearerSession(event) {
470
+ const authHeader = getHeader(event, "authorization");
471
+ if (!authHeader)
472
+ return null;
473
+ const bearerToken = getBearerSessionToken(event);
474
+ if (!bearerToken)
475
+ return null;
476
+ try {
477
+ const [{ getMcpOAuthResource }, { verifyAuth, resolveOrgIdFromDomain }] = await Promise.all([
478
+ import("../mcp/oauth-route.js"),
479
+ import("../mcp/build-server.js"),
480
+ ]);
481
+ const result = await verifyAuth(authHeader, undefined, {
482
+ resourceUrl: getMcpOAuthResource(event),
483
+ allowDevOpen: false,
484
+ });
485
+ const identity = result.authed ? result.identity : undefined;
486
+ if (!identity?.userEmail)
487
+ return null;
488
+ const orgId = identity.orgId ?? (await resolveOrgIdFromDomain(identity.orgDomain));
489
+ return {
490
+ email: identity.userEmail,
491
+ token: bearerToken,
492
+ ...(orgId ? { orgId } : {}),
493
+ };
494
+ }
495
+ catch (e) {
496
+ console.error("[auth] MCP OAuth bearer verification error:", e);
497
+ return null;
498
+ }
499
+ }
500
+ function isFrameworkActionRoute(event) {
501
+ const { rawPath } = getRequestPathAndSearch(event);
502
+ const path = stripAppBasePath(rawPath);
503
+ return (path === "/_agent-native/actions" ||
504
+ path.startsWith("/_agent-native/actions/"));
505
+ }
506
+ /**
507
+ * Resolve an `Authorization: Bearer` token to a session: first the legacy
508
+ * `sessions` table (desktop/native persisted tokens), then, only on the
509
+ * framework HTTP action surface, a connect-minted MCP OAuth access token (the
510
+ * local Plans publish credential).
511
+ */
512
+ async function getBearerSession(event) {
513
+ const legacy = await getBearerLegacySession(event);
514
+ if (legacy)
515
+ return legacy;
516
+ if (!isFrameworkActionRoute(event))
517
+ return null;
518
+ return getMcpOAuthBearerSession(event);
519
+ }
449
520
  function shouldExposeSessionTokenInBody(event) {
450
521
  const origin = getHeader(event, "origin");
451
522
  if (origin && DESKTOP_AUTH_TOKEN_BODY_ORIGINS.has(origin))
@@ -1442,7 +1513,7 @@ async function resolveSessionUncached(event) {
1442
1513
  const session = await customGetSession(event);
1443
1514
  if (session)
1444
1515
  return session;
1445
- const bearerSession = await getBearerLegacySession(event);
1516
+ const bearerSession = await getBearerSession(event);
1446
1517
  if (bearerSession)
1447
1518
  return bearerSession;
1448
1519
  // Desktop SSO broker: even with BYOA auth, fall back to the broker
@@ -1456,9 +1527,11 @@ async function resolveSessionUncached(event) {
1456
1527
  // Fall through to mobile _session check
1457
1528
  }
1458
1529
  else {
1459
- // 4. Bearer legacy session. Desktop/native clients can persist a session
1530
+ // 4. Bearer session. Desktop/native clients can persist a legacy session
1460
1531
  // token outside the WebView cookie jar and attach it to all app requests.
1461
- const bearerSession = await getBearerLegacySession(event);
1532
+ // `agent-native connect` clients may present a connect-minted MCP OAuth
1533
+ // token, but only the framework action route accepts that fallback.
1534
+ const bearerSession = await getBearerSession(event);
1462
1535
  if (bearerSession)
1463
1536
  return bearerSession;
1464
1537
  // 5. Better Auth session (cookie or Bearer token)