@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,352 @@
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
+ // Extract a printable name from a drift item. Items in onlyInSdf/onlyInDb/mismatched
6
+ // can be plain strings or objects depending on the section; fall back to JSON for
7
+ // unknown shapes. Defensive access per the verified JSON shape (phase 00 T3.1).
8
+ function itemName(item) {
9
+ if (typeof item === 'string')
10
+ return item;
11
+ if (item !== null && typeof item === 'object') {
12
+ const o = item;
13
+ if (typeof o.name === 'string')
14
+ return o.name;
15
+ if (typeof o.field === 'string')
16
+ return o.field;
17
+ if (typeof o.column === 'string')
18
+ return o.column;
19
+ }
20
+ return JSON.stringify(item);
21
+ }
22
+ // Summarise one { onlyInSdf, onlyInDb, mismatched } drift section. Returns null when
23
+ // the section is absent or has no drift, so clean sections stay out of the summary.
24
+ function summariseListSection(section) {
25
+ if (section === null || typeof section !== 'object')
26
+ return null;
27
+ const s = section;
28
+ const labels = {
29
+ onlyInSdf: 'only-in-SDF',
30
+ onlyInDb: 'only-in-DB',
31
+ mismatched: 'mismatched',
32
+ };
33
+ const parts = [];
34
+ for (const key of ['onlyInSdf', 'onlyInDb', 'mismatched']) {
35
+ const arr = Array.isArray(s[key]) ? s[key] : [];
36
+ if (arr.length > 0) {
37
+ parts.push(`${labels[key]} [${arr.map(itemName).join(', ')}]`);
38
+ }
39
+ }
40
+ return parts.length > 0 ? parts.join('; ') : null;
41
+ }
42
+ // Summarise a { match, sdf, db } section (primaryKey, softDelete). Returns null when
43
+ // match is not explicitly false or the shape is unknown.
44
+ function summariseMatchSection(section) {
45
+ if (section === null || typeof section !== 'object')
46
+ return null;
47
+ const s = section;
48
+ if (s.match !== false)
49
+ return null;
50
+ return `mismatch (SDF: ${JSON.stringify(s.sdf ?? null)} vs DB: ${JSON.stringify(s.db ?? null)})`;
51
+ }
52
+ // Build the per-table drift lines for the response text. Section order follows the
53
+ // JSON shape from phase 00 T3.1: fields, primaryKey, indexes, uniques, foreignKeys,
54
+ // checks, softDelete (the last two are optional in the report).
55
+ function buildDriftSummary(tables) {
56
+ const lines = [];
57
+ for (const t of tables) {
58
+ if (t === null || typeof t !== 'object')
59
+ continue;
60
+ const table = t;
61
+ if (table.hasDrift !== true)
62
+ continue;
63
+ const name = typeof table.tableName === 'string' ? table.tableName : '(unknown table)';
64
+ const sectionLines = [];
65
+ const fields = summariseListSection(table.fields);
66
+ if (fields)
67
+ sectionLines.push(` fields: ${fields}`);
68
+ const pk = summariseMatchSection(table.primaryKey);
69
+ if (pk)
70
+ sectionLines.push(` primaryKey: ${pk}`);
71
+ for (const key of ['indexes', 'uniques', 'foreignKeys', 'checks']) {
72
+ const summary = summariseListSection(table[key]);
73
+ if (summary)
74
+ sectionLines.push(` ${key}: ${summary}`);
75
+ }
76
+ const softDelete = summariseMatchSection(table.softDelete);
77
+ if (softDelete)
78
+ sectionLines.push(` softDelete: ${softDelete}`);
79
+ if (sectionLines.length === 0) {
80
+ sectionLines.push(' (drift flagged but no recognised section detail — see the raw JSON below)');
81
+ }
82
+ lines.push(`- ${name}:`, ...sectionLines);
83
+ }
84
+ return lines.join('\n');
85
+ }
86
+ export function registerCodegenDbschemaDiff(server) {
87
+ server.registerTool('codegen_dbschema_diff', {
88
+ title: 'Diff dbschema-kit Files Against Database',
89
+ description: `Detect schema drift between dbschema-kit SDF files and the live database structure (read-only, bidirectional), by wrapping restforge schema diff. The CLI loads the SDF files, introspects the matching tables in the database, and reports differences in both directions: only-in-SDF (declared but missing in the database), only-in-DB (present in the database but not declared), and mismatched (present on both sides but different). Nothing is written to the database or the filesystem.
90
+
91
+ EXIT CODE SEMANTICS (important):
92
+ - Exit 0 = no drift; schema and database are in sync.
93
+ - Exit 1 = drift detected. This is a NORMAL, meaningful result — NOT a failure. The response summarises the drift; treat it as the answer to "is my schema in sync?".
94
+ - Exit 2 = system error (invalid config, connection failure, schema path not found, SDF load error).
95
+
96
+ USE WHEN:
97
+ - The user asks "is my schema in sync with the database?", "apakah schema saya sinkron dengan database?", "ada drift nggak?", "cek drift schema"
98
+ - After editing SDF files — to check the impact against the live database before deciding what to apply
99
+ - After a manual database change (e.g. an ad-hoc ALTER) — to see how far the database diverged from the SDF source
100
+ - Before running 'codegen_dbschema_migrate' on an existing database — to know what differs first
101
+ - The user wants a safe read-only comparison without modifying anything
102
+ - Periodic drift audit of an environment (staging/production) against the SDF folder
103
+
104
+ DO NOT USE FOR:
105
+ - Applying the detected drift to the database -> use 'codegen_dbschema_apply', the incremental complement of this diff (additive ALTER by default; destructive changes need explicit opt-in).
106
+ - Full CREATE/DROP deployment of a schema -> use 'codegen_dbschema_migrate' (full apply, mutates the database — a different operation from drift detection)
107
+ - Validating SDF file correctness without a database -> use 'codegen_dbschema_validate'
108
+ - Reverse-engineering SDF files from the database -> use 'codegen_dbschema_introspect'
109
+ - Listing tables or describing a single table -> use 'codegen_list_tables' / 'codegen_describe_table'
110
+ - Comparing RDF payload files against the database -> use 'codegen_diff_payload'
111
+
112
+ This tool runs: npx restforge schema diff --path=<path> --config=<config> --json [--table=<name>] in the given cwd. The --json flag is always sent; the tool parses the JSON drift report (version, summary, per-table sections).
113
+
114
+ Soft-delete note: the diff is soft-delete aware but non-strict. Drift in the softDelete block is reported as-is in the table's softDelete section without blocking the diff — unlike introspect, which can block on a broken soft-delete contract.
115
+
116
+ Limitations:
117
+ - The sqlite dialect is not supported by schema diff.
118
+ - A table declared in SDF but absent in the database is reported as only-in-SDF drift, not as an error.
119
+
120
+ Preconditions:
121
+ - The project must have @restforgejs/platform installed in node_modules.
122
+ - The config file (default 'db-connection.env') must exist and contain valid database credentials.
123
+ - SDF files must exist at the given path. The --path flag is required by the CLI.
124
+
125
+ PRESENTATION GUIDANCE:
126
+ - Match the user's language. If the user writes in Indonesian, respond in Indonesian.
127
+ - Never mention internal tool names in the reply to the user. Describe actions by what they do (e.g. "compare the schema with the database", "check for drift").
128
+ - Drift detected is NOT an error. Present it as a factual comparison result: which tables drifted and in which direction (only-in-SDF / only-in-DB / mismatched).
129
+ - Speak in plain language. Summarise per table; do not paste the raw JSON unless the user explicitly asks.
130
+ - This is a read-only live comparison: the database is introspected at diff time and never modified.
131
+ - When a precondition is not met, frame it as a question or next-step suggestion rather than an error.`,
132
+ inputSchema: {
133
+ cwd: z
134
+ .string()
135
+ .min(1)
136
+ .describe('Absolute path of the project folder (must contain node_modules/@restforgejs/platform and the config file)'),
137
+ config: z
138
+ .string()
139
+ .min(1)
140
+ .default('db-connection.env')
141
+ .describe('Config file name relative to the project, used by the CLI to connect to the database'),
142
+ path: z
143
+ .string()
144
+ .min(1)
145
+ .describe('Path to schema file or folder relative to cwd (e.g. "./schema" or "schema/users.js"). Required by the CLI.'),
146
+ table: z
147
+ .string()
148
+ .min(1)
149
+ .optional()
150
+ .describe('Diff only one specific table. When omitted, all tables in the schema path are compared.'),
151
+ },
152
+ annotations: {
153
+ title: 'Diff dbschema-kit Files Against Database',
154
+ readOnlyHint: true,
155
+ idempotentHint: true,
156
+ },
157
+ }, async ({ cwd, config, path, table }) => {
158
+ const projectCwd = resolve(cwd);
159
+ // Precondition check: @restforgejs/platform must be present in node_modules. per §3.4
160
+ try {
161
+ await access(join(projectCwd, 'node_modules', '@restforgejs', 'platform'));
162
+ }
163
+ catch {
164
+ return {
165
+ content: [
166
+ {
167
+ type: 'text',
168
+ text: `Precondition not met: the RESTForge package is not installed in this project.
169
+
170
+ Project path: ${projectCwd}
171
+ Expected location: node_modules/@restforgejs/platform
172
+ Requested config: ${config}
173
+ Requested schema path: ${path}
174
+ Requested table filter: ${table ?? 'all tables'}
175
+
176
+ For the assistant:
177
+ - The user needs to install the RESTForge package before the schema can be diffed against the database.
178
+ - Suggest installing the package first, then retry the drift check.
179
+ - 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.`,
180
+ },
181
+ ],
182
+ isError: false, // per §3.4
183
+ };
184
+ }
185
+ // --json is always sent: the CLI default is a human-readable report, while this
186
+ // tool depends on JSON.parse of stdout. There is no --dry-run flag — schema diff
187
+ // is read-only by design. Optional flags forwarded only when supplied. per §3.5
188
+ const cliArgs = [
189
+ 'restforge',
190
+ 'schema',
191
+ 'diff',
192
+ `--path=${path}`,
193
+ `--config=${config}`,
194
+ '--json',
195
+ ];
196
+ if (table !== undefined)
197
+ cliArgs.push(`--table=${table}`);
198
+ const result = await execProcess('npx', cliArgs, {
199
+ cwd: projectCwd,
200
+ timeout: 60_000, // diff introspects every table in the schema path; more headroom than a single catalog query
201
+ env: { NODE_ENV: 'production' },
202
+ stripFinalNewline: true,
203
+ });
204
+ // Exit code semantics are part of the CLI spec: 0 = no drift, 1 = drift detected
205
+ // (a meaningful result, NOT an error), 2 = system error. execProcess treats only
206
+ // exit 0 as success, so exit 1 is re-routed into the result branches below.
207
+ const driftDetected = result.exitCode === 1;
208
+ // Branch C: system error (exit 2 or any other non-0/1 exit). per §3.4
209
+ if (!result.success && !driftDetected) {
210
+ return {
211
+ content: [
212
+ {
213
+ type: 'text',
214
+ text: `Failed to diff schema against the database.
215
+
216
+ Project path: ${projectCwd}
217
+ Config: ${config}
218
+ Schema path: ${path}
219
+ Table filter: ${table ?? 'all tables'}
220
+ Command: ${result.command}
221
+ Exit code: ${result.exitCode}
222
+
223
+ --- CLI output ---
224
+ stdout:
225
+ ${result.stdout}
226
+
227
+ stderr:
228
+ ${result.stderr}
229
+ --- end CLI output ---
230
+
231
+ For the assistant:
232
+ - Tell the user that the drift check could not run. This is a system error, not a drift result.
233
+ - Summarise the most likely cause from the CLI output in plain language. Common causes:
234
+ * Config file not found or invalid — suggest verifying the config path and its content.
235
+ * Database connection failed — suggest verifying credentials, host, and port.
236
+ * Schema path not found — the CLI cannot locate the path. Suggest verifying the folder or file name passed via --path.
237
+ * SDF load error — a schema file has invalid syntax or violates the defineModel contract. Suggest running the validate action first to surface the specific issue.
238
+ * Unsupported dialect — schema diff does not support sqlite. Suggest checking DB_TYPE in the config.
239
+ * Unknown command 'schema diff' — the installed RESTForge version may be older than this CLI subcommand; suggest upgrading the package.
240
+ - Do not paste the raw stdout/stderr unless the user explicitly asks. Do not mention internal tool names.
241
+ - Offer to retry once the underlying issue is resolved.`,
242
+ },
243
+ ],
244
+ isError: true, // per §3.4
245
+ };
246
+ }
247
+ // Branch D: JSON parse failure on exit 0/1 — real error per §3.4 (the CLI
248
+ // completed but produced output this tool cannot read).
249
+ let parsed;
250
+ try {
251
+ parsed = JSON.parse(result.stdout);
252
+ }
253
+ catch (err) {
254
+ const msg = err instanceof Error ? err.message : String(err);
255
+ return {
256
+ content: [
257
+ {
258
+ type: 'text',
259
+ text: `Failed to parse the schema drift report as JSON.
260
+
261
+ Project path: ${projectCwd}
262
+ Config: ${config}
263
+ Schema path: ${path}
264
+ Exit code: ${result.exitCode}
265
+ Reason: ${msg}
266
+
267
+ --- Raw stdout ---
268
+ ${result.stdout}
269
+ --- end Raw stdout ---
270
+
271
+ For the assistant:
272
+ - The CLI returned output that is not valid JSON, so the drift result could not be read.
273
+ - Summarise this to the user in plain language; do not paste the raw stdout unless they explicitly ask.
274
+ - Suggest checking that the installed RESTForge package version is compatible. Do not mention internal tool names.`,
275
+ },
276
+ ],
277
+ isError: true, // per §3.4
278
+ };
279
+ }
280
+ // Defensive labeled facts: if the JSON shape changes upstream, fall back to
281
+ // 'unknown' rather than crashing. Mirror the list-tables pattern.
282
+ const root = (parsed ?? {});
283
+ const summary = (root.summary ?? {});
284
+ const totalTables = typeof summary.totalTables === 'number' ? summary.totalTables : 'unknown';
285
+ const tablesWithDrift = typeof summary.tablesWithDrift === 'number' ? summary.tablesWithDrift : 'unknown';
286
+ const tablesClean = typeof summary.tablesClean === 'number' ? summary.tablesClean : 'unknown';
287
+ const tables = Array.isArray(root.tables) ? root.tables : [];
288
+ const prettyJson = JSON.stringify(parsed, null, 2);
289
+ // Branch B (no drift): exit 0 — schema and database are in sync. per §3.5
290
+ if (!driftDetected) {
291
+ return {
292
+ content: [
293
+ {
294
+ type: 'text',
295
+ text: `Schema drift check completed: no drift detected.
296
+
297
+ Project path: ${projectCwd}
298
+ Config: ${config}
299
+ Schema path: ${path}
300
+ Table filter: ${table ?? 'all tables'}
301
+ totalTables: ${totalTables}
302
+ tablesWithDrift: ${tablesWithDrift}
303
+ tablesClean: ${tablesClean}
304
+
305
+ For the assistant:
306
+ - Confirm to the user that the schema files and the database are in sync — mention the number of tables compared in plain language.
307
+ - This was a read-only comparison; nothing in the database or the filesystem was modified.
308
+ - No follow-up action is required. If the user expected drift, suggest double-checking that the schema path and config point at the intended files and database.
309
+ - Match the user's language.`,
310
+ },
311
+ ],
312
+ };
313
+ }
314
+ // Branch B (drift): exit 1 — drift detected, a meaningful result, NOT an error. per §3.5
315
+ const driftSummary = buildDriftSummary(tables);
316
+ return {
317
+ content: [
318
+ {
319
+ type: 'text',
320
+ text: `Schema drift check completed: drift detected (this is a result, not an error).
321
+
322
+ Project path: ${projectCwd}
323
+ Config: ${config}
324
+ Schema path: ${path}
325
+ Table filter: ${table ?? 'all tables'}
326
+ totalTables: ${totalTables}
327
+ tablesWithDrift: ${tablesWithDrift}
328
+ tablesClean: ${tablesClean}
329
+
330
+ --- Drift summary per table ---
331
+ ${driftSummary}
332
+ --- end Drift summary ---
333
+
334
+ --- Drift report (JSON) ---
335
+ ${prettyJson}
336
+ --- end Drift report (JSON) ---
337
+
338
+ For the assistant:
339
+ - Present this as a factual comparison result, NOT a failure: the schema files and the database differ.
340
+ - Summarise per drifted table in plain language: only-in-SDF means declared in the schema files but missing in the database; only-in-DB means present in the database but not declared; mismatched means present on both sides with different definitions.
341
+ - A whole table reported as only-in-SDF fields drift usually means the table does not exist in the database yet.
342
+ - Drift in the softDelete section is informational (non-strict) — report it as-is without treating it as a blocker.
343
+ - Do not paste the full JSON unless the user asks; the per-table summary above is usually enough.
344
+ - For next steps, depending on direction: additive changes can be applied incrementally via 'codegen_dbschema_apply' (preview with dryRun=true first; destructive changes need explicit user opt-in); a full re-deploy goes through the migrate action (destructive — needs explicit confirmation). When speaking to the user, describe these as actions — do not mention internal tool names.
345
+ - This was a read-only comparison; nothing was modified.
346
+ - Match the user's language.`,
347
+ },
348
+ ],
349
+ };
350
+ });
351
+ }
352
+ //# sourceMappingURL=dbschema-diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dbschema-diff.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-diff.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;A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P,eAAe;eACnB,WAAW;;;;;;6BAMG;qBAChB;iBACF;aACF,CAAC;QACJ,CAAC;QAED,yFAAyF;QACzF,MAAM,YAAY,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC/C,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;UAChB,MAAM;eACD,IAAI;gBACH,KAAK,IAAI,YAAY;eACtB,WAAW;mBACP,eAAe;eACnB,WAAW;;;EAGxB,YAAY;;;;EAIZ,UAAU;;;;;;;;;;;6BAWiB;iBAClB;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -23,7 +23,9 @@ DO NOT USE FOR:
23
23
  - Generating DDL for tables not defined in schema files -> out of scope (only schema-as-code files are processed)
