@restforgejs/mcp-server 1.2.1 → 1.2.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.
Files changed (30) hide show
  1. package/dist/server.js +45 -0
  2. package/dist/server.js.map +1 -1
  3. package/dist/tools/codegen/dbschema-apply.js +153 -153
  4. package/dist/tools/codegen/dbschema-diff.js +135 -135
  5. package/dist/tools/codegen/dbschema-template.js +111 -111
  6. package/dist/tools/designer/generate.d.ts +2 -0
  7. package/dist/tools/designer/generate.js +212 -0
  8. package/dist/tools/designer/generate.js.map +1 -0
  9. package/dist/tools/designer/index.d.ts +2 -0
  10. package/dist/tools/designer/index.js +17 -0
  11. package/dist/tools/designer/index.js.map +1 -0
  12. package/dist/tools/designer/init-project.d.ts +2 -0
  13. package/dist/tools/designer/init-project.js +235 -0
  14. package/dist/tools/designer/init-project.js.map +1 -0
  15. package/dist/tools/designer/inspect-plugin.d.ts +2 -0
  16. package/dist/tools/designer/inspect-plugin.js +148 -0
  17. package/dist/tools/designer/inspect-plugin.js.map +1 -0
  18. package/dist/tools/designer/list-plugins.d.ts +2 -0
  19. package/dist/tools/designer/list-plugins.js +141 -0
  20. package/dist/tools/designer/list-plugins.js.map +1 -0
  21. package/dist/tools/designer/preview-files.d.ts +2 -0
  22. package/dist/tools/designer/preview-files.js +150 -0
  23. package/dist/tools/designer/preview-files.js.map +1 -0
  24. package/dist/tools/designer/scaffold-plugin.d.ts +2 -0
  25. package/dist/tools/designer/scaffold-plugin.js +162 -0
  26. package/dist/tools/designer/scaffold-plugin.js.map +1 -0
  27. package/dist/tools/designer/validate-payload.d.ts +2 -0
  28. package/dist/tools/designer/validate-payload.js +158 -0
  29. package/dist/tools/designer/validate-payload.js.map +1 -0
  30. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -5,6 +5,7 @@ import { registerHealthTools } from './tools/health/index.js';
5
5
  import { registerSetupTools } from './tools/setup/index.js';
6
6
  import { registerCodegenTools } from './tools/codegen/index.js';
7
7
  import { registerRuntimeTools } from './tools/runtime/index.js';
8
+ import { registerDesignerTools } from './tools/designer/index.js';
8
9
  const SERVER_NAME = 'restforge-mcp';
9
10
  // Read the version from package.json at runtime so the advertised server version
10
11
  // never drifts from the published package version. createRequire resolves the JSON
@@ -227,6 +228,49 @@ documentationUrl returned by each catalog points to narrative
227
228
  documentation which may lag behind the most recent npm release; trust
228
229
  the catalog data over the URL for property reference, but use the URL
229
230
  for use case examples and decision guides.
