@notis_ai/cli 0.2.18 → 0.2.19

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 (395) hide show
  1. package/README.md +542 -146
  2. package/bin/check-runtime.js +15 -0
  3. package/bin/notis.js +2 -0
  4. package/config/notis_app_design_rules.json +320 -0
  5. package/config/portal-route-roots.json +45 -0
  6. package/dist/agent-hooks/notis-agent-hook.mjs +42325 -18273
  7. package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -0
  8. package/dist/base-skills/notis-cli/SKILL.md +51 -280
  9. package/dist/base-skills/notis-cli/references/app-delivery.md +17 -0
  10. package/dist/base-skills/notis-cli/references/intelligence.md +94 -0
  11. package/dist/base-skills/notis-cli/references/native-databases.md +21 -0
  12. package/dist/base-skills/notis-cli/references/tool-examples.md +56 -0
  13. package/dist/base-skills/notis-cli/references/troubleshooting.md +67 -0
  14. package/dist/base-skills/notis-query/.notis-base-skill.json +1 -0
  15. package/dist/base-skills/notis-query/SKILL.md +35 -699
  16. package/dist/base-skills/notis-query/references/database-discovery.md +59 -0
  17. package/dist/base-skills/notis-query/references/documents.md +74 -0
  18. package/dist/base-skills/notis-query/references/query.md +76 -0
  19. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -0
  20. package/dist/base-skills/notis-spaces/SKILL.md +218 -0
  21. package/dist/base-skills/notis-spaces/references/architecture.md +116 -0
  22. package/dist/base-skills/notis-spaces/references/context.md +81 -0
  23. package/dist/base-skills/notis-spaces/references/design.md +141 -0
  24. package/dist/base-skills/notis-spaces/references/fixtures.md +29 -0
  25. package/dist/base-skills/notis-spaces/references/memory.md +58 -0
  26. package/dist/base-skills/notis-spaces/references/reading.md +73 -0
  27. package/dist/base-skills/notis-spaces/references/release.md +120 -0
  28. package/dist/base-skills/notis-spaces/references/reports.md +77 -0
  29. package/dist/base-skills/notis-spaces/references/sdk.md +273 -0
  30. package/dist/base-skills/notis-spaces/references/store.md +118 -0
  31. package/dist/base-skills/notis-spaces/references/troubleshooting.md +28 -0
  32. package/dist/base-skills/notis-spaces/references/views.md +229 -0
  33. package/{template/packages → dist}/sdk/package.json +9 -10
  34. package/dist/sdk/src/agentContext.ts +36 -0
  35. package/dist/sdk/src/bundleModule.ts +175 -0
  36. package/dist/sdk/src/components/Dialog.tsx +103 -0
  37. package/dist/sdk/src/components/DocumentEditor.tsx +113 -0
  38. package/dist/sdk/src/components/DocumentPage.tsx +184 -0
  39. package/{template/packages → dist}/sdk/src/components/Markdown.tsx +9 -3
  40. package/{template/packages → dist}/sdk/src/components/MarkdownEditor.tsx +26 -5
  41. package/{template/packages → dist}/sdk/src/components/MultiSelectActionBar.tsx +95 -12
  42. package/{template/packages → dist}/sdk/src/components/MultiSelectCheckbox.tsx +4 -2
  43. package/dist/sdk/src/components/NotisCommentBoundary.tsx +172 -0
  44. package/{template/packages → dist}/sdk/src/components/NotisSelectionBoundary.tsx +9 -5
  45. package/dist/sdk/src/components/RecordComponents.tsx +111 -0
  46. package/dist/sdk/src/components/Skeleton.tsx +38 -0
  47. package/dist/sdk/src/config.ts +31 -0
  48. package/{template/packages → dist}/sdk/src/documents.ts +21 -6
  49. package/dist/sdk/src/hooks/useAction.ts +28 -0
  50. package/dist/sdk/src/hooks/useAgentContext.ts +23 -0
  51. package/{template/packages → dist}/sdk/src/hooks/useBackend.ts +3 -2
  52. package/dist/sdk/src/hooks/useCloudComputer.ts +94 -0
  53. package/dist/sdk/src/hooks/useCloudComputerShell.ts +114 -0
  54. package/{template/packages → dist}/sdk/src/hooks/useCollectionInteractions.ts +157 -147
  55. package/dist/sdk/src/hooks/useDatabaseSchema.ts +50 -0
  56. package/{template/packages → dist}/sdk/src/hooks/useDatabaseSubscription.ts +2 -2
  57. package/dist/sdk/src/hooks/useDocument.ts +51 -0
  58. package/{template/packages → dist}/sdk/src/hooks/useDocuments.ts +25 -59
  59. package/{template/packages → dist}/sdk/src/hooks/useHandover.ts +7 -7
  60. package/dist/sdk/src/hooks/useLongPressSelection.ts +79 -0
  61. package/dist/sdk/src/hooks/useMarqueeSelection.ts +194 -0
  62. package/{template/packages → dist}/sdk/src/hooks/useMultiSelect.ts +2 -8
  63. package/dist/sdk/src/hooks/useNativeDocumentBody.ts +50 -0
  64. package/dist/sdk/src/hooks/useNativeDocuments.ts +143 -0
  65. package/{template/packages → dist}/sdk/src/hooks/useNotis.ts +6 -1
  66. package/dist/sdk/src/hooks/useNotisNavigation.ts +70 -0
  67. package/dist/sdk/src/hooks/useQuery.ts +81 -0
  68. package/dist/sdk/src/hooks/useToolQuery.ts +12 -0
  69. package/dist/sdk/src/hooks/useTopBarSearch.ts +102 -0
  70. package/dist/sdk/src/hooks/useTopBarTitleLeaf.ts +75 -0
  71. package/{template/packages → dist}/sdk/src/hooks/useUpsertDocument.ts +1 -1
  72. package/dist/sdk/src/hooks/useViewParams.ts +195 -0
  73. package/dist/sdk/src/hooks/useViewerReads.ts +129 -0
  74. package/{template/packages → dist}/sdk/src/index.ts +64 -1
  75. package/{template/packages → dist}/sdk/src/interactions/actions.ts +14 -1
  76. package/{template/packages → dist}/sdk/src/interactions/shortcuts.tsx +129 -23
  77. package/dist/sdk/src/interactions/visibility.ts +13 -0
  78. package/{template/packages → dist}/sdk/src/interactions.ts +5 -1
  79. package/dist/sdk/src/nativeData.ts +39 -0
  80. package/{template/packages → dist}/sdk/src/provider.tsx +9 -4
  81. package/dist/sdk/src/queryCache.ts +292 -0
  82. package/dist/sdk/src/queryErrors.ts +51 -0
  83. package/dist/sdk/src/runtime.ts +675 -0
  84. package/dist/sdk/src/runtimeModules.ts +33 -0
  85. package/dist/sdk/src/space.ts +442 -0
  86. package/dist/sdk/src/standardViewParams.ts +36 -0
  87. package/{template/packages → dist}/sdk/src/styles.css +81 -16
  88. package/dist/sdk/src/tailwind.ts +66 -0
  89. package/dist/sdk/src/ui/charts/RenderChartData.tsx +25 -0
  90. package/dist/sdk/src/ui/engine/core.ts +392 -0
  91. package/dist/sdk/src/ui/engine/dom.ts +183 -0
  92. package/dist/sdk/src/ui/engine/hooks.ts +195 -0
  93. package/dist/sdk/src/ui/engine/instance.ts +63 -0
  94. package/dist/sdk/src/ui/engine/keycapContext.ts +2 -0
  95. package/dist/sdk/src/ui/engine/registry.ts +262 -0
  96. package/dist/sdk/src/ui/engine/types.ts +62 -0
  97. package/dist/sdk/src/ui/icons.tsx +91 -0
  98. package/dist/sdk/src/ui/util.ts +83 -0
  99. package/dist/sdk/src/viewPeriod.ts +26 -0
  100. package/dist/sdk/src/vite.ts +92 -0
  101. package/dist/sdk/src/words/actions.ts +295 -0
  102. package/dist/sdk/src/words/clashes.ts +158 -0
  103. package/dist/sdk/src/words/format.ts +136 -0
  104. package/dist/sdk/src/words/index.ts +13 -0
  105. package/dist/sdk/src/words/keymap.ts +72 -0
  106. package/dist/sdk/src/words/keys.ts +297 -0
  107. package/dist/sdk/src/words/shell.ts +46 -0
  108. package/dist/sdk/src/words/types.ts +65 -0
  109. package/dist/skill-sync/index.js +832 -151
  110. package/dist/skill-sync/index.js.map +4 -4
  111. package/dist/skill-sync-worker.mjs +3941 -0
  112. package/dist/space-harness/host.js +1460 -0
  113. package/dist/space-sdk/dist/chunk-ZSN57ATH.js +5 -0
  114. package/dist/space-sdk/dist/index.js +15 -0
  115. package/dist/space-sdk/dist/ui.js +18 -0
  116. package/dist/space-sdk/package.json +33 -0
  117. package/dist/space-sdk/src/agentContext.d.ts +36 -0
  118. package/dist/space-sdk/src/components/Dialog.d.ts +20 -0
  119. package/dist/space-sdk/src/components/DocumentEditor.d.ts +46 -0
  120. package/dist/space-sdk/src/components/DocumentPage.d.ts +53 -0
  121. package/dist/space-sdk/src/components/Markdown.d.ts +18 -0
  122. package/dist/space-sdk/src/components/MarkdownEditor.d.ts +11 -0
  123. package/dist/space-sdk/src/components/MultiSelectActionBar.d.ts +31 -0
  124. package/dist/space-sdk/src/components/MultiSelectCheckbox.d.ts +14 -0
  125. package/dist/space-sdk/src/components/MultiSelectDragOverlay.d.ts +8 -0
  126. package/dist/space-sdk/src/components/NotisCommentBoundary.d.ts +36 -0
  127. package/dist/space-sdk/src/components/NotisSelectionBoundary.d.ts +16 -0
  128. package/dist/space-sdk/src/components/RecordComponents.d.ts +64 -0
  129. package/dist/space-sdk/src/components/ShortcutHints.d.ts +12 -0
  130. package/dist/space-sdk/src/components/Skeleton.d.ts +23 -0
  131. package/dist/space-sdk/src/config.ts +31 -0
  132. package/dist/space-sdk/src/documents.d.ts +59 -0
  133. package/dist/space-sdk/src/hooks/useAction.d.ts +8 -0
  134. package/dist/space-sdk/src/hooks/useActiveResource.d.ts +3 -0
  135. package/dist/space-sdk/src/hooks/useAgentContext.d.ts +7 -0
  136. package/dist/space-sdk/src/hooks/useBackend.d.ts +23 -0
  137. package/dist/space-sdk/src/hooks/useCloudComputer.d.ts +45 -0
  138. package/dist/space-sdk/src/hooks/useCloudComputerShell.d.ts +49 -0
  139. package/dist/space-sdk/src/hooks/useCollectionInteractions.d.ts +118 -0
  140. package/dist/space-sdk/src/hooks/useDatabaseSchema.d.ts +14 -0
  141. package/dist/space-sdk/src/hooks/useDatabaseSubscription.d.ts +26 -0
  142. package/dist/space-sdk/src/hooks/useDocument.d.ts +22 -0
  143. package/dist/space-sdk/src/hooks/useDocuments.d.ts +31 -0
  144. package/dist/space-sdk/src/hooks/useHandover.d.ts +43 -0
  145. package/dist/space-sdk/src/hooks/useLongPressSelection.d.ts +9 -0
  146. package/dist/space-sdk/src/hooks/useMarqueeSelection.d.ts +57 -0
  147. package/dist/space-sdk/src/hooks/useMultiSelect.d.ts +51 -0
  148. package/dist/space-sdk/src/hooks/useNativeDocumentBody.d.ts +24 -0
  149. package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +55 -0
  150. package/dist/space-sdk/src/hooks/useNotis.d.ts +25 -0
  151. package/dist/space-sdk/src/hooks/useNotisNavigation.d.ts +33 -0
  152. package/dist/space-sdk/src/hooks/useQuery.d.ts +22 -0
  153. package/dist/space-sdk/src/hooks/useTool.d.ts +20 -0
  154. package/dist/space-sdk/src/hooks/useToolQuery.d.ts +3 -0
  155. package/dist/space-sdk/src/hooks/useTools.d.ts +15 -0
  156. package/dist/space-sdk/src/hooks/useTopBarSearch.d.ts +48 -0
  157. package/dist/space-sdk/src/hooks/useTopBarTitleLeaf.d.ts +24 -0
  158. package/dist/space-sdk/src/hooks/useUpsertDocument.d.ts +27 -0
  159. package/dist/space-sdk/src/hooks/useViewParams.d.ts +76 -0
  160. package/dist/space-sdk/src/hooks/useViewerReads.d.ts +38 -0
  161. package/dist/space-sdk/src/index.d.ts +98 -0
  162. package/dist/space-sdk/src/interactions/actions.d.ts +33 -0
  163. package/dist/space-sdk/src/interactions/shortcuts.d.ts +42 -0
  164. package/dist/space-sdk/src/interactions/visibility.d.ts +2 -0
  165. package/dist/space-sdk/src/nativeData.d.ts +66 -0
  166. package/dist/space-sdk/src/provider.d.ts +17 -0
  167. package/dist/space-sdk/src/queryCache.d.ts +45 -0
  168. package/dist/space-sdk/src/queryErrors.ts +51 -0
  169. package/dist/space-sdk/src/runtime.d.ts +615 -0
  170. package/dist/space-sdk/src/runtimeModules.ts +33 -0
  171. package/dist/space-sdk/src/space.ts +442 -0
  172. package/dist/space-sdk/src/standardViewParams.d.ts +15 -0
  173. package/dist/space-sdk/src/tailwind-candidates.d.ts +3418 -0
  174. package/dist/space-sdk/src/tailwind.ts +66 -0
  175. package/dist/space-sdk/src/ui/actions/ActionToast.d.ts +15 -0
  176. package/dist/space-sdk/src/ui/actions/actionWords.d.ts +16 -0
  177. package/dist/space-sdk/src/ui/actions/index.d.ts +7 -0
  178. package/dist/space-sdk/src/ui/actions/useActions.d.ts +69 -0
  179. package/dist/space-sdk/src/ui/actions/useToast.d.ts +41 -0
  180. package/dist/space-sdk/src/ui/blocks/Tabs.d.ts +139 -0
  181. package/dist/space-sdk/src/ui/blocks/blocks.d.ts +217 -0
  182. package/dist/space-sdk/src/ui/blocks/index.d.ts +4 -0
  183. package/dist/space-sdk/src/ui/board/BoardView.d.ts +36 -0
  184. package/dist/space-sdk/src/ui/board/boardModel.d.ts +46 -0
  185. package/dist/space-sdk/src/ui/board/boardWords.d.ts +9 -0
  186. package/dist/space-sdk/src/ui/board/index.d.ts +5 -0
  187. package/dist/space-sdk/src/ui/calendar/CalendarView.d.ts +49 -0
  188. package/dist/space-sdk/src/ui/calendar/DayPicker.d.ts +23 -0
  189. package/dist/space-sdk/src/ui/calendar/calendarMath.d.ts +81 -0
  190. package/dist/space-sdk/src/ui/charts/Chart.d.ts +203 -0
  191. package/dist/space-sdk/src/ui/charts/ChartTable.d.ts +37 -0
  192. package/dist/space-sdk/src/ui/charts/RenderChartData.d.ts +16 -0
  193. package/dist/space-sdk/src/ui/charts/StatRow.d.ts +59 -0
  194. package/dist/space-sdk/src/ui/charts/chartData.d.ts +84 -0
  195. package/dist/space-sdk/src/ui/comments/CommentPane.d.ts +58 -0
  196. package/dist/space-sdk/src/ui/comments/commentModel.d.ts +157 -0
  197. package/dist/space-sdk/src/ui/comments/commentWords.d.ts +60 -0
  198. package/dist/space-sdk/src/ui/comments/index.d.ts +4 -0
  199. package/dist/space-sdk/src/ui/comments/useComments.d.ts +146 -0
  200. package/dist/space-sdk/src/ui/engine/HelpSheet.d.ts +12 -0
  201. package/dist/space-sdk/src/ui/engine/KeyboardEngine.d.ts +27 -0
  202. package/dist/space-sdk/src/ui/engine/core.d.ts +73 -0
  203. package/dist/space-sdk/src/ui/engine/hooks.d.ts +64 -0
  204. package/dist/space-sdk/src/ui/engine/index.d.ts +14 -0
  205. package/dist/space-sdk/src/ui/engine/instance.d.ts +21 -0
  206. package/dist/space-sdk/src/ui/engine/keycapContext.d.ts +2 -0
  207. package/dist/space-sdk/src/ui/engine/registry.d.ts +77 -0
  208. package/dist/space-sdk/src/ui/engine/step.d.ts +11 -0
  209. package/dist/space-sdk/src/ui/engine/types.d.ts +54 -0
  210. package/dist/space-sdk/src/ui/fields/fieldWords.d.ts +56 -0
  211. package/dist/space-sdk/src/ui/fields/fields.d.ts +162 -0
  212. package/dist/space-sdk/src/ui/fields/index.d.ts +5 -0
  213. package/dist/space-sdk/src/ui/fields/useFieldDraft.d.ts +22 -0
  214. package/dist/space-sdk/src/ui/gallery/AttachmentGallery.d.ts +53 -0
  215. package/dist/space-sdk/src/ui/gallery/ImageViewer.d.ts +27 -0
  216. package/dist/space-sdk/src/ui/gallery/galleryWords.d.ts +95 -0
  217. package/dist/space-sdk/src/ui/gallery/index.d.ts +5 -0
  218. package/dist/space-sdk/src/ui/icons.d.ts +13 -0
  219. package/dist/space-sdk/src/ui/index.d.ts +54 -0
  220. package/dist/space-sdk/src/ui/keycap/Keycap.d.ts +22 -0
  221. package/dist/space-sdk/src/ui/keycap/index.d.ts +2 -0
  222. package/dist/space-sdk/src/ui/layout/Panels.d.ts +50 -0
  223. package/dist/space-sdk/src/ui/layout/chatPanelEdge.d.ts +77 -0
  224. package/dist/space-sdk/src/ui/layout/index.d.ts +5 -0
  225. package/dist/space-sdk/src/ui/layout/panelMath.d.ts +91 -0
  226. package/dist/space-sdk/src/ui/list/ListReader.d.ts +380 -0
  227. package/dist/space-sdk/src/ui/list/Row.d.ts +145 -0
  228. package/dist/space-sdk/src/ui/list/SelectionBar.d.ts +65 -0
  229. package/dist/space-sdk/src/ui/list/index.d.ts +14 -0
  230. package/dist/space-sdk/src/ui/list/rowState.d.ts +22 -0
  231. package/dist/space-sdk/src/ui/list/useListKeys.d.ts +89 -0
  232. package/dist/space-sdk/src/ui/list/useReorder.d.ts +86 -0
  233. package/dist/space-sdk/src/ui/list/useSelection.d.ts +90 -0
  234. package/dist/space-sdk/src/ui/open/OpenAsMenu.d.ts +15 -0
  235. package/dist/space-sdk/src/ui/open/index.d.ts +6 -0
  236. package/dist/space-sdk/src/ui/open/openModeStore.d.ts +39 -0
  237. package/dist/space-sdk/src/ui/open/useOpenMode.d.ts +17 -0
  238. package/dist/space-sdk/src/ui/overlay/Menu.d.ts +88 -0
  239. package/dist/space-sdk/src/ui/overlay/Popover.d.ts +28 -0
  240. package/dist/space-sdk/src/ui/overlay/Tooltip.d.ts +19 -0
  241. package/dist/space-sdk/src/ui/overlay/index.d.ts +9 -0
  242. package/dist/space-sdk/src/ui/overlay/layerRoot.d.ts +24 -0
  243. package/dist/space-sdk/src/ui/overlay/position.d.ts +31 -0
  244. package/dist/space-sdk/src/ui/period/PeriodPicker.d.ts +30 -0
  245. package/dist/space-sdk/src/ui/period/dateFormat.d.ts +50 -0
  246. package/dist/space-sdk/src/ui/period/dateWords.d.ts +88 -0
  247. package/dist/space-sdk/src/ui/period/periods.d.ts +70 -0
  248. package/dist/space-sdk/src/ui/period/usePeriod.d.ts +23 -0
  249. package/dist/space-sdk/src/ui/present/index.d.ts +3 -0
  250. package/dist/space-sdk/src/ui/present/presentWords.d.ts +27 -0
  251. package/dist/space-sdk/src/ui/present/screens.d.ts +36 -0
  252. package/dist/space-sdk/src/ui/present/useAudienceScreen.d.ts +38 -0
  253. package/dist/space-sdk/src/ui/styles.d.ts +21 -0
  254. package/dist/space-sdk/src/ui/timeline/TimelineView.d.ts +44 -0
  255. package/dist/space-sdk/src/ui/timeline/timelineMath.d.ts +123 -0
  256. package/dist/space-sdk/src/viewPeriod.d.ts +8 -0
  257. package/dist/space-sdk/src/vite.ts +92 -0
  258. package/dist/space-sdk/src/words/actions.ts +295 -0
  259. package/dist/space-sdk/src/words/clashes.ts +158 -0
  260. package/dist/space-sdk/src/words/format.ts +136 -0
  261. package/dist/space-sdk/src/words/index.ts +13 -0
  262. package/dist/space-sdk/src/words/keymap.ts +72 -0
  263. package/dist/space-sdk/src/words/keys.ts +297 -0
  264. package/dist/space-sdk/src/words/shell.ts +46 -0
  265. package/dist/space-sdk/src/words/types.ts +65 -0
  266. package/dist/view-renderer/dist/host.css +1 -0
  267. package/dist/view-renderer/dist/host.js +2374 -0
  268. package/dist/view-renderer/dist/theme.css +73 -0
  269. package/dist/view-renderer/src/dom.js +212 -0
  270. package/dist/view-renderer/src/errors.js +8 -0
  271. package/dist/view-renderer/src/host.tsx +250 -0
  272. package/dist/view-renderer/src/index.js +4 -0
  273. package/dist/view-renderer/src/png.js +213 -0
  274. package/dist/view-renderer/src/pool.js +110 -0
  275. package/dist/view-renderer/src/remote-broker.js +59 -0
  276. package/dist/view-renderer/src/renderer.js +271 -0
  277. package/package.json +21 -11
  278. package/skills/notis-cli/AGENT_INSTRUCTIONS.md +63 -12
  279. package/skills/notis-onboarding/BRIEF.md +14 -9
  280. package/skills/notis-query/cli.md +1 -1
  281. package/skills/notis-spaces/cli.md +540 -0
  282. package/src/cli.js +8 -8
  283. package/src/command-specs/agents.js +121 -8
  284. package/src/command-specs/auth.js +3 -3
  285. package/src/command-specs/diagnostics.js +97 -20
  286. package/src/command-specs/documents.js +158 -0
  287. package/src/command-specs/files.js +29 -0
  288. package/src/command-specs/handover.js +331 -79
  289. package/src/command-specs/helpers.js +50 -40
  290. package/src/command-specs/index.js +14 -5
  291. package/src/command-specs/meta.js +38 -9
  292. package/src/command-specs/onboarding.js +1 -1
  293. package/src/command-specs/profile.js +42 -1
  294. package/src/command-specs/skills.js +314 -9
  295. package/src/command-specs/smoke.js +16 -4
  296. package/src/command-specs/spaces.js +783 -0
  297. package/src/command-specs/tools.js +118 -21
  298. package/src/command-specs/version-history.js +20 -0
  299. package/src/command-specs/views.js +69 -0
  300. package/src/runtime/agent-browser.js +178 -267
  301. package/src/runtime/agent-setup.js +172 -13
  302. package/src/runtime/app-boundary-validator.js +338 -2
  303. package/src/runtime/app-data-literals.js +82 -0
  304. package/src/runtime/app-platform.js +750 -1570
  305. package/src/runtime/auth-recovery.js +17 -0
  306. package/src/runtime/base-skills.d.ts +11 -0
  307. package/src/runtime/base-skills.js +100 -3
  308. package/src/runtime/computer-identity.d.ts +30 -0
  309. package/src/runtime/computer-identity.js +151 -0
  310. package/src/runtime/config-lock.js +135 -0
  311. package/src/runtime/confined-space-build.js +74 -0
  312. package/src/runtime/confined-space-verify.js +49 -0
  313. package/src/runtime/delegated-context.js +5 -21
  314. package/src/runtime/native-record-files.js +47 -0
  315. package/src/runtime/oauth.js +342 -31
  316. package/src/runtime/profiles.js +19 -112
  317. package/src/runtime/retired-sdk-files.js +24 -0
  318. package/src/runtime/retry.js +150 -0
  319. package/src/runtime/skill-sync/cloud-client.ts +33 -8
  320. package/src/runtime/skill-sync/index.ts +443 -106
  321. package/src/runtime/skill-sync/local-scanner.ts +248 -32
  322. package/src/runtime/skill-sync/native-identity.ts +102 -0
  323. package/src/runtime/skill-sync/native-plan.ts +70 -0
  324. package/src/runtime/skill-sync/symlink-manager.ts +66 -16
  325. package/src/runtime/skill-sync/sync-plan.ts +34 -2
  326. package/src/runtime/skill-sync/types.ts +54 -0
  327. package/src/runtime/skill-sync/write-cloud-skill.ts +4 -4
  328. package/src/runtime/skill-sync-service.js +109 -0
  329. package/src/runtime/source-root.js +32 -0
  330. package/src/runtime/space-collection-scaffold.js +107 -0
  331. package/src/runtime/space-database-structures.js +229 -0
  332. package/src/runtime/space-fixture-broker.js +68 -0
  333. package/src/runtime/space-lock.js +337 -0
  334. package/src/runtime/space-platform.js +133 -0
  335. package/src/runtime/space-source.js +290 -0
  336. package/src/runtime/space-test-server.js +354 -0
  337. package/src/runtime/space-verification.js +94 -0
  338. package/src/runtime/space-verify-browser-worker.js +51 -0
  339. package/src/runtime/space-view-manifest.js +368 -0
  340. package/src/runtime/sync-skills.d.ts +5 -1
  341. package/src/runtime/sync-skills.js +11 -2
  342. package/src/runtime/tool-confirmation.js +138 -0
  343. package/src/runtime/transport.js +118 -24
  344. package/src/runtime/upsell.js +219 -0
  345. package/src/runtime/view-render.js +49 -0
  346. package/src/skill-sync-worker-entry.js +2 -0
  347. package/src/skill-sync-worker.js +114 -0
  348. package/src/space-harness-host.ts +122 -0
  349. package/template/.harness/index.html.tmpl +9 -352
  350. package/template/app/globals.css +29 -3
  351. package/template/app/layout.tsx +2 -6
  352. package/template/components/ui/badge.tsx +7 -4
  353. package/template/components/ui/button.tsx +1 -1
  354. package/template/components/ui/native-select.tsx +24 -0
  355. package/template/notis.config.ts +4 -36
  356. package/template/package-lock.json +1800 -1867
  357. package/template/package.json +16 -14
  358. package/template/postcss.config.mjs +1 -1
  359. package/template/tailwind.config.ts +1 -6
  360. package/template/tsconfig.json +1 -0
  361. package/template/vite.config.ts +2 -2
  362. package/dist/base-skills/notis-apps/SKILL.md +0 -613
  363. package/skills/notis-apps/cli.md +0 -285
  364. package/src/command-specs/apps.js +0 -3011
  365. package/src/runtime/app-changelog.js +0 -79
  366. package/src/runtime/app-dev-consumers.js +0 -154
  367. package/src/runtime/app-dev-host-lock.js +0 -80
  368. package/src/runtime/app-dev-process-identity.js +0 -111
  369. package/src/runtime/app-dev-roots.js +0 -284
  370. package/src/runtime/app-dev-server.js +0 -1140
  371. package/src/runtime/app-dev-sessions.js +0 -185
  372. package/src/runtime/app-registry-scaffolds.js +0 -367
  373. package/src/runtime/assets/store-screenshot-dark.png +0 -0
  374. package/src/runtime/cli-mode.generated.js +0 -5
  375. package/src/runtime/cli-mode.js +0 -34
  376. package/src/runtime/store-screenshot.js +0 -143
  377. package/template/CHANGELOG.md +0 -5
  378. package/template/app/page.tsx +0 -60
  379. package/template/components/ui/card.tsx +0 -56
  380. package/template/packages/sdk/src/components/DocumentEditor.tsx +0 -103
  381. package/template/packages/sdk/src/config.ts +0 -259
  382. package/template/packages/sdk/src/hooks/useCloudComputer.ts +0 -97
  383. package/template/packages/sdk/src/hooks/useDatabaseSchema.ts +0 -85
  384. package/template/packages/sdk/src/hooks/useDocument.ts +0 -78
  385. package/template/packages/sdk/src/hooks/useNotisNavigation.ts +0 -52
  386. package/template/packages/sdk/src/hooks/useTopBarSearch.ts +0 -73
  387. package/template/packages/sdk/src/runtime.ts +0 -439
  388. package/template/packages/sdk/src/vite.ts +0 -56
  389. package/template/packages/sdk/tsconfig.json +0 -15
  390. /package/{template/packages → dist}/sdk/src/components/MultiSelectDragOverlay.tsx +0 -0
  391. /package/{template/packages → dist}/sdk/src/components/ShortcutHints.tsx +0 -0
  392. /package/{template/packages → dist}/sdk/src/hooks/useActiveResource.ts +0 -0
  393. /package/{template/packages → dist}/sdk/src/hooks/useTool.ts +0 -0
  394. /package/{template/packages → dist}/sdk/src/hooks/useTools.ts +0 -0
  395. /package/{template/packages → dist}/sdk/src/ui.ts +0 -0
