@everystack/mcp 0.3.1 → 0.3.2

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.
package/dist/index.cjs CHANGED
@@ -23411,9 +23411,9 @@ var handWrittenMigration = {
23411
23411
  id: "hand-written-migration",
23412
23412
  tier: "framework",
23413
23413
  severity: "deny",
23414
- guide: "Schema and migrations are generated from your Models \u2014 edit the Model and run db:generate, never hand-write SQL migrations or edit the generated schema.",
23415
- conform: "everystack db:generate",
23416
- verify: "everystack db:generate produces no diff (a clean no-op)",
23414
+ guide: "Schema changes have two homes, neither is a hand-written migration: tables/constraints/authz are generated from your Models (edit the Model, run db:generate); functions, views, and matviews are authored in db/sql/ and DEPLOYED with db:reconcile \u2014 no migration file either way.",
23415
+ conform: "everystack db:generate (tables) \xB7 everystack db:reconcile (functions/views/matviews in db/sql)",
23416
+ verify: "everystack db:generate produces no diff AND everystack db:reconcile --check exits 0",
23417
23417
  detect(ctx) {
23418
23418
  if (ctx.tool !== "Write" && ctx.tool !== "Edit") return null;
23419
23419
  const p = ctx.filePath;
@@ -23705,7 +23705,7 @@ async function runGovernanceCli(argv) {
23705
23705
  }
23706
23706
 
23707
23707
  // src/index.ts
23708
- var version2 = (true ? "0.3.1" : null) ?? "0.3.0-dev";
23708
+ var version2 = (true ? "0.3.2" : null) ?? "0.3.0-dev";
23709
23709
  var INSTRUCTIONS = [
23710
23710
  "You govern how any agent builds everystack \u2014 a self-hosted application stack for Expo apps on AWS.",
23711
23711
  "Your job is not only to advise but to keep the build on-script: the architecture the maintainer",
@@ -23767,7 +23767,7 @@ var INSTRUCTIONS = [
23767
23767
  "1. Read everystack://core for architecture and conventions.",
23768
23768
  "2. Read everystack://security before any deployment or auth guidance.",
23769
23769
  "3. Load detail resources on demand when the user asks about specific features.",
23770
- "4. Data lives in PostgreSQL via Models/Modules and is served through the API \u2014 never bundle large computed data into the app. Schema changes go through generated migrations (`db:generate`), never hand-written DDL. Reuse `@everystack/ui` components; never put secret values behind `EXPO_PUBLIC_*`.",
23770
+ "4. Data lives in PostgreSQL via Models/Modules and is served through the API \u2014 never bundle large computed data into the app. Schema changes have two homes: tables/authz are generated from Models (`db:generate`); functions, views, and matviews are authored in `db/sql/` and deployed with `db:reconcile` \u2014 never a hand-written migration either way. Reuse `@everystack/ui` components; never put secret values behind `EXPO_PUBLIC_*`.",
23771
23771
  '5. When the user wants to start a new project, run check_environment (phase "local" for dev, "deploy" for deployment) to verify prerequisites.',
23772
23772
  "6. When the user needs to interact with deployed infrastructure, guide them to use the everystack CLI."
23773
23773
  ].join("\n");
@@ -19,9 +19,12 @@ These are enforced (everystack cheat gates) and load-bearing. Do not work around
19
19
  - **Data lives in PostgreSQL, served through the API — never bundle data into the app.** A
20
20
  large `.json`/`.csv` of computed data in the bundle is wrong; model it and serve it, or
21
21
  render an empty state if it does not exist yet.
22
- - **Schema and migrations are generated from Models.** Declare tables with `defineModel`
23
- (in `models/`), run `everystack db:generate`. Never hand-write a SQL migration, never edit
24
- the generated `db/schema.ts`. After any change, `db:generate` must be a clean no-op.
22
+ - **Schema changes have two homes; neither is a hand-written migration.** Tables and authz
23
+ are generated from Models: declare with `defineModel` (in `db/models/`), run
24
+ `everystack db:generate` never hand-write a SQL migration, never edit the generated
25
+ `db/schema.ts`; after any change `db:generate` must be a clean no-op. Functions, views,
26
+ and matviews are **authored** in `db/sql/` and **deployed** with `everystack db:reconcile`
27
+ — edit the SQL file, reconcile, done; `db:reconcile --check` must exit 0.
25
28
  - **Authorization is declared, not hand-written.** Use `can()` abilities on the Model; they
26
29
  compile to RLS + grants. Never hand-write `CREATE POLICY`/`GRANT`. RLS is required.
27
30
  - **Reuse `@everystack/ui`.** Do not hand-roll a component that already exists there. Style
@@ -32,10 +35,11 @@ These are enforced (everystack cheat gates) and load-bearing. Do not work around
32
35
 
33
36
  ## Start Here
34
37
 
35
- - `models/` — `defineModel` tables (the source of truth for schema + authz)
38
+ - `db/models/` — `defineModel` tables (the source of truth for schema + authz)
39
+ - `db/sql/` — functions, views, matviews (authored SQL; deploys via `db:reconcile`)
36
40
  - `app/` — Expo Router pages (screens, navigation, API routes)
37
41
  - `server/` — Lambda handlers (api.ts, worker.ts, image.ts)
38
- - `db/` — generated Drizzle schema + migrations (do not edit by hand)
42
+ - `db/schema.generated.ts`, `drizzle/` — generated artifacts (do not edit by hand)
39
43
  - `lib/` — shared code (auth context, API client)
40
44
  - `sst.config.ts` — AWS infrastructure definition
41
45
  - `docs/RUNBOOK.md` — how to operate this app; regenerate with `everystack runbook`
@@ -51,6 +55,7 @@ pnpm install # Install dependencies
51
55
  pnpm dev # Start the Expo dev server
52
56
  pnpm test # Run all tests (TDD)
53
57
  everystack db:generate # Models → next migration (data + authz)
58
+ everystack db:reconcile --apply # Deploy functions/views/matviews from db/sql (no migrations)
54
59
  everystack db:migrate # Apply migrations on the deployed Lambda
55
60
  everystack db:seed # Seed the database (dev only)
56
61
  everystack deploy --stage dev # Deploy infrastructure (SST)
@@ -67,7 +72,9 @@ Declare tables with `defineModel` (`field`, `can`, relations). A package's full
67
72
  `defineModule`; the app composes Modules. `everystack db:generate` compiles them to one
68
73
  migration (schema + RLS + grants); `deriveHandlerConfig(models)` derives the API config. You
69
74
  never hand-write migrations, RLS, or handler access-control — they are derived, so they cannot
70
- drift.
75
+ drift. The derived layer (functions, views, matviews) is the exception that proves the rule:
76
+ that SQL is authored, in `db/sql/`, and *deployed* with `db:reconcile` — hand-edits straight
77
+ against the database surface as drift, and a comment-only edit is a no-op.
71
78
 
72
79
  ### Security over all else
73
80
 
@@ -96,7 +103,8 @@ Every feature starts with a failing test. Tests in `__tests__/` mirroring source
96
103
  ## What NOT to Do
97
104
 
98
105
  - Don't bundle large data into the app — it lives in the DB, served by the API.
99
- - Don't hand-write migrations or edit `db/schema.ts` — edit the Model, run `db:generate`.
106
+ - Don't hand-write migrations or edit `db/schema.ts` — edit the Model, run `db:generate`;
107
+ for functions/views/matviews edit `db/sql/` and run `db:reconcile`.
100
108
  - Don't hand-write RLS — declare `can()` abilities.
101
109
  - Don't hand-roll a component that exists in `@everystack/ui`; don't use inline `StyleSheet`.
102
110
  - Don't put a secret behind `EXPO_PUBLIC_*` — that ships to the client.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everystack/mcp",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Governance layer that governs how any agent builds everystack — grounding, cheat gates, and Model-aware tooling over MCP",
5
5
  "license": "AGPL-3.0-only",
6
6
  "author": "Scalable Technology, Inc. <licensing@scalable.technology>",
@@ -40,7 +40,7 @@
40
40
  "tsx": "4.21.0",
41
41
  "typescript": "5.9.3",
42
42
  "zod": "3.25.67",
43
- "@everystack/cli": "0.3.12",
43
+ "@everystack/cli": "0.3.14",
44
44
  "@everystack/model": "0.3.4"
45
45
  },
46
46
  "scripts": {
@@ -5,6 +5,10 @@
5
5
  * (`db:generate`). A hand-written `.sql` migration or a hand-edit to the generated
6
6
  * `db/schema.ts` drifts the database from the Models — the migration the CLI would
7
7
  * write next is no longer a clean no-op. Pure path check; no IO.
8
+ *
9
+ * Note the layer split: SQL under `db/sql/` is the DERIVED layer (functions,
10
+ * views, matviews) and is legitimately authored — it deploys via `db:reconcile`,
11
+ * not through migrations, so this gate deliberately does not match it.
8
12
  */
9
13
 
10
14
  import { relative } from 'path';
@@ -28,9 +32,9 @@ export const handWrittenMigration: CheatGate = {
28
32
  tier: 'framework',
29
33
  severity: 'deny',
30
34
  guide:
31
- 'Schema and migrations are generated from your Models edit the Model and run db:generate, never hand-write SQL migrations or edit the generated schema.',
32
- conform: 'everystack db:generate',
33
- verify: 'everystack db:generate produces no diff (a clean no-op)',
35
+ 'Schema changes have two homes, neither is a hand-written migration: tables/constraints/authz are generated from your Models (edit the Model, run db:generate); functions, views, and matviews are authored in db/sql/ and DEPLOYED with db:reconcile — no migration file either way.',
36
+ conform: 'everystack db:generate (tables) · everystack db:reconcile (functions/views/matviews in db/sql)',
37
+ verify: 'everystack db:generate produces no diff AND everystack db:reconcile --check exits 0',
34
38
  detect(ctx: ToolCallContext): string | null {
35
39
  if (ctx.tool !== 'Write' && ctx.tool !== 'Edit') return null;
36
40
  const p = ctx.filePath;
package/src/index.ts CHANGED
@@ -71,7 +71,7 @@ const INSTRUCTIONS = [
71
71
  '1. Read everystack://core for architecture and conventions.',
72
72
  '2. Read everystack://security before any deployment or auth guidance.',
73
73
  '3. Load detail resources on demand when the user asks about specific features.',
74
- '4. Data lives in PostgreSQL via Models/Modules and is served through the API — never bundle large computed data into the app. Schema changes go through generated migrations (`db:generate`), never hand-written DDL. Reuse `@everystack/ui` components; never put secret values behind `EXPO_PUBLIC_*`.',
74
+ '4. Data lives in PostgreSQL via Models/Modules and is served through the API — never bundle large computed data into the app. Schema changes have two homes: tables/authz are generated from Models (`db:generate`); functions, views, and matviews are authored in `db/sql/` and deployed with `db:reconcile` — never a hand-written migration either way. Reuse `@everystack/ui` components; never put secret values behind `EXPO_PUBLIC_*`.',
75
75
  '5. When the user wants to start a new project, run check_environment (phase "local" for dev, "deploy" for deployment) to verify prerequisites.',
76
76
  '6. When the user needs to interact with deployed infrastructure, guide them to use the everystack CLI.',
77
77
  ].join('\n');
@@ -19,9 +19,12 @@ These are enforced (everystack cheat gates) and load-bearing. Do not work around
19
19
  - **Data lives in PostgreSQL, served through the API — never bundle data into the app.** A
20
20
  large `.json`/`.csv` of computed data in the bundle is wrong; model it and serve it, or
21
21
  render an empty state if it does not exist yet.
22
- - **Schema and migrations are generated from Models.** Declare tables with `defineModel`
23
- (in `models/`), run `everystack db:generate`. Never hand-write a SQL migration, never edit
24
- the generated `db/schema.ts`. After any change, `db:generate` must be a clean no-op.
22
+ - **Schema changes have two homes; neither is a hand-written migration.** Tables and authz
23
+ are generated from Models: declare with `defineModel` (in `db/models/`), run
24
+ `everystack db:generate` never hand-write a SQL migration, never edit the generated
25
+ `db/schema.ts`; after any change `db:generate` must be a clean no-op. Functions, views,
26
+ and matviews are **authored** in `db/sql/` and **deployed** with `everystack db:reconcile`
27
+ — edit the SQL file, reconcile, done; `db:reconcile --check` must exit 0.
25
28
  - **Authorization is declared, not hand-written.** Use `can()` abilities on the Model; they
26
29
  compile to RLS + grants. Never hand-write `CREATE POLICY`/`GRANT`. RLS is required.
27
30
  - **Reuse `@everystack/ui`.** Do not hand-roll a component that already exists there. Style
@@ -32,10 +35,11 @@ These are enforced (everystack cheat gates) and load-bearing. Do not work around
32
35
 
33
36
  ## Start Here
34
37
 
35
- - `models/` — `defineModel` tables (the source of truth for schema + authz)
38
+ - `db/models/` — `defineModel` tables (the source of truth for schema + authz)
39
+ - `db/sql/` — functions, views, matviews (authored SQL; deploys via `db:reconcile`)
36
40
  - `app/` — Expo Router pages (screens, navigation, API routes)
37
41
  - `server/` — Lambda handlers (api.ts, worker.ts, image.ts)
38
- - `db/` — generated Drizzle schema + migrations (do not edit by hand)
42
+ - `db/schema.generated.ts`, `drizzle/` — generated artifacts (do not edit by hand)
39
43
  - `lib/` — shared code (auth context, API client)
40
44
  - `sst.config.ts` — AWS infrastructure definition
41
45
  - `docs/RUNBOOK.md` — how to operate this app; regenerate with `everystack runbook`
@@ -51,6 +55,7 @@ pnpm install # Install dependencies
51
55
  pnpm dev # Start the Expo dev server
52
56
  pnpm test # Run all tests (TDD)
53
57
  everystack db:generate # Models → next migration (data + authz)
58
+ everystack db:reconcile --apply # Deploy functions/views/matviews from db/sql (no migrations)
54
59
  everystack db:migrate # Apply migrations on the deployed Lambda
55
60
  everystack db:seed # Seed the database (dev only)
56
61
  everystack deploy --stage dev # Deploy infrastructure (SST)
@@ -67,7 +72,9 @@ Declare tables with `defineModel` (`field`, `can`, relations). A package's full
67
72
  `defineModule`; the app composes Modules. `everystack db:generate` compiles them to one
68
73
  migration (schema + RLS + grants); `deriveHandlerConfig(models)` derives the API config. You
69
74
  never hand-write migrations, RLS, or handler access-control — they are derived, so they cannot
70
- drift.
75
+ drift. The derived layer (functions, views, matviews) is the exception that proves the rule:
76
+ that SQL is authored, in `db/sql/`, and *deployed* with `db:reconcile` — hand-edits straight
77
+ against the database surface as drift, and a comment-only edit is a no-op.
71
78
 
72
79
  ### Security over all else
73
80
 
@@ -96,7 +103,8 @@ Every feature starts with a failing test. Tests in `__tests__/` mirroring source
96
103
  ## What NOT to Do
97
104
 
98
105
  - Don't bundle large data into the app — it lives in the DB, served by the API.
99
- - Don't hand-write migrations or edit `db/schema.ts` — edit the Model, run `db:generate`.
106
+ - Don't hand-write migrations or edit `db/schema.ts` — edit the Model, run `db:generate`;
107
+ for functions/views/matviews edit `db/sql/` and run `db:reconcile`.
100
108
  - Don't hand-write RLS — declare `can()` abilities.
101
109
  - Don't hand-roll a component that exists in `@everystack/ui`; don't use inline `StyleSheet`.
102
110
  - Don't put a secret behind `EXPO_PUBLIC_*` — that ships to the client.