@everystack/mcp 0.3.1 → 0.3.3

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 (85) hide show
  1. package/dist/gates/detectors/embedded-data-bundle.d.ts +13 -0
  2. package/dist/gates/detectors/embedded-data-bundle.d.ts.map +1 -0
  3. package/dist/gates/detectors/embedded-data-bundle.js +56 -0
  4. package/dist/gates/detectors/hand-written-migration.d.ts +24 -0
  5. package/dist/gates/detectors/hand-written-migration.d.ts.map +1 -0
  6. package/dist/gates/detectors/hand-written-migration.js +54 -0
  7. package/dist/gates/detectors/secret-in-public-env.d.ts +12 -0
  8. package/dist/gates/detectors/secret-in-public-env.d.ts.map +1 -0
  9. package/dist/gates/detectors/secret-in-public-env.js +38 -0
  10. package/dist/gates/engine.d.ts +28 -0
  11. package/dist/gates/engine.d.ts.map +1 -0
  12. package/dist/gates/engine.js +74 -0
  13. package/dist/gates/registry.d.ts +14 -0
  14. package/dist/gates/registry.d.ts.map +1 -0
  15. package/dist/gates/registry.js +21 -0
  16. package/dist/gates/telemetry.d.ts +47 -0
  17. package/dist/gates/telemetry.d.ts.map +1 -0
  18. package/dist/gates/telemetry.js +121 -0
  19. package/dist/gates/types.d.ts +67 -0
  20. package/dist/gates/types.d.ts.map +1 -0
  21. package/dist/gates/types.js +14 -0
  22. package/dist/governance/cli.d.ts +57 -0
  23. package/dist/governance/cli.d.ts.map +1 -0
  24. package/dist/governance/cli.js +169 -0
  25. package/dist/governance/grounding.d.ts +78 -0
  26. package/dist/governance/grounding.d.ts.map +1 -0
  27. package/dist/governance/grounding.js +299 -0
  28. package/dist/index.cjs +11 -9
  29. package/dist/index.d.ts +2 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +94 -0
  32. package/dist/project-claude-md.md +33 -11
  33. package/dist/prompts/add-feature.d.ts +3 -0
  34. package/dist/prompts/add-feature.d.ts.map +1 -0
  35. package/dist/prompts/add-feature.js +154 -0
  36. package/dist/prompts/claude-md.d.ts +12 -0
  37. package/dist/prompts/claude-md.d.ts.map +1 -0
  38. package/dist/prompts/claude-md.js +87 -0
  39. package/dist/prompts/debug.d.ts +3 -0
  40. package/dist/prompts/debug.d.ts.map +1 -0
  41. package/dist/prompts/debug.js +129 -0
  42. package/dist/prompts/deploy.d.ts +3 -0
  43. package/dist/prompts/deploy.d.ts.map +1 -0
  44. package/dist/prompts/deploy.js +118 -0
  45. package/dist/prompts/design-schema.d.ts +3 -0
  46. package/dist/prompts/design-schema.d.ts.map +1 -0
  47. package/dist/prompts/design-schema.js +97 -0
  48. package/dist/prompts/governance-setup.d.ts +9 -0
  49. package/dist/prompts/governance-setup.d.ts.map +1 -0
  50. package/dist/prompts/governance-setup.js +76 -0
  51. package/dist/prompts/index.d.ts +3 -0
  52. package/dist/prompts/index.d.ts.map +1 -0
  53. package/dist/prompts/index.js +20 -0
  54. package/dist/prompts/new-app.d.ts +3 -0
  55. package/dist/prompts/new-app.d.ts.map +1 -0
  56. package/dist/prompts/new-app.js +203 -0
  57. package/dist/prompts/runbook.d.ts +12 -0
  58. package/dist/prompts/runbook.d.ts.map +1 -0
  59. package/dist/prompts/runbook.js +70 -0
  60. package/dist/prompts/secure.d.ts +3 -0
  61. package/dist/prompts/secure.d.ts.map +1 -0
  62. package/dist/prompts/secure.js +219 -0
  63. package/dist/resources/index.d.ts +12 -0
  64. package/dist/resources/index.d.ts.map +1 -0
  65. package/dist/resources/index.js +182 -0
  66. package/dist/tools/check-environment.d.ts +25 -0
  67. package/dist/tools/check-environment.d.ts.map +1 -0
  68. package/dist/tools/check-environment.js +281 -0
  69. package/dist/tools/index.d.ts +3 -0
  70. package/dist/tools/index.d.ts.map +1 -0
  71. package/dist/tools/index.js +18 -0
  72. package/dist/tools/project-status.d.ts +28 -0
  73. package/dist/tools/project-status.d.ts.map +1 -0
  74. package/dist/tools/project-status.js +138 -0
  75. package/dist/tools/project-validate.d.ts +19 -0
  76. package/dist/tools/project-validate.d.ts.map +1 -0
  77. package/dist/tools/project-validate.js +323 -0
  78. package/dist/tools/schema-analyze.d.ts +46 -0
  79. package/dist/tools/schema-analyze.d.ts.map +1 -0
  80. package/dist/tools/schema-analyze.js +336 -0
  81. package/package.json +3 -3
  82. package/src/gates/detectors/hand-written-migration.ts +23 -10
  83. package/src/index.ts +1 -1
  84. package/src/prompts/claude-md.ts +4 -2
  85. package/src/resources/project-claude-md.md +33 -11
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,94 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { registerResources } from './resources/index.js';
4
+ import { registerTools } from './tools/index.js';
5
+ import { registerPrompts } from './prompts/index.js';
6
+ import { GOVERNANCE_COMMANDS, runGovernanceCli } from './governance/cli.js';
7
+ const version = (typeof __MCP_VERSION__ === 'string' ? __MCP_VERSION__ : null) ?? '0.3.0-dev';
8
+ const INSTRUCTIONS = [
9
+ 'You govern how any agent builds everystack — a self-hosted application stack for Expo apps on AWS.',
10
+ 'Your job is not only to advise but to keep the build on-script: the architecture the maintainer',
11
+ 'set up (Models/Modules, generated migrations, the ui package, the secrets boundary) is the way,',
12
+ 'and the training-consensus shortcut (bundle the JSON, hand-write the migration, hand-roll a',
13
+ 'component) is the cheat. The cheat gates enforce this structurally; you reinforce it in guidance.',
14
+ '',
15
+ '## Governance setup (do this once, early)',
16
+ '',
17
+ 'This server is the knowledge + helpful path. The ENFORCEMENT (grounding gate + cheat gates) runs',
18
+ 'as Claude Code hooks, NOT from this server alone. If the hooks are not installed, none of the',
19
+ 'gates fire — so check and offer to install them at the start of work on an everystack project:',
20
+ '1. Look for the everystack governance hooks in the project\'s `.claude/settings.json` (a',
21
+ ' `hooks` block whose commands call `everystack-mcp gate`/`context`/`mark`/`validate`).',
22
+ '2. If they are absent, read this package\'s `hooks.example.json` and `docs/governance-setup.md`',
23
+ ' (in @everystack/mcp), then OFFER to merge the `hooks` block into `.claude/settings.json`.',
24
+ '3. NEVER install them silently — hooks run a shell command on every tool call. Show the human',
25
+ ' the exact block and the command form (workspace `npx tsx packages/mcp/src/index.ts <sub>` vs',
26
+ ' installed `everystack-mcp <sub>`), and let them confirm.',
27
+ '4. The `governance_setup` prompt produces the exact block for the current project.',
28
+ '',
29
+ '## The project contract (CLAUDE.md)',
30
+ '',
31
+ 'The grounding gate has nothing to enforce without a project `CLAUDE.md` — and writing one is',
32
+ 'what turns grounding ON (the nearest project CLAUDE.md is auto-required reading). Early in any',
33
+ 'everystack project, ensure a CLAUDE.md exists AND is current:',
34
+ '- If it is missing, offer to scaffold it (the `claude_md` prompt; template at',
35
+ ' everystack://project-claude-md). It carries the non-negotiables the cheat gates enforce.',
36
+ '- If it exists, it is a living contract — as the project adds packages, models, or a tier, it',
37
+ ' drifts. Offer to reconcile it (also `claude_md`): suggest updates against the project reality',
38
+ ' and the current conventions, confirm-first, and never clobber the human\'s own content.',
39
+ '',
40
+ '## Beginner Detection',
41
+ '',
42
+ 'Detect the user\'s experience level from context:',
43
+ '- If the user describes an app idea without technical terms, has no existing project, or asks basic questions ("how do I start?", "I want to build..."), treat them as a BEGINNER.',
44
+ '- If the user references specific packages, tiers (V1/V2/V3), tools (Drizzle, PostgREST, SST), or has an existing everystack project, treat them as a DEVELOPER.',
45
+ '',
46
+ '## Beginner Flow',
47
+ '',
48
+ 'For beginners:',
49
+ '1. Read everystack://getting-started first. This is your guide for how to talk to beginners.',
50
+ '2. Ask what they want to build. Listen to their idea before anything technical. Do NOT categorize into tiers or ask them to choose V1/V2/V3.',
51
+ '3. Run check_environment with phase "local". Only V1 prerequisites matter now (Node.js, git, pnpm). PostgreSQL is NOT needed yet.',
52
+ ' Do NOT require AWS tools (AWS CLI, credentials, SST) upfront. The user will build and run locally first.',
53
+ '4. Walk through installing missing prerequisites ONE AT A TIME. Do not list them all at once. Install the first missing tool, confirm it works, then move to the next.',
54
+ '5. Create a stock Expo app: `npx create-expo-app@latest`, install V1 packages (`@everystack/server`, `@everystack/cli`, `@everystack/ui`), and `pnpm add -D sst`.',
55
+ '6. Run `npx expo start`. Read everystack://first-run for the walkthrough. The first milestone is seeing the app running in a browser.',
56
+ '7. Build together. Discuss what the app should look like. Create screens, navigation, components. Everything is static and visual.',
57
+ '8. When a feature needs user accounts or saved data, read everystack://adding-database. This introduces PostgreSQL, the API handler, auth, and database setup step by step.',
58
+ '9. When a feature needs file uploads or background tasks, add the relevant packages incrementally (everystack://storage, everystack://jobs, everystack://images).',
59
+ '10. When the user is ready to deploy to the internet, run check_environment with phase "deploy" and walk through AWS setup.',
60
+ ' For AWS credentials specifically, read everystack://aws-setup and walk them through account creation and IAM setup step by step.',
61
+ '11. Never use jargon without explaining it. "Lambda" is "the server that runs your code." "S3" is "file storage." "RDS" is "the database server." "CloudFront" is "the CDN that makes your app fast worldwide."',
62
+ '',
63
+ '## Developer Flow',
64
+ '',
65
+ 'For experienced developers:',
66
+ '1. Read everystack://core for architecture and conventions.',
67
+ '2. Read everystack://security before any deployment or auth guidance.',
68
+ '3. Load detail resources on demand when the user asks about specific features.',
69
+ '4. Data lives in PostgreSQL via Models/Modules and is served through the API — never bundle large computed data into the app. NOBODY AUTHORS MIGRATIONS. Schema work has three homes: tables/constraints/authz are DECLARED in `db/models/` (edit the Model, then `everystack db:sync` moves the dev database to the checkout — verified by fingerprint); functions/views/matviews are authored in `db/sql/` (deployed by `db:reconcile`/`db:sync`); one-shot DATA moves are authored in `db/backfills/*.sql` (run via `db:backfill`, never as a schema side effect). Protected stages never take a sync: `db:plan` mints a reviewable, fingerprint-pinned edge and `db:apply` verifies at both ends — the checkout must descend from the commit declaring the target\'s state ("rebase first"), and destructive plans are confirmed, snapshotted, and approver-gated (`db:approvers`). CI runs `everystack db:check` (the merged declared state must compose; generated artifacts must match regeneration byte-for-byte). Per-branch dev databases: `db:template:refresh` + `db:branch`; deployed feature stages fork data with `db:fork`. Reuse `@everystack/ui` components; never put secret values behind `EXPO_PUBLIC_*`.',
70
+ '5. When the user wants to start a new project, run check_environment (phase "local" for dev, "deploy" for deployment) to verify prerequisites.',
71
+ '6. When the user needs to interact with deployed infrastructure, guide them to use the everystack CLI.',
72
+ ].join('\n');
73
+ async function startServer() {
74
+ const server = new McpServer({ name: '@everystack/mcp', version }, { instructions: INSTRUCTIONS });
75
+ registerResources(server);
76
+ registerTools(server);
77
+ registerPrompts(server);
78
+ const transport = new StdioServerTransport();
79
+ await server.connect(transport);
80
+ }
81
+ async function main() {
82
+ const sub = process.argv[2];
83
+ // Hook-shim CLI: `everystack-mcp <context|gate|mark|validate|report>` reads hook JSON on stdin.
84
+ if (sub && GOVERNANCE_COMMANDS.includes(sub)) {
85
+ await runGovernanceCli(process.argv.slice(2));
86
+ return;
87
+ }
88
+ // Default: the stdio MCP server.
89
+ await startServer();
90
+ }
91
+ main().catch((err) => {
92
+ console.error(err);
93
+ process.exit(1);
94
+ });
@@ -19,9 +19,19 @@ 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
+ - **Nobody authors migrations. Schema work has three homes.** Tables and authz are DECLARED
23
+ in `db/models/` with `defineModel` edit the Model, then `everystack db:sync` moves the
24
+ dev database to your checkout (state + authz + derived, fingerprint-verified). Functions,
25
+ views, and matviews are **authored** in `db/sql/` and deployed by `db:reconcile`/`db:sync`.
26
+ One-shot DATA moves are authored in `db/backfills/*.sql` and run via `everystack
27
+ db:backfill` — deliberately, never as a schema side effect. Never hand-write a SQL
28
+ migration, never edit `db/schema.generated.ts`; `everystack db:check` must pass (the CI
29
+ gate: the declared state composes, generated artifacts match regeneration).
30
+ - **Protected stages take plans, not syncs.** `everystack db:plan` mints a reviewable edge
31
+ pinned by fingerprints at both ends; `db:apply` verifies before and after, requires the
32
+ checkout to descend from the commit declaring the target's state ("rebase first"), and
33
+ gates destructive plans: `--confirm` always, snapshot always, the stage's approver set
34
+ (`db:approvers`) when declared.
25
35
  - **Authorization is declared, not hand-written.** Use `can()` abilities on the Model; they
