@simetrajs/designer 0.1.0 → 0.3.0-next.1

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 (29) hide show
  1. package/README.md +39 -4
  2. package/dist/{command-CRUaUglx.js → command-CHk1P9Dp.js} +91 -108
  3. package/dist/default-dir-DerxTbci.js +158 -0
  4. package/dist/errors-D1P2kKbL.js +62 -0
  5. package/dist/init-jr0Xsrpp.js +832 -0
  6. package/dist/invoke-BwP_5iN6.js +2676 -0
  7. package/dist/main.js +6 -6
  8. package/dist/mcp-args-D63akJ97.js +56 -0
  9. package/dist/mcp-jLOz0W7f.js +219 -0
  10. package/dist/package-hA0J8AMK.js +4 -0
  11. package/dist/{schema-engine-DAsJEc8K.js → schema-engine-8rVHcVYO.js} +704 -195
  12. package/dist/{types-CSc8XWLd.js → types-CMcZhIci.js} +8 -3
  13. package/package.json +16 -12
  14. package/skills/simetra-adoption/SKILL.md +82 -3
  15. package/skills/simetra-metadata/SKILL.md +126 -136
  16. package/skills/simetra-metadata/references/agents-over-mcp.md +236 -0
  17. package/skills/simetra-metadata/references/attribute-load-and-size.md +57 -0
  18. package/skills/simetra-metadata/references/list-order-indexes.md +17 -0
  19. package/skills/simetra-metadata/references/object-modules.md +78 -0
  20. package/skills/simetra-metadata/references/people-and-rights.md +702 -9
  21. package/skills/simetra-metadata/references/plan-and-apply.md +81 -0
  22. package/skills/simetra-metadata/references/project-setup.md +28 -0
  23. package/skills/simetra-metadata/references/row-version-epoch.md +39 -0
  24. package/skills/simetra-metadata/references/search-fields.md +28 -0
  25. package/skills/simetra-metadata/references/sql-trust-boundary.md +225 -0
  26. package/dist/errors-D5pJLrjP.js +0 -36
  27. package/dist/mcp-CJDCleh-.js +0 -241
  28. package/dist/package-DDuGk6yE.js +0 -5
  29. package/dist/report-D2jBS_04.js +0 -1550