24
24
  - Validating schema correctness -> use 'codegen_dbschema_validate'
25
25
 
26
- This tool runs: npx restforge schema generate-ddl <path> --dialect=<X> [--out=<file>] [--drop=<bool>] in the given cwd.
26
+ This tool runs: npx restforge schema generate-ddl --path=<path> --dialect=<X> [--out=<file>] [--drop=<bool>] in the given cwd.
27
+
28
+ SOFT-DELETE EMISSION: a table declared with softDelete enabled emits a consistency CHECK constraint named chk_<table>_soft_delete_consistency and emits its non-unique indexes as PostgreSQL partial indexes (WHERE is_deleted = FALSE); UNIQUE constraints are never made partial. Soft-delete is PostgreSQL-only in Phase 1: generating DDL for any other dialect fails with a clear error ("soft-delete is PostgreSQL-only in Phase 1") instead of emitting wrong DDL silently.
27
29
 
28
30
  Preconditions:
29
31
  - The project must have @restforgejs/platform installed in node_modules.
@@ -100,7 +102,7 @@ For the assistant:
100
102
  'restforge',
101
103
  'schema',
102
104
  'generate-ddl',
103
- path,
105
+ `--path=${path}`,
104
106
  `--dialect=${dialect}`,
105
107
  ];
