spine-framework 0.4.4 → 0.5.0-rc.4

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 (283) hide show
  1. package/.env.example +13 -3
  2. package/.framework/cli/commands/bootstrap.ts +392 -0
  3. package/.framework/cli/commands/dev.ts +91 -218
  4. package/.framework/cli/commands/doctor.ts +132 -26
  5. package/.framework/cli/commands/generate.ts +38 -298
  6. package/.framework/cli/commands/init.ts +20 -1
  7. package/.framework/cli/commands/migrate.ts +36 -30
  8. package/.framework/cli/commands/migrations.ts +16 -56
  9. package/.framework/cli/commands/upgrade.ts +35 -0
  10. package/.framework/cli/commands/validate-schema.ts +147 -0
  11. package/.framework/cli/context.ts +223 -110
  12. package/.framework/cli/index.ts +6 -0
  13. package/.framework/cli/lib/project-files.ts +241 -1
  14. package/.framework/functions/_shared/hash-api-key.ts +183 -79
  15. package/.framework/functions/_shared/logging.ts +562 -224
  16. package/.framework/functions/_shared/middleware.ts +47 -44
  17. package/.framework/functions/admin-data.ts +39 -28
  18. package/.framework/functions/ai-agents.ts +10 -6
  19. package/.framework/functions/api-keys.ts +301 -122
  20. package/.framework/functions/apps.ts +43 -26
  21. package/.framework/functions/cil-ingest.ts +48 -15
  22. package/.framework/functions/debug-auth.ts +14 -8
  23. package/.framework/functions/deliveries.ts +39 -12
  24. package/.framework/functions/embeddings.ts +145 -76
  25. package/.framework/functions/integration-outbound.ts +67 -27
  26. package/.framework/functions/integrations.ts +254 -127
  27. package/.framework/functions/logs.ts +273 -133
  28. package/.framework/functions/observability.ts +277 -147
  29. package/.framework/functions/pipeline-executions.ts +1 -1
  30. package/.framework/functions/pipelines.ts +14 -9
  31. package/.framework/functions/prompt-configs.ts +7 -4
  32. package/.framework/functions/roles.ts +8 -5
  33. package/.framework/functions/security.ts +30 -17
  34. package/.framework/functions/system-cron.ts +240 -127
  35. package/.framework/functions/tests.ts +7 -6
  36. package/.framework/functions/timers.ts +310 -107
  37. package/.framework/functions/triggers.ts +28 -13
  38. package/.framework/functions/types.ts +13 -10
  39. package/.framework/migrations/069_log_stats_window.sql +54 -0
  40. package/.framework/migrations/070_app_type_schema_rpcs.sql +166 -0
  41. package/.framework/migrations/071_timer_interval_keys.sql +96 -0
  42. package/.framework/migrations/072_slug_autofill.sql +77 -0
  43. package/.framework/migrations/073_seed_member_roles.sql +26 -0
  44. package/.framework/src/apps/admin/index.tsx +1141 -775
  45. package/.framework/src/components/ErrorBoundary.tsx +136 -0
  46. package/.framework/src/components/admin/AdminListPage.tsx +81 -73
  47. package/.framework/src/components/admin/AdminSidebar.tsx +88 -79
  48. package/.framework/src/components/admin/EntitySelect.tsx +181 -0
  49. package/.framework/src/components/admin/PageInstructions.tsx +86 -127
  50. package/.framework/src/components/app-shell/GenericDetailPage.tsx +37 -13
  51. package/.framework/src/components/app-shell/GenericListPage.tsx +28 -32
  52. package/.framework/src/components/layout/Sidebar.tsx +300 -177
  53. package/.framework/src/components/runtime/DataDetailPage.tsx +67 -35
  54. package/.framework/src/components/runtime/DataHeader.tsx +96 -48
  55. package/.framework/src/components/runtime/DataListPage.tsx +3 -26
  56. package/.framework/src/components/runtime/DataStats.tsx +10 -10
  57. package/.framework/src/components/runtime/DataTable.tsx +12 -10
  58. package/.framework/src/components/ui/sheet.tsx +24 -26
  59. package/.framework/src/components/ui/textarea.tsx +74 -48
  60. package/.framework/src/hooks/useEntityList.ts +12 -9
  61. package/.framework/src/hooks/useListSchema.ts +108 -58
  62. package/.framework/src/instructions/README.md +57 -0
  63. package/.framework/src/instructions/ai-agents.md +69 -0
  64. package/.framework/src/instructions/alerts.md +80 -0
  65. package/.framework/src/instructions/api-keys.md +87 -0
  66. package/.framework/src/instructions/apps.md +77 -0
  67. package/.framework/src/instructions/concepts/ai-and-prompts.md +150 -0
  68. package/.framework/src/instructions/concepts/apps-and-renderers.md +162 -0
  69. package/.framework/src/instructions/concepts/auth-and-api-keys.md +133 -0
  70. package/.framework/src/instructions/concepts/automation.md +186 -0
  71. package/.framework/src/instructions/concepts/concurrency-and-idempotency.md +125 -0
  72. package/.framework/src/instructions/concepts/core-vs-custom.md +124 -0
  73. package/.framework/src/instructions/concepts/design-schema.md +152 -0
  74. package/.framework/src/instructions/concepts/integrations-and-webhooks.md +127 -0
  75. package/.framework/src/instructions/concepts/observability.md +116 -0
  76. package/.framework/src/instructions/concepts/permissions.md +150 -0
  77. package/.framework/src/instructions/concepts/runtime-records.md +111 -0
  78. package/.framework/src/instructions/concepts/scope-and-accounts.md +112 -0
  79. package/.framework/src/instructions/concepts/spine-way.md +172 -0
  80. package/.framework/src/instructions/deliveries.md +59 -0
  81. package/.framework/src/instructions/guide/00-orientation.md +106 -0
  82. package/.framework/src/instructions/guide/01-install-and-first-run.md +253 -0
  83. package/.framework/src/instructions/guide/02-project-map.md +147 -0
  84. package/.framework/src/instructions/guide/03-domain-model.md +223 -0
  85. package/.framework/src/instructions/guide/04-first-app.md +227 -0
  86. package/.framework/src/instructions/guide/05-glossary.md +183 -0
  87. package/.framework/src/instructions/integrations.md +96 -0
  88. package/.framework/src/instructions/internal/cil-markers.md +83 -0
  89. package/.framework/src/instructions/invites.md +60 -0
  90. package/.framework/src/instructions/kb.md +80 -0
  91. package/.framework/src/instructions/logs.md +77 -0
  92. package/.framework/src/instructions/observability.md +61 -0
  93. package/.framework/src/instructions/operations/deployment.md +115 -0
  94. package/.framework/src/instructions/operations/migrations.md +125 -0
  95. package/.framework/src/instructions/operations/security-checklist.md +148 -0
  96. package/.framework/src/instructions/operations/troubleshooting.md +170 -0
  97. package/.framework/src/instructions/operations/upgrade.md +116 -0
  98. package/.framework/src/instructions/pipeline-executions.md +62 -0
  99. package/.framework/src/instructions/pipelines.md +78 -0
  100. package/.framework/src/instructions/prompts.md +95 -0
  101. package/.framework/src/instructions/reference/api/admin-data.md +162 -0
  102. package/.framework/src/instructions/reference/api/auth.md +113 -0
  103. package/.framework/src/instructions/reference/api/errors-and-envelopes.md +113 -0
  104. package/.framework/src/instructions/reference/app-manifest.md +150 -0
  105. package/.framework/src/instructions/reference/cli.md +124 -0
  106. package/.framework/src/instructions/reference/database.md +132 -0
  107. package/.framework/src/instructions/reference/design-schema.md +280 -0
  108. package/.framework/src/instructions/reference/env-vars.md +133 -0
  109. package/.framework/src/instructions/reference/functions/account-nodes.md +75 -0
  110. package/.framework/src/instructions/reference/functions/admin-data.md +195 -0
  111. package/.framework/src/instructions/reference/functions/admin-funnel.md +90 -0
  112. package/.framework/src/instructions/reference/functions/admin-install-funnel.md +107 -0
  113. package/.framework/src/instructions/reference/functions/admin-signals.md +102 -0
  114. package/.framework/src/instructions/reference/functions/ai-agents.md +148 -0
  115. package/.framework/src/instructions/reference/functions/ai-interactions.md +156 -0
  116. package/.framework/src/instructions/reference/functions/api-keys.md +130 -0
  117. package/.framework/src/instructions/reference/functions/apps.md +140 -0
  118. package/.framework/src/instructions/reference/functions/auth.md +99 -0
  119. package/.framework/src/instructions/reference/functions/debug-auth.md +91 -0
  120. package/.framework/src/instructions/reference/functions/deliveries.md +110 -0
  121. package/.framework/src/instructions/reference/functions/embeddings.md +166 -0
  122. package/.framework/src/instructions/reference/functions/eval-harness.md +149 -0
  123. package/.framework/src/instructions/reference/functions/index.md +103 -0
  124. package/.framework/src/instructions/reference/functions/integration-outbound.md +200 -0
  125. package/.framework/src/instructions/reference/functions/integration-routes.md +151 -0
  126. package/.framework/src/instructions/reference/functions/integrations.md +130 -0
  127. package/.framework/src/instructions/reference/functions/invites.md +182 -0
  128. package/.framework/src/instructions/reference/functions/item-progress.md +107 -0
  129. package/.framework/src/instructions/reference/functions/kb.md +166 -0
  130. package/.framework/src/instructions/reference/functions/logs.md +141 -0
  131. package/.framework/src/instructions/reference/functions/observability.md +105 -0
  132. package/.framework/src/instructions/reference/functions/pipeline-executions.md +132 -0
  133. package/.framework/src/instructions/reference/functions/pipeline-runner-background.md +121 -0
  134. package/.framework/src/instructions/reference/functions/pipelines.md +136 -0
  135. package/.framework/src/instructions/reference/functions/prompt-configs.md +121 -0
  136. package/.framework/src/instructions/reference/functions/roles.md +121 -0
  137. package/.framework/src/instructions/reference/functions/security.md +140 -0
  138. package/.framework/src/instructions/reference/functions/system-cron.md +136 -0
  139. package/.framework/src/instructions/reference/functions/system.md +106 -0
  140. package/.framework/src/instructions/reference/functions/tests.md +97 -0
  141. package/.framework/src/instructions/reference/functions/timers.md +117 -0
  142. package/.framework/src/instructions/reference/functions/trigger-scheduler.md +102 -0
  143. package/.framework/src/instructions/reference/functions/triggers.md +140 -0
  144. package/.framework/src/instructions/reference/functions/types.md +146 -0
  145. package/.framework/src/instructions/reference/seeds.md +126 -0
  146. package/.framework/src/instructions/reference/shared-modules.md +127 -0
  147. package/.framework/src/instructions/reference/spine-config.md +114 -0
  148. package/.framework/src/instructions/roles.md +80 -0
  149. package/.framework/src/instructions/runtime-detail.md +70 -0
  150. package/.framework/src/instructions/runtime-list.md +77 -0
  151. package/.framework/src/instructions/security.md +67 -0
  152. package/.framework/src/instructions/tasks/add-a-pipeline.md +110 -0
  153. package/.framework/src/instructions/tasks/add-a-role.md +96 -0
  154. package/.framework/src/instructions/tasks/add-a-timer.md +114 -0
  155. package/.framework/src/instructions/tasks/add-a-trigger.md +106 -0
  156. package/.framework/src/instructions/tasks/add-a-type.md +151 -0
  157. package/.framework/src/instructions/tasks/add-a-webhook.md +108 -0
  158. package/.framework/src/instructions/tasks/add-an-ai-agent.md +108 -0
  159. package/.framework/src/instructions/tasks/add-an-integration.md +124 -0
  160. package/.framework/src/instructions/tasks/build-a-custom-page.md +118 -0
  161. package/.framework/src/instructions/tasks/package-and-install-an-app.md +127 -0
  162. package/.framework/src/instructions/tasks/test-your-code.md +108 -0
  163. package/.framework/src/instructions/tasks/write-a-function.md +132 -0
  164. package/.framework/src/instructions/tasks/write-a-migration.md +110 -0
  165. package/.framework/src/instructions/testing.md +59 -0
  166. package/.framework/src/instructions/timers.md +82 -0
  167. package/.framework/src/instructions/triggers.md +69 -0
  168. package/.framework/src/instructions/types.md +93 -0
  169. package/.framework/src/pages/NotFoundPage.tsx +62 -31
  170. package/.framework/src/pages/admin/AIAgentDetailPage.tsx +117 -106
  171. package/.framework/src/pages/admin/AIAgentsPage.tsx +86 -48
  172. package/.framework/src/pages/admin/APIKeyDetailPage.tsx +153 -152
  173. package/.framework/src/pages/admin/APIKeysPage.tsx +91 -90
  174. package/.framework/src/pages/admin/AlertsConfigPage.tsx +29 -18
  175. package/.framework/src/pages/admin/AppDetailPage.tsx +6 -60
  176. package/.framework/src/pages/admin/AppsPage.tsx +104 -66
  177. package/.framework/src/pages/admin/DeliveriesPage.tsx +5 -5
  178. package/.framework/src/pages/admin/EmbeddingDetailPage.tsx +5 -23
  179. package/.framework/src/pages/admin/EmbeddingsPage.tsx +5 -26
  180. package/.framework/src/pages/admin/IntegrationDetailPage.tsx +7 -7
  181. package/.framework/src/pages/admin/IntegrationsPage.tsx +85 -43
  182. package/.framework/src/pages/admin/LogsPage.tsx +144 -76
  183. package/.framework/src/pages/admin/ObservabilityDashboard.tsx +223 -140
  184. package/.framework/src/pages/admin/PipelineDetailPage.tsx +134 -113
  185. package/.framework/src/pages/admin/PipelineExecutionsPage.tsx +108 -45
  186. package/.framework/src/pages/admin/PipelinesPage.tsx +160 -115
  187. package/.framework/src/pages/admin/PromptConfigDetailPage.tsx +96 -98
  188. package/.framework/src/pages/admin/PromptConfigsPage.tsx +101 -59
  189. package/.framework/src/pages/admin/RoleDetailPage.tsx +90 -79
  190. package/.framework/src/pages/admin/RolesPage.tsx +86 -43
  191. package/.framework/src/pages/admin/SecurityPage.tsx +1 -1
  192. package/.framework/src/pages/admin/TestingDashboard.tsx +16 -28
  193. package/.framework/src/pages/admin/TimerDetailPage.tsx +117 -100
  194. package/.framework/src/pages/admin/TimersPage.tsx +90 -62
  195. package/.framework/src/pages/admin/TriggerDetailPage.tsx +90 -83
  196. package/.framework/src/pages/admin/TriggersPage.tsx +124 -99
  197. package/.framework/src/pages/admin/TypeDetailPage.tsx +152 -138
  198. package/.framework/src/pages/admin/TypesPage.tsx +90 -48
  199. package/.framework/src/pages/admin/cil/CILAgentPage.tsx +17 -25
  200. package/.framework/src/pages/admin/cil/CILChunkDetailPage.tsx +17 -27
  201. package/.framework/src/pages/admin/cil/CILDashboardPage.tsx +72 -40
  202. package/.framework/src/pages/admin/cil/CILFileListPage.tsx +321 -129
  203. package/.framework/src/pages/admin/cil/CILFileSelectPage.tsx +18 -29
  204. package/.framework/src/pages/admin/cil/CILGraphPage.tsx +26 -38
  205. package/.framework/src/pages/admin/cil/CILIngestionPage.tsx +34 -46
  206. package/.framework/src/pages/admin/cil/CILProjectsPage.tsx +189 -103
  207. package/.framework/src/pages/admin/cil/CILSearchPage.tsx +246 -136
  208. package/.framework/src/pages/admin/cil/CILSuggestionsPage.tsx +11 -22
  209. package/.framework/src/pages/admin/cil/CILVersionsPage.tsx +9 -20
  210. package/.framework/src/pages/admin/cil/FlexiblePipelinePage.tsx +26 -38
  211. package/.framework/src/pages/admin/kb/KBAdminPage.tsx +7 -26
  212. package/.framework/templates/agent/AGENTS.md +150 -0
  213. package/.framework/templates/agent/skills/spine-add-ai-agent/SKILL.md +58 -0
  214. package/.framework/templates/agent/skills/spine-add-automation/SKILL.md +62 -0
  215. package/.framework/templates/agent/skills/spine-add-integration/SKILL.md +63 -0
  216. package/.framework/templates/agent/skills/spine-architect/SKILL.md +86 -0
  217. package/.framework/templates/agent/skills/spine-install-app/SKILL.md +72 -0
  218. package/.framework/templates/agent/skills/spine-migration/SKILL.md +75 -0
  219. package/.framework/templates/agent/skills/spine-new-app/SKILL.md +67 -0
  220. package/.framework/templates/agent/skills/spine-new-function/SKILL.md +65 -0
  221. package/.framework/templates/agent/skills/spine-new-type/SKILL.md +65 -0
  222. package/.framework/templates/agent/skills/spine-schema/SKILL.md +77 -0
  223. package/.framework/templates/agent/skills/spine-test/SKILL.md +67 -0
  224. package/.framework/templates/agent/skills/spine-troubleshoot/SKILL.md +74 -0
  225. package/.framework/templates/agent/skills/spine-upgrade/SKILL.md +69 -0
  226. package/.framework/templates/project.json +4 -1
  227. package/.framework/tests/unit/account-scoping-gates.test.ts +392 -0
  228. package/.framework/tests/unit/agent-files.test.ts +355 -0
  229. package/.framework/tests/unit/agent-runner.test.ts +479 -44
  230. package/.framework/tests/unit/api-keys-create-scope-gate.test.ts +160 -0
  231. package/.framework/tests/unit/api-keys-omit-secret-fields.test.ts +38 -0
  232. package/.framework/tests/unit/bootstrap.test.ts +242 -0
  233. package/.framework/tests/unit/cli-context-api-key.test.ts +114 -0
  234. package/.framework/tests/unit/debug-auth.test.ts +38 -0
  235. package/.framework/tests/unit/deliveries-account-scoping.test.ts +185 -0
  236. package/.framework/tests/unit/integration-outbound-credentials.test.ts +167 -0
  237. package/.framework/tests/unit/integrations-audit-redaction.test.ts +130 -0
  238. package/.framework/tests/unit/logging-app-id.test.ts +75 -0
  239. package/.framework/tests/unit/system-context-denial.test.ts +145 -0
  240. package/.framework/tests/unit/system-cron.test.ts +240 -0
  241. package/.framework/tests/unit/timers.test.ts +159 -0
  242. package/README.md +125 -166
  243. package/config/tsconfig.cli.json +2 -2
  244. package/package.json +15 -4
  245. package/templates/project/package-lock.json +2 -2
  246. package/.framework/docs/admin-routes.md +0 -76
  247. package/.framework/docs/api-docs-progress.md +0 -38
  248. package/.framework/docs/api-governance.md +0 -146
  249. package/.framework/docs/api-testing-results.md +0 -212
  250. package/.framework/docs/assembly-launch-guide.md +0 -138
  251. package/.framework/docs/audit-results.md +0 -590
  252. package/.framework/docs/db-api-inventory.md +0 -95
  253. package/.framework/docs/gap-remediation-backlog.md +0 -103
  254. package/.framework/docs/ui-adoption-verification.md +0 -111
  255. package/.framework/docs/ui-api-coverage.md +0 -84
  256. package/.framework/docs/v2-compatibility-audit.md +0 -228
  257. package/.framework/mcp/index.ts +0 -133
  258. package/.framework/mcp/load-env.ts +0 -60
  259. package/.framework/mcp/shared/app-manifest.ts +0 -275
  260. package/.framework/mcp/shared/db.ts +0 -477
  261. package/.framework/mcp/shared/kb.ts +0 -118
  262. package/.framework/mcp/tools/architect.ts +0 -431
  263. package/.framework/mcp/tools/cil/context.ts +0 -345
  264. package/.framework/mcp/tools/cil/graph.ts +0 -242
  265. package/.framework/mcp/tools/cil/ingest.ts +0 -1217
  266. package/.framework/mcp/tools/cil/pipeline-orchestrator.ts +0 -693
  267. package/.framework/mcp/tools/cil/pipeline.ts +0 -767
  268. package/.framework/mcp/tools/cil/project.ts +0 -791
  269. package/.framework/mcp/tools/cil/retrieval.ts +0 -336
  270. package/.framework/mcp/tools/cil/search-core.ts +0 -454
  271. package/.framework/mcp/tools/cil/search.ts +0 -97
  272. package/.framework/mcp/tools/cil/suggest.ts +0 -186
  273. package/.framework/mcp/tools/cil/validate.ts +0 -1369
  274. package/.framework/mcp/tools/kb/delete.ts +0 -139
  275. package/.framework/mcp/tools/kb/index.ts +0 -52
  276. package/.framework/mcp/tools/kb/ingest.ts +0 -84
  277. package/.framework/mcp/tools/kb/list-types.ts +0 -102
  278. package/.framework/mcp/tools/kb/publish.ts +0 -100
  279. package/.framework/mcp/tools/kb/reindex.ts +0 -86
  280. package/.framework/mcp/tools/kb/revoke.ts +0 -85
  281. package/.framework/mcp/tools/kb/search.ts +0 -101
  282. package/.framework/mcp/tools/kb/upsert.ts +0 -125
  283. package/.framework/mcp/tools/observability.ts +0 -510