231
+
232
+ DESIGNER (FRONTEND) DOMAIN:
233
+ The codegen/setup/runtime tools above all wrap the backend CLI
234
+ ('restforge', the @restforgejs/platform package). A separate family of
235
+ tools — the 'designer_*' tools — wraps a DIFFERENT command-line product,
236
+ 'restforge-designer' (the RESTForge Designer frontend generator). Keep
237
+ the two straight: backend payload/schema/API work goes through the
238
+ 'restforge' tools; frontend application work goes through the
239
+ 'designer_*' tools.
240
+
241
+ Prefer the 'designer_*' tools when the user wants to:
242
+ - Generate, validate, or preview a FRONTEND application (not a backend
243
+ API) from a UI Definition File (UDF) payload
244
+ - Work with a frontend/designer PLUGIN (list, inspect, scaffold) — plugin
245
+ ids look like 'vanilla-js-basic', 'vanilla-js-auth', 'vanilla-js-custom'
246
+ - Initialise a new frontend project from a designer plugin
247
+ - Phrases like "generate frontend", "build the UI from this payload",
248
+ "generate aplikasi frontend", "preview file frontend", "buat project
249
+ frontend dari plugin", "validate UDF", or any mention of
250
+ "restforge-designer", "designer", "rfd", or "frontend generation"
251
+
252
+ Detection signals that this is RESTForge Designer (frontend) work:
253
+ - The 'restforge-designer' binary (alias 'rfd') is installed and on PATH
254
+ - The user mentions UDF (UI Definition File), frontend generation, or a
255
+ designer plugin ('vanilla-js-*')
256
+ - A frontend project folder with a UDF payload (payload/NN-<name>.json
257
+ in the frontend project) is in play
258
+
259
+ Boundaries for the designer domain:
260
+ - The 'designer_*' tools wrap the 'restforge-designer' binary, which is a
261
+ product SEPARATE from the backend 'restforge' CLI. They are not
262
+ interchangeable; do not route a backend RDF/SDF request to a
263
+ 'designer_*' tool, or a UDF/frontend request to a 'codegen_*' tool.
264
+ - Designer LICENSE management and activation/deactivation are NOT
265
+ available through this MCP server (consistent with the backend, which
266
+ also does not manage per-machine license here). When a license-gated
267
+ designer operation (init, generate) fails because the license is not
268
+ active, relay that and tell the user to activate their RESTForge
269
+ Designer license through the Designer desktop application or its own
270
+ CLI — this server cannot activate it.
271
+ - If the 'restforge-designer' binary is not installed or not on PATH, the
272
+ designer tools return a non-error precondition; relay it as a setup
273
+ step (install RESTForge Designer), not a failure.
230
274
  `.trim();
231
275
  export async function startServer() {
232
276
  const server = new McpServer({
@@ -239,6 +283,7 @@ export async function startServer() {
239
283
  registerSetupTools(server);
240
284
  registerCodegenTools(server);
241
285
  registerRuntimeTools(server);
286
+ registerDesignerTools(server);
242
287
  const transport = new StdioServerTransport();
243
288
  await server.connect(transport);
244
289
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,WAAW,GAAG,eAAe,CAAC;AAEpC,iFAAiF;AACjF,mFAAmF;AACnF,6EAA6E;AAC7E,mFAAmF;AACnF,gFAAgF;AAChF,kFAAkF;AAClF,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,EAAE,OAAO,EAA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,CAAC;AAClC,CAAC"}
@@ -37,56 +37,56 @@ function extractWarningsAndSummary(stdout) {
37
37
  export function registerCodegenDbschemaApply(server) {
38
38
  server.registerTool('codegen_dbschema_apply', {
39
39
  title: 'Apply Schema Drift Incrementally via ALTER',
40
- description: `Resolve schema drift from dbschema-kit SDF files to the live database via incremental ALTER TABLE statements, by wrapping restforge schema apply. This is the incremental complement of 'codegen_dbschema_diff' (which only detects drift) and the SAFE alternative to 'codegen_dbschema_migrate' with drop=true (which destroys and recreates tables). By default the apply is ADDITIVE-ONLY: ADD COLUMN, CREATE INDEX, ADD UNIQUE, and ADD FOREIGN KEY are emitted; every destructive change is skipped with a warning unless explicitly opted in (allowDrop for DROP COLUMN/INDEX/UNIQUE/FOREIGN KEY, allowModify for ALTER COLUMN length/nullable and FOREIGN KEY action changes).
41
-
42
- RECOMMENDED WORKFLOW:
43
- 1. Run 'codegen_dbschema_diff' first to see the drift.
44
- 2. Run this tool with dryRun=true to preview the exact ALTER statements.
45
- 3. Show the preview to the user and ask for confirmation.
46
- 4. Only then run with dryRun=false to apply. Pass allowDrop/allowModify ONLY when the user explicitly asked for that destructive change — never to "make a warning go away".
47
-
48
- EXIT CODE SEMANTICS (important):
49
- - Exit 0 = success: every applicable drift was applied (or previewed in dry-run, or there was no drift). The output may still contain warnings for operations the platform defers (see below) — relay those.
50
- - Exit 1 = some drift was SKIPPED because it requires allowDrop or allowModify. This is a NORMAL, meaningful result — NOT a failure. In a real apply the additive statements WERE applied; only the skipped items remain. NEVER retry automatically with allowDrop/allowModify: those options drop or mutate data and need explicit user confirmation first.
51
- - Exit 2 = system error (invalid config, SDF load failure, connection failure, or apply failure). ROLLBACK means the database is unchanged; PARTIAL means some statements were applied and the database needs manual inspection.
52
-
53
- USE WHEN:
54
- - 'codegen_dbschema_diff' reported drift and the user wants to bring the database in sync incrementally
55
- - The user asks "apply the drift", "sinkronkan database dengan schema", "tambahkan kolom yang kurang ke database", "apply perubahan schema tanpa drop"
56
- - Evolving an existing populated database without recreating tables (data preserved)
57
- - The user wants a preview of the ALTER statements first — pass dryRun=true (safe path)
58
-
59
- DO NOT USE FOR:
60
- - Detecting drift without changing anything -> use 'codegen_dbschema_diff' (read-only)
61
- - Full CREATE/DROP deployment of a schema or initial setup of an empty database -> use 'codegen_dbschema_migrate'
62
- - Retrofitting the soft-delete consistency CHECK -> not supported here (detection-only); goes through 'codegen_dbschema_migrate' with drop (destructive) or manual SQL
63
- - Type changes, PK changes, default value changes, CHECK constraint changes -> not supported by the platform yet (always skipped); suggest a manual SQL migration
64
- - Validating SDF file correctness -> use 'codegen_dbschema_validate'
65
- - Reverse-engineering SDF files from the database -> use 'codegen_dbschema_introspect'
66
-
67
- This tool runs: npx restforge schema apply --path=<path> --config=<config> [--table=<name>] [--dry-run] [--allow-drop] [--allow-modify] in the given cwd. The output is a structured human-readable report (DDL preview or per-statement progress, Warnings, Summary) — there is no JSON mode.
68
-
69
- OPERATIONS NOT SUPPORTED by the platform yet (always skipped with a 'deferred' warning, regardless of opt-in flags):
70
- - ALTER COLUMN type change (needs a data conversion strategy per dialect)
71
- - ALTER COLUMN precision/scale change
72
- - DEFAULT value change
73
- - PRIMARY KEY changes (need a table rebuild)
74
- - CHECK constraint add/drop
75
- On SQLite, MODIFY/DROP COLUMN and ALL foreign key changes are additionally skipped ('sqlite limitation') even with opt-in flags; the sqlite dialect is rejected entirely by the default introspector.
76
-
77
- Soft-delete note: drift in the soft-delete consistency CHECK is detection-only. It is reported as a warning (never auto-applied) and does NOT by itself cause exit 1; the warning text suggests retrofitting via 'schema migrate --drop' (recreate) or adding the CHECK manually.
78
-
79
- Preconditions:
80
- - The project must have @restforgejs/platform installed in node_modules.
81
- - The config file (default 'db-connection.env') must exist and contain valid database credentials.
82
- - SDF files must exist at the given path. The --path flag is required by the CLI.
83
-
84
- PRESENTATION GUIDANCE:
85
- - Match the user's language. If the user writes in Indonesian, respond in Indonesian.
86
- - Never mention internal tool names in the reply to the user. Describe actions by what they do (e.g. "apply the missing columns", "preview the ALTER statements").
87
- - Exit 1 is NOT an error. Present it as: "these changes were applied/previewed, these were skipped because they would drop or modify existing data". Then ask the user whether they want the destructive part — do not decide for them.
88
- - This tool MUTATES the live database when dryRun=false. Prefer dryRun=true on the first call and confirm with the user before the real apply.
89
- - Speak in plain language. Summarise the applied/skipped items; do not paste raw CLI output unless the user explicitly asks.
40
+ description: `Resolve schema drift from dbschema-kit SDF files to the live database via incremental ALTER TABLE statements, by wrapping restforge schema apply. This is the incremental complement of 'codegen_dbschema_diff' (which only detects drift) and the SAFE alternative to 'codegen_dbschema_migrate' with drop=true (which destroys and recreates tables). By default the apply is ADDITIVE-ONLY: ADD COLUMN, CREATE INDEX, ADD UNIQUE, and ADD FOREIGN KEY are emitted; every destructive change is skipped with a warning unless explicitly opted in (allowDrop for DROP COLUMN/INDEX/UNIQUE/FOREIGN KEY, allowModify for ALTER COLUMN length/nullable and FOREIGN KEY action changes).
41
+
42
+ RECOMMENDED WORKFLOW:
43
+ 1. Run 'codegen_dbschema_diff' first to see the drift.
44
+ 2. Run this tool with dryRun=true to preview the exact ALTER statements.
45
+ 3. Show the preview to the user and ask for confirmation.
46
+ 4. Only then run with dryRun=false to apply. Pass allowDrop/allowModify ONLY when the user explicitly asked for that destructive change — never to "make a warning go away".
47
+
48
+ EXIT CODE SEMANTICS (important):
49
+ - Exit 0 = success: every applicable drift was applied (or previewed in dry-run, or there was no drift). The output may still contain warnings for operations the platform defers (see below) — relay those.
50
+ - Exit 1 = some drift was SKIPPED because it requires allowDrop or allowModify. This is a NORMAL, meaningful result — NOT a failure. In a real apply the additive statements WERE applied; only the skipped items remain. NEVER retry automatically with allowDrop/allowModify: those options drop or mutate data and need explicit user confirmation first.
51
+ - Exit 2 = system error (invalid config, SDF load failure, connection failure, or apply failure). ROLLBACK means the database is unchanged; PARTIAL means some statements were applied and the database needs manual inspection.
52
+
53
+ USE WHEN:
54
+ - 'codegen_dbschema_diff' reported drift and the user wants to bring the database in sync incrementally
55
+ - The user asks "apply the drift", "sinkronkan database dengan schema", "tambahkan kolom yang kurang ke database", "apply perubahan schema tanpa drop"
56
+ - Evolving an existing populated database without recreating tables (data preserved)
57
+ - The user wants a preview of the ALTER statements first — pass dryRun=true (safe path)
58
+
59
+ DO NOT USE FOR:
60
+ - Detecting drift without changing anything -> use 'codegen_dbschema_diff' (read-only)
61
+ - Full CREATE/DROP deployment of a schema or initial setup of an empty database -> use 'codegen_dbschema_migrate'
62
+ - Retrofitting the soft-delete consistency CHECK -> not supported here (detection-only); goes through 'codegen_dbschema_migrate' with drop (destructive) or manual SQL
63
+ - Type changes, PK changes, default value changes, CHECK constraint changes -> not supported by the platform yet (always skipped); suggest a manual SQL migration
64
+ - Validating SDF file correctness -> use 'codegen_dbschema_validate'
65
+ - Reverse-engineering SDF files from the database -> use 'codegen_dbschema_introspect'
66
+
67
+ This tool runs: npx restforge schema apply --path=<path> --config=<config> [--table=<name>] [--dry-run] [--allow-drop] [--allow-modify] in the given cwd. The output is a structured human-readable report (DDL preview or per-statement progress, Warnings, Summary) — there is no JSON mode.
68
+
69
+ OPERATIONS NOT SUPPORTED by the platform yet (always skipped with a 'deferred' warning, regardless of opt-in flags):
70
+ - ALTER COLUMN type change (needs a data conversion strategy per dialect)
71
+ - ALTER COLUMN precision/scale change
72
+ - DEFAULT value change
73
+ - PRIMARY KEY changes (need a table rebuild)
74
+ - CHECK constraint add/drop
75
+ On SQLite, MODIFY/DROP COLUMN and ALL foreign key changes are additionally skipped ('sqlite limitation') even with opt-in flags; the sqlite dialect is rejected entirely by the default introspector.
76
+
77
+ Soft-delete note: drift in the soft-delete consistency CHECK is detection-only. It is reported as a warning (never auto-applied) and does NOT by itself cause exit 1; the warning text suggests retrofitting via 'schema migrate --drop' (recreate) or adding the CHECK manually.
78
+
79
+ Preconditions:
80
+ - The project must have @restforgejs/platform installed in node_modules.
81
+ - The config file (default 'db-connection.env') must exist and contain valid database credentials.
82
+ - SDF files must exist at the given path. The --path flag is required by the CLI.
83
+
84
+ PRESENTATION GUIDANCE:
85
+ - Match the user's language. If the user writes in Indonesian, respond in Indonesian.
86
+ - Never mention internal tool names in the reply to the user. Describe actions by what they do (e.g. "apply the missing columns", "preview the ALTER statements").
87
+ - Exit 1 is NOT an error. Present it as: "these changes were applied/previewed, these were skipped because they would drop or modify existing data". Then ask the user whether they want the destructive part — do not decide for them.
88
+ - This tool MUTATES the live database when dryRun=false. Prefer dryRun=true on the first call and confirm with the user before the real apply.
89
+ - Speak in plain language. Summarise the applied/skipped items; do not paste raw CLI output unless the user explicitly asks.
90
90
  - When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
91
91
  inputSchema: {
92
92
  cwd: z
@@ -136,18 +136,18 @@ PRESENTATION GUIDANCE:
136
136
  content: [
137
137
  {
138
138
  type: 'text',
139
- text: `Precondition not met: the RESTForge package is not installed in this project.
140
-
141
- Project path: ${projectCwd}
142
- Expected location: node_modules/@restforgejs/platform
143
- Requested config: ${config}
144
- Requested schema path: ${path}
145
- Requested table filter: ${table ?? 'all tables'}
146
- Requested dryRun: ${dryRun}
147
-
148
- For the assistant:
149
- - The user needs to install the RESTForge package before drift can be applied to the database.
150
- - Suggest installing the package first, then retry the apply.
139
+ text: `Precondition not met: the RESTForge package is not installed in this project.
140
+
141
+ Project path: ${projectCwd}
142
+ Expected location: node_modules/@restforgejs/platform
143
+ Requested config: ${config}
144
+ Requested schema path: ${path}
145
+ Requested table filter: ${table ?? 'all tables'}
146
+ Requested dryRun: ${dryRun}
147
+
148
+ For the assistant:
149
+ - The user needs to install the RESTForge package before drift can be applied to the database.
150
+ - Suggest installing the package first, then retry the apply.
151
151
  - When explaining to the user, say something like "the RESTForge package isn't installed yet — should I install it first?". Do not mention internal tool names.`,