@@ -1,185 +0,0 @@
1
- import { randomUUID } from 'node:crypto';
2
- import { existsSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
3
- import { dirname, join } from 'node:path';
4
- import { CONFIG_DIR } from './profiles.js';
5
-
6
- export const DEFAULT_APP_DEV_SESSIONS_FILE = join(CONFIG_DIR, 'app-dev-sessions.json');
7
- export const APP_DEV_SESSIONS_FILE = DEFAULT_APP_DEV_SESSIONS_FILE;
8
- export const APP_DEV_SESSIONS_VERSION = 1;
9
- const REGISTRY_LOCK_TIMEOUT_MS = 5_000;
10
- const registryLockWait = new Int32Array(new SharedArrayBuffer(4));
11
-
12
- function readRegistryLockOwner(lockPath) {
13
- try {
14
- return readFileSync(join(lockPath, 'owner'), 'utf8').trim();
15
- } catch {
16
- return null;
17
- }
18
- }
19
-
20
- function withRegistryLock(filePath, callback) {
21
- mkdirSync(dirname(filePath), { recursive: true, mode: 0o700 });
22
- const lockPath = `${filePath}.lock`;
23
- const ownerId = `${process.pid}.${randomUUID()}`;
24
- const startedAt = Date.now();
25
- while (true) {
26
- try {
27
- mkdirSync(lockPath, { mode: 0o700 });
28
- try {
29
- writeFileSync(join(lockPath, 'owner'), ownerId, { mode: 0o600 });
30
- } catch (error) {
31
- rmSync(lockPath, { recursive: true, force: true });
32
- throw error;
33
- }
34
- break;
35
- } catch (error) {
36
- if (error?.code !== 'EEXIST') throw error;
37
- try {
38
- const lockStat = lstatSync(lockPath);
39
- if (lockStat.isSymbolicLink() || !lockStat.isDirectory()) {
40
- throw new Error(`Refusing unsafe app development registry lock: ${lockPath}`);
41
- }
42
- } catch (statError) {
43
- if (statError?.code === 'ENOENT') continue;
44
- throw statError;
45
- }
46
- if (Date.now() - startedAt >= REGISTRY_LOCK_TIMEOUT_MS) {
47
- throw new Error(
48
- `Timed out waiting for app development registry lock: ${filePath}. `
49
- + `If no app development process is running, remove the orphaned lock: ${lockPath}`,
50
- );
51
- }
52
- Atomics.wait(registryLockWait, 0, 0, 10);
53
- }
54
- }
55
- try {
56
- return callback();
57
- } finally {
58
- try {
59
- if (readRegistryLockOwner(lockPath) === ownerId) {
60
- rmSync(lockPath, { recursive: true, force: true });
61
- }
62
- } catch {
63
- // Never remove or disrupt a lock that no longer belongs to this writer.
64
- }
65
- }
66
- }
67
-
68
- export function getAppDevSessionsFile(filePath) {
69
- if (filePath) {
70
- return filePath;
71
- }
72
- return DEFAULT_APP_DEV_SESSIONS_FILE;
73
- }
74
-
75
- function normalizeSessions(raw) {
76
- if (!raw || typeof raw !== 'object' || !Array.isArray(raw.sessions)) {
77
- return [];
78
- }
79
- return raw.sessions
80
- .filter((session) =>
81
- session &&
82
- typeof session === 'object' &&
83
- typeof session.sessionId === 'string' &&
84
- typeof session.appId === 'string' &&
85
- typeof session.bundleBaseUrl === 'string',
86
- )
87
- .map((session) => {
88
- if (typeof session.targetAppId === 'string' && session.targetAppId.trim()) {
89
- return { ...session, targetAppId: session.targetAppId.trim() };
90
- }
91
- const { targetAppId: _targetAppId, ...rest } = session;
92
- return rest;
93
- });
94
- }
95
-
96
- export function readAppDevSessions(filePath) {
97
- const resolvedFilePath = getAppDevSessionsFile(filePath);
98
- if (!existsSync(resolvedFilePath)) {
99
- return { version: APP_DEV_SESSIONS_VERSION, sessions: [] };
100
- }
101
- try {
102
- const raw = JSON.parse(readFileSync(resolvedFilePath, 'utf8'));
103
- return {
104
- version: APP_DEV_SESSIONS_VERSION,
105
- sessions: normalizeSessions(raw),
106
- };
107
- } catch {
108
- return { version: APP_DEV_SESSIONS_VERSION, sessions: [] };
109
- }
110
- }
111
-
112
- function writeAppDevSessionsUnlocked(registry, filePath) {
113
- const resolvedFilePath = getAppDevSessionsFile(filePath);
114
- mkdirSync(dirname(resolvedFilePath), { recursive: true, mode: 0o700 });
115
- const normalized = {
116
- version: APP_DEV_SESSIONS_VERSION,
117
- sessions: normalizeSessions(registry),
118
- };
119
- const tempPath = `${resolvedFilePath}.${process.pid}.${randomUUID()}.tmp`;
120
- writeFileSync(tempPath, JSON.stringify(normalized, null, 2), { mode: 0o600 });
121
- renameSync(tempPath, resolvedFilePath);
122
- return normalized;
123
- }
124
-
125
- export function writeAppDevSessions(registry, filePath) {
126
- const resolvedFilePath = getAppDevSessionsFile(filePath);
127
- return withRegistryLock(resolvedFilePath, () => writeAppDevSessionsUnlocked(registry, resolvedFilePath));
128
- }
129
-
130
- export function upsertAppDevSessions(sessions, filePath) {
131
- const nextSessions = Array.isArray(sessions) ? sessions : [sessions];
132
- const resolvedFilePath = getAppDevSessionsFile(filePath);
133
- return withRegistryLock(resolvedFilePath, () => {
134
- const registry = readAppDevSessions(resolvedFilePath);
135
- const keys = new Set(nextSessions.map((session) => `${session.sessionId}:${session.appId}`));
136
- registry.sessions = [
137
- ...registry.sessions.filter((session) => !keys.has(`${session.sessionId}:${session.appId}`)),
138
- ...nextSessions,
139
- ];
140
- return writeAppDevSessionsUnlocked(registry, resolvedFilePath);
141
- });
142
- }
143
-
144
- export function heartbeatAppDevSession(sessionId, lastHeartbeatAt, filePath) {
145
- const resolvedFilePath = getAppDevSessionsFile(filePath);
146
- return withRegistryLock(resolvedFilePath, () => {
147
- const registry = readAppDevSessions(resolvedFilePath);
148
- registry.sessions = registry.sessions.map((session) =>
149
- session.sessionId === sessionId ? { ...session, lastHeartbeatAt } : session,
150
- );
151
- return writeAppDevSessionsUnlocked(registry, resolvedFilePath);
152
- });
153
- }
154
-
155
- export function linkAppDevSessionTarget({ sessionId, appId, devSlug, targetAppId, lastHeartbeatAt = new Date().toISOString() }, filePath) {
156
- const target = typeof targetAppId === 'string' ? targetAppId.trim() : '';
157
- if (!target) {
158
- return readAppDevSessions(filePath);
159
- }
160
- const resolvedFilePath = getAppDevSessionsFile(filePath);
161
- const result = withRegistryLock(resolvedFilePath, () => {
162
- const registry = readAppDevSessions(resolvedFilePath);
163
- registry.sessions = registry.sessions.map((session) => {
164
- const hasSelector = Boolean(appId || devSlug);
165
- const matchesSession = !sessionId || session.sessionId === sessionId;
166
- const matchesApp = !appId || session.appId === appId;
167
- const matchesSlug = !devSlug || session.devSlug === devSlug;
168
- if ((!hasSelector && !sessionId) || !matchesSession || !matchesApp || !matchesSlug) return session;
169
- const linked = { ...session, targetAppId: target, lastHeartbeatAt };
170
- return linked;
171
- });
172
- return writeAppDevSessionsUnlocked(registry, resolvedFilePath);
173
- });
174
- return result;
175
- }
176
-
177
- export function removeAppDevSession(sessionId, filePath) {
178
- const resolvedFilePath = getAppDevSessionsFile(filePath);
179
- const result = withRegistryLock(resolvedFilePath, () => {
180
- const registry = readAppDevSessions(resolvedFilePath);
181
- registry.sessions = registry.sessions.filter((session) => session.sessionId !== sessionId);
182
- return writeAppDevSessionsUnlocked(registry, resolvedFilePath);
183
- });
184
- return result;
185
- }
@@ -1,367 +0,0 @@
1
- /**
2
- * Store-backed scaffold catalog for the Notis CLI.
3
- *
4
- * Every app published to the public Store lives with its full source in the
5
- * public registry repository (github.com/mindtheflo/notis-apps, one app per
6
- * `apps/<slug>/` directory). That repository IS the scaffold catalog:
7
- * `apps scaffolds list` reads the published listings and `apps init --from
8
- * <slug>` downloads the listed app's source. Publishing an app automatically
9
- * makes it a scaffold — the CLI bundles nothing besides the bare template.
10
- */
11
-
12
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
13
- import { tmpdir } from 'node:os';
14
- import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
15
-
16
- import { usageError } from './errors.js';
17
-
18
- const DEFAULT_REGISTRY_REPO = 'mindtheflo/notis-apps';
19
- const DEFAULT_REGISTRY_REF = 'main';
20
- // How many registry files to download at once when materializing a scaffold.
21
- const DOWNLOAD_CONCURRENCY = 4;
22
- const MAX_SCAFFOLD_FILES = 2_000;
23
- const MAX_SCAFFOLD_FILE_BYTES = 5 * 1024 * 1024;
24
- const MAX_SCAFFOLD_TOTAL_BYTES = 50 * 1024 * 1024;
25
- const MAX_CATALOG_ENTRIES = 1_000;
26
- const MAX_REGISTRY_COMMIT_BYTES = 2 * 1024 * 1024;
27
- const MAX_REGISTRY_API_BYTES = 10 * 1024 * 1024;
28
- const MAX_CATALOG_METADATA_BYTES = 1024 * 1024;
29
- const MAX_CATALOG_TOTAL_BYTES = 20 * 1024 * 1024;
30
- // Registry bookkeeping that must never enter a new project: the listing
31
- // descriptor and the rendered Store gallery describe the published app, and a
32
- // scaffold copy starts a new identity.
33
- const REGISTRY_ARTIFACT = /^(notis-listing\.json$|screenshots(\/|$))/;
34
- // Files the scaffold copy step would drop anyway — skip the download.
35
- const SKIPPED_SOURCE = /(^|\/)(node_modules|\.notis|\.git|dist|coverage|\.next|\.turbo)(\/|$)|(^|\/)\.env|\.(test|spec)\.[cm]?[jt]sx?$/;
36
-
37
- function registryRepo() {
38
- return process.env.NOTIS_APP_REGISTRY_REPO || DEFAULT_REGISTRY_REPO;
39
- }
40
-
41
- function registryRef() {
42
- return process.env.NOTIS_APP_REGISTRY_REF || DEFAULT_REGISTRY_REF;
43
- }
44
-
45
- /**
46
- * Local registry checkout override (`<dir>/apps/<slug>/…`). Used by tests and
47
- * by offline development against a clone of the registry repository.
48
- */
49
- function localRegistryDir() {
50
- return process.env.NOTIS_APP_REGISTRY_DIR || null;
51
- }
52
-
53
- export function scaffoldRegistryLabel() {
54
- return localRegistryDir() || `github.com/${registryRepo()}`;
55
- }
56
-
57
- async function fetchRegistry(url, { binary = false, maxBytes = null } = {}) {
58
- let response;
59
- try {
60
- response = await fetch(url, { headers: { 'user-agent': 'notis-cli' } });
61
- } catch (error) {
62
- throw usageError(
63
- `Could not reach the Notis app registry (${scaffoldRegistryLabel()}): ${error.message}. ` +
64
- 'Scaffolds are downloaded from published Store apps and need network access.',
65
- );
66
- }
67
- if (!response.ok) {
68
- throw usageError(`Notis app registry request failed (${response.status}) for ${url}.`);
69
- }
70
- const contentLength = Number(response.headers?.get?.('content-length'));
71
- if (maxBytes && Number.isFinite(contentLength) && contentLength > maxBytes) {
72
- throw usageError(`Notis app registry response exceeds the ${maxBytes}-byte limit.`);
73
- }
74
- let data;
75
- if (maxBytes && response.body?.getReader) {
76
- const reader = response.body.getReader();
77
- const chunks = [];
78
- let total = 0;
79
- while (true) {
80
- const { done, value } = await reader.read();
81
- if (done) break;
82
- const chunk = Buffer.from(value);
83
- total += chunk.length;
84
- if (total > maxBytes) {
85
- await reader.cancel();
86
- throw usageError(`Notis app registry response exceeds the ${maxBytes}-byte limit.`);
87
- }
88
- chunks.push(chunk);
89
- }
90
- data = Buffer.concat(chunks, total);
91
- } else {
92
- data = Buffer.from(await response.arrayBuffer());
93
- }
94
- if (maxBytes && data.length > maxBytes) {
95
- throw usageError(`Notis app registry response exceeds the ${maxBytes}-byte limit.`);
96
- }
97
- return binary ? data : data.toString('utf8');
98
- }
99
-
100
- function encodedRegistryRepoPath() {
101
- const parts = registryRepo().split('/');
102
- if (
103
- parts.length !== 2
104
- || parts.some((part) => !part || !/^[A-Za-z0-9_.-]+$/.test(part))
105
- ) {
106
- throw usageError('Notis app registry repository must use the owner/repository form.');
107
- }
108
- return parts.map((part) => encodeURIComponent(part)).join('/');
109
- }
110
-
111
- async function resolveRegistryCommit() {
112
- const url = `https://api.github.com/repos/${encodedRegistryRepoPath()}/commits/${encodeURIComponent(registryRef())}`;
113
- // GitHub's commit-detail response includes changed-file metadata and can be
114
- // substantially larger than the SHA we read from it. Keep a bounded limit,
115
- // but allow normal registry commits with a long file list.
116
- const payload = JSON.parse(await fetchRegistry(url, { maxBytes: MAX_REGISTRY_COMMIT_BYTES }));
117
- const commitSha = typeof payload?.sha === 'string' ? payload.sha.trim() : '';
118
- if (!/^[0-9a-f]{40}$/i.test(commitSha)) {
119
- throw usageError(
120
- `Notis app registry returned no immutable commit for ${registryRepo()}@${registryRef()}.`,
121
- );
122
- }
123
- return commitSha;
124
- }
125
-
126
- async function fetchRegistryTree(commitSha) {
127
- const url = `https://api.github.com/repos/${encodedRegistryRepoPath()}/git/trees/${commitSha}?recursive=1`;
128
- const payload = JSON.parse(await fetchRegistry(url, { maxBytes: MAX_REGISTRY_API_BYTES }));
129
- if (!Array.isArray(payload?.tree)) {
130
- throw usageError(`Notis app registry returned no file tree for ${registryRepo()}@${commitSha}.`);
131
- }
132
- if (payload.truncated === true) {
133
- throw usageError(
134
- `Notis app registry tree was truncated for ${registryRepo()}@${commitSha}; refusing an incomplete scaffold catalog.`,
135
- );
136
- }
137
- return payload.tree
138
- .filter((entry) => entry?.type === 'blob' && typeof entry.path === 'string')
139
- .map((entry) => ({ path: entry.path, size: Number(entry.size) }));
140
- }
141
-
142
- function fetchRegistryFile(path, commitSha, options) {
143
- const encodedPath = String(path).split('/').map((part) => encodeURIComponent(part)).join('/');
144
- return fetchRegistry(
145
- `https://raw.githubusercontent.com/${encodedRegistryRepoPath()}/${commitSha}/${encodedPath}`,
146
- options,
147
- );
148
- }
149
-
150
- async function mapWithConcurrency(values, concurrency, mapper) {
151
- const results = new Array(values.length);
152
- let cursor = 0;
153
- async function worker() {
154
- while (cursor < values.length) {
155
- const index = cursor;
156
- cursor += 1;
157
- results[index] = await mapper(values[index], index);
158
- }
159
- }
160
- await Promise.all(Array.from({ length: Math.min(concurrency, values.length) }, worker));
161
- return results;
162
- }
163
-
164
- function assertSafeScaffoldSlug(value) {
165
- const slug = String(value || '');
166
- if (!slug || slug === '.' || slug === '..' || /[\\/\0]/.test(slug)) {
167
- throw usageError(`Unsafe scaffold slug: ${value}`);
168
- }
169
- return slug;
170
- }
171
-
172
- /**
173
- * Resolve a registry-owned relative path without allowing either slash style,
174
- * drive-letter paths, or dot segments to escape the temporary scaffold root.
175
- * Exported so the platform-independent boundary contract can be unit tested on
176
- * every host, including macOS CI for the Windows backslash case.
177
- */
178
- export function resolveScaffoldTargetPath(tempRoot, registryRelativePath) {
179
- const raw = String(registryRelativePath || '');
180
- const normalized = raw.replace(/\\/g, '/');
181
- const parts = normalized.split('/');
182
- if (
183
- !normalized
184
- || normalized.includes('\0')
185
- || normalized.startsWith('/')
186
- || /^[A-Za-z]:\//.test(normalized)
187
- || parts.some((part) => !part || part === '.' || part === '..')
188
- ) {
189
- throw usageError(`Refusing unsafe path from Notis app registry: ${registryRelativePath}`);
190
- }
191
-
192
- const root = resolve(tempRoot);
193
- const target = resolve(root, ...parts);
194
- const fromRoot = relative(root, target);
195
- if (!fromRoot || fromRoot === '..' || fromRoot.startsWith(`..${process.platform === 'win32' ? '\\' : '/'}`) || isAbsolute(fromRoot)) {
196
- throw usageError(`Refusing path outside scaffold directory: ${registryRelativePath}`);
197
- }
198
- return target;
199
- }
200
-
201
- function readTsStringProperty(source, propertyName) {
202
- const match = source.match(new RegExp(`\\b${propertyName}\\s*:\\s*(['"\`])([\\s\\S]*?)\\1`));
203
- return match ? match[2] : null;
204
- }
205
-
206
- function catalogEntry(slug, listing, configSource) {
207
- const description = listing?.description || readTsStringProperty(configSource, 'description') || '';
208
- return {
209
- slug,
210
- name: listing?.name || readTsStringProperty(configSource, 'title') || slug,
211
- description,
212
- icon: readTsStringProperty(configSource, 'icon') || 'phosphor:squares-four',
213
- categories: Array.isArray(listing?.categories) ? listing.categories.filter(Boolean) : [],
214
- tagline: listing?.tagline || readTsStringProperty(configSource, 'tagline') || description,
215
- };
216
- }
217
-
218
- function readOptionalFile(path) {
219
- return existsSync(path) ? readFileSync(path, 'utf-8') : '';
220
- }
221
-
222
- function loadLocalCatalog(registryDir) {
223
- const appsDir = join(registryDir, 'apps');
224
- if (!existsSync(appsDir)) {
225
- return [];
226
- }
227
- const scaffolds = [];
228
- for (const entry of readdirSync(appsDir, { withFileTypes: true })) {
229
- if (!entry.isDirectory() || entry.name.startsWith('.') || entry.name.startsWith('_')) {
230
- continue;
231
- }
232
- const appDir = join(appsDir, entry.name);
233
- if (!existsSync(join(appDir, 'notis.config.ts'))) {
234
- continue;
235
- }
236
- const listingPath = join(appDir, 'notis-listing.json');
237
- const listing = existsSync(listingPath) ? JSON.parse(readFileSync(listingPath, 'utf-8')) : null;
238
- scaffolds.push(catalogEntry(entry.name, listing, readOptionalFile(join(appDir, 'notis.config.ts'))));
239
- }
240
- return scaffolds.sort((a, b) => a.slug.localeCompare(b.slug));
241
- }
242
-
243
- /**
244
- * List every published Store app as a scaffold.
245
- */
246
- export async function loadScaffoldCatalog() {
247
- const registryDir = localRegistryDir();
248
- if (registryDir) {
249
- return loadLocalCatalog(registryDir);
250
- }
251
- const commitSha = await resolveRegistryCommit();
252
- const tree = (await fetchRegistryTree(commitSha)).map((entry) => entry.path);
253
- const slugs = [...new Set(
254
- tree
255
- .filter((path) => /^apps\/[^/]+\//.test(path))
256
- .map((path) => path.split('/')[1]),
257
- )].filter((slug) => tree.includes(`apps/${slug}/notis.config.ts`));
258
- if (slugs.length > MAX_CATALOG_ENTRIES) {
259
- throw usageError(`Notis app registry contains too many scaffold entries (${slugs.length}; maximum ${MAX_CATALOG_ENTRIES}).`);
260
- }
261
- let catalogBytes = 0;
262
- const scaffolds = await mapWithConcurrency(slugs, DOWNLOAD_CONCURRENCY, async (slug) => {
263
- const [listingText, configSource] = await Promise.all([
264
- tree.includes(`apps/${slug}/notis-listing.json`)
265
- ? fetchRegistryFile(`apps/${slug}/notis-listing.json`, commitSha, { maxBytes: MAX_CATALOG_METADATA_BYTES })
266
- : Promise.resolve(''),
267
- fetchRegistryFile(`apps/${slug}/notis.config.ts`, commitSha, { maxBytes: MAX_CATALOG_METADATA_BYTES }),
268
- ]);
269
- catalogBytes += Buffer.byteLength(listingText) + Buffer.byteLength(configSource);
270
- if (catalogBytes > MAX_CATALOG_TOTAL_BYTES) {
271
- throw usageError(
272
- `Notis app scaffold catalog exceeds the ${MAX_CATALOG_TOTAL_BYTES}-byte aggregate metadata limit.`,
273
- );
274
- }
275
- const listing = listingText ? JSON.parse(listingText) : null;
276
- return catalogEntry(slug, listing, configSource);
277
- });
278
- return scaffolds.sort((a, b) => a.slug.localeCompare(b.slug));
279
- }
280
-
281
- /**
282
- * Case-insensitive match over slug, name, tagline, description, and categories.
283
- */
284
- export function filterScaffoldCatalog(catalog, searchTerm) {
285
- const term = String(searchTerm || '').trim().toLowerCase();
286
- if (!term) {
287
- return catalog;
288
- }
289
- const words = term.split(/\s+/);
290
- return catalog.filter((entry) => {
291
- const haystack = [entry.slug, entry.name, entry.tagline, entry.description, ...(entry.categories || [])]
292
- .join(' ')
293
- .toLowerCase();
294
- return words.every((word) => haystack.includes(word));
295
- });
296
- }
297
-
298
- /**
299
- * Materialize one published app's source for `apps init --from`.
300
- *
301
- * Returns `{ dir, cleanup }` or null when the slug is not in the registry.
302
- * The caller copies out of `dir` and must call `cleanup()` afterwards.
303
- */
304
- export async function acquireScaffoldSource(fromSlug) {
305
- const safeSlug = assertSafeScaffoldSlug(fromSlug);
306
- const registryDir = localRegistryDir();
307
- if (registryDir) {
308
- const appDir = join(registryDir, 'apps', safeSlug);
309
- if (!existsSync(join(appDir, 'notis.config.ts'))) {
310
- return null;
311
- }
312
- return { dir: appDir, cleanup: () => {} };
313
- }
314
-
315
- const commitSha = await resolveRegistryCommit();
316
- const tree = await fetchRegistryTree(commitSha);
317
- const prefix = `apps/${safeSlug}/`;
318
- const files = tree
319
- .filter((entry) => entry.path.startsWith(prefix))
320
- .map((entry) => ({ ...entry, rel: entry.path.slice(prefix.length) }))
321
- .filter((entry) => entry.rel && !REGISTRY_ARTIFACT.test(entry.rel) && !SKIPPED_SOURCE.test(entry.rel));
322
- if (!files.some((entry) => entry.rel === 'notis.config.ts')) {
323
- return null;
324
- }
325
- if (files.length > MAX_SCAFFOLD_FILES) {
326
- throw usageError(`Published scaffold contains too many files (${files.length}; maximum ${MAX_SCAFFOLD_FILES}).`);
327
- }
328
- const declaredBytes = files.reduce((total, entry) => (
329
- Number.isFinite(entry.size) && entry.size >= 0 ? total + entry.size : total
330
- ), 0);
331
- if (files.some((entry) => Number.isFinite(entry.size) && entry.size > MAX_SCAFFOLD_FILE_BYTES)) {
332
- throw usageError(`Published scaffold contains a file larger than ${MAX_SCAFFOLD_FILE_BYTES} bytes.`);
333
- }
334
- if (declaredBytes > MAX_SCAFFOLD_TOTAL_BYTES) {
335
- throw usageError(`Published scaffold source exceeds ${MAX_SCAFFOLD_TOTAL_BYTES} bytes.`);
336
- }
337
-
338
- const tempRoot = mkdtempSync(join(tmpdir(), 'notis-scaffold-'));
339
- let downloadedBytes = 0;
340
- try {
341
- for (let index = 0; index < files.length; index += DOWNLOAD_CONCURRENCY) {
342
- const settled = await Promise.allSettled(
343
- files.slice(index, index + DOWNLOAD_CONCURRENCY).map(async (entry) => {
344
- const target = resolveScaffoldTargetPath(tempRoot, entry.rel);
345
- const data = await fetchRegistryFile(prefix + entry.rel, commitSha, {
346
- binary: true,
347
- maxBytes: MAX_SCAFFOLD_FILE_BYTES,
348
- });
349
- downloadedBytes += data.length;
350
- if (downloadedBytes > MAX_SCAFFOLD_TOTAL_BYTES) {
351
- throw usageError(`Published scaffold source exceeds ${MAX_SCAFFOLD_TOTAL_BYTES} bytes.`);
352
- }
353
- mkdirSync(dirname(target), { recursive: true });
354
- writeFileSync(target, data);
355
- }),
356
- );
357
- const failed = settled.find((result) => result.status === 'rejected');
358
- if (failed) {
359
- throw failed.reason;
360
- }
361
- }
362
- } catch (error) {
363
- rmSync(tempRoot, { recursive: true, force: true });
364
- throw error;
365
- }
366
- return { dir: tempRoot, cleanup: () => rmSync(tempRoot, { recursive: true, force: true }) };
367
- }
@@ -1,5 +0,0 @@
1
- // Auto-generated on npm publish.
2
- // Committed value is 'published' so the CLI defaults to the live Notis API.
3
- // Localhost overrides come only from the worktree test lease (`./dev.sh`).
4
- // scripts/set-cli-mode.js can rewrite this for publish/labeling experiments.
5
- export const MODE = 'published';
@@ -1,34 +0,0 @@
1
- /**
2
- * CLI mode detection for `notis apps dev`.
3
- *
4
- * The published npm CLI and the repo-local checkout both default to the live
5
- * Notis API (`api.notis.ai` / `api-beta.notis.ai`). Localhost is not a CLI
6
- * default — the `/notis-tests` worktree lease (`./dev.sh`) is the only
7
- * supported loopback override for Notis developers.
8
- *
9
- * Mode is baked into `cli-mode.generated.js` at publish time. The
10
- * `NOTIS_CLI_MODE` env var is honored for internal labeling only (e.g. the
11
- * `apps` auto-dev loop inside `./dev.sh`).
12
- */
13
-
14
- import { MODE as BAKED_MODE } from './cli-mode.generated.js';
15
-
16
- export function getCliMode() {
17
- const override = process.env.NOTIS_CLI_MODE;
18
- if (override === 'local' || override === 'published') {
19
- return override;
20
- }
21
- return BAKED_MODE === 'published' ? 'published' : 'local';
22
- }
23
-
24
- export function getDefaultApiBase(mode = getCliMode(), { beta = false } = {}) {
25
- // Mode no longer switches the default API to localhost. Local loopback is
26
- // reserved for the worktree test lease; `mode` only affects portal origin
27
- // labeling for the in-repo apps-dev helper.
28
- void mode;
29
- return beta ? 'https://api-beta.notis.ai' : 'https://api.notis.ai';
30
- }
31
-
32
- export function getDefaultPortalOrigin(mode = getCliMode()) {
33
- return mode === 'local' ? 'http://localhost:3000' : 'https://app.notis.ai';
34
- }