26
36
  compile to RLS + grants. Never hand-write `CREATE POLICY`/`GRANT`. RLS is required.
27
37
  - **Reuse `@everystack/ui`.** Do not hand-roll a component that already exists there. Style
@@ -32,10 +42,12 @@ These are enforced (everystack cheat gates) and load-bearing. Do not work around
32
42
 
33
43
  ## Start Here
34
44
 
35
- - `models/` — `defineModel` tables (the source of truth for schema + authz)
45
+ - `db/models/` — `defineModel` tables (the source of truth for schema + authz)
46
+ - `db/sql/` — functions, views, matviews (authored SQL; deploys via `db:reconcile`/`db:sync`)
47
+ - `db/backfills/` — one-shot data jobs (authored SQL; run via `db:backfill`, own record)
36
48
  - `app/` — Expo Router pages (screens, navigation, API routes)
37
49
  - `server/` — Lambda handlers (api.ts, worker.ts, image.ts)
38
- - `db/` — generated Drizzle schema + migrations (do not edit by hand)
50
+ - `db/schema.generated.ts` — generated artifact (never edit; `db:check` refuses drift)
39
51
  - `lib/` — shared code (auth context, API client)
40
52
  - `sst.config.ts` — AWS infrastructure definition
41
53
  - `docs/RUNBOOK.md` — how to operate this app; regenerate with `everystack runbook`