152
152
  },
153
153
  ],
@@ -188,38 +188,38 @@ For the assistant:
188
188
  content: [
189
189
  {
190
190
  type: 'text',
191
- text: `Failed to apply schema drift to the database.
192
-
193
- Project path: ${projectCwd}
194
- Config: ${config}
195
- Schema path: ${path}
196
- Table filter: ${table ?? 'all tables'}
197
- Mode: ${dryRun ? 'dry-run' : 'apply'}
198
- Command: ${result.command}
199
- Exit code: ${result.exitCode}
200
-
201
- --- CLI output ---
202
- stdout:
203
- ${result.stdout}
204
-
205
- stderr:
206
- ${result.stderr}
207
- --- end CLI output ---
208
-
209
- For the assistant:
210
- - Tell the user that the apply could not complete. This is a system error, not a drift result.
211
- - Check the CLI output for ROLLBACK or PARTIAL status first:
212
- * ROLLBACK applied — the database state is UNCHANGED; the failed statement is reported. Safe to fix the cause and retry.
213
- * Partial apply detected — SOME statements were applied before the failure and were NOT reverted. The user must inspect the database state manually before any retry.
214
- - Other common causes, in plain language:
215
- * Config file not found or invalid — suggest verifying the config path and its content.
216
- * Database connection failed — suggest verifying credentials, host, and port.
217
- * Schema path not found or no models in it — suggest verifying the folder or file name passed via --path.
218
- * SDF load error — a schema file has invalid syntax or violates the defineModel contract. Suggest running the validate action first.
219
- * Table filter not found in SDF — the --table value does not match any model.
220
- * Unsupported dialect — schema apply does not support sqlite. Suggest checking DB_TYPE in the config.
221
- * Unknown command 'schema apply' — the installed RESTForge version may be older than this CLI subcommand; suggest upgrading the package.
222
- - Do not paste the raw stdout/stderr unless the user explicitly asks. Do not mention internal tool names.
191
+ text: `Failed to apply schema drift to the database.
192
+
193
+ Project path: ${projectCwd}
194
+ Config: ${config}
195
+ Schema path: ${path}
196
+ Table filter: ${table ?? 'all tables'}
197
+ Mode: ${dryRun ? 'dry-run' : 'apply'}
198
+ Command: ${result.command}
199
+ Exit code: ${result.exitCode}
200
+
201
+ --- CLI output ---
202
+ stdout:
203
+ ${result.stdout}
204
+
205
+ stderr:
206
+ ${result.stderr}
207
+ --- end CLI output ---
208
+
209
+ For the assistant:
210
+ - Tell the user that the apply could not complete. This is a system error, not a drift result.
211
+ - Check the CLI output for ROLLBACK or PARTIAL status first:
212
+ * ROLLBACK applied — the database state is UNCHANGED; the failed statement is reported. Safe to fix the cause and retry.
213
+ * Partial apply detected — SOME statements were applied before the failure and were NOT reverted. The user must inspect the database state manually before any retry.
214
+ - Other common causes, in plain language:
215
+ * Config file not found or invalid — suggest verifying the config path and its content.
216
+ * Database connection failed — suggest verifying credentials, host, and port.
217
+ * Schema path not found or no models in it — suggest verifying the folder or file name passed via --path.
218
+ * SDF load error — a schema file has invalid syntax or violates the defineModel contract. Suggest running the validate action first.
219
+ * Table filter not found in SDF — the --table value does not match any model.
220
+ * Unsupported dialect — schema apply does not support sqlite. Suggest checking DB_TYPE in the config.
221
+ * Unknown command 'schema apply' — the installed RESTForge version may be older than this CLI subcommand; suggest upgrading the package.
222
+ - Do not paste the raw stdout/stderr unless the user explicitly asks. Do not mention internal tool names.
223
223
  - Offer to retry once the underlying issue is resolved (after manual inspection in the PARTIAL case).`,
224
224
  },
225
225
  ],
@@ -234,28 +234,28 @@ For the assistant:
234
234
  content: [
235
235
  {
236
236
  type: 'text',
237
- text: `Schema apply ${dryRun ? 'dry-run ' : ''}completed with skipped drift: some changes require explicit opt-in (this is a result, not an error).
238
-
239
- Project path: ${projectCwd}
240
- Config: ${config}
241
- Schema path: ${path}
242
- Table filter: ${table ?? 'all tables'}
243
- Mode: ${dryRun ? 'dry-run (nothing applied)' : 'apply (additive statements WERE applied)'}
244
-
245
- --- Warnings and Summary (from the CLI) ---
246
- ${excerpt}
247
- --- end Warnings and Summary ---
248
-
249
- --- Full CLI output ---
250
- ${result.stdout}
251
- --- end Full CLI output ---
252
-
253
- For the assistant:
254
- - Present this as a two-part factual result: (1) what was ${dryRun ? 'previewed' : 'applied'} — see the ${dryRun ? 'DDL preview' : 'progress lines'} in the full output; (2) what was SKIPPED — the Warnings above list each skipped item with its reason ('requires --allow-drop' or 'requires --allow-modify').
255
- - ${dryRun ? 'This was a preview only. Nothing was applied to the database.' : 'The additive statements were applied to the live database; only the skipped items remain outstanding.'}
256
- - Do NOT retry with allowDrop/allowModify on your own. Those options drop columns/constraints or alter existing columns — explain to the user what would be dropped or modified, and only proceed after the user explicitly confirms.
257
- - Warnings with reason 'deferred', 'detection-only', or 'sqlite limitation' cannot be resolved by opt-in flags at all — those need a manual migration or a full recreate; say so plainly.
258
- - Do not paste the full CLI output unless the user asks; the Warnings/Summary excerpt is usually enough.
237
+ text: `Schema apply ${dryRun ? 'dry-run ' : ''}completed with skipped drift: some changes require explicit opt-in (this is a result, not an error).
238
+
239
+ Project path: ${projectCwd}
240
+ Config: ${config}
241
+ Schema path: ${path}
242
+ Table filter: ${table ?? 'all tables'}
243
+ Mode: ${dryRun ? 'dry-run (nothing applied)' : 'apply (additive statements WERE applied)'}
244
+
245
+ --- Warnings and Summary (from the CLI) ---
246
+ ${excerpt}
247
+ --- end Warnings and Summary ---
248
+
249
+ --- Full CLI output ---
250
+ ${result.stdout}
251
+ --- end Full CLI output ---
252
+
253
+ For the assistant:
254
+ - Present this as a two-part factual result: (1) what was ${dryRun ? 'previewed' : 'applied'} — see the ${dryRun ? 'DDL preview' : 'progress lines'} in the full output; (2) what was SKIPPED — the Warnings above list each skipped item with its reason ('requires --allow-drop' or 'requires --allow-modify').
255
+ - ${dryRun ? 'This was a preview only. Nothing was applied to the database.' : 'The additive statements were applied to the live database; only the skipped items remain outstanding.'}
256
+ - Do NOT retry with allowDrop/allowModify on your own. Those options drop columns/constraints or alter existing columns — explain to the user what would be dropped or modified, and only proceed after the user explicitly confirms.
257
+ - Warnings with reason 'deferred', 'detection-only', or 'sqlite limitation' cannot be resolved by opt-in flags at all — those need a manual migration or a full recreate; say so plainly.
258
+ - Do not paste the full CLI output unless the user asks; the Warnings/Summary excerpt is usually enough.
259
259
  - Match the user's language.`,
260
260
  },
261
261
  ],
