primitive-admin 1.0.63 → 1.0.64

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 (328) hide show
  1. package/README.md +132 -42
  2. package/assets/skill/skills/primitive-platform/SKILL.md +142 -661
  3. package/dist/bin/primitive.js +121 -41
  4. package/dist/bin/primitive.js.map +1 -1
  5. package/dist/src/commands/admins.js +37 -50
  6. package/dist/src/commands/admins.js.map +1 -1
  7. package/dist/src/commands/analytics.js +178 -9
  8. package/dist/src/commands/analytics.js.map +1 -1
  9. package/dist/src/commands/apps.js +12 -5
  10. package/dist/src/commands/apps.js.map +1 -1
  11. package/dist/src/commands/auth-sessions.d.ts +7 -0
  12. package/dist/src/commands/auth-sessions.js +144 -0
  13. package/dist/src/commands/auth-sessions.js.map +1 -0
  14. package/dist/src/commands/auth.js +76 -116
  15. package/dist/src/commands/auth.js.map +1 -1
  16. package/dist/src/commands/blob-buckets.js +2 -1
  17. package/dist/src/commands/blob-buckets.js.map +1 -1
  18. package/dist/src/commands/catalog.js +26 -10
  19. package/dist/src/commands/catalog.js.map +1 -1
  20. package/dist/src/commands/collection-type-configs.js +3 -10
  21. package/dist/src/commands/collection-type-configs.js.map +1 -1
  22. package/dist/src/commands/collections.js +736 -19
  23. package/dist/src/commands/collections.js.map +1 -1
  24. package/dist/src/commands/config.js +13 -27
  25. package/dist/src/commands/config.js.map +1 -1
  26. package/dist/src/commands/connections.js +8 -9
  27. package/dist/src/commands/connections.js.map +1 -1
  28. package/dist/src/commands/cron-triggers.js +2 -1
  29. package/dist/src/commands/cron-triggers.js.map +1 -1
  30. package/dist/src/commands/database-type-configs.js +5 -12
  31. package/dist/src/commands/database-type-configs.js.map +1 -1
  32. package/dist/src/commands/databases.js +59 -72
  33. package/dist/src/commands/databases.js.map +1 -1
  34. package/dist/src/commands/documents.d.ts +58 -0
  35. package/dist/src/commands/documents.js +1623 -95
  36. package/dist/src/commands/documents.js.map +1 -1
  37. package/dist/src/commands/email-templates.js +2 -1
  38. package/dist/src/commands/email-templates.js.map +1 -1
  39. package/dist/src/commands/env.d.ts +1 -1
  40. package/dist/src/commands/env.js +89 -43
  41. package/dist/src/commands/env.js.map +1 -1
  42. package/dist/src/commands/feature-flags.js +2 -1
  43. package/dist/src/commands/feature-flags.js.map +1 -1
  44. package/dist/src/commands/functions.d.ts +20 -0
  45. package/dist/src/commands/functions.js +1630 -0
  46. package/dist/src/commands/functions.js.map +1 -0
  47. package/dist/src/commands/group-type-configs.js +2 -1
  48. package/dist/src/commands/group-type-configs.js.map +1 -1
  49. package/dist/src/commands/groups.js +30 -17
  50. package/dist/src/commands/groups.js.map +1 -1
  51. package/dist/src/commands/guides.js +17 -11
  52. package/dist/src/commands/guides.js.map +1 -1
  53. package/dist/src/commands/init.d.ts +12 -15
  54. package/dist/src/commands/init.js +44 -92
  55. package/dist/src/commands/init.js.map +1 -1
  56. package/dist/src/commands/integrations.js +35 -12
  57. package/dist/src/commands/integrations.js.map +1 -1
  58. package/dist/src/commands/locks.js +17 -2
  59. package/dist/src/commands/locks.js.map +1 -1
  60. package/dist/src/commands/metadata-category-configs.js +2 -1
  61. package/dist/src/commands/metadata-category-configs.js.map +1 -1
  62. package/dist/src/commands/metadata.js +8 -1
  63. package/dist/src/commands/metadata.js.map +1 -1
  64. package/dist/src/commands/prompts.js +106 -59
  65. package/dist/src/commands/prompts.js.map +1 -1
  66. package/dist/src/commands/rule-sets.js +3 -10
  67. package/dist/src/commands/rule-sets.js.map +1 -1
  68. package/dist/src/commands/scripts.js +33 -28
  69. package/dist/src/commands/scripts.js.map +1 -1
  70. package/dist/src/commands/secrets.js +2 -1
  71. package/dist/src/commands/secrets.js.map +1 -1
  72. package/dist/src/commands/sessions.js +10 -9
  73. package/dist/src/commands/sessions.js.map +1 -1
  74. package/dist/src/commands/sync-app-settings.js +3 -5
  75. package/dist/src/commands/sync-app-settings.js.map +1 -1
  76. package/dist/src/commands/sync.d.ts +390 -13
  77. package/dist/src/commands/sync.js +2613 -451
  78. package/dist/src/commands/sync.js.map +1 -1
  79. package/dist/src/commands/tokens.js +2 -1
  80. package/dist/src/commands/tokens.js.map +1 -1
  81. package/dist/src/commands/users.js +19 -10
  82. package/dist/src/commands/users.js.map +1 -1
  83. package/dist/src/commands/vars.js +2 -1
  84. package/dist/src/commands/vars.js.map +1 -1
  85. package/dist/src/commands/waitlist.js +2 -1
  86. package/dist/src/commands/waitlist.js.map +1 -1
  87. package/dist/src/commands/webhooks.d.ts +29 -0
  88. package/dist/src/commands/webhooks.js +135 -64
  89. package/dist/src/commands/webhooks.js.map +1 -1
  90. package/dist/src/commands/workflows.d.ts +1 -29
  91. package/dist/src/commands/workflows.js +113 -179
  92. package/dist/src/commands/workflows.js.map +1 -1
  93. package/dist/src/lib/api-client.d.ts +628 -14
  94. package/dist/src/lib/api-client.js +776 -70
  95. package/dist/src/lib/api-client.js.map +1 -1
  96. package/dist/src/lib/app-settings-descriptor.d.ts +1 -1
  97. package/dist/src/lib/app-settings-descriptor.js +9 -1
  98. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  99. package/dist/src/lib/block-selector.d.ts +58 -0
  100. package/dist/src/lib/block-selector.js +92 -0
  101. package/dist/src/lib/block-selector.js.map +1 -0
  102. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +24 -54
  103. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +31 -153
  104. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -1
  105. package/dist/src/lib/collection-export.d.ts +184 -0
  106. package/dist/src/lib/collection-export.js +252 -0
  107. package/dist/src/lib/collection-export.js.map +1 -0
  108. package/dist/src/lib/config-json-field.d.ts +28 -0
  109. package/dist/src/lib/config-json-field.js +56 -0
  110. package/dist/src/lib/config-json-field.js.map +1 -0
  111. package/dist/src/lib/config-object-descriptor.js +88 -6
  112. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  113. package/dist/src/lib/config-payload.d.ts +8 -1
  114. package/dist/src/lib/config-payload.js +49 -4
  115. package/dist/src/lib/config-payload.js.map +1 -1
  116. package/dist/src/lib/config-surface.d.ts +12 -1
  117. package/dist/src/lib/config-surface.js +71 -3
  118. package/dist/src/lib/config-surface.js.map +1 -1
  119. package/dist/src/lib/config.d.ts +31 -13
  120. package/dist/src/lib/config.js +34 -70
  121. package/dist/src/lib/config.js.map +1 -1
  122. package/dist/src/lib/credentials-store.d.ts +37 -22
  123. package/dist/src/lib/credentials-store.js +103 -97
  124. package/dist/src/lib/credentials-store.js.map +1 -1
  125. package/dist/src/lib/db-codegen/dbTypeIR.js +8 -0
  126. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
  127. package/dist/src/lib/deprecation.d.ts +22 -0
  128. package/dist/src/lib/deprecation.js +43 -0
  129. package/dist/src/lib/deprecation.js.map +1 -0
  130. package/dist/src/lib/document-export-permissions.d.ts +30 -0
  131. package/dist/src/lib/document-export-permissions.js +54 -0
  132. package/dist/src/lib/document-export-permissions.js.map +1 -0
  133. package/dist/src/lib/document-ingest-artifact.d.ts +120 -0
  134. package/dist/src/lib/document-ingest-artifact.js +505 -0
  135. package/dist/src/lib/document-ingest-artifact.js.map +1 -0
  136. package/dist/src/lib/document-ingest-input.d.ts +51 -0
  137. package/dist/src/lib/document-ingest-input.js +132 -0
  138. package/dist/src/lib/document-ingest-input.js.map +1 -0
  139. package/dist/src/lib/document-ingest-rows.d.ts +137 -0
  140. package/dist/src/lib/document-ingest-rows.js +181 -0
  141. package/dist/src/lib/document-ingest-rows.js.map +1 -0
  142. package/dist/src/lib/document-ingest.d.ts +101 -0
  143. package/dist/src/lib/document-ingest.js +384 -0
  144. package/dist/src/lib/document-ingest.js.map +1 -0
  145. package/dist/src/lib/env-resolver-core.d.ts +89 -18
  146. package/dist/src/lib/env-resolver-core.js +145 -23
  147. package/dist/src/lib/env-resolver-core.js.map +1 -1
  148. package/dist/src/lib/env-resolver.d.ts +18 -3
  149. package/dist/src/lib/env-resolver.js +23 -3
  150. package/dist/src/lib/env-resolver.js.map +1 -1
  151. package/dist/src/lib/function-bundle.d.ts +147 -0
  152. package/dist/src/lib/function-bundle.js +341 -0
  153. package/dist/src/lib/function-bundle.js.map +1 -0
  154. package/dist/src/lib/function-collect.d.ts +123 -0
  155. package/dist/src/lib/function-collect.js +610 -0
  156. package/dist/src/lib/function-collect.js.map +1 -0
  157. package/dist/src/lib/function-db-types.d.ts +202 -0
  158. package/dist/src/lib/function-db-types.js +870 -0
  159. package/dist/src/lib/function-db-types.js.map +1 -0
  160. package/dist/src/lib/function-document-types.d.ts +144 -0
  161. package/dist/src/lib/function-document-types.js +370 -0
  162. package/dist/src/lib/function-document-types.js.map +1 -0
  163. package/dist/src/lib/function-grants-preflight.d.ts +64 -0
  164. package/dist/src/lib/function-grants-preflight.js +105 -0
  165. package/dist/src/lib/function-grants-preflight.js.map +1 -0
  166. package/dist/src/lib/function-log-lines.d.ts +76 -0
  167. package/dist/src/lib/function-log-lines.js +160 -0
  168. package/dist/src/lib/function-log-lines.js.map +1 -0
  169. package/dist/src/lib/function-log-row.d.ts +29 -0
  170. package/dist/src/lib/function-log-row.js +73 -0
  171. package/dist/src/lib/function-log-row.js.map +1 -0
  172. package/dist/src/lib/function-log-tail.d.ts +132 -0
  173. package/dist/src/lib/function-log-tail.js +262 -0
  174. package/dist/src/lib/function-log-tail.js.map +1 -0
  175. package/dist/src/lib/function-run.d.ts +289 -0
  176. package/dist/src/lib/function-run.js +389 -0
  177. package/dist/src/lib/function-run.js.map +1 -0
  178. package/dist/src/lib/function-schema-codegen.d.ts +143 -0
  179. package/dist/src/lib/function-schema-codegen.js +420 -0
  180. package/dist/src/lib/function-schema-codegen.js.map +1 -0
  181. package/dist/src/lib/function-sync.d.ts +459 -0
  182. package/dist/src/lib/function-sync.js +1258 -0
  183. package/dist/src/lib/function-sync.js.map +1 -0
  184. package/dist/src/lib/function-trigger-listing.d.ts +27 -0
  185. package/dist/src/lib/function-trigger-listing.js +70 -0
  186. package/dist/src/lib/function-trigger-listing.js.map +1 -0
  187. package/dist/src/lib/function-typecheck.d.ts +86 -0
  188. package/dist/src/lib/function-typecheck.js +370 -0
  189. package/dist/src/lib/function-typecheck.js.map +1 -0
  190. package/dist/src/lib/function-versions.d.ts +122 -0
  191. package/dist/src/lib/function-versions.js +182 -0
  192. package/dist/src/lib/function-versions.js.map +1 -0
  193. package/dist/src/lib/generated-allowlist.js +4 -0
  194. package/dist/src/lib/generated-allowlist.js.map +1 -1
  195. package/dist/src/lib/generated-config-surfaces.d.ts +2332 -78
  196. package/dist/src/lib/generated-config-surfaces.js +6979 -468
  197. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  198. package/dist/src/lib/generated-sdk-types.d.ts +12 -0
  199. package/dist/src/lib/generated-sdk-types.js +13 -0
  200. package/dist/src/lib/generated-sdk-types.js.map +1 -0
  201. package/dist/src/lib/init-adopt.js +2 -2
  202. package/dist/src/lib/init-adopt.js.map +1 -1
  203. package/dist/src/lib/init-assets.js +3 -3
  204. package/dist/src/lib/init-config.d.ts +1 -1
  205. package/dist/src/lib/init-ios-links.d.ts +6 -5
  206. package/dist/src/lib/init-ios-links.js +9 -8
  207. package/dist/src/lib/init-ios-links.js.map +1 -1
  208. package/dist/src/lib/init-plan.d.ts +1 -1
  209. package/dist/src/lib/init-plan.js +1 -1
  210. package/dist/src/lib/init-xcode.d.ts +6 -5
  211. package/dist/src/lib/init-xcode.js +34 -10
  212. package/dist/src/lib/init-xcode.js.map +1 -1
  213. package/dist/src/lib/ios-app-id.d.ts +34 -0
  214. package/dist/src/lib/ios-app-id.js +69 -0
  215. package/dist/src/lib/ios-app-id.js.map +1 -0
  216. package/dist/src/lib/list-options.d.ts +68 -0
  217. package/dist/src/lib/list-options.js +89 -0
  218. package/dist/src/lib/list-options.js.map +1 -0
  219. package/dist/src/lib/local-state.d.ts +1 -1
  220. package/dist/src/lib/local-state.js +1 -1
  221. package/dist/src/lib/local-test-cases.d.ts +1 -1
  222. package/dist/src/lib/local-test-cases.js +2 -1
  223. package/dist/src/lib/local-test-cases.js.map +1 -1
  224. package/dist/src/lib/log-inspection.d.ts +152 -5
  225. package/dist/src/lib/log-inspection.js +179 -2
  226. package/dist/src/lib/log-inspection.js.map +1 -1
  227. package/dist/src/lib/logout-admin-session.d.ts +33 -0
  228. package/dist/src/lib/logout-admin-session.js +70 -0
  229. package/dist/src/lib/logout-admin-session.js.map +1 -0
  230. package/dist/src/lib/output.d.ts +15 -0
  231. package/dist/src/lib/output.js +28 -0
  232. package/dist/src/lib/output.js.map +1 -1
  233. package/dist/src/lib/paginate.d.ts +15 -0
  234. package/dist/src/lib/paginate.js +17 -0
  235. package/dist/src/lib/paginate.js.map +1 -1
  236. package/dist/src/lib/project-config.d.ts +38 -21
  237. package/dist/src/lib/project-config.js +57 -47
  238. package/dist/src/lib/project-config.js.map +1 -1
  239. package/dist/src/lib/prompt-cost-format.d.ts +11 -0
  240. package/dist/src/lib/prompt-cost-format.js +41 -0
  241. package/dist/src/lib/prompt-cost-format.js.map +1 -0
  242. package/dist/src/lib/prompt-schema-codegen.d.ts +147 -0
  243. package/dist/src/lib/prompt-schema-codegen.js +462 -0
  244. package/dist/src/lib/prompt-schema-codegen.js.map +1 -0
  245. package/dist/src/lib/refresh-admin-credentials.d.ts +9 -1
  246. package/dist/src/lib/refresh-admin-credentials.js +22 -2
  247. package/dist/src/lib/refresh-admin-credentials.js.map +1 -1
  248. package/dist/src/lib/resolve-owner.d.ts +19 -0
  249. package/dist/src/lib/resolve-owner.js +20 -0
  250. package/dist/src/lib/resolve-owner.js.map +1 -0
  251. package/dist/src/lib/skill-installer.d.ts +49 -3
  252. package/dist/src/lib/skill-installer.js +275 -100
  253. package/dist/src/lib/skill-installer.js.map +1 -1
  254. package/dist/src/lib/snapshot-audit-source.d.ts +45 -0
  255. package/dist/src/lib/snapshot-audit-source.js +58 -0
  256. package/dist/src/lib/snapshot-audit-source.js.map +1 -0
  257. package/dist/src/lib/snapshot-audit-store.d.ts +52 -0
  258. package/dist/src/lib/snapshot-audit-store.js +196 -0
  259. package/dist/src/lib/snapshot-audit-store.js.map +1 -0
  260. package/dist/src/lib/snapshot-audit.d.ts +207 -0
  261. package/dist/src/lib/snapshot-audit.js +431 -0
  262. package/dist/src/lib/snapshot-audit.js.map +1 -0
  263. package/dist/src/lib/snapshot-build-rows.d.ts +60 -0
  264. package/dist/src/lib/snapshot-build-rows.js +87 -0
  265. package/dist/src/lib/snapshot-build-rows.js.map +1 -0
  266. package/dist/src/lib/snapshot-build.d.ts +50 -0
  267. package/dist/src/lib/snapshot-build.js +111 -0
  268. package/dist/src/lib/snapshot-build.js.map +1 -0
  269. package/dist/src/lib/snapshot-manifest-layout.d.ts +61 -0
  270. package/dist/src/lib/snapshot-manifest-layout.js +70 -0
  271. package/dist/src/lib/snapshot-manifest-layout.js.map +1 -0
  272. package/dist/src/lib/snapshots.d.ts +8 -9
  273. package/dist/src/lib/snapshots.js +20 -83
  274. package/dist/src/lib/snapshots.js.map +1 -1
  275. package/dist/src/lib/step-run-table.d.ts +43 -0
  276. package/dist/src/lib/step-run-table.js +129 -0
  277. package/dist/src/lib/step-run-table.js.map +1 -0
  278. package/dist/src/lib/storage-pending-retry.d.ts +26 -0
  279. package/dist/src/lib/storage-pending-retry.js +42 -0
  280. package/dist/src/lib/storage-pending-retry.js.map +1 -0
  281. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +42 -0
  282. package/dist/src/lib/swift-codegen/agentGenerator.js +118 -0
  283. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -0
  284. package/dist/src/lib/swift-codegen/banners.d.ts +24 -0
  285. package/dist/src/lib/swift-codegen/banners.js +25 -0
  286. package/dist/src/lib/swift-codegen/banners.js.map +1 -0
  287. package/dist/src/lib/swift-codegen/dbGenerator.js +19 -7
  288. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -1
  289. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +139 -0
  290. package/dist/src/lib/swift-codegen/functionGenerator.js +462 -0
  291. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -0
  292. package/dist/src/lib/swift-codegen/generator.d.ts +7 -1
  293. package/dist/src/lib/swift-codegen/generator.js +28 -11
  294. package/dist/src/lib/swift-codegen/generator.js.map +1 -1
  295. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +15 -0
  296. package/dist/src/lib/swift-codegen/schemaToSwift.js +21 -4
  297. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
  298. package/dist/src/lib/sync-paths.d.ts +72 -55
  299. package/dist/src/lib/sync-paths.js +97 -100
  300. package/dist/src/lib/sync-paths.js.map +1 -1
  301. package/dist/src/lib/sync-resource-types.d.ts +23 -4
  302. package/dist/src/lib/sync-resource-types.js +106 -8
  303. package/dist/src/lib/sync-resource-types.js.map +1 -1
  304. package/dist/src/lib/sync-selectors.d.ts +45 -2
  305. package/dist/src/lib/sync-selectors.js +66 -5
  306. package/dist/src/lib/sync-selectors.js.map +1 -1
  307. package/dist/src/lib/template.d.ts +2 -2
  308. package/dist/src/lib/template.js +2 -2
  309. package/dist/src/lib/test-case-keys.d.ts +1 -1
  310. package/dist/src/lib/test-case-keys.js +1 -1
  311. package/dist/src/lib/test-case-variables.d.ts +14 -0
  312. package/dist/src/lib/test-case-variables.js +42 -0
  313. package/dist/src/lib/test-case-variables.js.map +1 -1
  314. package/dist/src/lib/toml-database-config.js +19 -2
  315. package/dist/src/lib/toml-database-config.js.map +1 -1
  316. package/dist/src/lib/webhook-deliver.d.ts +209 -0
  317. package/dist/src/lib/webhook-deliver.js +519 -0
  318. package/dist/src/lib/webhook-deliver.js.map +1 -0
  319. package/dist/src/lib/workflow-codegen/generator.d.ts +1 -1
  320. package/dist/src/lib/workflow-codegen/generator.js +1 -1
  321. package/dist/src/lib/workflow-toml-validator.d.ts +17 -8
  322. package/dist/src/lib/workflow-toml-validator.js +25 -12
  323. package/dist/src/lib/workflow-toml-validator.js.map +1 -1
  324. package/dist/src/lib/workflow-usage.d.ts +196 -0
  325. package/dist/src/lib/workflow-usage.js +310 -0
  326. package/dist/src/lib/workflow-usage.js.map +1 -0
  327. package/dist/src/types/index.d.ts +12 -2
  328. package/package.json +5 -4
