@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.
Files changed (56) hide show
  1. package/README.md +51 -8
  2. package/dist/server.js +71 -1
  3. package/dist/server.js.map +1 -1
  4. package/dist/tools/codegen/dbschema-apply.d.ts +2 -0
  5. package/dist/tools/codegen/dbschema-apply.js +324 -0
  6. package/dist/tools/codegen/dbschema-apply.js.map +1 -0
  7. package/dist/tools/codegen/dbschema-diff.d.ts +2 -0
  8. package/dist/tools/codegen/dbschema-diff.js +352 -0
  9. package/dist/tools/codegen/dbschema-diff.js.map +1 -0
  10. package/dist/tools/codegen/dbschema-generate-ddl.js +6 -3
  11. package/dist/tools/codegen/dbschema-generate-ddl.js.map +1 -1
  12. package/dist/tools/codegen/dbschema-init.js +9 -2
  13. package/dist/tools/codegen/dbschema-init.js.map +1 -1
  14. package/dist/tools/codegen/dbschema-introspect.js +25 -19
  15. package/dist/tools/codegen/dbschema-introspect.js.map +1 -1
  16. package/dist/tools/codegen/dbschema-migrate.js +55 -26
  17. package/dist/tools/codegen/dbschema-migrate.js.map +1 -1
  18. package/dist/tools/codegen/dbschema-models.js +11 -12
  19. package/dist/tools/codegen/dbschema-models.js.map +1 -1
  20. package/dist/tools/codegen/dbschema-template.d.ts +2 -0
  21. package/dist/tools/codegen/dbschema-template.js +384 -0
  22. package/dist/tools/codegen/dbschema-template.js.map +1 -0
  23. package/dist/tools/codegen/dbschema-validate.js +13 -13
  24. package/dist/tools/codegen/dbschema-validate.js.map +1 -1
  25. package/dist/tools/codegen/generate-payload.js +1 -1
  26. package/dist/tools/codegen/get-dbschema-catalog.js +4 -2
  27. package/dist/tools/codegen/get-dbschema-catalog.js.map +1 -1
  28. package/dist/tools/codegen/index.js +6 -0
  29. package/dist/tools/codegen/index.js.map +1 -1
  30. package/dist/tools/codegen/list-tables.js +4 -1
  31. package/dist/tools/codegen/list-tables.js.map +1 -1
  32. package/dist/tools/designer/generate.d.ts +2 -0
  33. package/dist/tools/designer/generate.js +212 -0
  34. package/dist/tools/designer/generate.js.map +1 -0
  35. package/dist/tools/designer/index.d.ts +2 -0
  36. package/dist/tools/designer/index.js +17 -0
  37. package/dist/tools/designer/index.js.map +1 -0
  38. package/dist/tools/designer/init-project.d.ts +2 -0
  39. package/dist/tools/designer/init-project.js +235 -0
  40. package/dist/tools/designer/init-project.js.map +1 -0
  41. package/dist/tools/designer/inspect-plugin.d.ts +2 -0
  42. package/dist/tools/designer/inspect-plugin.js +148 -0
  43. package/dist/tools/designer/inspect-plugin.js.map +1 -0
  44. package/dist/tools/designer/list-plugins.d.ts +2 -0
  45. package/dist/tools/designer/list-plugins.js +141 -0
  46. package/dist/tools/designer/list-plugins.js.map +1 -0
  47. package/dist/tools/designer/preview-files.d.ts +2 -0
  48. package/dist/tools/designer/preview-files.js +150 -0
  49. package/dist/tools/designer/preview-files.js.map +1 -0
  50. package/dist/tools/designer/scaffold-plugin.d.ts +2 -0
  51. package/dist/tools/designer/scaffold-plugin.js +162 -0
  52. package/dist/tools/designer/scaffold-plugin.js.map +1 -0
  53. package/dist/tools/designer/validate-payload.d.ts +2 -0
  54. package/dist/tools/designer/validate-payload.js +158 -0
  55. package/dist/tools/designer/validate-payload.js.map +1 -0
  56. package/package.json +2 -2