@@ -1,241 +0,0 @@
1
- #!/usr/bin/env node
2
- import { t as version } from "./package-DDuGk6yE.js";
3
- import { c as DEFAULT_DATABASE_URL_ENV, d as TOOLS, h as databaseResource, i as renderPlan, l as databaseWriteHint, n as renderApply, o as trimSlash, r as renderDiff, s as invoke, t as formatDiagnostics, u as readOnlyHint } from "./report-D2jBS_04.js";
4
- import { defineCommand } from "citty";
5
- import { z } from "zod";
6
- import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
7
- import { McpServer } from "@modelcontextprotocol/server";
8
- //#region src/mcp/tools.ts
9
- const dryRun = z.boolean().optional().meta({ description: "Report the changes without writing them." });
10
- const confirm = z.boolean().optional().meta({ description: "Must be true to actually perform a destructive change." });
11
- /**
12
- * Схема входу MCP = вхід каталогу плюс транспортні поля. Дозвіл, підтвердження
13
- * й запис вирішує `invoke`, тож тут лише перелік полів, які він отримує.
14
- */
15
- function mcpInputSchema(tool) {
16
- let previews;
17
- switch (tool.files) {
18
- case "read":
19
- case "artifact":
20
- previews = false;
21
- break;
22
- case "write": previews = true;
23
- }
24
- if (!previews && !tool.destructive) return tool.input;
25
- if (!(tool.input instanceof z.ZodObject)) throw new Error(`tool ${tool.name} needs an object input for dryRun/confirm`);
26
- return tool.input.extend({
27
- ...previews ? { dryRun } : {},
28
- ...tool.destructive ? { confirm } : {}
29
- });
30
- }
31
- function lineFor(c, written) {
32
- if (written) return `${c.deleted ? "deleted" : "written"} ${c.path}`;
33
- return `${c.deleted ? "would delete" : "would write"} ${c.path}`;
34
- }
35
- function toResponse(tool, result, o, dry) {
36
- const { ok, written, changes, diagnostics, refusal } = result;
37
- if (refusal !== void 0) return {
38
- isError: true,
39
- structuredContent: {
40
- ok,
41
- written,
42
- changes,
43
- diagnostics
44
- },
45
- content: [{
46
- type: "text",
47
- text: refusal.message
48
- }]
49
- };
50
- if (tool.name === "explain" && ok && result.data !== void 0) return {
51
- structuredContent: { ...result.data },
52
- content: [{
53
- type: "text",
54
- text: JSON.stringify(result.data, null, 2)
55
- }]
56
- };
57
- const report = formatDiagnostics(diagnostics, {
58
- dir: o.dir,
59
- locale: "en",
60
- format: "text"
61
- });
62
- if (tool.name === "diff" && result.data !== void 0) {
63
- const data = result.data;
64
- return {
65
- isError: !ok,
66
- structuredContent: {
67
- ok,
68
- written,
69
- changes,
70
- ...data
71
- },
72
- content: [{
73
- type: "text",
74
- text: renderDiff(data, report)
75
- }]
76
- };
77
- }
78
- if (tool.name === "plan") {
79
- const data = result.data;
80
- return {
81
- isError: !ok,
82
- structuredContent: {
83
- ok,
84
- written,
85
- artifacts: result.artifacts ?? [],
86
- diagnostics,
87
- ...data
88
- },
89
- content: [{
90
- type: "text",
91
- text: renderPlan(data, report, {
92
- ok,
93
- written
94
- })
95
- }]
96
- };
97
- }
98
- if (tool.name === "apply") {
99
- const data = result.data;
100
- return {
101
- isError: !ok,
102
- structuredContent: {
103
- ok,
104
- written,
105
- artifacts: result.artifacts ?? [],
106
- diagnostics,
107
- ...data
108
- },
109
- content: [{
110
- type: "text",
111
- text: renderApply(data, diagnostics, report)
112
- }]
113
- };
114
- }
115
- const record = tool.name === "promote" ? result.data : void 0;
116
- const databaseFailed = diagnostics.some((d) => d.code === "database.failed");
117
- const databaseUnreadable = diagnostics.some((d) => d.code === "engine.owner-not-member");
118
- const lines = ok ? [
119
- ...changes.map((c) => lineFor(c, written)),
120
- ...dry && tool.files === "write" ? ["dry run: nothing written"] : [],
121
- ...tool.files === "read" ? [`${tool.name}: no errors`] : []
122
- ] : databaseFailed ? [`${tool.files === "write" ? "nothing written" : tool.name}: the database work failed`] : databaseUnreadable ? [`${tool.name}: the database has objects the engine cannot read`] : tool.files === "write" ? ["nothing written: the operation was refused or the result has errors"] : [`${tool.name}: the metadata has errors`];
123
- return {
124
- isError: !ok,
125
- structuredContent: {
126
- ok,
127
- written,
128
- changes,
129
- diagnostics,
130
- ...tool.name === "introspect" && result.data !== void 0 ? result.data : {},
131
- ...record === void 0 ? {} : { record }
132
- },
133
- content: [{
134
- type: "text",
135
- text: [
136
- ...lines,
137
- report,
138
- ...record === void 0 ? [] : ["promotion record:", JSON.stringify(record, null, 2)]
139
- ].join("\n")
140
- }]
141
- };
142
- }
143
- /** Реєструє весь каталог: транспорт лише переказує `confirm`/`dryRun` у `invoke`. */
144
- function registerCatalog(server, o) {
145
- for (const tool of TOOLS) server.registerTool(tool.name, {
146
- description: tool.description,
147
- inputSchema: mcpInputSchema(tool),
148
- annotations: {
149
- readOnlyHint: tool.files === "read" && tool.database !== "write",
150
- destructiveHint: tool.destructive
151
- }
152
- }, async (args) => {
153
- const { dryRun: dry, confirm: confirmed, ...input } = args ?? {};
154
- const result = await invoke(tool, input, {
155
- dir: o.dir,
156
- readOnly: o.readOnly,
157
- allowDatabaseWrite: o.allowDatabaseWrite === true,
158
- dryRun: dry === true,
159
- confirmed: confirmed === true,
160
- channel: "mcp",
161
- database: o.database,
162
- ...o.databaseEnv === void 0 ? {} : { databaseEnv: o.databaseEnv },
163
- launchArgs: o.launchArgs
164
- });
165
- return toResponse(tool, result, o, dry === true);
166
- });
167
- }
168
- //#endregion
169
- //#region src/mcp/server.ts
170
- /**
171
- * Сервер не знає транспорту: stdio підключає команда, тести — пару в пам'яті.
172
- * Інструменти запису видно завжди: з `--read-only` вони відмовляють із
173
- * поясненням, а не зникають, тож агент знає, що запис існує, і що саме
174
- * увімкнути.
175
- */
176
- function createMcpServer(o) {
177
- const instructions = [
178
- `Metadata tools for the directory ${o.dir}: compile, explain, the editing tools, and introspect, diff, plan and apply against the database named by the server's environment.`,
179
- o.readOnly ? readOnlyHint(o.launchArgs) : "Writing is enabled; destructive tools need confirm: true, and dryRun previews any file change.",
180
- ...o.readOnly ? [] : [o.allowDatabaseWrite === true ? "Database writes are enabled: apply needs confirm: true and the planHash of the plan you showed." : databaseWriteHint(o.launchArgs, { refusal: false })],
181
- "dryRun does not apply to apply: review with plan, and rehearse it before applying."
182
- ].join(" ");
183
- const server = new McpServer({
184
- name: "simetra",
185
- version
186
- }, { instructions });
187
- registerCatalog(server, o);
188
- return server;
189
- }
190
- //#endregion
191
- //#region src/commands/mcp.ts
192
- var mcp_default = defineCommand({
193
- meta: {
194
- name: "mcp",
195
- description: "Serve the compiler operations over MCP (stdio)"
196
- },
197
- args: {
198
- dir: {
199
- type: "positional",
200
- description: "Metadata directory (default: ./metadata)",
201
- required: false
202
- },
203
- "read-only": {
204
- type: "boolean",
205
- default: false,
206
- description: "Refuse the tools that write"
207
- },
208
- "allow-database-write": {
209
- type: "boolean",
210
- default: false,
211
- description: "Let apply write to the database (it still needs confirm and the plan hash)"
212
- },
213
- "database-url-env": {
214
- type: "string",
215
- default: DEFAULT_DATABASE_URL_ENV,
216
- description: "Environment variable with the connection string of the target database"
217
- },
218
- "shadow-url-env": {
219
- type: "string",
220
- description: "Environment variable with a connection string to another server of the same PostgreSQL major version for the shadow database"
221
- }
222
- },
223
- async run({ args }) {
224
- const dir = trimSlash(args.dir ?? "./metadata");
225
- const databaseEnv = args["database-url-env"];
226
- const shadow = args["shadow-url-env"];
227
- await createMcpServer({
228
- dir,
229
- readOnly: args["read-only"],
230
- allowDatabaseWrite: args["allow-database-write"],
231
- database: databaseResource(process.env, {
232
- url: databaseEnv,
233
- ...shadow === void 0 ? {} : { shadow }
234
- }),
235
- databaseEnv,
236
- launchArgs: process.argv.slice(2)
237
- }).connect(new StdioServerTransport());
238
- }
239
- });
240
- //#endregion
241
- export { mcp_default as default };
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- //#region package.json
3
- var version = "0.1.0";
4
- //#endregion
5
- export { version as t };