@@ -268,23 +268,23 @@ For the assistant:
268
268
  content: [
269
269
  {
270
270
  type: 'text',
271
- text: `Schema apply dry-run completed (no changes applied).
272
-
273
- Project path: ${projectCwd}
274
- Config: ${config}
275
- Schema path: ${path}
276
- Table filter: ${table ?? 'all tables'}
277
- Mode: dry-run
278
-
279
- --- DDL preview ---
280
- ${result.stdout}
281
- --- end DDL preview ---
282
-
283
- For the assistant:
284
- - Confirm to the user that this was a preview only. No ALTER statement was applied to the database.
285
- - The statements shown above are exactly what would run if the same action is repeated without dry-run. "No applicable ALTER statements." means schema and database are already in sync for the applicable operations.
286
- - If a Warnings block is present, relay it: warnings with reason 'deferred', 'detection-only', or 'sqlite limitation' are operations the platform cannot apply incrementally yet (they do not block the rest).
287
- - Encourage the user to review the preview, then confirm before running the real apply.
271
+ text: `Schema apply dry-run completed (no changes applied).
272
+
273
+ Project path: ${projectCwd}
274
+ Config: ${config}
275
+ Schema path: ${path}
276
+ Table filter: ${table ?? 'all tables'}
277
+ Mode: dry-run
278
+
279
+ --- DDL preview ---
280
+ ${result.stdout}
281
+ --- end DDL preview ---
282
+
283
+ For the assistant:
284
+ - Confirm to the user that this was a preview only. No ALTER statement was applied to the database.
285
+ - The statements shown above are exactly what would run if the same action is repeated without dry-run. "No applicable ALTER statements." means schema and database are already in sync for the applicable operations.
286
+ - If a Warnings block is present, relay it: warnings with reason 'deferred', 'detection-only', or 'sqlite limitation' are operations the platform cannot apply incrementally yet (they do not block the rest).
287
+ - Encourage the user to review the preview, then confirm before running the real apply.
288
288
  - Match the user's language.`,
289
289
  },
290
290
  ],