@@ -0,0 +1,384 @@
1
+ import { z } from 'zod';
2
+ import { access } from 'node:fs/promises';
3
+ import { resolve, join } from 'node:path';
4
+ import { execProcess } from '../../lib/exec.js';
5
+ // Build a short human-readable description of what was requested, for the labeled
6
+ // facts block. Keeps the success response self-describing without re-listing every
7
+ // raw flag. Mirrors the "labeled facts" convention of the sibling dbschema tools.
8
+ function describeRequest(args) {
9
+ const parts = [];
10
+ if (args.generate)
11
+ parts.push(`generate template '${args.table ?? '(missing table)'}' to '${args.path ?? '(missing path)'}'`);
12
+ else if (args.show)
13
+ parts.push(`show template '${args.table ?? '(missing table)'}'${args.example ? ' with example data' : ''}`);
14
+ else if (args.stats)
15
+ parts.push('collection statistics');
16
+ else if (args.listDomains)
17
+ parts.push('list domains');
18
+ else if (args.listCategories)
19
+ parts.push('list categories');
20
+ else if (args.listSections)
21
+ parts.push('list sections');
22
+ else
23
+ parts.push('list/browse templates');
24
+ const filters = [];
25
+ if (args.domain)
26
+ filters.push(`domain=${args.domain}`);
27
+ if (args.table && !args.show && !args.generate)
28
+ filters.push(`table=${args.table}`);
29
+ if (args.category)
30
+ filters.push(`category=${args.category}`);
31
+ if (args.pattern)
32
+ filters.push(`pattern=${args.pattern}`);
33
+ if (args.section)
34
+ filters.push(`section=${args.section}`);
35
+ if (args.hasSdf)
36
+ filters.push('has-sdf');
37
+ if (args.noSdf)
38
+ filters.push('no-sdf');
39
+ if (filters.length > 0)
40
+ parts.push(`filters: ${filters.join(', ')}`);
41
+ if (args.lang)
42
+ parts.push(`lang=${args.lang}`);
43
+ if (args.format)
44
+ parts.push(`format=${args.format}`);
45
+ if (args.force)
46
+ parts.push('force=overwrite');
47
+ return parts.join('; ');
48
+ }
49
+ export function registerCodegenDbschemaTemplate(server) {
50
+ server.registerTool('codegen_dbschema_template', {
51
+ title: 'Browse / Preview / Generate Schema Templates',
52
+ description: `Access the RESTForge Schema Reference collection (87 ready-made templates spanning 30+ domains: ERP, finance, inventory, e-commerce, CRM, HR, POS, and more) by wrapping restforge schema template. Use it to browse and filter the catalog, preview a template's SDF or SQL, look up the available domains/categories/sections, and scaffold real schema files for common business tables (e.g. sales_order, inventory, customer_invoice) instead of starting from an empty skeleton.
53
+
54
+ FOUR MODES:
55
+ - LIST / BROWSE (default, no show/generate/utility flag): returns a filtered catalog of templates. Combine filters: domain (csv), table (wildcard glob like "sales*"), category, pattern, section, hasSdf, noSdf.
56
+ - SHOW (show=true, needs a SPECIFIC table name — no wildcard): prints the template's schema. lang=sdf (default) prints the dbschema-kit factory function; lang=sql prints raw DDL. example=true adds a sample-data section (only meaningful together with show).
57
+ - GENERATE (generate=true, needs a SPECIFIC table AND path): writes the template to the filesystem. A master-detail template writes TWO files (e.g. sales_order.js + sales_order_item.js). force=true overwrites existing destination files; without force the CLI refuses to overwrite.
58
+ - UTILITY (stats / listDomains / listCategories / listSections): collection statistics and the lookup lists that feed the filters above.
59
+
60
+ PLATFORM DEPENDENCY (important): this feature is backed by a native binary (sdf-tools.exe) that is currently WINDOWS-ONLY. On a non-Windows host, or if the binary is missing from the installed package, the CLI exits with code 3 and this tool reports that the template collection is unavailable on this platform — that is NOT a user error. In that case, author the SDF by hand (ground it with 'codegen_get_dbschema_catalog') or reverse-engineer it from an existing database with 'codegen_dbschema_introspect'.
61
+
62
+ USE WHEN:
63
+ - The user asks for an example schema, a starter for a common table, or "what tables/templates are available"
64
+ - Pertanyaan dalam bentuk: "ada template schema untuk sales order nggak?", "buatkan schema inventory dari template", "contoh schema invoice", "template apa saja untuk domain ERP", "scaffold tabel pelanggan dari contoh"
65
+ - The user wants to scaffold a real, fleshed-out table (sales_order, product, customer, journal_entry, ...) rather than the minimal id/code/name/is_active skeleton from 'codegen_dbschema_init'
66
+ - Exploring the catalog by domain/category/pattern, or doing SDF gap analysis (noSdf=true)
67
+ - The user wants to preview a template's SDF or SQL before committing it to a file
68
+
69
+ DO NOT USE FOR:
70
+ - Creating a minimal empty starter file (id/code/name/is_active only) -> use 'codegen_dbschema_init'
71
+ - Editing an existing schema file -> use Edit/Write tools directly
72
+ - Reverse-engineering SDF from a live database -> use 'codegen_dbschema_introspect'
73
+ - Validating a schema file -> use 'codegen_dbschema_validate'
74
+ - Generating DDL from an already-authored SDF -> use 'codegen_dbschema_generate_ddl'
75
+ - Looking up defineModel syntax / field types / constraints -> use 'codegen_get_dbschema_catalog'
76
+
77
+ This tool runs: npx restforge schema template [filters/mode flags] in the given cwd. Boolean flags (show, generate, stats, hasSdf, noSdf, example, force, listDomains, listCategories, listSections) are sent as bare flags only when true; string/enum flags (domain, table, category, pattern, section, lang, path, format) are sent as --flag=value when supplied.
78
+
79
+ OUTPUT: the tool relays the CLI's text output as-is; it does not parse it. The native binary's --format=json is honoured by the list/stats/listDomains/listCategories/listSections modes (machine-readable JSON text) but NOT by show (which always prints schema code) or generate (which prints a written-files summary). Pass format=json only when you specifically want the JSON form of a list/utility result; otherwise the default human-readable text is easier to summarise.
80
+
81
+ CLI constraints (the CLI enforces these; this tool does not pre-validate, it forwards and relays the CLI's own error):
82
+ - show and generate require a specific table name (no wildcard).
83
+ - generate requires path.
84
+ - example is only meaningful together with show.
85
+ - force only matters with generate (overwrite existing files).
86
+ - master-detail templates generate two files.
87
+
88
+ Preconditions:
89
+ - The project must have @restforgejs/platform installed in node_modules.
90
+ - The template feature requires the Windows-only sdf-tools.exe binary shipped with the package (exit 3 otherwise — see PLATFORM DEPENDENCY).
91
+
92
+ PRESENTATION GUIDANCE:
93
+ - Match the user's language. If the user writes in Indonesian, respond in Indonesian.
94
+ - Never mention internal tool names in the reply to the user. Describe actions by what they do (e.g. "browse the schema templates", "preview the sales order template", "scaffold the table from a template").
95
+ - Speak in plain language. Summarise list/stats output (counts, the templates relevant to the user's task); do not paste the entire table or JSON unless the user explicitly asks.
96
+ - For generate: confirm the files that were written and their paths (a master-detail template creates two files). Suggest validating the generated schema next.
97
+ - For the Windows-only exit 3 case: explain plainly that the ready-made template collection is not available on this platform, then offer the alternatives (author the SDF by hand with the catalog as reference, or reverse-engineer from an existing database). Do not present it as a failure of the user's request.
98
+ - When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
99
+ inputSchema: {
100
+ cwd: z
101
+ .string()
102
+ .min(1)
103
+ .describe('Absolute path of the project folder (must contain node_modules/@restforgejs/platform)'),
104
+ // Filters (list/browse).
105
+ domain: z
106
+ .string()
107
+ .min(1)
108
+ .optional()
109
+ .describe('Filter by domain, comma-separated (e.g. "erp" or "erp,finance"). Look up valid values via listDomains.'),
110
+ table: z
111
+ .string()
112
+ .min(1)
113
+ .optional()
114
+ .describe('For list: wildcard glob filter on table name (e.g. "sales*", "*_invoice"). For show/generate: the EXACT template/table name (no wildcard).'),
115
+ category: z
116
+ .enum(['master-data', 'transactional'])
117
+ .optional()
118
+ .describe('Filter by category.'),
119
+ pattern: z
120
+ .enum(['single-table', 'master-detail'])
121
+ .optional()
122
+ .describe('Filter by pattern. master-detail templates generate two files on generate.'),
123
+ section: z
124
+ .string()
125
+ .min(1)
126
+ .optional()
127
+ .describe('Filter by section code. Look up valid values via listSections.'),
128
+ hasSdf: z
129
+ .boolean()
130
+ .optional()
131
+ .describe('When true, only templates that already have an SDF version. Sent as --has-sdf.'),
132
+ noSdf: z
133
+ .boolean()
134
+ .optional()
135
+ .describe('When true, only templates without an SDF version (gap analysis). Sent as --no-sdf.'),
136
+ // Display (show).
137
+ show: z
138
+ .boolean()
139
+ .optional()
140
+ .describe('When true, print the template schema. Requires a specific table name (no wildcard).'),
141
+ example: z
142
+ .boolean()
143
+ .optional()
144
+ .describe('When true, include a sample-data section. Only meaningful together with show.'),
145
+ lang: z
146
+ .enum(['sdf', 'sql'])
147
+ .optional()
148
+ .describe('Schema language for show/generate: sdf (default, the dbschema-kit factory function) or sql (raw DDL).'),
149
+ // Generate.
150
+ generate: z
151
+ .boolean()
152
+ .optional()
153
+ .describe('When true, write the template to the filesystem. Requires a specific table name AND path. WRITES FILES.'),
154
+ path: z
155
+ .string()
156
+ .min(1)
157
+ .optional()
158
+ .describe('Destination directory (or file) for generate, relative to cwd or absolute.'),
159
+ force: z
160
+ .boolean()
161
+ .optional()
162
+ .describe('When true, overwrite existing destination files during generate. Without it, the CLI refuses to overwrite. Sent as --force.'),
163
+ // Utility.
164
+ listDomains: z
165
+ .boolean()
166
+ .optional()
167
+ .describe('When true, list all available domains. Sent as --list-domains.'),
168
+ listCategories: z
169
+ .boolean()
170
+ .optional()
171
+ .describe('When true, list all template categories. Sent as --list-categories.'),
172
+ listSections: z
173
+ .boolean()
174
+ .optional()
175
+ .describe('When true, list all sections with their category. Sent as --list-sections.'),
176
+ stats: z
177
+ .boolean()
178
+ .optional()
179
+ .describe('When true, show collection statistics (counts per category, pattern, domain, section).'),
180
+ format: z
181
+ .enum(['table', 'plain', 'json'])
182
+ .optional()
183
+ .describe('Output format: table (default), plain, or json. json is honoured by list/stats/list* modes only, not by show/generate.'),
184
+ },
185
+ annotations: {
186
+ title: 'Browse / Preview / Generate Schema Templates',
187
+ destructiveHint: false, // generate writes new files; force overwrites, but it never drops database data
188
+ idempotentHint: false, // generate writes to the filesystem; output also depends on the live catalog state
189
+ },
190
+ }, async ({ cwd, domain, table, category, pattern, section, hasSdf, noSdf, show, example, lang, generate, path, force, listDomains, listCategories, listSections, stats, format, }) => {
191
+ const projectCwd = resolve(cwd);
192
+ // Precondition check: @restforgejs/platform must be present in node_modules. per §3.4
193
+ try {
194
+ await access(join(projectCwd, 'node_modules', '@restforgejs', 'platform'));
195
+ }
196
+ catch {
197
+ return {
198
+ content: [
199
+ {
200
+ type: 'text',
201
+ text: `Precondition not met: the RESTForge package is not installed in this project.
202
+
203
+ Project path: ${projectCwd}
204
+ Expected location: node_modules/@restforgejs/platform
205
+
206
+ For the assistant:
207
+ - The user needs to install the RESTForge package before the schema template collection can be used.
208
+ - Suggest installing the package first, then retry.
209
+ - 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.`,
210
+ },
211
+ ],
212
+ isError: false, // per §3.4
213
+ };
214
+ }
215
+ // Forward only the flags that were supplied. Booleans become bare flags when
216
+ // true (mirrors the platform forwarder buildBinaryArgs: BOOLEAN_FLAGS only when
217
+ // === true); string/enum flags become --flag=value. CLI flag names are
218
+ // kebab-case (--has-sdf, --no-sdf, --list-domains, ...). per §3.5
219
+ const cliArgs = ['restforge', 'schema', 'template'];
220
+ if (domain !== undefined)
221
+ cliArgs.push(`--domain=${domain}`);
222
+ if (table !== undefined)
223
+ cliArgs.push(`--table=${table}`);
224
+ if (category !== undefined)
225
+ cliArgs.push(`--category=${category}`);
226
+ if (pattern !== undefined)
227
+ cliArgs.push(`--pattern=${pattern}`);
228
+ if (section !== undefined)
229
+ cliArgs.push(`--section=${section}`);
230
+ if (hasSdf === true)
231
+ cliArgs.push('--has-sdf');
232
+ if (noSdf === true)
233
+ cliArgs.push('--no-sdf');
234
+ if (show === true)
235
+ cliArgs.push('--show');
236
+ if (example === true)
237
+ cliArgs.push('--example');
238
+ if (lang !== undefined)
239
+ cliArgs.push(`--lang=${lang}`);
240
+ if (generate === true)
241
+ cliArgs.push('--generate');
242
+ if (path !== undefined)
243
+ cliArgs.push(`--path=${path}`);
244
+ if (force === true)
245
+ cliArgs.push('--force');
246
+ if (listDomains === true)
247
+ cliArgs.push('--list-domains');
248
+ if (listCategories === true)
249
+ cliArgs.push('--list-categories');
250
+ if (listSections === true)
251
+ cliArgs.push('--list-sections');
252
+ if (stats === true)
253
+ cliArgs.push('--stats');
254
+ if (format !== undefined)
255
+ cliArgs.push(`--format=${format}`);
256
+ const requestSummary = describeRequest({
257
+ domain,
258
+ table,
259
+ category,
260
+ pattern,
261
+ section,
262
+ hasSdf,
263
+ noSdf,
264
+ show,
265
+ example,
266
+ lang,
267
+ generate,
268
+ path,
269
+ force,
270
+ listDomains,
271
+ listCategories,
272
+ listSections,
273
+ stats,
274
+ format,
275
+ });
276
+ const result = await execProcess('npx', cliArgs, {
277
+ cwd: projectCwd,
278
+ timeout: 30_000, // native binary; list/show/stats are fast, generate writes a couple of files
279
+ env: { NODE_ENV: 'production' },
280
+ stripFinalNewline: true,
281
+ });
282
+ // Branch: exit 3 — the template feature is unavailable on this platform. NOT a
283
+ // user error: the CLI returns exit 3 when the host is non-Windows OR the
284
+ // sdf-tools.exe binary is missing from the installed package (template.js:185-200). per §3.4
285
+ if (result.exitCode === 3) {
286
+ return {
287
+ content: [
288
+ {
289
+ type: 'text',
290
+ text: `The schema template collection is unavailable on this platform.
291
+
292
+ Project path: ${projectCwd}
293
+ Requested: ${requestSummary}
294
+ Command: ${result.command}
295
+ Exit code: 3
296
+
297
+ --- CLI output ---
298
+ stdout:
299
+ ${result.stdout}
300
+
301
+ stderr:
302
+ ${result.stderr}
303
+ --- end CLI output ---
304
+
305
+ For the assistant:
306
+ - This is NOT a mistake by the user and NOT a bug in the request. The template feature is backed by a native binary (sdf-tools.exe) that currently only runs on Windows; exit 3 means either the host is not Windows, or the binary is missing from the installed package.
307
+ - Do not retry the same call — it will fail again on this host. Instead, offer the alternatives:
308
+ * Author the schema by hand: look up the defineModel syntax, field types, and constraints (the schema catalog is the ground truth), then create the file and validate it.
309
+ * Reverse-engineer the schema from an existing database table, if one already exists.
310
+ - Explain plainly to the user that the ready-made template collection is not available on this platform, then propose one of the alternatives above. Do not mention internal tool names.`,
311
+ },
312
+ ],
313
+ isError: true, // per §3.4
314
+ };
315
+ }
316
+ // Branch: exit 1 (binary spawn failure) / exit 2 (usage error) / any other
317
+ // non-zero — a real error. Relay full output plus likely causes. per §3.4
318
+ if (!result.success) {
319
+ return {
320
+ content: [
321
+ {
322
+ type: 'text',
323
+ text: `Failed to run the schema template command.
324
+
325
+ Project path: ${projectCwd}
326
+ Requested: ${requestSummary}
327
+ Command: ${result.command}
328
+ Exit code: ${result.exitCode}
329
+
330
+ --- CLI output ---
331
+ stdout:
332
+ ${result.stdout}
333
+
334
+ stderr:
335
+ ${result.stderr}
336
+ --- end CLI output ---
337
+
338
+ For the assistant:
339
+ - Tell the user that the template command did not complete successfully.
340
+ - Summarise the most likely cause from the CLI output in plain language. Common causes:
341
+ * Usage error (exit 2) — an invalid flag combination. Recall the CLI constraints: show/generate need a specific table name (no wildcard); generate also needs path; example only works with show; an unknown enum value for category/pattern/lang/format is rejected.
342
+ * Binary spawn failure (exit 1) — sdf-tools.exe could not be launched; suggest re-checking the installed package integrity.
343
+ * For generate specifically: the destination file already exists and force was not set (the CLI refuses to overwrite) — suggest a different path or passing force=true after confirming with the user.
344
+ * Unknown command 'schema template' — the installed RESTForge version may be older than this CLI subcommand; suggest upgrading the package.
345
+ - Do not paste the raw stdout/stderr unless the user explicitly asks. Do not mention internal tool names.`,
346
+ },
347
+ ],
348
+ isError: true, // per §3.4
349
+ };
350
+ }
351
+ // Branch: success (exit 0) — relay the CLI text output as-is. The output shape
352
+ // varies by mode (table/plain/json for list/stats; schema code for show; a
353
+ // written-files summary for generate); the tool does not parse it. per §3.5
354
+ const generated = generate === true;
355
+ return {
356
+ content: [
357
+ {
358
+ type: 'text',
359
+ text: `Schema template command completed successfully.
360
+
361
+ Project path: ${projectCwd}
362
+ Requested: ${requestSummary}
363
+ ${format ? `Format: ${format}\n` : ''}
364
+ --- CLI output ---
365
+ ${result.stdout}
366
+ --- end CLI output ---
367
+
368
+ For the assistant:
369
+ ${generated
370
+ ? `- Confirm to the user which files were written and their paths — the CLI output above lists each generated file. A master-detail template writes two files (the master plus its detail/line table).
371
+ - Suggest opening the generated file(s) and then validating the schema as a sanity check (without naming the internal tool).
372
+ - The generated schema is a real, fleshed-out starting point from the reference collection, not an empty skeleton; the user may still want to adjust field names/sizes to their exact domain.`
373
+ : show === true
374
+ ? `- This is a preview only; nothing was written to the filesystem.
375
+ - Read the schema above and summarise it in plain language if the user asked a question. If they want to keep it, offer to generate it to a file (which would write the actual file).`
376
+ : `- Read the output above and summarise it for the user (e.g. how many templates matched, the ones relevant to their task, or the requested list/statistics).
377
+ - Do not paste the entire table or JSON if it is long; surface only what the user needs. If they then want a specific template, offer to preview it (show) or scaffold it to a file (generate).`}
378
+ - Match the user's language.`,
379
+ },
380
+ ],
381
+ };
382
+ });
383
+ }
384
+ //# sourceMappingURL=dbschema-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dbschema-template.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-template.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,kFAAkF;AACl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J,CAAC"}
@@ -7,6 +7,8 @@ export function registerCodegenDbschemaValidate(server) {
7
7
  title: 'Validate dbschema-kit Files',
8
8
  description: `Validate dbschema-kit schema definition files (single-model + cross-model) by wrapping restforge schema validate. Single-model checks: defineModel structure, field types, length, nullable, primary key, default value compatibility. Cross-model checks: foreign key target table existence, referenced column existence, primary key requirement for belongsTo relations.
9
9
 
10
+ Validation also covers the soft-delete contract. The softDelete block is strict: keys other than enabled and reusable are rejected. The three contract columns (is_deleted boolean, deleted_at timestamp, deleted_by string) are biconditional with softDelete.enabled = true — missing columns, wrong types, or columns declared without enabled=true are all ERRORs. Each reusable entry must reference a declared string/text field with a single-column UNIQUE and a physical length >= base length + 38; with soft-delete enabled, composite UNIQUEs and non-string single-column UNIQUEs are rejected. These checks run at schema load (inside defineModel), so they are enforced identically by every schema command that loads SDF files (validate, generate-ddl, migrate), not only by this tool.
11
+
10
12
  USE WHEN:
11
13
  - The user asks to validate schema files or check defineModel correctness
12
14
  - Pertanyaan dalam bentuk: "validasi schema saya", "check apakah schema valid", "verify dbschema files", "cek schema definition"
@@ -23,19 +25,19 @@ DO NOT USE FOR:
23
25
  - Looking up valid syntax -> use 'codegen_get_dbschema_catalog'
24
26
  - Generating or applying DDL -> use 'codegen_dbschema_generate_ddl' / 'codegen_dbschema_migrate'
25
27
 
26
- This tool runs: npx restforge schema validate [<path>] in the given cwd.
28
+ This tool runs: npx restforge schema validate --path=<path> in the given cwd.
27
29
  The CLI loads each file in the path (file or folder), runs single-model checks first, then cross-model checks, and reports per-file status.
28
30
 
29
31
  Preconditions:
30
32
  - The project must have @restforgejs/platform installed in node_modules.
31
- - The schema path (default './schema') must exist. If the CLI fails because the folder is missing, the failure response surfaces the underlying cause.
33
+ - The schema path must exist. If the CLI fails because the folder is missing, the failure response surfaces the underlying cause.
32
34
 
33
35
  PRESENTATION GUIDANCE:
34
36
  - Match the user's language. If the user writes in Indonesian, respond in Indonesian.
35
37
  - Never mention internal tool names in the reply to the user. Describe actions by what they do (e.g. "validate the schema files", "look up the schema catalog", "generate the DDL").
36
38
  - Speak in plain language. Summarise the result; do not paste the raw CLI output unless the user explicitly asks.
37
39
  - Validation covers two layers: single-model (struct, types, constraints) and cross-model (FK target tables and columns). A model can be single-valid but fail cross-model if its FK target does not exist.
38
- - The path defaults to './schema'. If the user organizes files differently (e.g. 'db/models'), confirm the path before invoking.
40
+ - The user must specify --path (e.g. './schema' or 'schema/users.js'). The CLI no longer accepts a positional argument or default. If the user does not mention a path, confirm it before invoking.
39
41
  - When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
40
42
  inputSchema: {
41
43
  cwd: z
@@ -45,8 +47,7 @@ PRESENTATION GUIDANCE:
45
47
  path: z
46
48
  .string()
47
49
  .min(1)
48
- .optional()
49
- .describe('Path to schema file or folder relative to cwd. When omitted, the CLI uses its default (./schema).'),
50
+ .describe('Path to schema file or folder relative to cwd (e.g. "./schema" or "schema/users.js"). Required by the CLI.'),
50
51
  },
51
52
  annotations: {
52
53
  title: 'Validate dbschema-kit Files',
@@ -68,7 +69,7 @@ PRESENTATION GUIDANCE:
68
69
 
69
70
  Project path: ${projectCwd}
70
71
  Expected location: node_modules/@restforgejs/platform
71
- Requested schema path: ${path ?? 'default (./schema)'}
72
+ Requested schema path: ${path}
72
73
 
73
74
  For the assistant:
74
75
  - The user needs to install the RESTForge package before schema files can be validated.
@@ -79,10 +80,8 @@ For the assistant:
79
80
  isError: false, // per §3.4
80
81
  };
81
82
  }
82
- // Forward only the arguments the user supplied. CLI default './schema' applies otherwise. per §3.5
83
- const cliArgs = ['restforge', 'schema', 'validate'];
84
- if (path !== undefined)
85
- cliArgs.push(path);
83
+ // CLI v4+ requires --path as a flag (no positional, no default). per §3.5
84
+ const cliArgs = ['restforge', 'schema', 'validate', `--path=${path}`];
86
85
  const result = await execProcess('npx', cliArgs, {
87
86
  cwd: projectCwd,
88
87
  timeout: 30_000,
@@ -98,7 +97,7 @@ For the assistant:
98
97
  text: `Schema validation failed.
99
98
 
100
99
  Project path: ${projectCwd}
101
- Schema path: ${path ?? 'default (./schema)'}
100
+ Schema path: ${path}
102
101
  Command: ${result.command}
103
102
  Exit code: ${result.exitCode}
104
103
 
@@ -115,7 +114,8 @@ For the assistant:
115
114
  - Summarise the most likely cause from the CLI output in plain language. Common causes:
116
115
  * Single-model error — a field has an invalid type, constraint, or shorthand. Suggest reviewing the offending file and consulting the schema catalog for valid syntax.
117
116
  * Cross-model error — a foreign key references a table or column that does not exist in any sibling schema file. Suggest checking the FK target name and that the referenced model is included in the same path.
118
- * Schema folder not found — the CLI cannot locate the path. Suggest verifying the folder name (default is './schema').
117
+ * Schema folder not found — the CLI cannot locate the path. Suggest verifying the folder name passed via --path.
118
+ * Missing required flag --path — the CLI now requires this flag explicitly. Confirm the path with the user.
119
119
  * Unknown command 'schema validate' — the installed RESTForge version may be older than this CLI subcommand; suggest upgrading the package.
120
120
  - Read the per-file error report in the CLI output to identify the failing file and field. Help the user fix it by referencing the catalog (do not invent rules from training data).
121
121
  - Do not paste the raw stdout/stderr unless the user explicitly asks. Do not mention internal tool names.
@@ -133,7 +133,7 @@ For the assistant:
133
133
  text: `Schema validation passed.
134
134
 
135
135
  Project path: ${projectCwd}
136
- Schema path: ${path ?? 'default (./schema)'}
136
+ Schema path: ${path}
137
137
 
138
138
  --- CLI output ---
139
139
  ${result.stdout}
@@ -1 +1 @@
1
- {"version":3,"file":"dbschema-validate.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-validate.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,+BAA+B,CAAC,MAAiB;IAC/D,MAAM,CAAC,YAAY,CACjB,2BAA2B,E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E,QAAQ,EAAE,YAAY,EAAE;YAC/B,iBAAiB,EAAE,IAAI;SACxB,CACF,CAAC;QAEF,wFAAwF;QACxF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;gBAEJ,UAAU;eACX,IAAI,IAAI,oBAAoB;WAChC,MAAM,CAAC,OAAO;aACZ,MAAM,CAAC,QAAQ;;;;EAI1B,MAAM,CAAC,MAAM;;;EAGb,MAAM,CAAC,MAAM;;;;;;;;;;;;6CAY8B;qBAChC;iBACF;gBACD,OAAO,EAAE,IAAI,EAAE,WAAW;aAC3B,CAAC;QACJ,CAAC;QAED,kEAAkE;QAClE,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;eACX,IAAI,IAAI,oBAAoB;;;EAGzC,MAAM,CAAC,MAAM;;;;;;;;6BAQc;iBAClB;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"dbschema-validate.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-validate.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,+BAA+B,CAAC,MAAiB;IAC/D,MAAM,CAAC,YAAY,CACjB,2BAA2B,EAC3B;QACE,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uGAiCoF;QACjG,WAAW,EAAE;YACX,GAAG,EAAE,CAAC;iBACH,MAAM,EAAE;iBACR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,MAAM,CAAC,OAAO;aACZ,MAAM,CAAC,QAAQ;;;;EAI1B,MAAM,CAAC,MAAM;;;EAGb,MAAM,CAAC,MAAM;;;;;;;;;;;;;6CAa8B;qBAChC;iBACF;gBACD,OAAO,EAAE,IAAI,EAAE,WAAW;aAC3B,CAAC;QACJ,CAAC;QAED,kEAAkE;QAClE,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;eACX,IAAI;;;EAGjB,MAAM,CAAC,MAAM;;;;;;;;6BAQc;iBAClB;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -19,7 +19,7 @@ DO NOT USE FOR:
19
19
  - Validating config before generating payload -> use 'setup_validate_config'
20
20
  - Creating the project / endpoint code from a payload -> that is the next CLI step (will be wrapped in a future tool, not yet available)
21
21
 
22
- This tool runs: npx restforge payload --table=<table> --config=<config> in the given cwd.
22
+ This tool runs: npx restforge payload generate --table=<table> --config=<config> in the given cwd.
23
23
  The CLI connects to the database described in the config file, reads the table schema,
24
24
  and writes a payload JSON file (e.g. table 'guest_book' -> 'guest-book.json' with underscore
25
25
  mapped to hyphen). The payload file is the input for the next codegen step (project + endpoint creation).
@@ -5,7 +5,7 @@ import { execProcess } from '../../lib/exec.js';
5
5
  export function registerCodegenGetDbschemaCatalog(server) {
6
6
  server.registerTool('codegen_get_dbschema_catalog', {
7
7
  title: 'Get dbschema-kit Catalog',
8
- description: `Get authoritative JSON catalog of the dbschema-kit defineModel API: defineModel options, field types (with modifier formats), constraints (standalone vs value-bearing), relation types (belongsTo, hasMany, hasOne), referential actions (cascade/restrict/setNull/noAction), check operations (in/gt/gte/lt/lte/eq/neq), shorthand syntax rules and examples, naming rules (table/constraint), and dialect support (postgres/mysql/oracle/sqlite). The catalog is the single source of truth for schema-as-code authoring.
8
+ description: `Get authoritative JSON catalog of the dbschema-kit defineModel API: defineModel options, field types (with modifier formats), constraints (standalone vs value-bearing), relation types (belongsTo, hasMany, hasOne), referential actions (cascade/restrict/setNull/noAction), check operations (in/gt/gte/lt/lte/eq/neq), audit columns, soft-delete contract, shorthand syntax rules and examples, naming rules (table/constraint), and dialect support (postgres/mysql/oracle/sqlite). The catalog is the single source of truth for schema-as-code authoring. The softDelete section documents the SDF soft-delete contract: the three contract columns (is_deleted/deleted_at/deleted_by, biconditional with softDelete.enabled), the reusable unique-column rules (string/text + single-column UNIQUE + physical length >= base length + 38), the UNIQUE eligibility gate (composite and non-string UNIQUEs are rejected), the emitted DDL (consistency CHECK chk_<table>_soft_delete_consistency and PostgreSQL partial indexes), and dialect support (Phase 1: PostgreSQL only).
9
9
 
10
10
  USE WHEN:
11
11
  - The user asks how to define a database schema with dbschema-kit, the factory function pattern, or the \`defineModel\` API
@@ -16,6 +16,7 @@ USE WHEN:
16
16
  - The user asks about referential actions: \`cascade\`, \`restrict\`, \`setNull\`, \`noAction\`
17
17
  - The user asks about check operations: \`in\`, \`gt\`, \`gte\`, \`lt\`, \`lte\`, \`eq\`, \`neq\`
18
18
  - The user asks about audit columns: \`created_at\`, \`created_by\`, \`updated_at\`, \`updated_by\` — the 4-column RESTForge convention shared between SDF and RDF. Trigger phrases: "audit columns", "kolom audit", "kolom created_by updated_by", "konvensi audit"
19
+ - The user asks about soft-delete in the schema layer: the \`softDelete\` block, \`is_deleted\`/\`deleted_at\`/\`deleted_by\` columns, reusable unique columns, or why a UNIQUE constraint is rejected on a soft-delete table. Use section=softDelete. Trigger phrases: "soft delete", "soft-delete", "kolom is_deleted", "reusable unique"
19
20
  - The user asks which dialects are supported (postgres, mysql, oracle, sqlite)
20
21
  - The user is unsure about field shorthand like \`string:36 pk\` or \`decimal:15,2 default:0\`
21
22
 
@@ -55,6 +56,7 @@ PRESENTATION GUIDANCE:
55
56
  'referentialActions',
56
57
  'checkOperations',
57
58
  'auditColumns',
59
+ 'softDelete',
58
60
  'shorthandSyntax',
59
61
  'namingRules',
60
62
  'dialectSupport',
@@ -65,7 +67,7 @@ PRESENTATION GUIDANCE:
65
67
  .string()
66
68
  .min(1)
67
69
  .optional()
68
- .describe('Filter array sections by exact name (e.g. "string", "belongsTo", "cascade"). Use together with section.'),
70
+ .describe('Filter array sections by exact name (e.g. "string", "belongsTo", "cascade"). Only valid together with one of: section=defineModelOptions, fieldTypes, constraints, relationTypes, referentialActions, checkOperations, dialectSupport. The CLI rejects it for the other sections (auditColumns, softDelete, shorthandSyntax, namingRules).'),
69
71
  kind: z
70
72
  .enum(['standalone', 'value'])
71
73
  .optional()
@@ -1 +1 @@
1
- {"version":3,"file":"get-dbschema-catalog.js","sourceRoot":"","sources":["../../../src/tools/codegen/get-dbschema-catalog.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,iCAAiC,CAAC,MAAiB;IACjE,MAAM,CAAC,YAAY,CACjB,8BAA8B,EAC9B;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2IAmCwH;QACrI,WAAW,EAAE;YACX,GAAG,EAAE,CAAC;iBACH,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CAAC,uFAAuF,CAAC;YACpG,OAAO,EAAE,CAAC;iBACP,IAAI,CAAC;gBACJ,oBAAoB;gBACpB,YAAY;gBACZ,aAAa;gBACb,eAAe;gBACf,oBAAoB;gBACpB,iBAAiB;gBACjB,cAAc;gBACd,iBAAiB;gBACjB,aAAa;gBACb,gBAAgB;aACjB,CAAC;iBACD,QAAQ,EAAE;iBACV,QAAQ,CAAC,iFAAiF,CAAC;YAC9F,IAAI,EAAE,CAAC;i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AAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAEnD,2EAA2E;QAC3E,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;qBACL,WAAW;kBACd,OAAO,IAAI,KAAK;eACnB,IAAI,IAAI,MAAM;eACd,IAAI,IAAI,MAAM;mBACV,eAAe;oBACd,gBAAgB;sBACd,kBAAkB;2BACb,uBAAuB;wBAC1B,oBAAoB;qBACvB,iBAAiB;iBACrB,aAAa;;;EAG5B,UAAU;;;;;;;;;;;;;;;;;;6BAkBiB;iBAClB;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"get-dbschema-catalog.js","sourceRoot":"","sources":["../../../src/tools/codegen/get-dbschema-catalog.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,iCAAiC,CAAC,MAAiB;IACjE,MAAM,CAAC,YAAY,CACjB,8BAA8B,EAC9B;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2IAoCwH;QACrI,WAAW,EAAE;YACX,GAAG,EAAE,CAAC;iBACH,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CAAC,uFAAuF,CAAC;YACpG,OAAO,EAAE,CAAC;iBACP,IAAI,CAAC;gBACJ,oBAAoB;gBACpB,YAAY;gBACZ,aAAa;gBACb,eAAe;gBACf,oBAAoB;gBACpB,iBAAiB;gBACjB,cAAc;gBACd,YAAY;gBACZ,iBAAiB;gBACjB,aAAa;g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AC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC;QAEvF,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAEnD,2EAA2E;QAC3E,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;qBACL,WAAW;kBACd,OAAO,IAAI,KAAK;eACnB,IAAI,IAAI,MAAM;eACd,IAAI,IAAI,MAAM;mBACV,eAAe;oBACd,gBAAgB;sBACd,kBAAkB;2BACb,uBAAuB;wBAC1B,oBAAoB;qBACvB,iBAAiB;iBACrB,aAAa;;;EAG5B,UAAU;;;;;;;;;;;;;;;;;;6BAkBiB;iBAClB;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -18,6 +18,9 @@ import { registerCodegenDbschemaModels } from './dbschema-models.js';
18
18
  import { registerCodegenDbschemaGenerateDdl } from './dbschema-generate-ddl.js';
19
19
  import { registerCodegenDbschemaIntrospect } from './dbschema-introspect.js';
20
20
  import { registerCodegenDbschemaMigrate } from './dbschema-migrate.js';
21
+ import { registerCodegenDbschemaDiff } from './dbschema-diff.js';
22
+ import { registerCodegenDbschemaApply } from './dbschema-apply.js';
23
+ import { registerCodegenDbschemaTemplate } from './dbschema-template.js';
21
24
  export function registerCodegenTools(server) {
22
25
  registerCodegenGeneratePayload(server);
23
26
  registerCodegenValidatePayload(server);
@@ -39,5 +42,8 @@ export function registerCodegenTools(server) {
39
42
  registerCodegenDbschemaGenerateDdl(server);
40
43
  registerCodegenDbschemaIntrospect(server);
41
44
  registerCodegenDbschemaMigrate(server);
45
+ registerCodegenDbschemaDiff(server);
46
+ registerCodegenDbschemaApply(server);
47
+ registerCodegenDbschemaTemplate(server);
42
48
  }
43
49
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../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;IAClC,4BAA4B,CAAC,MAAM,CAAC,CAAC;IACrC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACnC,iCAAiC,CAAC,MAAM,CAAC,CAAC;IAC1C,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACpC,+BAA+B,CAAC,MAAM,CAAC,CAAC;IACxC,6BAA6B,CAAC,MAAM,CAAC,CAAC;IACtC,kCAAkC,CAAC,MAAM,CAAC,CAAC;IAC3C,iCAAiC,CAAC,MAAM,CAAC,CAAC;IAC1C,8BAA8B,CAAC,MAAM,CAAC,CAAC;IACvC,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACpC,4BAA4B,CAAC,MAAM,CAAC,CAAC;IACrC,+BAA+B,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC"}
@@ -25,7 +25,7 @@ DO NOT USE FOR:
25
25
  - Modifying the database schema (CREATE/ALTER/DROP TABLE) -> out of scope
26
26
  - Listing schemas or databases themselves -> out of scope; this tool returns the tables WITHIN a schema, not the schemas themselves
27
27
 
28
- This tool runs: npx restforge schema list --config=<config> [--schema=<schema>] [--include-system=<bool>] in the given cwd.
28
+ This tool runs: npx restforge schema list --config=<config> --format=json [--schema=<schema>] [--include-system=<bool>] in the given cwd.
29
29
  The CLI connects to the database described in the config file, queries the catalog, and emits a JSON envelope with summary counts and a tables array.
30
30
 
31
31
  Preconditions:
@@ -95,11 +95,14 @@ For the assistant:
95
95
  }
96
96
  // Forward only the arguments the user supplied. CLI defaults remain in
97
97
  // effect when the user does not specify them. per §3.5
98
+ // --format=json is always sent: the CLI default is a human-readable table,
99
+ // while this tool depends on JSON.parse of stdout.
98
100
  const cliArgs = [
99
101
  'restforge',
100
102
  'schema',
101
103
  'list',
102
104
  `--config=${config}`,
105
+ '--format=json',
103
106
  ];
104
107
  if (schema !== undefined)
105
108
  cliArgs.push(`--schema=${schema}`);