@restforgejs/mcp-server 1.2.0 → 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.
- package/README.md +51 -8
- package/dist/server.js +71 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/codegen/dbschema-apply.d.ts +2 -0
- package/dist/tools/codegen/dbschema-apply.js +324 -0
- package/dist/tools/codegen/dbschema-apply.js.map +1 -0
- package/dist/tools/codegen/dbschema-diff.d.ts +2 -0
- package/dist/tools/codegen/dbschema-diff.js +352 -0
- package/dist/tools/codegen/dbschema-diff.js.map +1 -0
- package/dist/tools/codegen/dbschema-generate-ddl.js +6 -3
- package/dist/tools/codegen/dbschema-generate-ddl.js.map +1 -1
- package/dist/tools/codegen/dbschema-init.js +9 -2
- package/dist/tools/codegen/dbschema-init.js.map +1 -1
- package/dist/tools/codegen/dbschema-introspect.js +25 -19
- package/dist/tools/codegen/dbschema-introspect.js.map +1 -1
- package/dist/tools/codegen/dbschema-migrate.js +55 -26
- package/dist/tools/codegen/dbschema-migrate.js.map +1 -1
- package/dist/tools/codegen/dbschema-models.js +11 -12
- package/dist/tools/codegen/dbschema-models.js.map +1 -1
- package/dist/tools/codegen/dbschema-template.d.ts +2 -0
- package/dist/tools/codegen/dbschema-template.js +384 -0
- package/dist/tools/codegen/dbschema-template.js.map +1 -0
- package/dist/tools/codegen/dbschema-validate.js +13 -13
- package/dist/tools/codegen/dbschema-validate.js.map +1 -1
- package/dist/tools/codegen/generate-payload.js +1 -1
- package/dist/tools/codegen/get-dbschema-catalog.js +4 -2
- package/dist/tools/codegen/get-dbschema-catalog.js.map +1 -1
- package/dist/tools/codegen/index.js +6 -0
- package/dist/tools/codegen/index.js.map +1 -1
- package/dist/tools/codegen/list-tables.js +4 -1
- package/dist/tools/codegen/list-tables.js.map +1 -1
- package/dist/tools/designer/generate.d.ts +2 -0
- package/dist/tools/designer/generate.js +212 -0
- package/dist/tools/designer/generate.js.map +1 -0
- package/dist/tools/designer/index.d.ts +2 -0
- package/dist/tools/designer/index.js +17 -0
- package/dist/tools/designer/index.js.map +1 -0
- package/dist/tools/designer/init-project.d.ts +2 -0
- package/dist/tools/designer/init-project.js +235 -0
- package/dist/tools/designer/init-project.js.map +1 -0
- package/dist/tools/designer/inspect-plugin.d.ts +2 -0
- package/dist/tools/designer/inspect-plugin.js +148 -0
- package/dist/tools/designer/inspect-plugin.js.map +1 -0
- package/dist/tools/designer/list-plugins.d.ts +2 -0
- package/dist/tools/designer/list-plugins.js +141 -0
- package/dist/tools/designer/list-plugins.js.map +1 -0
- package/dist/tools/designer/preview-files.d.ts +2 -0
- package/dist/tools/designer/preview-files.js +150 -0
- package/dist/tools/designer/preview-files.js.map +1 -0
- package/dist/tools/designer/scaffold-plugin.d.ts +2 -0
- package/dist/tools/designer/scaffold-plugin.js +162 -0
- package/dist/tools/designer/scaffold-plugin.js.map +1 -0
- package/dist/tools/designer/validate-payload.d.ts +2 -0
- package/dist/tools/designer/validate-payload.js +158 -0
- package/dist/tools/designer/validate-payload.js.map +1 -0
- package/package.json +2 -2
|
@@ -25,13 +25,14 @@ DO NOT USE FOR:
|
|
|
25
25
|
- Incremental ALTER migration — this tool does full apply only. For incremental migrations, suggest a manual SQL migration script.
|
|
26
26
|
- Production database without explicit user authorisation — DESTRUCTIVE; never proceed without confirmation.
|
|
27
27
|
|
|
28
|
-
This tool runs: npx restforge schema migrate
|
|
29
|
-
The CLI auto-detects the dialect from the config file (DB_TYPE=postgresql|mysql|oracle|sqlite).
|
|
28
|
+
This tool runs: npx restforge schema migrate --path=<path> --config=<file> [--drop=<bool>] [--dry-run] [--max-name-length=<N>] [--auto-create-db] in the given cwd.
|
|
29
|
+
The CLI auto-detects the dialect from the config file (DB_TYPE=postgresql|mysql|oracle|sqlite). The CLI exits 0 on success for BOTH a real apply and a dry-run preview (the legacy exit code 2 for dry-run has been removed); any non-zero exit is an error. This tool distinguishes a dry-run preview from a real apply by the dryRun parameter, not by the exit code.
|
|
30
|
+
Tables declared with softDelete enabled emit the same soft-delete DDL as generate-ddl: a consistency CHECK named chk_<table>_soft_delete_consistency and PostgreSQL partial indexes (WHERE is_deleted = FALSE) for non-unique indexes. Soft-delete is PostgreSQL-only in Phase 1 — migrating such a schema against any other dialect fails with a clear error.
|
|
30
31
|
|
|
31
32
|
Preconditions:
|
|
32
33
|
- The project must have @restforgejs/platform installed in node_modules.
|
|
33
34
|
- The config file (default 'db-connection.env') must exist and contain valid database credentials.
|
|
34
|
-
- Schema files must exist at the given path
|
|
35
|
+
- Schema files must exist at the given path and pass validation. The --path flag is required by the CLI.
|
|
35
36
|
|
|
36
37
|
PRESENTATION GUIDANCE:
|
|
37
38
|
- Match the user's language. If the user writes in Indonesian, respond in Indonesian.
|
|
@@ -41,6 +42,7 @@ PRESENTATION GUIDANCE:
|
|
|
41
42
|
- When the user uses drop=true, ALL DATA in the affected tables is destroyed. Confirm explicitly that the user understands this — quote the tables that will be dropped if known.
|
|
42
43
|
- Production database operations should be opt-in. If the config points to production (verify by reading DB_HOST or similar), strongly suggest dry-run + manual review first.
|
|
43
44
|
- There is no rollback on failure mid-migration — DDL changes that already executed are NOT automatically reverted. Plan for forward-fix only.
|
|
45
|
+
- The user must specify --path (e.g. './schema'). The CLI no longer accepts a positional argument or default. If the user does not mention a path, confirm it before invoking.
|
|
44
46
|
- When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
|
|
45
47
|
inputSchema: {
|
|
46
48
|
cwd: z
|
|
@@ -55,8 +57,7 @@ PRESENTATION GUIDANCE:
|
|
|
55
57
|
path: z
|
|
56
58
|
.string()
|
|
57
59
|
.min(1)
|
|
58
|
-
.
|
|
59
|
-
.describe('Path to schema file or folder relative to cwd. When omitted, the CLI uses its default (./schema).'),
|
|
60
|
+
.describe('Path to schema file or folder relative to cwd (e.g. "./schema"). Required by the CLI.'),
|
|
60
61
|
drop: z
|
|
61
62
|
.boolean()
|
|
62
63
|
.optional()
|
|
@@ -65,13 +66,21 @@ PRESENTATION GUIDANCE:
|
|
|
65
66
|
.boolean()
|
|
66
67
|
.optional()
|
|
67
68
|
.describe('Default false. When true, generate DDL and preview it without applying. Safe path: prefer this on the first call.'),
|
|
69
|
+
maxNameLength: z
|
|
70
|
+
.number()
|
|
71
|
+
.optional()
|
|
72
|
+
.describe('Optional override for the maximum database identifier length, mapped to --max-name-length=<N>. Sent only when supplied. The CLI already applies the correct default per dialect (postgres 63, mysql 64, oracle 128, sqlite 63), so this is rarely needed — leave it unset unless a specific identifier-length conflict requires a smaller bound.'),
|
|
73
|
+
autoCreateDb: z
|
|
74
|
+
.boolean()
|
|
75
|
+
.optional()
|
|
76
|
+
.describe('Default false. PostgreSQL/MySQL only; mapped to the bare flag --auto-create-db, sent only when true. When the target database does not yet exist, the CLI creates it and then STOPS with exit 0 and a re-run instruction — it does NOT continue to apply the tables in the same call. After an auto-create, the migrate action must be invoked a second time to apply the schema. Read the CLI output to tell "database created, please re-run" apart from "tables applied".'),
|
|
68
77
|
},
|
|
69
78
|
annotations: {
|
|
70
79
|
title: 'Migrate dbschema-kit Files to Database',
|
|
71
80
|
destructiveHint: true, // mutates live DB; with drop=true also destroys data
|
|
72
81
|
idempotentHint: false, // re-running on a fresh DB will fail (tables already exist) unless drop=true
|
|
73
82
|
},
|
|
74
|
-
}, async ({ cwd, config, path, drop, dryRun }) => {
|
|
83
|
+
}, async ({ cwd, config, path, drop, dryRun, maxNameLength, autoCreateDb }) => {
|
|
75
84
|
const projectCwd = resolve(cwd);
|
|
76
85
|
// Precondition check: @restforgejs/platform must be present in node_modules. per §3.4
|
|
77
86
|
try {
|
|
@@ -87,7 +96,7 @@ PRESENTATION GUIDANCE:
|
|
|
87
96
|
Project path: ${projectCwd}
|
|
88
97
|
Expected location: node_modules/@restforgejs/platform
|
|
89
98
|
Requested config: ${config}
|
|
90
|
-
Requested schema path: ${path
|
|
99
|
+
Requested schema path: ${path}
|
|
91
100
|
Requested drop: ${drop ?? false}
|
|
92
101
|
Requested dryRun: ${dryRun ?? false}
|
|
93
102
|
|
|
@@ -100,27 +109,35 @@ For the assistant:
|
|
|
100
109
|
isError: false, // per §3.4
|
|
101
110
|
};
|
|
102
111
|
}
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
const cliArgs = [
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
// CLI v4+ requires --path as a flag (no positional, no default). Other
|
|
113
|
+
// optional flags are only forwarded when the user supplied them. per §3.5
|
|
114
|
+
const cliArgs = [
|
|
115
|
+
'restforge',
|
|
116
|
+
'schema',
|
|
117
|
+
'migrate',
|
|
118
|
+
`--path=${path}`,
|
|
119
|
+
`--config=${config}`,
|
|
120
|
+
];
|
|
109
121
|
if (drop !== undefined)
|
|
110
122
|
cliArgs.push(`--drop=${drop}`);
|
|
111
123
|
if (dryRun === true)
|
|
112
124
|
cliArgs.push('--dry-run');
|
|
125
|
+
if (maxNameLength !== undefined)
|
|
126
|
+
cliArgs.push(`--max-name-length=${maxNameLength}`);
|
|
127
|
+
if (autoCreateDb === true)
|
|
128
|
+
cliArgs.push('--auto-create-db');
|
|
113
129
|
const result = await execProcess('npx', cliArgs, {
|
|
114
130
|
cwd: projectCwd,
|
|
115
131
|
timeout: 120_000, // schema apply on a populated DB can be slow
|
|
116
132
|
env: { NODE_ENV: 'production' },
|
|
117
133
|
stripFinalNewline: true,
|
|
118
134
|
});
|
|
119
|
-
// The CLI
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
//
|
|
123
|
-
|
|
135
|
+
// The CLI now exits 0 for a successful dry-run as well as a real apply (the
|
|
136
|
+
// legacy exit code 2 dry-run sentinel was removed in platform v5.1.17). The
|
|
137
|
+
// dry-run vs apply distinction is therefore driven by the dryRun parameter,
|
|
138
|
+
// not by the exit code. per D-06.2
|
|
139
|
+
// Branch C: real CLI failure (any non-zero exit). per §3.4
|
|
140
|
+
if (!result.success) {
|
|
124
141
|
return {
|
|
125
142
|
content: [
|
|
126
143
|
{
|
|
@@ -129,7 +146,7 @@ For the assistant:
|
|
|
129
146
|
|
|
130
147
|
Project path: ${projectCwd}
|
|
131
148
|
Config: ${config}
|
|
132
|
-
Schema path: ${path
|
|
149
|
+
Schema path: ${path}
|
|
133
150
|
Drop: ${drop ?? false}
|
|
134
151
|
DryRun: ${dryRun ?? false}
|
|
135
152
|
Command: ${result.command}
|
|
@@ -149,7 +166,8 @@ For the assistant:
|
|
|
149
166
|
* Config file not found — suggest verifying the config path and that the file exists.
|
|
150
167
|
* Database connection failed — suggest verifying credentials, host, and port.
|
|
151
168
|
* Schema validation error — a schema file has invalid syntax or a broken FK reference. Suggest running the validate action first to surface the specific issue.
|
|
152
|
-
* Schema folder not found — the CLI cannot locate the path. Suggest verifying the folder name
|
|
169
|
+
* Schema folder not found — the CLI cannot locate the path. Suggest verifying the folder name passed via --path.
|
|
170
|
+
* Missing required flag --path — the CLI now requires this flag explicitly. Confirm the path with the user.
|
|
153
171
|
* Apply error mid-transaction — DDL changes that already executed before the failure are NOT automatically reverted. The user must inspect the DB state manually and plan a forward-fix.
|
|
154
172
|
* Tables already exist (without drop=true) — the CLI does full apply only. Suggest dry-run + manual review of the existing schema, or pass drop=true with explicit user confirmation.
|
|
155
173
|
* Unknown command 'schema migrate' — the installed RESTForge version may be older than this CLI subcommand; suggest upgrading the package.
|
|
@@ -160,8 +178,9 @@ For the assistant:
|
|
|
160
178
|
isError: true, // per §3.4
|
|
161
179
|
};
|
|
162
180
|
}
|
|
163
|
-
if (
|
|
164
|
-
// Branch B (dry-run): preview only, no DDL applied.
|
|
181
|
+
if (dryRun === true) {
|
|
182
|
+
// Branch B (dry-run): preview only, no DDL applied. Reached on exit 0 with
|
|
183
|
+
// dryRun=true (the CLI printed the DDL preview and exited cleanly). per §3.5
|
|
165
184
|
return {
|
|
166
185
|
content: [
|
|
167
186
|
{
|
|
@@ -170,7 +189,7 @@ For the assistant:
|
|
|
170
189
|
|
|
171
190
|
Project path: ${projectCwd}
|
|
172
191
|
Config: ${config}
|
|
173
|
-
Schema path: ${path
|
|
192
|
+
Schema path: ${path}
|
|
174
193
|
Mode: dry-run
|
|
175
194
|
|
|
176
195
|
--- DDL preview ---
|
|
@@ -186,7 +205,16 @@ For the assistant:
|
|
|
186
205
|
],
|
|
187
206
|
};
|
|
188
207
|
}
|
|
189
|
-
//
|
|
208
|
+
// When autoCreateDb is enabled, the CLI may CREATE THE DATABASE ONLY and then
|
|
209
|
+
// stop (exit 0) with a re-run instruction instead of applying tables — see
|
|
210
|
+
// platform migrate.js (handleMissingDatabase: created -> return). That output
|
|
211
|
+
// lands in this success branch, so the guidance must steer the assistant to
|
|
212
|
+
// read stdout rather than assume the tables were applied. per §3.5
|
|
213
|
+
const autoCreateNote = autoCreateDb === true
|
|
214
|
+
? `
|
|
215
|
+
- CAUTION — auto-create-db was enabled. If the target database did not exist, the CLI may have CREATED ONLY THE DATABASE and then STOPPED with a re-run instruction, WITHOUT applying any tables. Read the CLI output above carefully: if it contains a re-run instruction (for example "database created ... re-run the command"), do NOT claim the tables were created. Instead tell the user the database was provisioned and the migrate action must be run a second time to apply the schema.`
|
|
216
|
+
: '';
|
|
217
|
+
// Branch B (apply): real apply succeeded (exit 0 with dryRun not requested). per §3.5
|
|
190
218
|
return {
|
|
191
219
|
content: [
|
|
192
220
|
{
|
|
@@ -195,16 +223,17 @@ For the assistant:
|
|
|
195
223
|
|
|
196
224
|
Project path: ${projectCwd}
|
|
197
225
|
Config: ${config}
|
|
198
|
-
Schema path: ${path
|
|
226
|
+
Schema path: ${path}
|
|
199
227
|
Mode: apply
|
|
200
228
|
Drop tables before recreate: ${drop ?? false}
|
|
229
|
+
Auto-create database: ${autoCreateDb ?? false}
|
|
201
230
|
|
|
202
231
|
--- CLI output ---
|
|
203
232
|
${result.stdout}
|
|
204
233
|
--- end CLI output ---
|
|
205
234
|
|
|
206
235
|
For the assistant:
|
|
207
|
-
- Confirm to the user that the migration was applied. Read the CLI output above and mention the database type and the count of tables/indexes/foreign keys created (when present)
|
|
236
|
+
- Confirm to the user that the migration was applied. Read the CLI output above and mention the database type and the count of tables/indexes/foreign keys created (when present).${autoCreateNote}
|
|
208
237
|
- This is a DESTRUCTIVE operation: tables, indexes, and foreign keys were created in the live database. With drop=true, existing tables and their data were also removed before recreation.
|
|
209
238
|
- The user should verify the database state matches expectation. Suggest listing tables (read-only) for confirmation.
|
|
210
239
|
- For follow-up changes, the user authors updated schema files and reruns the migrate action. Caution: there is no incremental ALTER migration in this version — full apply only. Schema-driven incremental migration is out of scope.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dbschema-migrate.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,8BAA8B,CAAC,MAAiB;IAC9D,MAAM,CAAC,YAAY,CACjB,0BAA0B,EAC1B;QACE,KAAK,EAAE,wCAAwC;QAC/C,WAAW,EAAE
|
|
1
|
+
{"version":3,"file":"dbschema-migrate.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,8BAA8B,CAAC,MAAiB;IAC9D,MAAM,CAAC,YAAY,CACjB,0BAA0B,EAC1B;QACE,KAAK,EAAE,wCAAwC;QAC/C,WAAW,EAAE;;;;;;;;;;;;;;;;;;;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IAAI;QACX,IAAI,IAAI,KAAK;UACX,MAAM,IAAI,KAAK;WACd,MAAM,CAAC,OAAO;aACZ,MAAM,CAAC,QAAQ;;;;EAI1B,MAAM,CAAC,MAAM;;;EAGb,MAAM,CAAC,MAAM;;;;;;;;;;;;;;;0IAe2H;qBAC7H;iBACF;gBACD,OAAO,EAAE,IAAI,EAAE,WAAW;aAC3B,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,2EAA2E;YAC3E,6EAA6E;YAC7E,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;gBAEJ,UAAU;UAChB,MAAM;eACD,IAAI;;;;EAIjB,MAAM,CAAC,MAAM;;;;;;;6BAOc;qBAChB;iBACF;aACF,CAAC;QACJ,CAAC;QAED,8EAA8E;QAC9E,2EAA2E;QAC3E,8EAA8E;QAC9E,4EAA4E;QAC5E,mEAAmE;QACnE,MAAM,cAAc,GAClB,YAAY,KAAK,IAAI;YACnB,CAAC,CAAC;meACud;YACzd,CAAC,CAAC,EAAE,CAAC;QAET,sFAAsF;QACtF,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;UAChB,MAAM;eACD,IAAI;;+BAEY,IAAI,IAAI,KAAK;wBACpB,YAAY,IAAI,KAAK;;;EAG3C,MAAM,CAAC,MAAM;;;;oLAIqK,cAAc;;;;;;6BAMrK;iBAClB;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -22,17 +22,18 @@ DO NOT USE FOR:
|
|
|
22
22
|
- Generating DDL -> use 'codegen_dbschema_generate_ddl'
|
|
23
23
|
- Looking up schema syntax -> use 'codegen_get_dbschema_catalog'
|
|
24
24
|
|
|
25
|
-
This tool runs: npx restforge schema models
|
|
25
|
+
This tool runs: npx restforge schema models --path=<path> in the given cwd.
|
|
26
26
|
|
|
27
27
|
Preconditions:
|
|
28
28
|
- The project must have @restforgejs/platform installed in node_modules.
|
|
29
|
-
- The schema path
|
|
29
|
+
- The schema path must exist. If the CLI fails because the folder is missing, the failure response surfaces the underlying cause.
|
|
30
30
|
|
|
31
31
|
PRESENTATION GUIDANCE:
|
|
32
32
|
- Match the user's language. If the user writes in Indonesian, respond in Indonesian.
|
|
33
33
|
- Never mention internal tool names in the reply to the user. Describe actions by what they do (e.g. "list the schema models", "validate the schema", "generate the DDL").
|
|
34
34
|
- Speak in plain language. Summarise the result (model count, schemas in use); do not paste the tabular output verbatim if many models are listed.
|
|
35
35
|
- Models listing skips cross-model validation. If FK references are broken, listing still works; that is by design — use the validate action for correctness check.
|
|
36
|
+
- The user must specify --path (e.g. './schema'). The CLI no longer accepts a positional argument or default. If the user does not mention a path, confirm it before invoking.
|
|
36
37
|
- When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
|
|
37
38
|
inputSchema: {
|
|
38
39
|
cwd: z
|
|
@@ -42,8 +43,7 @@ PRESENTATION GUIDANCE:
|
|
|
42
43
|
path: z
|
|
43
44
|
.string()
|
|
44
45
|
.min(1)
|
|
45
|
-
.
|
|
46
|
-
.describe('Path to schema file or folder relative to cwd. When omitted, the CLI uses its default (./schema).'),
|
|
46
|
+
.describe('Path to schema folder relative to cwd (e.g. "./schema"). Required by the CLI.'),
|
|
47
47
|
},
|
|
48
48
|
annotations: {
|
|
49
49
|
title: 'List dbschema-kit Models',
|
|
@@ -65,7 +65,7 @@ PRESENTATION GUIDANCE:
|
|
|
65
65
|
|
|
66
66
|
Project path: ${projectCwd}
|
|
67
67
|
Expected location: node_modules/@restforgejs/platform
|
|
68
|
-
Requested schema path: ${path
|
|
68
|
+
Requested schema path: ${path}
|
|
69
69
|
|
|
70
70
|
For the assistant:
|
|
71
71
|
- The user needs to install the RESTForge package before models can be listed.
|
|
@@ -76,10 +76,8 @@ For the assistant:
|
|
|
76
76
|
isError: false, // per §3.4
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
-
//
|
|
80
|
-
const cliArgs = ['restforge', 'schema', 'models'];
|
|
81
|
-
if (path !== undefined)
|
|
82
|
-
cliArgs.push(path);
|
|
79
|
+
// CLI v4+ requires --path as a flag (no positional, no default). per §3.5
|
|
80
|
+
const cliArgs = ['restforge', 'schema', 'models', `--path=${path}`];
|
|
83
81
|
const result = await execProcess('npx', cliArgs, {
|
|
84
82
|
cwd: projectCwd,
|
|
85
83
|
timeout: 30_000,
|
|
@@ -95,7 +93,7 @@ For the assistant:
|
|
|
95
93
|
text: `Failed to list schema models.
|
|
96
94
|
|
|
97
95
|
Project path: ${projectCwd}
|
|
98
|
-
Schema path: ${path
|
|
96
|
+
Schema path: ${path}
|
|
99
97
|
Command: ${result.command}
|
|
100
98
|
Exit code: ${result.exitCode}
|
|
101
99
|
|
|
@@ -110,7 +108,8 @@ ${result.stderr}
|
|
|
110
108
|
For the assistant:
|
|
111
109
|
- Tell the user that listing the schema models did not complete successfully.
|
|
112
110
|
- Summarise the most likely cause from the CLI output in plain language. Common causes:
|
|
113
|
-
* Schema folder not found — the CLI cannot locate the path. Suggest verifying the folder name
|
|
111
|
+
* Schema folder not found — the CLI cannot locate the path. Suggest verifying the folder name passed via --path.
|
|
112
|
+
* Missing required flag --path — the CLI now requires this flag explicitly. Confirm the path with the user.
|
|
114
113
|
* Single-model parse error — a file has invalid factory function content. Suggest opening the file and confirming it exports a defineModel call. The validate action surfaces field-level errors more precisely.
|
|
115
114
|
* Unknown command 'schema models' — the installed RESTForge version may be older than this CLI subcommand; suggest upgrading the package.
|
|
116
115
|
- Do not paste the raw stdout/stderr unless the user explicitly asks. Do not mention internal tool names.`,
|
|
@@ -127,7 +126,7 @@ For the assistant:
|
|
|
127
126
|
text: `Schema models listed successfully.
|
|
128
127
|
|
|
129
128
|
Project path: ${projectCwd}
|
|
130
|
-
Schema path: ${path
|
|
129
|
+
Schema path: ${path}
|
|
131
130
|
|
|
132
131
|
--- CLI output ---
|
|
133
132
|
${result.stdout}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dbschema-models.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,6BAA6B,CAAC,MAAiB;IAC7D,MAAM,CAAC,YAAY,CACjB,yBAAyB,EACzB;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE
|
|
1
|
+
{"version":3,"file":"dbschema-models.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,6BAA6B,CAAC,MAAiB;IAC7D,MAAM,CAAC,YAAY,CACjB,yBAAyB,EACzB;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uGA6BoF;QACjG,WAAW,EAAE;YACX,GAAG,EAAE,CAAC;iBACH,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CAAC,uFAAuF,CAAC;YACpG,IAAI,EAAE,CAAC;iBACJ,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CAAC,+EAA+E,CAAC;SAC7F;QACD,WAAW,EAAE;YACX,KAAK,EAAE,0BAA0B;YACj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