106
108
  if (out !== undefined)
@@ -141,7 +143,8 @@ For the assistant:
141
143
  - Tell the user that generating the DDL did not complete successfully.
142
144
  - Summarise the most likely cause from the CLI output in plain language. Common causes:
143
145
  * Schema validation failure — a file has invalid syntax or a broken FK reference. Suggest running the validate action first to surface the specific issue.
144
- * Schema folder not found — the CLI cannot locate the path. Suggest verifying the folder name.
146
+ * Schema folder not found — the CLI cannot locate the path. Suggest verifying the folder name passed via --path.
147
+ * Missing required flag --path or --dialect — the CLI now requires both explicitly. Confirm both values with the user.
145
148
  * Invalid dialect — only postgres, mysql, oracle, sqlite are supported.
146
149
  * Output path issue (parent folder missing) — the CLI does not auto-create intermediate folders. Suggest creating them first.
147
150
  * Unknown command 'schema generate-ddl' — the installed RESTForge version may be older than this CLI subcommand; suggest upgrading the package.
@@ -1 +1 @@
1
- {"version":3,"file":"dbschema-generate-ddl.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-generate-ddl.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,kCAAkC,CAAC,MAAiB;IAClE,MAAM,CAAC,YAAY,CACjB,+BAA+B,EAC/B;QACE,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uGAiCoF;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,sFAAsF,CAAC;YACnG,OAAO,EAAE,CAAC;iBACP,IAAI,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;iBA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;QAEvD,MAAM,MAAM,GAAG,MAAM,WAAW,CAC9B,KAAK,EACL,OAAO,EACP;YACE,GAAG,EAAE,UAAU;YACf,OAAO,EAAE,MAAM;YACf,GAAG,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE;YAC/B,iBAAiB,EAAE,IAAI;SACxB,CACF,CAAC;QAEF,wDAAwD;QACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;gBAEJ,UAAU;eACX,IAAI;WACR,OAAO;UACR,GAAG,IAAI,UAAU;eACZ,IAAI,IAAI,KAAK;WACjB,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,qGAAqG;QACrG,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;eACX,IAAI;WACR,OAAO;eACH,IAAI,IAAI,KAAK;UAClB,GAAG,IAAI,UAAU;;;EAGzB,MAAM,CAAC,MAAM;;;;;;;;;;;6BAWc;iBAClB;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"dbschema-generate-ddl.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-generate-ddl.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,C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;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;eACX,IAAI;WACR,OAAO;eACH,IAAI,IAAI,KAAK;UAClB,GAAG,IAAI,UAAU;;;EAGzB,MAAM,CAAC,MAAM;;;;;;;;;;;6BAWc;iBAClB;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -17,17 +17,23 @@ USE WHEN:
17
17
  - The user mentions a new domain entity (e.g. "I need a customer_invoice table") and wants a schema file as a starting point
18
18
 
19
19
  DO NOT USE FOR:
20
+ - Scaffolding a real, fleshed-out common table (sales_order, invoice, product, ...) from the reference collection -> use 'codegen_dbschema_template' (generate mode); this tool only creates a minimal dummy skeleton
20
21
  - Editing an existing schema file -> use Edit/Write tools directly
21
22
  - Generating schema files from a live database -> use 'codegen_dbschema_introspect'
22
23
  - Creating a CRUD payload (different concept) -> use 'codegen_generate_payload'
23
24
  - Validating the schema -> use 'codegen_dbschema_validate'
24
25
  - Generating DDL -> use 'codegen_dbschema_generate_ddl'
25
26
 
26
- This tool runs: npx restforge schema init <path> in the given cwd.
27
+ This tool runs: npx restforge schema init --path=<path> in the given cwd.
27
28
  The CLI writes a JavaScript factory function file to the target path. The path must end with '.js' and the file must NOT already exist.
28
29
 
30
+ IMPLEMENTATION NOTE (matters for cross-platform behaviour): schema init is a thin wrapper over 'schema template --table=dummy --generate --lang=sdf'. It therefore depends on the same native binary (sdf-tools.exe) that the template feature uses, and that binary 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 no file is created — that is a platform limitation, not a user error.
31
+
32
+ For scaffolding a real, fleshed-out table from the reference collection (e.g. sales_order, customer_invoice) instead of the minimal dummy skeleton, use 'codegen_dbschema_template' (generate mode).
33
+
29
34
  Preconditions:
30
35
  - The project must have @restforgejs/platform installed in node_modules.
36
+ - The init feature requires the Windows-only sdf-tools.exe binary shipped with the package (exit 3 otherwise — see IMPLEMENTATION NOTE).
31
37
  - The target file must NOT already exist (CLI fails otherwise — the user can pick a different name or remove the existing file first).
32
38
  - The parent folder of the target path must exist (CLI does not create intermediate folders).
33
39
 
@@ -81,7 +87,7 @@ For the assistant:
81
87
  }