@@ -50,8 +62,12 @@ These are enforced (everystack cheat gates) and load-bearing. Do not work around
50
62
  pnpm install # Install dependencies
51
63
  pnpm dev # Start the Expo dev server
52
64
  pnpm test # Run all tests (TDD)
53
- everystack db:generate # Models next migration (data + authz)
54
- everystack db:migrate # Apply migrations on the deployed Lambda
65
+ everystack db:sync # Dev edit loop: the database follows your checkout (state + authz + derived)
66
+ everystack db:check # CI gate: declared state composes; generated artifacts match regeneration
67
+ everystack db:plan | db:apply # Protected stages: reviewable, fingerprint-verified edges
68
+ everystack db:branch # Per-git-branch dev DB from the seeded template (db:template:refresh builds it)
69
+ everystack db:backfill --apply # Run one-shot data jobs from db/backfills/ (own record)
70
+ everystack db:generate # Models → the diff as SQL (review surface)
55
71
  everystack db:seed # Seed the database (dev only)
56
72
  everystack deploy --stage dev # Deploy infrastructure (SST)
57
73
  everystack update --channel production # OTA update (no redeploy)
@@ -64,10 +80,15 @@ everystack bundle:audit <url> # Audit a deployed bundle (weight +
64
80
  ### Models are the source of truth (v3)
