@loomwright/cli 1.2.0 → 1.3.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/CHANGELOG.md +31 -0
- package/README.md +32 -27
- package/dist/cli.js +389 -47
- package/dist/tui.js +2851 -973
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -14769,7 +14769,7 @@ class TransientError extends Error {
|
|
|
14769
14769
|
}
|
|
14770
14770
|
|
|
14771
14771
|
// packages/core/src/version.ts
|
|
14772
|
-
var FACTORY_VERSION = "1.
|
|
14772
|
+
var FACTORY_VERSION = "1.3.0";
|
|
14773
14773
|
var PACKAGE_NAME = "@loomwright/cli";
|
|
14774
14774
|
var runVersion = (version) => `npx ${PACKAGE_NAME}@${version}`;
|
|
14775
14775
|
|
|
@@ -29988,7 +29988,118 @@ function checkRecursiveSearch(state, base, args) {
|
|
|
29988
29988
|
block(\`searches \\\`\${root}\\\`, which contains secret file \\\`\${found}\\\`; search specific directories instead\`);
|
|
29989
29989
|
}
|
|
29990
29990
|
}
|
|
29991
|
-
var PACKAGE_MANAGERS = new Set(["npm", "pnpm", "yarn", "bun", "bunx"]);
|
|
29991
|
+
var PACKAGE_MANAGERS = new Set(["npm", "pnpm", "yarn", "bun", "bunx", "npx", "pnpx"]);
|
|
29992
|
+
var NPM_VALUE_FLAGS = new Set([
|
|
29993
|
+
"--_auth",
|
|
29994
|
+
"--access",
|
|
29995
|
+
"--allow-directory",
|
|
29996
|
+
"--allow-file",
|
|
29997
|
+
"--allow-git",
|
|
29998
|
+
"--allow-remote",
|
|
29999
|
+
"--allow-scripts",
|
|
30000
|
+
"--also",
|
|
30001
|
+
"--audit-level",
|
|
30002
|
+
"--auth-type",
|
|
30003
|
+
"--before",
|
|
30004
|
+
"--ca",
|
|
30005
|
+
"--cache",
|
|
30006
|
+
"--cache-max",
|
|
30007
|
+
"--cache-min",
|
|
30008
|
+
"--cafile",
|
|
30009
|
+
"--call",
|
|
30010
|
+
"--cert",
|
|
30011
|
+
"--cidr",
|
|
30012
|
+
"--cpu",
|
|
30013
|
+
"--depth",
|
|
30014
|
+
"--diff",
|
|
30015
|
+
"--diff-dst-prefix",
|
|
30016
|
+
"--diff-src-prefix",
|
|
30017
|
+
"--diff-unified",
|
|
30018
|
+
"--editor",
|
|
30019
|
+
"--enjoy-by",
|
|
30020
|
+
"--expect-result-count",
|
|
30021
|
+
"--expires",
|
|
30022
|
+
"--fetch-retries",
|
|
30023
|
+
"--fetch-retry-factor",
|
|
30024
|
+
"--fetch-retry-maxtimeout",
|
|
30025
|
+
"--fetch-retry-mintimeout",
|
|
30026
|
+
"--fetch-timeout",
|
|
30027
|
+
"--git",
|
|
30028
|
+
"--globalconfig",
|
|
30029
|
+
"--heading",
|
|
30030
|
+
"--https-proxy",
|
|
30031
|
+
"--include",
|
|
30032
|
+
"--init-author-email",
|
|
30033
|
+
"--init-author-name",
|
|
30034
|
+
"--init-author-url",
|
|
30035
|
+
"--init-license",
|
|
30036
|
+
"--init-module",
|
|
30037
|
+
"--init-type",
|
|
30038
|
+
"--init-version",
|
|
30039
|
+
"--init.author.email",
|
|
30040
|
+
"--init.author.name",
|
|
30041
|
+
"--init.author.url",
|
|
30042
|
+
"--init.license",
|
|
30043
|
+
"--init.module",
|
|
30044
|
+
"--init.version",
|
|
30045
|
+
"--install-strategy",
|
|
30046
|
+
"--key",
|
|
30047
|
+
"--libc",
|
|
30048
|
+
"--local-address",
|
|
30049
|
+
"--location",
|
|
30050
|
+
"--lockfile-version",
|
|
30051
|
+
"--loglevel",
|
|
30052
|
+
"--logs-dir",
|
|
30053
|
+
"--logs-max",
|
|
30054
|
+
"--maxsockets",
|
|
30055
|
+
"--message",
|
|
30056
|
+
"--min-release-age",
|
|
30057
|
+
"--name",
|
|
30058
|
+
"--node-gyp",
|
|
30059
|
+
"--node-options",
|
|
30060
|
+
"--noproxy",
|
|
30061
|
+
"--omit",
|
|
30062
|
+
"--only",
|
|
30063
|
+
"--orgs",
|
|
30064
|
+
"--orgs-permission",
|
|
30065
|
+
"--os",
|
|
30066
|
+
"--otp",
|
|
30067
|
+
"--pack-destination",
|
|
30068
|
+
"--package",
|
|
30069
|
+
"--packages",
|
|
30070
|
+
"--packages-and-scopes-permission",
|
|
30071
|
+
"--password",
|
|
30072
|
+
"--prefix",
|
|
30073
|
+
"--preid",
|
|
30074
|
+
"--provenance-file",
|
|
30075
|
+
"--proxy",
|
|
30076
|
+
"--reg",
|
|
30077
|
+
"--registry",
|
|
30078
|
+
"--replace-registry-host",
|
|
30079
|
+
"--save-prefix",
|
|
30080
|
+
"--sbom-format",
|
|
30081
|
+
"--sbom-type",
|
|
30082
|
+
"--scope",
|
|
30083
|
+
"--scopes",
|
|
30084
|
+
"--script-shell",
|
|
30085
|
+
"--searchexclude",
|
|
30086
|
+
"--searchlimit",
|
|
30087
|
+
"--searchopts",
|
|
30088
|
+
"--searchstaleness",
|
|
30089
|
+
"--shell",
|
|
30090
|
+
"--tag",
|
|
30091
|
+
"--tag-version-prefix",
|
|
30092
|
+
"--token-description",
|
|
30093
|
+
"--umask",
|
|
30094
|
+
"--user-agent",
|
|
30095
|
+
"--userconfig",
|
|
30096
|
+
"--viewer",
|
|
30097
|
+
"--which",
|
|
30098
|
+
"--workspace"
|
|
30099
|
+
]);
|
|
30100
|
+
var NPM_COLOR_VALUES = new Set(["always", "true", "false"]);
|
|
30101
|
+
var NPM_SHORT_VALUE_FLAGS = new Set(["c", "C", "L", "m", "w"]);
|
|
30102
|
+
var NPX_SHORT_VALUE_FLAGS = new Set([...NPM_SHORT_VALUE_FLAGS, "n", "p"]);
|
|
29992
30103
|
var BUN_GLOBAL_SUBCOMMANDS = new Set([
|
|
29993
30104
|
"install",
|
|
29994
30105
|
"i",
|
|
@@ -30034,11 +30145,167 @@ function bunRunScript(args, start) {
|
|
|
30034
30145
|
}
|
|
30035
30146
|
return;
|
|
30036
30147
|
}
|
|
30148
|
+
function npmSubcommands(args) {
|
|
30149
|
+
const found = new Map;
|
|
30150
|
+
const seen = new Set;
|
|
30151
|
+
const pending = [0];
|
|
30152
|
+
while (pending.length > 0) {
|
|
30153
|
+
const i = pending.pop();
|
|
30154
|
+
if (i === undefined || seen.has(i))
|
|
30155
|
+
continue;
|
|
30156
|
+
seen.add(i);
|
|
30157
|
+
if (i >= args.length)
|
|
30158
|
+
continue;
|
|
30159
|
+
const a = args[i] ?? "";
|
|
30160
|
+
if (a === "--") {
|
|
30161
|
+
const next = args[i + 1];
|
|
30162
|
+
if (next !== undefined)
|
|
30163
|
+
found.set(i + 1, { index: i + 1, word: next });
|
|
30164
|
+
continue;
|
|
30165
|
+
}
|
|
30166
|
+
if (!a.startsWith("-") || a === "-") {
|
|
30167
|
+
found.set(i, { index: i, word: a });
|
|
30168
|
+
continue;
|
|
30169
|
+
}
|
|
30170
|
+
if (a.startsWith("--")) {
|
|
30171
|
+
const next = args[i + 1] ?? "";
|
|
30172
|
+
if (a === "--color" && NPM_COLOR_VALUES.has(next))
|
|
30173
|
+
pending.push(i + 2);
|
|
30174
|
+
else if (a.includes("="))
|
|
30175
|
+
pending.push(i + 1);
|
|
30176
|
+
else if (NPM_VALUE_FLAGS.has(a) || a.startsWith("--fetch-"))
|
|
30177
|
+
pending.push(i + 2);
|
|
30178
|
+
else
|
|
30179
|
+
pending.push(i + 1, i + 2);
|
|
30180
|
+
continue;
|
|
30181
|
+
}
|
|
30182
|
+
let next;
|
|
30183
|
+
const letters = a.slice(1);
|
|
30184
|
+
for (let j = 0;j < letters.length; j++) {
|
|
30185
|
+
const ch = letters[j] ?? "";
|
|
30186
|
+
if (NPM_SHORT_VALUE_FLAGS.has(ch)) {
|
|
30187
|
+
next = letters.slice(j + 1) === "" ? i + 2 : i + 1;
|
|
30188
|
+
break;
|
|
30189
|
+
}
|
|
30190
|
+
}
|
|
30191
|
+
pending.push(next ?? i + 1);
|
|
30192
|
+
}
|
|
30193
|
+
return [...found.values()].sort((a, b) => a.index - b.index);
|
|
30194
|
+
}
|
|
30195
|
+
var NPX_RUNNER_FLAGS = {
|
|
30196
|
+
long: NPM_VALUE_FLAGS,
|
|
30197
|
+
short: NPX_SHORT_VALUE_FLAGS
|
|
30198
|
+
};
|
|
30199
|
+
var NPM_EXEC_RUNNER_FLAGS = {
|
|
30200
|
+
long: NPM_VALUE_FLAGS,
|
|
30201
|
+
short: NPM_SHORT_VALUE_FLAGS
|
|
30202
|
+
};
|
|
30203
|
+
function scanRunnerArgs(args, flags) {
|
|
30204
|
+
const starts = new Set;
|
|
30205
|
+
const calls = [];
|
|
30206
|
+
const seen = new Set;
|
|
30207
|
+
const pending = [0];
|
|
30208
|
+
while (pending.length > 0) {
|
|
30209
|
+
const i = pending.pop();
|
|
30210
|
+
if (i === undefined || seen.has(i))
|
|
30211
|
+
continue;
|
|
30212
|
+
seen.add(i);
|
|
30213
|
+
if (i >= args.length) {
|
|
30214
|
+
starts.add(i);
|
|
30215
|
+
continue;
|
|
30216
|
+
}
|
|
30217
|
+
const a = args[i] ?? "";
|
|
30218
|
+
if (a === "--") {
|
|
30219
|
+
starts.add(i + 1);
|
|
30220
|
+
continue;
|
|
30221
|
+
}
|
|
30222
|
+
if (!a.startsWith("-") || a === "-") {
|
|
30223
|
+
starts.add(i);
|
|
30224
|
+
continue;
|
|
30225
|
+
}
|
|
30226
|
+
if (a.startsWith("--")) {
|
|
30227
|
+
if (a === "--call") {
|
|
30228
|
+
calls.push(args[i + 1] ?? "");
|
|
30229
|
+
continue;
|
|
30230
|
+
}
|
|
30231
|
+
if (a.startsWith("--call=")) {
|
|
30232
|
+
calls.push(a.slice("--call=".length));
|
|
30233
|
+
continue;
|
|
30234
|
+
}
|
|
30235
|
+
const next = args[i + 1] ?? "";
|
|
30236
|
+
if (a === "--color" && NPM_COLOR_VALUES.has(next))
|
|
30237
|
+
pending.push(i + 2);
|
|
30238
|
+
else if (a.includes("="))
|
|
30239
|
+
pending.push(i + 1);
|
|
30240
|
+
else if (flags.long.has(a) || a.startsWith("--fetch-"))
|
|
30241
|
+
pending.push(i + 2);
|
|
30242
|
+
else
|
|
30243
|
+
pending.push(i + 1, i + 2);
|
|
30244
|
+
continue;
|
|
30245
|
+
}
|
|
30246
|
+
const letters = a.slice(1);
|
|
30247
|
+
let next;
|
|
30248
|
+
let called = false;
|
|
30249
|
+
for (let j = 0;j < letters.length; j++) {
|
|
30250
|
+
const ch = letters[j] ?? "";
|
|
30251
|
+
if (ch === "c") {
|
|
30252
|
+
const attached = letters.slice(j + 1).replace(/^=/, "");
|
|
30253
|
+
calls.push(attached !== "" ? attached : args[i + 1] ?? "");
|
|
30254
|
+
called = true;
|
|
30255
|
+
break;
|
|
30256
|
+
}
|
|
30257
|
+
if (flags.short.has(ch)) {
|
|
30258
|
+
next = letters.slice(j + 1) === "" ? i + 2 : i + 1;
|
|
30259
|
+
break;
|
|
30260
|
+
}
|
|
30261
|
+
}
|
|
30262
|
+
if (!called)
|
|
30263
|
+
pending.push(next ?? i + 1);
|
|
30264
|
+
}
|
|
30265
|
+
return { starts: [...starts].sort((a, b) => a - b), calls };
|
|
30266
|
+
}
|
|
30267
|
+
function checkPackageRunner(state, args, outer, flags) {
|
|
30268
|
+
const { starts, calls } = scanRunnerArgs(args, flags);
|
|
30269
|
+
for (const text of calls)
|
|
30270
|
+
checkScriptText(state, text, outer);
|
|
30271
|
+
for (const start of starts) {
|
|
30272
|
+
const wrapped = args.slice(start);
|
|
30273
|
+
if (wrapped.length === 0)
|
|
30274
|
+
continue;
|
|
30275
|
+
if (++state.depth > 25)
|
|
30276
|
+
block("command nests too deeply to inspect");
|
|
30277
|
+
try {
|
|
30278
|
+
scoped(state, () => checkSimple(state, {
|
|
30279
|
+
kind: "simple",
|
|
30280
|
+
assigns: [],
|
|
30281
|
+
words: wrapped,
|
|
30282
|
+
redirects: [...outer.redirects],
|
|
30283
|
+
substitutions: []
|
|
30284
|
+
}, outer.stdin));
|
|
30285
|
+
} finally {
|
|
30286
|
+
state.depth--;
|
|
30287
|
+
}
|
|
30288
|
+
}
|
|
30289
|
+
}
|
|
30037
30290
|
function checkPackageManager(state, tool, args, outer) {
|
|
30038
30291
|
if (tool === "bunx") {
|
|
30039
30292
|
checkPackageManager(state, "bun", ["x", ...args], outer);
|
|
30040
30293
|
return;
|
|
30041
30294
|
}
|
|
30295
|
+
if (tool === "npx" || tool === "pnpx") {
|
|
30296
|
+
checkPackageRunner(state, args, outer, NPX_RUNNER_FLAGS);
|
|
30297
|
+
return;
|
|
30298
|
+
}
|
|
30299
|
+
if (tool === "npm") {
|
|
30300
|
+
const runners = npmSubcommands(args).filter((c) => c.word === "exec" || c.word === "x");
|
|
30301
|
+
for (const cmd of runners) {
|
|
30302
|
+
for (const text of scanRunnerArgs(args.slice(0, cmd.index), NPM_EXEC_RUNNER_FLAGS).calls)
|
|
30303
|
+
checkScriptText(state, text, outer);
|
|
30304
|
+
checkPackageRunner(state, args.slice(cmd.index + 1), outer, NPM_EXEC_RUNNER_FLAGS);
|
|
30305
|
+
}
|
|
30306
|
+
if (runners.length > 0)
|
|
30307
|
+
return;
|
|
30308
|
+
}
|
|
30042
30309
|
const cmd = tool === "bun" ? bunSubcommand(args) : undefined;
|
|
30043
30310
|
const sub = cmd?.word;
|
|
30044
30311
|
const known = tool !== "bun" || sub !== undefined && BUN_BUILTINS.has(sub);
|
|
@@ -30084,7 +30351,7 @@ function expandScripts(state, dir, scripts, keys) {
|
|
|
30084
30351
|
block(\`script \\\`\${key}\\\` expands into itself\`);
|
|
30085
30352
|
state.expanding.add(expansion);
|
|
30086
30353
|
try {
|
|
30087
|
-
checkScript(state, body);
|
|
30354
|
+
scoped(state, () => checkScript(state, body));
|
|
30088
30355
|
} finally {
|
|
30089
30356
|
state.expanding.delete(expansion);
|
|
30090
30357
|
}
|
|
@@ -30219,7 +30486,7 @@ function checkMake(state, args) {
|
|
|
30219
30486
|
if (found)
|
|
30220
30487
|
block(\`make \${target}: \${found}\`);
|
|
30221
30488
|
} else
|
|
30222
|
-
checkScript(state, line.replaceAll(DOLLAR, "$"));
|
|
30489
|
+
scoped(state, () => checkScript(state, line.replaceAll(DOLLAR, "$")));
|
|
30223
30490
|
}
|
|
30224
30491
|
};
|
|
30225
30492
|
for (const t of targets.length > 0 ? targets : first === undefined ? [] : [first])
|
|
@@ -30748,7 +31015,7 @@ function unwrap(state, words, stdin) {
|
|
|
30748
31015
|
if (base === "flock") {
|
|
30749
31016
|
const c = rest.indexOf("-c");
|
|
30750
31017
|
if (c !== -1) {
|
|
30751
|
-
checkScript(state, rest[c + 1] ?? "");
|
|
31018
|
+
scoped(state, () => checkScript(state, rest[c + 1] ?? ""));
|
|
30752
31019
|
return [];
|
|
30753
31020
|
}
|
|
30754
31021
|
i += 1;
|
|
@@ -30762,7 +31029,7 @@ function unwrap(state, words, stdin) {
|
|
|
30762
31029
|
let i = 0;
|
|
30763
31030
|
while (i < rest.length && (rest[i] ?? "").startsWith("-"))
|
|
30764
31031
|
i += /^-(n|d)$/.test(rest[i] ?? "") ? 2 : 1;
|
|
30765
|
-
checkScript(state, rest.slice(i).join(" "));
|
|
31032
|
+
scoped(state, () => checkScript(state, rest.slice(i).join(" ")));
|
|
30766
31033
|
return [];
|
|
30767
31034
|
}
|
|
30768
31035
|
return w;
|
|
@@ -30914,18 +31181,26 @@ function checkSimple(state, cmd, stdin) {
|
|
|
30914
31181
|
break;
|
|
30915
31182
|
}
|
|
30916
31183
|
const operand = args[i];
|
|
30917
|
-
if (c)
|
|
30918
|
-
|
|
30919
|
-
|
|
30920
|
-
|
|
30921
|
-
if (
|
|
30922
|
-
|
|
30923
|
-
|
|
30924
|
-
|
|
31184
|
+
if (c) {
|
|
31185
|
+
scoped(state, () => checkScript(state, operand ?? ""));
|
|
31186
|
+
return;
|
|
31187
|
+
}
|
|
31188
|
+
if (!fromStdin && operand !== undefined) {
|
|
31189
|
+
scoped(state, () => checkScriptFile(state, operand, "shell"));
|
|
31190
|
+
return;
|
|
31191
|
+
}
|
|
31192
|
+
if (heredoc !== undefined) {
|
|
31193
|
+
scoped(state, () => checkScript(state, heredoc));
|
|
31194
|
+
return;
|
|
31195
|
+
}
|
|
31196
|
+
if (inputFile !== undefined) {
|
|
31197
|
+
scoped(state, () => checkScriptFile(state, inputFile, "shell"));
|
|
31198
|
+
return;
|
|
31199
|
+
}
|
|
30925
31200
|
if (stdin === null)
|
|
30926
31201
|
block(\`pipes generated input into \${base}\`);
|
|
30927
31202
|
if (stdin !== undefined)
|
|
30928
|
-
checkScript(state, stdin);
|
|
31203
|
+
scoped(state, () => checkScript(state, stdin));
|
|
30929
31204
|
return;
|
|
30930
31205
|
}
|
|
30931
31206
|
if (base === "source" || base === ".") {
|
|
@@ -30943,9 +31218,11 @@ function checkSimple(state, cmd, stdin) {
|
|
|
30943
31218
|
state.cwd = undefined;
|
|
30944
31219
|
return;
|
|
30945
31220
|
}
|
|
30946
|
-
|
|
30947
|
-
|
|
30948
|
-
|
|
31221
|
+
const at = base.lastIndexOf("@");
|
|
31222
|
+
const tool = at > 0 && PACKAGE_MANAGERS.has(base.slice(0, at)) ? base.slice(0, at) : base;
|
|
31223
|
+
if (PACKAGE_MANAGERS.has(tool))
|
|
31224
|
+
checkPackageManager(state, tool, args, { redirects: cmd.redirects, stdin });
|
|
31225
|
+
const interpreter = tool.replace(/\\d+(\\.\\d+)*$/, "");
|
|
30949
31226
|
if ((interpreter === "perl" || interpreter === "ruby") && args.some(isInPlaceFlag)) {
|
|
30950
31227
|
const operands = [];
|
|
30951
31228
|
let code = false;
|
|
@@ -30962,7 +31239,7 @@ function checkSimple(state, cmd, stdin) {
|
|
|
30962
31239
|
for (const f of code ? operands : operands.slice(1))
|
|
30963
31240
|
checkWrite(state, f, \`\${interpreter} -i edits\`);
|
|
30964
31241
|
}
|
|
30965
|
-
const inline = INTERPRETERS[interpreter] ?? INTERPRETERS[
|
|
31242
|
+
const inline = INTERPRETERS[interpreter] ?? INTERPRETERS[tool];
|
|
30966
31243
|
if (inline) {
|
|
30967
31244
|
const i = args.findIndex((a) => inline.includes(a));
|
|
30968
31245
|
const joined = args.find((a) => inline.some((f) => f.startsWith("--") && a.startsWith(\`\${f}=\`)));
|
|
@@ -30974,7 +31251,7 @@ function checkSimple(state, cmd, stdin) {
|
|
|
30974
31251
|
return;
|
|
30975
31252
|
}
|
|
30976
31253
|
const file = args.find((a) => !a.startsWith("-"));
|
|
30977
|
-
if (
|
|
31254
|
+
if (tool === "bun" && file !== undefined) {
|
|
30978
31255
|
checkPackageScript(state, "bun", args);
|
|
30979
31256
|
return;
|
|
30980
31257
|
}
|
|
@@ -31007,8 +31284,10 @@ function checkSimple(state, cmd, stdin) {
|
|
|
31007
31284
|
checkSed(state, args);
|
|
31008
31285
|
if (base === "script") {
|
|
31009
31286
|
const c = args.findIndex((a) => a === "-c" || a === "--command");
|
|
31010
|
-
if (c !== -1)
|
|
31011
|
-
|
|
31287
|
+
if (c !== -1) {
|
|
31288
|
+
scoped(state, () => checkScript(state, args[c + 1] ?? ""));
|
|
31289
|
+
return;
|
|
31290
|
+
}
|
|
31012
31291
|
}
|
|
31013
31292
|
if (base === "fd" || base === "fdfind") {
|
|
31014
31293
|
const x = args.findIndex((a) => ["-x", "--exec", "-X", "--exec-batch"].includes(a));
|
|
@@ -31018,8 +31297,8 @@ function checkSimple(state, cmd, stdin) {
|
|
|
31018
31297
|
}
|
|
31019
31298
|
}
|
|
31020
31299
|
if (head.includes("/"))
|
|
31021
|
-
checkScriptFile(state, head, "shell");
|
|
31022
|
-
switch (
|
|
31300
|
+
scoped(state, () => checkScriptFile(state, head, "shell"));
|
|
31301
|
+
switch (tool) {
|
|
31023
31302
|
case "git":
|
|
31024
31303
|
return checkGit(state, args);
|
|
31025
31304
|
case "rm":
|
|
@@ -31150,7 +31429,7 @@ function checkSimple(state, cmd, stdin) {
|
|
|
31150
31429
|
case "pnpm":
|
|
31151
31430
|
case "yarn":
|
|
31152
31431
|
case "bun":
|
|
31153
|
-
checkPackageScript(state,
|
|
31432
|
+
checkPackageScript(state, tool, args);
|
|
31154
31433
|
return;
|
|
31155
31434
|
case "make":
|
|
31156
31435
|
case "gmake":
|
|
@@ -31224,10 +31503,11 @@ function literalOutput(cmd) {
|
|
|
31224
31503
|
return cmd.redirects.find((r) => r.body !== undefined)?.body;
|
|
31225
31504
|
return;
|
|
31226
31505
|
}
|
|
31227
|
-
function checkPipeline(state, pipeline) {
|
|
31506
|
+
function checkPipeline(state, pipeline, inherited) {
|
|
31228
31507
|
const { commands } = pipeline;
|
|
31229
31508
|
commands.forEach((cmd, i) => {
|
|
31230
31509
|
const prev = commands[i - 1];
|
|
31510
|
+
const input = prev === undefined ? inherited : undefined;
|
|
31231
31511
|
let stdin;
|
|
31232
31512
|
if (prev !== undefined) {
|
|
31233
31513
|
const prevWords = prev.kind === "simple" ? prev.words : [];
|
|
@@ -31239,33 +31519,44 @@ function checkPipeline(state, pipeline) {
|
|
|
31239
31519
|
}
|
|
31240
31520
|
}
|
|
31241
31521
|
stdin = literalOutput(prev) ?? null;
|
|
31522
|
+
} else if (input !== undefined) {
|
|
31523
|
+
stdin = input.stdin;
|
|
31242
31524
|
}
|
|
31525
|
+
const redirects = input === undefined ? cmd.redirects : [...cmd.redirects, ...input.redirects];
|
|
31243
31526
|
if (cmd.kind === "subshell") {
|
|
31244
|
-
checkRedirects(state,
|
|
31245
|
-
scoped(state, () => checkScriptAst(state, cmd.script));
|
|
31527
|
+
checkRedirects(state, redirects);
|
|
31528
|
+
scoped(state, () => checkScriptAst(state, cmd.script, { redirects, stdin }));
|
|
31246
31529
|
} else {
|
|
31247
|
-
checkSimple(state, cmd, stdin);
|
|
31530
|
+
checkSimple(state, { ...cmd, redirects }, stdin);
|
|
31248
31531
|
}
|
|
31249
31532
|
});
|
|
31250
31533
|
}
|
|
31251
31534
|
function scoped(state, fn) {
|
|
31252
31535
|
const cwd = state.cwd;
|
|
31536
|
+
const aliases = new Map(state.aliases);
|
|
31253
31537
|
try {
|
|
31254
31538
|
fn();
|
|
31255
31539
|
} finally {
|
|
31256
31540
|
state.cwd = cwd;
|
|
31541
|
+
state.aliases.clear();
|
|
31542
|
+
for (const [name, value] of aliases)
|
|
31543
|
+
state.aliases.set(name, value);
|
|
31257
31544
|
}
|
|
31258
31545
|
}
|
|
31259
|
-
function checkScriptAst(state, script) {
|
|
31546
|
+
function checkScriptAst(state, script, inherited) {
|
|
31260
31547
|
if (++state.depth > 25)
|
|
31261
31548
|
block("command nests too deeply to inspect");
|
|
31262
31549
|
try {
|
|
31263
31550
|
for (const p of script.pipelines)
|
|
31264
|
-
checkPipeline(state, p);
|
|
31551
|
+
checkPipeline(state, p, inherited);
|
|
31265
31552
|
} finally {
|
|
31266
31553
|
state.depth--;
|
|
31267
31554
|
}
|
|
31268
31555
|
}
|
|
31556
|
+
function checkScriptText(state, text, inherited) {
|
|
31557
|
+
scoped(state, () => checkScriptAst(state, parseScript(text), inherited));
|
|
31558
|
+
return;
|
|
31559
|
+
}
|
|
31269
31560
|
function checkScript(state, text) {
|
|
31270
31561
|
checkScriptAst(state, parseScript(text));
|
|
31271
31562
|
return;
|
|
@@ -31508,7 +31799,9 @@ function onShellCreate(workspace, event) {
|
|
|
31508
31799
|
}
|
|
31509
31800
|
if (process.env.AI_FACTORY_SANDBOX === "seatbelt") {
|
|
31510
31801
|
const shell = typeof event.shell === "string" && event.shell.startsWith("/") ? event.shell : "/bin/bash";
|
|
31511
|
-
event.command = sandboxCommand(seatbeltProfile(sandboxPolicy(workspace, ctx)), shell, event.command)
|
|
31802
|
+
event.command = \`export AI_FACTORY_SANDBOX=wrapped; \${sandboxCommand(seatbeltProfile(sandboxPolicy(workspace, ctx)), shell, event.command)}\`;
|
|
31803
|
+
if (event.env !== undefined)
|
|
31804
|
+
event.env.AI_FACTORY_SANDBOX = "wrapped";
|
|
31512
31805
|
}
|
|
31513
31806
|
}
|
|
31514
31807
|
var entry_default = {
|
|
@@ -33964,9 +34257,33 @@ function requireInstalled(root) {
|
|
|
33964
34257
|
|
|
33965
34258
|
// packages/cli/src/command.ts
|
|
33966
34259
|
import { parseArgs } from "node:util";
|
|
34260
|
+
function bindHelpValue(args, options) {
|
|
34261
|
+
const bound = [];
|
|
34262
|
+
for (let i = 0;i < args.length; i++) {
|
|
34263
|
+
const arg = args[i];
|
|
34264
|
+
if (arg === "--") {
|
|
34265
|
+
bound.push(...args.slice(i));
|
|
34266
|
+
break;
|
|
34267
|
+
}
|
|
34268
|
+
const next = args[i + 1];
|
|
34269
|
+
if (arg !== undefined && next !== undefined && (next === "-h" || next === "--help") && arg.startsWith("--") && !arg.includes("=") && options[arg.slice(2)]?.type === "string") {
|
|
34270
|
+
bound.push(`${arg}=${next}`);
|
|
34271
|
+
i++;
|
|
34272
|
+
continue;
|
|
34273
|
+
}
|
|
34274
|
+
if (arg !== undefined)
|
|
34275
|
+
bound.push(arg);
|
|
34276
|
+
}
|
|
34277
|
+
return bound;
|
|
34278
|
+
}
|
|
33967
34279
|
function parseCommandArgs(command, args, options, allowPositionals = false) {
|
|
33968
34280
|
try {
|
|
33969
|
-
return parseArgs({
|
|
34281
|
+
return parseArgs({
|
|
34282
|
+
args: bindHelpValue(args, options),
|
|
34283
|
+
options,
|
|
34284
|
+
strict: true,
|
|
34285
|
+
allowPositionals
|
|
34286
|
+
});
|
|
33970
34287
|
} catch (err) {
|
|
33971
34288
|
const message = err instanceof Error ? err.message : String(err);
|
|
33972
34289
|
throw new UsageError(`${command}: ${message}`, [`see \`loomwright ${command} --help\``]);
|
|
@@ -36022,7 +36339,10 @@ function realPathOf(abs, depth = 0) {
|
|
|
36022
36339
|
|
|
36023
36340
|
// packages/core/src/policy/sandbox.ts
|
|
36024
36341
|
var SANDBOX_EXEC = "/usr/bin/sandbox-exec";
|
|
36025
|
-
function sandboxEnabled(setting, platform = process.platform, exists = existsSync30) {
|
|
36342
|
+
function sandboxEnabled(setting, platform = process.platform, exists = existsSync30, env = process.env) {
|
|
36343
|
+
const marker = env.AI_FACTORY_SANDBOX;
|
|
36344
|
+
if (marker === "wrapped" || marker === "off")
|
|
36345
|
+
return false;
|
|
36026
36346
|
return setting !== "off" && platform === "darwin" && exists(SANDBOX_EXEC);
|
|
36027
36347
|
}
|
|
36028
36348
|
var regexPath = (p) => realPathOf(p).replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
@@ -36174,11 +36494,13 @@ function staleLockfileNote(paths) {
|
|
|
36174
36494
|
async function runOne(input, gate) {
|
|
36175
36495
|
const before = await snapshot2(input.worktree);
|
|
36176
36496
|
const bins = gate.binDirs.map((b) => join39(input.worktree, b));
|
|
36497
|
+
const sandboxed = sandboxEnabled(input.config.security.sandbox);
|
|
36177
36498
|
const env = {
|
|
36178
36499
|
...agentProcessEnv(),
|
|
36179
36500
|
...cacheEnv(input.root, input.repo.name),
|
|
36180
36501
|
...QUIET_ENV,
|
|
36181
36502
|
...gate.env ?? {},
|
|
36503
|
+
AI_FACTORY_SANDBOX: sandboxed ? "wrapped" : "off",
|
|
36182
36504
|
PATH: [...bins, process.env.PATH ?? ""].join(delimiter)
|
|
36183
36505
|
};
|
|
36184
36506
|
const argv = [
|
|
@@ -36188,7 +36510,7 @@ async function runOne(input, gate) {
|
|
|
36188
36510
|
${gate.setup}
|
|
36189
36511
|
${gate.command}`
|
|
36190
36512
|
];
|
|
36191
|
-
const res = await exec(
|
|
36513
|
+
const res = await exec(sandboxed ? sandboxArgv(seatbeltProfile(checkoutPolicy(input.root, input.worktree, [join39(input.root, ".factory", "cache")])), argv) : argv, {
|
|
36192
36514
|
cwd: join39(input.worktree, gate.cwd),
|
|
36193
36515
|
env,
|
|
36194
36516
|
replaceEnv: true,
|
|
@@ -42069,13 +42391,25 @@ async function checkRepos(c, root, config, uninitialised) {
|
|
|
42069
42391
|
}
|
|
42070
42392
|
return ready;
|
|
42071
42393
|
}
|
|
42394
|
+
function errnoOf(err) {
|
|
42395
|
+
return typeof err === "object" && err !== null && "code" in err ? err.code : undefined;
|
|
42396
|
+
}
|
|
42397
|
+
function messageOf(err) {
|
|
42398
|
+
return err instanceof Error ? err.message : String(err);
|
|
42399
|
+
}
|
|
42072
42400
|
function packageScript(dir, name) {
|
|
42401
|
+
let text;
|
|
42402
|
+
try {
|
|
42403
|
+
text = readFileSync36(join54(dir, "package.json"), "utf8");
|
|
42404
|
+
} catch (err) {
|
|
42405
|
+
return errnoOf(err) === "ENOENT" ? { kind: "absent" } : { kind: "unreadable", error: messageOf(err) };
|
|
42406
|
+
}
|
|
42073
42407
|
try {
|
|
42074
|
-
const pkg = JSON.parse(
|
|
42408
|
+
const pkg = JSON.parse(text);
|
|
42075
42409
|
const value = pkg.scripts?.[name];
|
|
42076
|
-
return typeof value === "string" ? value :
|
|
42077
|
-
} catch {
|
|
42078
|
-
return;
|
|
42410
|
+
return typeof value === "string" ? { kind: "body", body: value } : { kind: "absent" };
|
|
42411
|
+
} catch (err) {
|
|
42412
|
+
return { kind: "unreadable", error: messageOf(err) };
|
|
42079
42413
|
}
|
|
42080
42414
|
}
|
|
42081
42415
|
var WRITE_FLAG = /(^|\s)(--write|--fix|--apply|-w)(\s|$)/;
|
|
@@ -42083,12 +42417,19 @@ function checkWriteModeScripts(c, root, config, repos) {
|
|
|
42083
42417
|
c.in("gates");
|
|
42084
42418
|
for (const repo of repos.filter((r) => r.role === "code")) {
|
|
42085
42419
|
const dir = join54(root, repo.path);
|
|
42086
|
-
for (const
|
|
42087
|
-
|
|
42420
|
+
for (const type of GATE_TYPES) {
|
|
42421
|
+
const name = config.gates.scripts[type];
|
|
42422
|
+
if (name === undefined)
|
|
42423
|
+
continue;
|
|
42424
|
+
if (config.gates.overrides[repo.name]?.[type] !== undefined)
|
|
42088
42425
|
continue;
|
|
42089
42426
|
const script = packageScript(dir, name);
|
|
42090
|
-
if (script
|
|
42091
|
-
c.add("warn", `${repo.name} ${type} script`,
|
|
42427
|
+
if (script.kind === "unreadable") {
|
|
42428
|
+
c.add("warn", `${repo.name} ${type} script`, `package.json cannot be read (${script.error}); the gate script cannot be checked`, "fix the JSON in package.json");
|
|
42429
|
+
continue;
|
|
42430
|
+
}
|
|
42431
|
+
if (script.kind === "body" && WRITE_FLAG.test(script.body)) {
|
|
42432
|
+
c.add("warn", `${repo.name} ${type} script`, `\`${name}\` writes files: ${script.body}`, `set gates.overrides.${repo.name}.${type} to a check-only variant (it replaces the script lookup), or point gates.scripts.${type} at a check-only variant`);
|
|
42092
42433
|
}
|
|
42093
42434
|
}
|
|
42094
42435
|
}
|
|
@@ -42409,7 +42750,7 @@ function checkSandbox(c, config) {
|
|
|
42409
42750
|
c.in("security");
|
|
42410
42751
|
if (config.security.sandbox === "off")
|
|
42411
42752
|
c.add("warn", "sandbox", "off: agent shells and gates run unsandboxed", 'set security.sandbox to "auto"');
|
|
42412
|
-
else if (sandboxEnabled(config.security.sandbox))
|
|
42753
|
+
else if (sandboxEnabled(config.security.sandbox, process.platform, existsSync40, {}))
|
|
42413
42754
|
c.add("ok", "sandbox", "agent shells and gates run under macOS sandbox-exec");
|
|
42414
42755
|
else
|
|
42415
42756
|
c.add("warn", "sandbox", `no OS sandbox on ${process.platform} yet: the shell parser, plugin, audit and git layers still apply`, "run the factory on macOS for the sandbox (ADR-0026)");
|
|
@@ -45310,7 +45651,7 @@ async function askText(question, initial) {
|
|
|
45310
45651
|
rl.close();
|
|
45311
45652
|
}
|
|
45312
45653
|
}
|
|
45313
|
-
async function runCli(argv, io) {
|
|
45654
|
+
async function runCli(argv, io, commands = COMMANDS) {
|
|
45314
45655
|
let cwd = io.cwd;
|
|
45315
45656
|
let i = 0;
|
|
45316
45657
|
for (;i < argv.length; i++) {
|
|
@@ -45337,7 +45678,7 @@ async function runCli(argv, io) {
|
|
|
45337
45678
|
io.err(usage());
|
|
45338
45679
|
return ExitCode.Usage;
|
|
45339
45680
|
}
|
|
45340
|
-
const command =
|
|
45681
|
+
const command = commands.find((c) => c.name === name);
|
|
45341
45682
|
if (command === undefined) {
|
|
45342
45683
|
io.err(`error: unknown command "${name}"
|
|
45343
45684
|
|
|
@@ -45345,7 +45686,8 @@ ${usage()}`);
|
|
|
45345
45686
|
return ExitCode.Usage;
|
|
45346
45687
|
}
|
|
45347
45688
|
const rest = argv.slice(i + 1);
|
|
45348
|
-
|
|
45689
|
+
const first = rest[0];
|
|
45690
|
+
if (command.hidden !== true && (first === "-h" || first === "--help")) {
|
|
45349
45691
|
io.out(command.help);
|
|
45350
45692
|
return ExitCode.Ok;
|
|
45351
45693
|
}
|