@simetrajs/designer 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +79 -2
- package/dist/command-BCAw6Fsb.js +794 -0
- package/dist/default-dir-DerxTbci.js +158 -0
- package/dist/errors-Brw6UjAD.js +35 -0
- package/dist/init-jr0Xsrpp.js +832 -0
- package/dist/main.js +29 -0
- package/dist/mcp-ChltmHBb.js +277 -0
- package/dist/mcp-args-D63akJ97.js +56 -0
- package/dist/package-Dg3MXPve.js +4 -0
- package/dist/report-DV4deFdu.js +2059 -0
- package/dist/schema-engine-DPPnife2.js +2809 -0
- package/dist/types-iWavtmdS.js +31 -0
- package/package.json +67 -3
- package/skills/simetra-adoption/SKILL.md +185 -0
- package/skills/simetra-metadata/SKILL.md +494 -0
- package/skills/simetra-metadata/references/agents-over-mcp.md +119 -0
- package/skills/simetra-metadata/references/object-modules.md +60 -0
- package/skills/simetra-metadata/references/people-and-rights.md +757 -0
- package/skills/simetra-metadata/references/project-setup.md +28 -0
- package/skills/simetra-metadata/references/sql-trust-boundary.md +194 -0
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { a as invoke, c as summarizeData, d as writeChanges, f as checkEnvName, h as databaseResource, i as renderPlan, m as parseDataLaunch, n as renderApply, p as dataResource, r as renderDiff, s as toolByName, t as formatDiagnostics, u as isMetadataFile } from "./report-DV4deFdu.js";
|
|
3
|
+
import { i as DEFAULT_DATABASE_URL_ENV, n as trimSlash, p as UsageError, t as DEFAULT_DIR } from "./default-dir-DerxTbci.js";
|
|
4
|
+
import { defineCommand } from "citty";
|
|
5
|
+
import { mkdtemp, readdir, rm, stat } from "node:fs/promises";
|
|
6
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
7
|
+
import { ATTRIBUTE_CASES, DATABASE_PROVIDERS, METADATA_KINDS } from "simetra/model";
|
|
8
|
+
import { DEFAULT_APPLY_TIMEOUTS, renderDesiredState } from "simetra/schema";
|
|
9
|
+
import { buildRuntimeCatalog, canonicalSnapshot, emitEntityTypes } from "simetra/compiler";
|
|
10
|
+
import { spawn } from "node:child_process";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
// src/tools/artifacts.ts
|
|
13
|
+
/**
|
|
14
|
+
* Артефакти компіляції як зміни файлів: рішення, куди й чи писати, ухвалює
|
|
15
|
+
* адаптер (`compile --out`), тут лише вміст.
|
|
16
|
+
*/
|
|
17
|
+
function compileArtifacts(model) {
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
path: "snapshot.json",
|
|
21
|
+
content: `${JSON.stringify(canonicalSnapshot(model), null, 2)}\n`
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
path: "desired-state.sql",
|
|
25
|
+
content: renderDesiredState(model).sql
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
path: "entities.d.ts",
|
|
29
|
+
content: emitEntityTypes(model)
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
path: "runtime-catalog.json",
|
|
33
|
+
content: `${JSON.stringify(buildRuntimeCatalog(model), null, 2)}\n`
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
// src/cli/metadata-dirs.ts
|
|
38
|
+
const PROJECT_FILE = "project.meta.json";
|
|
39
|
+
function git(cwd, args, input) {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const child = spawn("git", args, { cwd });
|
|
42
|
+
const out = [];
|
|
43
|
+
const err = [];
|
|
44
|
+
child.stdout.on("data", (c) => out.push(c));
|
|
45
|
+
child.stderr.on("data", (c) => err.push(c));
|
|
46
|
+
child.on("error", (error) => reject(error.code === "ENOENT" ? new UsageError("git is not installed or not on PATH") : error));
|
|
47
|
+
child.on("close", (status) => resolve({
|
|
48
|
+
status: status ?? 1,
|
|
49
|
+
stdout: Buffer.concat(out).toString("utf8"),
|
|
50
|
+
stderr: Buffer.concat(err).toString("utf8")
|
|
51
|
+
}));
|
|
52
|
+
child.stdin.on("error", () => void 0);
|
|
53
|
+
child.stdin.end(input);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async function isGitRepo(cwd) {
|
|
57
|
+
return (await git(cwd, ["rev-parse", "--is-inside-work-tree"])).status === 0;
|
|
58
|
+
}
|
|
59
|
+
const nulList = (s) => s.split("\0").filter(Boolean);
|
|
60
|
+
/** Обхід без Git: у `node_modules` і `.git` не спускаємось — метаданих проєкту там немає. */
|
|
61
|
+
async function walk(cwd, rel = "") {
|
|
62
|
+
const entries = await readdir(join(cwd, rel), { withFileTypes: true });
|
|
63
|
+
const found = [];
|
|
64
|
+
if (rel !== "" && basename(rel).endsWith("metadata") && entries.some((e) => e.isFile() && e.name === PROJECT_FILE)) found.push(rel);
|
|
65
|
+
for (const e of entries) {
|
|
66
|
+
if (!e.isDirectory() || e.name === "node_modules" || e.name === ".git") continue;
|
|
67
|
+
found.push(...await walk(cwd, rel === "" ? e.name : `${rel}/${e.name}`));
|
|
68
|
+
}
|
|
69
|
+
return found.sort();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Теки метаданих у поточній теці й нижче: у Git — відстежені `*metadata/project.meta.json`
|
|
73
|
+
* (pathspec `*` перетинає `/`, тож збігаються корінь і вкладені теки); поза
|
|
74
|
+
* Git — обхід файлової системи.
|
|
75
|
+
*/
|
|
76
|
+
async function findMetadataDirs(cwd) {
|
|
77
|
+
if (!await isGitRepo(cwd).catch((error) => {
|
|
78
|
+
if (error instanceof UsageError) return false;
|
|
79
|
+
throw error;
|
|
80
|
+
})) return walk(cwd);
|
|
81
|
+
const r = await git(cwd, [
|
|
82
|
+
"ls-files",
|
|
83
|
+
"-z",
|
|
84
|
+
"--",
|
|
85
|
+
`*metadata/${PROJECT_FILE}`
|
|
86
|
+
]);
|
|
87
|
+
if (r.status !== 0) throw new UsageError(r.stderr.trim());
|
|
88
|
+
return nulList(r.stdout).map((f) => dirname(f));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Вміст індексу Git для зазначених тек у тимчасовій теці: pre-commit перевіряє
|
|
92
|
+
* те, що буде закомічено, а не робоче дерево. Поза Git індексу немає.
|
|
93
|
+
*/
|
|
94
|
+
async function stageMetadataDirs(cwd, dirs) {
|
|
95
|
+
if (!await isGitRepo(cwd)) throw new UsageError(`--staged: not a git repository: ${cwd}`);
|
|
96
|
+
const top = await git(cwd, [
|
|
97
|
+
"rev-parse",
|
|
98
|
+
"--show-toplevel",
|
|
99
|
+
"--show-prefix"
|
|
100
|
+
]);
|
|
101
|
+
if (top.status !== 0) throw new UsageError(top.stderr.trim());
|
|
102
|
+
const [toplevel = cwd, prefix = ""] = top.stdout.split("\n");
|
|
103
|
+
const root = await mkdtemp(join(tmpdir(), "simetra-staged-"));
|
|
104
|
+
const dispose = () => rm(root, {
|
|
105
|
+
recursive: true,
|
|
106
|
+
force: true
|
|
107
|
+
});
|
|
108
|
+
try {
|
|
109
|
+
const list = await git(cwd, [
|
|
110
|
+
"ls-files",
|
|
111
|
+
"-z",
|
|
112
|
+
"--cached",
|
|
113
|
+
"--full-name",
|
|
114
|
+
"--",
|
|
115
|
+
...dirs
|
|
116
|
+
]);
|
|
117
|
+
if (list.status !== 0) throw new UsageError(list.stderr.trim());
|
|
118
|
+
const files = nulList(list.stdout);
|
|
119
|
+
const out = await git(toplevel, [
|
|
120
|
+
"checkout-index",
|
|
121
|
+
`--prefix=${root}/`,
|
|
122
|
+
"-z",
|
|
123
|
+
"--stdin"
|
|
124
|
+
], files.length > 0 ? files.join("\0") + "\0" : "");
|
|
125
|
+
if (out.status !== 0) throw new UsageError(out.stderr.trim());
|
|
126
|
+
} catch (error) {
|
|
127
|
+
await dispose();
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
root,
|
|
132
|
+
dirs: dirs.map((d) => join(root, prefix, d)),
|
|
133
|
+
dispose
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Один запуск `git cat-file --batch` на всі блоби: формат відповіді —
|
|
138
|
+
* `<sha> blob <size>\n<content>\n`, тож розбираємо за довжиною в байтах.
|
|
139
|
+
*/
|
|
140
|
+
async function readBlobs(cwd, shas) {
|
|
141
|
+
const out = await new Promise((res, rej) => {
|
|
142
|
+
const child = spawn("git", ["cat-file", "--batch"], { cwd });
|
|
143
|
+
const chunks = [];
|
|
144
|
+
child.stdout.on("data", (c) => chunks.push(c));
|
|
145
|
+
child.on("error", rej);
|
|
146
|
+
child.on("close", (status) => status === 0 ? res(Buffer.concat(chunks)) : rej(new UsageError("git cat-file failed")));
|
|
147
|
+
child.stdin.on("error", () => void 0);
|
|
148
|
+
child.stdin.end(shas.map((s) => `${s}\n`).join(""));
|
|
149
|
+
});
|
|
150
|
+
const texts = [];
|
|
151
|
+
let at = 0;
|
|
152
|
+
for (const sha of shas) {
|
|
153
|
+
const eol = out.indexOf(10, at);
|
|
154
|
+
const header = out.subarray(at, eol).toString("utf8").split(" ");
|
|
155
|
+
if (header[0] !== sha || header[1] !== "blob") throw new UsageError(`git cat-file: unexpected object ${sha}`);
|
|
156
|
+
const size = Number(header[2]);
|
|
157
|
+
texts.push(out.subarray(eol + 1, eol + 1 + size).toString("utf8"));
|
|
158
|
+
at = eol + 1 + size + 1;
|
|
159
|
+
}
|
|
160
|
+
return texts;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Базовий стан теки метаданих — її вміст у коміті `HEAD`: за ним компілятор
|
|
164
|
+
* перевіряє поля, призначені раз. `undefined` — поза git (перевірки немає);
|
|
165
|
+
* порожня мапа — коміту ще немає або теки в ньому немає (усе нове). Ключі —
|
|
166
|
+
* шляхи відносно теки, як у `readMetadataDir`.
|
|
167
|
+
*/
|
|
168
|
+
async function readHeadMetadata(cwd, dir) {
|
|
169
|
+
const at = resolve(cwd, dir);
|
|
170
|
+
if (!await stat(at).then((s) => s.isDirectory(), () => false)) return;
|
|
171
|
+
if (!await isGitRepo(at).catch((error) => {
|
|
172
|
+
if (error instanceof UsageError) return false;
|
|
173
|
+
throw error;
|
|
174
|
+
})) return void 0;
|
|
175
|
+
const top = await git(at, ["rev-parse", "--show-prefix"]);
|
|
176
|
+
if (top.status !== 0) throw new UsageError(top.stderr.trim());
|
|
177
|
+
const prefix = top.stdout.trim().replace(/\/$/, "");
|
|
178
|
+
const tree = await git(at, [
|
|
179
|
+
"ls-tree",
|
|
180
|
+
"-r",
|
|
181
|
+
"-z",
|
|
182
|
+
"--full-name",
|
|
183
|
+
"HEAD",
|
|
184
|
+
"--",
|
|
185
|
+
"."
|
|
186
|
+
]);
|
|
187
|
+
if (tree.status !== 0) {
|
|
188
|
+
if ((await git(at, [
|
|
189
|
+
"rev-parse",
|
|
190
|
+
"--verify",
|
|
191
|
+
"-q",
|
|
192
|
+
"HEAD"
|
|
193
|
+
])).status !== 0) return /* @__PURE__ */ new Map();
|
|
194
|
+
throw new UsageError(tree.stderr.trim());
|
|
195
|
+
}
|
|
196
|
+
const entries = [];
|
|
197
|
+
for (const record of nulList(tree.stdout)) {
|
|
198
|
+
const tab = record.indexOf(" ");
|
|
199
|
+
const [, type, sha] = record.slice(0, tab).split(" ");
|
|
200
|
+
const path = record.slice(tab + 1);
|
|
201
|
+
if (type !== "blob" || sha === void 0) continue;
|
|
202
|
+
const key = prefix === "" ? path : path.slice(prefix.length + 1);
|
|
203
|
+
if (!isMetadataFile(key)) continue;
|
|
204
|
+
entries.push({
|
|
205
|
+
key,
|
|
206
|
+
sha
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const texts = entries.length === 0 ? [] : await readBlobs(at, entries.map((e) => e.sha));
|
|
210
|
+
return new Map(entries.map((e, i) => [e.key, texts[i] ?? ""]));
|
|
211
|
+
}
|
|
212
|
+
// src/cli/input.ts
|
|
213
|
+
/**
|
|
214
|
+
* Читальні інструменти й `fix` мають зручні позиційні форми — це лише вигляд
|
|
215
|
+
* над тим самим входом каталогу. Усі інші беруть вхід каталогу як JSON.
|
|
216
|
+
*/
|
|
217
|
+
const ERGONOMIC = /* @__PURE__ */ new Set([
|
|
218
|
+
"compile",
|
|
219
|
+
"explain",
|
|
220
|
+
"fix",
|
|
221
|
+
"introspect",
|
|
222
|
+
"diff",
|
|
223
|
+
"plan",
|
|
224
|
+
"apply",
|
|
225
|
+
"roles"
|
|
226
|
+
]);
|
|
227
|
+
/** `a,b` → `["a", "b"]`; порожні елементи — помилка написання, не фільтр. */
|
|
228
|
+
function list(flag, value) {
|
|
229
|
+
const items = value.split(",").map((s) => s.trim());
|
|
230
|
+
if (items.some((s) => s === "")) throw new UsageError(`--${flag} expects a comma-separated list, got "${value}".`);
|
|
231
|
+
return items;
|
|
232
|
+
}
|
|
233
|
+
function takesJsonInput(tool) {
|
|
234
|
+
return !ERGONOMIC.has(tool.name);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Переводить argv у вхід каталогу й список тек. Тут лише форма введення:
|
|
238
|
+
* перевірку входу робить схема каталогу в `invoke`.
|
|
239
|
+
*/
|
|
240
|
+
async function cliInput(tool, args, stdin) {
|
|
241
|
+
const positional = args._;
|
|
242
|
+
if (tool.name === "compile") return {
|
|
243
|
+
input: {},
|
|
244
|
+
dirs: (positional.length > 0 ? positional : [DEFAULT_DIR]).map(trimSlash)
|
|
245
|
+
};
|
|
246
|
+
if (tool.name === "explain") {
|
|
247
|
+
const target = positional[0] ?? "";
|
|
248
|
+
const dot = target.indexOf(".");
|
|
249
|
+
if (dot <= 0 || dot === target.length - 1) throw new UsageError(`Invalid target "${target}". Expected <Kind>.<Name>, e.g. Document.ServiceAccrual (kinds: ${METADATA_KINDS.join(", ")}).`);
|
|
250
|
+
return {
|
|
251
|
+
input: {
|
|
252
|
+
kind: target.slice(0, dot),
|
|
253
|
+
name: target.slice(dot + 1)
|
|
254
|
+
},
|
|
255
|
+
dirs: [trimSlash(positional[1] ?? "./metadata")]
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
if (tool.name === "fix") return {
|
|
259
|
+
input: {},
|
|
260
|
+
dirs: [trimSlash(positional[0] ?? "./metadata")]
|
|
261
|
+
};
|
|
262
|
+
if (tool.name === "introspect") {
|
|
263
|
+
const name = args["project-name"];
|
|
264
|
+
const attributeCase = args["attribute-case"];
|
|
265
|
+
const provider = args["database-provider"];
|
|
266
|
+
const project = {
|
|
267
|
+
...name === void 0 ? {} : { name },
|
|
268
|
+
...attributeCase === void 0 ? {} : { attributeCase },
|
|
269
|
+
...provider === void 0 ? {} : { database: { provider } }
|
|
270
|
+
};
|
|
271
|
+
return {
|
|
272
|
+
input: {
|
|
273
|
+
...args.schemas === void 0 ? {} : { schemas: list("schemas", args.schemas) },
|
|
274
|
+
...Object.keys(project).length === 0 ? {} : { project }
|
|
275
|
+
},
|
|
276
|
+
dirs: [trimSlash(positional[0] ?? "./metadata")]
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
if (tool.name === "diff") return {
|
|
280
|
+
input: args.tables === void 0 ? {} : { tables: list("tables", args.tables) },
|
|
281
|
+
dirs: [trimSlash(positional[0] ?? "./metadata")]
|
|
282
|
+
};
|
|
283
|
+
if (tool.name === "plan" || tool.name === "roles") return {
|
|
284
|
+
input: {},
|
|
285
|
+
dirs: [trimSlash(positional[0] ?? "./metadata")]
|
|
286
|
+
};
|
|
287
|
+
if (tool.name === "apply") {
|
|
288
|
+
const plan = positional[0];
|
|
289
|
+
if (plan === void 0) throw new UsageError("apply needs the plan file: simetra apply <plans/….plan.json> [dir] --plan-hash <hex> --yes.");
|
|
290
|
+
const lockTimeout = args["lock-timeout-ms"];
|
|
291
|
+
const statementTimeout = args["statement-timeout-ms"];
|
|
292
|
+
return {
|
|
293
|
+
input: {
|
|
294
|
+
plan,
|
|
295
|
+
...args["plan-hash"] === void 0 ? {} : { planHash: args["plan-hash"] },
|
|
296
|
+
...args.allow === void 0 ? {} : { allow: list("allow", args.allow) },
|
|
297
|
+
...args.rehearse === true ? { rehearse: true } : {},
|
|
298
|
+
...lockTimeout === void 0 ? {} : { lockTimeoutMs: Number(lockTimeout) },
|
|
299
|
+
...statementTimeout === void 0 ? {} : { statementTimeoutMs: Number(statementTimeout) }
|
|
300
|
+
},
|
|
301
|
+
dirs: [trimSlash(positional[1] ?? "./metadata")]
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
const fromFlag = args.input !== void 0;
|
|
305
|
+
const raw = fromFlag ? args.input : positional[0];
|
|
306
|
+
if (raw === void 0) throw new UsageError(`${tool.name} needs its input as JSON: <json|-> [dir] or --input <json> [dir].`);
|
|
307
|
+
const text = raw === "-" ? await stdin() : raw;
|
|
308
|
+
let input;
|
|
309
|
+
try {
|
|
310
|
+
input = JSON.parse(text);
|
|
311
|
+
} catch (error) {
|
|
312
|
+
throw new UsageError(`Input is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
313
|
+
}
|
|
314
|
+
const rest = fromFlag ? positional : positional.slice(1);
|
|
315
|
+
return {
|
|
316
|
+
input,
|
|
317
|
+
dirs: [trimSlash(rest[0] ?? "./metadata")]
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
// src/cli/render.ts
|
|
321
|
+
/** Текст пояснення об'єкта для терміналу; JSON-вигляд друкується як є. */
|
|
322
|
+
function renderExplanation(e) {
|
|
323
|
+
const lines = [`${e.object.kind} ${e.object.name} (${e.object.file})`];
|
|
324
|
+
if (e.object.scopeKind !== void 0) lines.push(`scope: ${e.object.scopeKind}`);
|
|
325
|
+
for (const t of e.tables) {
|
|
326
|
+
lines.push("", `table ${t.schema}.${t.name}${t.part ? ` [${t.part}]` : ""}`);
|
|
327
|
+
for (const c of t.columns) {
|
|
328
|
+
const tags = [
|
|
329
|
+
c.notNull ? "not null" : void 0,
|
|
330
|
+
c.logical === void 0 ? void 0 : `logical: ${c.logical}`,
|
|
331
|
+
c.standard === void 0 ? void 0 : `standard: ${c.standard}`,
|
|
332
|
+
c.scope === true ? "scope" : void 0
|
|
333
|
+
].filter((x) => x !== void 0);
|
|
334
|
+
lines.push(` ${c.name} ${c.type}${tags.length > 0 ? ` (${tags.join(", ")})` : ""}`);
|
|
335
|
+
}
|
|
336
|
+
if (t.primaryKey !== void 0) lines.push(` primary key (${t.primaryKey.join(", ")})`);
|
|
337
|
+
for (const u of t.uniques) lines.push(` unique (${u.join(", ")})`);
|
|
338
|
+
for (const f of t.foreignKeys) lines.push(` foreign key (${f.columns.join(", ")}) -> ${f.references}`);
|
|
339
|
+
}
|
|
340
|
+
for (const q of e.movementQueries) lines.push("", `movement query ${q.identity}`, q.sql);
|
|
341
|
+
for (const u of e.generatedUnits) lines.push("", `generated ${u.identity}`, u.sql);
|
|
342
|
+
if (e.contracts.length > 0) lines.push("", "contracts:", JSON.stringify(e.contracts, null, 2));
|
|
343
|
+
if (e.referencedBy.length > 0) {
|
|
344
|
+
lines.push("", "referenced by:");
|
|
345
|
+
for (const r of e.referencedBy) lines.push(` ${r.file}#${r.pointer} (${r.role})`);
|
|
346
|
+
}
|
|
347
|
+
return `${lines.join("\n")}\n`;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Підсумок запису промоції для терміналу: що на що перетворилось і що
|
|
351
|
+
* лишається плану бази. Повний запис — у `--format json`.
|
|
352
|
+
*/
|
|
353
|
+
function renderPromotion(r, written) {
|
|
354
|
+
const lines = [`${written ? "promoted" : "would promote"} ${r.objectId} into ${r.kind}`];
|
|
355
|
+
for (const t of r.tables) lines.push(` table ${t.schema}.${t.from} -> ${t.to}`);
|
|
356
|
+
const counts = [
|
|
357
|
+
["columns renamed or moved", r.columns.length],
|
|
358
|
+
["type changes", r.typeChanges.length],
|
|
359
|
+
["data steps", r.dataSteps.length],
|
|
360
|
+
["columns retired", r.retired.length],
|
|
361
|
+
["constraints relaxed", r.relaxed.length],
|
|
362
|
+
["constraints tightened", r.tightened.length],
|
|
363
|
+
["row level security changes", r.rowLevelSecurity.length],
|
|
364
|
+
["delete semantics changes", r.deleteSemantics.length],
|
|
365
|
+
["conversions", r.conversions.length],
|
|
366
|
+
["units moved", r.movedUnits.length],
|
|
367
|
+
["units rewritten", r.rewrittenUnits.length],
|
|
368
|
+
["contract changes", r.contractChanges.length]
|
|
369
|
+
];
|
|
370
|
+
for (const [label, n] of counts) if (n > 0) lines.push(` ${label}: ${n}`);
|
|
371
|
+
return lines.join("\n");
|
|
372
|
+
}
|
|
373
|
+
/** Кінцевий результат одного виклику в тексті/JSON для терміналу. */
|
|
374
|
+
function renderResult(tool, r, o) {
|
|
375
|
+
const report = formatDiagnostics(r.diagnostics, o);
|
|
376
|
+
if (tool.name === "compile") return o.format === "json" ? {
|
|
377
|
+
stdout: "",
|
|
378
|
+
json: JSON.parse(report)
|
|
379
|
+
} : { stdout: report };
|
|
380
|
+
if (tool.name === "explain" && r.ok && r.data !== void 0) {
|
|
381
|
+
const explanation = r.data;
|
|
382
|
+
return { stdout: o.format === "json" ? JSON.stringify(explanation, null, 2) : renderExplanation(explanation).trimEnd() };
|
|
383
|
+
}
|
|
384
|
+
if (tool.name === "diff" && r.data !== void 0) {
|
|
385
|
+
const data = r.data;
|
|
386
|
+
return { stdout: o.format === "json" ? JSON.stringify({
|
|
387
|
+
ok: r.ok,
|
|
388
|
+
empty: data.empty,
|
|
389
|
+
plan: data.plan,
|
|
390
|
+
differences: data.differences,
|
|
391
|
+
diagnostics: JSON.parse(report)
|
|
392
|
+
}, null, 2) : renderDiff(data, report) };
|
|
393
|
+
}
|
|
394
|
+
if (tool.name === "plan" || tool.name === "apply") {
|
|
395
|
+
if (o.format === "json") return { stdout: JSON.stringify({
|
|
396
|
+
ok: r.ok,
|
|
397
|
+
written: r.written,
|
|
398
|
+
artifacts: r.artifacts ?? [],
|
|
399
|
+
...r.data,
|
|
400
|
+
diagnostics: JSON.parse(report)
|
|
401
|
+
}, null, 2) };
|
|
402
|
+
return { stdout: tool.name === "plan" ? renderPlan(r.data, report, {
|
|
403
|
+
ok: r.ok,
|
|
404
|
+
written: r.written
|
|
405
|
+
}) : renderApply(r.data, r.diagnostics, report) };
|
|
406
|
+
}
|
|
407
|
+
if (tool.name === "roles" && r.data !== void 0) {
|
|
408
|
+
const { roles, skipped } = r.data;
|
|
409
|
+
return { stdout: o.format === "json" ? JSON.stringify({
|
|
410
|
+
ok: r.ok,
|
|
411
|
+
roles,
|
|
412
|
+
skipped,
|
|
413
|
+
diagnostics: JSON.parse(report)
|
|
414
|
+
}, null, 2) : [
|
|
415
|
+
...roles.map((x) => `${x.server}: ${x.name} ${x.outcome}`),
|
|
416
|
+
...skipped.map((x) => `target: ${x.name} skipped: the directory has no project.meta.json, so database.provider is unknown; run roles in a metadata directory with a project file to create it`),
|
|
417
|
+
...r.diagnostics.length > 0 ? [report] : []
|
|
418
|
+
].join("\n") };
|
|
419
|
+
}
|
|
420
|
+
if (tool.name === "rights-maintenance" && r.data !== void 0) {
|
|
421
|
+
const done = r.data;
|
|
422
|
+
return { stdout: o.format === "json" ? JSON.stringify({
|
|
423
|
+
ok: r.ok,
|
|
424
|
+
...done,
|
|
425
|
+
diagnostics: JSON.parse(report)
|
|
426
|
+
}, null, 2) : `assigned ${done.assignment}${done.member === void 0 ? "" : ` to member ${done.member}`}` };
|
|
427
|
+
}
|
|
428
|
+
if ((tool.name === "data-read" || tool.name === "data-command") && r.data !== void 0) {
|
|
429
|
+
const data = r.data;
|
|
430
|
+
return { stdout: o.format === "json" ? JSON.stringify({
|
|
431
|
+
ok: r.ok,
|
|
432
|
+
...data
|
|
433
|
+
}, null, 2) : summarizeData(tool.name, data) };
|
|
434
|
+
}
|
|
435
|
+
if (tool.files === "read") return { stdout: report };
|
|
436
|
+
const changed = r.changes.map((c) => c.path);
|
|
437
|
+
if (o.format === "json") return { stdout: JSON.stringify({
|
|
438
|
+
ok: r.ok,
|
|
439
|
+
written: r.written,
|
|
440
|
+
changed,
|
|
441
|
+
diagnostics: JSON.parse(report),
|
|
442
|
+
...tool.name === "promote" && r.data !== void 0 ? { record: r.data } : {}
|
|
443
|
+
}, null, 2) };
|
|
444
|
+
const verb = (deleted) => r.written ? deleted ? "deleted" : "written" : deleted ? "would delete" : "would write";
|
|
445
|
+
return { stdout: [
|
|
446
|
+
...r.changes.map((c) => `${verb(c.deleted)} ${o.dir}/${c.path}`),
|
|
447
|
+
...r.ok ? [] : ["nothing written: the result has errors"],
|
|
448
|
+
report,
|
|
449
|
+
...tool.name === "promote" && r.data !== void 0 ? [renderPromotion(r.data, r.written)] : []
|
|
450
|
+
].join("\n") };
|
|
451
|
+
}
|
|
452
|
+
// src/cli/command.ts
|
|
453
|
+
const readStdin = async () => {
|
|
454
|
+
const chunks = [];
|
|
455
|
+
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
456
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
457
|
+
};
|
|
458
|
+
const fail = (message) => ({
|
|
459
|
+
exitCode: 2,
|
|
460
|
+
stdout: "",
|
|
461
|
+
stderr: `error: ${message}\n`
|
|
462
|
+
});
|
|
463
|
+
function isLocale(v) {
|
|
464
|
+
return v === "en" || v === "uk";
|
|
465
|
+
}
|
|
466
|
+
function isFormat(v) {
|
|
467
|
+
return v === "text" || v === "json";
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Не викликає `process.exit`: код виходу ставить `main.ts`, тож тести
|
|
471
|
+
* проганяють команду в процесі. Рішення про дозвіл, підтвердження й запис
|
|
472
|
+
* приймає `invoke`; тут лише argv → вхід і результат → код та текст. Єдиний
|
|
473
|
+
* запис поза `invoke` — вигляд `compile --out`, що існує лише в CLI.
|
|
474
|
+
*/
|
|
475
|
+
async function runTool(tool, argv, stdin = readStdin, cwd = process.cwd(), env = process.env) {
|
|
476
|
+
try {
|
|
477
|
+
const locale = argv.locale ?? "en";
|
|
478
|
+
const format = argv.format ?? "text";
|
|
479
|
+
if (!isLocale(locale)) throw new UsageError(`Invalid --locale "${locale}". Expected en or uk.`);
|
|
480
|
+
if (!isFormat(format)) throw new UsageError(`Invalid --format "${format}". Expected text or json.`);
|
|
481
|
+
if (argv["dry-run"] === true) switch (tool.files) {
|
|
482
|
+
case "read": throw new UsageError(`${tool.name} has no --dry-run: it writes no files. Nothing changed.`);
|
|
483
|
+
case "artifact": throw new UsageError(tool.name === "apply" ? "apply has no --dry-run: it writes the database, not files. To run the plan and roll it back, use --rehearse. Nothing changed." : `${tool.name} has no --dry-run: it writes only its own file under plans/ and never changes the metadata directory. Nothing changed.`);
|
|
484
|
+
}
|
|
485
|
+
const sweep = tool.name === "compile" && argv.all === true;
|
|
486
|
+
if (tool.name === "compile" && argv.staged === true && !sweep) throw new UsageError("--staged works only together with --all.");
|
|
487
|
+
if (sweep && argv._.length > 0) throw new UsageError("--all cannot be combined with explicit directories.");
|
|
488
|
+
if (sweep && argv.out !== void 0) throw new UsageError("--all cannot be combined with --out.");
|
|
489
|
+
const parsed = sweep ? {
|
|
490
|
+
input: {},
|
|
491
|
+
dirs: await findMetadataDirs(cwd)
|
|
492
|
+
} : await cliInput(tool, argv, stdin);
|
|
493
|
+
const { input } = parsed;
|
|
494
|
+
const databaseEnv = argv["database-url-env"] ?? "SIMETRA_DATABASE_URL";
|
|
495
|
+
checkEnvName("--database-url-env", databaseEnv);
|
|
496
|
+
if (argv["shadow-url-env"] !== void 0) checkEnvName("--shadow-url-env", argv["shadow-url-env"]);
|
|
497
|
+
const database = tool.database === "none" ? void 0 : databaseResource(env, {
|
|
498
|
+
url: databaseEnv,
|
|
499
|
+
...argv["shadow-url-env"] === void 0 ? {} : { shadow: argv["shadow-url-env"] }
|
|
500
|
+
});
|
|
501
|
+
const launch = tool.data === "none" ? void 0 : parseDataLaunch({
|
|
502
|
+
dataUrlEnv: argv["data-url-env"],
|
|
503
|
+
as: argv.as,
|
|
504
|
+
agent: argv.agent
|
|
505
|
+
});
|
|
506
|
+
const data = launch === void 0 ? void 0 : dataResource(env, launch);
|
|
507
|
+
let { dirs } = parsed;
|
|
508
|
+
const shown = dirs;
|
|
509
|
+
if (sweep) dirs = dirs.map((d) => resolve(cwd, d));
|
|
510
|
+
if (sweep && dirs.length === 0) return {
|
|
511
|
+
exitCode: 0,
|
|
512
|
+
stdout: "no metadata directories found.\n",
|
|
513
|
+
stderr: ""
|
|
514
|
+
};
|
|
515
|
+
let staged;
|
|
516
|
+
if (sweep && argv.staged === true) {
|
|
517
|
+
staged = await stageMetadataDirs(cwd, shown);
|
|
518
|
+
dirs = staged.dirs;
|
|
519
|
+
}
|
|
520
|
+
try {
|
|
521
|
+
const out = tool.name === "compile" ? argv.out : void 0;
|
|
522
|
+
if (out !== void 0) {
|
|
523
|
+
if (dirs.length > 1) throw new UsageError("--out accepts exactly one metadata directory.");
|
|
524
|
+
const parent = dirname(resolve(out));
|
|
525
|
+
if (!await stat(parent).then((s) => s.isDirectory(), () => false)) throw new UsageError(`--out parent directory not found: ${parent}`);
|
|
526
|
+
const existing = await stat(resolve(out)).catch(() => void 0);
|
|
527
|
+
if (existing !== void 0 && !existing.isDirectory()) throw new UsageError(`--out is not a directory: ${out}`);
|
|
528
|
+
}
|
|
529
|
+
const blocks = [];
|
|
530
|
+
const allJson = [];
|
|
531
|
+
let failed = false;
|
|
532
|
+
let notGit = false;
|
|
533
|
+
for (const [i, dir] of dirs.entries()) {
|
|
534
|
+
const baseline = tool.name === "compile" ? await readHeadMetadata(cwd, shown[i] ?? dir) : void 0;
|
|
535
|
+
if (tool.name === "compile" && baseline === void 0) notGit = true;
|
|
536
|
+
const result = await invoke(tool, input, {
|
|
537
|
+
dir,
|
|
538
|
+
readOnly: false,
|
|
539
|
+
allowDatabaseWrite: true,
|
|
540
|
+
allowDataWrite: true,
|
|
541
|
+
allowRightsWrite: argv["allow-rights-write"] === true,
|
|
542
|
+
...data === void 0 ? {} : { data },
|
|
543
|
+
...launch === void 0 ? {} : { dataEnv: launch.urlEnv },
|
|
544
|
+
dryRun: argv["dry-run"] === true,
|
|
545
|
+
confirmed: argv.yes === true,
|
|
546
|
+
channel: "cli",
|
|
547
|
+
database,
|
|
548
|
+
databaseEnv,
|
|
549
|
+
...baseline === void 0 ? {} : { baseline }
|
|
550
|
+
});
|
|
551
|
+
if (result.refusal !== void 0) return fail(result.refusal.message);
|
|
552
|
+
failed ||= !result.ok || tool.name === "diff" && result.data?.empty !== true;
|
|
553
|
+
const rendered = renderResult(tool, result, {
|
|
554
|
+
dir: shown[i] ?? dir,
|
|
555
|
+
locale,
|
|
556
|
+
format
|
|
557
|
+
});
|
|
558
|
+
if (rendered.json !== void 0) allJson.push(...rendered.json);
|
|
559
|
+
else blocks.push(dirs.length > 1 ? `${shown[i] ?? dir}:\n${rendered.stdout}` : rendered.stdout);
|
|
560
|
+
const model = result.data?.model;
|
|
561
|
+
if (out !== void 0 && model !== void 0) await writeChanges(out, compileArtifacts(model));
|
|
562
|
+
}
|
|
563
|
+
const stdout = tool.name === "compile" && format === "json" ? `${JSON.stringify(allJson, null, 2)}\n` : `${blocks.join("\n")}\n`;
|
|
564
|
+
return {
|
|
565
|
+
exitCode: failed ? 1 : 0,
|
|
566
|
+
stdout,
|
|
567
|
+
stderr: notGit ? "warning: not a git repository: assigned-once fields are not checked\n" : ""
|
|
568
|
+
};
|
|
569
|
+
} finally {
|
|
570
|
+
await staged?.dispose();
|
|
571
|
+
}
|
|
572
|
+
} catch (error) {
|
|
573
|
+
if (error instanceof UsageError) return fail(error.message);
|
|
574
|
+
throw error;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
function argsFor(tool) {
|
|
578
|
+
const args = {};
|
|
579
|
+
if (tool.name === "compile") {
|
|
580
|
+
args.dirs = {
|
|
581
|
+
type: "positional",
|
|
582
|
+
description: "Metadata directories (default: ./metadata)",
|
|
583
|
+
required: false
|
|
584
|
+
};
|
|
585
|
+
args.all = {
|
|
586
|
+
type: "boolean",
|
|
587
|
+
default: false,
|
|
588
|
+
description: "Check every metadata directory under the current directory"
|
|
589
|
+
};
|
|
590
|
+
args.staged = {
|
|
591
|
+
type: "boolean",
|
|
592
|
+
default: false,
|
|
593
|
+
description: "With --all: check the Git index instead of the working tree"
|
|
594
|
+
};
|
|
595
|
+
args.out = {
|
|
596
|
+
type: "string",
|
|
597
|
+
description: "Write snapshot.json, desired-state.sql, entities.d.ts, runtime-catalog.json here"
|
|
598
|
+
};
|
|
599
|
+
} else if (tool.name === "explain") {
|
|
600
|
+
args.target = {
|
|
601
|
+
type: "positional",
|
|
602
|
+
description: "<Kind>.<Name>, e.g. Document.ServiceAccrual",
|
|
603
|
+
required: true
|
|
604
|
+
};
|
|
605
|
+
args.dir = {
|
|
606
|
+
type: "positional",
|
|
607
|
+
description: "Metadata directory (default: ./metadata)",
|
|
608
|
+
required: false
|
|
609
|
+
};
|
|
610
|
+
} else if (tool.name === "apply") {
|
|
611
|
+
args.plan = {
|
|
612
|
+
type: "positional",
|
|
613
|
+
description: "Plan file written by plan, e.g. plans/initial-….plan.json",
|
|
614
|
+
required: true
|
|
615
|
+
};
|
|
616
|
+
args.dir = {
|
|
617
|
+
type: "positional",
|
|
618
|
+
description: "Metadata directory (default: ./metadata)",
|
|
619
|
+
required: false
|
|
620
|
+
};
|
|
621
|
+
} else if (takesJsonInput(tool)) {
|
|
622
|
+
args.json = {
|
|
623
|
+
type: "positional",
|
|
624
|
+
description: "Tool input as JSON, or - to read it from stdin",
|
|
625
|
+
required: false
|
|
626
|
+
};
|
|
627
|
+
args.dir = {
|
|
628
|
+
type: "positional",
|
|
629
|
+
description: "Metadata directory (default: ./metadata)",
|
|
630
|
+
required: false
|
|
631
|
+
};
|
|
632
|
+
args.input = {
|
|
633
|
+
type: "string",
|
|
634
|
+
description: "Tool input as JSON (instead of the positional form)"
|
|
635
|
+
};
|
|
636
|
+
} else args.dir = {
|
|
637
|
+
type: "positional",
|
|
638
|
+
description: "Metadata directory (default: ./metadata)",
|
|
639
|
+
required: false
|
|
640
|
+
};
|
|
641
|
+
if (tool.name === "introspect") {
|
|
642
|
+
args.schemas = {
|
|
643
|
+
type: "string",
|
|
644
|
+
description: "Comma-separated schemas to read (required for a directory without project.meta.json)"
|
|
645
|
+
};
|
|
646
|
+
args["project-name"] = {
|
|
647
|
+
type: "string",
|
|
648
|
+
description: "Name of a new project"
|
|
649
|
+
};
|
|
650
|
+
args["attribute-case"] = {
|
|
651
|
+
type: "enum",
|
|
652
|
+
options: [...ATTRIBUTE_CASES],
|
|
653
|
+
description: "Attribute case of a new project"
|
|
654
|
+
};
|
|
655
|
+
args["database-provider"] = {
|
|
656
|
+
type: "enum",
|
|
657
|
+
options: [...DATABASE_PROVIDERS],
|
|
658
|
+
description: "Database provider of a new project (default \"supabase\")"
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
if (tool.name === "diff") args.tables = {
|
|
662
|
+
type: "string",
|
|
663
|
+
description: "Comma-separated tables to compare: schema.table or table"
|
|
664
|
+
};
|
|
665
|
+
if (tool.name === "apply") {
|
|
666
|
+
args["plan-hash"] = {
|
|
667
|
+
type: "string",
|
|
668
|
+
description: "planHash of the reviewed plan (printed by plan)"
|
|
669
|
+
};
|
|
670
|
+
args.allow = {
|
|
671
|
+
type: "string",
|
|
672
|
+
description: "Comma-separated plan items to permit: step ids (s1,s2), drift, access:, delete:, update:, remove: and repair: items (a name with a comma only via MCP)"
|
|
673
|
+
};
|
|
674
|
+
args.rehearse = {
|
|
675
|
+
type: "boolean",
|
|
676
|
+
default: false,
|
|
677
|
+
description: "Run the plan and roll back; still takes the plan's locks"
|
|
678
|
+
};
|
|
679
|
+
args["lock-timeout-ms"] = {
|
|
680
|
+
type: "string",
|
|
681
|
+
description: `lock_timeout of the apply transaction (default ${DEFAULT_APPLY_TIMEOUTS.lockTimeoutMs})`
|
|
682
|
+
};
|
|
683
|
+
args["statement-timeout-ms"] = {
|
|
684
|
+
type: "string",
|
|
685
|
+
description: `statement_timeout of the apply transaction (default ${DEFAULT_APPLY_TIMEOUTS.statementTimeoutMs})`
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
if (tool.database !== "none") {
|
|
689
|
+
args["database-url-env"] = {
|
|
690
|
+
type: "string",
|
|
691
|
+
description: `Environment variable with the connection string (default: ${DEFAULT_DATABASE_URL_ENV})`
|
|
692
|
+
};
|
|
693
|
+
args["shadow-url-env"] = {
|
|
694
|
+
type: "string",
|
|
695
|
+
description: "Environment variable with a connection string to another server of the same PostgreSQL major version for the shadow database"
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
if (tool.data !== "none") {
|
|
699
|
+
args["data-url-env"] = {
|
|
700
|
+
type: "string",
|
|
701
|
+
description: "Environment variable with the connection string of the runtime login role to the development database"
|
|
702
|
+
};
|
|
703
|
+
args.as = {
|
|
704
|
+
type: "string",
|
|
705
|
+
description: "UUID of the user the command acts as, with that user's rights"
|
|
706
|
+
};
|
|
707
|
+
args.agent = {
|
|
708
|
+
type: "string",
|
|
709
|
+
description: "UUID of the agent, recorded as the act claim; it grants no rights"
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
if (tool.data === "write") args["allow-rights-write"] = {
|
|
713
|
+
type: "boolean",
|
|
714
|
+
default: false,
|
|
715
|
+
description: "Write rights catalogs and create scope roots whose creator receives a role"
|
|
716
|
+
};
|
|
717
|
+
if (tool.files === "write") args["dry-run"] = {
|
|
718
|
+
type: "boolean",
|
|
719
|
+
default: false,
|
|
720
|
+
description: "Report the changes without writing them"
|
|
721
|
+
};
|
|
722
|
+
if (tool.destructive) args.yes = {
|
|
723
|
+
type: "boolean",
|
|
724
|
+
default: false,
|
|
725
|
+
description: "Confirm a destructive change"
|
|
726
|
+
};
|
|
727
|
+
args.locale = {
|
|
728
|
+
type: "enum",
|
|
729
|
+
options: ["en", "uk"],
|
|
730
|
+
default: "en",
|
|
731
|
+
description: "Diagnostic language"
|
|
732
|
+
};
|
|
733
|
+
args.format = {
|
|
734
|
+
type: "enum",
|
|
735
|
+
options: ["text", "json"],
|
|
736
|
+
default: "text",
|
|
737
|
+
description: "Output format"
|
|
738
|
+
};
|
|
739
|
+
return args;
|
|
740
|
+
}
|
|
741
|
+
const str = (v) => typeof v === "string" ? v : void 0;
|
|
742
|
+
/** Типізований перелік полів: citty для динамічних `args` типів не дає. */
|
|
743
|
+
function toCliArgs(args) {
|
|
744
|
+
return {
|
|
745
|
+
_: args._,
|
|
746
|
+
input: str(args.input),
|
|
747
|
+
out: str(args.out),
|
|
748
|
+
format: str(args.format),
|
|
749
|
+
locale: str(args.locale),
|
|
750
|
+
"dry-run": args["dry-run"] === true,
|
|
751
|
+
yes: args.yes === true,
|
|
752
|
+
all: args.all === true,
|
|
753
|
+
staged: args.staged === true,
|
|
754
|
+
schemas: str(args.schemas),
|
|
755
|
+
tables: str(args.tables),
|
|
756
|
+
"project-name": str(args["project-name"]),
|
|
757
|
+
"attribute-case": str(args["attribute-case"]),
|
|
758
|
+
"database-provider": str(args["database-provider"]),
|
|
759
|
+
"database-url-env": str(args["database-url-env"]),
|
|
760
|
+
"shadow-url-env": str(args["shadow-url-env"]),
|
|
761
|
+
"plan-hash": str(args["plan-hash"]),
|
|
762
|
+
allow: str(args.allow),
|
|
763
|
+
rehearse: args.rehearse === true,
|
|
764
|
+
"lock-timeout-ms": str(args["lock-timeout-ms"]),
|
|
765
|
+
"statement-timeout-ms": str(args["statement-timeout-ms"]),
|
|
766
|
+
"data-url-env": str(args["data-url-env"]),
|
|
767
|
+
as: str(args.as),
|
|
768
|
+
agent: str(args.agent),
|
|
769
|
+
"allow-rights-write": args["allow-rights-write"] === true
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
/** Підкоманда з запису каталогу: опис, прапорці й дозволи беруться з нього. */
|
|
773
|
+
function toolCommand(tool) {
|
|
774
|
+
return defineCommand({
|
|
775
|
+
meta: {
|
|
776
|
+
name: tool.name,
|
|
777
|
+
description: tool.description
|
|
778
|
+
},
|
|
779
|
+
args: argsFor(tool),
|
|
780
|
+
async run({ args }) {
|
|
781
|
+
const result = await runTool(tool, toCliArgs(args));
|
|
782
|
+
process.stdout.write(result.stdout);
|
|
783
|
+
process.stderr.write(result.stderr);
|
|
784
|
+
process.exitCode = result.exitCode;
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
/** Для лінивої реєстрації в `main.ts`: команда будується лише на виклик. */
|
|
789
|
+
function commandByName(name) {
|
|
790
|
+
const tool = toolByName(name);
|
|
791
|
+
if (tool === void 0) throw new Error(`unknown tool: ${name}`);
|
|
792
|
+
return toolCommand(tool);
|
|
793
|
+
}
|
|
794
|
+
export { commandByName };
|