@@ -1,508 +1,104 @@
1
1
  ---
2
2
  name: primitive-platform
3
3
  description: >
4
- Expert guide for building applications on the Primitive platform. MUST be used whenever the user
5
- is writing code that uses js-bao, js-bao-wss-client, primitive-app components, or any Primitive
6
- platform feature (documents, databases, workflows, prompts, integrations, blobs, authentication,
7
- users/groups). Also trigger whenever about to run any `primitive` CLI command (e.g., primitive config, primitive integrations, primitive apps, primitive env) to ensure Step 0 CLI verification is performed first. After writing or modifying code that touches Primitive
8
- APIs, this skill cross-references the implementation against official guides and automatically
9
- corrects common mistakes. Use this skill even if the user doesn't explicitly ask for it —
10
- any Primitive-related code should be validated against current best practices. Also use it
11
- when something looks like a platform bug or missing platform capability, to decide whether
12
- (and how) to file a platform issue. Also trigger whenever the user wants to upgrade or update
13
- the app to a newer platform version — bumping js-bao, js-bao-wss-client, primitive-app, or the
14
- primitive CLI — which follows the "Upgrading Platform Libraries" workflow below.
4
+ Fetches the Primitive platform's agent guides and applies them. MUST be used whenever the user
5
+ is writing or reviewing code that uses js-bao, js-bao-wss-client, primitive-app,
6
+ primitive-functions, or any Primitive platform feature (documents, databases, server functions,
7
+ prompts, integrations, blobs, authentication, users/groups), and before running any `primitive`
8
+ CLI command. All development guidance lives in the guides this skill fetches; after writing or
9
+ modifying code that touches Primitive APIs, it cross-references the code against those guides
10
+ and corrects mistakes. Use this skill even if the user doesn't explicitly ask for it. Also use it
11
+ when something looks like a platform bug or missing platform capability, to record the platform
12
+ feedback in the app's PRIMITIVE-FEEDBACK.md. Also trigger whenever the user wants to upgrade or
13
+ update the app to a newer platform version — bumping js-bao, js-bao-wss-client, primitive-app, or
14
+ the primitive CLI — which follows the "Upgrading Platform Libraries" workflow below.
15
15
  allowed-tools: Bash, Read, Edit, Write, Glob, Grep, Agent
