@terreno/mcp 57.19.2 → 57.20.0
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/CHANGELOG.md +393 -0
- package/README.md +32 -269
- package/dist/bootstrap.d.ts +12 -0
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +77 -122
- package/dist/bootstrap.js.map +1 -1
- package/dist/docs/guidelines/ui/guidelines/core.md +1 -1
- package/dist/docs/resources/overview.md +4 -2
- package/dist/docs/resources/patterns.md +237 -176
- package/dist/docs/resources/ui.md +48 -17
- package/dist/docs/templates/bootstrap/frontend/app/(tabs)/profile.template.tsx +0 -26
- package/dist/docs/templates/bootstrap/frontend/app/_layout.template.tsx +3 -2
- package/dist/docs/templates/bootstrap/frontend/app/login.template.tsx +1 -1
- package/dist/docs/upgrades/57.20.0.md +238 -0
- package/dist/docs/versioned/next/approval-rubric.md +30 -12
- package/dist/docs/versioned/next/explanation/README.md +5 -0
- package/dist/docs/versioned/next/explanation/account-linking.md +169 -0
- package/dist/docs/versioned/next/explanation/admin-interface.md +1 -1
- package/dist/docs/versioned/next/explanation/agent-guidelines.md +173 -0
- package/dist/docs/versioned/next/explanation/ai-development-loop.md +196 -0
- package/dist/docs/versioned/next/explanation/authentication.md +45 -1
- package/dist/docs/versioned/next/explanation/consent-forms.md +105 -0
- package/dist/docs/versioned/next/explanation/example-coverage.md +1 -0
- package/dist/docs/versioned/next/explanation/local-first-data.md +1 -1
- package/dist/docs/versioned/next/explanation/organizations.md +37 -0
- package/dist/docs/versioned/next/explanation/planning-plugins.md +4 -0
- package/dist/docs/versioned/next/explanation/responsive-design.md +143 -0
- package/dist/docs/versioned/next/explanation/roadmap-seed-issues.md +11 -0
- package/dist/docs/versioned/next/explanation/schema-metadata.md +5 -0
- package/dist/docs/versioned/next/how-to/README.md +7 -2
- package/dist/docs/versioned/next/how-to/audit-log.md +22 -3
- package/dist/docs/versioned/next/how-to/automate-terreno-upgrades.md +169 -0
- package/dist/docs/versioned/next/how-to/build-list-detail-screens.md +160 -0
- package/dist/docs/versioned/next/how-to/circleci.md +15 -5
- package/dist/docs/versioned/next/how-to/configure-better-auth.md +673 -53
- package/dist/docs/versioned/next/how-to/create-a-terreno-app.md +8 -5
- package/dist/docs/versioned/next/how-to/debug-with-mcp.md +393 -23
- package/dist/docs/versioned/next/how-to/enable-mcp-oauth.md +54 -3
- package/dist/docs/versioned/next/how-to/migrate-rtk-to-syncdb.md +9 -0
- package/dist/docs/versioned/next/how-to/password-reset.md +1 -1
- package/dist/docs/versioned/next/how-to/recover-locked-out-user.md +112 -0
- package/dist/docs/versioned/next/how-to/run-tests-locally.md +37 -8
- package/dist/docs/versioned/next/how-to/set-up-social-login.md +424 -0
- package/dist/docs/versioned/next/how-to/set-up-terreno-mcp.md +241 -36
- package/dist/docs/versioned/next/how-to/sign-consent-on-behalf.md +139 -0
- package/dist/docs/versioned/next/how-to/upgrade-terreno.md +4 -0
- package/dist/docs/versioned/next/implementationPlans/ai-dev-loop-boost.md +47 -32
- package/dist/docs/versioned/next/implementationPlans/auth-experience.md +952 -0
- package/dist/docs/versioned/next/implementationPlans/consent-forms.md +8 -0
- package/dist/docs/versioned/next/implementationPlans/list-detail-layout.md +297 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/HANDOFF.md +211 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/AnotherWay.html +121 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/BackupCode.html +72 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/Cancelled.html +87 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/ContinueEmail.html +64 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/FirstVisit.html +81 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/Main.html +88 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/ManageAccounts.html +77 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/NotLinked.html +92 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/SigningIn.html +60 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/TwoFactor.html +76 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/TwoFactorError.html +81 -0
- package/dist/docs/versioned/next/implementationPlans/login-redesign/boards/WrongPassword.html +69 -0
- package/dist/docs/versioned/next/implementationPlans/mcp-boost-parity.md +1 -1
- package/dist/docs/versioned/next/plans/2026-10-23-provisional-consent.md +297 -0
- package/dist/docs/versioned/next/plans/2026-10-29-fix-mcp-oauth-native-and-machine.md +68 -0
- package/dist/docs/versioned/next/reference/README.md +1 -0
- package/dist/docs/versioned/next/reference/account-security.md +700 -0
- package/dist/docs/versioned/next/reference/admin-backend.md +3 -1
- package/dist/docs/versioned/next/reference/admin-frontend.md +225 -1
- package/dist/docs/versioned/next/reference/api.md +461 -35
- package/dist/docs/versioned/next/reference/cli.md +1 -1
- package/dist/docs/versioned/next/reference/comms.md +8 -0
- package/dist/docs/versioned/next/reference/create-terreno-app.md +3 -1
- package/dist/docs/versioned/next/reference/environment-variables.md +9 -3
- package/dist/docs/versioned/next/reference/legacy/rtk.md +19 -3
- package/dist/docs/versioned/next/reference/lifecycle-plugin.md +6 -0
- package/dist/docs/versioned/next/reference/mcp-server.md +1158 -441
- package/dist/docs/versioned/next/reference/syncdb.md +8 -1
- package/dist/docs/versioned/next/reference/ui.md +1271 -27
- package/dist/docs/versioned/next/tasks/ai-dev-loop-boost.md +28 -16
- package/dist/docs/versioned/next/tutorials/README.md +4 -0
- package/dist/httpApp.d.ts +14 -0
- package/dist/httpApp.d.ts.map +1 -0
- package/dist/httpApp.js +99 -0
- package/dist/httpApp.js.map +1 -0
- package/dist/index.js +8 -90
- package/dist/index.js.map +1 -1
- package/dist/local/localTools.d.ts.map +1 -1
- package/dist/local/localTools.js +44 -14
- package/dist/local/localTools.js.map +1 -1
- package/dist/local/metro/metroDevSession.d.ts +18 -0
- package/dist/local/metro/metroDevSession.d.ts.map +1 -1
- package/dist/local/metro/metroDevSession.js +42 -3
- package/dist/local/metro/metroDevSession.js.map +1 -1
- package/dist/local/tools/databaseQuery.d.ts.map +1 -1
- package/dist/local/tools/databaseQuery.js +3 -13
- package/dist/local/tools/databaseQuery.js.map +1 -1
- package/dist/local/tools/databaseSchema.d.ts.map +1 -1
- package/dist/local/tools/databaseSchema.js +3 -13
- package/dist/local/tools/databaseSchema.js.map +1 -1
- package/dist/local/tools/localMongo.d.ts +10 -0
- package/dist/local/tools/localMongo.d.ts.map +1 -0
- package/dist/local/tools/localMongo.js +30 -0
- package/dist/local/tools/localMongo.js.map +1 -0
- package/dist/local/tools/runtime.d.ts +18 -2
- package/dist/local/tools/runtime.d.ts.map +1 -1
- package/dist/local/tools/runtime.js +75 -20
- package/dist/local/tools/runtime.js.map +1 -1
- package/dist/local/tools/syncDb.d.ts +11 -0
- package/dist/local/tools/syncDb.d.ts.map +1 -1
- package/dist/local/tools/syncDb.js +15 -3
- package/dist/local/tools/syncDb.js.map +1 -1
- package/dist/rateLimit.d.ts +35 -0
- package/dist/rateLimit.d.ts.map +1 -0
- package/dist/rateLimit.js +112 -0
- package/dist/rateLimit.js.map +1 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +42 -60
- package/dist/tools.js.map +1 -1
- package/package.json +4 -3
- package/src/docs/guidelines/ui/guidelines/core.md +1 -1
- package/src/docs/resources/overview.md +4 -2
- package/src/docs/resources/patterns.md +237 -176
- package/src/docs/resources/ui.md +48 -17
- package/src/docs/templates/bootstrap/frontend/app/(tabs)/profile.template.tsx +0 -26
- package/src/docs/templates/bootstrap/frontend/app/_layout.template.tsx +3 -2
- package/src/docs/templates/bootstrap/frontend/app/login.template.tsx +1 -1
- package/src/docs/upgrades/57.20.0.md +238 -0
- package/src/docs/versioned/next/approval-rubric.md +30 -12
- package/src/docs/versioned/next/explanation/README.md +5 -0
- package/src/docs/versioned/next/explanation/account-linking.md +169 -0
- package/src/docs/versioned/next/explanation/admin-interface.md +1 -1
- package/src/docs/versioned/next/explanation/agent-guidelines.md +173 -0
- package/src/docs/versioned/next/explanation/ai-development-loop.md +196 -0
- package/src/docs/versioned/next/explanation/authentication.md +45 -1
- package/src/docs/versioned/next/explanation/consent-forms.md +105 -0
- package/src/docs/versioned/next/explanation/example-coverage.md +1 -0
- package/src/docs/versioned/next/explanation/local-first-data.md +1 -1
- package/src/docs/versioned/next/explanation/organizations.md +37 -0
- package/src/docs/versioned/next/explanation/planning-plugins.md +4 -0
- package/src/docs/versioned/next/explanation/responsive-design.md +143 -0
- package/src/docs/versioned/next/explanation/roadmap-seed-issues.md +11 -0
- package/src/docs/versioned/next/explanation/schema-metadata.md +5 -0
- package/src/docs/versioned/next/how-to/README.md +7 -2
- package/src/docs/versioned/next/how-to/audit-log.md +22 -3
- package/src/docs/versioned/next/how-to/automate-terreno-upgrades.md +169 -0
- package/src/docs/versioned/next/how-to/build-list-detail-screens.md +160 -0
- package/src/docs/versioned/next/how-to/circleci.md +15 -5
- package/src/docs/versioned/next/how-to/configure-better-auth.md +673 -53
- package/src/docs/versioned/next/how-to/create-a-terreno-app.md +8 -5
- package/src/docs/versioned/next/how-to/debug-with-mcp.md +393 -23
- package/src/docs/versioned/next/how-to/enable-mcp-oauth.md +54 -3
- package/src/docs/versioned/next/how-to/migrate-rtk-to-syncdb.md +9 -0
- package/src/docs/versioned/next/how-to/password-reset.md +1 -1
- package/src/docs/versioned/next/how-to/recover-locked-out-user.md +112 -0
- package/src/docs/versioned/next/how-to/run-tests-locally.md +37 -8
- package/src/docs/versioned/next/how-to/set-up-social-login.md +424 -0
- package/src/docs/versioned/next/how-to/set-up-terreno-mcp.md +241 -36
- package/src/docs/versioned/next/how-to/sign-consent-on-behalf.md +139 -0
- package/src/docs/versioned/next/how-to/upgrade-terreno.md +4 -0
- package/src/docs/versioned/next/implementationPlans/ai-dev-loop-boost.md +47 -32
- package/src/docs/versioned/next/implementationPlans/auth-experience.md +952 -0
- package/src/docs/versioned/next/implementationPlans/consent-forms.md +8 -0
- package/src/docs/versioned/next/implementationPlans/list-detail-layout.md +297 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/HANDOFF.md +211 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/AnotherWay.html +121 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/BackupCode.html +72 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/Cancelled.html +87 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/ContinueEmail.html +64 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/FirstVisit.html +81 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/Main.html +88 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/ManageAccounts.html +77 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/NotLinked.html +92 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/SigningIn.html +60 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/TwoFactor.html +76 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/TwoFactorError.html +81 -0
- package/src/docs/versioned/next/implementationPlans/login-redesign/boards/WrongPassword.html +69 -0
- package/src/docs/versioned/next/implementationPlans/mcp-boost-parity.md +1 -1
- package/src/docs/versioned/next/plans/2026-10-23-provisional-consent.md +297 -0
- package/src/docs/versioned/next/plans/2026-10-29-fix-mcp-oauth-native-and-machine.md +68 -0
- package/src/docs/versioned/next/reference/README.md +1 -0
- package/src/docs/versioned/next/reference/account-security.md +700 -0
- package/src/docs/versioned/next/reference/admin-backend.md +3 -1
- package/src/docs/versioned/next/reference/admin-frontend.md +225 -1
- package/src/docs/versioned/next/reference/api.md +461 -35
- package/src/docs/versioned/next/reference/cli.md +1 -1
- package/src/docs/versioned/next/reference/comms.md +8 -0
- package/src/docs/versioned/next/reference/create-terreno-app.md +3 -1
- package/src/docs/versioned/next/reference/environment-variables.md +9 -3
- package/src/docs/versioned/next/reference/legacy/rtk.md +19 -3
- package/src/docs/versioned/next/reference/lifecycle-plugin.md +6 -0
- package/src/docs/versioned/next/reference/mcp-server.md +1158 -441
- package/src/docs/versioned/next/reference/syncdb.md +8 -1
- package/src/docs/versioned/next/reference/ui.md +1271 -27
- package/src/docs/versioned/next/tasks/ai-dev-loop-boost.md +28 -16
- package/src/docs/versioned/next/tutorials/README.md +4 -0
package/README.md
CHANGED
|
@@ -1,295 +1,58 @@
|
|
|
1
1
|
# @terreno/mcp
|
|
2
2
|
|
|
3
|
-
MCP
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
### Resources
|
|
8
|
-
|
|
9
|
-
Documentation resources accessible via MCP:
|
|
10
|
-
|
|
11
|
-
- `terreno://docs/overview` - Overview of the Terreno monorepo
|
|
12
|
-
- `terreno://docs/api` - @terreno/api documentation
|
|
13
|
-
- `terreno://docs/ui` - @terreno/ui documentation
|
|
14
|
-
- `terreno://docs/rtk` - @terreno/rtk documentation
|
|
15
|
-
- `terreno://docs/patterns` - Common patterns and best practices
|
|
16
|
-
|
|
17
|
-
### Tools
|
|
18
|
-
|
|
19
|
-
Code generation tools:
|
|
20
|
-
|
|
21
|
-
- `terreno_search_docs` - Search bundled Terreno documentation (call before guessing APIs). Optional `version` selects a retained docs snapshot; omit for current `next` docs.
|
|
22
|
-
- `terreno_get_component_docs` - Full `@terreno/ui` props table for one component
|
|
23
|
-
- `terreno_get_upgrade_guide` - Lockstep upgrade notes between two `@terreno/*` versions
|
|
24
|
-
- `terreno_search_update_notes` - Search bundled upgrade markdown and optional backend announcement help API
|
|
25
|
-
- `terreno_get_update_note` - Fetch one full update note by id (`upgrade:<semver>` or `announcement:<mongoId>`)
|
|
26
|
-
- `terreno_ask_update_help` - Ask a natural-language question; returns ranked matches with full update bodies
|
|
27
|
-
- `terreno_bootstrap_ai_rules` - Scaffold AI assistant rules files for Cursor, Claude Code, etc.
|
|
28
|
-
- `terreno_generate_model` - Generate a Mongoose model with proper Terreno conventions
|
|
29
|
-
- `terreno_generate_route` - Generate a modelRouter route configuration
|
|
30
|
-
- `terreno_generate_screen` - Generate a React Native screen component
|
|
31
|
-
- `terreno_generate_form_fields` - Generate form field components
|
|
32
|
-
- `terreno_validate_model_schema` - Validate a Mongoose schema follows conventions
|
|
33
|
-
- `terreno_install_admin` - Generate admin panel integration files and instructions
|
|
34
|
-
|
|
35
|
-
Local runtime tools (`terreno-mcp-local`):
|
|
36
|
-
|
|
37
|
-
- `get_syncdb_state` - Inspect live SyncDB entities, outbox, conflicts, cursors,
|
|
38
|
-
streams, repair markers, status, and debugger events
|
|
39
|
-
- `syncdb_snapshot` - Capture, list, read, compare, and delete SyncDB snapshots
|
|
40
|
-
- `syncdb_action` - Mutate/edit local state, flush, reconcile/resync,
|
|
41
|
-
resolve/retry, toggle offline mode, clear events, and merge snapshots
|
|
42
|
-
|
|
43
|
-
Create the SyncDB client with `debug: true`. State changes require
|
|
44
|
-
`TERRENO_MCP_EVAL=1`; reads and snapshots do not.
|
|
45
|
-
|
|
46
|
-
### Prompts
|
|
47
|
-
|
|
48
|
-
Code generation prompts:
|
|
49
|
-
|
|
50
|
-
- `terreno_bootstrap` - Prompt workflow for scaffolding a new Terreno application
|
|
51
|
-
- `terreno_create_crud_feature` - Generate complete CRUD feature (model, routes, screens)
|
|
52
|
-
- `terreno_create_api_endpoint` - Generate custom API endpoint with OpenAPI docs
|
|
53
|
-
- `terreno_create_ui_component` - Generate reusable UI component
|
|
54
|
-
- `terreno_create_form_screen` - Generate form screen with validation
|
|
55
|
-
- `terreno_add_authentication` - Generate authentication setup
|
|
56
|
-
- `terreno_migrate_to_terreno_app` - Migrate from setupServer to TerrenoApp pattern
|
|
57
|
-
- `terreno_style_guide` - Get the Terreno code style guide
|
|
58
|
-
- `terreno_upgrade` - Lockstep Terreno upgrade workflow
|
|
3
|
+
MCP servers that give coding agents Terreno docs, code generators, and live app diagnostics — part of
|
|
4
|
+
Terreno, the batteries-included TypeScript framework for universal apps.
|
|
59
5
|
|
|
60
6
|
## Install
|
|
61
7
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
bun install
|
|
65
|
-
bun run mcp:build
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Usage
|
|
69
|
-
|
|
70
|
-
### With Claude Desktop
|
|
71
|
-
|
|
72
|
-
Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
73
|
-
|
|
74
|
-
```json
|
|
75
|
-
{
|
|
76
|
-
"mcpServers": {
|
|
77
|
-
"terreno": {
|
|
78
|
-
"command": "bun",
|
|
79
|
-
"args": ["/path/to/terreno/mcp-server/dist/index.js"]
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### With Claude Code CLI
|
|
86
|
-
|
|
87
|
-
Add to your project's `.claude/settings.json`:
|
|
88
|
-
|
|
89
|
-
```json
|
|
90
|
-
{
|
|
91
|
-
"mcpServers": {
|
|
92
|
-
"terreno": {
|
|
93
|
-
"command": "bun",
|
|
94
|
-
"args": ["./mcp-server/dist/index.js"]
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### Update help (optional)
|
|
101
|
-
|
|
102
|
-
When `TERRENO_HELP_API_URL` points at a Terreno backend with `AnnouncementsApp({help: {enabled: true}})`, the update-note tools also search live product announcements (published by default; pass `includeArchived: true` for archived notes). Set `TERRENO_HELP_API_TOKEN` when the help routes require authentication.
|
|
103
|
-
|
|
104
|
-
## Development
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
# Build
|
|
108
|
-
bun run build
|
|
109
|
-
|
|
110
|
-
# Watch mode
|
|
111
|
-
bun run dev
|
|
112
|
-
|
|
113
|
-
# Start server
|
|
114
|
-
bun run start
|
|
115
|
-
|
|
116
|
-
# Run tests
|
|
117
|
-
bun run test
|
|
118
|
-
|
|
119
|
-
# Lint
|
|
120
|
-
bun run lint
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## Docker
|
|
124
|
-
|
|
125
|
-
Build and run the MCP server in Docker:
|
|
8
|
+
The hosted server needs no install: point your editor at `https://mcp.terreno.app/mcp` (MCP
|
|
9
|
+
Streamable HTTP). Install the package in your app for the local stdio server:
|
|
126
10
|
|
|
127
11
|
```bash
|
|
128
|
-
|
|
129
|
-
docker build -t terreno-mcp-server ./mcp-server
|
|
130
|
-
|
|
131
|
-
# Run the container
|
|
132
|
-
docker run --rm terreno-mcp-server
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## CI/CD
|
|
136
|
-
|
|
137
|
-
The MCP server includes GitHub Actions workflows:
|
|
138
|
-
|
|
139
|
-
### CI Workflow (`.github/workflows/mcp-server-ci.yml`)
|
|
140
|
-
- Runs on every push/PR to `mcp-server/**`
|
|
141
|
-
- Lints, builds, and tests the code
|
|
142
|
-
- Builds Docker image to verify it works
|
|
143
|
-
|
|
144
|
-
### Deploy Workflow (`.github/workflows/mcp-server-deploy.yml`)
|
|
145
|
-
- Runs on push to `master`/`main` branch
|
|
146
|
-
- Deploys to Google Cloud Run
|
|
147
|
-
|
|
148
|
-
### Required GitHub Secrets for Deployment
|
|
149
|
-
|
|
150
|
-
Configure these secrets in your GitHub repository:
|
|
151
|
-
|
|
152
|
-
| Secret | Description |
|
|
153
|
-
|--------|-------------|
|
|
154
|
-
| `GCP_PROJECT_ID` | Your Google Cloud project ID |
|
|
155
|
-
| `GCP_WORKLOAD_IDENTITY_PROVIDER` | Workload Identity Federation provider |
|
|
156
|
-
| `GCP_SERVICE_ACCOUNT` | Service account email for deployment |
|
|
157
|
-
| `GCP_ARTIFACT_REGISTRY` | Artifact Registry repository name |
|
|
158
|
-
|
|
159
|
-
### Setting up GCP for Deployment
|
|
160
|
-
|
|
161
|
-
1. Create an Artifact Registry repository:
|
|
162
|
-
```bash
|
|
163
|
-
gcloud artifacts repositories create terreno \
|
|
164
|
-
--repository-format=docker \
|
|
165
|
-
--location=us-central1
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
2. Set up Workload Identity Federation for GitHub Actions:
|
|
169
|
-
```bash
|
|
170
|
-
# Create workload identity pool
|
|
171
|
-
gcloud iam workload-identity-pools create "github" \
|
|
172
|
-
--location="global" \
|
|
173
|
-
--display-name="GitHub Actions"
|
|
174
|
-
|
|
175
|
-
# Create provider
|
|
176
|
-
gcloud iam workload-identity-pools providers create-oidc "github" \
|
|
177
|
-
--location="global" \
|
|
178
|
-
--workload-identity-pool="github" \
|
|
179
|
-
--display-name="GitHub" \
|
|
180
|
-
--attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.repository=assertion.repository" \
|
|
181
|
-
--issuer-uri="https://token.actions.githubusercontent.com"
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
3. Grant permissions to the service account:
|
|
185
|
-
```bash
|
|
186
|
-
# Cloud Run deployment
|
|
187
|
-
gcloud projects add-iam-policy-binding PROJECT_ID \
|
|
188
|
-
--member="serviceAccount:SA_EMAIL" \
|
|
189
|
-
--role="roles/run.admin"
|
|
190
|
-
|
|
191
|
-
# Artifact Registry push
|
|
192
|
-
gcloud artifacts repositories add-iam-policy-binding terreno \
|
|
193
|
-
--location=us-central1 \
|
|
194
|
-
--member="serviceAccount:SA_EMAIL" \
|
|
195
|
-
--role="roles/artifactregistry.writer"
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
## How Tools Work
|
|
199
|
-
|
|
200
|
-
**Important**: MCP tools return generated code as text content. They do not create files directly. When using these tools with an AI assistant (like Claude in Cursor), the assistant should:
|
|
201
|
-
|
|
202
|
-
1. Call the appropriate tool to generate code
|
|
203
|
-
2. Take the returned code text and write it to the appropriate file in your project
|
|
204
|
-
3. Follow up with any necessary steps (registering routes, regenerating SDK, etc.)
|
|
205
|
-
|
|
206
|
-
This design allows the AI assistant to:
|
|
207
|
-
- Review and adapt the generated code to your project structure
|
|
208
|
-
- Make any necessary modifications before writing
|
|
209
|
-
- Handle file paths based on your project's conventions
|
|
210
|
-
|
|
211
|
-
## Example Tool Usage
|
|
212
|
-
|
|
213
|
-
### Generate a Model
|
|
214
|
-
|
|
215
|
-
```json
|
|
216
|
-
{
|
|
217
|
-
"name": "terreno_generate_model",
|
|
218
|
-
"arguments": {
|
|
219
|
-
"name": "Product",
|
|
220
|
-
"fields": [
|
|
221
|
-
{ "name": "title", "type": "String", "required": true },
|
|
222
|
-
{ "name": "price", "type": "Number", "required": true },
|
|
223
|
-
{ "name": "active", "type": "Boolean", "default": "true" }
|
|
224
|
-
],
|
|
225
|
-
"hasOwner": true,
|
|
226
|
-
"softDelete": true
|
|
227
|
-
}
|
|
228
|
-
}
|
|
12
|
+
bun add -d @terreno/mcp
|
|
229
13
|
```
|
|
230
14
|
|
|
231
|
-
The
|
|
15
|
+
The local server needs Bun 1.4 or newer for its `browser` tool.
|
|
232
16
|
|
|
233
|
-
|
|
17
|
+
## Quick start
|
|
234
18
|
|
|
235
|
-
|
|
236
|
-
{
|
|
237
|
-
"name": "terreno_generate_route",
|
|
238
|
-
"arguments": {
|
|
239
|
-
"modelName": "Product",
|
|
240
|
-
"routePath": "/products",
|
|
241
|
-
"permissions": {
|
|
242
|
-
"create": "authenticated",
|
|
243
|
-
"list": "any",
|
|
244
|
-
"read": "any",
|
|
245
|
-
"update": "owner",
|
|
246
|
-
"delete": "admin"
|
|
247
|
-
},
|
|
248
|
-
"queryFields": ["active", "category"],
|
|
249
|
-
"ownerFiltered": true,
|
|
250
|
-
"sort": "-created"
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
The tool returns route configuration code that should be written to `backend/src/api/product.ts`, then exported from `backend/src/api/index.ts` and registered in your server setup.
|
|
256
|
-
|
|
257
|
-
### Generate a Screen
|
|
19
|
+
Add both servers to `.cursor/mcp.json` (or `.mcp.json` for Claude Code) at the app repository root:
|
|
258
20
|
|
|
259
21
|
```json
|
|
260
22
|
{
|
|
261
|
-
"
|
|
262
|
-
|
|
263
|
-
"
|
|
264
|
-
"type": "list",
|
|
265
|
-
"modelName": "Product",
|
|
266
|
-
"fields": ["title", "price"]
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"terreno": {"type": "http", "url": "https://mcp.terreno.app/mcp"},
|
|
25
|
+
"terreno-local": {"command": "bunx", "args": ["terreno-mcp-local"]}
|
|
267
26
|
}
|
|
268
27
|
}
|
|
269
28
|
```
|
|
270
29
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
## Example Prompt Usage
|
|
274
|
-
|
|
275
|
-
### Create CRUD Feature
|
|
30
|
+
Restart the editor, then ask the agent to call `terreno_search_docs` or `application_info`.
|
|
276
31
|
|
|
277
|
-
|
|
278
|
-
Prompt: terreno_create_crud_feature
|
|
279
|
-
Arguments:
|
|
280
|
-
- name: "Product"
|
|
281
|
-
- fields: "title:string,price:number,description:string,active:boolean"
|
|
282
|
-
- hasOwner: "yes"
|
|
283
|
-
```
|
|
32
|
+
## What's included
|
|
284
33
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
34
|
+
- Hosted `terreno-mcp` tools (14): `terreno_bootstrap_ai_rules`, `terreno_search_docs`,
|
|
35
|
+
`terreno_get_component_docs`, `terreno_get_upgrade_guide`, `terreno_search_update_notes`,
|
|
36
|
+
`terreno_get_update_note`, `terreno_ask_update_help`, `terreno_generate_model`,
|
|
37
|
+
`terreno_generate_route`, `terreno_generate_screen`, `terreno_generate_form_fields`,
|
|
38
|
+
`terreno_validate_model_schema`, `terreno_validate_ui_blocks`, `terreno_install_admin`
|
|
39
|
+
- Local `terreno-mcp-local` tools (13): `application_info`, `database_schema`, `database_query`,
|
|
40
|
+
`read_logs`, `last_error`, `get_client_state`, `get_rtk_state` (deprecated alias of
|
|
41
|
+
`get_client_state`), `get_syncdb_state`, `syncdb_snapshot`, `syncdb_action`, `evaluate`,
|
|
42
|
+
`navigate`, `browser`
|
|
43
|
+
- Nine workflow prompts (`terreno_bootstrap`, `terreno_create_crud_feature`, `terreno_upgrade`, and
|
|
44
|
+
more) and `terreno://docs/*` documentation resources on the hosted server
|
|
45
|
+
- Code generators return text with a target path; the agent writes the files
|
|
46
|
+
- Rate limiting: the hosted server allows 120 requests per 60 seconds per client IP by default and
|
|
47
|
+
answers `429` with `Retry-After` beyond that
|
|
48
|
+
- `TERRENO_MCP_EVAL` gate: `evaluate`, `navigate`, `syncdb_action`, and the `browser` `evaluate`
|
|
49
|
+
action run only when the local server's environment sets `TERRENO_MCP_EVAL=1` (or `true`)
|
|
289
50
|
|
|
290
51
|
## Documentation
|
|
291
52
|
|
|
292
|
-
|
|
53
|
+
- Reference (every tool, parameter, and environment variable): [docs/reference/mcp-server.md](https://github.com/TerrenoLabs/terreno/blob/master/docs/reference/mcp-server.md)
|
|
54
|
+
- How-to: [Set up Terreno MCP](https://github.com/TerrenoLabs/terreno/blob/master/docs/how-to/set-up-terreno-mcp.md)
|
|
55
|
+
- How-to: [Debug a Terreno app with MCP](https://github.com/TerrenoLabs/terreno/blob/master/docs/how-to/debug-with-mcp.md)
|
|
293
56
|
|
|
294
57
|
## License and Contributing
|
|
295
58
|
|
package/dist/bootstrap.d.ts
CHANGED
|
@@ -9,6 +9,18 @@ export interface BootstrapAiRulesArgs extends BootstrapArgs {
|
|
|
9
9
|
/** Optional `@terreno/*` package ids to include (e.g. `["api","ui"]`). Omits others from merged guidelines. */
|
|
10
10
|
packages?: string[];
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* rulesync targets the generated config and root rule share. Every entry must be a target
|
|
14
|
+
* rulesync 9 accepts (it dropped `windsurf`; Windsurf reads the `agentsmd` output).
|
|
15
|
+
*/
|
|
16
|
+
export declare const RULESYNC_TARGETS: readonly ["cursor", "claudecode", "copilot", "agentsmd"];
|
|
17
|
+
/**
|
|
18
|
+
* Warning shown before every `rulesync generate`: with `delete: true` rulesync overwrites the
|
|
19
|
+
* root files and deletes anything else in the rule directories it owns.
|
|
20
|
+
*/
|
|
21
|
+
export declare const RULESYNC_OVERWRITE_WARNING = "`rulesync generate` overwrites the root `CLAUDE.md`, `AGENTS.md`, and `.github/copilot-instructions.md` and deletes every file under `.claude/rules/`, `.cursor/rules/`, `.github/instructions/`, and `.agents/memories/` that it did not generate. Move any edits you made to those root files, and any hand-written files in those directories, into `.rulesync/rules/10-project.md` (or other `.rulesync/rules/*.md` sources) first, or they are lost.";
|
|
22
|
+
/** Command that regenerates editor files; pinned to the rulesync major the output is tested on. */
|
|
23
|
+
export declare const RULESYNC_GENERATE_COMMAND = "bunx rulesync@9 generate";
|
|
12
24
|
interface AiRulesFile {
|
|
13
25
|
path: string;
|
|
14
26
|
content: string;
|
package/dist/bootstrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,8BAA8B,CAAC;AAUvD,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,cAAc,EAAE,IAAI,EA+BhC,CAAC;AAEF,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,+GAA+G;IAC/G,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,8BAA8B,CAAC;AAUvD,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,cAAc,EAAE,IAAI,EA+BhC,CAAC;AAEF,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,+GAA+G;IAC/G,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AACD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,0DAA2D,CAAC;AAEzF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,8bACsZ,CAAC;AAE9b,mGAAmG;AACnG,eAAO,MAAM,yBAAyB,6BAA6B,CAAC;AAkRpE,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,oBAAoB,GAAI,MAAM,oBAAoB,KAAG,WAAW,EAyB5E,CAAC;AAsFF,eAAO,MAAM,uBAAuB,GAClC,MAAM,MAAM,EACZ,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B;IAAC,OAAO,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;CAQ/C,CAAC;AAGF,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC,CAAC;CACJ;AAED,eAAO,MAAM,gBAAgB,EAAE,eAAe,EAkB7C,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,MAAM,MAAM,EACZ,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC3B;IAAC,QAAQ,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAC,CAAA;KAAC,CAAC,CAAA;CA8DzE,CAAC"}
|
package/dist/bootstrap.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { composePackageGuidelinesForRules, filterGuidelineIdsForRootRules, loadPackageGuidelineMarkdown, resolveBootstrapGuidelinePackages, } from "./packageGuidelines.js";
|
|
2
2
|
export const bootstrapTools = [
|
|
3
3
|
{
|
|
4
|
-
description: "Bootstrap AI coding assistant rules for a Terreno project. Creates
|
|
4
|
+
description: "Bootstrap AI coding assistant rules for a Terreno project. Creates rulesync sources that generate rules for Cursor, Claude Code, GitHub Copilot, and AGENTS.md readers (Codex, Windsurf, and others) with Terreno-specific guidelines adapted for the project.",
|
|
5
5
|
inputSchema: {
|
|
6
6
|
properties: {
|
|
7
7
|
appDisplayName: {
|
|
@@ -28,13 +28,25 @@ export const bootstrapTools = [
|
|
|
28
28
|
name: "terreno_bootstrap_ai_rules",
|
|
29
29
|
},
|
|
30
30
|
];
|
|
31
|
+
/**
|
|
32
|
+
* rulesync targets the generated config and root rule share. Every entry must be a target
|
|
33
|
+
* rulesync 9 accepts (it dropped `windsurf`; Windsurf reads the `agentsmd` output).
|
|
34
|
+
*/
|
|
35
|
+
export const RULESYNC_TARGETS = ["cursor", "claudecode", "copilot", "agentsmd"];
|
|
36
|
+
/**
|
|
37
|
+
* Warning shown before every `rulesync generate`: with `delete: true` rulesync overwrites the
|
|
38
|
+
* root files and deletes anything else in the rule directories it owns.
|
|
39
|
+
*/
|
|
40
|
+
export const RULESYNC_OVERWRITE_WARNING = "`rulesync generate` overwrites the root `CLAUDE.md`, `AGENTS.md`, and `.github/copilot-instructions.md` and deletes every file under `.claude/rules/`, `.cursor/rules/`, `.github/instructions/`, and `.agents/memories/` that it did not generate. Move any edits you made to those root files, and any hand-written files in those directories, into `.rulesync/rules/10-project.md` (or other `.rulesync/rules/*.md` sources) first, or they are lost.";
|
|
41
|
+
/** Command that regenerates editor files; pinned to the rulesync major the output is tested on. */
|
|
42
|
+
export const RULESYNC_GENERATE_COMMAND = "bunx rulesync@9 generate";
|
|
43
|
+
const RULESYNC_TARGETS_FRONTMATTER = `[${RULESYNC_TARGETS.map((t) => `"${t}"`).join(", ")}]`;
|
|
31
44
|
const generateRulesyncConfig = () => {
|
|
32
45
|
return JSON.stringify({
|
|
33
46
|
$schema: "https://raw.githubusercontent.com/dyoshikawa/rulesync/refs/heads/main/config-schema.json",
|
|
34
|
-
baseDirs: ["."],
|
|
35
47
|
delete: true,
|
|
36
48
|
features: ["rules"],
|
|
37
|
-
targets: [
|
|
49
|
+
targets: [...RULESYNC_TARGETS],
|
|
38
50
|
verbose: false,
|
|
39
51
|
}, null, 2);
|
|
40
52
|
};
|
|
@@ -73,14 +85,49 @@ ${appDescription}
|
|
|
73
85
|
Uses [Bun](https://bun.sh/) as the package manager.
|
|
74
86
|
|
|
75
87
|
\`\`\`bash
|
|
88
|
+
# Install dependencies
|
|
89
|
+
cd backend && bun install
|
|
90
|
+
cd frontend && bun install
|
|
91
|
+
|
|
76
92
|
# Backend
|
|
77
93
|
cd backend && bun run dev # Start backend on port 4000
|
|
78
94
|
|
|
79
95
|
# Frontend
|
|
80
|
-
cd frontend && bun run web # Start web frontend
|
|
96
|
+
cd frontend && bun run web # Start web frontend on port 8082
|
|
81
97
|
cd frontend && bun run sdk # Regenerate SDK after backend changes
|
|
82
98
|
\`\`\`
|
|
83
99
|
|
|
100
|
+
## Adding Features
|
|
101
|
+
|
|
102
|
+
1. Create model in \`backend/src/models/\`
|
|
103
|
+
2. Create route in \`backend/src/api/\`
|
|
104
|
+
3. Register route in \`backend/src/server.ts\`
|
|
105
|
+
4. Regenerate SDK: \`cd frontend && bun run sdk\`
|
|
106
|
+
5. Create screens in \`frontend/app/\`
|
|
107
|
+
|
|
108
|
+
## Backend Conventions
|
|
109
|
+
|
|
110
|
+
- Use \`modelRouter\` for CRUD endpoints
|
|
111
|
+
- Use \`APIError\` for error responses
|
|
112
|
+
- Use \`logger.info/warn/error/debug\` for logging
|
|
113
|
+
- Use \`Model.findExactlyOne\` or \`Model.findOneOrNone\` (not \`Model.findOne\`)
|
|
114
|
+
|
|
115
|
+
## Frontend Conventions
|
|
116
|
+
|
|
117
|
+
- Use \`@terreno/syncdb/react\` hooks (\`useQuery\`, \`useMutate\`) for synced collection CRUD
|
|
118
|
+
- Use generated SDK hooks from \`@/store/openApiSdk\` for non-synced routes only
|
|
119
|
+
- Use @terreno/ui components (Box, Page, Button, TextField, etc.)
|
|
120
|
+
- Never modify \`openApiSdk.ts\` manually - regenerate with \`bun run sdk\`
|
|
121
|
+
- Use Redux Toolkit for state management (Better Auth session and the RTK Query SDK)
|
|
122
|
+
|
|
123
|
+
## AI Assistance
|
|
124
|
+
|
|
125
|
+
This project is configured to use the Terreno MCP server for AI-assisted development.
|
|
126
|
+
Use the MCP tools and prompts for:
|
|
127
|
+
- Generating new models and routes
|
|
128
|
+
- Creating screens and forms
|
|
129
|
+
- Following Terreno patterns and best practices
|
|
130
|
+
|
|
84
131
|
## Code Style
|
|
85
132
|
|
|
86
133
|
### TypeScript/JavaScript
|
|
@@ -124,23 +171,11 @@ const generateRootRulesFile = (args, packageIds) => {
|
|
|
124
171
|
const body = buildSharedRootRulesMarkdownBody(args, filterGuidelineIdsForRootRules(packageIds));
|
|
125
172
|
return `---
|
|
126
173
|
root: true
|
|
127
|
-
targets:
|
|
174
|
+
targets: ${RULESYNC_TARGETS_FRONTMATTER}
|
|
128
175
|
description: "${appDisplayName} root guidelines"
|
|
129
176
|
globs: ["**/*"]
|
|
130
177
|
---
|
|
131
178
|
|
|
132
|
-
${body}`;
|
|
133
|
-
};
|
|
134
|
-
const generateClaudeCodeRootRulesFile = (args, packageIds) => {
|
|
135
|
-
const { appDisplayName } = args;
|
|
136
|
-
const body = buildSharedRootRulesMarkdownBody(args, filterGuidelineIdsForRootRules(packageIds));
|
|
137
|
-
return `---
|
|
138
|
-
localRoot: true
|
|
139
|
-
targets: ["claudecode"]
|
|
140
|
-
description: "${appDisplayName} Claude Code guidelines"
|
|
141
|
-
globs: ["**/*"]
|
|
142
|
-
---
|
|
143
|
-
|
|
144
179
|
${body}`;
|
|
145
180
|
};
|
|
146
181
|
const appendAdminBackendGuidelines = (packageIds) => {
|
|
@@ -161,8 +196,6 @@ const generateBackendRulesFile = (args, packageIds) => {
|
|
|
161
196
|
const { appDisplayName } = args;
|
|
162
197
|
const admin = appendAdminBackendGuidelines(packageIds);
|
|
163
198
|
return `---
|
|
164
|
-
root: true
|
|
165
|
-
targets: ["cursor", "windsurf", "copilot"]
|
|
166
199
|
description: "${appDisplayName} backend guidelines"
|
|
167
200
|
globs: ["**/*"]
|
|
168
201
|
---
|
|
@@ -202,51 +235,10 @@ Use \`AppConfig.updateConfig(updates)\` to write. All values are persisted in Mo
|
|
|
202
235
|
6. Optionally add to \`AdminApp\` in \`src/server.ts\` for admin panel access
|
|
203
236
|
`;
|
|
204
237
|
};
|
|
205
|
-
const _generateBackendClaudeRulesFile = (args) => {
|
|
206
|
-
const { appDisplayName } = args;
|
|
207
|
-
return `---
|
|
208
|
-
localRoot: true
|
|
209
|
-
targets: ["claudecode"]
|
|
210
|
-
description: "${appDisplayName} backend Claude Code guidelines"
|
|
211
|
-
globs: ["**/*"]
|
|
212
|
-
---
|
|
213
|
-
|
|
214
|
-
# ${appDisplayName} Backend
|
|
215
|
-
|
|
216
|
-
Express/Mongoose backend using @terreno/api.
|
|
217
|
-
|
|
218
|
-
## Development
|
|
219
|
-
|
|
220
|
-
\`\`\`bash
|
|
221
|
-
bun run dev # Start on port 4000
|
|
222
|
-
bun run test # Run tests
|
|
223
|
-
bun run lint # Lint code
|
|
224
|
-
\`\`\`
|
|
225
|
-
|
|
226
|
-
## Backend Conventions
|
|
227
|
-
|
|
228
|
-
- Use \`modelRouter\` for CRUD endpoints
|
|
229
|
-
- Use \`APIError\` for error responses: \`throw new APIError({status: 400, title: "Message"})\`
|
|
230
|
-
- Use \`logger.info/warn/error/debug\` for logging
|
|
231
|
-
- Use \`Model.findExactlyOne\` or \`Model.findOneOrNone\` (not \`Model.findOne\`)
|
|
232
|
-
- All model types live in \`src/types/models/\`
|
|
233
|
-
- In routes: \`req.user\` is \`UserDocument | undefined\`
|
|
234
|
-
|
|
235
|
-
## Adding a New Model
|
|
236
|
-
|
|
237
|
-
1. Create model in \`src/models/yourModel.ts\`
|
|
238
|
-
2. Create types in \`src/types/models/yourModelTypes.ts\`
|
|
239
|
-
3. Export from \`src/models/index.ts\` and \`src/types/models/index.ts\`
|
|
240
|
-
4. Create route in \`src/api/yourModel.ts\`
|
|
241
|
-
5. Register route in \`src/server.ts\`
|
|
242
|
-
`;
|
|
243
|
-
};
|
|
244
238
|
const generateFrontendRulesFile = (args, packageIds) => {
|
|
245
239
|
const { appDisplayName } = args;
|
|
246
240
|
const admin = appendAdminFrontendGuidelines(packageIds);
|
|
247
241
|
return `---
|
|
248
|
-
root: true
|
|
249
|
-
targets: ["cursor", "windsurf", "copilot"]
|
|
250
242
|
description: "${appDisplayName} frontend guidelines"
|
|
251
243
|
globs: ["**/*"]
|
|
252
244
|
---
|
|
@@ -285,44 +277,6 @@ ${admin}## Expo SDK upgrades
|
|
|
285
277
|
|
|
286
278
|
## Adding a New Screen
|
|
287
279
|
|
|
288
|
-
1. Regenerate SDK if backend changed: \`bun run sdk\`
|
|
289
|
-
2. Create screen in \`app/\` directory
|
|
290
|
-
3. Use @terreno/ui components for layout
|
|
291
|
-
4. Use SDK hooks for non-synced routes; use syncdb hooks for synced collections
|
|
292
|
-
`;
|
|
293
|
-
};
|
|
294
|
-
const _generateFrontendClaudeRulesFile = (args) => {
|
|
295
|
-
const { appDisplayName } = args;
|
|
296
|
-
return `---
|
|
297
|
-
localRoot: true
|
|
298
|
-
targets: ["claudecode"]
|
|
299
|
-
description: "${appDisplayName} frontend Claude Code guidelines"
|
|
300
|
-
globs: ["**/*"]
|
|
301
|
-
---
|
|
302
|
-
|
|
303
|
-
# ${appDisplayName} Frontend
|
|
304
|
-
|
|
305
|
-
Expo/React Native frontend using @terreno/ui, @terreno/syncdb, and @terreno/rtk.
|
|
306
|
-
|
|
307
|
-
## Development
|
|
308
|
-
|
|
309
|
-
\`\`\`bash
|
|
310
|
-
bun run web # Start web frontend on port 8082
|
|
311
|
-
bun run sdk # Regenerate SDK from backend OpenAPI spec
|
|
312
|
-
bun run lint # Lint code
|
|
313
|
-
\`\`\`
|
|
314
|
-
|
|
315
|
-
## Frontend Conventions
|
|
316
|
-
|
|
317
|
-
- Use \`@terreno/syncdb/react\` hooks for synced collection CRUD
|
|
318
|
-
- Use generated SDK hooks from \`@/store/openApiSdk\` for non-synced routes only
|
|
319
|
-
- Use @terreno/ui components (Box, Page, Button, TextField, etc.)
|
|
320
|
-
- Never modify \`openApiSdk.ts\` manually - regenerate with \`bun run sdk\`
|
|
321
|
-
- Use Luxon for date operations
|
|
322
|
-
- Better Auth session: \`generateBetterAuthSlice\` + \`lib/betterAuth.ts\`
|
|
323
|
-
|
|
324
|
-
## Adding a New Screen
|
|
325
|
-
|
|
326
280
|
1. Regenerate SDK if backend changed: \`bun run sdk\`
|
|
327
281
|
2. Create screen in \`app/\` directory
|
|
328
282
|
3. Use @terreno/ui components for layout
|
|
@@ -338,12 +292,8 @@ export const generateAiRulesFiles = (args) => {
|
|
|
338
292
|
const backendContent = stripFrontmatter(generateBackendRulesFile(args, packageIds));
|
|
339
293
|
const frontendContent = stripFrontmatter(generateFrontendRulesFile(args, packageIds));
|
|
340
294
|
return [
|
|
341
|
-
// .rulesync/rules/ source
|
|
295
|
+
// .rulesync/rules/ source file (the source of truth for root rules in every editor)
|
|
342
296
|
{ content: generateRootRulesFile(args, packageIds), path: ".rulesync/rules/00-root.md" },
|
|
343
|
-
{
|
|
344
|
-
content: generateClaudeCodeRootRulesFile(args, packageIds),
|
|
345
|
-
path: ".rulesync/rules/01-claudecode-root.md",
|
|
346
|
-
},
|
|
347
297
|
// Direct output files for backend (AGENTS.md and CLAUDE.md in backend/)
|
|
348
298
|
{ content: backendContent, path: "backend/AGENTS.md" },
|
|
349
299
|
{ content: backendContent, path: "backend/CLAUDE.md" },
|
|
@@ -380,30 +330,35 @@ ${fileList}
|
|
|
380
330
|
|
|
381
331
|
1. **Create all the files listed above.** Each file's content is provided below.
|
|
382
332
|
|
|
383
|
-
2. **
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
\`\`\`
|
|
333
|
+
2. **If \`.rulesync/rules/01-claudecode-root.md\` exists from an earlier bootstrap, delete it.** The root rule now covers Claude Code.
|
|
334
|
+
|
|
335
|
+
3. **Before generating, move hand-written rules into \`.rulesync/rules/\`.** ${RULESYNC_OVERWRITE_WARNING}
|
|
387
336
|
|
|
388
|
-
|
|
337
|
+
4. **Delete the stale \`.cursorrules\`** that \`create-terreno-app\` wrote. \`.cursor/rules/00-root.mdc\` supersedes it, and the root rule contains everything it said.
|
|
338
|
+
|
|
339
|
+
5. **Generate the editor files with rulesync:**
|
|
389
340
|
\`\`\`bash
|
|
390
|
-
|
|
341
|
+
${RULESYNC_GENERATE_COMMAND}
|
|
391
342
|
\`\`\`
|
|
392
|
-
|
|
343
|
+
|
|
393
344
|
This generates root-level files from \`.rulesync/rules/\`:
|
|
394
|
-
- \`.
|
|
345
|
+
- \`.cursor/rules/00-root.mdc\` (Cursor)
|
|
346
|
+
- \`CLAUDE.md\` (Claude Code; replaces the one \`create-terreno-app\` wrote)
|
|
347
|
+
- \`.github/copilot-instructions.md\` (GitHub Copilot)
|
|
348
|
+
- \`AGENTS.md\` (Codex, Windsurf, and other AGENTS.md readers)
|
|
395
349
|
|
|
396
350
|
## How It Works
|
|
397
351
|
|
|
398
|
-
- **\`.rulesync/rules
|
|
399
|
-
- **\`rulesync.jsonc\`** -
|
|
352
|
+
- **\`.rulesync/rules/00-root.md\`** - Source of truth for root-level AI coding guidelines (Terreno-owned; regenerated on re-bootstrap)
|
|
353
|
+
- **\`rulesync.jsonc\`** - rulesync config: \`rules\` feature, targets ${RULESYNC_TARGETS.map((t) => `\`${t}\``).join(", ")}, \`delete: true\`
|
|
400
354
|
- **\`backend/AGENTS.md\` & \`backend/CLAUDE.md\`** - Direct context files for backend
|
|
401
355
|
- **\`frontend/AGENTS.md\` & \`frontend/CLAUDE.md\`** - Direct context files for frontend
|
|
402
356
|
|
|
403
357
|
## Keeping Rules Updated
|
|
404
358
|
|
|
405
|
-
- **
|
|
406
|
-
- **
|
|
359
|
+
- **Project rules**: Add your own sources such as \`.rulesync/rules/10-project.md\` (scope with \`globs\`, e.g. \`["backend/**"]\`) and run \`${RULESYNC_GENERATE_COMMAND}\`. Re-bootstrapping never overwrites them.
|
|
360
|
+
- **Terreno rules**: Re-run \`terreno_bootstrap_ai_rules\` to refresh \`00-root.md\` and the \`backend/\`/\`frontend/\` files, then run \`${RULESYNC_GENERATE_COMMAND}\`
|
|
361
|
+
- Never hand-edit the root-level generated files (\`CLAUDE.md\`, \`AGENTS.md\`, \`.cursor/rules/\`, \`.github/copilot-instructions.md\`); rulesync replaces them
|
|
407
362
|
|
|
408
363
|
---
|
|
409
364
|
|
|
@@ -488,16 +443,16 @@ The application should include:
|
|
|
488
443
|
- Cursor rules for AI assistance
|
|
489
444
|
- MCP integration for development assistance
|
|
490
445
|
|
|
491
|
-
**IMPORTANT: After the CLI writes the app, also run the \`terreno_bootstrap_ai_rules\` tool** with the same appName and appDisplayName to set up AI coding assistant rules for Cursor,
|
|
492
|
-
-
|
|
493
|
-
- .
|
|
494
|
-
- GitHub Copilot instructions
|
|
495
|
-
- Claude Code local rules
|
|
446
|
+
**IMPORTANT: After the CLI writes the app, also run the \`terreno_bootstrap_ai_rules\` tool** with the same appName and appDisplayName to set up AI coding assistant rules for Cursor, Claude Code, GitHub Copilot, and AGENTS.md readers. This will create:
|
|
447
|
+
- \`.rulesync/rules/00-root.md\`, the root rule source for every editor
|
|
448
|
+
- AGENTS.md and CLAUDE.md files for \`backend/\` and \`frontend/\`
|
|
496
449
|
- rulesync.jsonc for keeping rules in sync
|
|
497
450
|
|
|
498
|
-
|
|
451
|
+
Before generating, delete the stale root \`.cursorrules\` (\`.cursor/rules/00-root.mdc\` supersedes it). ${RULESYNC_OVERWRITE_WARNING}
|
|
452
|
+
|
|
453
|
+
Then generate the editor files from the rulesync sources:
|
|
499
454
|
\`\`\`bash
|
|
500
|
-
|
|
455
|
+
${RULESYNC_GENERATE_COMMAND}
|
|
501
456
|
\`\`\``;
|
|
502
457
|
return {
|
|
503
458
|
messages: [
|