@simetrajs/designer 0.1.0 → 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/README.md +39 -4
- package/dist/{command-CRUaUglx.js → command-BCAw6Fsb.js} +81 -17
- package/dist/default-dir-DerxTbci.js +158 -0
- package/dist/{errors-D5pJLrjP.js → errors-Brw6UjAD.js} +1 -2
- package/dist/init-jr0Xsrpp.js +832 -0
- package/dist/main.js +6 -6
- package/dist/{mcp-CJDCleh-.js → mcp-ChltmHBb.js} +108 -72
- package/dist/mcp-args-D63akJ97.js +56 -0
- package/dist/package-Dg3MXPve.js +4 -0
- package/dist/{report-D2jBS_04.js → report-DV4deFdu.js} +733 -224
- package/dist/{schema-engine-DAsJEc8K.js → schema-engine-DPPnife2.js} +82 -78
- package/dist/{types-CSc8XWLd.js → types-iWavtmdS.js} +6 -3
- package/package.json +12 -11
- package/skills/simetra-adoption/SKILL.md +15 -1
- package/skills/simetra-metadata/SKILL.md +71 -68
- 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 +609 -8
- package/skills/simetra-metadata/references/project-setup.md +28 -0
- package/skills/simetra-metadata/references/sql-trust-boundary.md +194 -0
- package/dist/package-DDuGk6yE.js +0 -5
|
@@ -0,0 +1,832 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { d as installedPackageDir, f as posixRelative, p as UsageError, t as DEFAULT_DIR } from "./default-dir-DerxTbci.js";
|
|
3
|
+
import { t as mcpArgs } from "./mcp-args-D63akJ97.js";
|
|
4
|
+
import { defineCommand, parseArgs } from "citty";
|
|
5
|
+
import { lstat, mkdir, readFile, readdir, readlink, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
6
|
+
import { basename, dirname, join, posix, resolve, win32 } from "node:path";
|
|
7
|
+
import { parse } from "smol-toml";
|
|
8
|
+
import { randomUUID } from "node:crypto";
|
|
9
|
+
// src/init/fs-probe.ts
|
|
10
|
+
/**
|
|
11
|
+
* Що лежить за шляхом, без переходу за симлінком: `init` судить про власні
|
|
12
|
+
* лінки за самим лінком (`readlink`), тож битий власний лінк — теж власний.
|
|
13
|
+
* Помилка ФС повертається значенням, а не винятком: план збирає відмови й
|
|
14
|
+
* нічого не застосовує (спека designer §4.2).
|
|
15
|
+
*/
|
|
16
|
+
async function probe(path) {
|
|
17
|
+
try {
|
|
18
|
+
const s = await lstat(path);
|
|
19
|
+
if (s.isSymbolicLink()) return { kind: "symlink" };
|
|
20
|
+
return { kind: s.isDirectory() ? "dir" : "file" };
|
|
21
|
+
} catch (e) {
|
|
22
|
+
const code = errorCode(e);
|
|
23
|
+
return code === "ENOENT" ? { kind: "missing" } : {
|
|
24
|
+
kind: "error",
|
|
25
|
+
code
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function errorCode(e) {
|
|
30
|
+
const code = e?.code;
|
|
31
|
+
return typeof code === "string" ? code : "EUNKNOWN";
|
|
32
|
+
}
|
|
33
|
+
// src/init/own-path.ts
|
|
34
|
+
const DESIGNER_PACKAGE = "@simetrajs/designer";
|
|
35
|
+
const PACKAGE_DIR = `/node_modules/${DESIGNER_PACKAGE}/`;
|
|
36
|
+
/**
|
|
37
|
+
* Сегменти шляху всередині встановленого пакета designer: `target`
|
|
38
|
+
* резолвиться від `base` і нормалізується, тоді береться хвіст після
|
|
39
|
+
* останнього `node_modules/@simetrajs/designer/`. `undefined` — шлях поза
|
|
40
|
+
* пакетом. Власність судиться за нормалізованим шляхом, а не за підрядком:
|
|
41
|
+
* `node_modules/@simetrajs/designer/skills/../../other` містить сегмент
|
|
42
|
+
* пакета, але веде за його межі. На Windows регістр не розрізняється, а
|
|
43
|
+
* роздільник буває будь-який, тож шлях зводиться до нижнього регістру й `/`.
|
|
44
|
+
*/
|
|
45
|
+
function packageSubpath(base, target, platform) {
|
|
46
|
+
const path = platform === "win32" ? win32.resolve(base, target).replaceAll("\\", "/").toLowerCase() : posix.resolve(base, target.replaceAll("\\", "/"));
|
|
47
|
+
const at = path.lastIndexOf(PACKAGE_DIR);
|
|
48
|
+
if (at === -1) return void 0;
|
|
49
|
+
const rest = path.slice(at + PACKAGE_DIR.length).split("/").filter(Boolean);
|
|
50
|
+
return rest.length > 0 ? rest : void 0;
|
|
51
|
+
}
|
|
52
|
+
// src/init/mcp-config.ts
|
|
53
|
+
const AGENTS = [
|
|
54
|
+
"claude",
|
|
55
|
+
"codex",
|
|
56
|
+
"cursor",
|
|
57
|
+
"vscode"
|
|
58
|
+
];
|
|
59
|
+
const DEFAULT_AGENTS = ["claude"];
|
|
60
|
+
const MCP_SERVER_NAME = "simetra";
|
|
61
|
+
const WORKSPACE = "${workspaceFolder}";
|
|
62
|
+
const CURSOR_METADATA_DIR = `${WORKSPACE}/${DEFAULT_DIR.replace(/^\.\//, "")}`;
|
|
63
|
+
const CLIENTS = {
|
|
64
|
+
claude: {
|
|
65
|
+
file: ".mcp.json",
|
|
66
|
+
format: "json",
|
|
67
|
+
container: "mcpServers",
|
|
68
|
+
entry: (l) => ({
|
|
69
|
+
command: l.command,
|
|
70
|
+
args: l.args
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
codex: {
|
|
74
|
+
file: ".codex/config.toml",
|
|
75
|
+
format: "toml",
|
|
76
|
+
container: "mcp_servers",
|
|
77
|
+
entry: (l) => ({
|
|
78
|
+
command: l.command,
|
|
79
|
+
args: l.args
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
cursor: {
|
|
83
|
+
file: ".cursor/mcp.json",
|
|
84
|
+
format: "json",
|
|
85
|
+
container: "mcpServers",
|
|
86
|
+
entry: ({ command, args: [bin, ...rest] }) => ({
|
|
87
|
+
type: "stdio",
|
|
88
|
+
command,
|
|
89
|
+
args: [
|
|
90
|
+
`${WORKSPACE}/${bin}`,
|
|
91
|
+
...rest,
|
|
92
|
+
CURSOR_METADATA_DIR
|
|
93
|
+
]
|
|
94
|
+
})
|
|
95
|
+
},
|
|
96
|
+
vscode: {
|
|
97
|
+
file: ".vscode/mcp.json",
|
|
98
|
+
format: "json",
|
|
99
|
+
container: "servers",
|
|
100
|
+
entry: (l) => ({
|
|
101
|
+
type: "stdio",
|
|
102
|
+
command: l.command,
|
|
103
|
+
args: l.args,
|
|
104
|
+
cwd: WORKSPACE
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Команда запуску сервера: `node` + шлях до bin з маніфесту встановленого
|
|
110
|
+
* пакета. `node` не залежить від ОС (`npx` на Windows вимагає обгортки) і від
|
|
111
|
+
* менеджера пакетів; шлях — той самий механізм, що й у лінків скілів.
|
|
112
|
+
*/
|
|
113
|
+
async function mcpLaunch(root, pkgDir) {
|
|
114
|
+
const manifest = JSON.parse(await readFile(join(pkgDir, "package.json"), "utf8"));
|
|
115
|
+
const bin = isTable(manifest.bin) ? manifest.bin.simetra : void 0;
|
|
116
|
+
if (typeof bin !== "string") throw new UsageError(`${DESIGNER_PACKAGE} manifest has no simetra bin`);
|
|
117
|
+
return {
|
|
118
|
+
command: "node",
|
|
119
|
+
args: [posixRelative(root, join(pkgDir, bin)), "mcp"]
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Чи запис наш і чи він уже такий, як треба. Зайві ключі й `args[2..]`
|
|
124
|
+
* (дописаний `--read-only`, тека) — воля власника, тож на збіг не впливають.
|
|
125
|
+
*/
|
|
126
|
+
function matchesOwn(entry, expected, context) {
|
|
127
|
+
if (!isTable(entry) || !isOwn(entry, context)) return "foreign";
|
|
128
|
+
const args = entry.args;
|
|
129
|
+
const want = expected.args;
|
|
130
|
+
return args[0] === want[0] && args[1] === "mcp" && (want.length <= 2 || hasDir(args.slice(2))) && requiredKeys(expected).every(([k, v]) => entry[k] === v) ? "match" : "own-differs";
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Запис наш, коли `node` запускає файл усередині якоїсь теки
|
|
134
|
+
* `node_modules/@simetrajs/designer/` після нормалізації: старий шлях bin
|
|
135
|
+
* (оновлення пакета, інший `node_modules`) теж власний, а вихід через `..` —
|
|
136
|
+
* ні. Префікс Cursor `${workspaceFolder}/` — це корінь проєкту.
|
|
137
|
+
*/
|
|
138
|
+
function isOwn(entry, { root, platform }) {
|
|
139
|
+
const first = Array.isArray(entry.args) ? entry.args[0] : void 0;
|
|
140
|
+
if (entry.command !== "node" || typeof first !== "string") return false;
|
|
141
|
+
return packageSubpath(root, first.startsWith(`${WORKSPACE}/`) ? first.slice(19) : first, platform) !== void 0;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Чи хвіст `args` уже називає теку метаданих. Розбір — за описом самої
|
|
145
|
+
* команди `mcp`: значення рядкового прапорця (`--database-url-env X`) інакше
|
|
146
|
+
* сприймалося б як тека.
|
|
147
|
+
*/
|
|
148
|
+
function hasDir(rest) {
|
|
149
|
+
const strings = rest.filter((a) => typeof a === "string");
|
|
150
|
+
return parseArgs(strings, mcpArgs).dir !== void 0;
|
|
151
|
+
}
|
|
152
|
+
function requiredKeys(expected) {
|
|
153
|
+
return Object.entries(expected).filter(([k]) => k !== "command" && k !== "args");
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Виправлений власний запис: ставить `args[0..1]` і обов'язкові ключі, а
|
|
157
|
+
* решту лишає — нестандартну теку й прапорці власник дописує сам.
|
|
158
|
+
*/
|
|
159
|
+
function fixEntry(entry, expected) {
|
|
160
|
+
const want = expected.args;
|
|
161
|
+
let rest = entry.args.slice(2);
|
|
162
|
+
if (want.length > 2 && !hasDir(rest)) rest = [...want.slice(2), ...rest];
|
|
163
|
+
const args = [
|
|
164
|
+
want[0],
|
|
165
|
+
"mcp",
|
|
166
|
+
...rest
|
|
167
|
+
];
|
|
168
|
+
return {
|
|
169
|
+
...entry,
|
|
170
|
+
...Object.fromEntries(requiredKeys(expected)),
|
|
171
|
+
args
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* План MCP-конфігів обраних агентів. Лише читає диск: будь-яка проблема стає
|
|
176
|
+
* відмовою, і тоді `init` не пише нічого (спека designer §4.2).
|
|
177
|
+
*/
|
|
178
|
+
async function planMcpConfigs(root, agents, launch, platform) {
|
|
179
|
+
const context = {
|
|
180
|
+
root,
|
|
181
|
+
platform
|
|
182
|
+
};
|
|
183
|
+
const plan = {
|
|
184
|
+
actions: [],
|
|
185
|
+
notes: [],
|
|
186
|
+
refusals: []
|
|
187
|
+
};
|
|
188
|
+
for (const agent of AGENTS.filter((a) => agents.includes(a))) {
|
|
189
|
+
const client = CLIENTS[agent];
|
|
190
|
+
const path = join(root, client.file);
|
|
191
|
+
const read = await readConfig(root, client.file);
|
|
192
|
+
if ("refusal" in read) {
|
|
193
|
+
plan.refusals.push(read.refusal);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const expected = client.entry(launch);
|
|
197
|
+
const result = client.format === "json" ? planJson(read.text, client.container, expected, context) : planToml(read.text ?? "", expected, context);
|
|
198
|
+
if (result === "match") continue;
|
|
199
|
+
if (result === "foreign") plan.notes.push({
|
|
200
|
+
kind: "foreign-mcp-entry",
|
|
201
|
+
path
|
|
202
|
+
});
|
|
203
|
+
else if (typeof result === "string") plan.refusals.push({
|
|
204
|
+
path,
|
|
205
|
+
reason: result
|
|
206
|
+
});
|
|
207
|
+
else {
|
|
208
|
+
const creates = read.text === void 0;
|
|
209
|
+
plan.actions.push({
|
|
210
|
+
kind: "write",
|
|
211
|
+
path,
|
|
212
|
+
content: result.content,
|
|
213
|
+
creates
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return plan;
|
|
218
|
+
}
|
|
219
|
+
async function readConfig(root, rel) {
|
|
220
|
+
const segments = rel.split("/");
|
|
221
|
+
for (let i = 1; i < segments.length; i++) {
|
|
222
|
+
const ancestor = join(root, ...segments.slice(0, i));
|
|
223
|
+
const p = await probe(ancestor);
|
|
224
|
+
if (p.kind === "missing") return {};
|
|
225
|
+
if (p.kind === "dir") continue;
|
|
226
|
+
if (p.kind === "error") return { refusal: fsRefusal(ancestor, p.code) };
|
|
227
|
+
if (p.kind === "symlink" && await isDir(ancestor)) continue;
|
|
228
|
+
return { refusal: {
|
|
229
|
+
path: ancestor,
|
|
230
|
+
reason: "not-a-directory"
|
|
231
|
+
} };
|
|
232
|
+
}
|
|
233
|
+
const path = join(root, rel);
|
|
234
|
+
const p = await probe(path);
|
|
235
|
+
if (p.kind === "missing") return {};
|
|
236
|
+
if (p.kind === "dir") return { refusal: {
|
|
237
|
+
path,
|
|
238
|
+
reason: "not-a-file"
|
|
239
|
+
} };
|
|
240
|
+
if (p.kind === "error") return { refusal: fsRefusal(path, p.code) };
|
|
241
|
+
try {
|
|
242
|
+
return { text: await readFile(path, "utf8") };
|
|
243
|
+
} catch (e) {
|
|
244
|
+
const code = errorCode(e);
|
|
245
|
+
if (code === "EISDIR") return { refusal: {
|
|
246
|
+
path,
|
|
247
|
+
reason: "not-a-file"
|
|
248
|
+
} };
|
|
249
|
+
return { refusal: fsRefusal(path, code) };
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
async function isDir(path) {
|
|
253
|
+
try {
|
|
254
|
+
return (await stat(path)).isDirectory();
|
|
255
|
+
} catch {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function fsRefusal(path, code) {
|
|
260
|
+
return {
|
|
261
|
+
path,
|
|
262
|
+
reason: code === "ENOTDIR" ? "not-a-directory" : "unreadable",
|
|
263
|
+
code
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
function planJson(text, container, expected, context) {
|
|
267
|
+
let root = {};
|
|
268
|
+
if (text !== void 0) try {
|
|
269
|
+
root = JSON.parse(text);
|
|
270
|
+
} catch {
|
|
271
|
+
return "invalid-json";
|
|
272
|
+
}
|
|
273
|
+
if (!isTable(root)) return "not-an-object";
|
|
274
|
+
const servers = root[container] === void 0 ? {} : root[container];
|
|
275
|
+
if (!isTable(servers)) return "servers-not-an-object";
|
|
276
|
+
const current = servers[MCP_SERVER_NAME];
|
|
277
|
+
let next = expected;
|
|
278
|
+
if (current !== void 0) {
|
|
279
|
+
const verdict = matchesOwn(current, expected, context);
|
|
280
|
+
if (verdict !== "own-differs") return verdict;
|
|
281
|
+
next = fixEntry(current, expected);
|
|
282
|
+
}
|
|
283
|
+
const updated = {
|
|
284
|
+
...root,
|
|
285
|
+
[container]: {
|
|
286
|
+
...servers,
|
|
287
|
+
[MCP_SERVER_NAME]: next
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
return { content: JSON.stringify(updated, null, 2) + "\n" };
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Codex: розбір парсером, запис — правкою тексту. Дописування й заміна одного
|
|
294
|
+
* рядка зберігають коментарі й порядок споживача; повторний розбір після
|
|
295
|
+
* правки доводить, що вона однозначна.
|
|
296
|
+
*/
|
|
297
|
+
function planToml(text, expected, context) {
|
|
298
|
+
const servers = parseToml(text);
|
|
299
|
+
if (servers === "invalid-toml") return servers;
|
|
300
|
+
if (servers !== void 0 && !isTable(servers)) return "servers-not-an-object";
|
|
301
|
+
const current = servers?.[MCP_SERVER_NAME];
|
|
302
|
+
let content;
|
|
303
|
+
let want = expected;
|
|
304
|
+
if (current === void 0) {
|
|
305
|
+
const eol = lineEnding(text);
|
|
306
|
+
content = text + (text === "" ? "" : text.endsWith(eol) ? eol : eol + eol) + tomlBlock(expected, eol);
|
|
307
|
+
} else {
|
|
308
|
+
const verdict = matchesOwn(current, expected, context);
|
|
309
|
+
if (verdict !== "own-differs") return verdict;
|
|
310
|
+
want = fixEntry(current, expected);
|
|
311
|
+
const fixed = replaceArgsLine(text, want.args);
|
|
312
|
+
if (fixed === void 0) return "ambiguous-toml";
|
|
313
|
+
content = fixed;
|
|
314
|
+
}
|
|
315
|
+
const after = parseToml(content);
|
|
316
|
+
const entry = isTable(after) ? after[MCP_SERVER_NAME] : void 0;
|
|
317
|
+
return isTable(entry) && entry.command === want.command && JSON.stringify(entry.args) === JSON.stringify(want.args) ? { content } : "ambiguous-toml";
|
|
318
|
+
}
|
|
319
|
+
function parseToml(text) {
|
|
320
|
+
try {
|
|
321
|
+
return parse(text).mcp_servers;
|
|
322
|
+
} catch {
|
|
323
|
+
return "invalid-toml";
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function tomlBlock(entry, eol) {
|
|
327
|
+
const args = tomlArray(entry.args);
|
|
328
|
+
return [
|
|
329
|
+
`[mcp_servers.${MCP_SERVER_NAME}]`,
|
|
330
|
+
`command = ${tomlString(entry.command)}`,
|
|
331
|
+
`args = ${args}`
|
|
332
|
+
].join(eol) + eol;
|
|
333
|
+
}
|
|
334
|
+
function lineEnding(text) {
|
|
335
|
+
return text.includes("\r\n") ? "\r\n" : "\n";
|
|
336
|
+
}
|
|
337
|
+
function tomlString(s) {
|
|
338
|
+
return JSON.stringify(s).replaceAll("", "\\u007f");
|
|
339
|
+
}
|
|
340
|
+
function tomlArray(items) {
|
|
341
|
+
if (!items.every((i) => typeof i === "string")) return void 0;
|
|
342
|
+
return `[${items.map(tomlString).join(", ")}]`;
|
|
343
|
+
}
|
|
344
|
+
const HEADER = new RegExp(`^\\s*\\[\\s*(?:mcp_servers|"mcp_servers"|'mcp_servers')\\s*\\.\\s*(?:${MCP_SERVER_NAME}|"${MCP_SERVER_NAME}"|'${MCP_SERVER_NAME}')\\s*\\]\\s*(?:#.*)?$`);
|
|
345
|
+
const ANY_HEADER = /^\s*\[/;
|
|
346
|
+
const ARGS_KEY = /^\s*args\s*=/;
|
|
347
|
+
const ARGS_LINE = /^(\s*args\s*=\s*)(\[.*)$/;
|
|
348
|
+
const TRAILER$1 = /^\s*(?:#.*)?$/;
|
|
349
|
+
/**
|
|
350
|
+
* Межа масиву в рядку `args`: `]` може стояти і в елементі (`"a]#x"`), і в
|
|
351
|
+
* коментарі (`# see [docs]`), тож жоден регулярний вираз її не знайде. Кінець
|
|
352
|
+
* — перша `]`, після якої лише коментар і до якої текст розбирається як масив
|
|
353
|
+
* рядків.
|
|
354
|
+
*/
|
|
355
|
+
function splitArray(rest) {
|
|
356
|
+
for (let i = rest.indexOf("]"); i !== -1; i = rest.indexOf("]", i + 1)) {
|
|
357
|
+
const candidate = rest.slice(0, i + 1);
|
|
358
|
+
const tail = rest.slice(i + 1);
|
|
359
|
+
if (TRAILER$1.test(tail) && isStringArray(candidate)) return [candidate, tail];
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function isStringArray(array) {
|
|
363
|
+
try {
|
|
364
|
+
const { args } = parse(`args = ${array}`);
|
|
365
|
+
return Array.isArray(args) && args.every((a) => typeof a === "string");
|
|
366
|
+
} catch {
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Замінює масив у єдиному однорядковому `args` єдиної таблиці
|
|
372
|
+
* `[mcp_servers.simetra]`. Будь-яка інша форма — неоднозначна: правити її
|
|
373
|
+
* текстом означало б вгадувати.
|
|
374
|
+
*/
|
|
375
|
+
function replaceArgsLine(text, args) {
|
|
376
|
+
const array = tomlArray(args);
|
|
377
|
+
const eol = lineEnding(text);
|
|
378
|
+
const lines = text.split(eol);
|
|
379
|
+
const headers = lines.flatMap((l, i) => HEADER.test(l) ? [i] : []);
|
|
380
|
+
if (array === void 0 || headers.length !== 1) return void 0;
|
|
381
|
+
const start = headers[0] + 1;
|
|
382
|
+
let end = lines.findIndex((l, i) => i >= start && ANY_HEADER.test(l));
|
|
383
|
+
if (end === -1) end = lines.length;
|
|
384
|
+
const argLines = [];
|
|
385
|
+
for (let i = start; i < end; i++) if (ARGS_KEY.test(lines[i])) argLines.push(i);
|
|
386
|
+
const at = argLines.length === 1 ? argLines[0] : void 0;
|
|
387
|
+
const match = at === void 0 ? null : ARGS_LINE.exec(lines[at]);
|
|
388
|
+
const split = match ? splitArray(match[2]) : void 0;
|
|
389
|
+
if (at === void 0 || !match || !split) return void 0;
|
|
390
|
+
lines[at] = `${match[1]}${array}${split[1]}`;
|
|
391
|
+
return lines.join(eol);
|
|
392
|
+
}
|
|
393
|
+
function isTable(v) {
|
|
394
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
395
|
+
}
|
|
396
|
+
// src/init/skills.ts
|
|
397
|
+
/** Теки скілів у корені проєкту — у спеці не прив'язані до агента (§4.2). */
|
|
398
|
+
const SKILL_DIRS = [".agents/skills", ".claude/skills"];
|
|
399
|
+
/**
|
|
400
|
+
* Чи ціль лінка — тека скіла пакета: рівно один сегмент під
|
|
401
|
+
* `node_modules/@simetrajs/designer/skills/` після нормалізації. Будь-який
|
|
402
|
+
* `node_modules` годиться, тож застарілий лінк (перенесений проєкт, інший
|
|
403
|
+
* `node_modules`) теж власний і його можна виправити.
|
|
404
|
+
*/
|
|
405
|
+
function isOwnSkillTarget(linkPath, target, platform) {
|
|
406
|
+
const sub = packageSubpath(dirname(linkPath), target, platform);
|
|
407
|
+
return sub?.length === 2 && sub[0] === "skills";
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Перевірка власності на диску перед видаленням: між планом і застосуванням
|
|
411
|
+
* інший процес міг підмінити власний лінк чужим. Файл — розгорнутий git-ом
|
|
412
|
+
* симлінк, тож його вміст судиться як ціль.
|
|
413
|
+
*/
|
|
414
|
+
async function isOwnSkillEntry(path, platform) {
|
|
415
|
+
const s = await lstat(path);
|
|
416
|
+
if (s.isSymbolicLink()) return isOwnSkillTarget(path, await readlink(path), platform);
|
|
417
|
+
if (!s.isFile()) return false;
|
|
418
|
+
return isOwnSkillTarget(path, (await readFile(path, "utf8")).trim(), platform);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Як створити лінк скіла. Junction на Windows вимагає абсолютної цілі
|
|
422
|
+
* (дослідження доставки §4); деінде ціль відносна, щоб закомічений лінк
|
|
423
|
+
* пережив перенос репо.
|
|
424
|
+
*/
|
|
425
|
+
function linkSpec(linkPath, targetDir, platform) {
|
|
426
|
+
if (platform === "win32") return {
|
|
427
|
+
type: "junction",
|
|
428
|
+
target: targetDir
|
|
429
|
+
};
|
|
430
|
+
return {
|
|
431
|
+
type: "dir",
|
|
432
|
+
target: posixRelative(dirname(linkPath), targetDir)
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Чи це та сама тека, лексично. Файлова система Windows не розрізняє регістру,
|
|
437
|
+
* а `readlink` junction віддає шлях із хвостовим роздільником — без
|
|
438
|
+
* нормалізації абсолютний junction вічно не збігався б з очікуваною текою.
|
|
439
|
+
*/
|
|
440
|
+
function sameDir(a, b, platform) {
|
|
441
|
+
if (platform === "win32") {
|
|
442
|
+
const norm = (p) => win32.normalize(p).replace(/\\+$/, "").toLowerCase();
|
|
443
|
+
return norm(a) === norm(b);
|
|
444
|
+
}
|
|
445
|
+
const norm = (p) => posix.normalize(p).replace(/\/+$/, "");
|
|
446
|
+
return norm(a) === norm(b);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* План лінків скілів пакета в теках скілів проєкту. Лише читає диск: будь-яка
|
|
450
|
+
* проблема стає відмовою в плані, і тоді `init` не пише нічого (спека
|
|
451
|
+
* designer §4.2).
|
|
452
|
+
*/
|
|
453
|
+
async function planSkillLinks(root, pkgDir, platform) {
|
|
454
|
+
const plan = {
|
|
455
|
+
actions: [],
|
|
456
|
+
notes: [],
|
|
457
|
+
refusals: []
|
|
458
|
+
};
|
|
459
|
+
const skills = await packageSkills(pkgDir, plan);
|
|
460
|
+
for (const rel of SKILL_DIRS) {
|
|
461
|
+
const dir = await usableSkillDir(root, rel, plan, platform);
|
|
462
|
+
if (dir) await planDir(dir, pkgDir, skills, plan, platform);
|
|
463
|
+
}
|
|
464
|
+
return plan;
|
|
465
|
+
}
|
|
466
|
+
async function packageSkills(pkgDir, plan) {
|
|
467
|
+
const dir = join(pkgDir, "skills");
|
|
468
|
+
try {
|
|
469
|
+
const names = [];
|
|
470
|
+
for (const e of await readdir(dir, { withFileTypes: true })) {
|
|
471
|
+
const md = await probe(join(dir, e.name, "SKILL.md"));
|
|
472
|
+
if (e.isDirectory() && md.kind === "file") names.push(e.name);
|
|
473
|
+
}
|
|
474
|
+
return names.sort();
|
|
475
|
+
} catch (e) {
|
|
476
|
+
plan.refusals.push({
|
|
477
|
+
path: dir,
|
|
478
|
+
reason: "unreadable",
|
|
479
|
+
code: errorCode(e)
|
|
480
|
+
});
|
|
481
|
+
return [];
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Тека скілів, у якій можна планувати лінки. Симлінк-предок у межах кореня
|
|
486
|
+
* відмовляє: відносна ціль, порахована від лексичного шляху, у чужій фізичній
|
|
487
|
+
* теці не резолвилась би. Аліас на іншу теку скілів пропускається, бо дві дії
|
|
488
|
+
* на один фізичний шлях дали б `EEXIST` посеред застосування.
|
|
489
|
+
*/
|
|
490
|
+
async function usableSkillDir(root, rel, plan, platform) {
|
|
491
|
+
const segments = rel.split("/");
|
|
492
|
+
for (let i = 1; i < segments.length; i++) {
|
|
493
|
+
const ancestor = join(root, ...segments.slice(0, i));
|
|
494
|
+
const p = await probe(ancestor);
|
|
495
|
+
if (p.kind === "missing") return {
|
|
496
|
+
rel,
|
|
497
|
+
path: join(root, rel),
|
|
498
|
+
existing: false
|
|
499
|
+
};
|
|
500
|
+
if (p.kind !== "dir") return void plan.refusals.push(refusal(ancestor, p));
|
|
501
|
+
}
|
|
502
|
+
const path = join(root, rel);
|
|
503
|
+
const p = await probe(path);
|
|
504
|
+
if (p.kind === "missing" || p.kind === "dir") return {
|
|
505
|
+
rel,
|
|
506
|
+
path,
|
|
507
|
+
existing: p.kind === "dir"
|
|
508
|
+
};
|
|
509
|
+
if (p.kind === "symlink" && await aliasesOther(root, rel, platform)) {
|
|
510
|
+
plan.notes.push({
|
|
511
|
+
kind: "aliased-skill-dir",
|
|
512
|
+
path
|
|
513
|
+
});
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
plan.refusals.push(refusal(path, p));
|
|
517
|
+
}
|
|
518
|
+
async function aliasesOther(root, rel, platform) {
|
|
519
|
+
const path = join(root, rel);
|
|
520
|
+
try {
|
|
521
|
+
const resolved = resolve(dirname(path), await readlink(path));
|
|
522
|
+
return SKILL_DIRS.some((other) => other !== rel && sameDir(resolved, join(root, other), platform));
|
|
523
|
+
} catch {
|
|
524
|
+
return false;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
function refusal(path, p) {
|
|
528
|
+
if (p.kind === "symlink") return {
|
|
529
|
+
path,
|
|
530
|
+
reason: "skill-dir-is-a-link"
|
|
531
|
+
};
|
|
532
|
+
if (p.kind !== "error") return {
|
|
533
|
+
path,
|
|
534
|
+
reason: "not-a-directory"
|
|
535
|
+
};
|
|
536
|
+
return {
|
|
537
|
+
path,
|
|
538
|
+
reason: p.code === "ENOTDIR" ? "not-a-directory" : "unreadable",
|
|
539
|
+
code: p.code
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
async function planDir(dir, pkgDir, skills, plan, platform) {
|
|
543
|
+
const existing = dir.existing ? await entries(dir.path, plan) : [];
|
|
544
|
+
if (!existing) return;
|
|
545
|
+
for (const name of skills) {
|
|
546
|
+
const path = join(dir.path, name);
|
|
547
|
+
const expected = join(pkgDir, "skills", name);
|
|
548
|
+
const entry = await classify(path, expected, platform);
|
|
549
|
+
if (entry.kind === "refused") plan.refusals.push(entry.refusal);
|
|
550
|
+
if (entry.kind === "foreign") plan.notes.push({
|
|
551
|
+
kind: "foreign-skill",
|
|
552
|
+
path
|
|
553
|
+
});
|
|
554
|
+
if (entry.kind === "missing" || entry.kind === "stale") {
|
|
555
|
+
const replaces = entry.kind === "stale";
|
|
556
|
+
const spec = linkSpec(path, expected, platform);
|
|
557
|
+
plan.actions.push({
|
|
558
|
+
kind: "link",
|
|
559
|
+
path,
|
|
560
|
+
...spec,
|
|
561
|
+
replaces
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
await planOrphans(dir.path, existing, skills, pkgDir, plan, platform);
|
|
566
|
+
}
|
|
567
|
+
async function planOrphans(dirPath, existing, skills, pkgDir, plan, platform) {
|
|
568
|
+
for (const name of existing.filter((n) => !skills.includes(n))) {
|
|
569
|
+
const path = join(dirPath, name);
|
|
570
|
+
const entry = await classify(path, join(pkgDir, "skills", name), platform);
|
|
571
|
+
if (entry.kind === "match" || entry.kind === "stale") plan.actions.push({
|
|
572
|
+
kind: "unlink",
|
|
573
|
+
path
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
async function entries(path, plan) {
|
|
578
|
+
try {
|
|
579
|
+
return (await readdir(path)).sort();
|
|
580
|
+
} catch (e) {
|
|
581
|
+
plan.refusals.push({
|
|
582
|
+
path,
|
|
583
|
+
reason: "unreadable",
|
|
584
|
+
code: errorCode(e)
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
async function classify(path, expected, platform) {
|
|
589
|
+
const p = await probe(path);
|
|
590
|
+
if (p.kind === "missing") return { kind: "missing" };
|
|
591
|
+
if (p.kind === "dir") return { kind: "foreign" };
|
|
592
|
+
if (p.kind === "error") return {
|
|
593
|
+
kind: "refused",
|
|
594
|
+
refusal: refusal(path, p)
|
|
595
|
+
};
|
|
596
|
+
try {
|
|
597
|
+
return p.kind === "symlink" ? await classifyLink(path, expected, platform) : await classifyFile(path, expected);
|
|
598
|
+
} catch (e) {
|
|
599
|
+
return {
|
|
600
|
+
kind: "refused",
|
|
601
|
+
refusal: {
|
|
602
|
+
path,
|
|
603
|
+
reason: "unreadable",
|
|
604
|
+
code: errorCode(e)
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
async function classifyLink(path, expected, platform) {
|
|
610
|
+
const target = await readlink(path);
|
|
611
|
+
if (!isOwnSkillTarget(path, target, platform)) return { kind: "foreign" };
|
|
612
|
+
return { kind: sameDir(resolve(dirname(path), target), expected, platform) ? "match" : "stale" };
|
|
613
|
+
}
|
|
614
|
+
async function classifyFile(path, expected) {
|
|
615
|
+
return { kind: (await readFile(path, "utf8")).trim() === posixRelative(dirname(path), expected) ? "stale" : "foreign" };
|
|
616
|
+
}
|
|
617
|
+
// src/init/plan.ts
|
|
618
|
+
/**
|
|
619
|
+
* Повний план `init`: лише читає диск. Пакет шукається вгору від кореня тим
|
|
620
|
+
* самим механізмом, що й `$schema` (спека designer §4.2); його відсутність —
|
|
621
|
+
* `UsageError` з назвою пакета.
|
|
622
|
+
*/
|
|
623
|
+
async function planInit(root, agents, platform) {
|
|
624
|
+
const pkgDir = installedPackageDir(root, DESIGNER_PACKAGE);
|
|
625
|
+
const skills = await planSkillLinks(root, pkgDir, platform);
|
|
626
|
+
const configs = await planMcpConfigs(root, agents, await mcpLaunch(root, pkgDir), platform);
|
|
627
|
+
return {
|
|
628
|
+
actions: [...skills.actions, ...configs.actions],
|
|
629
|
+
notes: [...skills.notes, ...configs.notes],
|
|
630
|
+
refusals: [...skills.refusals, ...configs.refusals]
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Збій посеред застосування чистого плану — гонка з іншим процесом. `code` —
|
|
635
|
+
* код помилки ФС або `changed-since-plan`, коли власний лінк перед
|
|
636
|
+
* видаленням уже не наш.
|
|
637
|
+
*/
|
|
638
|
+
var InitApplyError = class extends Error {
|
|
639
|
+
path;
|
|
640
|
+
code;
|
|
641
|
+
name = "InitApplyError";
|
|
642
|
+
constructor(path, code) {
|
|
643
|
+
super(`${path}: ${code}`);
|
|
644
|
+
this.path = path;
|
|
645
|
+
this.code = code;
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
/**
|
|
649
|
+
* Застосовує план без відмов. Кожна дія вже перевірена планом, тож тут лише
|
|
650
|
+
* механіка; будь-який збій зупиняє застосування й називає шлях дії. Уже
|
|
651
|
+
* виконані дії лишаються: повторний `init` доробить решту (спека designer
|
|
652
|
+
* §4.2).
|
|
653
|
+
*/
|
|
654
|
+
async function applyInit(plan, platform) {
|
|
655
|
+
for (const action of plan.actions) try {
|
|
656
|
+
await applyAction(action, platform);
|
|
657
|
+
} catch (e) {
|
|
658
|
+
if (e instanceof InitApplyError) throw e;
|
|
659
|
+
throw new InitApplyError(action.path, errorCode(e));
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
async function applyAction(action, platform) {
|
|
663
|
+
switch (action.kind) {
|
|
664
|
+
case "unlink":
|
|
665
|
+
await assertOwnSkill(action.path, platform);
|
|
666
|
+
return unlink(action.path);
|
|
667
|
+
case "link":
|
|
668
|
+
if (action.replaces) {
|
|
669
|
+
await assertOwnSkill(action.path, platform);
|
|
670
|
+
await unlink(action.path);
|
|
671
|
+
}
|
|
672
|
+
await mkdir(dirname(action.path), { recursive: true });
|
|
673
|
+
return symlink(action.target, action.path, action.type);
|
|
674
|
+
case "write":
|
|
675
|
+
await mkdir(dirname(action.path), { recursive: true });
|
|
676
|
+
return writeAtomic(action.path, action.content);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
async function assertOwnSkill(path, platform) {
|
|
680
|
+
if (!await isOwnSkillEntry(path, platform)) throw new InitApplyError(path, "changed-since-plan");
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Запис через тимчасовий файл у тій самій теці й `rename`: обірваний запис не
|
|
684
|
+
* лишає напівконфігу. Симлінк конфігу резолвиться заздалегідь, бо `rename`
|
|
685
|
+
* поверх самого лінка замінив би його звичайним файлом; права файлу
|
|
686
|
+
* зберігаються.
|
|
687
|
+
*/
|
|
688
|
+
async function writeAtomic(path, content) {
|
|
689
|
+
const target = await realpath(path).catch((e) => {
|
|
690
|
+
if (errorCode(e) === "ENOENT") return path;
|
|
691
|
+
throw e;
|
|
692
|
+
});
|
|
693
|
+
const mode = await stat(target).then((s) => s.mode & 511, () => void 0);
|
|
694
|
+
const temp = join(dirname(target), `.${basename(target)}.${randomUUID()}.tmp`);
|
|
695
|
+
try {
|
|
696
|
+
await writeFile(temp, content, mode === void 0 ? { flag: "wx" } : {
|
|
697
|
+
flag: "wx",
|
|
698
|
+
mode
|
|
699
|
+
});
|
|
700
|
+
await rename(temp, target);
|
|
701
|
+
} catch (e) {
|
|
702
|
+
await rm(temp, { force: true });
|
|
703
|
+
throw e;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
// src/commands/init.ts
|
|
707
|
+
const initArgs = {
|
|
708
|
+
agents: {
|
|
709
|
+
type: "string",
|
|
710
|
+
description: `Comma-separated agents to write MCP configs for: ${AGENTS.join(", ")} (default: ${DEFAULT_AGENTS.join(",")})`
|
|
711
|
+
},
|
|
712
|
+
"dry-run": {
|
|
713
|
+
type: "boolean",
|
|
714
|
+
description: "Print the changes without writing them"
|
|
715
|
+
},
|
|
716
|
+
check: {
|
|
717
|
+
type: "boolean",
|
|
718
|
+
description: "Exit with code 1 if init would change anything; write nothing"
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
const KNOWN_KEYS = /* @__PURE__ */ new Set([
|
|
722
|
+
"_",
|
|
723
|
+
"agents",
|
|
724
|
+
"dry-run",
|
|
725
|
+
"dryRun",
|
|
726
|
+
"check"
|
|
727
|
+
]);
|
|
728
|
+
const TRAILER = ["The MCP server lets agents write the metadata directory; add --read-only to its args to refuse the tools that write.", "To check metadata before each commit, add this line to .husky/pre-commit: npx simetra compile --all --staged"];
|
|
729
|
+
var init_default = defineCommand({
|
|
730
|
+
meta: {
|
|
731
|
+
name: "init",
|
|
732
|
+
description: "Link the package skills and write the MCP server configs of agents into the project"
|
|
733
|
+
},
|
|
734
|
+
args: initArgs,
|
|
735
|
+
async run({ args }) {
|
|
736
|
+
const result = await runInit(args, process.cwd());
|
|
737
|
+
process.stdout.write(result.stdout);
|
|
738
|
+
process.stderr.write(result.stderr);
|
|
739
|
+
process.exitCode = result.exitCode;
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
/**
|
|
743
|
+
* Не викликає `process.exit`: тести проганяють команду в процесі. Аргументи
|
|
744
|
+
* перевіряються до пошуку пакета, щоб помилка використання називала саме
|
|
745
|
+
* поганий аргумент, а не відсутній пакет.
|
|
746
|
+
*/
|
|
747
|
+
async function runInit(args, cwd, platform = process.platform) {
|
|
748
|
+
const root = resolve(cwd);
|
|
749
|
+
const rel = (path) => posixRelative(root, path);
|
|
750
|
+
try {
|
|
751
|
+
const { agents, mode } = parseInitArgs(args);
|
|
752
|
+
const plan = await planInit(root, agents, platform);
|
|
753
|
+
if (plan.refusals.length > 0) return refused(plan, rel);
|
|
754
|
+
const lines = plan.actions.map(renderAction(rel));
|
|
755
|
+
const notes = plan.notes.map(renderNote(rel));
|
|
756
|
+
if (mode === "check") {
|
|
757
|
+
const drift = lines.length > 0;
|
|
758
|
+
const tail = drift ? "The project is out of date; run simetra init to fix it." : "The project is up to date.";
|
|
759
|
+
return ok(drift ? 1 : 0, [
|
|
760
|
+
...lines,
|
|
761
|
+
...notes,
|
|
762
|
+
tail
|
|
763
|
+
]);
|
|
764
|
+
}
|
|
765
|
+
if (mode === "init") await applyInit(plan, platform);
|
|
766
|
+
const summary = lines.length === 0 ? ["Nothing to change."] : lines;
|
|
767
|
+
return ok(0, [
|
|
768
|
+
...summary,
|
|
769
|
+
...notes,
|
|
770
|
+
...TRAILER
|
|
771
|
+
]);
|
|
772
|
+
} catch (e) {
|
|
773
|
+
if (e instanceof InitApplyError) return fail(`${rel(e.path)}: ${e.code}`);
|
|
774
|
+
if (e instanceof UsageError) return fail(e.message);
|
|
775
|
+
throw e;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
function parseInitArgs(args) {
|
|
779
|
+
for (const key of Object.keys(args)) if (!KNOWN_KEYS.has(key)) throw new UsageError(`unknown option --${key}`);
|
|
780
|
+
const positional = Array.isArray(args._) ? args._ : [];
|
|
781
|
+
if (positional.length > 0) throw new UsageError(`unexpected argument "${String(positional[0])}": init takes no positional arguments`);
|
|
782
|
+
const check = args.check === true;
|
|
783
|
+
const dryRun = args["dry-run"] === true;
|
|
784
|
+
if (check && dryRun) throw new UsageError("--check and --dry-run cannot be combined");
|
|
785
|
+
return {
|
|
786
|
+
agents: args.agents === void 0 ? DEFAULT_AGENTS : agentList(args.agents),
|
|
787
|
+
mode: check ? "check" : dryRun ? "dry-run" : "init"
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
function agentList(value) {
|
|
791
|
+
const expected = `expected a comma-separated list of ${AGENTS.join(", ")}`;
|
|
792
|
+
const items = typeof value === "string" ? value.split(",") : [""];
|
|
793
|
+
const agents = [];
|
|
794
|
+
for (const raw of items.map((i) => i.trim())) {
|
|
795
|
+
if (raw === "") throw new UsageError(`--agents has an empty item; ${expected}`);
|
|
796
|
+
if (!isAgent(raw)) throw new UsageError(`unknown agent "${raw}" in --agents; ${expected}`);
|
|
797
|
+
agents.push(raw);
|
|
798
|
+
}
|
|
799
|
+
return agents;
|
|
800
|
+
}
|
|
801
|
+
const isAgent = (v) => AGENTS.includes(v);
|
|
802
|
+
const renderAction = (rel) => (a) => {
|
|
803
|
+
switch (a.kind) {
|
|
804
|
+
case "link": return `${a.replaces ? "relink" : "link"} ${rel(a.path)} -> ${a.target}`;
|
|
805
|
+
case "unlink": return `remove ${rel(a.path)}`;
|
|
806
|
+
case "write": return `write ${rel(a.path)}`;
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
const NOTES = {
|
|
810
|
+
"foreign-skill": "not a link to the package skill; left as is",
|
|
811
|
+
"aliased-skill-dir": "links to the other skills directory; skills are linked there",
|
|
812
|
+
"foreign-mcp-entry": "the \"simetra\" server entry does not run this package; left as is"
|
|
813
|
+
};
|
|
814
|
+
const renderNote = (rel) => (n) => `note: ${rel(n.path)}: ${NOTES[n.kind]}`;
|
|
815
|
+
function refused(plan, rel) {
|
|
816
|
+
return {
|
|
817
|
+
exitCode: 2,
|
|
818
|
+
stdout: "",
|
|
819
|
+
stderr: [...plan.refusals.map((r) => `error: ${rel(r.path)}: ${r.reason}${r.code === void 0 ? "" : ` (${r.code})`}`), "Nothing changed."].join("\n") + "\n"
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
const ok = (exitCode, lines) => ({
|
|
823
|
+
exitCode,
|
|
824
|
+
stdout: lines.join("\n") + "\n",
|
|
825
|
+
stderr: ""
|
|
826
|
+
});
|
|
827
|
+
const fail = (message) => ({
|
|
828
|
+
exitCode: 2,
|
|
829
|
+
stdout: "",
|
|
830
|
+
stderr: `error: ${message}\n`
|
|
831
|
+
});
|
|
832
|
+
export { init_default as default };
|