@@ -0,0 +1,150 @@
1
+ ---
2
+ title: App Manifest Reference
3
+ audience: developers, agents
4
+ kind: reference
5
+ verified_against: f69c37d
6
+ verified_on: 2026-10-30
7
+ source_files:
8
+ - .framework/functions/_shared/app-manifest.ts
9
+ - .framework/cli/commands/install-app.ts
10
+ - .framework/cli/commands/validate-app.ts
11
+ ---
12
+
13
+ # App Manifest Reference
14
+
15
+ `manifest.json` is the install-time and runtime descriptor every app carries
16
+ at `custom/apps/<slug>/manifest.json`. Two consumers read it:
17
+
18
+ - **CLI installers** (`install-app`, `update-app`, `update-db-app`, `seed-app`,
19
+ `uninstall-app` in `.framework/cli/commands/install-app.ts`) — copy files,
20
+ upsert the `public.apps` row, run the `seed` block, and sync the
21
+ `registration` policy into `apps.config` and `spine.config.json`.
22
+ - **Runtime** (`loadManifest` / `mergeWithManifest` / `discoverManifests` in
23
+ `.framework/functions/_shared/app-manifest.ts`) — when an `apps` row has
24
+ `manifest_path` set and `config_source = 'manifest'`, the manifest file
25
+ overrides DB columns for slug, name, roles, routes, and nav.
26
+
27
+ See [Seeds](seeds.md) for the seed mechanics and
28
+ [spine.config.json](spine-config.md) for the registration file the installer
29
+ writes.
30
+
31
+ ## Required fields
32
+
33
+ | Field | Rule |
34
+ |---|---|
35
+ | `name` | non-empty string |
36
+ | `slug` | must match `/^[a-z][a-z0-9-]*$/`, equal the app directory name, and equal the `seed-app`/`update-db-app` argument |
37
+
38
+ `loadManifest` rejects manifests missing either, and `preflightAppInputs`
39
+ rejects a manifest whose `slug` does not match the app's directory slug —
40
+ before any database work happens.
41
+
42
+ ## Runtime fields (`AppManifest`)
43
+
44
+ Read by `.framework/functions/_shared/app-manifest.ts` and mirrored onto the
45
+ `apps` row by `appRowPayload` in the installer:
46
+
47
+ | Field | Type | Default on the apps row |
48
+ |---|---|---|
49
+ | `description` | string | `''` |
50
+ | `version` | string | `'1.0.0'` |
51
+ | `required_roles` | string[] | `[]`; `min_role` column becomes `required_roles[0]` (or legacy `min_role`) |
52
+ | `route_prefix` | string | `'/' + slug` |
53
+ | `renderer` | `'generic' \| 'custom' \| 'none'` | `'custom'` — matches the `apps.renderer` CHECK constraint |
54
+ | `routes` | string[] | app route paths; `:param` segments supported |
55
+ | `nav_items` | `NavItem[]` | `[]` — `{title, path, icon?, order?, type_slug?, view?, children?}`. **`path` must include the `route_prefix`** (e.g. `/taskboard/tasks`, not `/tasks`) — the app index navigates to `path` verbatim, so a bare path escapes the app and 404s. `view` is **one slug consumed by both the list and the detail page** — naming `default_list` makes the detail page resolve a list view (which has `fields`, not `sections`) and render empty. Omit `view` to get `default_list` + `default_detail`; a nav item cannot pick list and detail views independently |
56
+ | `features` | string[] | `[]` |
57
+ | `dependencies` | string[] | `[]` |
58
+ | `entry_point` | string | e.g. `"./index.tsx"` |
59
+ | `is_public` | boolean | `false` — reachable without auth when true |
60
+ | `auth_required` | boolean | `true` |
61
+ | `preview_domain` | string | `null` |
62
+ | `prod_domain` | string | `null` |
63
+
64
+ `mergeWithManifest` always keeps DB-owned values for `id`, `is_active`,
65
+ `is_system`, `account_id`, `pack_id`, and `ownership`; the manifest wins for
66
+ `slug`, `name`, `required_roles`, `routes`, `nav_items`, `features`,
67
+ `dependencies`, `version`, `is_public`, `auth_required`.
68
+
69
+ ## Installer-only fields
70
+
71
+ Consumed by `.framework/cli/commands/install-app.ts`; ignored by the runtime
72
+ loader:
73
+
74
+ | Field | Type | Purpose |
75
+ |---|---|---|
76
+ | `app_type` | string | informational; the installer always writes `app_type: 'custom'` on the apps row |
77
+ | `sidebar_component` | string | app-relative path to a sidebar component |
78
+ | `seed` | `SeedEntry[]` | seed declarations — see below and [Seeds](seeds.md) |
79
+ | `owned_types` | string[] | type slugs this app may reconcile when `--reconcile-owned-types` is passed; every slug must exist in a types seed |
80
+ | `registration` | object | registration policy synced to `apps.config.registration` and `spine.config.json` |
81
+ | `config` | object | merged (shallow) into `apps.config`; existing keys the manifest does not declare survive |
82
+ | `metadata` | object | written to `apps.metadata` |
83
+
84
+ ### `seed[]` entries
85
+
86
+ ```json
87
+ "seed": [
88
+ { "file": "seed/roles.json", "table": "roles", "conflict": "slug" },
89
+ { "file": "seed/types.json", "table": "types", "conflict": "kind,slug", "inject_app_id": false },
90
+ { "file": "seed/link-types.json", "table": "link_types", "conflict": "app_id,slug" },
91
+ { "file": "seed/type_permissions.json", "table": "types", "conflict": "kind,slug",
92
+ "inject_app_id": false, "permissions_patch": true },
93
+ { "file": "seed/pipelines.json", "table": "pipelines", "conflict": "app_id,slug" },
94
+ { "file": "seed/triggers.json", "table": "triggers", "conflict": "app_id,slug" }
95
+ ]
96
+ ```
97
+
98
+ | Key | Rule |
99
+ |---|---|
100
+ | `file` | path relative to the app root; must resolve inside the app directory (canonicalization rejects `..` and symlink escapes). **Declared files must exist** — a missing declared file fails the install |
101
+ | `table` | target `public.*` table |
102
+ | `conflict` | PostgREST `onConflict` columns, e.g. `slug`, `kind,slug`, `app_id,slug` |
103
+ | `inject_app_id` | default `true` — stamps `app_id` on every row. Set `false` for global rows (types are global per `kind,slug`) |
104
+ | `ignore_duplicates` | upsert skips existing rows instead of updating (always forced for `types`) |
105
+ | `permissions_patch` | row shape `{kind, slug, record_permissions}`; patches `design_schema.record_permissions` on an existing type |
106
+
107
+ If `manifest.seed` is absent, the installer falls back to the conventional set:
108
+ `seed/roles.json`, `seed/types.json` (`inject_app_id: false`),
109
+ `seed/link-types.json`. A `seed/type_permissions.json` file is auto-declared
110
+ as a `permissions_patch` entry even when `seed` is explicit, unless a patch
111
+ entry already exists. Every row of a `types` seed gets a fresh
112
+ `validation_schema` generated from its `design_schema` at apply time.
113
+
114
+ ### `registration`
115
+
116
+ ```json
117
+ "registration": {
118
+ "enabled": true,
119
+ "default_role": "member_admin",
120
+ "redirect_path": "/my-app",
121
+ "account_strategy": "new",
122
+ "parent_account": "spine-system",
123
+ "target_account": "<account-id>",
124
+ "allow_domain_join": false,
125
+ "default_workspace_name": "Team"
126
+ }
127
+ ```
128
+
129
+ Validated at preflight: `registration` must be an object; `enabled` must be a
130
+ boolean; when `enabled: true`, `default_role` and `redirect_path` are required
131
+ non-empty strings. The resolved entry is written to both
132
+ `apps.config.registration` (server-side source of truth) and
133
+ `spine.config.json` `registration.apps.<slug>` — see
134
+ [spine.config.json](spine-config.md). `account_strategy` is `new` or
135
+ `existing`; `parent_account`/`target_account` select where new accounts/users
136
+ land.
137
+
138
+ ## App-row mapping
139
+
140
+ `appRowPayload` upserts `public.apps` on `slug` with `app_type: 'custom'`,
141
+ `source: 'npm'`, `is_active: true`, and the manifest-derived columns above.
142
+ `manifest.config` is shallow-merged over the existing `apps.config` (manifest
143
+ wins shared keys; unrelated keys are preserved).
144
+
145
+ ## Related files
146
+
147
+ - `.framework/functions/_shared/app-manifest.ts` — runtime loader, cache, discovery, manifest-over-DB merge
148
+ - `.framework/cli/commands/install-app.ts` — preflight, `appRowPayload`, `seedApp`, `syncAppRegistration`
149
+ - `.framework/cli/commands/validate-app.ts` — `spine-framework validate-app` structural checks
150
+ - [Apps](../apps.md) · [Seeds](seeds.md) · [spine.config.json](spine-config.md) · [Apps and Renderers](../concepts/apps-and-renderers.md)
@@ -0,0 +1,124 @@
1
+ ---
2
+ title: CLI Reference
3
+ audience: developers, agents
4
+ kind: reference
5
+ verified_against: f69c37d
6
+ verified_on: 2026-10-30
7
+ source_files:
8
+ - .framework/cli/index.ts
9
+ - .framework/cli/context.ts
10
+ - .framework/cli/commands/agents.ts
11
+ - .framework/cli/commands/auth.ts
12
+ - .framework/cli/commands/bootstrap.ts
13
+ - .framework/cli/commands/create-app.ts
14
+ - .framework/cli/commands/doctor.ts
15
+ - .framework/cli/commands/init.ts
16
+ - .framework/cli/commands/install-app.ts
17
+ - .framework/cli/commands/items.ts
18
+ - .framework/cli/commands/migrate.ts
19
+ - .framework/cli/commands/migrations.ts
20
+ - .framework/cli/commands/pipelines.ts
21
+ - .framework/cli/commands/status.ts
22
+ - .framework/cli/commands/system.ts
23
+ - .framework/cli/commands/test.ts
24
+ - .framework/cli/commands/upgrade.ts
25
+ - .framework/cli/commands/validate-app.ts
26
+ - .framework/cli/commands/validate-schema.ts
27
+ - .framework/cli/commands/dev.ts
28
+ - .framework/cli/commands/generate.ts
29
+ ---
30
+
31
+ # CLI Reference
32
+
33
+ `spine-framework` is the project CLI (bin entry `.framework/cli/bin.mjs` →
34
+ `.framework/cli/index.ts`, Commander.js). Run it as `npx spine-framework …`
35
+ or via the project script `npm run spine-framework -- …`.
36
+
37
+ Global behaviors:
38
+
39
+ - `--account <id>` on the root program overrides the account scope.
40
+ - Most read commands accept `--json` for machine output.
41
+ - Credential resolution lives in `.framework/cli/context.ts`: DB-backed
42
+ commands need `SUPABASE_URL` + `SUPABASE_SERVICE_ROLE_KEY`; remote commands
43
+ authenticate with `SPINE_CLI_API_KEY` or `SPINE_CLI_JWT`; see
44
+ [Environment Variables](env-vars.md).
45
+ - `.env` in the project root is preloaded by the bin wrapper before any
46
+ command module evaluates.
47
+
48
+ ## Project lifecycle
49
+
50
+ | Command | What it does |
51
+ |---|---|
52
+ | `init [dir]` | Scaffolds a Spine project: copies framework files, creates `custom/` workspace dirs (`apps`, `functions`, `components`, `migrations`, `tests`), writes `package.json`/`package-lock.json`, agent files. Refuses to run over an existing `.framework/` |
53
+ | `bootstrap` | Provisions the first `system_admin` (person bound to `spine-system`, same columns the `handle_new_auth_user` trigger writes) and mints the first `sk_` API key — fully scriptable, no browser. `--email`/`--password` also creates a confirmed auth user via `auth.admin.createUser` (UI-login capable); without them the person row is DB-only. `--scope <scope>` is repeatable (default `*:*` = system_admin), `--name`, `--full-name`, `--json`. Idempotent: an existing `system_admin` skips person creation; each run mints one new key (hash stored, raw key printed once) |
54
+ | `upgrade` | Syncs project files to the `spine-framework` version in `node_modules`. `--dry-run` reports without writing; `--force` overwrites locally modified framework files |
55
+ | `status` | Shows installed apps and framework version (`--json`) |
56
+ | `doctor` | Validates installation health (env, files, DB reachability). `--fix` prints repair instructions; `--ticket <id>` attaches a sanitized diagnostic report to a support ticket |
57
+ | `test [suite]` | Runs Vitest suites. `--watch` for unit/integration; `--reporter <name>`; `--json` |
58
+ | `dev` | Runs `scripts/assemble.sh`, verifies integrity (`--no-verify` skips), then starts Vite via `config/vite.config.ts` on `--port` (default 3001; `--host` exposes to network) — equivalent to `npm run dev`. `--netlify` runs `scripts/dev-netlify.sh` instead (functions + UI on :8888, equivalent to `npm run dev:netlify`; `--port`/`--host` are ignored). Watches `custom/` and re-assembles on change; `--no-watch`, `--watch-delay <ms>` |
59
+
60
+ ## Database
61
+
62
+ | Command | What it does |
63
+ |---|---|
64
+ | `migrate` | Applies pending `.framework/migrations/` then `custom/migrations/` SQL files in filename order, tracked in the `_spine_migrations` ledger table, one transaction per file. `--db-password` (default `SUPABASE_DB_PASSWORD`), `--dry-run`, `--framework-only` (skip `custom/`) |
65
+ | `migrations list` | Lists applied migrations from `supabase_migrations.schema_migrations` (`--json`) |
66
+ | `migrations status` | Diffs local migration files against applied ones (`--json`) |
67
+
68
+ ## App management
69
+
70
+ | Command | What it does |
71
+ |---|---|
72
+ | `install-app <package>` | `npm install`s the package, copies `index.tsx`, `manifest.json`, `package.json`, `pages`, `components`, `hooks`, `utils`, `functions`, `seed`, `public` into `custom/apps/<slug>/` (on reinstall `manifest.json` is preserved — use `update-db-app` to sync it), runs migrations, then seeds and syncs registration. `--no-seed` installs files only; `--reconcile-owned-types` prompts to update manifest-owned types whose DB `design_schema` drifted |
73
+ | `uninstall-app <package>` | Removes `custom/apps/<slug>/` and `npm uninstall`s the package. **`--keep-data` is currently a no-op — the command never deletes seeded DB rows** |
74
+ | `update-app <package>` | `npm install <pkg>@latest`, re-copies app files into `custom/apps/<slug>/`, re-syncs registration config |
75
+ | `update-db-app <slug>` | Upserts the `apps` row and registration from local `manifest.json` — no npm, no file copies |
76
+ | `seed-app <slug>` | Runs only the manifest `seed` block (plus registration sync). `--reconcile-owned-types` as above |
77
+ | `validate-app [path]` | Validates app structure and `manifest.json`. `--fix` is declared but **not implemented** |
78
+ | `create-app <slug>` | Scaffolds a new custom app in `custom/apps/<slug>/` (index, manifest, starter pages). `--name`, `--role`, `--force` |
79
+ | `validate-schema <file>` | Validates a `design_schema` JSON file against the field/view/permission rules. `--no-views` skips `default_list`/`default_detail` requirements (for custom apps); `--json` |
80
+
81
+ ## Runtime data
82
+
83
+ These commands talk to a running instance via the API
84
+ (`SPINE_CLI_API_KEY`/`SPINE_CLI_JWT` + `SUPABASE_URL`).
85
+
86
+ | Command | What it does |
87
+ |---|---|
88
+ | `auth whoami` | Prints the resolved principal for the current env config (`--json`) |
89
+ | `auth check` | Exits 0 when credentials resolve, 1 otherwise — CI gate |
90
+ | `items list` | Lists items. `--type <slug>`, `--account`, `--limit`, `--json` |
91
+ | `items get <id>` | Fetches one item (`--json`) |
92
+ | `items create` | `--type <slug>`, `--data <json>`, `--title`, `--account` |
93
+ | `items update <id>` | `--data <json>` partial update, `--title` |
94
+ | `items delete <id>` | Soft-deletes (`is_active = false`); `--hard` permanently removes |
95
+ | `pipelines list` | Lists active pipelines. `--all` includes inactive; `--account`, `--json` |
96
+ | `pipelines get <id>` | Pipeline detail (`--json`) |
97
+ | `pipelines run <id>` | Executes a pipeline. `--data <json>` trigger payload, `--account` |
98
+ | `pipelines executions <id>` | Recent executions. `--limit`, `--json` |
99
+ | `agents run <threadId>` | Sends a message to an agent thread and returns the response. `--message` required, `--account`, `--json` |
100
+ | `agents threads list` | Lists agent threads. `--account`, `--limit`, `--json` |
101
+ | `agents threads get <id>` | Thread detail + recent messages. `--limit`, `--json` |
102
+
103
+ ## System
104
+
105
+ | Command | What it does |
106
+ |---|---|
107
+ | `system manifest` | Fetches the instance manifest (version, functions, migrations) from the `system` function (`--json`) |
108
+ | `system health` | Fetches health-check status (`--json`) |
109
+ | `system openapi` | Fetches the OpenAPI specification |
110
+
111
+ ## Removed commands
112
+
113
+ These commands remain registered so callers get a clear message instead of
114
+ silent failure — do not build workflows on them.
115
+
116
+ | Command | Status |
117
+ |---|---|
118
+ | `generate [slug]` | **Removed.** Previously wrote type/handler/page stubs to a `v2-custom/` tree and emitted a legacy `design_schema` shape — both dead. Now prints migration guidance (`create-app` for apps; admin UI or `POST /api/types` + `validate-schema` for types) and exits 1 |
119
+
120
+ ## Related
121
+
122
+ - `.framework/cli/index.ts` — command registration
123
+ - `.framework/cli/context.ts` — credential and account resolution
124
+ - [Seeds](seeds.md) · [App Manifest](app-manifest.md) · [Environment Variables](env-vars.md)
@@ -0,0 +1,132 @@
1
+ ---
2
+ title: Database Reference
3
+ audience: developers, agents
4
+ kind: reference
5
+ verified_against: f69c37d
6
+ verified_on: 2026-10-30
7
+ source_files:
8
+ - .framework/migrations/001_core_schema.sql
9
+ - .framework/migrations/004_core_rpc_and_broker.sql
10
+ - .framework/migrations/018_runtime_tables.sql
11
+ - .framework/migrations/035_rate_limits.sql
12
+ - .framework/migrations/049_security_blocklist.sql
13
+ - .framework/migrations/050_notifications.sql
14
+ - .framework/migrations/054_kb_ingest_lease.sql
15
+ - .framework/migrations/064_episode_leases.sql
16
+ - .framework/cli/commands/migrate.ts
17
+ - .framework/src/types/types.ts
18
+ ---
19
+
20
+ # Database Reference
21
+
22
+ Postgres (Supabase) tables that custom code touches, grouped by purpose.
23
+ Column lists are the ones custom code actually reads/writes — every table has
24
+ `id uuid` plus `created_at`, and most have `updated_at`, `is_active`,
25
+ `account_id`, `app_id`, `created_by`/`updated_by`, and stamped
26
+ `design_schema`/`validation_schema` jsonb. The canonical DDL is
27
+ `.framework/migrations/001_core_schema.sql` (base) plus later migrations.
28
+
29
+ ## Tenancy & identity
30
+
31
+ | Table | Purpose | Key columns |
32
+ |---|---|---|
33
+ | `accounts` | Tenant boundary; every scoped row hangs off one | `slug` UNIQUE, `display_name`, `parent_id`, `type_id`, `data`, `logs_retention_days`, `observability_retention_days` |
34
+ | `account_paths` | Closure table for account hierarchies | `ancestor_id`, `descendant_id`, `depth` (PK pair) |
35
+ | `people` | Human users (one per Supabase auth user + invite stubs) | `auth_uid` UNIQUE, `email` UNIQUE, `full_name`, `account_id`, `role_id`, `status`, `data` |
36
+ | `roles` | Role definitions granting record/field permissions | `slug` UNIQUE, `name`, `permissions` jsonb, `is_system`, `is_protected`, `account_id` |
37
+ | `system_settings` | Instance/account-scoped key-value settings | `scope`, `scope_id`, `key`, `value` |
38
+ | `invites` | Invite tokens and placement config | `app_id`, `account_id`, `slug`, `config`, `is_active` |
39
+
40
+ ## Types, apps, configuration
41
+
42
+ | Table | Purpose | Key columns |
43
+ |---|---|---|
44
+ | `types` | Type definitions — the `design_schema` contract lives here | `kind`, `slug` (UNIQUE per `kind,slug` since 015), `name`, `icon`, `color`, `design_schema`, `validation_schema`, `ownership`, `is_active`, `app_id` |
45
+ | `apps` | Installed apps | `slug` UNIQUE, `name`, `app_type`, `source`, `renderer` (`generic`/`custom`/`none`), `route_prefix`, `required_roles`, `min_role`, `config` (incl. `registration`), `nav_items`, `manifest_path`, `config_source` |
46
+ | `link_types` | Named link semantics between records | `slug`, `name`, `config`, `source_kind`, `target_kind` |
47
+
48
+ ## Runtime records
49
+
50
+ Every runtime row is typed (`type_id` → `types`) and stamped with the type's
51
+ schemas at insert. `system: true` fields are top-level columns; others live
52
+ in `data`.
53
+
54
+ | Table | Purpose | Key columns |
55
+ |---|---|---|
56
+ | `items` | The workhorse record kind | `type_id`, `title`, `status`, `data`, `account_id`, `app_id` |
57
+ | `threads` | Conversation containers bound to a target record | `type_id`, `title`, `target_type`, `target_id`, `visibility` (`internal`/`external`/`public`), `status`; UNIQUE `(target_type, target_id, visibility)` |
58
+ | `messages` | Posts inside threads | `thread_id`, `type_id`, `content`, `direction`, `sequence`, `visibility`, `person_id`; UNIQUE `(thread_id, sequence)` |
59
+ | `links` | Typed edges between records | `link_type_id`, `link_type`, `source_type`/`source_id`, `target_type`/`target_id`; UNIQUE edge constraint |
60
+ | `attachments` | File records | `filename`, `file_size`, `mime_type`, `storage_path`, `storage_provider`, `uploaded_by` |
61
+ | `watchers` | People watching a target record | `target_type`/`target_id`, `person_id`, `watch_type`, `notification_level`; UNIQUE `(target_type, target_id, person_id)` |
62
+ | `item_progress` | Per-item pipeline progress rows | `item_id`, `slug`, `config`, `status` fields |
63
+
64
+ ## Automation
65
+
66
+ | Table | Purpose | Key columns |
67
+ |---|---|---|
68
+ | `pipelines` | Declarative stage sequences | `slug`, `name`, `config`/`metadata` (incl. `stages[]`), `account_id`, `app_id`, UNIQUE `(app_id, slug)` |
69
+ | `pipeline_executions` | Pipeline run ledger | `pipeline_id` FK CASCADE, `status`, `started_at`, `completed_at`, `input_data`, `output_data`, `error_message` |
70
+ | `triggers` | Event→pipeline dispatch rules | `slug`, `config` (event type, entity, filters, `pipeline_id`), `account_id`, UNIQUE `(app_id, slug)` |
71
+ | `trigger_executions` | Trigger fire ledger | `trigger_id` FK CASCADE, `status`, `input_data`, `output_data` |
72
+ | `timers` | Scheduled work definitions | `slug`, `config`, `account_id`, UNIQUE `(app_id, slug)` |
73
+ | `schedules` | Cron schedule principals (018) | schedule rows bound to `machine_principal_id` with `delegated_scopes` |
74
+ | `schedule_executions` | Schedule run ledger (018) | execution rows |
75
+ | `actions` | Stage-type catalog for pipelines (018, seeded by 053) | `slug`, `name`, `config`, `default_machine_principal_id` |
76
+ | `episode_leases` | Agent-episode concurrency leases (064) | lease rows gated by `lease_token` |
77
+ | `document_leases` | KB ingest leases by content hash (054) | lease rows |
78
+ | `rate_limits` | Atomic rate counters for `rate_limit_hit` RPC (035) | `key`, `window_start`, `count` |
79
+
80
+ ## AI & knowledge
81
+
82
+ | Table | Purpose | Key columns |
83
+ |---|---|---|
84
+ | `ai_agents` | Agent configurations | `slug`, `name`, `config` (model, prompts, capabilities), `account_id`, UNIQUE `(app_id, slug)` |
85
+ | `prompt_configs` | Named prompt templates | `slug`, `name`, `config`, `account_id`, UNIQUE `(app_id, slug)` |
86
+ | `embeddings` | KB chunks with pgvector | `model_id`, `document_id`, `chunk_index`, `content`, `embedding vector(1536)`, `content_hash`, `approved_at`, `revoked_at`; UNIQUE `(model_id, document_id, chunk_index)` |
87
+
88
+ ## Integrations & webhooks
89
+
90
+ | Table | Purpose | Key columns |
91
+ |---|---|---|
92
+ | `integrations` | Outbound/inbound integration configs | `slug`, `name`, `config` (credentials, adapters), `account_id`, UNIQUE `(app_id, account_id, slug)` |
93
+ | `integration_routes` | Inbound route definitions | `slug`, `config` (event path, handler), `account_id` |
94
+ | `webhook_handlers` | Dynamic handler registry (004) | `name`, `function_name`, `events[]`, `account_id`, `is_deleted`; UNIQUE `(app_id, account_id, name)` |
95
+ | `webhook_deliveries` | Inbound+outbound delivery ledger (004) | `direction`, `integration_id`, `api_key_id`, `handler_name`, `action_slug`, attempt/status fields |
96
+ | `api_keys` | Machine principals and integration keys | `key_prefix`, `key_hash`, `key_type` (`inbound`/`outbound`/`internal`/`cli`), `scopes[]`, `rate_limit`, `machine_type`, `is_internal`, `expires_at`, `integration_id` |
97
+ | `api_key_usage_logs` | Per-key request ledger (004) | `api_key_id` FK, `request_method`, `request_path`, `request_ip`, `success` |
98
+
99
+ ## Observability & security
100
+
101
+ | Table | Purpose | Key columns |
102
+ |---|---|---|
103
+ | `logs` | Append-only log/audit/span/event rows | `level`, `message`, `context`, `metadata`, `source`/`source_type`/`source_id` |
104
+ | `observability` | Metric points | `metric_name`, `metric_value`, `metric_unit`, `context` |
105
+ | `alerts` | Alert rule configs | `slug`, `config` |
106
+ | `security_blocklist` | Hard-blocked persons/accounts/emails/IPs (049) | blocklist entries with `type` and value |
107
+ | `notifications` | User notifications (050) | recipient/title/body rows |
108
+
109
+ ## Testing
110
+
111
+ `test_runs` (suite results incl. `pipeline_execution_id`), `test_cases`,
112
+ `test_results` (018) — test definitions and outcomes.
113
+
114
+ ## Migration conventions
115
+
116
+ - Files live in `.framework/migrations/` (framework) and `custom/migrations/`
117
+ (project); `migrate` applies framework first, then custom, in filename
118
+ order — `.framework/cli/commands/migrate.ts`.
119
+ - Naming: `NNN_snake_case_description.sql`, three-digit prefix. Applied files
120
+ are recorded in the `_spine_migrations` ledger (`filename` UNIQUE); each
121
+ file runs in its own transaction and the run stops on first failure.
122
+ - Known numbering gaps: **22–31, 39–41, 63** — numbers were reserved or
123
+ consolidated during development (audit D-007). A gap is expected, not a
124
+ missing migration.
125
+ - `idempotent by convention`: framework migrations use `IF NOT EXISTS` /
126
+ `ON CONFLICT DO NOTHING` so re-running a file is safe.
127
+
128
+ ## Related
129
+
130
+ - [Design Schema](design-schema.md) · [Runtime Records](../concepts/runtime-records.md)
131
+ - [admin-data](api/admin-data.md) — the API surface over these tables
132
+ - `.framework/migrations/` — authoritative DDL