@@ -295,26 +295,26 @@ For the assistant:
295
295
  content: [
296
296
  {
297
297
  type: 'text',
298
- text: `Schema apply completed successfully: all applicable drift was applied.
299
-
300
- Project path: ${projectCwd}
301
- Config: ${config}
302
- Schema path: ${path}
303
- Table filter: ${table ?? 'all tables'}
304
- Mode: apply
305
- allowDrop: ${allowDrop}
306
- allowModify: ${allowModify}
307
-
308
- --- CLI output ---
309
- ${result.stdout}
310
- --- end CLI output ---
311
-
312
- For the assistant:
313
- - Confirm to the user that the incremental changes were applied to the live database. "No drift to apply." means schema and database were already in sync.
314
- - Read the Summary in the CLI output and mention the number of statements applied in plain language.
315
- - If skipped warnings are present (reason 'deferred', 'detection-only', or 'sqlite limitation'), relay them: those operations cannot be applied incrementally yet and need a manual migration or a full recreate. They did not block this apply.
316
- - Suggest verifying the result with a drift check (read-only) if the user wants confirmation that everything is now in sync.
317
- - Do not paste the raw CLI output unless the user explicitly asks.
298
+ text: `Schema apply completed successfully: all applicable drift was applied.
299
+
300
+ Project path: ${projectCwd}
301
+ Config: ${config}
302
+ Schema path: ${path}
303
+ Table filter: ${table ?? 'all tables'}
304
+ Mode: apply
305
+ allowDrop: ${allowDrop}
306
+ allowModify: ${allowModify}
307
+
308
+ --- CLI output ---
309
+ ${result.stdout}
310
+ --- end CLI output ---
311
+
312
+ For the assistant:
313
+ - Confirm to the user that the incremental changes were applied to the live database. "No drift to apply." means schema and database were already in sync.
314
+ - Read the Summary in the CLI output and mention the number of statements applied in plain language.
315
+ - If skipped warnings are present (reason 'deferred', 'detection-only', or 'sqlite limitation'), relay them: those operations cannot be applied incrementally yet and need a manual migration or a full recreate. They did not block this apply.
316
+ - Suggest verifying the result with a drift check (read-only) if the user wants confirmation that everything is now in sync.
317
+ - Do not paste the raw CLI output unless the user explicitly asks.
318
318
  - Match the user's language.`,
319
319
  },
320
320
  ],