@agent-native/core 0.102.1 → 0.103.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 (295) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +15 -0
  3. package/corpus/core/docs/content/local-file-mode.mdx +99 -489
  4. package/corpus/core/docs/content/locales/ar-SA/local-file-mode.mdx +35 -490
  5. package/corpus/core/docs/content/locales/ar-SA/template-content.mdx +10 -24
  6. package/corpus/core/docs/content/locales/de-DE/local-file-mode.mdx +37 -491
  7. package/corpus/core/docs/content/locales/de-DE/template-content.mdx +10 -24
  8. package/corpus/core/docs/content/locales/es-ES/local-file-mode.mdx +35 -493
  9. package/corpus/core/docs/content/locales/es-ES/template-content.mdx +10 -24
  10. package/corpus/core/docs/content/locales/fr-FR/local-file-mode.mdx +38 -491
  11. package/corpus/core/docs/content/locales/fr-FR/template-content.mdx +10 -24
  12. package/corpus/core/docs/content/locales/hi-IN/local-file-mode.mdx +33 -492
  13. package/corpus/core/docs/content/locales/hi-IN/template-content.mdx +10 -24
  14. package/corpus/core/docs/content/locales/ja-JP/local-file-mode.mdx +36 -492
  15. package/corpus/core/docs/content/locales/ja-JP/template-content.mdx +10 -24
  16. package/corpus/core/docs/content/locales/ko-KR/local-file-mode.mdx +35 -490
  17. package/corpus/core/docs/content/locales/ko-KR/template-content.mdx +10 -24
  18. package/corpus/core/docs/content/locales/pt-BR/local-file-mode.mdx +35 -493
  19. package/corpus/core/docs/content/locales/pt-BR/template-content.mdx +10 -24
  20. package/corpus/core/docs/content/locales/zh-CN/local-file-mode.mdx +31 -489
  21. package/corpus/core/docs/content/locales/zh-CN/template-content.mdx +9 -24
  22. package/corpus/core/docs/content/locales/zh-TW/local-file-mode.mdx +31 -489
  23. package/corpus/core/docs/content/locales/zh-TW/template-content.mdx +9 -24
  24. package/corpus/core/docs/content/template-content.mdx +26 -42
  25. package/corpus/core/package.json +1 -1
  26. package/corpus/core/src/cli/content-local.ts +86 -18
  27. package/corpus/core/src/cli/index.ts +2 -2
  28. package/corpus/core/src/cli/skills-content/content-skill.ts +36 -25
  29. package/corpus/core/src/cli/skills.ts +47 -13
  30. package/corpus/core/src/client/AgentPanel.tsx +7 -0
  31. package/corpus/core/src/client/AssistantChat.tsx +7 -0
  32. package/corpus/core/src/client/agent-chat-adapter.ts +7 -1
  33. package/corpus/core/src/client/chat/message-components.tsx +17 -3
  34. package/corpus/core/src/client/composer/ComposerPlusMenu.tsx +96 -6
  35. package/corpus/core/src/client/composer/asset-picker-url.ts +80 -0
  36. package/corpus/core/src/client/error-format.ts +24 -0
  37. package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +8 -1
  38. package/corpus/core/src/local-artifacts/index.ts +65 -0
  39. package/corpus/templates/assets/app/components/library/GenerationPresetsPanel.tsx +325 -0
  40. package/corpus/templates/assets/app/hooks/use-navigation-state.ts +12 -0
  41. package/corpus/templates/assets/app/i18n/zh-TW.ts +21 -0
  42. package/corpus/templates/assets/app/i18n-data.ts +215 -0
  43. package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +19 -479
  44. package/corpus/templates/assets/app/routes/brand-kits.$id_.presets.$presetId.tsx +1 -1
  45. package/corpus/templates/assets/app/routes/brand-kits.$id_.settings.tsx +446 -0
  46. package/corpus/templates/assets/app/routes/library.tsx +69 -0
  47. package/corpus/templates/assets/changelog/2026-07-15-fixed-top-level-image-picker-selections-returning-to-the-com.md +6 -0
  48. package/corpus/templates/clips/actions/disconnect-calendar.ts +57 -9
  49. package/corpus/templates/clips/actions/generate-workflow.ts +102 -59
  50. package/corpus/templates/clips/actions/get-recording-player-data.ts +64 -1
  51. package/corpus/templates/clips/actions/regenerate-summary.ts +7 -0
  52. package/corpus/templates/clips/actions/regenerate-title.ts +29 -11
  53. package/corpus/templates/clips/app/components/editor/editor-layout.tsx +34 -13
  54. package/corpus/templates/clips/app/components/editor/thumbnail-picker.tsx +87 -9
  55. package/corpus/templates/clips/app/components/editor/trim-handles.tsx +15 -0
  56. package/corpus/templates/clips/app/components/editor/waveform.tsx +21 -8
  57. package/corpus/templates/clips/app/components/library/folder-tree.tsx +52 -0
  58. package/corpus/templates/clips/app/components/player/settings-panel.tsx +116 -58
  59. package/corpus/templates/clips/app/components/player/share-dialog.tsx +43 -37
  60. package/corpus/templates/clips/app/components/player/video-player.tsx +50 -2
  61. package/corpus/templates/clips/app/components/recorder/microphone-visualizer.tsx +22 -3
  62. package/corpus/templates/clips/app/i18n/ar-SA.ts +5 -2
  63. package/corpus/templates/clips/app/i18n/de-DE.ts +6 -2
  64. package/corpus/templates/clips/app/i18n/en-US.ts +5 -2
  65. package/corpus/templates/clips/app/i18n/es-ES.ts +6 -2
  66. package/corpus/templates/clips/app/i18n/fr-FR.ts +5 -2
  67. package/corpus/templates/clips/app/i18n/hi-IN.ts +5 -2
  68. package/corpus/templates/clips/app/i18n/ja-JP.ts +6 -1
  69. package/corpus/templates/clips/app/i18n/ko-KR.ts +5 -2
  70. package/corpus/templates/clips/app/i18n/pt-BR.ts +6 -2
  71. package/corpus/templates/clips/app/i18n/zh-CN.ts +5 -2
  72. package/corpus/templates/clips/app/i18n/zh-TW.ts +5 -2
  73. package/corpus/templates/clips/app/lib/timestamp-mapping.ts +14 -0
  74. package/corpus/templates/clips/app/routes/_app.library._index.tsx +1 -2
  75. package/corpus/templates/clips/app/routes/_index.tsx +1 -2
  76. package/corpus/templates/clips/app/routes/r.$recordingId.tsx +98 -32
  77. package/corpus/templates/clips/app/routes/share.$shareId.tsx +4 -1
  78. package/corpus/templates/clips/changelog/2026-07-15-ai-workflow-generation-now-stays-visible-avoids-duplicate-re.md +6 -0
  79. package/corpus/templates/clips/changelog/2026-07-15-clip-playback-and-cta-controls-remain-interactive-through-ed.md +6 -0
  80. package/corpus/templates/clips/changelog/2026-07-15-clip-titles-no-longer-describe-the-product-as-a-loom-alterna.md +6 -0
  81. package/corpus/templates/clips/changelog/2026-07-15-description-regeneration-now-opens-the-agent-chat-so-progres.md +6 -0
  82. package/corpus/templates/clips/changelog/2026-07-15-direct-recording-urls-now-respect-share-link-and-password-ac.md +6 -0
  83. package/corpus/templates/clips/changelog/2026-07-15-disconnecting-a-calendar-now-clears-unrecorded-synced-meetin.md +6 -0
  84. package/corpus/templates/clips/changelog/2026-07-15-folders-now-expose-rename-and-delete-actions-directly-in-the.md +6 -0
  85. package/corpus/templates/clips/changelog/2026-07-15-recording-pages-now-explain-sign-in-access-and-avoid-showing.md +6 -0
  86. package/corpus/templates/clips/changelog/2026-07-15-the-clips-extension-quick-actions-toolbar-can-be-moved-out-o.md +6 -0
  87. package/corpus/templates/clips/changelog/2026-07-15-the-editor-now-skips-cut-sections-during-preview-and-keeps-t.md +6 -0
  88. package/corpus/templates/clips/changelog/2026-07-15-thumbnail-capture-now-updates-previews-while-scrubbing-and-l.md +6 -0
  89. package/corpus/templates/clips/changelog/2026-07-15-windows-permission-links-open-the-matching-settings-page.md +6 -0
  90. package/corpus/templates/clips/chrome-extension/src/content-script.ts +117 -2
  91. package/corpus/templates/clips/chrome-extension/src/overlay.ts +27 -0
  92. package/corpus/templates/clips/desktop/src-tauri/tauri.conf.json +1 -1
  93. package/corpus/templates/clips/server/lib/calendar-event-meetings.ts +139 -101
  94. package/corpus/templates/clips/server/lib/recording-page-access.ts +35 -0
  95. package/corpus/templates/clips/server/lib/share-password.ts +6 -3
  96. package/corpus/templates/content/.agents/skills/content/SKILL.md +26 -39
  97. package/corpus/templates/content/AGENTS.md +25 -30
  98. package/corpus/templates/content/actions/_builder-docs-client.ts +23 -0
  99. package/corpus/templates/content/actions/_content-database-source-adapters.ts +21 -3
  100. package/corpus/templates/content/actions/_content-files.ts +338 -0
  101. package/corpus/templates/content/actions/_content-space-access.ts +135 -0
  102. package/corpus/templates/content/actions/_content-spaces.ts +640 -0
  103. package/corpus/templates/content/actions/_database-source-utils.ts +90 -7
  104. package/corpus/templates/content/actions/_database-utils.ts +7 -1
  105. package/corpus/templates/content/actions/_local-file-documents.ts +0 -9
  106. package/corpus/templates/content/actions/_local-folder-source.ts +53 -0
  107. package/corpus/templates/content/actions/_property-utils.ts +9 -4
  108. package/corpus/templates/content/actions/add-database-item.ts +108 -65
  109. package/corpus/templates/content/actions/backfill-content-files.ts +22 -0
  110. package/corpus/templates/content/actions/connect-local-folder-source.ts +221 -0
  111. package/corpus/templates/content/actions/create-content-database.ts +129 -3
  112. package/corpus/templates/content/actions/create-document.ts +65 -55
  113. package/corpus/templates/content/actions/create-inline-content-database.ts +6 -1
  114. package/corpus/templates/content/actions/delete-content-database.ts +3 -0
  115. package/corpus/templates/content/actions/delete-document.ts +7 -11
  116. package/corpus/templates/content/actions/disconnect-local-folder-source.ts +175 -0
  117. package/corpus/templates/content/actions/duplicate-database-item.ts +10 -0
  118. package/corpus/templates/content/actions/duplicate-database-items.ts +13 -0
  119. package/corpus/templates/content/actions/edit-document.ts +2 -28
  120. package/corpus/templates/content/actions/ensure-content-spaces.ts +26 -0
  121. package/corpus/templates/content/actions/export-content-source.ts +47 -9
  122. package/corpus/templates/content/actions/get-document.ts +0 -14
  123. package/corpus/templates/content/actions/import-content-source.ts +43 -3
  124. package/corpus/templates/content/actions/list-content-spaces.ts +103 -0
  125. package/corpus/templates/content/actions/list-documents.ts +12 -9
  126. package/corpus/templates/content/actions/move-document.ts +3 -14
  127. package/corpus/templates/content/actions/pull-document.ts +0 -23
  128. package/corpus/templates/content/actions/remove-local-file-source.ts +50 -29
  129. package/corpus/templates/content/actions/resolve-local-folder-conflict.ts +442 -0
  130. package/corpus/templates/content/actions/reveal-local-source-file.ts +6 -17
  131. package/corpus/templates/content/actions/search-documents.ts +0 -34
  132. package/corpus/templates/content/actions/share-local-file-document.ts +25 -1
  133. package/corpus/templates/content/actions/submit-content-database-form.ts +12 -0
  134. package/corpus/templates/content/actions/sync-local-folder-source.ts +731 -0
  135. package/corpus/templates/content/actions/sync-manifest-local-folder-source.ts +123 -0
  136. package/corpus/templates/content/actions/update-content-database-view.ts +10 -1
  137. package/corpus/templates/content/actions/update-document.ts +0 -15
  138. package/corpus/templates/content/actions/view-screen.ts +2 -50
  139. package/corpus/templates/content/app/components/editor/SlashCommandMenu.tsx +76 -62
  140. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +70 -22
  141. package/corpus/templates/content/app/components/editor/database/grouping.ts +2 -1
  142. package/corpus/templates/content/app/components/editor/database/settings.tsx +23 -20
  143. package/corpus/templates/content/app/components/editor/database/shared.tsx +2 -0
  144. package/corpus/templates/content/app/components/editor/database/sidebar.tsx +330 -0
  145. package/corpus/templates/content/app/components/editor/database/types.ts +1 -0
  146. package/corpus/templates/content/app/components/editor/database/view-config.ts +3 -1
  147. package/corpus/templates/content/app/components/layout/Layout.tsx +25 -1
  148. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +209 -113
  149. package/corpus/templates/content/app/components/sidebar/select-content-space.ts +31 -0
  150. package/corpus/templates/content/app/hooks/use-content-database.ts +16 -0
  151. package/corpus/templates/content/app/hooks/use-content-spaces.ts +39 -0
  152. package/corpus/templates/content/app/i18n/zh-TW.ts +11 -0
  153. package/corpus/templates/content/app/i18n-data.ts +75 -0
  154. package/corpus/templates/content/app/routes/_app.local-files.tsx +174 -65
  155. package/corpus/templates/content/changelog/2026-07-16-content-callouts-can-now-be-reviewed-and-published-to-builder.md +6 -0
  156. package/corpus/templates/content/changelog/2026-07-16-heading-5-and-heading-6-are-available-from-the-editor-slash-.md +6 -0
  157. package/corpus/templates/content/changelog/2026-07-16-organize-every-workspace-through-a-customizable-files-databa.md +6 -0
  158. package/corpus/templates/content/parity/matrix.md +2 -1
  159. package/corpus/templates/content/parity/matrix.ts +37 -1
  160. package/corpus/templates/content/scripts/dev-database.mjs +7 -5
  161. package/corpus/templates/content/server/db/schema.ts +113 -40
  162. package/corpus/templates/content/server/lib/document-context.ts +15 -1
  163. package/corpus/templates/content/server/lib/notion-sync.ts +6 -0
  164. package/corpus/templates/content/server/plugins/db.ts +153 -0
  165. package/corpus/templates/content/shared/api.ts +17 -3
  166. package/corpus/templates/content/shared/builder-mdx.ts +163 -16
  167. package/corpus/templates/design/.agents/skills/design-templates/SKILL.md +59 -0
  168. package/corpus/templates/design/AGENTS.md +6 -1
  169. package/corpus/templates/design/actions/create-design-from-template.ts +19 -7
  170. package/corpus/templates/design/actions/list-design-templates.ts +69 -21
  171. package/corpus/templates/design/actions/navigate.ts +2 -2
  172. package/corpus/templates/design/actions/view-screen.ts +15 -2
  173. package/corpus/templates/design/agent-native.app-skill.json +5 -0
  174. package/corpus/templates/design/app/components/design/design-canvas/external-preview.ts +7 -3
  175. package/corpus/templates/design/app/components/editor/PromptDialog.tsx +281 -56
  176. package/corpus/templates/design/app/components/templates/TemplatePreview.tsx +14 -2
  177. package/corpus/templates/design/app/hooks/use-navigation-state.ts +3 -2
  178. package/corpus/templates/design/app/i18n/zh-TW.ts +3 -3
  179. package/corpus/templates/design/app/i18n-data.ts +21 -2
  180. package/corpus/templates/design/app/i18n-template-feature.ts +218 -10
  181. package/corpus/templates/design/app/pages/Index.tsx +195 -24
  182. package/corpus/templates/design/app/pages/Templates.tsx +144 -55
  183. package/corpus/templates/design/app/pages/design-editor/generation-prompt-directives.ts +12 -1
  184. package/corpus/templates/design/changelog/2026-07-14-templates-now-appear-in-the-new-design-picker-with-previews-.md +6 -0
  185. package/corpus/templates/design/changelog/2026-07-15-prototype-print-and-download-buttons-now-work-in-preview.md +6 -0
  186. package/corpus/templates/design/changelog/2026-07-15-templates-now-open-immediately-after-copying-even-while-the-.md +6 -0
  187. package/corpus/templates/design/server/plugins/agent-chat.ts +1 -1
  188. package/corpus/templates/mail/AGENTS.md +23 -18
  189. package/corpus/templates/mail/actions/bulk-archive.ts +32 -28
  190. package/corpus/templates/mail/actions/mark-read.ts +131 -20
  191. package/corpus/templates/mail/actions/mark-thread-read.ts +1 -1
  192. package/corpus/templates/mail/actions/move-email.ts +30 -24
  193. package/corpus/templates/mail/actions/send-email.ts +73 -68
  194. package/corpus/templates/mail/changelog/2026-07-15-unread-inbox-cleanup-now-completes-reliably.md +6 -0
  195. package/corpus/templates/mail/server/handlers/emails.ts +218 -209
  196. package/corpus/templates/mail/server/lib/bulk-mark-read.ts +30 -0
  197. package/corpus/templates/mail/server/lib/email-state.ts +198 -113
  198. package/corpus/templates/mail/server/lib/google-auth.ts +218 -25
  199. package/corpus/templates/mail/server/lib/jobs.ts +69 -74
  200. package/corpus/templates/mail/server/lib/local-email-store.ts +265 -0
  201. package/corpus/templates/mail/server/plugins/agent-chat.ts +6 -0
  202. package/corpus/templates/slides/actions/extract-pdf.ts +1 -1
  203. package/corpus/templates/slides/actions/import-file.ts +4 -1
  204. package/corpus/templates/slides/app/components/editor/ImageGenPanel.tsx +1 -1
  205. package/corpus/templates/slides/app/components/editor/ImageSearchPanel.tsx +9 -12
  206. package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +29 -21
  207. package/corpus/templates/slides/app/i18n/ar-SA.ts +1 -0
  208. package/corpus/templates/slides/app/i18n/de-DE.ts +1 -0
  209. package/corpus/templates/slides/app/i18n/en-US.ts +1 -0
  210. package/corpus/templates/slides/app/i18n/es-ES.ts +1 -0
  211. package/corpus/templates/slides/app/i18n/fr-FR.ts +1 -0
  212. package/corpus/templates/slides/app/i18n/hi-IN.ts +1 -0
  213. package/corpus/templates/slides/app/i18n/ja-JP.ts +1 -0
  214. package/corpus/templates/slides/app/i18n/ko-KR.ts +1 -0
  215. package/corpus/templates/slides/app/i18n/pt-BR.ts +1 -0
  216. package/corpus/templates/slides/app/i18n/zh-CN.ts +1 -0
  217. package/corpus/templates/slides/app/i18n/zh-TW.ts +1 -0
  218. package/corpus/templates/slides/changelog/2026-07-15-image-search-and-generation-controls-now-use-the-registered-.md +6 -0
  219. package/corpus/templates/slides/changelog/2026-07-15-pdf-deck-references-can-be-imported-for-slide-inspiration-ag.md +6 -0
  220. package/corpus/templates/slides/changelog/2026-07-15-stable-style-inspector-dock.md +6 -0
  221. package/dist/cli/content-local.d.ts +1 -0
  222. package/dist/cli/content-local.d.ts.map +1 -1
  223. package/dist/cli/content-local.js +75 -17
  224. package/dist/cli/content-local.js.map +1 -1
  225. package/dist/cli/index.js +2 -2
  226. package/dist/cli/index.js.map +1 -1
  227. package/dist/cli/skills-content/content-skill.d.ts +1 -1
  228. package/dist/cli/skills-content/content-skill.d.ts.map +1 -1
  229. package/dist/cli/skills-content/content-skill.js +36 -25
  230. package/dist/cli/skills-content/content-skill.js.map +1 -1
  231. package/dist/cli/skills.d.ts.map +1 -1
  232. package/dist/cli/skills.js +47 -14
  233. package/dist/cli/skills.js.map +1 -1
  234. package/dist/client/AgentPanel.d.ts.map +1 -1
  235. package/dist/client/AgentPanel.js +5 -0
  236. package/dist/client/AgentPanel.js.map +1 -1
  237. package/dist/client/AssistantChat.d.ts.map +1 -1
  238. package/dist/client/AssistantChat.js +7 -0
  239. package/dist/client/AssistantChat.js.map +1 -1
  240. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  241. package/dist/client/agent-chat-adapter.js +8 -1
  242. package/dist/client/agent-chat-adapter.js.map +1 -1
  243. package/dist/client/chat/message-components.d.ts +4 -0
  244. package/dist/client/chat/message-components.d.ts.map +1 -1
  245. package/dist/client/chat/message-components.js +10 -3
  246. package/dist/client/chat/message-components.js.map +1 -1
  247. package/dist/client/composer/ComposerPlusMenu.d.ts.map +1 -1
  248. package/dist/client/composer/ComposerPlusMenu.js +58 -6
  249. package/dist/client/composer/ComposerPlusMenu.js.map +1 -1
  250. package/dist/client/composer/asset-picker-url.d.ts +16 -0
  251. package/dist/client/composer/asset-picker-url.d.ts.map +1 -0
  252. package/dist/client/composer/asset-picker-url.js +64 -0
  253. package/dist/client/composer/asset-picker-url.js.map +1 -0
  254. package/dist/client/error-format.d.ts.map +1 -1
  255. package/dist/client/error-format.js +17 -0
  256. package/dist/client/error-format.js.map +1 -1
  257. package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
  258. package/dist/client/resources/McpIntegrationDialog.js +6 -1
  259. package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
  260. package/dist/collab/awareness.d.ts +2 -2
  261. package/dist/collab/awareness.d.ts.map +1 -1
  262. package/dist/collab/struct-routes.d.ts +1 -1
  263. package/dist/local-artifacts/index.d.ts +10 -0
  264. package/dist/local-artifacts/index.d.ts.map +1 -1
  265. package/dist/local-artifacts/index.js +39 -0
  266. package/dist/local-artifacts/index.js.map +1 -1
  267. package/dist/notifications/routes.d.ts +1 -1
  268. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  269. package/dist/resources/handlers.d.ts +3 -3
  270. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  271. package/dist/server/transcribe-voice.d.ts +1 -1
  272. package/docs/content/local-file-mode.mdx +99 -489
  273. package/docs/content/locales/ar-SA/local-file-mode.mdx +35 -490
  274. package/docs/content/locales/ar-SA/template-content.mdx +10 -24
  275. package/docs/content/locales/de-DE/local-file-mode.mdx +37 -491
  276. package/docs/content/locales/de-DE/template-content.mdx +10 -24
  277. package/docs/content/locales/es-ES/local-file-mode.mdx +35 -493
  278. package/docs/content/locales/es-ES/template-content.mdx +10 -24
  279. package/docs/content/locales/fr-FR/local-file-mode.mdx +38 -491
  280. package/docs/content/locales/fr-FR/template-content.mdx +10 -24
  281. package/docs/content/locales/hi-IN/local-file-mode.mdx +33 -492
  282. package/docs/content/locales/hi-IN/template-content.mdx +10 -24
  283. package/docs/content/locales/ja-JP/local-file-mode.mdx +36 -492
  284. package/docs/content/locales/ja-JP/template-content.mdx +10 -24
  285. package/docs/content/locales/ko-KR/local-file-mode.mdx +35 -490
  286. package/docs/content/locales/ko-KR/template-content.mdx +10 -24
  287. package/docs/content/locales/pt-BR/local-file-mode.mdx +35 -493
  288. package/docs/content/locales/pt-BR/template-content.mdx +10 -24
  289. package/docs/content/locales/zh-CN/local-file-mode.mdx +31 -489
  290. package/docs/content/locales/zh-CN/template-content.mdx +9 -24
  291. package/docs/content/locales/zh-TW/local-file-mode.mdx +31 -489
  292. package/docs/content/locales/zh-TW/template-content.mdx +9 -24
  293. package/docs/content/template-content.mdx +26 -42
  294. package/package.json +1 -1
  295. package/corpus/templates/assets/app/components/library/EditLibraryDialog.tsx +0 -126