82
88
  // Subprocess call. The CLI handles all filesystem validation
83
89
  // (extension, parent folder existence, target file non-existence). per §3.5
84
- const cliArgs = ['restforge', 'schema', 'init', path];
90
+ const cliArgs = ['restforge', 'schema', 'init', `--path=${path}`];
85
91
  const result = await execProcess('npx', cliArgs, {
86
92
  cwd: projectCwd,
87
93
  timeout: 10_000,
@@ -115,6 +121,7 @@ For the assistant:
115
121
  * The target file already exists — suggest picking a different filename or removing the existing file first.
116
122
  * The path does not end with '.js' — schema files use the JavaScript factory function pattern; suggest correcting the extension.
117
123
  * The parent folder does not exist — the CLI does not auto-create intermediate folders. Suggest creating the folder first.
124
+ * Exit code 3 / non-Windows platform — init depends on the Windows-only sdf-tools.exe binary (it wraps 'schema template --generate'). On a non-Windows host the skeleton cannot be generated. Offer alternatives: author the schema file by hand (ground it with the schema catalog), or reverse-engineer it from an existing database table. Present this as a platform limitation, not a user error.
118
125
  * Unknown command 'schema init' — the installed RESTForge version may be older than this CLI subcommand; suggest upgrading the package.
119
126
  - Do not paste the raw stdout/stderr unless the user explicitly asks. Do not mention internal tool names.`,
120
127
  },
@@ -1 +1 @@
1
- {"version":3,"file":"dbschema-init.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-init.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,2BAA2B,CAAC,MAAiB;IAC3D,MAAM,CAAC,YAAY,CACjB,uBAAuB,EACvB;QACE,KAAK,EAAE,iCAAiC;QACx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Q,EAAE,YAAY,EAAE;YAC/B,iBAAiB,EAAE,IAAI;SACxB,CACF,CAAC;QAEF,oEAAoE;QACpE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;;gBAEJ,UAAU;eACX,IAAI;WACR,MAAM,CAAC,OAAO;aACZ,MAAM,CAAC,QAAQ;;;;EAI1B,MAAM,CAAC,MAAM;;;EAGb,MAAM,CAAC,MAAM;;;;;;;;;;;0GAW2F;qBAC7F;iBACF;gBACD,OAAO,EAAE,IAAI,EAAE,WAAW;aAC3B,CAAC;QACJ,CAAC;QAED,mEAAmE;QACnE,2FAA2F;QAC3F,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC;QACtD,MAAM,gBAAgB,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC;YAClD,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC1B,CAAC,CAAC,WAAW,CAAC;QAEhB,kEAAkE;QAClE,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;gBAEF,UAAU;eACX,IAAI;sCACmB,gBAAgB;;;EAGpD,MAAM,CAAC,MAAM;;;;;;;;;6BASc;iBAClB;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -5,7 +5,7 @@ import { execProcess } from '../../lib/exec.js';
5
5
  export function registerCodegenDbschemaIntrospect(server) {
6
6
  server.registerTool('codegen_dbschema_introspect', {
7
7
  title: 'Introspect Database into dbschema-kit Files',
8
- description: `Reverse-engineer an existing database into dbschema-kit definition files (factory function pattern), by wrapping restforge schema introspect. Useful for migrating legacy projects to declarative schema-as-code, or for capturing the current database structure under version control. Mode (single-table, bulk single-schema, bulk multi-schema, all-schemas) is derived from the combination of 'table', 'schema', 'allSchemas', and 'output'.
8
+ description: `Reverse-engineer an existing database into dbschema-kit definition files (factory function pattern), by wrapping restforge schema introspect. Useful for migrating legacy projects to declarative schema-as-code, or for capturing the current database structure under version control. Mode (single-table, bulk single-schema, bulk multi-schema, all-schemas) is derived from the combination of 'table', 'schema', and 'allSchemas'.
9
9
 
10
10
  USE WHEN:
11
11
  - The user asks to reverse-engineer a database, "buatkan schema dari database existing", "introspect DB ke schema files"
@@ -25,19 +25,21 @@ DO NOT USE FOR:
25
25
  - Modifying database schema (CREATE/ALTER/DROP) -> use 'codegen_dbschema_migrate'
26
26
  - Querying actual row data -> out of scope (returns metadata only)
27
27
 
28
- This tool runs: npx restforge schema introspect --config=<file> [--output=<path>] [--table=<name>] [--schema=<name>] [--all-schemas] [--force] [--dry-run] in the given cwd.
28
+ This tool runs: npx restforge schema introspect --config=<file> --schema-path=<path> [--table=<name>] [--schema=<name>] [--all-schemas] [--force] [--dry-run] in the given cwd.
29
29
  The mode is derived by the CLI from the flag combination. The MCP layer passes flags through and does not validate mutual exclusivity — the CLI is the single source of truth for mode resolution.
30
30
 
31
+ SOFT-DELETE STRICT BLOCK: on PostgreSQL, any table that has soft-delete columns (is_deleted/deleted_at/deleted_by) is validated against the soft-delete contract. A non-conforming table BLOCKS the whole introspect run with exit code 1 in three cases: (1) only a partial set of the three columns exists, (2) the columns exist but their types do not match the contract, or (3) the columns are complete and correctly typed but the consistency CHECK constraint is missing. The CLI error message starts with "[restforge] ERROR: introspect blocked for table '<name>'" and lists concrete mitigation options (complete the contract or drop the soft-delete columns; the missing-CHECK case includes a ready-to-run ALTER TABLE ... ADD CONSTRAINT statement). Relay that message and its options to the user — never report it as a generic failure. A fully conforming table introspects normally and the generated SDF carries softDelete: { enabled: true }.
32
+
31
33
  Preconditions:
32
34
  - The project must have @restforgejs/platform installed in node_modules.
33
35
  - The config file (default 'db-connection.env') must exist and contain valid database credentials.
34
- - 'output' is required unless 'dryRun' is true.
36
+ - 'schemaPath' is required for every mode. The CLI declares --schema-path as a required flag and rejects the call at parse level without it, even when 'dryRun' is true.
35
37
 
36
38
  PRESENTATION GUIDANCE:
37
39
  - Match the user's language. If the user writes in Indonesian, respond in Indonesian.
38
40
  - Never mention internal tool names in the reply to the user. Describe actions by what they do (e.g. "introspect the database", "validate the schema", "preview before writing").
39
41
  - Speak in plain language. Confirm the mode (single-table / bulk / dry-run) and the output target; do not paste raw CLI output unless the user explicitly asks.
40
- - Mode is derived from the combination of 'table', 'schema', 'allSchemas', and 'output'. Confirm with the user before invoking — different modes produce different file layouts (flat vs subfolder).
42
+ - Mode is derived from the combination of 'table', 'schema', and 'allSchemas'. Confirm with the user before invoking — different modes produce different file layouts (flat vs subfolder).
41
43
  - Without 'force', the tool refuses to overwrite existing files. If the user wants to refresh introspection, confirm before passing force=true.
42
44
  - 'dryRun=true' is the safe path for preview. Suggest dry-run first when the user is exploring an unfamiliar database.
43
45
  - This is a write operation in non-dry-run mode. Files in the output target may have been created or overwritten.
@@ -52,11 +54,10 @@ PRESENTATION GUIDANCE:
52
54
  .min(1)
53
55
  .default('db-connection.env')
54
56
  .describe('Config file name relative to the project, used by the CLI to connect to the database'),
55
- output: z
57
+ schemaPath: z
56
58
  .string()
57
59
  .min(1)
58
- .optional()
59
- .describe('Output target relative to cwd. Required unless dryRun=true. For single-table mode: a .js file path; for bulk modes: a folder path. Multi-schema bulk uses subfolders inside this folder.'),
60
+ .describe('Schema output target relative to cwd, mapped to the CLI flag --schema-path. Required for every mode, including dry-run. For single-table mode: a .js file path; for bulk modes: a folder path. Multi-schema bulk uses subfolders inside this folder.'),
60
61
  table: z
61
62
  .string()
62
63
  .min(1)
@@ -85,7 +86,7 @@ PRESENTATION GUIDANCE:
85
86
  destructiveHint: false, // writes files (and may overwrite with force=true), but no live DB mutation; reversible by deleting outputs
86
87
  idempotentHint: false, // first call writes new files; subsequent calls behave differently depending on force
87
88
  },
88
- }, async ({ cwd, config, output, table, schema, allSchemas, force, dryRun }) => {
89
+ }, async ({ cwd, config, schemaPath, table, schema, allSchemas, force, dryRun }) => {
89
90
  const projectCwd = resolve(cwd);
90
91
  // Precondition check: @restforgejs/platform must be present in node_modules. per §3.4
91
92
  try {
@@ -101,7 +102,7 @@ PRESENTATION GUIDANCE:
101
102
  Project path: ${projectCwd}
102
103
  Expected location: node_modules/@restforgejs/platform
103
104
  Requested config: ${config}
104
- Requested output: ${output ?? '(none)'}
105
+ Requested schemaPath: ${schemaPath}
105
106
  Requested table: ${table ?? '(none)'}
106
107
  Requested schema: ${schema ?? '(none)'}
107
108
  Requested allSchemas: ${allSchemas ?? false}
@@ -119,9 +120,7 @@ For the assistant:
119
120
  }
120
121
  // Forward only the arguments the user supplied. The CLI handles mode resolution
121
122
  // and mutual-exclusivity rules. per §3.5
122
- const cliArgs = ['restforge', 'schema', 'introspect', `--config=${config}`];
123
- if (output !== undefined)
124
- cliArgs.push(`--output=${output}`);
123
+ const cliArgs = ['restforge', 'schema', 'introspect', `--config=${config}`, `--schema-path=${schemaPath}`];
125
124
  if (table !== undefined)
126
125
  cliArgs.push(`--table=${table}`);
127
126
  if (schema !== undefined)
@@ -138,9 +137,15 @@ For the assistant:
138
137
  env: { NODE_ENV: 'production' },
139
138
  stripFinalNewline: true,
140
139
  });
141
- // The CLI uses exit code 2 to signal "dry-run completed successfully". execProcess
142
- // treats only exit 0 as success, so we re-route exit 2 back into the success branch.
143
- const isDryRunSuccess = !result.success && result.exitCode === 2;
140
+ // The CLI signals "dry-run completed" with exit code 2 (it throws 'schema introspect
141
+ // dry-run complete' with exitCode=2), but usage errors also exit 2. Exit 2 only counts
142
+ // as dry-run success when dry-run was actually requested AND the combined output carries
143
+ // the dry-run completion marker; any other exit 2 falls through to the error branch.
144
+ // per D-00.2 / D-00.6
145
+ const combinedOutput = `${result.stdout}\n${result.stderr}`;
146
+ const isDryRunSuccess = dryRun === true &&
147
+ result.exitCode === 2 &&
148
+ /dry-run complete/i.test(combinedOutput);
144
149
  // Branch C: real CLI failure (any non-zero exit other than dry-run sentinel). per §3.4
145
150
  if (!result.success && !isDryRunSuccess) {
146
151
  return {
@@ -151,7 +156,7 @@ For the assistant:
151
156
 
152
157
  Project path: ${projectCwd}
153
158
  Config: ${config}
154
- Output: ${output ?? '(none)'}
159
+ SchemaPath: ${schemaPath}
155
160
  Table: ${table ?? '(none)'}
156
161
  Schema: ${schema ?? '(none)'}
157
162
  allSchemas: ${allSchemas ?? false}
@@ -173,9 +178,10 @@ For the assistant:
173
178
  - Summarise the most likely cause from the CLI output in plain language. Common causes:
174
179
  * Config file not found — suggest verifying the config path and that the file exists.
175
180
  * Database connection failed — suggest verifying credentials, host, and port.
176
- * Output target missing or invalid (the CLI requires --output unless --dry-run).
177
- * Output file exists without --force — suggest passing force=true if the user really wants to overwrite, or picking a different output path.
181
+ * Schema path missing or invalid the CLI requires --schema-path for every mode, including dry-run.
182
+ * Output file exists without --force — suggest passing force=true if the user really wants to overwrite, or picking a different schema path.
178
183
  * Conflicting flags — e.g. table together with allSchemas, or schema together with allSchemas. The CLI rejects these combinations; suggest picking a single mode.
184
+ * Soft-delete contract violation (PostgreSQL) — the output contains "introspect blocked for table". This is a strict block, NOT a generic failure: the message lists the exact non-conformance (partial columns, wrong types, or missing consistency CHECK) and concrete mitigation options (possibly including a ready-to-run ALTER TABLE statement). Present the full blocked-table message including its options to the user — this is an exception to the no-paste rule below.
179
185
  * Unknown command 'schema introspect' — the installed RESTForge version may be older than this CLI subcommand; suggest upgrading the package.
180
186
  - Do not paste the raw stdout/stderr unless the user explicitly asks. Do not mention internal tool names.
181
187
  - Offer to retry once the issue is resolved.`,
@@ -216,7 +222,7 @@ For the assistant:
216
222
  Project path: ${projectCwd}
217
223
  Config: ${config}
218
224
  Mode: ${modeLabel}
219
- Output target: ${output ?? '(none — dry-run)'}
225
+ Schema path: ${schemaPath}
220
226
  Table: ${table ?? '(not specified)'}
221
227
  Schema: ${schema ?? '(not specified)'}
222
228
  allSchemas: ${allSchemas ?? false}
@@ -1 +1 @@
1
- {"version":3,"file":"dbschema-introspect.js","sourceRoot":"","sources":["../../../src/tools/codegen/dbschema-introspect.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,6BAA6B,EAC7B;QACE,KAAK,EAAE,6CAA6C;QACpD,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uGAoCoF;QACjG,WAAW,EAAE;YACX,GAAG,EAAE,CAAC;iBACH,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CAAC,2GAA2G,CAAC;YACxH,MAAM,EAAE,CAAC;iBACN,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,OAAO,CAAC,mBAAmB,CAAC;iBAC5B,QAAQ,CAAC,sFAAsF,CAAC;YACnG,MAAM,EAAE,CAAC;iBACN,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,EAAE;iBACV,QAAQ,CAAC,0LAA0L,CAAC;YACvM,KAAK,EAAE,CAAC;iBACL,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,EAAE;iBACV,QAAQ,CAAC,8IAA8I,CAAC;YAC3J,MAAM,EAAE,CAAC;iBACN,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,EAAE;iBACV,QAAQ,CAAC,uIAAuI,CAAC;YACpJ,UAAU,EAAE,CAAC;iBACV,OAAO,EAAE;iBACT,QAAQ,EAAE;iBACV,QAAQ,CAAC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