@workit-dev/codex 2.25.0 → 2.25.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.
package/dist/launch-mcp.js
CHANGED
|
@@ -32218,6 +32218,8 @@ var CLOSES = new Set(["fi", "done", "}"]);
|
|
|
32218
32218
|
var UNFOLLOWED = new Set(["case", "esac", "select", "function"]);
|
|
32219
32219
|
var TRANSPARENT = new Set(["builtin", "command", "time", "!"]);
|
|
32220
32220
|
var UNKNOWN_VAR = path35.resolve(path35.parse(process.cwd()).root, ".workit-unknown-var");
|
|
32221
|
+
// packages/workit-core/src/core/verdict-set.ts
|
|
32222
|
+
var SET_TTL_MS = 7 * 86400000;
|
|
32221
32223
|
// packages/workit-core/src/core/skill-manifests.ts
|
|
32222
32224
|
if (false) {}
|
|
32223
32225
|
|
|
@@ -18206,6 +18206,58 @@ var linkSources = (args, at) => {
|
|
|
18206
18206
|
return resolved ? [resolved] : [];
|
|
18207
18207
|
});
|
|
18208
18208
|
};
|
|
18209
|
+
var commandName2 = (word) => (word.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
|
18210
|
+
var fedRuns = (words, fed) => {
|
|
18211
|
+
const run = words.slice(Math.max(0, words.findIndex((word) => word === "xargs" || !PREFIXES2.has(word))));
|
|
18212
|
+
const name = commandName2(run[0] ?? "");
|
|
18213
|
+
if (name === "xargs")
|
|
18214
|
+
return xargsCommands(run, fed);
|
|
18215
|
+
if (name !== "parallel")
|
|
18216
|
+
return [run];
|
|
18217
|
+
return parallelCommands(fed === undefined || run.includes(":::") ? run : [...run, ":::", ...fed.split(`
|
|
18218
|
+
`).filter(Boolean)]);
|
|
18219
|
+
};
|
|
18220
|
+
var windowsScript = (input, stdin) => {
|
|
18221
|
+
const words = input.slice(Math.max(0, input.findIndex((word) => !PREFIXES2.has(word))));
|
|
18222
|
+
const name = commandName2(words[0] ?? "").replace(/\.exe$/, "");
|
|
18223
|
+
if (name === "cmd")
|
|
18224
|
+
return cmdScript(words);
|
|
18225
|
+
return name === "pwsh" || name === "powershell" ? powershellScript(words, stdin) : null;
|
|
18226
|
+
};
|
|
18227
|
+
var WINDOWS_LINK_TYPE = /^(?:symboliclink|junction|hardlink)$/i;
|
|
18228
|
+
var linkReach = (verb, args, at, atAll) => {
|
|
18229
|
+
const all = (files) => files.flatMap((file) => atAll(file));
|
|
18230
|
+
const names = operands(args);
|
|
18231
|
+
if (verb === "mount" || verb === "bindfs")
|
|
18232
|
+
return all(names);
|
|
18233
|
+
if (verb === "ln" || verb === "cp" && args.some((arg) => /^-[a-zA-Z]*[ls]|^--(?:link|symbolic-link)$/.test(arg)))
|
|
18234
|
+
return [...linkSources(args, at), ...all(names.length < 2 ? names : names.slice(0, -1))];
|
|
18235
|
+
if (verb === "install") {
|
|
18236
|
+
const flag = args.findIndex((arg) => arg.startsWith("-l"));
|
|
18237
|
+
if (flag < 0)
|
|
18238
|
+
return [];
|
|
18239
|
+
const rest = operands(args.filter((_, index) => index !== flag && (args[flag] !== "-l" || index !== flag + 1)));
|
|
18240
|
+
return all(rest.slice(0, -1));
|
|
18241
|
+
}
|
|
18242
|
+
if (verb === "rsync") {
|
|
18243
|
+
const dest = names.at(-1);
|
|
18244
|
+
return args.flatMap((arg, index) => {
|
|
18245
|
+
const match = /^--link-dest(?:=(.*))?$/s.exec(arg);
|
|
18246
|
+
const dir = match ? match[1] ?? args[index + 1] : undefined;
|
|
18247
|
+
if (!dir)
|
|
18248
|
+
return [];
|
|
18249
|
+
return [...atAll(dir), ...dest && !path30.isAbsolute(dir) ? atAll(path30.join(dest, dir)) : []];
|
|
18250
|
+
});
|
|
18251
|
+
}
|
|
18252
|
+
if (verb === "mklink")
|
|
18253
|
+
return all(args.filter((arg) => !/^\/[dhj]$/i.test(arg)));
|
|
18254
|
+
if ((verb === "new-item" || verb === "ni") && args.some((arg) => WINDOWS_LINK_TYPE.test(arg.replace(/^-[\w-]+:/, ""))))
|
|
18255
|
+
return all(args.flatMap((arg) => {
|
|
18256
|
+
const value = arg.startsWith("-") ? /^-[\w-]+:(.+)$/s.exec(arg)?.[1] : arg;
|
|
18257
|
+
return value && !WINDOWS_LINK_TYPE.test(value) ? [value] : [];
|
|
18258
|
+
}));
|
|
18259
|
+
return [];
|
|
18260
|
+
};
|
|
18209
18261
|
var shellWrites = (command, depth = 0) => {
|
|
18210
18262
|
const targets = [];
|
|
18211
18263
|
let unknown = false;
|
|
@@ -18314,6 +18366,7 @@ var recording = (make) => {
|
|
|
18314
18366
|
var placeholdersOf = (targets) => PLACEHOLDERS.get(targets) ?? new Set;
|
|
18315
18367
|
var OPAQUE_TARGET = ".workit-runs-";
|
|
18316
18368
|
var UNRESOLVED_TARGET = ".workit-unresolved-target";
|
|
18369
|
+
var LINK_SOURCE = ".workit-link-source";
|
|
18317
18370
|
var OVERRIDE = "WORKIT_LIVE_SESSION=override";
|
|
18318
18371
|
var inert = (args, sub) => args.some((arg) => arg === "--help" || arg === "-h" || arg === "--dry-run" || DRY_N.has(sub) && /^-[a-zA-Z]*n[a-zA-Z]*$/.test(arg) && !arg.startsWith("--"));
|
|
18319
18372
|
var gitMutationDirs = (cwd, command, dialect) => {
|
|
@@ -18715,6 +18768,10 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
18715
18768
|
if (inner !== null && dir !== undefined)
|
|
18716
18769
|
for (const runIn of workitRunDir(dir, words, atAll))
|
|
18717
18770
|
targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, runIn === dir ? vars : unPwd()));
|
|
18771
|
+
const windows = strict && depth < 4 ? windowsScript(words, segment.stdin?.join(`
|
|
18772
|
+
`)) : null;
|
|
18773
|
+
if (windows !== null && dir !== undefined)
|
|
18774
|
+
targets.push(...segmentTargets(dir, windows, "powershell", depth + 1, strict, vars));
|
|
18718
18775
|
const bare = strict === "registry" && depth < 4 ? unwrapped2(words) : null;
|
|
18719
18776
|
if (bare?.length && dir !== undefined)
|
|
18720
18777
|
targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
|
|
@@ -18790,9 +18847,11 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
18790
18847
|
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"))))
|
|
18791
18848
|
for (const file of operands(args))
|
|
18792
18849
|
targets.push(...atAll(file));
|
|
18793
|
-
|
|
18794
|
-
|
|
18795
|
-
|
|
18850
|
+
const feed = fed === undefined && !piped.length ? undefined : [fed, ...piped].join(`
|
|
18851
|
+
`);
|
|
18852
|
+
for (const [linker = "", ...rest] of fedRuns(words, feed))
|
|
18853
|
+
for (const source of linkReach(commandName2(linker), rest, at, atAll))
|
|
18854
|
+
targets.push(path30.join(source, LINK_SOURCE));
|
|
18796
18855
|
}
|
|
18797
18856
|
if (strict && dir !== undefined) {
|
|
18798
18857
|
const runIn = dir;
|
|
@@ -18988,19 +19047,42 @@ var hardLinked = (file, state, configs, inodes) => {
|
|
|
18988
19047
|
return;
|
|
18989
19048
|
}
|
|
18990
19049
|
};
|
|
19050
|
+
var inRepoLedger = (file) => [...file.matchAll(/[\\/]workit[\\/]ledger(?=[\\/]|$)/g)].some(({ index }) => {
|
|
19051
|
+
const gitDir = file.slice(0, index);
|
|
19052
|
+
return /(?:^|[\\/])\.git$/.test(gitDir) || existsSync12(path30.join(gitDir, "HEAD")) && existsSync12(path30.join(gitDir, "objects"));
|
|
19053
|
+
});
|
|
19054
|
+
var holdsGuarded = (cwd, source, state, configs) => {
|
|
19055
|
+
const real = canonical5(source);
|
|
19056
|
+
const below = (parent, child) => {
|
|
19057
|
+
const rel = path30.relative(parent, child);
|
|
19058
|
+
return rel === "" || !rel.startsWith("..") && !path30.isAbsolute(rel);
|
|
19059
|
+
};
|
|
19060
|
+
const holds = (file) => below(real, canonical5(file));
|
|
19061
|
+
const inState = path30.relative(canonical5(state), real).split(path30.sep);
|
|
19062
|
+
const ledgers = ["ledger", "workit/ledger", ".git/workit/ledger"].map((rel) => path30.join(real, rel)).filter((dir) => existsSync12(dir) && inRepoLedger(dir));
|
|
19063
|
+
const own = ledgerPath(cwd);
|
|
19064
|
+
return holds(state) || below(canonical5(state), real) && inState[0] === "folders" && inState.length <= 2 || configs.some(holds) || ledgers.length > 0 || own.ok && existsSync12(own.value) && holds(path30.dirname(own.value));
|
|
19065
|
+
};
|
|
18991
19066
|
var registryTarget = (cwd, targets) => {
|
|
18992
19067
|
const state = resolveStateDir();
|
|
18993
19068
|
const configs = configDirs();
|
|
18994
19069
|
const inodes = {};
|
|
18995
19070
|
for (const target of targets) {
|
|
18996
19071
|
const file = homeExpanded(target);
|
|
19072
|
+
if (path30.basename(file) === LINK_SOURCE) {
|
|
19073
|
+
const source = path30.dirname(path30.resolve(cwd, file));
|
|
19074
|
+
const reached = registryTarget(cwd, [source])?.registry ?? (holdsGuarded(cwd, source, state, configs) ? "holds" : null);
|
|
19075
|
+
if (reached)
|
|
19076
|
+
return { file: target, registry: reached };
|
|
19077
|
+
continue;
|
|
19078
|
+
}
|
|
18997
19079
|
if (realPath(path30.resolve(cwd, file)) === null)
|
|
18998
19080
|
return { file: target, registry: "link" };
|
|
18999
19081
|
const glob = globbed(cwd, file, state, configs)[0];
|
|
19000
19082
|
const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
|
|
19001
19083
|
if (viaGlob)
|
|
19002
19084
|
return { file: target, registry: viaGlob.registry };
|
|
19003
|
-
const registry = hardLinked(path30.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (
|
|
19085
|
+
const registry = hardLinked(path30.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (inRepoLedger(canonical5(path30.resolve(cwd, file))) ? "ledger" : null) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical5)) ? "grants" : null);
|
|
19004
19086
|
if (registry)
|
|
19005
19087
|
return { file: target, registry };
|
|
19006
19088
|
}
|
|
@@ -19027,6 +19109,7 @@ var underConfig = (dir, cwd, target, platform = process.platform, real = (file)
|
|
|
19027
19109
|
const parts = partsUnder(dir, cwd, target, platform, real);
|
|
19028
19110
|
return parts?.length === 1 && ["", ...CONFIG_FILES, DIR_TARGET, UNRESOLVED_TARGET].includes(parts[0]);
|
|
19029
19111
|
};
|
|
19112
|
+
var windowsSlashed = (command, platform = process.platform) => platform === "win32" && command.includes("\\") ? command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/")) : null;
|
|
19030
19113
|
var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
19031
19114
|
if (platform !== "win32" || !command.includes("\\"))
|
|
19032
19115
|
return null;
|
|
@@ -19035,28 +19118,36 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
|
19035
19118
|
const state = flat(resolveStateDir());
|
|
19036
19119
|
const configs = configDirs().map(flat);
|
|
19037
19120
|
const folders = `${state}/folders/`;
|
|
19038
|
-
const ledger = (at) => at.includes(`${state}/verdicts`) ||
|
|
19039
|
-
const
|
|
19040
|
-
if (!
|
|
19121
|
+
const ledger = (at, named = false) => at.includes(`${state}/verdicts`) || (named ? inRepoLedger(at) : /\/workit\/ledger(?:[/\s'"]|$)/.test(at)) || at.split(folders).slice(1).some((rest) => /^[^/\s]+\/ledger(?:[/\s'"]|$)/.test(rest));
|
|
19122
|
+
const present = ["issued", "approvals", "ledger", "grants"].filter((kind) => kind === "ledger" ? ledger(text) : kind === "grants" ? configs.some((dir) => text.includes(dir)) : text.includes(`${state}/${kind}`));
|
|
19123
|
+
if (!present.length)
|
|
19041
19124
|
return null;
|
|
19042
|
-
const spans = command
|
|
19125
|
+
const spans = windowsSlashed(command, platform) ?? command;
|
|
19043
19126
|
const writes = shellWrites(spans);
|
|
19127
|
+
if (!writes.writes)
|
|
19128
|
+
return null;
|
|
19044
19129
|
const moved = [
|
|
19045
19130
|
"",
|
|
19046
19131
|
...[...spans.matchAll(/(?:^|[;&|(]\s*)(?:cd|pushd|chdir)\s+([^\s;&|)]+)/g)].map((match) => `${match[1]}/`)
|
|
19047
19132
|
];
|
|
19048
|
-
const named = (target) => moved.some((dir) => {
|
|
19133
|
+
const named = (registry, target) => moved.some((dir) => {
|
|
19049
19134
|
const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
|
|
19050
|
-
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, ...CONFIG_FILES.map((name) => `${cfg}/${name}`)].includes(at)) : registry === "ledger" ? ledger(at) : at.includes(`${state}/${registry}`);
|
|
19135
|
+
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, ...CONFIG_FILES.map((name) => `${cfg}/${name}`)].includes(at)) : registry === "ledger" ? ledger(at, true) : at.includes(`${state}/${registry}`);
|
|
19051
19136
|
});
|
|
19052
|
-
return
|
|
19137
|
+
return present.find((registry) => writes.targets === null || writes.targets.some((target) => named(registry, target))) ?? null;
|
|
19053
19138
|
};
|
|
19139
|
+
var LINK_UNBLOCK = "Never link or bind-mount Workit's state, config or ledgers: a write through the link would land in them. Read the file in place.";
|
|
19054
19140
|
var REGISTRY_DENY = {
|
|
19055
19141
|
link: {
|
|
19056
19142
|
label: "registry guard",
|
|
19057
19143
|
what: "a symlink chain Workit could not resolve (over 40 links), which may reach a guarded path",
|
|
19058
19144
|
unblock: "Write to the file's real path."
|
|
19059
19145
|
},
|
|
19146
|
+
holds: {
|
|
19147
|
+
label: "registry guard",
|
|
19148
|
+
what: "Workit's state, its config or a repository ledger",
|
|
19149
|
+
unblock: LINK_UNBLOCK
|
|
19150
|
+
},
|
|
19060
19151
|
issued: {
|
|
19061
19152
|
label: "issued-registry guard",
|
|
19062
19153
|
what: "Workit's issued-session state",
|
|
@@ -19080,6 +19171,12 @@ var REGISTRY_DENY = {
|
|
|
19080
19171
|
};
|
|
19081
19172
|
var registryDeny = ({ file, registry }) => {
|
|
19082
19173
|
const { label, what, unblock } = REGISTRY_DENY[registry];
|
|
19174
|
+
if (path30.basename(file) === LINK_SOURCE)
|
|
19175
|
+
return {
|
|
19176
|
+
kind: "deny",
|
|
19177
|
+
reason: `workit ${label}: this command links or mounts ${path30.dirname(file)}, which is or holds ${what}. ${LINK_UNBLOCK}`,
|
|
19178
|
+
unblock: LINK_UNBLOCK
|
|
19179
|
+
};
|
|
19083
19180
|
if (path30.basename(file) === UNRESOLVED_TARGET)
|
|
19084
19181
|
return {
|
|
19085
19182
|
kind: "deny",
|
|
@@ -19111,7 +19208,8 @@ function writeGate(cwd, paths, owner, deps) {
|
|
|
19111
19208
|
function shellGate(cwd, command, owner, dialect = "posix", deps) {
|
|
19112
19209
|
try {
|
|
19113
19210
|
const windows = unquotedWindowsRegistry(command);
|
|
19114
|
-
const
|
|
19211
|
+
const slashed = dialect === "posix" ? windowsSlashed(command) : null;
|
|
19212
|
+
const forged = registryTarget(cwd, shellMutationTargets(cwd, command, dialect, "registry")) ?? (slashed === null ? null : registryTarget(cwd, shellMutationTargets(cwd, slashed, dialect, "registry"))) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
|
|
19115
19213
|
if (forged)
|
|
19116
19214
|
return registryDeny(forged);
|
|
19117
19215
|
} catch {
|
|
@@ -19250,6 +19348,26 @@ function currentJudgment(cwd) {
|
|
|
19250
19348
|
}
|
|
19251
19349
|
}
|
|
19252
19350
|
|
|
19351
|
+
// packages/workit-core/src/core/verdict-set.ts
|
|
19352
|
+
import path32 from "node:path";
|
|
19353
|
+
var SET_TTL_MS = 7 * 86400000;
|
|
19354
|
+
var SET_VOID = "verdict.set.voided";
|
|
19355
|
+
var setStorePath = () => path32.join(resolveStateDir(), "verdicts", "sets", "ledger.jsonl");
|
|
19356
|
+
function gateStands(cwd, gate, rows, now = Date.now()) {
|
|
19357
|
+
const id = typeof gate.verdictId === "string" ? gate.verdictId : null;
|
|
19358
|
+
if (id !== null && verdictVoids(rows).has(id))
|
|
19359
|
+
return false;
|
|
19360
|
+
if (gate.via !== "set")
|
|
19361
|
+
return true;
|
|
19362
|
+
const until = typeof gate.expires === "string" ? Date.parse(gate.expires) : Date.parse(gate.at) + SET_TTL_MS;
|
|
19363
|
+
if (!(until > now))
|
|
19364
|
+
return false;
|
|
19365
|
+
if (id === null)
|
|
19366
|
+
return true;
|
|
19367
|
+
const read = readLedgerAt(cwd, setStorePath(), { integrity: true });
|
|
19368
|
+
return read.ok && !read.value.rows.some((row) => row.type === SET_VOID && row.target === id && row.integrity === "verified");
|
|
19369
|
+
}
|
|
19370
|
+
|
|
19253
19371
|
// packages/workit-core/src/hooks/stop.ts
|
|
19254
19372
|
var NONE4 = { kind: "none" };
|
|
19255
19373
|
var QUESTION = /[??؟](?=[\s*_`"')\]>]*(?:\s|$))|¿/;
|
|
@@ -19363,7 +19481,7 @@ var unverified = (cwd, branch, all, descriptor, verification, head) => {
|
|
|
19363
19481
|
const check = checkVerdicts(cwd, branch, all);
|
|
19364
19482
|
if (check.accepted.accepted || check.accepted.reasons.includes("failing_verdict"))
|
|
19365
19483
|
return null;
|
|
19366
|
-
if (all.some((row) => row.type === "pr.gate" && row.branch === branch && row.head === check.head))
|
|
19484
|
+
if (all.some((row) => row.type === "pr.gate" && row.branch === branch && row.head === check.head && gateStands(cwd, row, all)))
|
|
19367
19485
|
return null;
|
|
19368
19486
|
const judgment = currentJudgment(cwd);
|
|
19369
19487
|
const high = judgment?.riskTier === "high";
|
|
@@ -19684,12 +19802,12 @@ ${line}` };
|
|
|
19684
19802
|
};
|
|
19685
19803
|
// packages/workit-core/src/hooks/hosts/fields.ts
|
|
19686
19804
|
import { existsSync as existsSync13, realpathSync as realpathSync9, statSync as statSync4 } from "node:fs";
|
|
19687
|
-
import
|
|
19805
|
+
import path33 from "node:path";
|
|
19688
19806
|
var isRecord7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
19689
19807
|
var nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "";
|
|
19690
19808
|
var optionalText = (value) => typeof value === "string" ? value : null;
|
|
19691
19809
|
var existingDirectory = (value) => {
|
|
19692
|
-
if (!nonEmpty2(value) || !
|
|
19810
|
+
if (!nonEmpty2(value) || !path33.isAbsolute(value) || !existsSync13(value))
|
|
19693
19811
|
return null;
|
|
19694
19812
|
try {
|
|
19695
19813
|
return statSync4(value).isDirectory() ? realpathSync9(value) : null;
|
|
@@ -19757,7 +19875,7 @@ var writeTargets = (input) => {
|
|
|
19757
19875
|
};
|
|
19758
19876
|
// packages/workit-core/src/hooks/standing.ts
|
|
19759
19877
|
import fs23 from "node:fs";
|
|
19760
|
-
import
|
|
19878
|
+
import path35 from "node:path";
|
|
19761
19879
|
|
|
19762
19880
|
// packages/workit-core/src/approvals/store.ts
|
|
19763
19881
|
var REQUEST_TTL_MS = 30 * 60000;
|
|
@@ -20465,35 +20583,35 @@ function neededChecks(lane, configured) {
|
|
|
20465
20583
|
import { createHash as createHash16 } from "node:crypto";
|
|
20466
20584
|
import fs22 from "node:fs";
|
|
20467
20585
|
import os10 from "node:os";
|
|
20468
|
-
import
|
|
20586
|
+
import path34 from "node:path";
|
|
20469
20587
|
var FANOUT_TOKEN_FILE = "workit-fanout-token";
|
|
20470
20588
|
var NONE5 = { kind: "none" };
|
|
20471
20589
|
var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
|
|
20472
20590
|
var realOf = (file) => {
|
|
20473
20591
|
let rest = "";
|
|
20474
|
-
for (let dir = file;; dir =
|
|
20592
|
+
for (let dir = file;; dir = path34.dirname(dir)) {
|
|
20475
20593
|
try {
|
|
20476
|
-
return
|
|
20594
|
+
return path34.join(fs22.realpathSync.native(dir), rest);
|
|
20477
20595
|
} catch {
|
|
20478
|
-
if (
|
|
20596
|
+
if (path34.dirname(dir) === dir)
|
|
20479
20597
|
return file;
|
|
20480
|
-
rest = rest ?
|
|
20598
|
+
rest = rest ? path34.join(path34.basename(dir), rest) : path34.basename(dir);
|
|
20481
20599
|
}
|
|
20482
20600
|
}
|
|
20483
20601
|
};
|
|
20484
20602
|
var canonical6 = (file, hops = { chain: 40, total: 1000 }) => {
|
|
20485
|
-
const start =
|
|
20486
|
-
const { root } =
|
|
20603
|
+
const start = path34.isAbsolute(file) ? file : `${process.cwd()}${path34.sep}${file}`;
|
|
20604
|
+
const { root } = path34.parse(start);
|
|
20487
20605
|
let at = root;
|
|
20488
20606
|
let missing = false;
|
|
20489
20607
|
for (const part of start.slice(root.length).split(/[\\/]+/)) {
|
|
20490
20608
|
if (part === "" || part === ".")
|
|
20491
20609
|
continue;
|
|
20492
20610
|
if (part === "..") {
|
|
20493
|
-
at =
|
|
20611
|
+
at = path34.dirname(at);
|
|
20494
20612
|
continue;
|
|
20495
20613
|
}
|
|
20496
|
-
const next =
|
|
20614
|
+
const next = path34.join(at, part);
|
|
20497
20615
|
let link = null;
|
|
20498
20616
|
if (!missing)
|
|
20499
20617
|
try {
|
|
@@ -20505,25 +20623,25 @@ var canonical6 = (file, hops = { chain: 40, total: 1000 }) => {
|
|
|
20505
20623
|
at = next;
|
|
20506
20624
|
hops.chain = 40;
|
|
20507
20625
|
} else if (hops.chain-- > 0 && hops.total-- > 0)
|
|
20508
|
-
at = canonical6(
|
|
20626
|
+
at = canonical6(path34.isAbsolute(link) ? link : `${at}${path34.sep}${link}`, hops);
|
|
20509
20627
|
else
|
|
20510
|
-
return
|
|
20628
|
+
return path34.resolve(file);
|
|
20511
20629
|
}
|
|
20512
20630
|
return realOf(at);
|
|
20513
20631
|
};
|
|
20514
20632
|
var within = (child, parent) => {
|
|
20515
20633
|
const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
|
|
20516
|
-
const relative =
|
|
20517
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
20634
|
+
const relative = path34.relative(fold(parent), fold(child));
|
|
20635
|
+
return relative === "" || !relative.startsWith("..") && !path34.isAbsolute(relative);
|
|
20518
20636
|
};
|
|
20519
20637
|
var checkoutOf2 = (file) => {
|
|
20520
|
-
for (let dir = canonical6(file);; dir =
|
|
20521
|
-
const dotGit =
|
|
20638
|
+
for (let dir = canonical6(file);; dir = path34.dirname(dir)) {
|
|
20639
|
+
const dotGit = path34.join(dir, ".git");
|
|
20522
20640
|
if (fs22.existsSync(dotGit)) {
|
|
20523
20641
|
const admin = fs22.statSync(dotGit).isFile() ? gitDirsAt(dir, null, false)?.[0] : undefined;
|
|
20524
|
-
return { root: dir, workit: !!admin && fs22.existsSync(
|
|
20642
|
+
return { root: dir, workit: !!admin && fs22.existsSync(path34.join(admin, FANOUT_TOKEN_FILE)) };
|
|
20525
20643
|
}
|
|
20526
|
-
if (
|
|
20644
|
+
if (path34.dirname(dir) === dir)
|
|
20527
20645
|
return null;
|
|
20528
20646
|
}
|
|
20529
20647
|
};
|
|
@@ -20535,8 +20653,8 @@ var workitWorktreeOf = (file) => {
|
|
|
20535
20653
|
return null;
|
|
20536
20654
|
}
|
|
20537
20655
|
};
|
|
20538
|
-
var bindingDir = () =>
|
|
20539
|
-
var bindingFile = (session, agentId) =>
|
|
20656
|
+
var bindingDir = () => path34.join(resolveStateDir(), "worktree-bind");
|
|
20657
|
+
var bindingFile = (session, agentId) => path34.join(bindingDir(), `${createHash16("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
|
|
20540
20658
|
var readBinding = (file) => {
|
|
20541
20659
|
try {
|
|
20542
20660
|
const value = JSON.parse(fs22.readFileSync(file, "utf8"));
|
|
@@ -20561,7 +20679,7 @@ var bind = (input, worktree) => {
|
|
|
20561
20679
|
agentId,
|
|
20562
20680
|
at: new Date().toISOString()
|
|
20563
20681
|
};
|
|
20564
|
-
fs22.mkdirSync(
|
|
20682
|
+
fs22.mkdirSync(path34.dirname(file), { recursive: true });
|
|
20565
20683
|
fs22.writeFileSync(file, JSON.stringify(binding));
|
|
20566
20684
|
try {
|
|
20567
20685
|
if (inWorkitWorkspace(input.cwd))
|
|
@@ -20580,26 +20698,26 @@ var hostIsolated = (cwd, agentId) => {
|
|
|
20580
20698
|
const checkout = checkoutOf2(cwd);
|
|
20581
20699
|
if (!checkout)
|
|
20582
20700
|
return false;
|
|
20583
|
-
const dotGit =
|
|
20701
|
+
const dotGit = path34.join(checkout.root, ".git");
|
|
20584
20702
|
if (!fs22.statSync(dotGit).isFile())
|
|
20585
20703
|
return false;
|
|
20586
20704
|
const [adminDir, gitDir] = gitDirsAt(checkout.root, null, false) ?? [];
|
|
20587
|
-
const back = fs22.readFileSync(
|
|
20588
|
-
if (
|
|
20705
|
+
const back = fs22.readFileSync(path34.join(adminDir, "gitdir"), "utf8").trim();
|
|
20706
|
+
if (path34.relative(canonical6(path34.resolve(adminDir, back)), canonical6(dotGit)) !== "")
|
|
20589
20707
|
return false;
|
|
20590
|
-
const expected =
|
|
20591
|
-
return
|
|
20708
|
+
const expected = path34.join(path34.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
|
|
20709
|
+
return path34.relative(canonical6(expected), checkout.root) === "";
|
|
20592
20710
|
} catch {
|
|
20593
20711
|
return false;
|
|
20594
20712
|
}
|
|
20595
20713
|
};
|
|
20596
20714
|
var runnerAt = (target) => {
|
|
20597
|
-
const base =
|
|
20715
|
+
const base = path34.basename(target);
|
|
20598
20716
|
return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
|
|
20599
20717
|
};
|
|
20600
20718
|
var shown = (target) => {
|
|
20601
|
-
const named = /^\.workit-(?:live-target$|runs-)/.test(
|
|
20602
|
-
return
|
|
20719
|
+
const named = /^\.workit-(?:live-target$|runs-)/.test(path34.basename(target)) ? path34.dirname(target) : target;
|
|
20720
|
+
return path34.sep === "\\" ? named.replaceAll("/", "\\") : named;
|
|
20603
20721
|
};
|
|
20604
20722
|
var runFrom = (dir, command) => `cd ${dir} && ${command.replace(/^\s*cd\s+\S+\s*(?:&&|;)\s*/, "")}`;
|
|
20605
20723
|
var deny2 = (what, unblock) => ({
|
|
@@ -20615,7 +20733,7 @@ var outsideDeny = (input, worktree, target, command) => {
|
|
|
20615
20733
|
};
|
|
20616
20734
|
var unknownDirDeny = (input, worktree) => deny2(`workit worktree confinement: implementer ${input.session.agentId} writes after a directory change Workit cannot resolve (\`cd -\`, \`cd "$X"\`, \`popd\`)`, `Why: write by absolute path, \`git -C ${worktree ?? "<worktree>"}\` or \`workit <verb> --cwd\`.`);
|
|
20617
20735
|
var refsOf = (targets) => [
|
|
20618
|
-
...new Set(targets.flatMap((target) =>
|
|
20736
|
+
...new Set(targets.flatMap((target) => path34.relative(UNKNOWN_VAR, path34.resolve(target)).split(path34.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
|
|
20619
20737
|
];
|
|
20620
20738
|
var literalForm = (command, refs) => {
|
|
20621
20739
|
let text = command;
|
|
@@ -20648,10 +20766,10 @@ function confineImplementer(input, targets, command) {
|
|
|
20648
20766
|
try {
|
|
20649
20767
|
if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
|
|
20650
20768
|
return NONE5;
|
|
20651
|
-
const unresolved = targets.filter((target) => within(
|
|
20769
|
+
const unresolved = targets.filter((target) => within(path34.resolve(target), UNKNOWN_VAR));
|
|
20652
20770
|
if (unresolved.length > 0)
|
|
20653
20771
|
return unknownVarDeny(input, unresolved, command);
|
|
20654
|
-
if (targets.some((target) => within(
|
|
20772
|
+
if (targets.some((target) => within(path34.resolve(target), UNKNOWN_DIR)))
|
|
20655
20773
|
return unknownDirDeny(input, boundWorktree(input));
|
|
20656
20774
|
const bindings = canonical6(bindingDir());
|
|
20657
20775
|
const judged = targets.map((named) => ({ named, real: canonical6(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
|
|
@@ -20758,10 +20876,10 @@ var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/
|
|
|
20758
20876
|
var VALUED2 = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
|
|
20759
20877
|
var commonDir = (root) => gitDirsAt(root, null, false)?.[1] ?? "";
|
|
20760
20878
|
var inScratch = (real, repo) => {
|
|
20761
|
-
for (let dir = real;
|
|
20762
|
-
if (
|
|
20879
|
+
for (let dir = real;path34.dirname(dir) !== dir; dir = path34.dirname(dir)) {
|
|
20880
|
+
if (path34.basename(dir) !== SCRATCH)
|
|
20763
20881
|
continue;
|
|
20764
|
-
const root =
|
|
20882
|
+
const root = path34.dirname(dir);
|
|
20765
20883
|
const checkout = checkoutOf2(root);
|
|
20766
20884
|
if (checkout?.root === root && (repo === null || checkout.workit || commonDir(root) === repo))
|
|
20767
20885
|
return true;
|
|
@@ -20771,7 +20889,7 @@ var inScratch = (real, repo) => {
|
|
|
20771
20889
|
var inGitDir = (real) => real.split(/[\\/]/).includes(".git");
|
|
20772
20890
|
var SAFE_KEY = /^(?:core\.(?:repositoryformatversion|filemode|bare|logallrefupdates|ignorecase|precomposeunicode|symlinks)|user\..*|init\.defaultbranch|commit\.gpgsign|extensions\.(?:objectformat|refstorage)|branch\..*\.(?:remote|merge)|remote\..*\.fetch)$/;
|
|
20773
20891
|
var literalIn = (value, repo, checkout = false) => {
|
|
20774
|
-
if (/[$`]/.test(value) || !
|
|
20892
|
+
if (/[$`]/.test(value) || !path34.isAbsolute(value))
|
|
20775
20893
|
return false;
|
|
20776
20894
|
const real = canonical6(value);
|
|
20777
20895
|
const root = checkout ? checkoutOf2(real)?.root : undefined;
|
|
@@ -20792,8 +20910,8 @@ var configEntries = (text) => {
|
|
|
20792
20910
|
return entries;
|
|
20793
20911
|
};
|
|
20794
20912
|
function gitDirsAt(dir, repo, scan = true) {
|
|
20795
|
-
for (let at = dir;; at =
|
|
20796
|
-
const dotGit =
|
|
20913
|
+
for (let at = dir;; at = path34.dirname(at)) {
|
|
20914
|
+
const dotGit = path34.join(at, ".git");
|
|
20797
20915
|
let gitDir = null;
|
|
20798
20916
|
try {
|
|
20799
20917
|
if (fs22.statSync(dotGit).isDirectory())
|
|
@@ -20802,19 +20920,19 @@ function gitDirsAt(dir, repo, scan = true) {
|
|
|
20802
20920
|
const named = /^gitdir:\s*(.+?)\s*$/mu.exec(fs22.readFileSync(dotGit, "utf8"))?.[1];
|
|
20803
20921
|
if (!named)
|
|
20804
20922
|
return null;
|
|
20805
|
-
gitDir = canonical6(
|
|
20923
|
+
gitDir = canonical6(path34.resolve(at, named));
|
|
20806
20924
|
}
|
|
20807
20925
|
} catch (error) {
|
|
20808
20926
|
if (error.code !== "ENOENT")
|
|
20809
20927
|
return null;
|
|
20810
|
-
if (["HEAD", "objects", "refs"].every((name) => fs22.existsSync(
|
|
20928
|
+
if (["HEAD", "objects", "refs"].every((name) => fs22.existsSync(path34.join(at, name))))
|
|
20811
20929
|
gitDir = canonical6(at);
|
|
20812
20930
|
}
|
|
20813
20931
|
if (gitDir !== null) {
|
|
20814
|
-
const common =
|
|
20815
|
-
const shared = fs22.existsSync(common) ? canonical6(
|
|
20932
|
+
const common = path34.join(gitDir, "commondir");
|
|
20933
|
+
const shared = fs22.existsSync(common) ? canonical6(path34.resolve(gitDir, fs22.readFileSync(common, "utf8").trim())) : gitDir;
|
|
20816
20934
|
const dirs = [gitDir, shared];
|
|
20817
|
-
for (const config of scan ? new Set([
|
|
20935
|
+
for (const config of scan ? new Set([path34.join(gitDir, "config"), path34.join(shared, "config")]) : []) {
|
|
20818
20936
|
let text = "";
|
|
20819
20937
|
try {
|
|
20820
20938
|
text = fs22.readFileSync(config, "utf8");
|
|
@@ -20823,14 +20941,14 @@ function gitDirsAt(dir, repo, scan = true) {
|
|
|
20823
20941
|
}
|
|
20824
20942
|
for (const [key, value] of configEntries(text)) {
|
|
20825
20943
|
if (key === "core.worktree")
|
|
20826
|
-
dirs.push(canonical6(
|
|
20944
|
+
dirs.push(canonical6(path34.resolve(gitDir, value)));
|
|
20827
20945
|
else if (/^remote\..*\.url$/.test(key) ? !literalIn(value, repo, true) : !SAFE_KEY.test(key))
|
|
20828
20946
|
return null;
|
|
20829
20947
|
}
|
|
20830
20948
|
}
|
|
20831
20949
|
return dirs;
|
|
20832
20950
|
}
|
|
20833
|
-
if (
|
|
20951
|
+
if (path34.dirname(at) === at)
|
|
20834
20952
|
return [];
|
|
20835
20953
|
}
|
|
20836
20954
|
}
|
|
@@ -20970,10 +21088,10 @@ var gitKind = (args, local = () => true) => {
|
|
|
20970
21088
|
return GIT_VERBS[verb].startsWith("+") ? "write" : "read";
|
|
20971
21089
|
};
|
|
20972
21090
|
var remoteIn = (dir, name, repo) => {
|
|
20973
|
-
const shared =
|
|
21091
|
+
const shared = path34.isAbsolute(dir) ? gitDirsAt(canonical6(dir), repo, false)?.[1] : undefined;
|
|
20974
21092
|
if (!shared)
|
|
20975
21093
|
return false;
|
|
20976
|
-
const url = configEntries(fs22.readFileSync(
|
|
21094
|
+
const url = configEntries(fs22.readFileSync(path34.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
|
|
20977
21095
|
return url !== undefined && literalIn(url, repo, true);
|
|
20978
21096
|
};
|
|
20979
21097
|
var judgeGit = (command, repo, cwd, depth = 0) => {
|
|
@@ -20987,7 +21105,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
|
|
|
20987
21105
|
const lead = [];
|
|
20988
21106
|
while (/^\w+\+?=/.test(words[at] ?? ""))
|
|
20989
21107
|
lead.push(words[at++]);
|
|
20990
|
-
const name =
|
|
21108
|
+
const name = path34.basename(words[at] ?? "");
|
|
20991
21109
|
let start = words.findIndex((word) => /(?:^|[\\/])git(?:\.exe)?(?:=|$)/.test(word));
|
|
20992
21110
|
if (start > at) {
|
|
20993
21111
|
if (/^(?:grep|egrep|rg|echo|printf|ls|wc|head|tail|cat|which|type|test|\[|cd|mkdir)$/.test(name) || name === "command" && /^-[vV]$/.test(words[at + 1] ?? ""))
|
|
@@ -20998,7 +21116,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
|
|
|
20998
21116
|
if (start >= 0 && words[start].includes("="))
|
|
20999
21117
|
why = "git is redefined";
|
|
21000
21118
|
const run = words[start] ?? "";
|
|
21001
|
-
if (run.includes("/") && (!
|
|
21119
|
+
if (run.includes("/") && (!path34.isAbsolute(run) || literalIn(run, repo, true)))
|
|
21002
21120
|
why ??= `\`${run}\` is not the system git`;
|
|
21003
21121
|
if (segment.expands?.includes(at) && name !== "[" || /\{[^}]*,/.test(words[at] ?? ""))
|
|
21004
21122
|
why = "the command's name is expanded by the shell";
|
|
@@ -21023,13 +21141,13 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
|
|
|
21023
21141
|
const args = words[index] === "--version" ? ["version"] : words.slice(index);
|
|
21024
21142
|
if (!why && start >= 0) {
|
|
21025
21143
|
const local = (source, remote) => remote && /^[\w-][\w.-]*$/.test(source) ? remoteIn(dir, source, repo) : literalIn(source, repo, true);
|
|
21026
|
-
const runsIn =
|
|
21144
|
+
const runsIn = path34.isAbsolute(dir) ? dir : cwd && path34.resolve(cwd, dir);
|
|
21027
21145
|
const home = runsIn && checkoutOf2(runsIn);
|
|
21028
21146
|
const fetches = args[0] === "fetch" && plainFetch(args.slice(1)) && home && (home.workit || commonDir(home.root) === repo) && !words.some((word) => /^--[gw]/.test(word));
|
|
21029
21147
|
if (!fetches && !gitKind(args, local))
|
|
21030
21148
|
why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
|
|
21031
21149
|
}
|
|
21032
|
-
const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(
|
|
21150
|
+
const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path34.basename(word)));
|
|
21033
21151
|
const scripts = [
|
|
21034
21152
|
...words.filter((_, after) => shell >= 0 && after > shell && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(words[after - 1])),
|
|
21035
21153
|
...shell < 0 ? [] : segment.stdin ?? []
|
|
@@ -21074,7 +21192,7 @@ var judgeVerbRefused = (args) => {
|
|
|
21074
21192
|
var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
|
|
21075
21193
|
var CLI_ENTRY = /(?:^|[=\\/])(?:workit(?:\.(?:exe|cmd|[cm]?js))?|@workit-dev\/cli(?:@\S*)?)$|(?:workit-cli|@workit-dev[\\/]cli)[\\/](?:src[\\/](?:index|main)|dist[\\/]index)\.[cm]?[jt]sx?$/;
|
|
21076
21194
|
var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
|
|
21077
|
-
const name =
|
|
21195
|
+
const name = path34.basename(words[0] ?? "").toLowerCase();
|
|
21078
21196
|
if (name === "alias")
|
|
21079
21197
|
return words.flatMap((word) => {
|
|
21080
21198
|
const set = /^([\w-]+)=(.*)$/s.exec(word);
|
|
@@ -21103,11 +21221,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
|
|
|
21103
21221
|
return why;
|
|
21104
21222
|
}
|
|
21105
21223
|
const { words } = segment;
|
|
21106
|
-
const runs = (word = "") => RUNS.test(
|
|
21224
|
+
const runs = (word = "") => RUNS.test(path34.basename(word).toLowerCase());
|
|
21107
21225
|
let at = 0;
|
|
21108
21226
|
while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
|
|
21109
21227
|
at++;
|
|
21110
|
-
const name =
|
|
21228
|
+
const name = path34.basename(words[at] ?? "").toLowerCase();
|
|
21111
21229
|
const args = words.slice(at + 1);
|
|
21112
21230
|
const unseen = `\`${words.join(" ").slice(0, 80)}\` runs a script Workit cannot read (piped, on stdin, a process substitution or eval): write the case to a file in ${SCRATCH} and dispatch it from a test instead`;
|
|
21113
21231
|
if (/^(?:cd|chdir|pushd|popd)$/.test(name))
|
|
@@ -21189,9 +21307,9 @@ var judgeDeny = (input, what, target, retry) => {
|
|
|
21189
21307
|
const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
|
|
21190
21308
|
const root = checkoutOf2(input.cwd)?.root;
|
|
21191
21309
|
const candidate = target ? checkoutOf2(target)?.root : undefined;
|
|
21192
|
-
const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ?
|
|
21193
|
-
const scratch = root ? `${
|
|
21194
|
-
const call = root ? retry?.((other ??
|
|
21310
|
+
const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? path34.join(candidate, SCRATCH) : undefined;
|
|
21311
|
+
const scratch = root ? `${path34.join(root, SCRATCH)}${other ? ` or ${other}` : ""}` : `${SCRATCH}/ at the root of the checkout you judge`;
|
|
21312
|
+
const call = root ? retry?.((other ?? path34.join(root, SCRATCH)).replaceAll("\\", "/")) : null;
|
|
21195
21313
|
const unblock = call ? `Retry as: ${call}` : "Why: write only there (mkdir -p it); a fix the candidate needs is a finding (`workit finding record`).";
|
|
21196
21314
|
return {
|
|
21197
21315
|
kind: "deny",
|
|
@@ -21202,9 +21320,9 @@ ${unblock}`,
|
|
|
21202
21320
|
};
|
|
21203
21321
|
var movedInto = (command, cwd, target, dir) => {
|
|
21204
21322
|
for (const { words, redirects } of segmentsOf(command))
|
|
21205
|
-
for (const word of [...redirects, ...
|
|
21206
|
-
if (
|
|
21207
|
-
const moved = command.replace(new RegExp(`((?:>>?\\|?|\\btee(?:\\s+-a)?)\\s*)(['"]?)${word.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}\\2(?![^\\s;&|)])`), (_, lead) => `${lead}${dir}/${
|
|
21323
|
+
for (const word of [...redirects, ...path34.basename(words[0] ?? "") === "tee" ? words : []])
|
|
21324
|
+
if (path34.resolve(cwd, word) === path34.resolve(cwd, target)) {
|
|
21325
|
+
const moved = command.replace(new RegExp(`((?:>>?\\|?|\\btee(?:\\s+-a)?)\\s*)(['"]?)${word.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}\\2(?![^\\s;&|)])`), (_, lead) => `${lead}${dir}/${path34.basename(word)}`);
|
|
21208
21326
|
return moved === command ? null : moved;
|
|
21209
21327
|
}
|
|
21210
21328
|
return null;
|
|
@@ -21216,19 +21334,19 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets), co
|
|
|
21216
21334
|
const judged = checkoutOf2(input.cwd);
|
|
21217
21335
|
const repo = judged ? commonDir(judged.root) : null;
|
|
21218
21336
|
const scratch = (real) => inScratch(real, repo) || [os10.tmpdir(), "/tmp"].some((dir) => {
|
|
21219
|
-
const [host, , session] =
|
|
21337
|
+
const [host, , session] = path34.relative(canonical6(dir), real).split(path34.sep);
|
|
21220
21338
|
return /^claude-\d+$/.test(host) && session === input.session.id;
|
|
21221
21339
|
});
|
|
21222
21340
|
for (const target of targets) {
|
|
21223
|
-
const resolved =
|
|
21341
|
+
const resolved = path34.resolve(target);
|
|
21224
21342
|
if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
|
|
21225
21343
|
return judgeDeny(input, "it writes to a path Workit cannot resolve", undefined, () => {
|
|
21226
21344
|
const literal = command && literalForm(command, refsOf([target]));
|
|
21227
21345
|
return literal === command ? null : literal;
|
|
21228
21346
|
});
|
|
21229
21347
|
const real = canonical6(target);
|
|
21230
|
-
const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(
|
|
21231
|
-
const gitDirs = runsGit ? gitDirsAt(
|
|
21348
|
+
const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path34.basename(target));
|
|
21349
|
+
const gitDirs = runsGit ? gitDirsAt(path34.dirname(real), repo) : [];
|
|
21232
21350
|
if (gitDirs === null)
|
|
21233
21351
|
return judgeDeny(input, `git in ${shown(target)} uses a git dir or config Workit cannot check`);
|
|
21234
21352
|
if (runsGit ? gitDirs.length > 0 ? gitDirs.every(scratch) : scratch(real) : scratch(real) && !inGitDir(real))
|
|
@@ -21294,7 +21412,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
|
|
|
21294
21412
|
let git = [];
|
|
21295
21413
|
try {
|
|
21296
21414
|
git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args) || gitKind(args) === "write" && !/^(?:init|clone)$/.test(args[0]) && !(args[0] === "fetch" && plainFetch(args.slice(1)))) ? [
|
|
21297
|
-
|
|
21415
|
+
path34.join(dir === undefined ? UNKNOWN_DIR : path34.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
|
|
21298
21416
|
] : []);
|
|
21299
21417
|
} catch {}
|
|
21300
21418
|
const lists = [
|
|
@@ -21339,7 +21457,7 @@ var judgeChecksLine = (cwd) => {
|
|
|
21339
21457
|
|
|
21340
21458
|
// packages/workit-core/src/hooks/standing.ts
|
|
21341
21459
|
var readPlans = (store) => {
|
|
21342
|
-
const dir =
|
|
21460
|
+
const dir = path35.join(store, "fanouts");
|
|
21343
21461
|
let names;
|
|
21344
21462
|
try {
|
|
21345
21463
|
names = fs23.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
@@ -21349,7 +21467,7 @@ var readPlans = (store) => {
|
|
|
21349
21467
|
const plans = [];
|
|
21350
21468
|
for (const name of names) {
|
|
21351
21469
|
try {
|
|
21352
|
-
const raw = JSON.parse(fs23.readFileSync(
|
|
21470
|
+
const raw = JSON.parse(fs23.readFileSync(path35.join(dir, name), "utf8"));
|
|
21353
21471
|
if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
|
|
21354
21472
|
continue;
|
|
21355
21473
|
const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
|
|
@@ -21559,12 +21677,12 @@ var cdWorkitSplit = (command) => {
|
|
|
21559
21677
|
|
|
21560
21678
|
// packages/workit-core/src/hooks/spawn-gate.ts
|
|
21561
21679
|
import fs24 from "node:fs";
|
|
21562
|
-
import
|
|
21680
|
+
import path37 from "node:path";
|
|
21563
21681
|
|
|
21564
21682
|
// packages/workit-core/src/hooks/model-limit.ts
|
|
21565
21683
|
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync4, readSync, statSync as statSync5 } from "node:fs";
|
|
21566
21684
|
import os11 from "node:os";
|
|
21567
|
-
import
|
|
21685
|
+
import path36 from "node:path";
|
|
21568
21686
|
var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
21569
21687
|
var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
|
|
21570
21688
|
var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
|
|
@@ -21762,17 +21880,17 @@ var firstPrompt = (file) => {
|
|
|
21762
21880
|
var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
|
|
21763
21881
|
var listDir = (dir) => {
|
|
21764
21882
|
try {
|
|
21765
|
-
return readdirSync4(dir).map((name) =>
|
|
21883
|
+
return readdirSync4(dir).map((name) => path36.join(dir, name));
|
|
21766
21884
|
} catch {
|
|
21767
21885
|
return [];
|
|
21768
21886
|
}
|
|
21769
21887
|
};
|
|
21770
21888
|
var SCAN_MS = 30 * 60000;
|
|
21771
21889
|
var scanClaudeTranscripts = (cwd, env, now = new Date) => {
|
|
21772
|
-
const projects =
|
|
21773
|
-
const project =
|
|
21890
|
+
const projects = path36.join(env.CLAUDE_CONFIG_DIR || path36.join(env.HOME || os11.homedir(), ".claude"), "projects");
|
|
21891
|
+
const project = path36.join(projects, claudeProjectSlug(cwd));
|
|
21774
21892
|
const notes = [];
|
|
21775
|
-
const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(
|
|
21893
|
+
const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path36.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
|
|
21776
21894
|
for (const { file, worker } of files)
|
|
21777
21895
|
try {
|
|
21778
21896
|
const stat = statSync5(file);
|
|
@@ -21787,7 +21905,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
|
|
|
21787
21905
|
if (!seen)
|
|
21788
21906
|
continue;
|
|
21789
21907
|
notes.push(worker ? redispatchNote(seen, {
|
|
21790
|
-
label: `worker ${
|
|
21908
|
+
label: `worker ${path36.basename(file, ".jsonl")}`,
|
|
21791
21909
|
prompt: firstPrompt(file)
|
|
21792
21910
|
}, now) : `Workit: this session hit a usage limit (${seen.reason}); ${seen.key} is marked exhausted until ${shortTime(seen.until)}. Claude Code runs only Anthropic models: Workit cannot switch this session, so continue on another host or after the reset.`);
|
|
21793
21911
|
} catch {}
|
|
@@ -21889,10 +22007,10 @@ var namesMade = (word) => {
|
|
|
21889
22007
|
const stat = fs24.statSync(word);
|
|
21890
22008
|
if (stat.isFile())
|
|
21891
22009
|
return stat.size < 1e6 && MADE_WORKTREE.test(fs24.readFileSync(word, "utf8"));
|
|
21892
|
-
const dotGit =
|
|
22010
|
+
const dotGit = path37.join(word, ".git");
|
|
21893
22011
|
const link = fs24.statSync(dotGit);
|
|
21894
22012
|
const admin = link.isFile() && link.size <= 4096 && /^gitdir: *(.+)/u.exec(fs24.readFileSync(dotGit, "utf8"));
|
|
21895
|
-
return !!admin && fs24.existsSync(
|
|
22013
|
+
return !!admin && fs24.existsSync(path37.resolve(word, admin[1].trim(), FANOUT_TOKEN_FILE));
|
|
21896
22014
|
} catch {
|
|
21897
22015
|
return false;
|
|
21898
22016
|
}
|
|
@@ -21939,7 +22057,7 @@ var spawnDecision = (descriptor, cwd, tool, permissionMode = null) => {
|
|
|
21939
22057
|
// packages/workit-core/src/hooks/teardown.ts
|
|
21940
22058
|
import { spawn } from "node:child_process";
|
|
21941
22059
|
import fs25 from "node:fs";
|
|
21942
|
-
import
|
|
22060
|
+
import path38 from "node:path";
|
|
21943
22061
|
var REAP_INTERVAL_MS = 10 * 60000;
|
|
21944
22062
|
var LOG_MAX_BYTES = 1 << 20;
|
|
21945
22063
|
var ENDS = {
|
|
@@ -21950,9 +22068,9 @@ var ENDS = {
|
|
|
21950
22068
|
};
|
|
21951
22069
|
var SAFE_SESSION = /^[\w.@+][\w.:@/+-]{0,127}$/u;
|
|
21952
22070
|
var HOST_SESSION_VARS = ["OPENCODE_SESSION_ID", "PI_SESSION_ID", "CODEX_THREAD_ID"];
|
|
21953
|
-
var teardownDir = (env) =>
|
|
21954
|
-
var teardownLog = (env) =>
|
|
21955
|
-
var reapStamp = (env) =>
|
|
22071
|
+
var teardownDir = (env) => path38.join(stateDir3(env), "procs");
|
|
22072
|
+
var teardownLog = (env) => path38.join(teardownDir(env), "teardown.log");
|
|
22073
|
+
var reapStamp = (env) => path38.join(teardownDir(env), "reap-at-start.stamp");
|
|
21956
22074
|
function spawnDetached(request) {
|
|
21957
22075
|
try {
|
|
21958
22076
|
const shell = process.platform === "win32" && !/\.exe$/iu.test(request.command);
|
|
@@ -21979,7 +22097,7 @@ var teardownDeps = {
|
|
|
21979
22097
|
var openLog = (env, args) => {
|
|
21980
22098
|
try {
|
|
21981
22099
|
const file = teardownLog(env);
|
|
21982
|
-
fs25.mkdirSync(
|
|
22100
|
+
fs25.mkdirSync(path38.dirname(file), { recursive: true });
|
|
21983
22101
|
let size = 0;
|
|
21984
22102
|
try {
|
|
21985
22103
|
size = fs25.statSync(file).size;
|
|
@@ -22064,7 +22182,7 @@ function reapAtStart(_cwd, env = process.env) {
|
|
|
22064
22182
|
try {
|
|
22065
22183
|
if (fresh(stamp, now))
|
|
22066
22184
|
return false;
|
|
22067
|
-
fs25.mkdirSync(
|
|
22185
|
+
fs25.mkdirSync(path38.dirname(stamp), { recursive: true });
|
|
22068
22186
|
if (!claim2(lock, now))
|
|
22069
22187
|
return false;
|
|
22070
22188
|
} catch {
|
|
@@ -23084,7 +23202,7 @@ var dispatchHook = (adapter, raw, env = process.env) => {
|
|
|
23084
23202
|
};
|
|
23085
23203
|
// packages/workit-core/src/hooks/deadline.ts
|
|
23086
23204
|
import { appendFileSync, mkdirSync as mkdirSync4 } from "node:fs";
|
|
23087
|
-
import
|
|
23205
|
+
import path39 from "node:path";
|
|
23088
23206
|
var HOOK_SKIP_TEXT = "workit context skipped: host under load";
|
|
23089
23207
|
var HOOK_DEADLINE_MS = 8000;
|
|
23090
23208
|
var HOST_DEADLINES = {
|
|
@@ -23102,7 +23220,7 @@ var hookDeadlineMs = (env, host = "", native) => {
|
|
|
23102
23220
|
const row = HOST_DEADLINES[host];
|
|
23103
23221
|
return override(env) ?? (row ? native === undefined ? Math.min(...Object.values(row)) : row[native] ?? row[""] : HOOK_DEADLINE_MS);
|
|
23104
23222
|
};
|
|
23105
|
-
var skipsFile = (stateDir) =>
|
|
23223
|
+
var skipsFile = (stateDir) => path39.join(stateDir, HOOK_SKIPS_FILE);
|
|
23106
23224
|
var recordHookSkip = (skip, stateDir = resolveStateDir()) => {
|
|
23107
23225
|
try {
|
|
23108
23226
|
mkdirSync4(stateDir, { recursive: true });
|
|
@@ -76,7 +76,11 @@ var reachTests = (dirs) => {
|
|
|
76
76
|
};
|
|
77
77
|
const state = canon(dirs.state);
|
|
78
78
|
const configs = dirs.configs.map(canon);
|
|
79
|
-
const
|
|
79
|
+
const repoLedger = (file) => [...file.matchAll(/[\\/]workit[\\/]ledger(?=[\\/]|$)/g)].some(({ index }) => {
|
|
80
|
+
const gitDir = file.slice(0, index);
|
|
81
|
+
return /(?:^|[\\/])\.git$/.test(gitDir) || existsSync(path.join(gitDir, "HEAD")) && existsSync(path.join(gitDir, "objects"));
|
|
82
|
+
});
|
|
83
|
+
const at = (file) => file === LOST || configs.some((dir) => within(dir, file)) || within(state, file) && /^(?:issued[^\\/]*|approvals|verdicts|folders[\\/][^\\/]+[\\/]ledger)(?:[\\/]|$)/.test(path.relative(state, file)) || repoLedger(file);
|
|
80
84
|
const above = (file) => within(file, state) || configs.some((dir) => within(file, dir));
|
|
81
85
|
const linked = (file) => {
|
|
82
86
|
try {
|
|
@@ -98,7 +102,7 @@ var mayReachWith = (text, cwd, dirs) => {
|
|
|
98
102
|
return true;
|
|
99
103
|
const joined = text.replace(/\\\r?\n/g, "");
|
|
100
104
|
const bare = joined.replace(/['"\\]/g, "");
|
|
101
|
-
if (/\$['"]/.test(joined) || /~[\w+-]|\$\{(?:!|\w+[^\w}])|\bpopd\b/.test(bare) || /(?:^|[\s;&|(])(?:cd|pushd|chdir)(?:\s+-\S*)*\s*(?:$|[;&|)\n$`])/.test(bare) || dirs.env.CDPATH !== undefined && /\b(?:cd|pushd)\b/.test(bare))
|
|
105
|
+
if (/\$['"]/.test(joined) || /~[\w+-]|\$\{(?:!|\w+[^\w}])|\bpopd\b/.test(bare) || /(?:^|[\s;&|(])(?:cd|pushd|chdir)(?:\s+-\S*)*\s*(?:$|[;&|)\n$`])/.test(bare) || dirs.env.CDPATH !== undefined && /\b(?:cd|pushd)\b/.test(bare) || /(?:^|[\s;&|(/])(?:ln|mount|bindfs|mklink)(?:\s|$)/i.test(bare) || /(?:^|[\s;&|(/])(?:cp|install)\s[^;&|\n]*\s(?:-[a-zA-Z]*[ls]|--(?:link|symbolic-link)\b)/.test(bare) || /--link-dest\b|\b(?:symboliclink|junction|hardlink)\b/i.test(bare))
|
|
102
106
|
return true;
|
|
103
107
|
const bound = (name) => new RegExp(`(?:^|[^\\w$])${name}=|\\bfor\\s+${name}\\b|\\bread\\b[^;&|\\n]*\\b${name}\\b`).test(bare);
|
|
104
108
|
const expanded = bare.replace(/\$\{([A-Za-z_]\w*)\}|\$([A-Za-z_]\w*)/g, (all, braced, plain) => {
|
package/dist/workit-hook.js
CHANGED
|
@@ -40,7 +40,7 @@ var { standingPending } = await import("./workit-hook-mk64s4fk.js");
|
|
|
40
40
|
var { procNoticeFile } = await import("./workit-hook-dv9s0sjq.js");
|
|
41
41
|
var { recordHookRun } = await import("./workit-hook-a7qmf2t8.js");
|
|
42
42
|
var { observeHookBudget } = await import("./workit-hook-3g6cv3hd.js");
|
|
43
|
-
var { hasTaskStore, mayReach } = await import("./workit-hook-
|
|
43
|
+
var { hasTaskStore, mayReach } = await import("./workit-hook-zgd5gqzm.js");
|
|
44
44
|
var YTRACK_WORD = /ytrack(?![\w/-]|\.(?!exe|cmd))/i;
|
|
45
45
|
var namesYtrack = (text) => {
|
|
46
46
|
const bare = text.replace(/['"\\]/g, "");
|
|
@@ -101,7 +101,7 @@ if (quiet) {
|
|
|
101
101
|
`);
|
|
102
102
|
} else {
|
|
103
103
|
try {
|
|
104
|
-
const { runCodexHook } = await import("./workit-hook-
|
|
104
|
+
const { runCodexHook } = await import("./workit-hook-2et385jj.js");
|
|
105
105
|
await runCodexHook([payload]);
|
|
106
106
|
} catch (error) {
|
|
107
107
|
const { answerRuntimeFailure } = await import("./workit-hook-2j7nwxvz.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/codex",
|
|
3
|
-
"version": "2.25.
|
|
3
|
+
"version": "2.25.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, method skills, and verifier/reviewer/implementer agents",
|
|
6
6
|
"keywords": [
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"build": "bun scripts/build.ts"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@workit-dev/core": "^2.25.
|
|
45
|
-
"@workit-dev/mcp": "^2.25.
|
|
44
|
+
"@workit-dev/core": "^2.25.2",
|
|
45
|
+
"@workit-dev/mcp": "^2.25.2"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=24"
|