@workit-dev/codex 1.8.0 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -278,9 +278,9 @@ var releaseTagPrefixOf = (workspaceRoot, policyPrefix) => {
|
|
|
278
278
|
};
|
|
279
279
|
|
|
280
280
|
// packages/workit-core/src/core/workspaces.ts
|
|
281
|
-
import { spawnSync as
|
|
281
|
+
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
282
282
|
import { createHash as createHash2 } from "node:crypto";
|
|
283
|
-
import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync as
|
|
283
|
+
import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync as readFileSync4, realpathSync as realpathSync2 } from "node:fs";
|
|
284
284
|
import path5 from "node:path";
|
|
285
285
|
|
|
286
286
|
// node_modules/zod/v4/core/util.js
|
|
@@ -6157,9 +6157,8 @@ function superRefine(fn, params) {
|
|
|
6157
6157
|
return _superRefine(fn, params);
|
|
6158
6158
|
}
|
|
6159
6159
|
// packages/workit-core/src/core/remotes.ts
|
|
6160
|
-
import { lstatSync, readFileSync as
|
|
6161
|
-
import { spawnSync as
|
|
6162
|
-
import os2 from "node:os";
|
|
6160
|
+
import { lstatSync, readFileSync as readFileSync3, realpathSync, statSync } from "node:fs";
|
|
6161
|
+
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
6163
6162
|
import path4 from "node:path";
|
|
6164
6163
|
|
|
6165
6164
|
// packages/workit-core/src/git/rev.ts
|
|
@@ -6899,6 +6898,56 @@ function resolveSshHost(alias, sshConfig) {
|
|
|
6899
6898
|
return { hostname: (hostname ?? alias).replace(/\.$/u, ""), port };
|
|
6900
6899
|
}
|
|
6901
6900
|
|
|
6901
|
+
// packages/workit-core/src/core/account-home.ts
|
|
6902
|
+
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
6903
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
6904
|
+
import os2 from "node:os";
|
|
6905
|
+
var WINDOWS = "C:\\Windows";
|
|
6906
|
+
var SYSTEM32 = `${WINDOWS}\\System32\\`;
|
|
6907
|
+
var PROFILES = "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\";
|
|
6908
|
+
var childEnv = (platform) => platform === "win32" ? { SystemRoot: WINDOWS } : {};
|
|
6909
|
+
var hostIo = {
|
|
6910
|
+
bun: Boolean(process.versions.bun),
|
|
6911
|
+
uid: process.getuid?.() ?? -1,
|
|
6912
|
+
userInfo: () => os2.userInfo().homedir,
|
|
6913
|
+
passwd: () => readFileSync2("/etc/passwd", "utf8"),
|
|
6914
|
+
run: (file, args) => {
|
|
6915
|
+
const done = spawnSync3(file, args, {
|
|
6916
|
+
encoding: "utf8",
|
|
6917
|
+
env: childEnv(process.platform),
|
|
6918
|
+
timeout: 3000,
|
|
6919
|
+
windowsHide: true
|
|
6920
|
+
});
|
|
6921
|
+
return done.status === 0 ? done.stdout : "";
|
|
6922
|
+
}
|
|
6923
|
+
};
|
|
6924
|
+
var field = (text, uid, at) => text.split(`
|
|
6925
|
+
`).filter((line) => !line.startsWith("#")).map((line) => line.split(":")).find((fields) => fields[2] === uid)?.[at];
|
|
6926
|
+
var profilePath = (raw) => {
|
|
6927
|
+
const value = raw.replaceAll(/%SystemDrive%/giu, WINDOWS.slice(0, 2)).replaceAll(/%SystemRoot%/giu, WINDOWS);
|
|
6928
|
+
return /^[A-Za-z]:\\/u.test(value) && !value.includes("%") ? value : null;
|
|
6929
|
+
};
|
|
6930
|
+
var accountHome = (platform = process.platform, io = hostIo) => {
|
|
6931
|
+
try {
|
|
6932
|
+
if (!io.bun)
|
|
6933
|
+
return io.userInfo() || null;
|
|
6934
|
+
if (platform === "win32") {
|
|
6935
|
+
const sid = /S-1-[\d-]+/u.exec(io.run(`${SYSTEM32}whoami.exe`, ["/user", "/fo", "csv"]));
|
|
6936
|
+
const key = sid && io.run(`${SYSTEM32}reg.exe`, ["query", PROFILES + sid[0], "/v", "ProfileImagePath"]);
|
|
6937
|
+
const raw = /ProfileImagePath\s+REG_\w+\s+(.+)/u.exec(key || "")?.[1]?.trim();
|
|
6938
|
+
return raw ? profilePath(raw) : null;
|
|
6939
|
+
}
|
|
6940
|
+
const uid = String(io.uid);
|
|
6941
|
+
let passwd = "";
|
|
6942
|
+
try {
|
|
6943
|
+
passwd = io.passwd();
|
|
6944
|
+
} catch {}
|
|
6945
|
+
return field(passwd, uid, 5) || (platform === "darwin" ? field(io.run("/usr/bin/id", ["-P"]), uid, 8) : field(io.run("/usr/bin/getent", ["passwd", uid]), uid, 5)) || null;
|
|
6946
|
+
} catch {
|
|
6947
|
+
return null;
|
|
6948
|
+
}
|
|
6949
|
+
};
|
|
6950
|
+
|
|
6902
6951
|
// packages/workit-core/src/core/remotes.ts
|
|
6903
6952
|
var FORGE_SCHEMES = new Set(["ssh", "git", "http", "https", "git+ssh", "ssh+git"]);
|
|
6904
6953
|
var SSH_SCHEMES = new Set(["ssh", "git+ssh", "ssh+git"]);
|
|
@@ -6908,15 +6957,11 @@ var SSH_443 = {
|
|
|
6908
6957
|
};
|
|
6909
6958
|
var WINDOWS_DRIVE = /^[A-Za-z]:[\\/]/u;
|
|
6910
6959
|
var SCP_LIKE = /^(?:[^@/\\]+@)?([^/\\:]+):(.+)$/u;
|
|
6911
|
-
var accountHome = () => {
|
|
6912
|
-
try {
|
|
6913
|
-
return os2.userInfo().homedir;
|
|
6914
|
-
} catch {
|
|
6915
|
-
return os2.homedir();
|
|
6916
|
-
}
|
|
6917
|
-
};
|
|
6918
6960
|
var sshSeam = {
|
|
6919
|
-
read: () =>
|
|
6961
|
+
read: () => {
|
|
6962
|
+
const home = accountHome();
|
|
6963
|
+
return home === null ? { text: "", home: "" } : readSshConfig(home);
|
|
6964
|
+
}
|
|
6920
6965
|
};
|
|
6921
6966
|
var forgeKey = (rawHost, repo, ssh) => {
|
|
6922
6967
|
let host = rawHost.toLowerCase().replace(/\.$/u, "");
|
|
@@ -6963,7 +7008,7 @@ var gitDirAt = (at, depth = 0) => {
|
|
|
6963
7008
|
return null;
|
|
6964
7009
|
try {
|
|
6965
7010
|
if (statSync(real).isFile()) {
|
|
6966
|
-
const pointer = /^gitdir:\s*(.+?)\s*$/mu.exec(
|
|
7011
|
+
const pointer = /^gitdir:\s*(.+?)\s*$/mu.exec(readFileSync3(real, "utf8"))?.[1];
|
|
6967
7012
|
if (!pointer)
|
|
6968
7013
|
return null;
|
|
6969
7014
|
const target = path4.isAbsolute(pointer) ? pointer : `${path4.dirname(real)}/${pointer}`;
|
|
@@ -6971,7 +7016,7 @@ var gitDirAt = (at, depth = 0) => {
|
|
|
6971
7016
|
}
|
|
6972
7017
|
let common;
|
|
6973
7018
|
try {
|
|
6974
|
-
common =
|
|
7019
|
+
common = readFileSync3(`${real}/commondir`, "utf8").trim();
|
|
6975
7020
|
} catch {}
|
|
6976
7021
|
if (common !== undefined) {
|
|
6977
7022
|
lstatSync(`${real}/HEAD`);
|
|
@@ -7075,7 +7120,7 @@ var checkoutRemotes = (cwd) => {
|
|
|
7075
7120
|
const env = { ...process.env };
|
|
7076
7121
|
for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
|
|
7077
7122
|
delete env[name];
|
|
7078
|
-
const git = (args) =>
|
|
7123
|
+
const git = (args) => spawnSync4("git", args, {
|
|
7079
7124
|
cwd,
|
|
7080
7125
|
env,
|
|
7081
7126
|
encoding: "utf8",
|
|
@@ -7126,6 +7171,8 @@ var userLevel = (scope, origin) => {
|
|
|
7126
7171
|
return false;
|
|
7127
7172
|
const file = realOrSelf(origin.slice("file:".length));
|
|
7128
7173
|
const home = userGitSeam.home();
|
|
7174
|
+
if (home === null)
|
|
7175
|
+
return false;
|
|
7129
7176
|
return [path4.join(home, ".gitconfig"), path4.join(home, ".config", "git", "config")].map(realOrSelf).includes(file);
|
|
7130
7177
|
};
|
|
7131
7178
|
var escapeRegex2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
@@ -7136,7 +7183,7 @@ var transportOverride = (git, remote, vars) => {
|
|
|
7136
7183
|
const execPath = vars.GIT_EXEC_PATH;
|
|
7137
7184
|
if (execPath) {
|
|
7138
7185
|
const { GIT_EXEC_PATH: _set, ...rest } = vars;
|
|
7139
|
-
const own =
|
|
7186
|
+
const own = spawnSync4("git", ["--exec-path"], {
|
|
7140
7187
|
env: rest,
|
|
7141
7188
|
encoding: "utf8"
|
|
7142
7189
|
});
|
|
@@ -7172,7 +7219,7 @@ var pushTarget = (cwd, remote, replay = {}) => {
|
|
|
7172
7219
|
delete env[name];
|
|
7173
7220
|
if (!remote || remote.startsWith("-"))
|
|
7174
7221
|
return Error(`push remote ${JSON.stringify(remote)} cannot be resolved`);
|
|
7175
|
-
const git = (args) =>
|
|
7222
|
+
const git = (args) => spawnSync4("git", [...replay.config ?? [], ...args], {
|
|
7176
7223
|
cwd,
|
|
7177
7224
|
env,
|
|
7178
7225
|
encoding: "utf8",
|
|
@@ -7404,7 +7451,7 @@ var readWorkspacesResult = (dir = configDir()) => {
|
|
|
7404
7451
|
const file = path5.join(dir, "workspaces.json");
|
|
7405
7452
|
let raw;
|
|
7406
7453
|
try {
|
|
7407
|
-
raw =
|
|
7454
|
+
raw = readFileSync4(file, "utf8");
|
|
7408
7455
|
} catch (error) {
|
|
7409
7456
|
if (error.code === "ENOENT")
|
|
7410
7457
|
return {
|
|
@@ -7525,7 +7572,7 @@ var probeCheckout = (cwd) => {
|
|
|
7525
7572
|
for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
|
|
7526
7573
|
delete env[name];
|
|
7527
7574
|
const git = (args) => {
|
|
7528
|
-
const run =
|
|
7575
|
+
const run = spawnSync5("git", args, {
|
|
7529
7576
|
cwd,
|
|
7530
7577
|
env,
|
|
7531
7578
|
encoding: "utf8",
|
|
@@ -7722,7 +7769,7 @@ var matchRuntimeWorkspace = (cwd, dir = configDir()) => {
|
|
|
7722
7769
|
const file = path5.join(dir, "workspaces.json");
|
|
7723
7770
|
let raw;
|
|
7724
7771
|
try {
|
|
7725
|
-
raw =
|
|
7772
|
+
raw = readFileSync4(file, "utf8");
|
|
7726
7773
|
} catch (error) {
|
|
7727
7774
|
if (error.code === "ENOENT")
|
|
7728
7775
|
return null;
|
|
@@ -7798,7 +7845,7 @@ var modelSources = (cwd, dir) => {
|
|
|
7798
7845
|
}
|
|
7799
7846
|
} catch {}
|
|
7800
7847
|
try {
|
|
7801
|
-
const document = JSON.parse(
|
|
7848
|
+
const document = JSON.parse(readFileSync4(path5.join(dir ?? configDir(), "workspaces.json"), "utf8"));
|
|
7802
7849
|
if (document && typeof document === "object" && !Array.isArray(document))
|
|
7803
7850
|
out.push({
|
|
7804
7851
|
name: "global",
|
|
@@ -7867,7 +7914,7 @@ import path6 from "node:path";
|
|
|
7867
7914
|
|
|
7868
7915
|
// packages/workit-core/src/core/release-tracks.ts
|
|
7869
7916
|
import { createHash as createHash3 } from "node:crypto";
|
|
7870
|
-
import { spawnSync as
|
|
7917
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
7871
7918
|
class ReleaseTrackError extends Error {
|
|
7872
7919
|
}
|
|
7873
7920
|
var KNOWN_FIELDS = new Set([
|
|
@@ -8152,7 +8199,7 @@ function resolveReleaseTrack(input) {
|
|
|
8152
8199
|
return fallback(`${branch} has the same or unrelated fork points with ${[...new Set(newest.map((fork) => `${fork.ref} (${fork.track.name === IMPLICIT ? "workspace default" : fork.track.name})`))].join(" and ")}`);
|
|
8153
8200
|
}
|
|
8154
8201
|
var git2 = (cwd, args) => {
|
|
8155
|
-
const run =
|
|
8202
|
+
const run = spawnSync6("git", args, {
|
|
8156
8203
|
cwd,
|
|
8157
8204
|
encoding: "utf8",
|
|
8158
8205
|
timeout: 20000,
|
|
@@ -8648,7 +8695,7 @@ var isProtectedTarget = (root, name) => {
|
|
|
8648
8695
|
|
|
8649
8696
|
// packages/workit-core/src/core/model-fallback.ts
|
|
8650
8697
|
import { createHash as createHash5 } from "node:crypto";
|
|
8651
|
-
import { mkdirSync as mkdirSync2, readFileSync as
|
|
8698
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, renameSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
8652
8699
|
import path7 from "node:path";
|
|
8653
8700
|
|
|
8654
8701
|
// packages/workit-core/src/core/logger.ts
|
|
@@ -8720,7 +8767,7 @@ var empty = () => ({ exhausted: {}, seen: {}, redispatched: {} });
|
|
|
8720
8767
|
var storePath = (stateDir) => path7.join(stateDir ?? resolveStateDir(), LIMITS_FILE);
|
|
8721
8768
|
var readStore = (stateDir) => {
|
|
8722
8769
|
try {
|
|
8723
|
-
const parsed = JSON.parse(
|
|
8770
|
+
const parsed = JSON.parse(readFileSync5(storePath(stateDir), "utf8"));
|
|
8724
8771
|
const store = empty();
|
|
8725
8772
|
for (const key of ["exhausted", "seen", "redispatched"])
|
|
8726
8773
|
if (parsed[key] && typeof parsed[key] === "object")
|
|
@@ -9182,13 +9229,13 @@ ${table}` : BOOTSTRAP;
|
|
|
9182
9229
|
};
|
|
9183
9230
|
|
|
9184
9231
|
// packages/workit-core/src/store/paths.ts
|
|
9185
|
-
import { spawnSync as
|
|
9232
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
9186
9233
|
import { createHash as createHash6 } from "node:crypto";
|
|
9187
9234
|
import fs4 from "node:fs";
|
|
9188
9235
|
import path8 from "node:path";
|
|
9189
9236
|
var NOT_A_REPO = /not a git repository \(or any (of the parent directories|parent up to)/u;
|
|
9190
9237
|
var gitRun = (cwd, args) => {
|
|
9191
|
-
const run =
|
|
9238
|
+
const run = spawnSync7("git", args, {
|
|
9192
9239
|
cwd,
|
|
9193
9240
|
encoding: "utf8",
|
|
9194
9241
|
timeout: 20000,
|
|
@@ -10280,7 +10327,7 @@ function candidateDigest(input) {
|
|
|
10280
10327
|
// packages/workit-core/src/core/task-evaluation.ts
|
|
10281
10328
|
import { createHash as createHash10 } from "node:crypto";
|
|
10282
10329
|
import * as fs13 from "node:fs";
|
|
10283
|
-
import { spawnSync as
|
|
10330
|
+
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
10284
10331
|
import path18 from "node:path";
|
|
10285
10332
|
|
|
10286
10333
|
// packages/workit-core/src/core/task-read.ts
|
|
@@ -10904,7 +10951,7 @@ var packageRoot = () => {
|
|
|
10904
10951
|
};
|
|
10905
10952
|
|
|
10906
10953
|
// packages/workit-core/src/core/store-lock.ts
|
|
10907
|
-
import { spawnSync as
|
|
10954
|
+
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
10908
10955
|
import fs8 from "node:fs";
|
|
10909
10956
|
import { hostname } from "node:os";
|
|
10910
10957
|
var metadataLockSchema = object({
|
|
@@ -10955,7 +11002,7 @@ var readProcStat = (pid) => {
|
|
|
10955
11002
|
};
|
|
10956
11003
|
var psStart = (pid) => {
|
|
10957
11004
|
try {
|
|
10958
|
-
const run =
|
|
11005
|
+
const run = spawnSync8("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
10959
11006
|
encoding: "utf8",
|
|
10960
11007
|
timeout: 1000,
|
|
10961
11008
|
env: { ...process.env, LC_ALL: "C" }
|
|
@@ -12181,19 +12228,19 @@ import { existsSync as existsSync6 } from "node:fs";
|
|
|
12181
12228
|
import path17 from "node:path";
|
|
12182
12229
|
|
|
12183
12230
|
// packages/workit-core/src/ledger.ts
|
|
12184
|
-
import { spawnSync as
|
|
12231
|
+
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
12185
12232
|
import { createHash as createHash9, randomBytes as randomBytes3 } from "node:crypto";
|
|
12186
12233
|
import fs12 from "node:fs";
|
|
12187
12234
|
import path16 from "node:path";
|
|
12188
12235
|
|
|
12189
12236
|
// packages/workit-core/src/core/policy/bookkeeping.ts
|
|
12190
|
-
import { spawnSync as
|
|
12237
|
+
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
12191
12238
|
var OID = /^[0-9a-f]{40,64}$/u;
|
|
12192
12239
|
var safe = (value) => value.length > 0 && !value.startsWith("-");
|
|
12193
12240
|
function replayTree(cwd, from, fromFork, toFork) {
|
|
12194
12241
|
if (![from, fromFork, toFork].every(safe))
|
|
12195
12242
|
return null;
|
|
12196
|
-
const run =
|
|
12243
|
+
const run = spawnSync9("git", ["merge-tree", "--write-tree", "--no-messages", `--merge-base=${fromFork}`, toFork, from], {
|
|
12197
12244
|
cwd,
|
|
12198
12245
|
encoding: "utf8",
|
|
12199
12246
|
timeout: GIT_TIMEOUTS.worktree,
|
|
@@ -12264,11 +12311,11 @@ function bookkeepingPaths(cwd, input) {
|
|
|
12264
12311
|
}
|
|
12265
12312
|
|
|
12266
12313
|
// packages/workit-core/src/core/policy/lane.ts
|
|
12267
|
-
import { existsSync as existsSync5, readFileSync as
|
|
12314
|
+
import { existsSync as existsSync5, readFileSync as readFileSync7 } from "node:fs";
|
|
12268
12315
|
import path14 from "node:path";
|
|
12269
12316
|
|
|
12270
12317
|
// packages/workit-core/src/git/default-base.ts
|
|
12271
|
-
import { spawnSync as
|
|
12318
|
+
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
12272
12319
|
var safeRef = (value) => value.length > 0 && !value.startsWith("-");
|
|
12273
12320
|
var trackTrunk = (cwd) => {
|
|
12274
12321
|
try {
|
|
@@ -12318,7 +12365,7 @@ var shorten = (table, full) => {
|
|
|
12318
12365
|
return full;
|
|
12319
12366
|
};
|
|
12320
12367
|
function refTable(cwd) {
|
|
12321
|
-
const run =
|
|
12368
|
+
const run = spawnSync10("git", ["for-each-ref", "--format=%(refname)%00%(objecttype)%00%(*objecttype)%00%(symref)"], { cwd, encoding: "utf8", timeout: 20000, killSignal: "SIGKILL", windowsHide: true });
|
|
12322
12369
|
if (run.status !== 0)
|
|
12323
12370
|
return null;
|
|
12324
12371
|
const refs = new Map;
|
|
@@ -12919,7 +12966,7 @@ function computeLane(input) {
|
|
|
12919
12966
|
}
|
|
12920
12967
|
function untrackedStat(cwd, file) {
|
|
12921
12968
|
try {
|
|
12922
|
-
const bytes =
|
|
12969
|
+
const bytes = readFileSync7(path14.join(cwd, file));
|
|
12923
12970
|
if (bytes.includes(0))
|
|
12924
12971
|
return { path: file, added: 0, deleted: 0, binary: true };
|
|
12925
12972
|
const text = bytes.toString("utf8");
|
|
@@ -12950,7 +12997,7 @@ function cosmeticFiles(cwd, fork, head) {
|
|
|
12950
12997
|
let after = blobs.get(entry.newBlob);
|
|
12951
12998
|
if (!after && head === null && ABSENT.test(entry.newBlob))
|
|
12952
12999
|
try {
|
|
12953
|
-
after =
|
|
13000
|
+
after = readFileSync7(path14.join(cwd, entry.path));
|
|
12954
13001
|
} catch {
|
|
12955
13002
|
after = undefined;
|
|
12956
13003
|
}
|
|
@@ -13265,7 +13312,7 @@ var err = (code, error, unblock) => ({
|
|
|
13265
13312
|
...unblock ? { unblock } : {}
|
|
13266
13313
|
});
|
|
13267
13314
|
var gitRun2 = (cwd, args, timeoutMs = GIT_TIMEOUTS.local) => {
|
|
13268
|
-
const run =
|
|
13315
|
+
const run = spawnSync11("git", args, {
|
|
13269
13316
|
cwd,
|
|
13270
13317
|
encoding: "utf8",
|
|
13271
13318
|
timeout: timeoutMs,
|
|
@@ -14485,7 +14532,7 @@ var compareCodeUnits2 = (left, right) => {
|
|
|
14485
14532
|
return left.length - right.length;
|
|
14486
14533
|
};
|
|
14487
14534
|
var gitPaths = (root) => {
|
|
14488
|
-
const result =
|
|
14535
|
+
const result = spawnSync12("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
|
|
14489
14536
|
cwd: root,
|
|
14490
14537
|
encoding: "buffer"
|
|
14491
14538
|
});
|
|
@@ -14498,7 +14545,7 @@ var gitPaths = (root) => {
|
|
|
14498
14545
|
};
|
|
14499
14546
|
}
|
|
14500
14547
|
const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path18.sep).join("/")) : [];
|
|
14501
|
-
const stagedDeleted =
|
|
14548
|
+
const stagedDeleted = spawnSync12("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
|
|
14502
14549
|
if (stagedDeleted.status !== 0) {
|
|
14503
14550
|
const stderr = stagedDeleted.stderr?.toString("utf8") ?? "";
|
|
14504
14551
|
if (!/not a git repository/i.test(stderr))
|
|
@@ -14629,7 +14676,7 @@ function captureCandidate(root, scope, environment = []) {
|
|
|
14629
14676
|
const values = supplied.toSorted((left, right) => compareCodeUnits2(left.name, right.name)).map(({ name, value }) => ({ name, value, refs: [] }));
|
|
14630
14677
|
if (values.some(({ value }) => value === null))
|
|
14631
14678
|
completeness = "uncertain";
|
|
14632
|
-
const headResult =
|
|
14679
|
+
const headResult = spawnSync12("git", ["rev-parse", "HEAD"], { cwd: checkout, encoding: "utf8" });
|
|
14633
14680
|
if (headResult.status !== 0 && !/not a git repository/i.test(headResult.stderr ?? ""))
|
|
14634
14681
|
completeness = "uncertain";
|
|
14635
14682
|
const head = headResult.status === 0 ? headResult.stdout.trim() : null;
|
|
@@ -15443,19 +15490,18 @@ var seedTurnContext = (input, descriptor, text = turnContextText(input, descript
|
|
|
15443
15490
|
clearTurnDigest(file);
|
|
15444
15491
|
};
|
|
15445
15492
|
// packages/workit-core/src/core/route-intent.ts
|
|
15446
|
-
import { spawnSync as
|
|
15493
|
+
import { spawnSync as spawnSync14 } from "node:child_process";
|
|
15447
15494
|
import { existsSync as existsSync9 } from "node:fs";
|
|
15448
15495
|
import path24 from "node:path";
|
|
15449
15496
|
|
|
15450
15497
|
// packages/workit-core/src/hooks/raw-git.ts
|
|
15451
|
-
import { spawnSync as
|
|
15498
|
+
import { spawnSync as spawnSync13 } from "node:child_process";
|
|
15452
15499
|
import { createHash as createHash13 } from "node:crypto";
|
|
15453
15500
|
import fs16 from "node:fs";
|
|
15454
|
-
import
|
|
15501
|
+
import os5 from "node:os";
|
|
15455
15502
|
import path23 from "node:path";
|
|
15456
15503
|
|
|
15457
15504
|
// packages/workit-core/src/autonomy.ts
|
|
15458
|
-
import os5 from "node:os";
|
|
15459
15505
|
import path21 from "node:path";
|
|
15460
15506
|
|
|
15461
15507
|
// packages/workit-core/src/core/eval-world.ts
|
|
@@ -15468,30 +15514,43 @@ var inside2 = (dir, file) => {
|
|
|
15468
15514
|
const rel = path20.relative(dir, file);
|
|
15469
15515
|
return !rel.startsWith("..") && !path20.isAbsolute(rel);
|
|
15470
15516
|
};
|
|
15471
|
-
var
|
|
15517
|
+
var evalWorld = (cwd) => {
|
|
15472
15518
|
const raw = process.env[EVAL_WORLD_ENV];
|
|
15473
15519
|
if (!raw || !path20.isAbsolute(raw))
|
|
15474
15520
|
return null;
|
|
15475
15521
|
try {
|
|
15476
15522
|
const world = realpathSync6(raw);
|
|
15477
|
-
|
|
15478
|
-
return null;
|
|
15479
|
-
return loadWorkspacesFrom(path20.join(world, "config"))[0] ?? null;
|
|
15523
|
+
return inside2(realpathSync6(os4.tmpdir()), world) && inside2(world, realpathSync6(cwd)) && existsSync8(path20.join(world, EVAL_WORLD_MARKER)) ? world : null;
|
|
15480
15524
|
} catch {
|
|
15481
15525
|
return null;
|
|
15482
15526
|
}
|
|
15483
15527
|
};
|
|
15484
|
-
|
|
15485
|
-
|
|
15486
|
-
var accountHome2 = () => {
|
|
15528
|
+
var evalWorldEntry = (cwd) => {
|
|
15529
|
+
const world = evalWorld(cwd);
|
|
15487
15530
|
try {
|
|
15488
|
-
return
|
|
15531
|
+
return world ? loadWorkspacesFrom(path20.join(world, "config"))[0] ?? null : null;
|
|
15489
15532
|
} catch {
|
|
15490
|
-
return
|
|
15533
|
+
return null;
|
|
15491
15534
|
}
|
|
15492
15535
|
};
|
|
15493
|
-
|
|
15494
|
-
|
|
15536
|
+
|
|
15537
|
+
// packages/workit-core/src/autonomy.ts
|
|
15538
|
+
var grantsHome = { resolve: accountHome };
|
|
15539
|
+
var accountDir = () => {
|
|
15540
|
+
const home = grantsHome.resolve();
|
|
15541
|
+
return home === null ? null : configDir2({ HOME: home });
|
|
15542
|
+
};
|
|
15543
|
+
var grantsDir = () => accountDir() ?? resolveConfigDir();
|
|
15544
|
+
var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
|
|
15545
|
+
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
15546
|
+
var resolveFrom = (cwd, name) => {
|
|
15547
|
+
const dir = accountDir();
|
|
15548
|
+
return dir === null ? null : resolveWorkspaceFrom(cwd, dir, name);
|
|
15549
|
+
};
|
|
15550
|
+
var shownGrantsDir = () => {
|
|
15551
|
+
const world = evalWorld(process.cwd());
|
|
15552
|
+
return world ? path21.join(world, "config") : accountDir();
|
|
15553
|
+
};
|
|
15495
15554
|
var benchWorld = (cwd) => {
|
|
15496
15555
|
const entry = evalWorldEntry(cwd);
|
|
15497
15556
|
if (!entry)
|
|
@@ -15511,8 +15570,11 @@ var benchWorld = (cwd) => {
|
|
|
15511
15570
|
};
|
|
15512
15571
|
};
|
|
15513
15572
|
var grantsOverride = () => {
|
|
15573
|
+
const shown = shownGrantsDir();
|
|
15574
|
+
if (shown === null)
|
|
15575
|
+
return NO_ACCOUNT;
|
|
15514
15576
|
const configured = path21.resolve(resolveConfigDir());
|
|
15515
|
-
return configured === path21.resolve(
|
|
15577
|
+
return configured === path21.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path21.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
|
|
15516
15578
|
};
|
|
15517
15579
|
var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
|
|
15518
15580
|
var DEFAULT_GRANTS = Object.freeze({
|
|
@@ -15638,7 +15700,7 @@ function capAt(named, where, by, why, main = false) {
|
|
|
15638
15700
|
try {
|
|
15639
15701
|
if (where instanceof Error)
|
|
15640
15702
|
throw where;
|
|
15641
|
-
folder = autonomyOf(typeof where === "string" ?
|
|
15703
|
+
folder = autonomyOf(typeof where === "string" ? resolveFrom(where) : where.entry);
|
|
15642
15704
|
} catch (error) {
|
|
15643
15705
|
none = error.message;
|
|
15644
15706
|
}
|
|
@@ -15682,7 +15744,10 @@ function resolveAutonomy(cwd, target) {
|
|
|
15682
15744
|
if (override)
|
|
15683
15745
|
return { ...autonomyOf(null), note: override };
|
|
15684
15746
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
15685
|
-
|
|
15747
|
+
const real = resolveFrom(cwd, name);
|
|
15748
|
+
let autonomy = autonomyOf(real ?? world);
|
|
15749
|
+
if (!real && world)
|
|
15750
|
+
autonomy.world = evalWorld(cwd) ?? undefined;
|
|
15686
15751
|
if (name)
|
|
15687
15752
|
autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
15688
15753
|
const above = checkoutsAbove(cwd);
|
|
@@ -15691,7 +15756,7 @@ function resolveAutonomy(cwd, target) {
|
|
|
15691
15756
|
return capAtRemotes(autonomy, cwd, target);
|
|
15692
15757
|
}
|
|
15693
15758
|
function capAtRemotes(autonomy, cwd, target) {
|
|
15694
|
-
const claiming =
|
|
15759
|
+
const claiming = entriesIn(accountDir()).filter((entry) => entry.remotes?.length);
|
|
15695
15760
|
if (claiming.length === 0)
|
|
15696
15761
|
return autonomy;
|
|
15697
15762
|
const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
|
|
@@ -15706,15 +15771,15 @@ function capAtRemotes(autonomy, cwd, target) {
|
|
|
15706
15771
|
}
|
|
15707
15772
|
return capped;
|
|
15708
15773
|
}
|
|
15709
|
-
var grantsMatter = (kind) => !grantsOverride() &&
|
|
15774
|
+
var grantsMatter = (kind) => !grantsOverride() && entriesIn(accountDir()).some((entry) => {
|
|
15710
15775
|
const autonomy = autonomyOf(entry);
|
|
15711
15776
|
return entry.remotes?.length || autonomy.grants[kind] === false || autonomy.configured.length > 0 && !autonomy.accountConfigured;
|
|
15712
15777
|
});
|
|
15713
|
-
var remotesClaimed = (dir =
|
|
15714
|
-
function targetClaims(target, dir =
|
|
15778
|
+
var remotesClaimed = (dir = accountDir()) => entriesIn(dir).some((entry) => entry.remotes?.length);
|
|
15779
|
+
function targetClaims(target, dir = accountDir()) {
|
|
15715
15780
|
if (target instanceof Error)
|
|
15716
15781
|
return target;
|
|
15717
|
-
const claiming =
|
|
15782
|
+
const claiming = entriesIn(dir).filter((entry) => entry.remotes?.length);
|
|
15718
15783
|
return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
|
|
15719
15784
|
const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
|
|
15720
15785
|
return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
|
|
@@ -15752,7 +15817,7 @@ function rawGrantDenial(cwd, kind, target) {
|
|
|
15752
15817
|
const claims = targetClaims(lazy());
|
|
15753
15818
|
if (claims instanceof Error)
|
|
15754
15819
|
return { error: `${kind}: ${claims.message}`, unblock: "name a target workit can resolve" };
|
|
15755
|
-
const entries =
|
|
15820
|
+
const entries = entriesIn(accountDir());
|
|
15756
15821
|
const strict = claims.find(({ workspace: name }) => {
|
|
15757
15822
|
const entry = entries.find((item) => item.name === name);
|
|
15758
15823
|
return entry && autonomyOf(entry).grants[kind] === false;
|
|
@@ -16160,7 +16225,9 @@ var tokenize = (command, dialect) => {
|
|
|
16160
16225
|
heredocs.push({ delimiter: text.replace(/^-/, ""), owner: current });
|
|
16161
16226
|
else if (pending === "herestring")
|
|
16162
16227
|
(current.stdin ??= []).push(text);
|
|
16163
|
-
else if (pending
|
|
16228
|
+
else if (pending === "input")
|
|
16229
|
+
(current.inputs ??= []).push(text);
|
|
16230
|
+
else {
|
|
16164
16231
|
const at = current.words.length;
|
|
16165
16232
|
current.words.push(...MARKERS.test(word) ? expandBraces(word) : [word]);
|
|
16166
16233
|
if (expanding || !posix && word.startsWith("@"))
|
|
@@ -16406,7 +16473,7 @@ var joinDir = (base, raw) => {
|
|
|
16406
16473
|
const next = raw.replace(HERE, ".");
|
|
16407
16474
|
if (base === undefined || /[$`*?]/.test(next) || next === "-")
|
|
16408
16475
|
return;
|
|
16409
|
-
const expanded = next === "~" || next.startsWith("~/") ? path23.join(
|
|
16476
|
+
const expanded = next === "~" || next.startsWith("~/") ? path23.join(os5.homedir(), next.slice(1)) : next;
|
|
16410
16477
|
return base === null || isAbsolute(expanded) ? expanded : path23.join(base, expanded);
|
|
16411
16478
|
};
|
|
16412
16479
|
var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
|
|
@@ -16808,7 +16875,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
|
|
|
16808
16875
|
}
|
|
16809
16876
|
if (CD.has(name)) {
|
|
16810
16877
|
const target = cdTarget(words);
|
|
16811
|
-
dir = target === null ?
|
|
16878
|
+
dir = target === null ? os5.homedir() : joinDir(dir, target);
|
|
16812
16879
|
} else if (PUSHD.has(name)) {
|
|
16813
16880
|
const target = cdTarget(words);
|
|
16814
16881
|
stack.push(dir);
|
|
@@ -17351,7 +17418,7 @@ var gitConfig = (dir, invocation, cache) => {
|
|
|
17351
17418
|
if (cached)
|
|
17352
17419
|
return cached;
|
|
17353
17420
|
const config = new Map;
|
|
17354
|
-
const listed =
|
|
17421
|
+
const listed = spawnSync13("git", [...invocation.config ?? [], "config", "-z", "--list"], {
|
|
17355
17422
|
cwd: dir,
|
|
17356
17423
|
encoding: "utf8",
|
|
17357
17424
|
timeout: 3000,
|
|
@@ -17524,7 +17591,7 @@ var refFacts = (repo, remote) => {
|
|
|
17524
17591
|
tags: new Set,
|
|
17525
17592
|
remoteHeads: new Set
|
|
17526
17593
|
};
|
|
17527
|
-
const listed =
|
|
17594
|
+
const listed = spawnSync13("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/tags", `refs/remotes/${remote}`], { cwd: repo.dir, encoding: "utf8", timeout: 5000 });
|
|
17528
17595
|
const remotePrefix = `refs/remotes/${remote}/`;
|
|
17529
17596
|
for (const ref of (listed.stdout ?? "").split(`
|
|
17530
17597
|
`)) {
|
|
@@ -17541,7 +17608,7 @@ var globBranches = (repo, glob) => {
|
|
|
17541
17608
|
const source = glob.source.startsWith("refs/") ? glob.source : `refs/heads/${glob.source}`;
|
|
17542
17609
|
const [sourcePrefix, sourceSuffix = ""] = source.split("*");
|
|
17543
17610
|
const [destinationPrefix, destinationSuffix = ""] = glob.destination.split("*");
|
|
17544
|
-
const listed =
|
|
17611
|
+
const listed = spawnSync13("git", [
|
|
17545
17612
|
"for-each-ref",
|
|
17546
17613
|
"--format=%(refname)",
|
|
17547
17614
|
sourcePrefix.slice(0, sourcePrefix.lastIndexOf("/") + 1)
|
|
@@ -17618,7 +17685,7 @@ var tagRefusal = (action, facts, dir) => {
|
|
|
17618
17685
|
return `workit: raw ${quote(`git push${action.allTags ? " --tags" : ""}`)} of ${tags.length ? `tag ${tags.join(", ")}` : "tags"} bypasses the release grant. Push a release tag with ${quote(`workit git push --release ${named}`)} (${shape} tags whose commit the production branch already has; a tag never moves), under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}).`;
|
|
17619
17686
|
};
|
|
17620
17687
|
var remoteHeads = (repo, remote) => {
|
|
17621
|
-
const listed =
|
|
17688
|
+
const listed = spawnSync13("git", ["ls-remote", "--heads", remote], {
|
|
17622
17689
|
cwd: repo.dir,
|
|
17623
17690
|
encoding: "utf8",
|
|
17624
17691
|
timeout: 3000,
|
|
@@ -17839,7 +17906,7 @@ var cdCommitCall = (input, command, target, repo) => {
|
|
|
17839
17906
|
if (!messages.length)
|
|
17840
17907
|
return null;
|
|
17841
17908
|
if (!all) {
|
|
17842
|
-
const staged =
|
|
17909
|
+
const staged = spawnSync13("git", ["diff", "--cached", "--quiet"], {
|
|
17843
17910
|
cwd: target,
|
|
17844
17911
|
timeout: 5000
|
|
17845
17912
|
});
|
|
@@ -18001,7 +18068,7 @@ function noteRawCommit(input, command, key) {
|
|
|
18001
18068
|
} catch {}
|
|
18002
18069
|
}
|
|
18003
18070
|
var headCommit = (dir) => {
|
|
18004
|
-
const run =
|
|
18071
|
+
const run = spawnSync13("git", [
|
|
18005
18072
|
"log",
|
|
18006
18073
|
"-1",
|
|
18007
18074
|
"--format=%H%x1f%ct%x1f%s%x1f%(trailers:key=Workit-Session,valueonly,separator=%x2c)"
|
|
@@ -18225,7 +18292,7 @@ var targetsOf = (invocations) => invocations.flatMap((invocation) => invocation.
|
|
|
18225
18292
|
branch,
|
|
18226
18293
|
dir: invocation.dir
|
|
18227
18294
|
})) : []);
|
|
18228
|
-
var localBranchExists = (dir, branch) =>
|
|
18295
|
+
var localBranchExists = (dir, branch) => spawnSync14("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], {
|
|
18229
18296
|
cwd: dir,
|
|
18230
18297
|
stdio: "ignore",
|
|
18231
18298
|
timeout: 5000
|
|
@@ -18357,7 +18424,7 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
|
|
|
18357
18424
|
};
|
|
18358
18425
|
// packages/workit-core/src/core/heavy-rules.ts
|
|
18359
18426
|
import fs17 from "node:fs";
|
|
18360
|
-
import
|
|
18427
|
+
import os6 from "node:os";
|
|
18361
18428
|
import path25 from "node:path";
|
|
18362
18429
|
var EMPTY2 = () => ({ deny: [], allow: [] });
|
|
18363
18430
|
var readText3 = (file) => {
|
|
@@ -18415,7 +18482,7 @@ var projectDirs = (cwd) => {
|
|
|
18415
18482
|
return dirs;
|
|
18416
18483
|
}
|
|
18417
18484
|
};
|
|
18418
|
-
var homeOf = (env) => env.HOME ||
|
|
18485
|
+
var homeOf = (env) => env.HOME || os6.homedir();
|
|
18419
18486
|
var CLAUDE_MANAGED = {
|
|
18420
18487
|
linux: "/etc/claude-code/managed-settings.json",
|
|
18421
18488
|
darwin: "/Library/Application Support/ClaudeCode/managed-settings.json",
|
|
@@ -19097,21 +19164,21 @@ var splitDenial = (plan) => ({
|
|
|
19097
19164
|
unblock: plan.unblock
|
|
19098
19165
|
});
|
|
19099
19166
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
19100
|
-
import { existsSync as existsSync10, realpathSync as realpathSync7, statSync as statSync3 } from "node:fs";
|
|
19101
|
-
import
|
|
19167
|
+
import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync9, realpathSync as realpathSync7, statSync as statSync3 } from "node:fs";
|
|
19168
|
+
import os8 from "node:os";
|
|
19102
19169
|
import path28 from "node:path";
|
|
19103
19170
|
|
|
19104
19171
|
// packages/workit-core/src/core/live-session.ts
|
|
19105
|
-
import { spawnSync as
|
|
19172
|
+
import { spawnSync as spawnSync15 } from "node:child_process";
|
|
19106
19173
|
import { createHash as createHash14 } from "node:crypto";
|
|
19107
19174
|
import fs19 from "node:fs";
|
|
19108
|
-
import
|
|
19175
|
+
import os7 from "node:os";
|
|
19109
19176
|
import path27 from "node:path";
|
|
19110
19177
|
var LIVE_SESSION_TTL_MS = 15 * 60000;
|
|
19111
19178
|
var HEARTBEAT_EVERY_MS = 30000;
|
|
19112
19179
|
var liveProbe = {
|
|
19113
19180
|
platform: process.platform,
|
|
19114
|
-
run: (args) =>
|
|
19181
|
+
run: (args) => spawnSync15("ps", args, { encoding: "utf8", timeout: 2000 }).stdout ?? "",
|
|
19115
19182
|
start: (pid) => processStartOf(pid)
|
|
19116
19183
|
};
|
|
19117
19184
|
var leadOf = (session) => session.split(":")[0].replace(/-w-.*$/su, "") || session;
|
|
@@ -19231,7 +19298,7 @@ var isLive = (marker, deps) => {
|
|
|
19231
19298
|
const age = ageOf2(marker, deps.now ?? new Date);
|
|
19232
19299
|
if (age > (deps.ttlMs ?? LIVE_SESSION_TTL_MS))
|
|
19233
19300
|
return false;
|
|
19234
|
-
if (marker.machine !== (deps.machine ??
|
|
19301
|
+
if (marker.machine !== (deps.machine ?? os7.hostname()) || marker.pid === null)
|
|
19235
19302
|
return true;
|
|
19236
19303
|
if (!(deps.alive ?? processAlive)(marker.pid))
|
|
19237
19304
|
return false;
|
|
@@ -19260,7 +19327,7 @@ var liveConflict = (target, owner, deps = {}) => {
|
|
|
19260
19327
|
const marker = readMarker(file);
|
|
19261
19328
|
if (!marker || sameLead(marker, owner) || !isLive(marker, deps))
|
|
19262
19329
|
return null;
|
|
19263
|
-
if (sameOwner(marker, owner, deps.machine ??
|
|
19330
|
+
if (sameOwner(marker, owner, deps.machine ?? os7.hostname()))
|
|
19264
19331
|
return null;
|
|
19265
19332
|
return { marker, file, ageMs: ageOf2(marker, deps.now ?? new Date), checkout };
|
|
19266
19333
|
} catch {
|
|
@@ -19274,7 +19341,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
|
|
|
19274
19341
|
return;
|
|
19275
19342
|
const file = markerFile2(checkout);
|
|
19276
19343
|
const now = deps.now ?? new Date;
|
|
19277
|
-
const machine = deps.machine ??
|
|
19344
|
+
const machine = deps.machine ?? os7.hostname();
|
|
19278
19345
|
const current = readMarker(file);
|
|
19279
19346
|
if (current) {
|
|
19280
19347
|
const age = ageOf2(current, now);
|
|
@@ -19363,9 +19430,9 @@ var editsOf = (input) => {
|
|
|
19363
19430
|
case "cp":
|
|
19364
19431
|
case "ln":
|
|
19365
19432
|
case "install": {
|
|
19366
|
-
const
|
|
19367
|
-
if (
|
|
19368
|
-
return
|
|
19433
|
+
const into = valueOf(args, /^(?:-t|--target-directory=?)(.*)$/s);
|
|
19434
|
+
if (into !== undefined)
|
|
19435
|
+
return [into];
|
|
19369
19436
|
const last = operands(args).at(-1);
|
|
19370
19437
|
return last ? [last] : null;
|
|
19371
19438
|
}
|
|
@@ -19419,6 +19486,84 @@ var editsOf = (input) => {
|
|
|
19419
19486
|
return [];
|
|
19420
19487
|
}
|
|
19421
19488
|
};
|
|
19489
|
+
var WRAPPERS2 = {
|
|
19490
|
+
sudo: "ugCDhpRrTtU",
|
|
19491
|
+
doas: "uC",
|
|
19492
|
+
env: "uCS",
|
|
19493
|
+
nice: "n",
|
|
19494
|
+
ionice: "cnp",
|
|
19495
|
+
timeout: "sk",
|
|
19496
|
+
stdbuf: "ioe",
|
|
19497
|
+
time: "fo",
|
|
19498
|
+
nohup: "",
|
|
19499
|
+
command: "",
|
|
19500
|
+
exec: "a",
|
|
19501
|
+
setsid: "",
|
|
19502
|
+
builtin: "",
|
|
19503
|
+
"!": "",
|
|
19504
|
+
npx: "p",
|
|
19505
|
+
bunx: "p"
|
|
19506
|
+
};
|
|
19507
|
+
var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
|
|
19508
|
+
var isConfigDir = (file) => configDirs().some((dir) => canonical3(dir) === canonical3(file));
|
|
19509
|
+
var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path28.relative(canonical3(resolveStateDir()), canonical3(file)));
|
|
19510
|
+
var READ_CALLS = /^(?:print|log|info|warn|error|debug|puts|readdir(?:Sync)?|listdir|scandir|iterdir|glob|l?stat(?:Sync)?|exists(?:Sync)?|isdir|isfile|is_dir|is_file|access(?:Sync)?|realpath(?:Sync)?|dirname|basename|relative|str|repr|len)$/;
|
|
19511
|
+
var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move|copy(?:2|file|tree|File)?(?:Sync)?|cp(?:Sync)?|rm(?:tree|dir|Sync|dirSync)?|unlink(?:Sync)?|remove(?:dirs)?|mkdirs?(?:Sync)?|makedirs|mkdtemp(?:Sync)?|(?:sym|hard)?link(?:Sync|_to)?|write\w*|append\w*|truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
|
|
19512
|
+
var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
|
|
19513
|
+
var readsRoot = (text, at) => {
|
|
19514
|
+
let call;
|
|
19515
|
+
for (let index = at, depth = 0;index > 0 && call === undefined; index--) {
|
|
19516
|
+
const char = text[index - 1];
|
|
19517
|
+
if (char === ")")
|
|
19518
|
+
depth++;
|
|
19519
|
+
else if (char === "(" && depth-- === 0)
|
|
19520
|
+
call = /([\w$]+)\s*$/.exec(text.slice(0, index - 1))?.[1] ?? "";
|
|
19521
|
+
else if (depth <= 0 && /[;\n]/.test(char))
|
|
19522
|
+
break;
|
|
19523
|
+
}
|
|
19524
|
+
if (call !== undefined && READ_CALLS.test(call))
|
|
19525
|
+
return true;
|
|
19526
|
+
if (call !== undefined && !PATH_CALLS.test(call))
|
|
19527
|
+
return false;
|
|
19528
|
+
return ![...text.matchAll(/([\w$]+)\s*\(/g)].some(([, name]) => MUTATING_CALLS.test(name));
|
|
19529
|
+
};
|
|
19530
|
+
var inertEdit = (command) => command.split("|").every((part) => /^:?(?:se(?:t)?|sy(?:ntax)?|colo(?:rscheme)?)(?:\s|$)|^[/?][^/?]*[/?]?$|^\d+$/.test(part.trim()));
|
|
19531
|
+
var SCRIPT_OPTIONS = [
|
|
19532
|
+
[/^(?:(?:ba|z|k|da)?sh|source|\.)$/, /^(?:[-+][oO]|--(?:rcfile|init-file))$/],
|
|
19533
|
+
[/^python/, /^-[WXQ]$/],
|
|
19534
|
+
[
|
|
19535
|
+
/./,
|
|
19536
|
+
/^(?:-[rCI]|--(?:require|import|(?:experimental-)?loader|preload|input-type|conditions|title|cwd|tsconfig|project|env-file|config))$/
|
|
19537
|
+
]
|
|
19538
|
+
];
|
|
19539
|
+
var PRELOAD = /^(?:-r|--(?:require|import|(?:experimental-)?loader|preload|rcfile|init-file))$/;
|
|
19540
|
+
var scriptArgs = (verb, args) => {
|
|
19541
|
+
const takes = SCRIPT_OPTIONS.find(([family]) => family.test(verb))?.[1] ?? /^$/;
|
|
19542
|
+
const preloads = [];
|
|
19543
|
+
for (let at = 0;at < args.length; at++) {
|
|
19544
|
+
const [option, value] = args[at].split(/=(.*)/s);
|
|
19545
|
+
if (value !== undefined && PRELOAD.test(option))
|
|
19546
|
+
preloads.push(value);
|
|
19547
|
+
else if (/^-[mce]$|^--(?:eval|print)$/.test(option))
|
|
19548
|
+
break;
|
|
19549
|
+
else if (takes.test(option)) {
|
|
19550
|
+
if (PRELOAD.test(option))
|
|
19551
|
+
preloads.push(args[at + 1] ?? "");
|
|
19552
|
+
at++;
|
|
19553
|
+
} else if (!/^[-+]/.test(option) && option !== "run")
|
|
19554
|
+
return { named: args[at], preloads };
|
|
19555
|
+
}
|
|
19556
|
+
return { preloads };
|
|
19557
|
+
};
|
|
19558
|
+
var unwrapped = (words) => {
|
|
19559
|
+
let at = 0;
|
|
19560
|
+
for (let takes;(takes = WRAPPERS2[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; ) {
|
|
19561
|
+
at++;
|
|
19562
|
+
while (at < words.length && /^-|^\w+=|^\d[\w.]*$/.test(words[at]))
|
|
19563
|
+
at += words[at].length === 2 && words[at][0] === "-" && takes.includes(words[at][1]) ? 2 : 1;
|
|
19564
|
+
}
|
|
19565
|
+
return at ? words.slice(at) : null;
|
|
19566
|
+
};
|
|
19422
19567
|
var shellScript2 = (words) => {
|
|
19423
19568
|
if (!SCRIPT_SHELLS.has((words[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase()))
|
|
19424
19569
|
return null;
|
|
@@ -19663,9 +19808,8 @@ var gitOutputs = (args) => {
|
|
|
19663
19808
|
const under = (file) => file === "." ? `${base}/${OPAQUE_TARGET}git` : /^[/~$]|^[A-Za-z]:[\\/]/.test(file) ? file : `${base}/${file}`;
|
|
19664
19809
|
return files.length ? files.map(under) : null;
|
|
19665
19810
|
};
|
|
19666
|
-
var
|
|
19667
|
-
|
|
19668
|
-
].map((match) => match[0]);
|
|
19811
|
+
var PATHS = /(?<![\w.~:/$-])(?:~\/|\/|[A-Za-z]:\/|\.\.(?:\/|$))[^\s'"`$),;:*?<>|\\[\]{}]*/g;
|
|
19812
|
+
var pathsIn = (text) => [...text.matchAll(PATHS)].map((match) => match[0]);
|
|
19669
19813
|
var linkSources = (args, at) => {
|
|
19670
19814
|
const names = operands([...args]);
|
|
19671
19815
|
const into = args.indexOf("-t");
|
|
@@ -19792,16 +19936,16 @@ var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
|
19792
19936
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
19793
19937
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
19794
19938
|
var UNKNOWN_DIR = path28.resolve(path28.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
19795
|
-
var cdInto = (dir, words, strict = false, vars = new Map) => {
|
|
19939
|
+
var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
19796
19940
|
const lost = strict ? UNKNOWN_DIR : undefined;
|
|
19797
19941
|
const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
|
|
19798
19942
|
const named = found === undefined ? undefined : expandVars(found, vars);
|
|
19799
19943
|
const target = named === undefined ? undefined : homeExpanded(named);
|
|
19800
|
-
if (target === "-" || target && /^~|[$`*?]
|
|
19944
|
+
if (target === "-" || target && (globs ? /^~|[$`]/ : /^~|[$`*?]/).test(target))
|
|
19801
19945
|
return lost;
|
|
19802
19946
|
if (dir === undefined)
|
|
19803
19947
|
return lost;
|
|
19804
|
-
return target === undefined ?
|
|
19948
|
+
return target === undefined ? os8.homedir() : path28.resolve(dir, target);
|
|
19805
19949
|
};
|
|
19806
19950
|
var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
19807
19951
|
var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
|
|
@@ -19820,7 +19964,8 @@ var assignmentsOf = (words) => {
|
|
|
19820
19964
|
var commandWords = (words) => {
|
|
19821
19965
|
let start = 0;
|
|
19822
19966
|
while (start < words.length && COMPOUND.has(words[start]))
|
|
19823
|
-
start
|
|
19967
|
+
if (words[start++] === "function")
|
|
19968
|
+
start++;
|
|
19824
19969
|
return words.slice(start);
|
|
19825
19970
|
};
|
|
19826
19971
|
var REBINDS_ANY = new Set([
|
|
@@ -19972,7 +20117,8 @@ var expansions = (text, vars, loops) => {
|
|
|
19972
20117
|
last = match.index + match[0].length;
|
|
19973
20118
|
const value = vars.get(name);
|
|
19974
20119
|
const values = loops.get(name) ?? (value === undefined ? null : [value]);
|
|
19975
|
-
const
|
|
20120
|
+
const fallback = /^:?[-=](.*)$/s.exec(match[2] ?? "")?.[1];
|
|
20121
|
+
const applied = values?.flatMap((item) => fallback === undefined ? [applyOperator(item, match[2] ?? "")] : item === "" ? expansions(fallback, vars, loops) : [item]);
|
|
19976
20122
|
const fits = applied && results.length * applied.length <= MAX_EXPANSIONS2;
|
|
19977
20123
|
results = fits && applied.every((item) => item !== null) ? results.flatMap((prefix) => applied.map((item) => prefix + literal + item)) : results.map((prefix) => prefix + literal + match[0]);
|
|
19978
20124
|
}
|
|
@@ -20003,7 +20149,7 @@ var mktempPath = (value, dir) => {
|
|
|
20003
20149
|
template = arg;
|
|
20004
20150
|
}
|
|
20005
20151
|
if (base === null && (temp || template === undefined))
|
|
20006
|
-
base =
|
|
20152
|
+
base = os8.tmpdir();
|
|
20007
20153
|
const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
|
|
20008
20154
|
if (path28.isAbsolute(name))
|
|
20009
20155
|
return name;
|
|
@@ -20014,10 +20160,11 @@ var mktempPath = (value, dir) => {
|
|
|
20014
20160
|
};
|
|
20015
20161
|
var homeExpanded = (file) => {
|
|
20016
20162
|
const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
|
|
20017
|
-
return match ? (process.env.HOME ||
|
|
20163
|
+
return match ? (process.env.HOME || os8.homedir()) + file.slice(match[0].length) : file;
|
|
20018
20164
|
};
|
|
20019
20165
|
var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
|
|
20020
20166
|
const targets = [];
|
|
20167
|
+
const written = new Map;
|
|
20021
20168
|
let dir = cwd;
|
|
20022
20169
|
let stack = [];
|
|
20023
20170
|
const segments = segmentsOf(command, dialect);
|
|
@@ -20080,6 +20227,8 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20080
20227
|
continue;
|
|
20081
20228
|
}
|
|
20082
20229
|
const body = commandWords(segment.words);
|
|
20230
|
+
const before = segments[segments.indexOf(segment) - 1];
|
|
20231
|
+
const feeder = before?.pipe ? before : undefined;
|
|
20083
20232
|
const keywords = segment.words.length - body.length;
|
|
20084
20233
|
for (const keyword of segment.words.slice(0, keywords))
|
|
20085
20234
|
if (OPENS.has(keyword))
|
|
@@ -20133,7 +20282,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20133
20282
|
}
|
|
20134
20283
|
const plain = !segment.conditional;
|
|
20135
20284
|
if (CD2.has(name)) {
|
|
20136
|
-
dir = cdInto(dir, words, strict, vars);
|
|
20285
|
+
dir = cdInto(dir, words, Boolean(strict), vars, strict === "registry");
|
|
20137
20286
|
moved(plain);
|
|
20138
20287
|
continue;
|
|
20139
20288
|
}
|
|
@@ -20144,7 +20293,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20144
20293
|
}
|
|
20145
20294
|
if (PUSHD2.has(name)) {
|
|
20146
20295
|
stack.push(dir);
|
|
20147
|
-
dir = cdInto(dir, words, strict, vars);
|
|
20296
|
+
dir = cdInto(dir, words, Boolean(strict), vars, strict === "registry");
|
|
20148
20297
|
moved(plain);
|
|
20149
20298
|
continue;
|
|
20150
20299
|
}
|
|
@@ -20153,15 +20302,94 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20153
20302
|
moved(plain);
|
|
20154
20303
|
continue;
|
|
20155
20304
|
}
|
|
20156
|
-
const
|
|
20305
|
+
const literal = depth < 4 ? wrappedScript(words) ?? (strict ? shellScript2(words) : null) : null;
|
|
20306
|
+
const held = literal !== null && strict === "registry" ? expansions(literal, vars, loops) : [];
|
|
20307
|
+
const inner = held.length === 1 ? held[0] : literal;
|
|
20157
20308
|
const unPwd = () => new Map([...vars].filter(([key]) => key !== "PWD"));
|
|
20158
20309
|
if (inner !== null && dir !== undefined)
|
|
20159
20310
|
for (const runIn of workitRunDir(dir, words, atAll))
|
|
20160
20311
|
targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, runIn === dir ? vars : unPwd()));
|
|
20312
|
+
const bare = strict === "registry" && depth < 4 ? unwrapped(words) : null;
|
|
20313
|
+
if (bare?.length && dir !== undefined)
|
|
20314
|
+
targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
|
|
20315
|
+
if (strict === "registry" && dir !== undefined && depth < 4) {
|
|
20316
|
+
const run = words.slice(Math.max(0, words.findIndex((word) => !PREFIXES2.has(word))));
|
|
20317
|
+
const [verb = "", ...args] = run.map((word, index) => index ? word : (word.split(/[\\/]/).at(-1) ?? "").toLowerCase());
|
|
20318
|
+
const fed = segment.stdin?.join(`
|
|
20319
|
+
`);
|
|
20320
|
+
if (fed !== undefined)
|
|
20321
|
+
for (const file of segment.redirects)
|
|
20322
|
+
for (const into of atAll(file))
|
|
20323
|
+
written.set(into, fed);
|
|
20324
|
+
const read = (file) => atAll(file).flatMap((script) => {
|
|
20325
|
+
const made = written.get(script);
|
|
20326
|
+
if (made !== undefined)
|
|
20327
|
+
return [made];
|
|
20328
|
+
try {
|
|
20329
|
+
const stat = statSync3(script);
|
|
20330
|
+
const text = stat.isFile() && stat.size <= 262144 ? readFileSync9(script, "utf8") : "\x00";
|
|
20331
|
+
return text.includes("\x00") ? [] : [text];
|
|
20332
|
+
} catch {
|
|
20333
|
+
return [];
|
|
20334
|
+
}
|
|
20335
|
+
});
|
|
20336
|
+
const { named: operand, preloads } = scriptArgs(verb, args);
|
|
20337
|
+
const named = operand === "/dev/stdin" ? undefined : operand;
|
|
20338
|
+
const maker = feeder ? commandWords(feeder.words) : [];
|
|
20339
|
+
const [format = "", ...values] = maker.slice(1);
|
|
20340
|
+
let filled = 0;
|
|
20341
|
+
const printed = format.replace(/%[sbq]/g, () => values[filled++] ?? "");
|
|
20342
|
+
const piped = /^(?:echo|printf)$/.test(maker[0] ?? "") ? [[maker[0] === "printf" ? printed : format, ...values].join(`
|
|
20343
|
+
`).replaceAll("\\n", `
|
|
20344
|
+
`)] : maker[0] === "cat" ? [...feeder?.stdin ?? [], ...operands(maker.slice(1)).flatMap(read)] : [];
|
|
20345
|
+
const inputs = (segment.inputs ?? []).filter((file) => file !== "/dev/null");
|
|
20346
|
+
const shells = verb === "eval" ? [args.join(" ")] : verb === "trap" ? args.slice(0, 1) : verb === "alias" ? args.map((arg) => arg.replace(/^[^=]*=/, "")) : [];
|
|
20347
|
+
const others = [];
|
|
20348
|
+
if (SCRIPT_SHELLS.has(verb) || verb === "." || verb === "source") {
|
|
20349
|
+
if (named === undefined && shellScript2(run) === null)
|
|
20350
|
+
shells.push(...segment.stdin ?? [], ...inputs.flatMap(read), ...piped);
|
|
20351
|
+
else if (named !== undefined && shellScript2(run) === null)
|
|
20352
|
+
shells.push(...read(named));
|
|
20353
|
+
shells.push(...preloads.flatMap(read));
|
|
20354
|
+
} else if (INTERPRETERS.test(verb)) {
|
|
20355
|
+
const code = args.findIndex((arg) => /^-[a-zA-Z]*[ce]$|^--eval$/.test(arg));
|
|
20356
|
+
if (code >= 0)
|
|
20357
|
+
others.push(...expansions(args[code + 1] ?? "", vars, loops));
|
|
20358
|
+
others.push(...named === undefined ? [...segment.stdin ?? [], ...inputs.flatMap(read), ...piped] : read(named), ...preloads.flatMap(read));
|
|
20359
|
+
} else if (/[\\/]/.test(run[0] ?? ""))
|
|
20360
|
+
for (const text of read(run[0]))
|
|
20361
|
+
(/^#!.*\b(?:python|node|bun|deno|ruby|perl|php)/.test(text) ? others : shells).push(text);
|
|
20362
|
+
for (const script of shells)
|
|
20363
|
+
targets.push(...segmentTargets(dir, script, "posix", depth + 1, strict, vars));
|
|
20364
|
+
for (const raw of others) {
|
|
20365
|
+
const text = raw.replace(/^\s*(?:#(?!!)|\/\/|\/?\*).*$/gm, "");
|
|
20366
|
+
const joined = [
|
|
20367
|
+
...text.matchAll(/(?:["'][^"'\s,*?[]+["']\s*[,/+]\s*)+["'][^"'\s,*?[]+["']/g)
|
|
20368
|
+
].map(({ 0: literals, index }) => ({
|
|
20369
|
+
word: literals.replace(/["']\s*[,/+]\s*["']/g, "/").replace(/["']/g, ""),
|
|
20370
|
+
index
|
|
20371
|
+
}));
|
|
20372
|
+
const homes = /homedir\(|expanduser\(|Path\.home\(|['"]HOME['"]|env\.HOME|\$HOME|~/.test(text);
|
|
20373
|
+
const under = (word) => homes ? [path28.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
|
|
20374
|
+
const found = [
|
|
20375
|
+
...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
|
|
20376
|
+
...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
|
|
20377
|
+
];
|
|
20378
|
+
for (const { file, index } of found)
|
|
20379
|
+
if (!isRoot(file) || !readsRoot(text, index))
|
|
20380
|
+
targets.push(file);
|
|
20381
|
+
}
|
|
20382
|
+
if (/^(?:n?vim?|ex|ed|emacs)$/.test(verb) && (segment.stdin || inputs.length > 0 || feeder || args.some((arg, index) => /^(?:-[a-zA-Z]*[se]|--(?:batch|eval|script))$/.test(arg) || /^(?:-c|--cmd)$/.test(arg) && !inertEdit(args[index + 1] ?? "") || arg.startsWith("+") && !inertEdit(arg.slice(1) || "1"))))
|
|
20383
|
+
for (const file of operands(args))
|
|
20384
|
+
targets.push(...atAll(file));
|
|
20385
|
+
if (verb === "cp" && args.some((arg) => /^-[a-zA-Z]*l|^--link$/.test(arg)))
|
|
20386
|
+
for (const file of operands(args).slice(0, -1))
|
|
20387
|
+
targets.push(...atAll(file));
|
|
20388
|
+
}
|
|
20161
20389
|
if (strict && dir !== undefined) {
|
|
20162
20390
|
const runIn = dir;
|
|
20163
20391
|
for (const sub of depth < 4 ? segment.subs ?? [] : [])
|
|
20164
|
-
targets.push(...segmentTargets(runIn, sub, dialect, depth + 1,
|
|
20392
|
+
targets.push(...segmentTargets(runIn, sub, dialect, depth + 1, strict, vars));
|
|
20165
20393
|
const expanding = new Set(segment.expands ?? []);
|
|
20166
20394
|
const scriptOf = (index) => {
|
|
20167
20395
|
const word = body[index];
|
|
@@ -20177,12 +20405,15 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20177
20405
|
if (runner !== undefined && expanding.has(keywords + lead + ran) && unresolvedRefs(homeExpanded(runner)).length > 0)
|
|
20178
20406
|
targets.push(unknownVarTarget(runner));
|
|
20179
20407
|
const here = segment.unanalyzable ? DIR_TARGET : `${OPAQUE_TARGET}${encodeURIComponent(runner?.split(/[\\/]/).at(-1) ?? "a command")}`;
|
|
20408
|
+
const quiet = strict === "registry" && INTERPRETERS.test(runner?.split(/[\\/]/).at(-1) ?? "");
|
|
20180
20409
|
for (const file of opaque ?? [])
|
|
20181
20410
|
for (const resolved of atAll(file))
|
|
20182
|
-
|
|
20411
|
+
if (!quiet || !isRoot(resolved))
|
|
20412
|
+
targets.push(file === "." ? path28.join(resolved, here) : resolved);
|
|
20183
20413
|
const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
|
|
20184
|
-
|
|
20185
|
-
|
|
20414
|
+
const lnArgs = words.slice(ln + 1);
|
|
20415
|
+
if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
|
|
20416
|
+
targets.push(...linkSources(lnArgs, at));
|
|
20186
20417
|
}
|
|
20187
20418
|
for (const file of segment.redirects)
|
|
20188
20419
|
if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file))
|
|
@@ -20217,11 +20448,14 @@ var workitCwd = (dir, args, resolve) => {
|
|
|
20217
20448
|
};
|
|
20218
20449
|
var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) => {
|
|
20219
20450
|
try {
|
|
20451
|
+
const env = new Map(strict === "registry" ? [...command.matchAll(/\$\{?([A-Za-z_]\w*)/g)].filter((match) => !/^(?:OLD)?PWD$/.test(match[1])).map((match) => [match[1], process.env[match[1]] ?? ""]) : []);
|
|
20220
20452
|
return [
|
|
20221
|
-
...segmentTargets(cwd, command, dialect, 0, strict),
|
|
20453
|
+
...segmentTargets(cwd, command, dialect, 0, strict, env),
|
|
20222
20454
|
...gitMutationDirs(cwd, command, dialect).map((dir) => path28.join(dir, DIR_TARGET))
|
|
20223
20455
|
];
|
|
20224
|
-
} catch {
|
|
20456
|
+
} catch (error) {
|
|
20457
|
+
if (strict === "registry")
|
|
20458
|
+
throw error;
|
|
20225
20459
|
return [];
|
|
20226
20460
|
}
|
|
20227
20461
|
};
|
|
@@ -20279,12 +20513,79 @@ var claimAll = (owner, targets, deps) => {
|
|
|
20279
20513
|
};
|
|
20280
20514
|
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path28.resolve(cwd, file)) : [path28.join(cwd, DIR_TARGET)];
|
|
20281
20515
|
var configDirs = () => [resolveConfigDir(), grantsDir()];
|
|
20516
|
+
var globbed = (cwd, target, state, configs) => {
|
|
20517
|
+
if (!/[*?[]/.test(target))
|
|
20518
|
+
return [];
|
|
20519
|
+
const raw = path28.resolve(cwd, target).split(path28.sep);
|
|
20520
|
+
const literal = raw.findIndex((part) => /[*?[]/.test(part));
|
|
20521
|
+
const pattern = [
|
|
20522
|
+
...canonical3(raw.slice(0, literal).join(path28.sep) || path28.sep).replace(/[\\/]+$/, "").split(path28.sep),
|
|
20523
|
+
...raw.slice(literal)
|
|
20524
|
+
];
|
|
20525
|
+
const segment = (glob, name) => {
|
|
20526
|
+
try {
|
|
20527
|
+
return new RegExp(`^${glob.startsWith(".") ? "" : "(?!\\.)"}${glob.replace(/[.+^$(){}|\\]/g, "\\$&").replace(/\[!/g, "[^").replaceAll("*", ".*").replaceAll("?", ".")}$`, CASE_INSENSITIVE ? "i" : "").test(name);
|
|
20528
|
+
} catch {
|
|
20529
|
+
return false;
|
|
20530
|
+
}
|
|
20531
|
+
};
|
|
20532
|
+
const hit = (file, below) => {
|
|
20533
|
+
const parts = canonical3(file).split(path28.sep);
|
|
20534
|
+
return (below ? pattern.length >= parts.length : pattern.length === parts.length) && parts.every((part, index) => segment(pattern[index], part));
|
|
20535
|
+
};
|
|
20536
|
+
let roots = [];
|
|
20537
|
+
try {
|
|
20538
|
+
roots = readdirSync3(state).filter((name) => /^(?:issued|approvals$)/.test(name));
|
|
20539
|
+
} catch {}
|
|
20540
|
+
return [
|
|
20541
|
+
...roots.map((name) => path28.join(state, name)).filter((root) => hit(root, true)),
|
|
20542
|
+
...configs.flatMap((dir) => [dir, path28.join(dir, "workspaces.json")]).filter((file) => hit(file, false))
|
|
20543
|
+
];
|
|
20544
|
+
};
|
|
20545
|
+
var guardedInodes = (state, configs) => {
|
|
20546
|
+
const seen = new Map;
|
|
20547
|
+
let budget = 2000;
|
|
20548
|
+
const add = (file, registry) => {
|
|
20549
|
+
if (budget-- <= 0)
|
|
20550
|
+
return;
|
|
20551
|
+
const stat = statSync3(file, { throwIfNoEntry: false });
|
|
20552
|
+
if (stat?.isFile())
|
|
20553
|
+
seen.set(`${stat.dev}:${stat.ino}`, registry);
|
|
20554
|
+
else if (stat?.isDirectory())
|
|
20555
|
+
for (const name of readdirSync3(file))
|
|
20556
|
+
add(path28.join(file, name), registry);
|
|
20557
|
+
};
|
|
20558
|
+
try {
|
|
20559
|
+
for (const dir of configs)
|
|
20560
|
+
add(path28.join(dir, "workspaces.json"), "grants");
|
|
20561
|
+
for (const name of readdirSync3(state))
|
|
20562
|
+
if (/^(?:issued|approvals$)/.test(name))
|
|
20563
|
+
add(path28.join(state, name), name === "approvals" ? "approvals" : "issued");
|
|
20564
|
+
} catch {}
|
|
20565
|
+
return seen;
|
|
20566
|
+
};
|
|
20567
|
+
var hardLinked = (file, state, configs, inodes) => {
|
|
20568
|
+
try {
|
|
20569
|
+
const stat = statSync3(file, { throwIfNoEntry: false });
|
|
20570
|
+
if (!stat?.isFile() || stat.nlink < 2 || !stat.ino)
|
|
20571
|
+
return;
|
|
20572
|
+
inodes.map ??= guardedInodes(state, configs);
|
|
20573
|
+
return inodes.map.get(`${stat.dev}:${stat.ino}`);
|
|
20574
|
+
} catch {
|
|
20575
|
+
return;
|
|
20576
|
+
}
|
|
20577
|
+
};
|
|
20282
20578
|
var registryTarget = (cwd, targets) => {
|
|
20283
20579
|
const state = resolveStateDir();
|
|
20284
20580
|
const configs = configDirs();
|
|
20581
|
+
const inodes = {};
|
|
20285
20582
|
for (const target of targets) {
|
|
20286
20583
|
const file = homeExpanded(target);
|
|
20287
|
-
const
|
|
20584
|
+
const glob = globbed(cwd, file, state, configs)[0];
|
|
20585
|
+
const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
|
|
20586
|
+
if (viaGlob)
|
|
20587
|
+
return { file: target, registry: viaGlob.registry };
|
|
20588
|
+
const registry = hardLinked(path28.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical3) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical3)) ? "grants" : null);
|
|
20288
20589
|
if (registry)
|
|
20289
20590
|
return { file: target, registry };
|
|
20290
20591
|
}
|
|
@@ -20306,7 +20607,7 @@ var underRegistry = (state, cwd, target, platform = process.platform, real = (fi
|
|
|
20306
20607
|
};
|
|
20307
20608
|
var underConfig = (dir, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
20308
20609
|
const parts = partsUnder(dir, cwd, target, platform, real);
|
|
20309
|
-
return parts?.length === 1 &&
|
|
20610
|
+
return parts?.length === 1 && ["", "workspaces.json", DIR_TARGET].includes(parts[0]);
|
|
20310
20611
|
};
|
|
20311
20612
|
var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
20312
20613
|
if (platform !== "win32" || !command.includes("\\"))
|
|
@@ -20314,8 +20615,21 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
|
20314
20615
|
const flat = (value) => value.replaceAll("\\", "/").toLowerCase();
|
|
20315
20616
|
const text = flat(command);
|
|
20316
20617
|
const state = flat(resolveStateDir());
|
|
20317
|
-
const
|
|
20318
|
-
|
|
20618
|
+
const configs = configDirs().map(flat);
|
|
20619
|
+
const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : configs.some((dir) => text.includes(dir)) ? "grants" : null;
|
|
20620
|
+
if (!registry)
|
|
20621
|
+
return null;
|
|
20622
|
+
const spans = command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/"));
|
|
20623
|
+
const writes = shellWrites(spans);
|
|
20624
|
+
const moved = [
|
|
20625
|
+
"",
|
|
20626
|
+
...[...spans.matchAll(/(?:^|[;&|(]\s*)(?:cd|pushd|chdir)\s+([^\s;&|)]+)/g)].map((match) => `${match[1]}/`)
|
|
20627
|
+
];
|
|
20628
|
+
const named = (target) => moved.some((dir) => {
|
|
20629
|
+
const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
|
|
20630
|
+
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, `${cfg}/workspaces.json`].includes(at)) : at.includes(`${state}/${registry}`);
|
|
20631
|
+
});
|
|
20632
|
+
return writes.writes && (writes.targets === null || writes.targets.some(named)) ? registry : null;
|
|
20319
20633
|
};
|
|
20320
20634
|
var REGISTRY_DENY = {
|
|
20321
20635
|
issued: {
|
|
@@ -20336,9 +20650,10 @@ var REGISTRY_DENY = {
|
|
|
20336
20650
|
};
|
|
20337
20651
|
var registryDeny = ({ file, registry }) => {
|
|
20338
20652
|
const { label, what, unblock } = REGISTRY_DENY[registry];
|
|
20653
|
+
const named = path28.basename(file).startsWith(".workit-") ? path28.dirname(file) : file;
|
|
20339
20654
|
return {
|
|
20340
20655
|
kind: "deny",
|
|
20341
|
-
reason: `workit ${label}: ${
|
|
20656
|
+
reason: `workit ${label}: ${named} is under ${what}. ${unblock}`,
|
|
20342
20657
|
unblock
|
|
20343
20658
|
};
|
|
20344
20659
|
};
|
|
@@ -20360,10 +20675,20 @@ function writeGate(cwd, paths, owner, deps) {
|
|
|
20360
20675
|
function shellGate(cwd, command, owner, dialect = "posix", deps) {
|
|
20361
20676
|
try {
|
|
20362
20677
|
const windows = unquotedWindowsRegistry(command);
|
|
20363
|
-
const forged = registryTarget(cwd,
|
|
20678
|
+
const forged = registryTarget(cwd, shellMutationTargets(cwd, command, dialect, "registry")) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
|
|
20364
20679
|
if (forged)
|
|
20365
20680
|
return registryDeny(forged);
|
|
20366
|
-
} catch {
|
|
20681
|
+
} catch {
|
|
20682
|
+
const text = command.replaceAll("\\", "/").replace(/['"]/g, "").toLowerCase();
|
|
20683
|
+
if (/issued|approvals|workspaces\.json|\.config\/workit|state\/workit/.test(text) || [resolveStateDir(), ...configDirs()].some((dir) => text.includes(dir.replaceAll("\\", "/").toLowerCase()))) {
|
|
20684
|
+
const { unblock } = REGISTRY_DENY.grants;
|
|
20685
|
+
return {
|
|
20686
|
+
kind: "deny",
|
|
20687
|
+
reason: `workit registry guard: Workit could not analyse this command, which names a guarded path; split it into plain commands. ${unblock}`,
|
|
20688
|
+
unblock
|
|
20689
|
+
};
|
|
20690
|
+
}
|
|
20691
|
+
}
|
|
20367
20692
|
const writes = shellWrites(command);
|
|
20368
20693
|
let targets = [];
|
|
20369
20694
|
if (owner)
|
|
@@ -20411,7 +20736,7 @@ function beforeWriteGate(cwd, paths) {
|
|
|
20411
20736
|
}
|
|
20412
20737
|
}
|
|
20413
20738
|
// packages/workit-core/src/hooks/stop.ts
|
|
20414
|
-
import { spawnSync as
|
|
20739
|
+
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
20415
20740
|
|
|
20416
20741
|
// packages/workit-core/src/ci-waiter.ts
|
|
20417
20742
|
import fs20 from "node:fs";
|
|
@@ -20510,7 +20835,7 @@ var asksUser = (message) => {
|
|
|
20510
20835
|
};
|
|
20511
20836
|
var short = (sha) => (sha ?? "?").slice(0, 12);
|
|
20512
20837
|
var gitList = (cwd, args) => {
|
|
20513
|
-
const run =
|
|
20838
|
+
const run = spawnSync16("git", args, {
|
|
20514
20839
|
cwd,
|
|
20515
20840
|
encoding: "utf8",
|
|
20516
20841
|
timeout: 3000,
|
|
@@ -21970,7 +22295,7 @@ function confineImplementerShell(input, command, dialect = "posix") {
|
|
|
21970
22295
|
}
|
|
21971
22296
|
var SCRATCH = ".workit-scratch";
|
|
21972
22297
|
var SHELL_NAMES = /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/;
|
|
21973
|
-
var
|
|
22298
|
+
var INTERPRETERS2 = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php)$/;
|
|
21974
22299
|
var FED = /^(?:-|\/dev\/stdin|\/dev\/fd\/0|\/proc\/self\/fd\/0)$|^<\(/;
|
|
21975
22300
|
var LEADS = /^(?:sudo|doas|env|command|builtin|exec|nohup|time|nice|timeout|stdbuf|xargs|busybox|!|\{|if|then|else|elif|do|while|until|\w+=.*|[-\d].*)$/s;
|
|
21976
22301
|
var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|perl|php|eval|source|\.|workit)$/;
|
|
@@ -22087,7 +22412,7 @@ var judgeRefusal = (command, fed, depth = 0) => {
|
|
|
22087
22412
|
}
|
|
22088
22413
|
}
|
|
22089
22414
|
}
|
|
22090
|
-
if (
|
|
22415
|
+
if (INTERPRETERS2.test(name) && !args.some((arg) => INLINE.test(arg))) {
|
|
22091
22416
|
const operand = args.find((arg, index) => (arg === "-" || !arg.startsWith("-")) && !VALUED.test(args[index - 1] ?? ""));
|
|
22092
22417
|
if (FED.test(operand ?? "") || operand === undefined && !/^(?:bun|deno)$/.test(name))
|
|
22093
22418
|
return unseen;
|
|
@@ -22439,8 +22764,8 @@ var cdWorkitSplit = (command) => {
|
|
|
22439
22764
|
};
|
|
22440
22765
|
|
|
22441
22766
|
// packages/workit-core/src/hooks/model-limit.ts
|
|
22442
|
-
import { closeSync as closeSync2, openSync as openSync2, readdirSync as
|
|
22443
|
-
import
|
|
22767
|
+
import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync4, readSync, statSync as statSync5 } from "node:fs";
|
|
22768
|
+
import os9 from "node:os";
|
|
22444
22769
|
import path33 from "node:path";
|
|
22445
22770
|
var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
22446
22771
|
var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
|
|
@@ -22639,14 +22964,14 @@ var firstPrompt = (file) => {
|
|
|
22639
22964
|
var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
|
|
22640
22965
|
var listDir = (dir) => {
|
|
22641
22966
|
try {
|
|
22642
|
-
return
|
|
22967
|
+
return readdirSync4(dir).map((name) => path33.join(dir, name));
|
|
22643
22968
|
} catch {
|
|
22644
22969
|
return [];
|
|
22645
22970
|
}
|
|
22646
22971
|
};
|
|
22647
22972
|
var SCAN_MS = 30 * 60000;
|
|
22648
22973
|
var scanClaudeTranscripts = (cwd, env, now = new Date) => {
|
|
22649
|
-
const projects = path33.join(env.CLAUDE_CONFIG_DIR || path33.join(env.HOME ||
|
|
22974
|
+
const projects = path33.join(env.CLAUDE_CONFIG_DIR || path33.join(env.HOME || os9.homedir(), ".claude"), "projects");
|
|
22650
22975
|
const project = path33.join(projects, claudeProjectSlug(cwd));
|
|
22651
22976
|
const notes = [];
|
|
22652
22977
|
const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path33.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
|