@@ -1,4 +1,5 @@
1
1
  import { spawn } from "node:child_process";
2
+ import { createHash } from "node:crypto";
2
3
  import fsSync from "node:fs";
3
4
  import fs from "node:fs/promises";
4
5
  import path from "node:path";
@@ -7,7 +8,7 @@ const CONTENT_APP_ID = "content";
7
8
  const MANIFEST_FILE = "agent-native.json";
8
9
  const DEFAULT_PORT = 8083;
9
10
  const DEFAULT_PROFILE = "docs/no-bookkeeping";
10
- const LOCAL_FILE_ID_PREFIX = "local-file:";
11
+ const LOCAL_FOLDER_CONNECTION_PREFIX = "local-folder:";
11
12
  function normalizeSlash(value) {
12
13
  return value.replace(/\\/g, "/");
13
14
  }
@@ -20,8 +21,20 @@ function titleFromPath(value) {
20
21
  .trim()
21
22
  .replace(/\b\w/g, (char) => char.toUpperCase()) || "Content");
22
23
  }
23
- function encodeLocalFileId(filePath) {
24
- return `${LOCAL_FILE_ID_PREFIX}${Buffer.from(filePath, "utf8").toString("base64url")}`;
24
+ function localFolderConnectionId(absoluteRootPath) {
25
+ let canonicalRootPath = path.resolve(absoluteRootPath);
26
+ try {
27
+ canonicalRootPath = fsSync.realpathSync(canonicalRootPath);
28
+ }
29
+ catch (error) {
30
+ if (error.code !== "ENOENT")
31
+ throw error;
32
+ }
33
+ const digest = createHash("sha256")
34
+ .update(canonicalRootPath)
35
+ .digest("base64url")
36
+ .slice(0, 24);
37
+ return `${LOCAL_FOLDER_CONNECTION_PREFIX}${digest}`;
25
38
  }
26
39
  function isRecord(value) {
27
40
  return !!value && typeof value === "object" && !Array.isArray(value);
@@ -105,6 +118,7 @@ function resolveTarget(target, cwd) {
105
118
  : undefined;
106
119
  return {
107
120
  absoluteTarget,
121
+ absoluteRootPath: targetDirectory,
108
122
  isFile: stat.isFile(),
109
123
  workspaceRoot,
110
124
  rootPath: normalizeSlash(rootPath),
@@ -127,7 +141,7 @@ async function readManifest(manifestPath) {
127
141
  throw error;
128
142
  }
129
143
  }
130
- function upsertContentManifest(manifest, rootPath, options) {
144
+ function upsertContentManifest(manifest, workspaceRoot, rootPath, options) {
131
145
  const next = {
132
146
  ...manifest,
133
147
  version: manifest.version ?? 1,
@@ -154,14 +168,50 @@ function upsertContentManifest(manifest, rootPath, options) {
154
168
  ? existingRoot.extensions
155
169
  : [".md", ".mdx"],
156
170
  ...(profile ? { profile } : {}),
157
- ...(include && rootIndex === -1 ? { include } : {}),
171
+ ...(include && (rootIndex === -1 || Array.isArray(existingRoot?.include))
172
+ ? {
173
+ include: Array.from(new Set([
174
+ ...(Array.isArray(existingRoot?.include)
175
+ ? existingRoot.include.filter((value) => typeof value === "string")
176
+ : []),
177
+ ...include,
178
+ ])),
179
+ }
180
+ : {}),
181
+ source: {
182
+ ...(isRecord(existingRoot?.source) ? existingRoot.source : {}),
183
+ type: "local-folder",
184
+ connectionId: options.connectionId,
185
+ truthPolicy: "source_primary",
186
+ },
158
187
  };
159
- const roots = rootIndex === -1
188
+ let roots = rootIndex === -1
160
189
  ? [...existingRoots, root]
161
190
  : existingRoots.map((entry, index) => index === rootIndex ? { ...entry, ...root } : entry);
191
+ if (existingContent.mode === "local-files") {
192
+ roots = roots.map((entry) => {
193
+ if (entry === root || typeof entry.path !== "string")
194
+ return entry;
195
+ const existingSource = isRecord(entry.source) ? entry.source : {};
196
+ return {
197
+ ...entry,
198
+ source: {
199
+ ...existingSource,
200
+ type: "local-folder",
201
+ connectionId: typeof existingSource.connectionId === "string" &&
202
+ existingSource.connectionId
203
+ ? existingSource.connectionId
204
+ : localFolderConnectionId(path.resolve(workspaceRoot, entry.path)),
205
+ truthPolicy: typeof existingSource.truthPolicy === "string"
206
+ ? existingSource.truthPolicy
207
+ : "source_primary",
208
+ },
209
+ };
210
+ });
211
+ }
212
+ delete existingContent.mode;
162
213
  apps[CONTENT_APP_ID] = {
163
214
  ...existingContent,
164
- mode: "local-files",
165
215
  roots,
166
216
  hide: Array.isArray(existingContent.hide)
167
217
  ? existingContent.hide
@@ -184,15 +234,19 @@ export function findContentTemplateDir(cwd = process.cwd()) {
184
234
  candidates.push(path.resolve(cliDir, "../../../..", "templates/content"));
185
235
  return (candidates.find((candidate) => fsSync.existsSync(path.join(candidate, "package.json"))) ?? null);
186
236
  }
187
- function launchUrl(port, filePath) {
188
- const base = `http://127.0.0.1:${port}`;
189
- return filePath ? `${base}/page/${encodeLocalFileId(filePath)}` : base;
237
+ function launchUrl(port, connectionId, filePath) {
238
+ const params = new URLSearchParams({ connectionId });
239
+ if (filePath)
240
+ params.set("file", filePath);
241
+ return `http://127.0.0.1:${port}/local-files?${params.toString()}`;
190
242
  }
191
243
  export async function prepareContentLocalLaunch(options) {
192
244
  const cwd = path.resolve(options.cwd ?? process.cwd());
193
245
  const target = resolveTarget(options.target, cwd);
194
246
  const manifestPath = path.join(target.workspaceRoot, MANIFEST_FILE);
195
- const manifest = upsertContentManifest(await readManifest(manifestPath), target.rootPath, {
247
+ const connectionId = localFolderConnectionId(target.absoluteRootPath);
248
+ const manifest = upsertContentManifest(await readManifest(manifestPath), target.workspaceRoot, target.rootPath, {
249
+ connectionId,
196
250
  filePath: target.filePath,
197
251
  profile: options.profile,
198
252
  });
@@ -208,7 +262,8 @@ export async function prepareContentLocalLaunch(options) {
208
262
  manifestPath,
209
263
  rootPath: target.rootPath,
210
264
  filePath: target.filePath,
211
- url: launchUrl(options.port ?? DEFAULT_PORT, target.filePath),
265
+ connectionId,
266
+ url: launchUrl(options.port ?? DEFAULT_PORT, connectionId, target.filePath),
212
267
  command: "corepack",
213
268
  args: [
214
269
  "pnpm",
@@ -222,7 +277,6 @@ export async function prepareContentLocalLaunch(options) {
222
277
  "--strictPort",
223
278
  ],
224
279
  env: {
225
- AGENT_NATIVE_MODE: "local-files",
226
280
  AGENT_NATIVE_MANIFEST_PATH: manifestPath,
227
281
  },
228
282
  manifest,
@@ -248,7 +302,7 @@ function printHelp() {
248
302
  agent-native content <file-or-folder> [options]
249
303
 
250
304
  Options:
251
- --profile <name> Local file profile, for example docs/no-bookkeeping
305
+ --profile <name> Local folder profile, for example docs/no-bookkeeping
252
306
  --port <number> Dev server port (default ${DEFAULT_PORT})
253
307
  --open Open the target in the browser (default)
254
308
  --no-open Start the server without opening the browser
@@ -257,9 +311,13 @@ Options:
257
311
  }
258
312
  export async function runContentLocal(argv) {
259
313
  const parsed = parseContentLocalArgs(argv);
260
- if (parsed.help || !parsed.target) {
314
+ if (parsed.help) {
315
+ printHelp();
316
+ return 0;
317
+ }
318
+ if (!parsed.target) {
261
319
  printHelp();
262
- return parsed.target ? 0 : 1;
320
+ return 1;
263
321
  }
264
322
  const plan = await prepareContentLocalLaunch({
265
323
  target: parsed.target,
@@ -271,7 +329,7 @@ export async function runContentLocal(argv) {
271
329
  console.log(JSON.stringify(plan, null, 2));
272
330
  return 0;
273
331
  }
274
- console.log(`Content local files: ${plan.rootPath}`);
332
+ console.log(`Content folder source: ${plan.rootPath}`);
275
333
  console.log(`Manifest: ${plan.manifestPath}`);
276
334
  console.log(`Opening: ${plan.url}`);
277
335
  if (parsed.open) {
@@ -1 +1 @@
1
- {"version":3,"file":"content-local.js","sourceRoot":"","sources":["../../src/cli/content-local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,cAAc,GAAG,SAAS,CAAC;AACjC,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAC1C,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAC9C,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAwB3C,SAAS,cAAc,CAAC,KAA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E,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/C,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7B,OAAO,CAAC,CAAC,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;QACH,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAU,EAAE,CAAC;YAC9D,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;gBACtB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACnB,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport fsSync from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst CONTENT_APP_ID = \"content\";\nconst MANIFEST_FILE = \"agent-native.json\";\nconst DEFAULT_PORT = 8083;\nconst DEFAULT_PROFILE = \"docs/no-bookkeeping\";\nconst LOCAL_FILE_ID_PREFIX = \"local-file:\";\n\nexport interface ContentLocalArgs {\n target?: string;\n open: boolean;\n port: number;\n profile?: string;\n dryRun: boolean;\n json: boolean;\n help: boolean;\n}\n\nexport interface ContentLocalLaunchPlan {\n workspaceRoot: string;\n manifestPath: string;\n rootPath: string;\n filePath?: string;\n url: string;\n command: string;\n args: string[];\n env: Record<string, string>;\n manifest: Record<string, unknown>;\n}\n\nfunction normalizeSlash(value: string) {\n return value.replace(/\\\\/g, \"/\");\n}\n\nfunction titleFromPath(value: string) {\n return (\n path\n .basename(value)\n .replace(/\\.(mdx?|markdown)$/i, \"\")\n .replace(/[-_]+/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim()\n .replace(/\\b\\w/g, (char) => char.toUpperCase()) || \"Content\"\n );\n}\n\nfunction encodeLocalFileId(filePath: string) {\n return `${LOCAL_FILE_ID_PREFIX}${Buffer.from(filePath, \"utf8\").toString(\n \"base64url\",\n )}`;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction stringFlagValue(argv: string[], index: number, flag: string) {\n const value = argv[index + 1];\n if (!value || value.startsWith(\"-\")) {\n throw new Error(`${flag} requires a value`);\n }\n return value;\n}\n\nexport function parseContentLocalArgs(argv: string[]): ContentLocalArgs {\n const args = argv[0] === \"local-files\" ? argv.slice(1) : argv;\n const parsed: ContentLocalArgs = {\n open: true,\n port: DEFAULT_PORT,\n dryRun: false,\n json: false,\n help: false,\n };\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index]!;\n if (arg === \"help\" || arg === \"--help\" || arg === \"-h\") {\n parsed.help = true;\n } else if (arg === \"--open\") {\n parsed.open = true;\n } else if (arg === \"--no-open\") {\n parsed.open = false;\n } else if (arg === \"--dry-run\") {\n parsed.dryRun = true;\n } else if (arg === \"--json\") {\n parsed.json = true;\n } else if (arg === \"--port\") {\n parsed.port = Number.parseInt(stringFlagValue(args, index, arg), 10);\n index += 1;\n } else if (arg.startsWith(\"--port=\")) {\n parsed.port = Number.parseInt(arg.slice(\"--port=\".length), 10);\n } else if (arg === \"--profile\") {\n parsed.profile = stringFlagValue(args, index, arg);\n index += 1;\n } else if (arg.startsWith(\"--profile=\")) {\n parsed.profile = arg.slice(\"--profile=\".length);\n } else if (arg.startsWith(\"-\")) {\n throw new Error(`Unknown option: ${arg}`);\n } else if (!parsed.target) {\n parsed.target = arg;\n } else {\n throw new Error(`Unexpected argument: ${arg}`);\n }\n }\n\n if (!Number.isInteger(parsed.port) || parsed.port <= 0) {\n throw new Error(\"--port must be a positive integer\");\n }\n\n return parsed;\n}\n\nfunction resolveTarget(target: string, cwd: string) {\n const absoluteTarget = path.resolve(cwd, target);\n const stat = fsSync.statSync(absoluteTarget);\n const targetDirectory = stat.isDirectory()\n ? absoluteTarget\n : path.dirname(absoluteTarget);\n let workspaceRoot = path.resolve(cwd);\n let rootPath = normalizeSlash(path.relative(workspaceRoot, targetDirectory));\n\n if (!rootPath || rootPath === \".\" || rootPath.startsWith(\"../\")) {\n workspaceRoot = path.dirname(targetDirectory);\n rootPath = path.basename(targetDirectory);\n }\n\n const filePath = stat.isFile()\n ? normalizeSlash(path.posix.join(rootPath, path.basename(absoluteTarget)))\n : undefined;\n\n return {\n absoluteTarget,\n isFile: stat.isFile(),\n workspaceRoot,\n rootPath: normalizeSlash(rootPath),\n filePath,\n };\n}\n\nasync function readManifest(\n manifestPath: string,\n): Promise<Record<string, unknown>> {\n try {\n const raw = await fs.readFile(manifestPath, \"utf8\");\n const parsed = JSON.parse(raw) as unknown;\n if (!isRecord(parsed)) {\n throw new Error(`${MANIFEST_FILE} must contain a JSON object`);\n }\n return parsed;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return { version: 1 };\n }\n throw error;\n }\n}\n\nfunction upsertContentManifest(\n manifest: Record<string, unknown>,\n rootPath: string,\n options: { filePath?: string; profile?: string },\n) {\n const next: Record<string, unknown> = {\n ...manifest,\n version: manifest.version ?? 1,\n };\n const apps = isRecord(next.apps) ? { ...next.apps } : {};\n const existingContent = isRecord(apps[CONTENT_APP_ID])\n ? { ...apps[CONTENT_APP_ID] }\n : {};\n const existingRoots = Array.isArray(existingContent.roots)\n ? existingContent.roots.filter(isRecord).map((root) => ({ ...root }))\n : [];\n const include = options.filePath ? [options.filePath] : undefined;\n const rootIndex = existingRoots.findIndex((entry) => entry.path === rootPath);\n const existingRoot = rootIndex === -1 ? undefined : existingRoots[rootIndex];\n const profile =\n options.profile && !existingRoot?.profile ? options.profile : undefined;\n const root = {\n ...existingRoot,\n name:\n typeof existingRoot?.name === \"string\"\n ? existingRoot.name\n : titleFromPath(rootPath),\n path: rootPath,\n kind: typeof existingRoot?.kind === \"string\" ? existingRoot.kind : \"docs\",\n extensions: Array.isArray(existingRoot?.extensions)\n ? existingRoot.extensions\n : [\".md\", \".mdx\"],\n ...(profile ? { profile } : {}),\n ...(include && rootIndex === -1 ? { include } : {}),\n };\n const roots =\n rootIndex === -1\n ? [...existingRoots, root]\n : existingRoots.map((entry, index) =>\n index === rootIndex ? { ...entry, ...root } : entry,\n );\n\n apps[CONTENT_APP_ID] = {\n ...existingContent,\n mode: \"local-files\",\n roots,\n hide: Array.isArray(existingContent.hide)\n ? existingContent.hide\n : [\"**/_*.md\", \"**/_*.mdx\"],\n };\n next.apps = apps;\n return next;\n}\n\nexport function findContentTemplateDir(cwd = process.cwd()) {\n const cliDir = path.dirname(fileURLToPath(import.meta.url));\n const candidates: string[] = [];\n let current = path.resolve(cwd);\n for (;;) {\n candidates.push(\n path.join(current, \"templates\", \"content\"),\n path.join(current, \"apps\", \"content\"),\n );\n const parent = path.dirname(current);\n if (parent === current) break;\n current = parent;\n }\n candidates.push(path.resolve(cliDir, \"../../../..\", \"templates/content\"));\n return (\n candidates.find((candidate) =>\n fsSync.existsSync(path.join(candidate, \"package.json\")),\n ) ?? null\n );\n}\n\nfunction launchUrl(port: number, filePath?: string) {\n const base = `http://127.0.0.1:${port}`;\n return filePath ? `${base}/page/${encodeLocalFileId(filePath)}` : base;\n}\n\nexport async function prepareContentLocalLaunch(options: {\n target: string;\n cwd?: string;\n port?: number;\n profile?: string;\n dryRun?: boolean;\n}): Promise<ContentLocalLaunchPlan> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const target = resolveTarget(options.target, cwd);\n const manifestPath = path.join(target.workspaceRoot, MANIFEST_FILE);\n const manifest = upsertContentManifest(\n await readManifest(manifestPath),\n target.rootPath,\n {\n filePath: target.filePath,\n profile: options.profile,\n },\n );\n const templateDir = findContentTemplateDir(cwd);\n if (!templateDir) {\n throw new Error(\n \"Could not find the Content app template. Run this from the framework checkout or a workspace that includes templates/content.\",\n );\n }\n\n if (!options.dryRun) {\n await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`);\n }\n\n return {\n workspaceRoot: target.workspaceRoot,\n manifestPath,\n rootPath: target.rootPath,\n filePath: target.filePath,\n url: launchUrl(options.port ?? DEFAULT_PORT, target.filePath),\n command: \"corepack\",\n args: [\n \"pnpm\",\n \"--dir\",\n templateDir,\n \"dev\",\n \"--host\",\n \"127.0.0.1\",\n \"--port\",\n String(options.port ?? DEFAULT_PORT),\n \"--strictPort\",\n ],\n env: {\n AGENT_NATIVE_MODE: \"local-files\",\n AGENT_NATIVE_MANIFEST_PATH: manifestPath,\n },\n manifest,\n };\n}\n\nfunction openBrowser(url: string) {\n const command =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"cmd\"\n : \"xdg-open\";\n const args = process.platform === \"win32\" ? [\"/c\", \"start\", \"\", url] : [url];\n const child = spawn(command, args, {\n detached: true,\n stdio: \"ignore\",\n shell: false,\n });\n child.unref();\n}\n\nfunction printHelp() {\n console.log(`Usage:\n agent-native content local-files <file-or-folder> [options]\n agent-native content <file-or-folder> [options]\n\nOptions:\n --profile <name> Local file profile, for example docs/no-bookkeeping\n --port <number> Dev server port (default ${DEFAULT_PORT})\n --open Open the target in the browser (default)\n --no-open Start the server without opening the browser\n --dry-run Print the launch plan without writing ${MANIFEST_FILE}\n --json Print the launch plan as JSON`);\n}\n\nexport async function runContentLocal(argv: string[]) {\n const parsed = parseContentLocalArgs(argv);\n if (parsed.help || !parsed.target) {\n printHelp();\n return parsed.target ? 0 : 1;\n }\n\n const plan = await prepareContentLocalLaunch({\n target: parsed.target,\n port: parsed.port,\n profile: parsed.profile ?? DEFAULT_PROFILE,\n dryRun: parsed.dryRun,\n });\n\n if (parsed.dryRun || parsed.json) {\n console.log(JSON.stringify(plan, null, 2));\n return 0;\n }\n\n console.log(`Content local files: ${plan.rootPath}`);\n console.log(`Manifest: ${plan.manifestPath}`);\n console.log(`Opening: ${plan.url}`);\n\n if (parsed.open) {\n setTimeout(() => openBrowser(plan.url), 1000).unref();\n }\n\n const child = spawn(plan.command, plan.args, {\n cwd: plan.workspaceRoot,\n stdio: \"inherit\",\n shell: process.platform === \"win32\",\n env: { ...process.env, ...plan.env },\n });\n\n return await new Promise<number>((resolve) => {\n child.on(\"exit\", (code) => resolve(code ?? 0));\n child.on(\"error\", (error) => {\n console.error(error.message);\n resolve(1);\n });\n for (const signal of [\"SIGINT\", \"SIGTERM\", \"SIGHUP\"] as const) {\n process.on(signal, () => {\n child.kill(signal);\n resolve(1);\n });\n }\n });\n}\n"]}
1
+ {"version":3,"file":"content-local.js","sourceRoot":"","sources":["../../src/cli/content-local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,cAAc,GAAG,SAAS,CAAC;AACjC,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAC1C,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAC9C,MAAM,8BAA8B,GAAG,eAAe,CAAC;AAyBvD,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,CACL,IAAI;SACD,QAAQ,CAAC,KAAK,CAAC;SACf,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC;SAClC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,MAAM,EAAE,GAAG,CA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GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE;QAC3C,GAAG,EAAE,IAAI,CAAC,aAAa;QACvB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO;QACnC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;KACrC,CAAC,CAAC;IAEH,OAAO,MAAM,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;QAC3C,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/C,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7B,OAAO,CAAC,CAAC,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;QACH,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAU,EAAE,CAAC;YAC9D,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;gBACtB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACnB,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport fsSync from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst CONTENT_APP_ID = \"content\";\nconst MANIFEST_FILE = \"agent-native.json\";\nconst DEFAULT_PORT = 8083;\nconst DEFAULT_PROFILE = \"docs/no-bookkeeping\";\nconst LOCAL_FOLDER_CONNECTION_PREFIX = \"local-folder:\";\n\nexport interface ContentLocalArgs {\n target?: string;\n open: boolean;\n port: number;\n profile?: string;\n dryRun: boolean;\n json: boolean;\n help: boolean;\n}\n\nexport interface ContentLocalLaunchPlan {\n workspaceRoot: string;\n manifestPath: string;\n rootPath: string;\n filePath?: string;\n connectionId: string;\n url: string;\n command: string;\n args: string[];\n env: Record<string, string>;\n manifest: Record<string, unknown>;\n}\n\nfunction normalizeSlash(value: string) {\n return value.replace(/\\\\/g, \"/\");\n}\n\nfunction titleFromPath(value: string) {\n return (\n path\n .basename(value)\n .replace(/\\.(mdx?|markdown)$/i, \"\")\n .replace(/[-_]+/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim()\n .replace(/\\b\\w/g, (char) => char.toUpperCase()) || \"Content\"\n );\n}\n\nfunction localFolderConnectionId(absoluteRootPath: string) {\n let canonicalRootPath = path.resolve(absoluteRootPath);\n try {\n canonicalRootPath = fsSync.realpathSync(canonicalRootPath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n const digest = createHash(\"sha256\")\n .update(canonicalRootPath)\n .digest(\"base64url\")\n .slice(0, 24);\n return `${LOCAL_FOLDER_CONNECTION_PREFIX}${digest}`;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction stringFlagValue(argv: string[], index: number, flag: string) {\n const value = argv[index + 1];\n if (!value || value.startsWith(\"-\")) {\n throw new Error(`${flag} requires a value`);\n }\n return value;\n}\n\nexport function parseContentLocalArgs(argv: string[]): ContentLocalArgs {\n const args = argv[0] === \"local-files\" ? argv.slice(1) : argv;\n const parsed: ContentLocalArgs = {\n open: true,\n port: DEFAULT_PORT,\n dryRun: false,\n json: false,\n help: false,\n };\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index]!;\n if (arg === \"help\" || arg === \"--help\" || arg === \"-h\") {\n parsed.help = true;\n } else if (arg === \"--open\") {\n parsed.open = true;\n } else if (arg === \"--no-open\") {\n parsed.open = false;\n } else if (arg === \"--dry-run\") {\n parsed.dryRun = true;\n } else if (arg === \"--json\") {\n parsed.json = true;\n } else if (arg === \"--port\") {\n parsed.port = Number.parseInt(stringFlagValue(args, index, arg), 10);\n index += 1;\n } else if (arg.startsWith(\"--port=\")) {\n parsed.port = Number.parseInt(arg.slice(\"--port=\".length), 10);\n } else if (arg === \"--profile\") {\n parsed.profile = stringFlagValue(args, index, arg);\n index += 1;\n } else if (arg.startsWith(\"--profile=\")) {\n parsed.profile = arg.slice(\"--profile=\".length);\n } else if (arg.startsWith(\"-\")) {\n throw new Error(`Unknown option: ${arg}`);\n } else if (!parsed.target) {\n parsed.target = arg;\n } else {\n throw new Error(`Unexpected argument: ${arg}`);\n }\n }\n\n if (!Number.isInteger(parsed.port) || parsed.port <= 0) {\n throw new Error(\"--port must be a positive integer\");\n }\n\n return parsed;\n}\n\nfunction resolveTarget(target: string, cwd: string) {\n const absoluteTarget = path.resolve(cwd, target);\n const stat = fsSync.statSync(absoluteTarget);\n const targetDirectory = stat.isDirectory()\n ? absoluteTarget\n : path.dirname(absoluteTarget);\n let workspaceRoot = path.resolve(cwd);\n let rootPath = normalizeSlash(path.relative(workspaceRoot, targetDirectory));\n\n if (!rootPath || rootPath === \".\" || rootPath.startsWith(\"../\")) {\n workspaceRoot = path.dirname(targetDirectory);\n rootPath = path.basename(targetDirectory);\n }\n\n const filePath = stat.isFile()\n ? normalizeSlash(path.posix.join(rootPath, path.basename(absoluteTarget)))\n : undefined;\n\n return {\n absoluteTarget,\n absoluteRootPath: targetDirectory,\n isFile: stat.isFile(),\n workspaceRoot,\n rootPath: normalizeSlash(rootPath),\n filePath,\n };\n}\n\nasync function readManifest(\n manifestPath: string,\n): Promise<Record<string, unknown>> {\n try {\n const raw = await fs.readFile(manifestPath, \"utf8\");\n const parsed = JSON.parse(raw) as unknown;\n if (!isRecord(parsed)) {\n throw new Error(`${MANIFEST_FILE} must contain a JSON object`);\n }\n return parsed;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return { version: 1 };\n }\n throw error;\n }\n}\n\nfunction upsertContentManifest(\n manifest: Record<string, unknown>,\n workspaceRoot: string,\n rootPath: string,\n options: {\n connectionId: string;\n filePath?: string;\n profile?: string;\n },\n) {\n const next: Record<string, unknown> = {\n ...manifest,\n version: manifest.version ?? 1,\n };\n const apps = isRecord(next.apps) ? { ...next.apps } : {};\n const existingContent = isRecord(apps[CONTENT_APP_ID])\n ? { ...apps[CONTENT_APP_ID] }\n : {};\n const existingRoots = Array.isArray(existingContent.roots)\n ? existingContent.roots.filter(isRecord).map((root) => ({ ...root }))\n : [];\n const include = options.filePath ? [options.filePath] : undefined;\n const rootIndex = existingRoots.findIndex((entry) => entry.path === rootPath);\n const existingRoot = rootIndex === -1 ? undefined : existingRoots[rootIndex];\n const profile =\n options.profile && !existingRoot?.profile ? options.profile : undefined;\n const root = {\n ...existingRoot,\n name:\n typeof existingRoot?.name === \"string\"\n ? existingRoot.name\n : titleFromPath(rootPath),\n path: rootPath,\n kind: typeof existingRoot?.kind === \"string\" ? existingRoot.kind : \"docs\",\n extensions: Array.isArray(existingRoot?.extensions)\n ? existingRoot.extensions\n : [\".md\", \".mdx\"],\n ...(profile ? { profile } : {}),\n ...(include && (rootIndex === -1 || Array.isArray(existingRoot?.include))\n ? {\n include: Array.from(\n new Set([\n ...(Array.isArray(existingRoot?.include)\n ? existingRoot.include.filter(\n (value): value is string => typeof value === \"string\",\n )\n : []),\n ...include,\n ]),\n ),\n }\n : {}),\n source: {\n ...(isRecord(existingRoot?.source) ? existingRoot.source : {}),\n type: \"local-folder\",\n connectionId: options.connectionId,\n truthPolicy: \"source_primary\",\n },\n };\n let roots =\n rootIndex === -1\n ? [...existingRoots, root]\n : existingRoots.map((entry, index) =>\n index === rootIndex ? { ...entry, ...root } : entry,\n );\n\n if (existingContent.mode === \"local-files\") {\n roots = roots.map((entry) => {\n if (entry === root || typeof entry.path !== \"string\") return entry;\n const existingSource = isRecord(entry.source) ? entry.source : {};\n return {\n ...entry,\n source: {\n ...existingSource,\n type: \"local-folder\",\n connectionId:\n typeof existingSource.connectionId === \"string\" &&\n existingSource.connectionId\n ? existingSource.connectionId\n : localFolderConnectionId(\n path.resolve(workspaceRoot, entry.path),\n ),\n truthPolicy:\n typeof existingSource.truthPolicy === \"string\"\n ? existingSource.truthPolicy\n : \"source_primary\",\n },\n };\n });\n }\n\n delete existingContent.mode;\n apps[CONTENT_APP_ID] = {\n ...existingContent,\n roots,\n hide: Array.isArray(existingContent.hide)\n ? existingContent.hide\n : [\"**/_*.md\", \"**/_*.mdx\"],\n };\n next.apps = apps;\n return next;\n}\n\nexport function findContentTemplateDir(cwd = process.cwd()) {\n const cliDir = path.dirname(fileURLToPath(import.meta.url));\n const candidates: string[] = [];\n let current = path.resolve(cwd);\n for (;;) {\n candidates.push(\n path.join(current, \"templates\", \"content\"),\n path.join(current, \"apps\", \"content\"),\n );\n const parent = path.dirname(current);\n if (parent === current) break;\n current = parent;\n }\n candidates.push(path.resolve(cliDir, \"../../../..\", \"templates/content\"));\n return (\n candidates.find((candidate) =>\n fsSync.existsSync(path.join(candidate, \"package.json\")),\n ) ?? null\n );\n}\n\nfunction launchUrl(port: number, connectionId: string, filePath?: string) {\n const params = new URLSearchParams({ connectionId });\n if (filePath) params.set(\"file\", filePath);\n return `http://127.0.0.1:${port}/local-files?${params.toString()}`;\n}\n\nexport async function prepareContentLocalLaunch(options: {\n target: string;\n cwd?: string;\n port?: number;\n profile?: string;\n dryRun?: boolean;\n}): Promise<ContentLocalLaunchPlan> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const target = resolveTarget(options.target, cwd);\n const manifestPath = path.join(target.workspaceRoot, MANIFEST_FILE);\n const connectionId = localFolderConnectionId(target.absoluteRootPath);\n const manifest = upsertContentManifest(\n await readManifest(manifestPath),\n target.workspaceRoot,\n target.rootPath,\n {\n connectionId,\n filePath: target.filePath,\n profile: options.profile,\n },\n );\n const templateDir = findContentTemplateDir(cwd);\n if (!templateDir) {\n throw new Error(\n \"Could not find the Content app template. Run this from the framework checkout or a workspace that includes templates/content.\",\n );\n }\n\n if (!options.dryRun) {\n await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`);\n }\n\n return {\n workspaceRoot: target.workspaceRoot,\n manifestPath,\n rootPath: target.rootPath,\n filePath: target.filePath,\n connectionId,\n url: launchUrl(options.port ?? DEFAULT_PORT, connectionId, target.filePath),\n command: \"corepack\",\n args: [\n \"pnpm\",\n \"--dir\",\n templateDir,\n \"dev\",\n \"--host\",\n \"127.0.0.1\",\n \"--port\",\n String(options.port ?? DEFAULT_PORT),\n \"--strictPort\",\n ],\n env: {\n AGENT_NATIVE_MANIFEST_PATH: manifestPath,\n },\n manifest,\n };\n}\n\nfunction openBrowser(url: string) {\n const command =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"cmd\"\n : \"xdg-open\";\n const args = process.platform === \"win32\" ? [\"/c\", \"start\", \"\", url] : [url];\n const child = spawn(command, args, {\n detached: true,\n stdio: \"ignore\",\n shell: false,\n });\n child.unref();\n}\n\nfunction printHelp() {\n console.log(`Usage:\n agent-native content local-files <file-or-folder> [options]\n agent-native content <file-or-folder> [options]\n\nOptions:\n --profile <name> Local folder profile, for example docs/no-bookkeeping\n --port <number> Dev server port (default ${DEFAULT_PORT})\n --open Open the target in the browser (default)\n --no-open Start the server without opening the browser\n --dry-run Print the launch plan without writing ${MANIFEST_FILE}\n --json Print the launch plan as JSON`);\n}\n\nexport async function runContentLocal(argv: string[]) {\n const parsed = parseContentLocalArgs(argv);\n if (parsed.help) {\n printHelp();\n return 0;\n }\n if (!parsed.target) {\n printHelp();\n return 1;\n }\n\n const plan = await prepareContentLocalLaunch({\n target: parsed.target,\n port: parsed.port,\n profile: parsed.profile ?? DEFAULT_PROFILE,\n dryRun: parsed.dryRun,\n });\n\n if (parsed.dryRun || parsed.json) {\n console.log(JSON.stringify(plan, null, 2));\n return 0;\n }\n\n console.log(`Content folder source: ${plan.rootPath}`);\n console.log(`Manifest: ${plan.manifestPath}`);\n console.log(`Opening: ${plan.url}`);\n\n if (parsed.open) {\n setTimeout(() => openBrowser(plan.url), 1000).unref();\n }\n\n const child = spawn(plan.command, plan.args, {\n cwd: plan.workspaceRoot,\n stdio: \"inherit\",\n shell: process.platform === \"win32\",\n env: { ...process.env, ...plan.env },\n });\n\n return await new Promise<number>((resolve) => {\n child.on(\"exit\", (code) => resolve(code ?? 0));\n child.on(\"error\", (error) => {\n console.error(error.message);\n resolve(1);\n });\n for (const signal of [\"SIGINT\", \"SIGTERM\", \"SIGHUP\"] as const) {\n process.on(signal, () => {\n child.kill(signal);\n resolve(1);\n });\n }\n });\n}\n"]}
package/dist/cli/index.js CHANGED
@@ -975,8 +975,8 @@ Usage:
975
975
  --with-github-action also writes the PR Visual
976
976
  Recap workflow into .github/workflows/.
977
977
  agent-native content local-files <file-or-folder>
978
- Launch Content in local-file mode for a local
979
- docs/content folder. Use --no-open, --port N,
978
+ Connect a local docs/content folder to normal
979
+ database-backed Content. Use --no-open, --port N,
980
980
  or --profile docs/no-bookkeeping as needed.
981
981
  agent-native design connect Start a localhost Design bridge for a running
982
982
  dev server. Use --url, --port, --root, or