65
81
 
66
82
  Declare tables with `defineModel` (`field`, `can`, relations). A package's full DB slice is a
67
- `defineModule`; the app composes Modules. `everystack db:generate` compiles them to one
68
- migration (schema + RLS + grants); `deriveHandlerConfig(models)` derives the API config. You
83
+ `defineModule`; the app composes Modules. The database's own schema is the authority — the
84
+ live state is content-addressed (`db:fingerprint`), and every apply verifies against it. You
69
85
  never hand-write migrations, RLS, or handler access-control — they are derived, so they cannot
70
- drift.
86
+ drift; `deriveHandlerConfig(models)` derives the API config. The derived layer (functions,
87
+ views, matviews) is the exception that proves the rule: that SQL is authored, in `db/sql/`,
88
+ and *deployed* by reconcile — hand-edits straight against the database surface as drift, and a
89
+ comment-only edit is a no-op. Contraction is a two-step ceremony: `field.deprecated()` first
90
+ (the column stays readable, new writes are rejected, generated types strike it through), the
91
+ physical drop later — a destructive plan, confirmed, snapshotted, approver-gated.
71
92
 
72
93
  ### Security over all else
73
94
 
@@ -96,7 +117,8 @@ Every feature starts with a failing test. Tests in `__tests__/` mirroring source
96
117
  ## What NOT to Do
97
118
 