16
16
  ---
17
17
 
18
- # Primitive Platform Development Guide
18
+ # Primitive Platform
19
19
 
20
- You are an expert on the Primitive platform. Your job is to help developers write correct,
21
- idiomatic Primitive code by leveraging the CLI's built-in guide system and enforcing best practices.
20
+ Everything about how to build on Primitive — APIs, configuration, the CLI, patterns and
21
+ pitfalls — lives in the **agent guides** the `primitive` CLI serves. This skill tells you how to
22
+ get the right guides and when to read them. It deliberately teaches nothing about the platform
23
+ itself: never write Primitive code, answer a Primitive question, or run a Primitive command from
24
+ memory or from this file. Fetch the guide.
22
25
 
23
- **The CLI guides are the single source of truth.** Never hardcode or memorize guide content —
24
- always fetch the latest from the CLI.
26
+ ## Getting the guides
25
27
 
26
- ## Step 0: Verify CLI Configuration
27
-
28
- The Primitive CLI is **project-scoped**, and project mode is **strongly preferred** for any work
29
- inside a repo. Each project has a `.primitive/config.json` (committed to the repo) that defines
30
- named environments (`dev`, `prod`, `staging`, …), where each environment binds an `apiUrl` and
31
- (optionally) an `appId`. Per-environment auth tokens live in `.primitive/credentials.json`
32
- (gitignored). There is no global "currently active app" — the active environment determines the
33
- server *and* the app.
34
-
35
- The legacy global fallback (`~/.primitive/credentials.json`) exists only for one-off use outside a
36
- project. **Inside a project, treat its absence as a setup gap to fix, not a mode to operate in.**
37
-
38
- **Before running any CLI commands**, your *first* check is whether the project is in project mode:
39
-
40
- ```bash
41
- ls .primitive/config.json # exists at project root or any ancestor?
42
- ```
43
-
44
- The two branches below are not equivalent — pick the one that matches reality and follow it.
45
-
46
- ### Branch A — `.primitive/config.json` exists (project mode)
47
-
48
- The active environment is resolved in this order:
49
- 1. `--env <name>` flag on the command
50
- 2. `PRIMITIVE_ENV` environment variable
51
- 3. This machine's selection in `.primitive/local.json` (written by `primitive env use`, gitignored)
52
- 4. `defaultEnvironment` in `.primitive/config.json` — the committed team default
53
- 5. The sole environment, if exactly one is defined
54
-
55
- `primitive env use <name>` does NOT edit the committed config: pointing this
56
- machine at a different backend never shows up as a file change. `env list`
57
- shows the resolved current environment and the committed team default
58
- separately, and reports a corrupt or dangling selection rather than falling
59
- back to the default.
60
-
61
- Confirm you're targeting the correct environment:
62
-
63
- 1. **Read the CLI header.** Every command prints `Env | App | Server` at the top of its output —
64
- verify these match the project's intended target.
65
- 2. **Inspect the project config:**
66
-
67
- ```bash
68
- primitive env list # All environments (CURRENT and TEAM DEFAULT shown separately)
69
- primitive env show # Details for the currently-resolved env
70
- primitive whoami # Authenticated user + resolved server/app
71
- ```
72
-
73
- **To switch environments** for a one-off command, pass `--env <name>`. To point this machine at
74
- a different environment, run `primitive env use <name>` (local state; the committed
75
- `defaultEnvironment` is unchanged). To switch the *app* an env points at, edit the env's
76
- `appId` in `.primitive/config.json` (or re-run `primitive env add`). `primitive use <app>` is a
77
- no-op when the active env already pins an `appId`.
78
-
79
- ### Branch B — no `.primitive/config.json` (project mode NOT set up)
80
-
81
- Without project config the CLI silently falls back to global state in `~/.primitive/credentials.json`
82
- (legacy mode). Commands run against whatever app/server happens to be globally active — which the
83
- agent didn't set and the user may have forgotten about. **This is a footgun, not a supported way to
84
- work inside a project.** Do not proceed silently, and do not treat the global fallback as the
85
- default path.
86
-
87
- **Your default action is to set up project mode.** Stop and prompt the user to create the project
88
- config before doing anything else. Don't bury the recommendation behind an equal-weight "or proceed
89
- against global state" option — make setting up project config the clear, recommended next step.
90
-
91
- First gather the context you'll propose (so the prompt is concrete, not abstract):
92
-
93
- ```bash
94
- primitive whoami # current global server + app, if any — shows what the fallback WOULD target
95
- ```
96
-
97
- Then prompt the user, e.g.:
98
-
99
- > "This project has no `.primitive/config.json`, so the CLI isn't in project mode. I recommend
100
- > setting up project-scoped config so this repo pins its own environment instead of relying on your
101
- > global state (currently `<server>` / `<app from whoami>`, which I didn't set). I'll add an env
102
- > with:
103
- >
104
- > ```bash
105
- > primitive env add dev --api-url <url> --app-id <id>
106
- > ```
107
- >
108
- > Does this look right, or should I adjust the env name / URL / app?"
109
-
110
- If you need the user to pick the env name, server, or app, ask them. Confirm the values before
111
- running `env add` — but the question to resolve is *which* project config to create, not *whether*
112
- to create one.
113
-
114
- `primitive env add` is additive and safe — it only writes an entry to `.primitive/config.json`
115
- (creating the file if needed). It does not touch source code, create apps on the server, or install
116
- dependencies.
117
-
118
- **Only fall back to global state if the user explicitly declines project setup** after you've
119
- recommended it. Even then, name the exact server/app the command will hit and get clear
120
- confirmation before running anything mutating (`primitive config push`, `primitive apps create`, etc.).
121
- A read-only command (`whoami`, `guides list`) against global state is fine while you're still
122
- working out the config.
123
-
124
- Do not rely on `.env` files like `PRIMITIVE_API_URL` to control CLI targeting — those are not
125
- read by the CLI in project mode, and the project config is the source of truth.
126
-
127
- **Why this matters:** If the CLI is pointed at the wrong environment (e.g., prod instead of dev),
128
- commands like `primitive config push` will modify the wrong server. Silent fallback to global state
129
- makes this exact mistake easy to commit. Setting up project config is the durable fix — verify and
130
- surface before running mutating operations.
131
-
132
- ## Step 1: Discover Available Guides
133
-
134
- Before writing or reviewing any Primitive code, run:
135
-
136
- ```bash
137
- primitive guides list
138
- ```
139
-
140
- This returns the full list of available guide topics with descriptions, keywords, and use cases.
141
- The `COMBINATIONS` column shows which `(language, platform)` variants each guide is available in
142
- (e.g. `ts; swift`). Use this output to determine which guides are relevant to the current task —
143
- and which language/platform variant to request in Step 2.
144
-
145
- ### Determine the project's language and platform
146
-
147
- Figure out what the project you're working in targets, then request the matching variant when
148
- fetching guides:
149
-
150
- - A `Package.swift`, `*.xcodeproj`, or `project.yml` → `--language swift` (plus `--platform ios`
151
- or `--platform macos` as appropriate).
152
- - A Vite/React/Node web app (`package.json`, `js-bao-wss-client`) → `--language ts --platform web`.
153
-
154
- If you can't tell, omit the flags — every guide has a default variant, so a bare
155
- `primitive guides get <topic>` always returns something useful.
156
-
157
- ## Step 2: Fetch the Relevant Guides
158
-
159
- For each relevant topic identified in Step 1, fetch the full guide, passing the project's
160
- language/platform so you get the right variant:
28
+ `primitive guides` works anywhere, inside a Primitive project or not.
161
29
 
162
30
  ```bash
31
+ primitive guides list # every topic: description, keywords, use cases, variants
163
32
  primitive guides get <topic> --language <ts|swift> --platform <web|ios|macos>
164
- # or, when the project's language/platform is unknown or doesn't matter:
165
- primitive guides get <topic>
166
- ```
167
-
168
- `--language` accepts aliases (`typescript`/`javascript`/`js` → `ts`). These flags **never fail**:
169
- an unknown value or an unavailable combination falls back to the guide's default variant rather
170
- than erroring, so it's always safe to pass your best guess.
171
-
172
- **Always fetch guide(s) BEFORE writing code.** If multiple features are involved, fetch multiple
173
- guides. The guides contain:
174
- - Complete API documentation with method signatures
175
- - Working code examples in the requested language (e.g. TypeScript or Swift)
176
- - Common patterns and anti-patterns
177
- - Configuration examples (TOML files for `primitive config`)
178
- - Decision frameworks for architecture choices
179
-
180
- **Do not guess or assume API patterns.** If you're unsure about a method signature, parameter,
181
- or pattern, fetch the guide. The guides are comprehensive and authoritative.
182
-
183
- ## Step 3: Write Code Following Guide Patterns
184
-
185
- When writing Primitive code:
186
-
187
- 1. **Follow the patterns from the fetched guides exactly** — method names, argument order, lifecycle patterns
188
- 2. **Use `primitive config`** for all backend configuration (workflows, prompts, integrations, databases)
189
- 3. **Configuration lives in TOML files** in version control, pushed via `primitive config push` — including test cases, authored as sidecars at `prompts/<key>.tests/`, `workflows/<key>.tests/`, `transforms/<name>.tests/` and `integrations/<key>.tests/` (one `[test]` file per case, with its attachments in a directory of the same name). A case file's name is its identity: `config pull` writes it back under that name and renaming it renames the case, so the checked-in tree reconciles on a fresh clone instead of duplicating
190
- 4. **Run `pnpm codegen`** after creating or modifying js-bao models
191
-
192
- ## Step 4: Post-Code Review (Automatic)
193
-
194
- After writing or modifying Primitive-related code, **automatically perform this review**:
195
-
196
- ### 4a. Identify What Was Written
197
- Determine which Primitive features the new/modified code touches by scanning for:
198
- - Import statements from `js-bao`, `js-bao-wss-client`, or `primitive-app`
199
- - Primitive API calls (documents.open, databases.connect, workflows, etc.)
200
- - Model definitions, schemas, queries
201
- - Configuration files (TOML for sync)
202
-
203
- ### 4b. Fetch and Cross-Reference
204
- Run `primitive guides list` to identify which guides cover the features used, then fetch each one
205
- in the project's language/platform:
206
- ```bash
207
- primitive guides get <topic> --language <ts|swift> --platform <web|ios|macos>
208
- ```
209
-
210
- Compare the written code against the guide content:
211
- - **API usage patterns** — Are methods called correctly with proper arguments?
212
- - **Lifecycle management** — Are documents opened before queries? Is auth checked first?
213
- - **Access control** — Are CEL expressions or permissions configured properly?
214
- - **Anti-patterns** — Does the code do anything the guide explicitly warns against?
215
- - **Untyped workflow invocation** — Is `client.workflows.start`/`runSync` called with a string-literal `workflowKey` and a hand-typed/cast `input`/`output` (e.g. `result.output as {...}`) instead of a generated invoker? That's a finding whenever the workflow has an `inputSchema`/`outputSchema` to generate from — regenerate with `primitive workflows codegen` (`--lang swift` for iOS/macOS) and call through the factory it emits instead, per the workflows guide's "Typed invocation (codegen)" section.
216
- - **Missing steps** — Does the code need `pnpm codegen`, `primitive workflows codegen`, `primitive config push`, or other follow-up?
217
-
218
- ### 4c. Report and Fix
219
- If issues are found:
220
- 1. **Explain the issue** — cite the specific guide section that applies
221
- 2. **Show the fix** — provide corrected code
222
- 3. **Apply the fix** — edit the file directly (don't just suggest, actually fix it)
223
- 4. **Note any CLI commands needed** — e.g., `pnpm codegen` or `primitive config push`
224
-
225
- If no issues are found, briefly confirm the code follows best practices.
226
-
227
- ## CLI Quick Reference
228
-
229
- Remind users of these essential commands when relevant:
230
-
231
- ```bash
232
- # Verify current configuration (DO THIS FIRST)
233
- primitive env list # List environments (CURRENT vs committed TEAM DEFAULT)
234
- primitive env show # Details for the currently-resolved env (api URL, app ID)
235
- primitive whoami # Authenticated user + resolved server/app
236
-
237
- # Switching environments
238
- primitive env use <name> # Select this machine's environment (gitignored local state)
239
- primitive --env <name> <command> # One-off override for a single command
240
- PRIMITIVE_ENV=<name> <command> # Override via env var (useful in scripts/CI)
241
-
242
- # Setup — existing project (most common: adopting Primitive in an existing repo)
243
- pnpm add -g primitive-admin # Install CLI (pnpm preferred; npm works too)
244
- primitive env add dev --api-url <url> --app-id <id> # Add env to .primitive/config.json
245
- primitive env add prod --api-url <url> --app-id <id> # (creates the file if missing)
246
- primitive login # Authenticate (tokens stored per-env)
247
-
248
- # Setup — brand-new project (greenfield only)
249
- primitive init my-new-app # Scaffolds template, creates a new app
250
- # on the server, runs pnpm install.
251
- primitive init my-new-app --platform web,ios # One app, a web client AND a native
252
- # client: web/ and ios/, with the project
253
- # config, git repo and the shared
254
- # models/models.toml at the root.
255
-
256
- # Setup — adding a client to an app that already exists
257
- primitive init ios --platform ios # Run INSIDE the app's repo: adds the
258
- # client to the app the nearest ancestor
259
- # .primitive/config.json targets. Writes
260
- # no nested .primitive/ or .git/ and makes
261
- # no commit — review with `git status`.
262
- # Read the multi-client guide first.
263
-
264
- # Guides (the most important commands for development)
265
- primitive guides list # See all guides: topics, descriptions, available (lang,platform) combinations
266
- primitive guides get <topic> # Read a guide's default variant
267
- primitive guides get <topic> --language swift --platform ios # Read a specific language/platform variant
268
-
269
- # Configuration as Code
270
- primitive config init --dir ./config # Initialize config directory
271
- primitive config pull --dir ./config # Pull config from server
272
- primitive config push --dir ./config # Push config to server
273
- primitive config diff --dir ./config # Preview changes before push
274
-
275
- # Taking something out of service (or putting it back)
276
- primitive workflows disable <key> # same verb pair on every type that has one
277
- primitive cron-triggers disable <id>
278
- primitive webhooks disable <id>
279
- primitive integrations disable <key>
280
- primitive prompts disable <key>
281
- primitive users disable <user-id> # a person, not an object — reversible
282
- primitive feature-flags disable <key> # super-admin platform toggle
283
-
284
- # Retiring an object (soft delete; NOT the same as disable)
285
- primitive workflows archive <key> # same verb on the five types that carry
286
- primitive cron-triggers archive <id> # `archived`; confirms first, -y skips
287
- primitive webhooks archive <id>
288
- primitive integrations archive <id> # the ID column of `integrations list`
289
- primitive prompts archive <id> # the ID column of `prompts list`
290
-
291
- # Common operations
292
- primitive apps list # List apps on the active env's server
293
- primitive apps create "Name" # Create an app (does NOT auto-bind to an env;
294
- # edit .primitive/config.json or use `env add` to bind)
33
+ primitive guides get <topic> # the topic's default variant
295
34
  ```
296
35
 
297
- **Availability is not configuration.** Whether a workflow, cron trigger,
298
- webhook, integration or prompt is in service is one server-owned `status`
299
- field, changed only by `<noun> enable|disable` (or the matching console
300
- action) and by the delete flow, whose CLI spelling is `<noun> archive` on those
301
- same five types. It is not a TOML key: `config pull` does not emit it,
302
- `config push` never sends it, and a file that still carries a `status` line
303
- fails the push with a message naming the verbs. So a push cannot put something back in service
304
- that an operator took out of it, and a fresh environment stood up from config
305
- has everything active. Anything newly created or pushed is active; there is no
306
- `draft` state on any object.
307
-
308
- **`archive` retires, `--prune` destroys.** `<noun> archive <id>` writes the
309
- third value, `archived`: the delete lifecycle rather than availability. The row
310
- is kept so its history still resolves, it goes on holding its key — and, for
311
- webhooks and cron triggers, its slot against the per-app cap — `enable` refuses
312
- it, and there is no un-archive. Reclaiming the key means a hard delete: remove
313
- the object's TOML file and run a confirmed `primitive config push --prune`, then
314
- re-add the file and push. There is no `--hard` flag and no per-type `delete`
315
- verb; prune-by-push is the CLI's only hard delete. `users` and `admins` carry
316
- `enable`/`disable` but no `archive` — people are not configuration objects.
317
-
318
- Per-VERSION status is a different thing and stays in TOML: a prompt, workflow
319
- or script config retires a named version with `status = "archived"` inside its
320
- `[[configs]]` entry, which says which version is live, not whether the object
321
- is serving.
322
-
323
- ## Debugging and inspection
324
-
325
- The CLI is the reference surface for inspecting a running app — reading what
326
- happened without opening the admin UI. The inspection commands share one set of
327
- conventions so they behave predictably across resources.
328
-
329
- ```bash
330
- # Workflow runs (the reference tailing command)
331
- primitive workflows runs list <workflow-id> # recent runs
332
- primitive workflows runs list <workflow-id> --json # normalized inspection items
333
- primitive workflows runs list <workflow-id> --watch # re-render the list every 2s (snapshot)
334
- primitive workflows runs list <workflow-id> --follow # append runs as they start or change (tail)
335
- primitive workflows runs list --user-id <user-id> # one user's runs, across every workflow
336
- primitive workflows runs steps <workflow-id> <run-id> # every step run of one run
337
- primitive workflows runs status <workflow-id> <run-id> # one run's status + step results
338
-
339
- # The other log-shaped views
340
- primitive integrations logs <integration-id> # outbound calls: status, timing, actor
341
- primitive webhooks events <webhook-id> # inbound deliveries and how they were handled
342
- primitive analytics events # app activity events
343
-
344
- # Per-subject analytics — one home, the analytics noun
345
- primitive analytics workflows --window-days 7 # top workflows by runs
346
- primitive analytics prompts --window-days 7 # top prompts by executions
347
- primitive analytics integrations # calls, error rate, latency
348
-
349
- # Blob storage
350
- primitive blob-buckets list # buckets in the app (app-scoped: no selector)
351
- primitive blob-buckets head <bucket> <key> # object metadata without downloading
352
-
353
- # Live connections and sessions
354
- primitive connections list --user-id <id> # active WebSocket connections
355
- primitive sessions list --user-id <id> # auth sessions
356
-
357
- # Database records and app documents
358
- primitive databases records query <database> ... # read records
359
- primitive databases records get <database> <model-name> <record-id>
360
- primitive documents records query <document> <model-name> [--filter '{...}']
361
- primitive documents records get <document> <model-name> <record-id>
362
- primitive documents dump <document-id> # every model's records as JSON
363
- primitive documents export <document-id> # dump a document's contents
364
- primitive documents create "<title>" [--owner <user-id-or-email>] # mint a document (--owner needs a super-admin or assigned-console-admin token; app-role admins create as themselves)
365
- primitive documents delete <document-id> [-y] [--json] # delete a document (document owner / app owner / super-admin or assigned-console-admin; app-role admins only via a containing collection's document.delete rule)
366
-
367
- # Metadata
368
- primitive metadata get <type> <id> <category> # resource metadata VALUES
369
- primitive metadata-category-configs list # category DEFINITIONS (schema + read/write rules)
370
- primitive metadata-category-configs get <type> <category>
371
- ```
372
-
373
- **Uniform flags across every inspection command:**
374
-
375
- - `--app <id>` — target app (falls back to the resolved env's app).
376
- - `--json` — the output you parse in scripts. Most commands print the endpoint
377
- payload as-is; the log views below normalize theirs into the shared item
378
- shape. Either way it is a JSON document, never a bare array — except the
379
- type-config readers (`group-type-configs`, `collection-type-configs`,
380
- `metadata-category-configs`), whose `list --json` prints the configs as a
381
- bare array (`jq '.[]'`). Data goes to
382
- stdout; status, warnings and the `CLI Version: …` banner go to stderr — so
383
- even the always-JSON commands that take no `--json` flag pipe cleanly
384
- (`primitive documents dump <doc> | jq .`).
385
- - `--limit <n>` / `--cursor <c>` — paged reads. The response envelope is always
386
- `{ items, hasMore, nextCursor? }`. Both `records query` verbs print that
387
- envelope whatever shape their endpoint returns, and neither emits the
388
- deprecated `cursor` alias — read `nextCursor`. Aggregate reads walk the
389
- `nextCursor` chain.
390
- - `list` always requires a **selector** (`--user-id`, `--owner`, a resource id, …)
391
- so it never enumerates the whole app — **except** genuinely app-scoped
392
- resources like `blob-buckets list`, which lists the app's buckets directly.
393
- `--user-id` is the spelling on every list/inspection selector; `connections
394
- list`, `sessions list` and `tokens list` still accept `--user` as a
395
- deprecated alias that prints a notice on stderr.
396
-
397
- **One `--json` item shape across the log views.** `workflows runs list`,
398
- `workflows runs steps`, `integrations logs`, `webhooks events` and `analytics
399
- events` all emit the same item envelope inside their endpoint's pagination
400
- envelope — never a bare array:
401
-
402
- ```json
403
- {
404
- "items": [
405
- {
406
- "source": "workflow-run",
407
- "timestamp": "2026-07-24T18:03:11.204Z",
408
- "outcome": "error",
409
- "nativeStatus": "failed",
410
- "correlation": { "runId": "01J…", "workflowId": "01J…", "userId": "01J…" },
411
- "detail": { "workflowKey": "summarize", "errorMessage": "…" }
412
- }
413
- ],
414
- "hasMore": false
415
- }
416
- ```
417
-
418
- - `source` is the discriminator: `workflow-run`, `workflow-step`,
419
- `integration`, `webhook`, `activity`.
420
- - `outcome` is the normalized verdict — `ok`, `error`, `pending`, or `neutral`
421
- — and `nativeStatus` keeps the source's own value (an HTTP integer, `failed`,
422
- `duplicate`, …) verbatim, so filtering on the raw value stays possible. A
423
- webhook that was accepted but matched no active workflow is `ok` with
424
- `nativeStatus: "workflow_inactive"` — a non-dispatch, not a failure.
425
- - `correlation` carries the pivot keys that let you follow one operation
426
- between views (`runId`, `stepId`, `traceId`, `workflowId`, `webhookId`,
427
- `userId`) plus the row's own id (`stepRunId`, `eventId`), so a row you
428
- printed can always be looked up again.
429
- - `detail` is a per-source allowlist of operator-facing fields, not the whole
430
- stored record.
431
- - Pagination rides alongside `items`: `hasMore` plus `nextCursor` where the
432
- endpoint pages by cursor, `page`/`pageSize`/`totalRows` for `analytics
433
- events`. `integrations logs` returns `{ items }` — it filters within a
434
- bounded scan rather than paging.
435
- - The normalization is `--json`-only: the human tables stay per-view because
436
- each shows columns the shared shape has no room for (queue delay, inter-step
437
- gap, token counts, event id). `--watch --json` reprints the same envelope
438
- each tick; `--follow --json` emits one item per line (newline-delimited
439
- JSON), since a tail has no closing bracket to wait for.
440
-
441
- **Per-user inspection.** Two views can be keyed on a user:
442
-
443
- ```bash
444
- primitive workflows runs list --user-id <user-id> # every run that user started
445
- primitive analytics events --user-id <user-id> # that user's activity events
446
- ```
447
-
448
- `workflows runs list --user-id` makes `<workflow-id>` optional — it lists the
449
- user's runs across every workflow. Pass both to narrow to one workflow.
450
- `integrations logs` and `webhooks events` have no `--user-id`: an integration
451
- invocation records the actor but is indexed by integration, and a webhook event
452
- carries no user identity at all. To follow a user through those, take the
453
- `runId`/`traceId` from that user's workflow runs and match it in the
454
- integration logs.
455
-
456
- **`--watch` vs `--follow` (both poll — there is no server push):**
457
-
458
- - `--watch` re-fetches the current snapshot each interval and re-renders the whole
459
- view (a periodic re-`list`/`get`). It works on any list command with no server
460
- change.
461
- - `--follow` tails: it appends new/changed rows since a server-owned checkpoint,
462
- like `tail -f`. It is offered **only** where the endpoint supports the resume
463
- contract (today: `workflows runs list`); other commands offer only `--watch`
464
- until their endpoint adds it. Passing `--follow` where it isn't supported fails
465
- with a clear message.
466
- - `--interval <seconds>` sets the poll interval (minimum 1s, default 2s).
467
- - `--watch` and `--follow` are mutually exclusive.
468
- - `--json --follow` emits **NDJSON** (one JSON object per new row per line) — a
469
- tail is an unbounded stream, so it can't be one array; pipe it to `jq -c`.
470
- `--json --watch` emits one array per redraw.
471
- - Ctrl-C stops a tail cleanly (exit 0).
472
-
473
- **`--follow` shows the latest observed version of a row, not every state change.**
474
- It re-emits a run when a newer version is observed between polls, so a run you
475
- already saw can reappear at its new position after its status changes — that is
476
- expected, not a duplicate. Fast transitions that happen between two polls collapse
477
- to the latest stored version. This is near-lossless observed-version tailing:
478
- rows sharing a timestamp, or a delayed index update, can occasionally be skipped
479
- or re-shown. Use it to watch activity, not as an exactly-once event log.
480
-
481
- ## When the User is Starting a New Feature
482
-
483
- If the user describes a new feature they want to build:
484
-
485
- 1. **Verify CLI configuration** per Step 0 — confirm the active environment in
486
- `.primitive/config.json` (and its bound `apiUrl` / `appId`) match the project's intended target
487
- before running any commands
488
- 2. **Run `primitive guides list`** to discover available topics and their `(language, platform)` combinations
489
- 3. **Identify which guides are relevant** to their feature from the list output
490
- 4. **Fetch those guides** with `primitive guides get <topic> --language <lang> --platform <platform>`
491
- (using the project's language/platform; omit the flags if unknown)
492
- 5. **Recommend a data modeling approach** based on the guide content. If requirements are unclear or ambiguous, **ask the user clarifying questions before proceeding** — it's much easier to get the data model right upfront than to migrate later
493
- 6. **Outline the implementation steps** referencing specific patterns from the guides
494
- 7. **Write the code** following the patterns exactly
495
- 8. **Review automatically** per Step 4 above
496
-
497
- ## When the User Asks "How Do I...?"
498
-
499
- For any question about Primitive platform capabilities:
500
-
501
- 1. **Run `primitive guides list`** to find the relevant topic (and its available language/platform combinations)
502
- 2. **Fetch the guide**: `primitive guides get <topic> --language <lang> --platform <platform>` (omit the flags if the language/platform is unknown)
503
- 3. **Answer from the guide content** — don't guess or make up APIs
504
- 4. **Include working code examples** from the guide
505
- 5. **Point the user to the guide** for further reading: "You can see more examples by running `primitive guides get <topic>`"
36
+ - **Which topics.** Read the `list` output and fetch every guide whose topic the task touches.
37
+ A feature usually spans several (a server function that writes a database and runs a prompt
38
+ needs all three guides). Fetch them BEFORE writing code.
39
+ - **Which variant.** Pass the project's language and platform. A `Package.swift`,
40
+ `*.xcodeproj`, or `project.yml` means `--language swift` with `--platform ios` or `macos`; a
41
+ web app with `package.json` and `js-bao-wss-client` means `--language ts --platform web`. The
42
+ `COMBINATIONS` column of `list` shows what each guide offers. The flags never fail: an unknown
43
+ value or unavailable combination falls back to the default variant, so pass your best guess,
44
+ or omit them when you can't tell. `--language` accepts `typescript`/`javascript`/`js` for `ts`.
45
+ - **Which channel.** Outside a project the CLI serves the production guides. Inside a project it
46
+ serves the guides matching the server the project's current environment points at, so an app
47
+ on the alpha environment reads the alpha guides. The version follows the installed
48
+ `js-bao-wss-client`.
49
+ - **Freshness.** Guides are cached under `~/.primitive/guides/` for 24 hours. After upgrading the
50
+ CLI or the libraries, pass `--refresh` on the first `list` and `get`.
51
+ - **Where to start.** `configuration` covers projects, environments, and pushing config;
52
+ `data-modeling` covers choosing where data lives; `inspecting-and-debugging` covers reading a
53
+ running app. For a CLI command you have not used, fetch the guide for its feature first.
54
+
55
+ ## Writing code
56
+
57
+ 1. Fetch the guides for every feature the change touches.
58
+ 2. Follow them exactly: method names, argument order, lifecycle, configuration shapes, and the
59
+ follow-up steps they name (codegen, pushing config, typechecking).
60
+ 3. Never guess an API. If the guide you have does not answer the question, fetch the related
61
+ guides it links before inventing anything. If none does, it is a platform gap: see "The
62
+ platform feedback doc" below.
63
+ 4. Before running a `primitive` command that changes server state, read the `Env | App | Server`
64
+ header every command prints and confirm it names the environment you intend. The
65
+ `configuration` guide explains projects and environments.
66
+
67
+ ## Reviewing code (automatic, after every change)
68
+
69
+ After writing or modifying code that touches Primitive, review it without being asked:
70
+
71
+ 1. **Identify the features touched.** Imports from `js-bao`, `js-bao-wss-client`,
72
+ `primitive-app`, or `primitive-functions`; files in the project's configuration tree; model
73
+ definitions and schemas.
74
+ 2. **Fetch those guides** in the project's language and platform.
75
+ 3. **Compare the code against them.** API usage, lifecycle, access and authorization, anything
76
+ the guide warns against, and any follow-up step the guide requires that the change skipped.
77
+ 4. **Fix what's wrong.** Cite the guide section, edit the file (don't just suggest), and name any
78
+ command the user still needs to run. If nothing is wrong, say so briefly.
79
+
80
+ ## When the user is starting a new feature
81
+
82
+ 1. Run `primitive guides list` and pick every relevant topic.
83
+ 2. Fetch those guides in the project's language and platform.
84
+ 3. Recommend a data model from the guides. If requirements are ambiguous, ask clarifying
85
+ questions first: a data model is much easier to get right up front than to migrate.
86
+ 4. Outline the implementation, citing the guide patterns it follows.
87
+ 5. Write the code, then review it as above.
88
+
89
+ ## When the user asks "How do I…?"
90
+
91
+ 1. Find the topic with `primitive guides list`, then fetch it.
92
+ 2. Answer from the guide, with its examples. Don't guess or invent APIs.
93
+ 3. Point the user at the guide for more: `primitive guides get <topic>`.
94
+
95
+ ## When the user is moving an app's data to another app
96
+
97
+ Fetch the `documents` guide and follow its export/import sections. A migration is two
98
+ exports into one directory and two imports out of it, in a fixed order — the documents
99
+ bundle, then the collections those documents sit in — and the guide has the commands, the
100
+ order they must run in, and what does not travel. Don't run a single export or import from
101
+ memory: the wrong order silently loses every collection's document membership.
506
102
 
507
103
  ## Upgrading Platform Libraries
508
104
 
@@ -513,7 +109,7 @@ moved too, and new platform capabilities should be considered. The refreshed gui
513
109
  source of truth for what the platform can do now.
514
110
 
515
111
  The backend is upgraded by the platform team, not by the app — the app only chooses which
516
- environment it points at (Step 0). A library upgrade against the production environment
112
+ environment it points at (see the `configuration` guide). A library upgrade against the production environment
517
113
  needs no server-side changes.
518
114
 
519
115
  ### 1. Snapshot the current state
@@ -554,13 +150,41 @@ channel from the *installed* `js-bao-wss-client` major, so fetching first return
554
150
  for the old version. Then refetch the guides for every feature area the app uses,
555
151
  passing `--refresh` on the first call.
556
152
 
557
- ### 4. Fix breaking changes
153
+ ### 4. Fix breaking changes, then scan for deprecated API use
558
154
 
559
155
  Run the app's typecheck/build. For every error, consult the refreshed guide for that
560
156
  feature area and migrate the code to the current API — don't pin back or suppress. A
561
157
  major version bump means breaking changes are expected; treat the migration as part of
562
158
  the upgrade, not an optional follow-up.
563
159
 
160
+ Once it builds, find every platform API the app still uses that the platform has
161
+ deprecated. A deprecated surface works today and is removed in a later major, so this
162
+ is the moment to warn the user, not the moment it breaks. Each surface marks its
163
+ deprecations where the toolchain already looks, so the scan is a lint or a build, not
164
+ a grep:
165
+
166
+ - **TypeScript (web) apps.** Every deprecated member of the platform packages carries
167
+ a `@deprecated` note in its typings, and the `@typescript-eslint/no-deprecated` lint
168
+ rule reports each use together with that note. The Vue starter template enables it
169
+ for `src/`, so `pnpm lint` in an app on the current template lists them. An app
170
+ whose lint config predates the rule reports nothing: pull the template's
171
+ `eslint.config.ts` forward first (Step 6 covers the rest of the template; take that
172
+ one file now), then lint.
173
+ - **Swift apps.** The client marks deprecations with `@available(*, deprecated,
174
+ message:)`, so the compiler reports each use as a warning that names the
175
+ replacement. Build the app and read the `is deprecated` warnings for the app's own
176
+ sources, not its dependencies.
177
+ - **The configuration tree.** A deprecated key or spelling in the app's `primitive/`
178
+ TOML is reported when the tree is pushed; the `configuration` guide explains how to
179
+ check a tree without applying it.
180
+
181
+ Report every hit to the user as a list: file and line, the deprecated API, and the
182
+ replacement its note names (the `changelog` guide has the entry that deprecated it
183
+ and what replaced it). Don't migrate them unasked — some replacements change
184
+ behavior — but say which ones are a mechanical rename and offer to do those in the
185
+ same upgrade. A use the app keeps on purpose gets a lint suppression with the reason
186
+ beside it, so the next upgrade's scan does not report it again.
187
+
564
188
  ### 5. Retire resolved workarounds
565
189
 
566
190
  For each workaround tracked in the feedback doc, re-test the underlying platform
@@ -617,16 +241,18 @@ guides for the app's feature areas. Compare against what the app actually does:
617
241
 
618
242
  ### 8. Verify and stamp
619
243
 
620
- Run the app's tests, apply the Step 4 post-code review to everything modified, and
244
+ Run the app's tests, apply the post-change review above to everything modified, and
621
245
  update the feedback doc's upgrade stamp (date, channel, versions, and the template
622
246
  commit synced in Step 6).
623
247
 
624
248
  ### The platform feedback doc
625
249
 
626
250
  Convention: a `PRIMITIVE-FEEDBACK.md` at the app root tracks the app's relationship to the
627
- platform — when it was last upgraded, and which workarounds exist for platform issues.
628
- This is what makes upgrades mechanical instead of archaeological. If the app doesn't
629
- have one, create it during the first upgrade:
251
+ platform — when it was last upgraded, which workarounds exist for platform problems, and
252
+ what the app found missing or broken. This is what makes upgrades mechanical instead of
253
+ archaeological, and it is also how platform feedback reaches the platform team: **the
254
+ platform team reads this document. No issue is filed from an app.** If the app doesn't
255
+ have one, create it the first time there is something to record:
630
256
 
631
257
  ```markdown
632
258
  # Platform Feedback
@@ -638,171 +264,26 @@ have one, create it during the first upgrade:
638
264
  - Template: primitive-vue-template @ main 0f1c2d3
639
265
 
640
266
  ## Open items
641
- - [#1234] Symptom or missing capability. Workaround: `src/lib/foo.ts:42` (retry loop).
267
+ - Symptom or missing capability. Evidence: `POST /app/x/api/databases` returns 500
268
+ (error text below). Workaround: `src/lib/foo.ts:42` (retry loop). Remove when: the
269
+ create returns 201 on the first call.
642
270
 
643
271
  ## Resolved
644
- - [#1101] Symptom. Workaround removed 2026-07-21.
645
- ```
646
-
647
- Issue numbers refer to platform issues where known (Primitive-Labs members); items
648
- without an issue number are fine — the doc is useful even when the issue tracker isn't
649
- accessible.
650
-
651
- ## Filing Platform Issues
652
-
653
- Sometimes the problem is in the platform itself — a bug in js-bao, the client library,
654
- the CLI, or a capability the platform doesn't have — rather than in the user's app.
655
- Platform work is tracked as GitHub issues on `Primitive-Labs/js-bao-wss`.
656
-
657
- **Gate: only suggest filing an issue if the signed-in GitHub user is a member of the
658
- Primitive-Labs org.** Check silently before ever raising the option:
659
-
660
- ```bash
661
- gh api user/memberships/orgs/Primitive-Labs --jq .state 2>/dev/null
662
- ```
663
-
664
- If this doesn't print `active` (not a member, or `gh` is missing or unauthenticated),
665
- don't mention filing an issue at all — help the user work around the problem instead.
666
-
667
- ### Tracker hygiene (issues and comments alike)
668
-
669
- Everything you write to the tracker — new issues and follow-up comments on existing
670
- ones — is read by an agent pipeline and by maintainers who have none of your session's
671
- context. What you write is all they get, and investigating is the assignee's job —
672
- yours is to state the problem clearly.
673
-
674
- - **Brevity and clarity win over verbosity.** Keep the prose to 1000 characters or
675
- less. Fenced code blocks (repro commands, config, verbatim error output) don't count
676
- toward the cap — precision there is what makes an issue reproducible. If the prose
677
- doesn't fit, you're including solution detail or context the assignee can rediscover.
678
- - **Self-contained.** Assume the reader knows nothing about the user's app and has no
679
- internal knowledge of the platform. Reference related issues by number, but inline
680
- whatever context is needed to read the issue standalone.
681
- - **Describe the problem, not the solution.** Don't prescribe the fix or assume a
682
- particular implementation.
683
- - **Don't relitigate decisions rejected in earlier issues** — carry forward the
684
- discovered tradeoffs, stated neutrally.
685
-
686
- ### Bugs (an existing platform feature not working as designed)
687
-
688
- Body template — fill each section with as much precision as possible, so the issue is
689
- easy to reproduce on the first try:
690
-
691
- ```
692
- ## Repro steps
693
- <numbered, precise, minimal: exact API calls, config, versions. The test:
694
- someone with no context reproduces it on the first try>
695
-
696
- ## Observed behavior
697
- <what actually happens, with verbatim error text / response bodies in fenced
698
- blocks>
699
-
700
- ## Expected behavior
701
- <what should happen instead, stated as an observable outcome — this is what
702
- "fixed" means, and what a fix will be tested against>
703
-
704
- ## Design review needed?
705
- <tick any that apply; leave all unticked if the fix looks self-contained>
706
-
707
- - [ ] Involves a critical security decision (auth, permissions, CEL, secrets, webhook
708
- verification, DO routing)
709
- - [ ] Risks a performance regression on a per-request, per-message or per-connection path
710
- - [ ] Requires a data model or index change (`models.yaml`)
711
- - [ ] Breaks an existing API contract (removes or retypes something in `openapi.json`, or
712
- changes a `src/client` public signature non-additively)
713
- ```
714
-
715
- Write "Expected behavior" as the acceptance criterion: the observable outcome that
716
- defines the bug as fixed. If prior investigation exists (an earlier thread, a
717
- session's debugging), link it — don't inline a root-cause theory as fact.
718
-
719
- The "Design review needed?" checkboxes decide the bug's route: any tick sends it
720
- through the design gate; all unticked sends it straight to implementation, with
721
- "Expected behavior" as the acceptance criteria. When unsure, leave a box unticked —
722
- the worker re-checks against its own diff and routes itself back if one applies.
723
-
724
- Labels: `type:bug` only.
725
-
726
- ### Features / enhancements / platform extensions
727
-
728
- ```
729
- ## Problem
730
- <the application-level problem being solved, and who hits it — a concrete
731
- scenario, not an abstraction, and not a solution>
732
-
733
- ## What I tried
734
- <existing platform features attempted, and why each falls short — omit if none apply>
735
-
736
- ## What a solution needs to enable
737
- <the outcomes a solution must make possible, as bullets — capabilities from
738
- the consumer's perspective, not designs>
739
- ```
740
-
741
- Keep "What a solution needs to enable" outcome-shaped: "an app can resume a follow
742
- from the last event it saw across restarts" — not "add a `resumeAfter` token to the
743
- list endpoint". If you have a design idea worth preserving, put it in a comment,
744
- clearly labeled as an idea — never in the body.
745
-
746
- Labels: `type:feature` only.
747
-
748
- ### Filing
749
-
750
- Use only `type:bug` or `type:feature` (e.g. file performance problems as `type:bug`
751
- with measurements in the repro steps). Search open issues for duplicates first:
752
-
753
- ```bash
754
- gh issue list --repo Primitive-Labs/js-bao-wss --search "<keywords>" --state open \
755
- --json number,title
756
- ```
757
-
758
- Then create the issue with exactly one `type:*` label and nothing else — **no
759
- assignee** (triage assigns sponsors; unassigned is the correct starting state), no
760
- priority labels, no `state:*` label, and no `dispatch-v3` (state and dispatch labels
761
- are added together by triage once it judges the filing complete — never by the
762
- filer; an issue waiting for triage is the correct starting state):
763
-
764
- ```bash
765
- gh issue create --repo Primitive-Labs/js-bao-wss \
766
- --title "<one-line symptom or need>" \
767
- --label "type:bug" \
768
- --body "<template body>"
272
+ - Symptom. Workaround removed 2026-07-21.
769
273
  ```
770
274
 
771
- The templates above mirror the canonical ones in the js-bao-wss repo at
772
- `.claude/skills/_shared/templates/` (`bug-filing.md`, `feature-filing.md`,
773
- `docs-filing.md`), which the pipeline validates against with
774
- `.claude/skills/_shared/check-filing.sh` before an issue can be picked up — a body
775
- missing a required section stalls in triage until a human repairs it. If the
776
- templates here and the repo's ever disagree, the repo's win. When working inside a
777
- js-bao-wss checkout, don't file by hand at all: use that repo's `/file-issue` skill,
778
- which interviews for the sections, validates the draft offline, and files with the
779
- right labels.
780
-
781
- ### Follow-up comments on existing issues
782
-
783
- When the duplicate search finds an issue that already covers the problem, comment
784
- there instead of filing. A comment is a **delta on the thread, not a fresh report** —
785
- the hygiene rules above (1000-character prose cap, fenced blocks exempt, problem not
786
- solution, self-contained) apply to it unchanged, plus:
787
-
788
- - **Lead with what's new**: a repro, a counterexample, a version/deployment where the
789
- behavior changed, a confirmation that it no longer reproduces. Don't restate what
790
- the thread already establishes — reference it.
791
- - **Evidence goes in fenced blocks**, exactly as in an issue body: numbered repro
792
- steps, exact commands and API calls, verbatim errors, versions and app/resource
793
- ids. Prose interprets the evidence; it must not be the container for it.
794
- - **One comment, one issue's scope.** Evidence that implicates a *different* issue
795
- belongs in a separate comment on that issue, cross-referenced by number — not
796
- folded into this one.
797
- - **State facts; leave triage to the maintainers.** Stage, priority, closure, and
798
- duplicate-of verdicts are theirs. If the evidence points at a next step (re-test
799
- after X lands, likely duplicate of #N), one closing sentence may say so — never
800
- more.
801
-
802
- ### Record the issue in the app
803
-
804
- After filing, add an entry to the app's `PRIMITIVE-FEEDBACK.md` (see "The platform feedback doc"
805
- above) under **Open items**: the issue number, a one-line symptom, and — if you built a
806
- workaround in the app — where it lives (`file:line`). This is what lets a future upgrade
807
- find and remove the workaround once the platform fix ships. If a workaround is added
808
- later for an already-filed issue, update the entry then.
275
+ **When something looks like a platform problem** — a bug in js-bao, the client library,
276
+ the CLI, or a capability the platform doesn't have — rather than a problem in the user's
277
+ app, write it into this document under **Open items**. That is the whole of what to do
278
+ with it; help the user work around the problem in the app, and record:
279
+
280
+ - **The symptom**: one line, what goes wrong or what is missing.
281
+ - **The evidence**: the exact call, config, or command and the verbatim error or
282
+ response, in a fenced block if it is more than a line. Precision here is what lets the
283
+ platform team reproduce it.
284
+ - **The workaround location**: `file:line` of the code the app carries because of it.
285
+ - **The condition for removing the workaround**: the observable platform behavior that
286
+ means the workaround can come out. A later upgrade re-tests exactly this (Step 5).
287
+
288
+ Entries sometimes carry a platform issue number (Primitive-Labs members add them); items
289
+ without one are just as useful — the document is the feedback channel, not the tracker.