98
119
  - 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`.
120
+ - Don't hand-write migrations or edit `db/schema.ts` — edit the Model, run `db:generate`;
121
+ for functions/views/matviews edit `db/sql/` and run `db:reconcile`.
100
122
  - Don't hand-write RLS — declare `can()` abilities.
101
123
  - Don't hand-roll a component that exists in `@everystack/ui`; don't use inline `StyleSheet`.
102
124
  - Don't put a secret behind `EXPO_PUBLIC_*` — that ships to the client.
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerAddFeaturePrompt(server: McpServer): void;
3
+ //# sourceMappingURL=add-feature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-feature.d.ts","sourceRoot":"","sources":["../../src/prompts/add-feature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAmHzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA+ChE"}
@@ -0,0 +1,154 @@
1
+ import { z } from 'zod';
2
+ const FEATURES = {
3
+ auth: {
4
+ resource: 'everystack://auth',
5
+ packages: ['@everystack/auth'],
6
+ steps: [
7
+ 'Install @everystack/auth',
8
+ 'Create auth handlers with createAuthHandlers(db, schema, jwtSecret)',
9
+ 'Add auth routes to Lambda handler (signup, signin, refresh, verify, signout)',
10
+ 'Create lib/auth-context.tsx with AuthProvider and useAuth hook',
11
+ 'Add pgSettings to handler config for RLS claim injection',
12
+ 'Add signup and signin screens in app/',
13
+ 'Set JwtSecret via SST secrets: `pnpm sst secret set JwtSecret "$(openssl rand -base64 32)" --stage dev`',
14
+ ],
15
+ },
16
+ jobs: {
17
+ resource: 'everystack://jobs',
18
+ packages: ['@everystack/jobs'],
19
+ steps: [
20
+ 'Install @everystack/jobs',
21
+ 'Create server/worker.ts with createWorkerHandler',
22
+ 'Define job types and handlers',
23
+ 'Add SQS queue to sst.config.ts',
24
+ 'Create job adapter: createJobAdapter({ type: "sqs", queueUrl: Resource.Jobs.url })',
25
+ 'Publish jobs from API handlers: jobClient.publish(type, payload)',
26
+ 'Add dead letter queue for failed jobs',
27
+ ],
28
+ },
29
+ storage: {
30
+ resource: 'everystack://storage',
31
+ packages: ['@everystack/storage'],
32
+ steps: [
33
+ 'Install @everystack/storage',
34
+ 'Add S3 bucket for uploads to sst.config.ts',
35
+ 'Add storagePlugin to handler plugins with MIME type validation',
36
+ 'Add uploads table to schema (or use @everystack/storage/schema)',
37
+ 'Client flow: request presigned URL → upload to S3 → confirm upload',
38
+ 'Configure CDN delivery for public files',
39
+ ],
40
+ },
41
+ images: {
42
+ resource: 'everystack://images',
43
+ packages: ['@everystack/images'],
44
+ steps: [
45
+ 'Install @everystack/images',
46
+ 'Create server/image.ts with createImageHandler',
47
+ 'Add image Lambda to sst.config.ts (needs sharp layer)',
48
+ 'Add image_variants table to schema',
49
+ 'Configure variant generation (thumb, medium, large)',
50
+ 'Set up CDN delivery with format negotiation (WebP, AVIF)',
51
+ ],
52
+ },
53
+ admin: {
54
+ resource: 'everystack://admin',
55
+ packages: ['@everystack/admin'],
56
+ steps: [
57
+ 'Install @everystack/admin',
58
+ 'Create admin page in app/ using AdminRoot and AdminLayout',
59
+ 'Define resource configs for each table (fields, columns, actions)',
60
+ 'Use EverystackAdapter for API integration',
61
+ 'Add admin role check to protect admin routes',
62
+ 'Add dashboard RPCs via createAllDashboardRpcs',
63
+ ],
64
+ },
65
+ logging: {
66
+ resource: 'everystack://logging',
67
+ packages: ['@everystack/logging'],
68
+ steps: [
69
+ 'Install @everystack/logging',
70
+ 'Add loggingPlugin to handler plugins',
71
+ 'Add logging schema tables to your schema exports',
72
+ 'Configure S3 log storage in sst.config.ts',
73
+ 'Add client SDK: createLoggingClient for crash reports and analytics',
74
+ 'Add admin dashboard RPCs for log viewing',
75
+ ],
76
+ },
77
+ security: {
78
+ resource: 'everystack://security-device',
79
+ packages: ['@everystack/security'],
80
+ steps: [
81
+ 'Install @everystack/security',
82
+ 'Set up Apple App Attest (requires iOS 14+, real device)',
83
+ 'Set up Google Play Integrity (requires Google Play Services)',
84
+ 'Generate RS256 device keys on client',
85
+ 'Add device attestation verification to auth flow',
86
+ 'Store device keys in secure enclave/keystore',
87
+ ],
88
+ },
89
+ ssr: {
90
+ resource: 'everystack://ssr',
91
+ packages: [],
92
+ steps: [
93
+ 'SSR is built into @everystack/server — no extra packages needed',
94
+ 'Create SSR loader functions that query Drizzle directly',
95
+ 'Add getWebHandler to Lambda for HTML rendering',
96
+ 'Set up JSON-LD structured data for SEO',
97
+ 'Add OG meta tags for social sharing',
98
+ 'Configure cache headers per route',
99
+ ],
100
+ },
101
+ events: {
102
+ resource: 'everystack://events',
103
+ packages: [],
104
+ steps: [
105
+ 'Events use PostgreSQL LISTEN/NOTIFY — built into the database',
106
+ 'Create database trigger functions for table change notifications',
107
+ 'Set up a listener Lambda with persistent database connection',
108
+ 'Add WebSocket fan-out for client delivery',
109
+ 'Use the useSignal hook in React components for real-time updates',
110
+ ],
111
+ },
112
+ };
113
+ export function registerAddFeaturePrompt(server) {
114
+ server.prompt('add-feature', 'Add an everystack feature to an existing project. Provides step-by-step instructions for auth, jobs, storage, images, admin, logging, security, SSR, or events.', {
115
+ feature: z.enum(['auth', 'jobs', 'storage', 'images', 'admin', 'logging', 'security', 'ssr', 'events'])
116
+ .describe('Feature to add'),
117
+ projectPath: z.string().optional().describe('Absolute path to project root'),
118
+ }, async ({ feature, projectPath }) => {
119
+ const f = FEATURES[feature];
120
+ return {
121
+ messages: [
122
+ {
123
+ role: 'user',
124
+ content: {
125
+ type: 'text',
126
+ text: [
127
+ `Add ${feature} to ${projectPath ? 'the project at ' + projectPath : 'my everystack project'}.`,
128
+ '',
129
+ '## Instructions',
130
+ '',
131
+ `1. Read the ${f.resource} resource for full documentation.`,
132
+ '2. Read everystack://core for architecture context.',
133
+ feature === 'auth' || feature === 'security' ? '3. Read everystack://security for the security model.' : '',
134
+ projectPath ? `4. Run the project_status tool with projectPath="${projectPath}" to understand the current state.` : '',
135
+ projectPath ? `5. Run the project_validate tool with projectPath="${projectPath}" after making changes.` : '',
136
+ '',
137
+ '## Steps',
138
+ '',
139
+ ...f.steps.map((s, i) => `${i + 1}. ${s}`),
140
+ '',
141
+ f.packages.length > 0 ? `## Install\n\n\`\`\`bash\npnpm add ${f.packages.join(' ')}\n\`\`\`` : '',
142
+ '',
143
+ '## After Setup',
144
+ '',
145
+ '- Run tests to verify the integration',
146
+ '- Run project_validate to check for configuration issues',
147
+ '- Read the relevant resource docs for advanced configuration',
148
+ ].filter(Boolean).join('\n'),
149
+ },
150
+ },
151
+ ],
152
+ };
153
+ });
154
+ }
@@ -0,0 +1,12 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ /**
3
+ * `claude_md` — create or reconcile the project's CLAUDE.md.
4
+ *
5
+ * The CLAUDE.md is the project contract. Writing it activates the grounding gate
6
+ * (the nearest project CLAUDE.md is auto-required). But a contract is a living
7
+ * document — it drifts from reality as the project grows. So this prompt is
8
+ * bidirectional: scaffold it when missing, and review + suggest updates when it
9
+ * exists (a drift check on the contract itself), never clobbering human content.
10
+ */
11
+ export declare function registerClaudeMdPrompt(server: McpServer): void;
12
+ //# sourceMappingURL=claude-md.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-md.d.ts","sourceRoot":"","sources":["../../src/prompts/claude-md.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiF9D"}
@@ -0,0 +1,87 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * `claude_md` — create or reconcile the project's CLAUDE.md.
4
+ *
5
+ * The CLAUDE.md is the project contract. Writing it activates the grounding gate
6
+ * (the nearest project CLAUDE.md is auto-required). But a contract is a living
7
+ * document — it drifts from reality as the project grows. So this prompt is
8
+ * bidirectional: scaffold it when missing, and review + suggest updates when it
9
+ * exists (a drift check on the contract itself), never clobbering human content.
10
+ */
11
+ export function registerClaudeMdPrompt(server) {
12
+ server.prompt('claude_md', 'Create or keep the project CLAUDE.md current. Missing → scaffold from the everystack contract. Exists → review against the project reality + the cheat-gate rules and suggest updates (confirm-first, never clobber). Writing it activates the grounding gate.', {
13
+ projectPath: z.string().optional().describe('Absolute path to the project root (where CLAUDE.md lives)'),
14
+ }, async ({ projectPath }) => {
15
+ const root = projectPath ?? '.';
16
+ return {
17
+ messages: [
18
+ {
19
+ role: 'user',
20
+ content: {
21
+ type: 'text',
22
+ text: [
23
+ `Create or reconcile the CLAUDE.md for the project at ${root}.`,
24
+ '',
25
+ '## Why this matters',
26
+ '',
27
+ 'CLAUDE.md is this project\'s contract. The grounding gate auto-requires the nearest',
28
+ 'project CLAUDE.md — so writing it is what turns grounding ON (the agent must read it',
29
+ 'before editing). A contract also drifts as the project grows, so it must be kept current.',
30
+ '',
31
+ '## Step 1 — detect the project reality',
32
+ '',
33
+ `- Read ${root}/package.json: which @everystack/* packages are installed (tier: V1 server/cli/ui;`,
34
+ ' V2 adds api/auth/admin/logging/security/query; V3 adds jobs/storage/images).',
35
+ `- Check for a models/ directory (defineModel files) and a db/ directory.`,
36
+ `- Note the project name and what the app does.`,
37
+ '',
38
+ '## Step 2 — read the template',
39
+ '',
40
+ 'Read the everystack://project-claude-md resource. It is the everystack contract: the',
41
+ 'Non-negotiables (which mirror the cheat gates), Key Principles, Commands, and the',
42
+ 'What NOT to Do list. Fill {PROJECT_NAME}, {ONE_LINE_DESCRIPTION}, {ANNOTATED_DIRECTORY_TREE}',
43
+ 'and tailor Structure/Commands to the packages actually installed.',
44
+ '',
45
+ `## Step 3 — does ${root}/CLAUDE.md already exist?`,
46
+ '',
47
+ '### If it does NOT exist → scaffold',
48
+ '',
49
+ `- Write ${root}/CLAUDE.md from the template, tailored to the detected reality.`,
50
+ '- Keep it tight and load-bearing — a wall of prose gets read as scenery. Lead with the',
51
+ ' Non-negotiables.',
52
+ '- Tell the human: this activates the grounding gate; new sessions must read it first.',
53
+ '',
54
+ '### If it EXISTS → review and suggest updates (DO NOT clobber)',
55
+ '',
56
+ 'Reconcile the existing CLAUDE.md against three things, and propose a concrete diff:',
57
+ '1. **Framework drift** — does it teach superseded ways (e.g. `drizzle-kit generate`,',
58
+ ' hand-written migrations, a migration journal, "pass your Drizzle schema") instead of',
59
+ ' the migration-authority flow (`defineModel` in db/models/ → `everystack db:sync` on',
60
+ ' dev; `db:plan` → `db:apply` on protected stages; `db:check` in CI; data moves in',
61
+ ' db/backfills/ via `db:backfill`)? Suggest the current conventions.',
62
+ '2. **Project drift** — do the Structure / Commands / package list match what is actually',
63
+ ' installed now (new packages, a new tier, a new models/ dir)? Suggest updates. Also',
64
+ ' check the operations manual: if docs/RUNBOOK.md is missing, or stale per',
65
+ ' `everystack runbook --check`, suggest the `runbook` prompt.',
66
+ '3. **Contract-vs-gates drift** — is it missing any Non-negotiable the cheat gates enforce',
67
+ ' (data→DB, generated migrations, declared authz, reuse @everystack/ui, secrets boundary)?',
68
+ ' Suggest adding it, so the human contract and the enforced rules agree.',
69
+ '',
70
+ 'Rules for reconciling:',
71
+ '- **Preserve all human/project-specific content** — project rules, domain notes, the',
72
+ ' REQUIRED-READS line. Only update the framework/structure/commands sections and flag gaps.',
73
+ '- **Propose, then confirm.** Show the human the suggested changes (a diff) and let them',
74
+ ' approve before writing. The CLAUDE.md is theirs; you assist, you do not own it.',
75
+ '- **Only flag real drift**, not cosmetic rewording.',
76
+ '',
77
+ '## Step 4 — confirm',
78
+ '',
79
+ 'After writing/updating, confirm the file is at the project root so the grounding gate',
80
+ 'picks it up, and summarize what changed.',
81
+ ].join('\n'),
82
+ },
83
+ },
84
+ ],
85
+ };
86
+ });
87
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerDebugPrompt(server: McpServer): void;
3
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/prompts/debug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAoI3D"}
@@ -0,0 +1,129 @@
1
+ import { z } from 'zod';
2
+ export function registerDebugPrompt(server) {
3
+ server.prompt('debug', 'Systematic debugging for common everystack issues. Provides diagnostic steps based on the symptom.', {
4
+ symptom: z.string().describe('Description of the problem (e.g., "401 on all API requests", "RLS blocking reads", "Lambda timeout")'),
5
+ projectPath: z.string().optional().describe('Absolute path to project root'),
6
+ }, async ({ symptom, projectPath }) => {
7
+ return {
8
+ messages: [
9
+ {
10
+ role: 'user',
11
+ content: {
12
+ type: 'text',
13
+ text: [
14
+ `Debug this issue: ${symptom}`,
15
+ '',
16
+ '## Instructions',
17
+ '',
18
+ '1. Read everystack://core for architecture context.',
19
+ projectPath ? `2. Run project_status with projectPath="${projectPath}" to understand the project.` : '',
20
+ projectPath ? `3. Run project_validate with projectPath="${projectPath}" to find configuration issues.` : '',
21
+ projectPath ? `4. Run schema_analyze with projectPath="${projectPath}" to check schema/handler alignment.` : '',
22
+ '',
23
+ '## Diagnostic Framework',
24
+ '',
25
+ 'Work through these categories systematically:',
26
+ '',
27
+ '### 1. Authentication Issues (401/403)',
28
+ '',
29
+ 'If the symptom involves authentication or authorization:',
30
+ '',
31
+ '- **Check token flow:**',
32
+ ' - Is the JWT being sent in the Authorization header?',
33
+ ' - Is the token expired? Decode at jwt.io and check `exp`',
34
+ ' - Does `auth.verifyToken` return a valid payload?',
35
+ '',
36
+ '- **Check publicRoutes:**',
37
+ ' - Is the route supposed to be public? Check `auth.publicRoutes` in handler config',
38
+ ' - Is the RPC in `auth.publicRpc`?',
39
+ '',
40
+ '- **Check pgSettings:**',
41
+ ' - Is `pgSettings` configured in the handler?',
42
+ ' - Does it set `role` and `request.jwt.claims`?',
43
+ ' - Test with: `SELECT current_setting(\'request.jwt.claims\', true);`',
44
+ '',
45
+ '### 2. RLS Issues (empty results, permission denied)',
46
+ '',
47
+ 'Read everystack://security for RLS debugging.',
48
+ '',
49
+ '- **Check RLS is enabled:**',
50
+ ' ```sql',
51
+ ' SELECT tablename, rowsecurity FROM pg_tables WHERE schemaname = \'public\';',
52
+ ' ```',
53
+ '',
54
+ '- **Check policies exist:**',
55
+ ' ```sql',
56
+ ' SELECT * FROM pg_policies WHERE schemaname = \'public\';',
57
+ ' ```',
58
+ '',
59
+ '- **Test as specific role:**',
60
+ ' ```sql',
61
+ ' SET LOCAL ROLE authenticated;',
62
+ ' SELECT set_config(\'request.jwt.claims\', \'{"sub":"user-id","role":"authenticated"}\', true);',
63
+ ' SELECT * FROM your_table;',
64
+ ' ```',
65
+ '',
66
+ '- **Common RLS mistakes:**',
67
+ ' - Policy references wrong claim path (sub vs user_id)',
68
+ ' - USING clause doesn\'t match the data (e.g., UUID vs text comparison)',
69
+ ' - Missing policy for the operation (SELECT exists but not INSERT)',
70
+ ' - Forgot `WITH CHECK` on INSERT/UPDATE policies',
71
+ '',
72
+ '### 3. Query Issues (wrong data, missing relations)',
73
+ '',
74
+ 'Read everystack://query-protocol for filter syntax.',
75
+ '',
76
+ '- **Check relations config:**',
77
+ ' - Does the handler `relations` config match the Drizzle schema relations?',
78
+ ' - Is the relation direction correct (from/to)?',
79
+ '',
80
+ '- **Check column names:**',
81
+ ' - Handler uses camelCase by default. Database uses snake_case.',
82
+ ' - Check `naming` option in handler config.',
83
+ '',
84
+ '### 4. Deployment Issues',
85
+ '',
86
+ 'Read everystack://deployment and everystack://cli.',
87
+ '',
88
+ '- **Lambda errors:**',
89
+ ' ```bash',
90
+ ' everystack logs:errors --stage dev',
91
+ ' everystack logs:tail --stage dev',
92
+ ' ```',
93
+ '',
94
+ '- **Database connection:**',
95
+ ' ```bash',
96
+ ' everystack db:psql --stage dev',
97
+ ' everystack diag --stage dev',
98
+ ' ```',
99
+ '',
100
+ '- **Common deployment issues:**',
101
+ ' - Missing secrets: `pnpm sst secret list --stage dev`',
102
+ ' - VPC configuration: Lambda can\'t reach RDS without proper VPC setup',
103
+ ' - Bundle size: Check if unnecessary packages are bundled',
104
+ '',
105
+ '### 5. Performance Issues',
106
+ '',
107
+ '- **Slow queries:**',
108
+ ' - Check for missing indexes on filtered/joined columns',
109
+ ' - Check `maxLimit` and `maxEmbedDepth` in handler config',
110
+ ' - Use `EXPLAIN ANALYZE` on slow queries',
111
+ '',
112
+ '- **Cold starts:**',
113
+ ' - Minimize Lambda bundle size',
114
+ ' - Use provisioned concurrency for production',
115
+ '',
116
+ '## Resolution',
117
+ '',
118
+ 'After diagnosing:',
119
+ '1. Identify the root cause',
120
+ '2. Propose a fix with the specific code change',
121
+ '3. Verify the fix resolves the issue',
122
+ '4. Run project_validate to ensure no new issues were introduced',
123
+ ].filter(Boolean).join('\n'),
124
+ },
125
+ },
126
+ ],
127
+ };
128
+ });
129
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerDeployPrompt(server: McpServer): void;
3
+ //# sourceMappingURL=deploy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/prompts/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA0H5D"}