@workit-dev/codex 2.4.3 → 2.4.4
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
|
@@ -30685,6 +30685,7 @@ var MUTATING_GIT = new Set([
|
|
|
30685
30685
|
]);
|
|
30686
30686
|
var DRY_N = new Set(["add", "clean", "rm", "mv"]);
|
|
30687
30687
|
var MUTATING_WORKIT_GIT = new Set(["commit", "branch", "stage", "unstage"]);
|
|
30688
|
+
var PLACEHOLDERS = new WeakMap;
|
|
30688
30689
|
var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
30689
30690
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
30690
30691
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
@@ -31498,6 +31499,60 @@ var MUTATING_REMOTE = new Set([
|
|
|
31498
31499
|
"set-branches",
|
|
31499
31500
|
"prune"
|
|
31500
31501
|
]);
|
|
31502
|
+
var GIT_VERBS = {
|
|
31503
|
+
log: "@d@l|@d @l",
|
|
31504
|
+
show: "@d@l|@d @l",
|
|
31505
|
+
diff: "@d|@d cached staged merge-base no-index",
|
|
31506
|
+
"diff-tree": "@drtcm|@d root stdin no-commit-id",
|
|
31507
|
+
"diff-index": "@dm|@d cached merge-base",
|
|
31508
|
+
status: "sbu?zv|short branch porcelain? long untracked-files? ignored? ignore-submodules? show-stash ahead-behind no-ahead-behind renames no-renames find-renames? column? no-column null verbose",
|
|
31509
|
+
"rev-parse": "q|verify short? abbrev-ref? symbolic symbolic-full-name show-toplevel show-prefix git-dir git-common-dir absolute-git-dir is-inside-work-tree is-inside-git-dir is-bare-repository show-cdup quiet all branches? tags? remotes? since= until= default= path-format= sq-quote",
|
|
31510
|
+
"rev-list": "@l|@l count objects? left-only right-only",
|
|
31511
|
+
"ls-files": "cdmoiskuvtzfx:X:|cached deleted modified others ignored stage unmerged killed directory no-empty-directory exclude-standard exclude= exclude-from= full-name abbrev? error-unmatch with-tree= eol deduplicate format= recurse-submodules sparse",
|
|
31512
|
+
"ls-tree": "rdtlz|long name-only name-status object-only full-name full-tree abbrev? format=",
|
|
31513
|
+
"cat-file": "tsepz|batch? batch-check? batch-all-objects follow-symlinks unordered buffer allow-unknown-type mailmap use-mailmap",
|
|
31514
|
+
blame: "L:lstfnepwbcM?C?|porcelain line-porcelain incremental root show-stats show-name show-number show-email abbrev= reverse= first-parent date= ignore-rev= ignore-revs-file= minimal contents=",
|
|
31515
|
+
describe: "|tags all long abbrev= contains always dirty? broken? match= exclude= first-parent exact-match candidates= debug",
|
|
31516
|
+
"merge-base": "a|all octopus independent is-ancestor fork-point",
|
|
31517
|
+
"for-each-ref": "|count= sort= format= color? shell perl python tcl points-at= merged? no-merged? contains? no-contains? ignore-case omit-empty exclude=",
|
|
31518
|
+
shortlog: "@lsnec|@l summary numbered email committer group= format=",
|
|
31519
|
+
"show-ref": "dsq|head verify heads tags branches hash? abbrev? quiet dereference exists",
|
|
31520
|
+
"name-rev": "|tags refs= exclude= all annotate-stdin name-only no-undefined always",
|
|
31521
|
+
grep: "aiIvnhHcEGFPlLzoWqwe:A:B:C:m:f:|cached untracked no-index no-exclude-standard exclude-standard recurse-submodules text ignore-case word-regexp invert-match line-number column count full-name extended-regexp basic-regexp fixed-strings perl-regexp files-with-matches name-only files-without-match null only-matching heading break show-function function-context max-depth= threads= and or not all-match quiet after-context= before-context= context= max-count= color? no-color",
|
|
31522
|
+
"format-patch": "@do:nNks|@d stdout output-directory= numbered no-numbered start-number= subject-prefix= root cover-letter thread? signoff attach? inline? suffix= base=",
|
|
31523
|
+
reflog: "@l|@l all expire= expire-unreachable= rewrite updateref stale-fix dry-run verbose",
|
|
31524
|
+
"count-objects": "vH|verbose human-readable",
|
|
31525
|
+
"check-ignore": "qvnz|quiet verbose stdin non-matching no-index",
|
|
31526
|
+
var: "l|",
|
|
31527
|
+
version: "|build-options",
|
|
31528
|
+
"ls-remote": "htbq|heads tags branches refs quiet exit-code get-url symref sort=",
|
|
31529
|
+
remote: "v|verbose",
|
|
31530
|
+
config: "lz|get get-all get-regexp list local name-only null type= default=",
|
|
31531
|
+
worktree: "fdqvzb:B:|force detach lock reason= orphan no-checkout checkout quiet track no-track guess-remote porcelain expire= verbose",
|
|
31532
|
+
branch: "dDmMcCfvraliu:|delete move copy force list all remotes verbose contains? merged? no-merged? points-at= show-current set-upstream-to= unset-upstream track? no-track sort= format= color? column? ignore-case create-reflog",
|
|
31533
|
+
tag: "lam:dfF:n?|list annotate message= file= delete force sort= format= contains? merged? no-merged? points-at= column? create-reflog ignore-case",
|
|
31534
|
+
init: "+qb:|quiet bare initial-branch= object-format= ref-format= shared? separate-git-dir=",
|
|
31535
|
+
add: "+AunNvf|all update intent-to-add force dry-run verbose ignore-errors ignore-removal no-all renormalize chmod= sparse",
|
|
31536
|
+
commit: "+m:aqsnF:C:ouv|message= all amend no-edit allow-empty allow-empty-message author= date= signoff no-verify quiet file= reuse-message= fixup= squash= only include dry-run no-gpg-sign untracked-files? cleanup= reset-author verbose",
|
|
31537
|
+
checkout: "+b:B:fqm|detach force orphan= quiet track? no-track merge ours theirs",
|
|
31538
|
+
switch: "+c:C:dfqm|create= force-create= detach discard-changes force orphan= quiet track? no-track merge",
|
|
31539
|
+
restore: "+s:SWq|source= staged worktree ours theirs merge quiet overlay no-overlay",
|
|
31540
|
+
reset: "+qN|soft mixed hard merge keep quiet no-refresh",
|
|
31541
|
+
rm: "+rfnq|cached force dry-run quiet ignore-unmatch",
|
|
31542
|
+
mv: "+fnkv|force dry-run verbose",
|
|
31543
|
+
merge: "+m:qvnX:|no-ff ff ff-only squash no-squash commit no-commit message= no-edit abort continue quit allow-unrelated-histories stat no-stat quiet verbose no-verify signoff strategy-option=",
|
|
31544
|
+
stash: "+m:ukqa|message= include-untracked keep-index quiet all index staged",
|
|
31545
|
+
apply: "+p:C:R3qv|check stat numstat summary index cached 3way reverse reject allow-empty exclude= include= verbose quiet whitespace= recount",
|
|
31546
|
+
am: "+skq3|signoff keep 3way quiet abort continue skip quit whitespace= reject",
|
|
31547
|
+
fetch: "+fqvptn|all depth= deepen= shallow-since= unshallow tags no-tags prune force quiet verbose dry-run update-shallow refmap=",
|
|
31548
|
+
clone: "+nqlsb:o:|bare no-checkout depth= branch= origin= single-branch no-single-branch no-tags quiet shared local no-local filter= separate-git-dir=",
|
|
31549
|
+
"cherry-pick": "+nm:sxX:|no-commit mainline= signoff abort continue skip quit allow-empty keep-redundant-commits ff strategy-option=",
|
|
31550
|
+
revert: "+nm:sX:|no-commit mainline= signoff abort continue skip quit strategy-option= no-edit",
|
|
31551
|
+
rebase: "+qvfnX:|onto= root abort continue skip quit keep-base no-ff force-rebase autosquash no-autosquash autostash no-autostash update-refs signoff quiet verbose stat no-stat committer-date-is-author-date reset-author-date rebase-merges? no-rebase-merges empty= strategy-option= apply merge",
|
|
31552
|
+
clean: "+dfnqxXe:|dry-run force quiet exclude=",
|
|
31553
|
+
bisect: "+|term-old= term-new= no-checkout first-parent"
|
|
31554
|
+
};
|
|
31555
|
+
var JUDGE_GIT = `a judge runs git ${Object.keys(GIT_VERBS).join(" ")} with the options each documents (no abbreviations), writing only in a scratch repo; no -c, no wrapper but timeout, nice, time, command, no env but PAGER=cat, GIT_PAGER=cat, GIT_OPTIONAL_LOCKS=0, LC_*, LANG, TZ; status outside scratch needs --no-optional-locks`;
|
|
31501
31556
|
var JUDGE_VERBS = {
|
|
31502
31557
|
check: true,
|
|
31503
31558
|
dir: true,
|
|
@@ -20098,7 +20098,21 @@ var gitOutputs = (args) => {
|
|
|
20098
20098
|
if (output !== undefined)
|
|
20099
20099
|
files.push(output);
|
|
20100
20100
|
if (sub === "init")
|
|
20101
|
-
files.push(names[0] ?? "
|
|
20101
|
+
files.push(names[0] ?? "./");
|
|
20102
|
+
if (sub === "init" || sub === "clone") {
|
|
20103
|
+
const separate = valueOf(rest, /^--separate-git-dir=?(.*)$/s);
|
|
20104
|
+
if (separate !== undefined)
|
|
20105
|
+
files.push(separate);
|
|
20106
|
+
}
|
|
20107
|
+
if (sub === "worktree") {
|
|
20108
|
+
const end = rest.includes("--") ? rest.indexOf("--") : rest.length;
|
|
20109
|
+
const named = [
|
|
20110
|
+
...rest.slice(1, end).filter((arg, index, words) => !arg.startsWith("-") && !/^(?:-[bB]|--reason)$/.test(words[index - 1] ?? "")),
|
|
20111
|
+
...rest.slice(end + 1)
|
|
20112
|
+
];
|
|
20113
|
+
const count = { add: 1, move: 2, remove: 1, repair: named.length || 1 }[rest[0] ?? ""] ?? 0;
|
|
20114
|
+
files.push(...(named.length ? named : ["."]).slice(0, count));
|
|
20115
|
+
}
|
|
20102
20116
|
if (sub === "clone")
|
|
20103
20117
|
files.push(names[1] ?? names[0]?.replace(/(?:\.git)?[\\/]*$/, "").split(/[\\/:]/).at(-1) ?? ".");
|
|
20104
20118
|
if (sub === "format-patch" && !has(/^--stdout$/))
|
|
@@ -20216,6 +20230,28 @@ var MUTATING_GIT = new Set([
|
|
|
20216
20230
|
var DRY_N = new Set(["add", "clean", "rm", "mv"]);
|
|
20217
20231
|
var MUTATING_WORKIT_GIT = new Set(["commit", "branch", "stage", "unstage"]);
|
|
20218
20232
|
var DIR_TARGET = ".workit-live-target";
|
|
20233
|
+
var PLACEHOLDERS = new WeakMap;
|
|
20234
|
+
var collecting = null;
|
|
20235
|
+
var placeholderIn = (dir, name) => {
|
|
20236
|
+
const target = path29.join(dir, name);
|
|
20237
|
+
collecting?.add(target);
|
|
20238
|
+
return target;
|
|
20239
|
+
};
|
|
20240
|
+
var recording = (make) => {
|
|
20241
|
+
const outer = collecting;
|
|
20242
|
+
const found = new Set;
|
|
20243
|
+
collecting = found;
|
|
20244
|
+
try {
|
|
20245
|
+
const targets = make();
|
|
20246
|
+
PLACEHOLDERS.set(targets, found);
|
|
20247
|
+
for (const target of found)
|
|
20248
|
+
outer?.add(target);
|
|
20249
|
+
return targets;
|
|
20250
|
+
} finally {
|
|
20251
|
+
collecting = outer;
|
|
20252
|
+
}
|
|
20253
|
+
};
|
|
20254
|
+
var placeholdersOf = (targets) => PLACEHOLDERS.get(targets) ?? new Set;
|
|
20219
20255
|
var OPAQUE_TARGET = ".workit-runs-";
|
|
20220
20256
|
var UNRESOLVED_TARGET = ".workit-unresolved-target";
|
|
20221
20257
|
var OVERRIDE = "WORKIT_LIVE_SESSION=override";
|
|
@@ -20487,7 +20523,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20487
20523
|
return [unknownVarTarget(home)];
|
|
20488
20524
|
if (path29.isAbsolute(home))
|
|
20489
20525
|
return [home];
|
|
20490
|
-
return base === undefined ? [] : [
|
|
20526
|
+
return base === undefined ? [] : [resolvedUnder(base, home)];
|
|
20491
20527
|
});
|
|
20492
20528
|
const at = (file) => {
|
|
20493
20529
|
const all = atAll(file);
|
|
@@ -20719,7 +20755,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20719
20755
|
for (const file of opaque ?? [])
|
|
20720
20756
|
for (const resolved of atAll(file))
|
|
20721
20757
|
if (!quiet || !isRoot(resolved))
|
|
20722
|
-
targets.push(file === "." ? path29.
|
|
20758
|
+
targets.push(file === "." ? placeholderIn(resolved, here) : path29.basename(resolved).startsWith(OPAQUE_TARGET) ? placeholderIn(path29.dirname(resolved), path29.basename(resolved)) : resolved);
|
|
20723
20759
|
const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
|
|
20724
20760
|
const lnArgs = words.slice(ln + 1);
|
|
20725
20761
|
if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
|
|
@@ -20731,7 +20767,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20731
20767
|
const edits = editsOf(body);
|
|
20732
20768
|
if (edits === null) {
|
|
20733
20769
|
if (dir !== undefined)
|
|
20734
|
-
targets.push(
|
|
20770
|
+
targets.push(placeholderIn(dir, DIR_TARGET));
|
|
20735
20771
|
} else
|
|
20736
20772
|
for (const file of edits)
|
|
20737
20773
|
targets.push(...atAll(file));
|
|
@@ -20739,7 +20775,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20739
20775
|
for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
|
|
20740
20776
|
const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
|
|
20741
20777
|
if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
|
|
20742
|
-
targets.push(...runsIn.map((runs) =>
|
|
20778
|
+
targets.push(...runsIn.map((runs) => placeholderIn(runs, DIR_TARGET)));
|
|
20743
20779
|
}
|
|
20744
20780
|
}
|
|
20745
20781
|
return targets;
|
|
@@ -20759,10 +20795,10 @@ var workitCwd = (dir, args, resolve) => {
|
|
|
20759
20795
|
var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) => {
|
|
20760
20796
|
try {
|
|
20761
20797
|
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]] ?? ""]) : []);
|
|
20762
|
-
return [
|
|
20798
|
+
return recording(() => [
|
|
20763
20799
|
...segmentTargets(cwd, command, dialect, 0, strict, env),
|
|
20764
|
-
...gitMutationDirs(cwd, command, dialect).map((dir) =>
|
|
20765
|
-
];
|
|
20800
|
+
...gitMutationDirs(cwd, command, dialect).map((dir) => placeholderIn(dir, DIR_TARGET))
|
|
20801
|
+
]);
|
|
20766
20802
|
} catch (error) {
|
|
20767
20803
|
if (strict === "registry")
|
|
20768
20804
|
throw error;
|
|
@@ -20821,7 +20857,8 @@ var claimAll = (owner, targets, deps) => {
|
|
|
20821
20857
|
for (const target of guarded(targets))
|
|
20822
20858
|
claimLiveSession(target, owner, deps);
|
|
20823
20859
|
};
|
|
20824
|
-
var
|
|
20860
|
+
var resolvedUnder = (dir, file) => !/(?:^|[\\/])\.\.(?:[\\/]|$)/.test(file) ? path29.resolve(dir, file) : path29.isAbsolute(file) ? file : `${dir}${path29.sep}${file}`;
|
|
20861
|
+
var liveTargets = (cwd, paths) => recording(() => paths?.length ? paths.map((file) => resolvedUnder(cwd, file)) : [placeholderIn(cwd, DIR_TARGET)]);
|
|
20825
20862
|
var CONFIG_FILES = ["workspaces.json", SEAL_FILE];
|
|
20826
20863
|
var configDirs = () => [resolveConfigDir(), grantsDir()];
|
|
20827
20864
|
var globbed = (cwd, target, state, configs) => {
|
|
@@ -22336,18 +22373,48 @@ import path32 from "node:path";
|
|
|
22336
22373
|
var FANOUT_TOKEN_FILE = "workit-fanout-token";
|
|
22337
22374
|
var NONE5 = { kind: "none" };
|
|
22338
22375
|
var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
|
|
22339
|
-
var
|
|
22376
|
+
var realOf = (file) => {
|
|
22340
22377
|
let rest = "";
|
|
22341
|
-
for (let dir =
|
|
22378
|
+
for (let dir = file;; dir = path32.dirname(dir)) {
|
|
22342
22379
|
try {
|
|
22343
22380
|
return path32.join(fs21.realpathSync.native(dir), rest);
|
|
22344
22381
|
} catch {
|
|
22345
22382
|
if (path32.dirname(dir) === dir)
|
|
22346
|
-
return
|
|
22383
|
+
return file;
|
|
22347
22384
|
rest = rest ? path32.join(path32.basename(dir), rest) : path32.basename(dir);
|
|
22348
22385
|
}
|
|
22349
22386
|
}
|
|
22350
22387
|
};
|
|
22388
|
+
var canonical5 = (file, hops = { chain: 40, total: 1000 }) => {
|
|
22389
|
+
const start = path32.isAbsolute(file) ? file : `${process.cwd()}${path32.sep}${file}`;
|
|
22390
|
+
const { root } = path32.parse(start);
|
|
22391
|
+
let at = root;
|
|
22392
|
+
let missing = false;
|
|
22393
|
+
for (const part of start.slice(root.length).split(/[\\/]+/)) {
|
|
22394
|
+
if (part === "" || part === ".")
|
|
22395
|
+
continue;
|
|
22396
|
+
if (part === "..") {
|
|
22397
|
+
at = path32.dirname(at);
|
|
22398
|
+
continue;
|
|
22399
|
+
}
|
|
22400
|
+
const next = path32.join(at, part);
|
|
22401
|
+
let link = null;
|
|
22402
|
+
if (!missing)
|
|
22403
|
+
try {
|
|
22404
|
+
link = fs21.readlinkSync(next);
|
|
22405
|
+
} catch (error) {
|
|
22406
|
+
missing = error.code !== "EINVAL";
|
|
22407
|
+
}
|
|
22408
|
+
if (link === null) {
|
|
22409
|
+
at = next;
|
|
22410
|
+
hops.chain = 40;
|
|
22411
|
+
} else if (hops.chain-- > 0 && hops.total-- > 0)
|
|
22412
|
+
at = canonical5(path32.isAbsolute(link) ? link : `${at}${path32.sep}${link}`, hops);
|
|
22413
|
+
else
|
|
22414
|
+
return path32.resolve(file);
|
|
22415
|
+
}
|
|
22416
|
+
return realOf(at);
|
|
22417
|
+
};
|
|
22351
22418
|
var within = (child, parent) => {
|
|
22352
22419
|
const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
|
|
22353
22420
|
const relative = path32.relative(fold(parent), fold(child));
|
|
@@ -22357,13 +22424,8 @@ var checkoutOf2 = (file) => {
|
|
|
22357
22424
|
for (let dir = canonical5(file);; dir = path32.dirname(dir)) {
|
|
22358
22425
|
const dotGit = path32.join(dir, ".git");
|
|
22359
22426
|
if (fs21.existsSync(dotGit)) {
|
|
22360
|
-
|
|
22361
|
-
|
|
22362
|
-
const admin = /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim();
|
|
22363
|
-
return {
|
|
22364
|
-
root: dir,
|
|
22365
|
-
workit: Boolean(admin) && fs21.existsSync(path32.join(path32.resolve(dir, admin), FANOUT_TOKEN_FILE))
|
|
22366
|
-
};
|
|
22427
|
+
const admin = fs21.statSync(dotGit).isFile() ? gitDirsAt(dir, null, false)?.[0] : undefined;
|
|
22428
|
+
return { root: dir, workit: !!admin && fs21.existsSync(path32.join(admin, FANOUT_TOKEN_FILE)) };
|
|
22367
22429
|
}
|
|
22368
22430
|
if (path32.dirname(dir) === dir)
|
|
22369
22431
|
return null;
|
|
@@ -22425,16 +22487,11 @@ var hostIsolated = (cwd, agentId) => {
|
|
|
22425
22487
|
const dotGit = path32.join(checkout.root, ".git");
|
|
22426
22488
|
if (!fs21.statSync(dotGit).isFile())
|
|
22427
22489
|
return false;
|
|
22428
|
-
const
|
|
22429
|
-
if (!admin)
|
|
22430
|
-
return false;
|
|
22431
|
-
const adminDir = path32.resolve(checkout.root, admin);
|
|
22490
|
+
const [adminDir, gitDir] = gitDirsAt(checkout.root, null, false) ?? [];
|
|
22432
22491
|
const back = fs21.readFileSync(path32.join(adminDir, "gitdir"), "utf8").trim();
|
|
22433
22492
|
if (path32.relative(canonical5(path32.resolve(adminDir, back)), canonical5(dotGit)) !== "")
|
|
22434
22493
|
return false;
|
|
22435
|
-
const
|
|
22436
|
-
const gitDir = fs21.existsSync(common) ? path32.resolve(adminDir, fs21.readFileSync(common, "utf8").trim()) : adminDir;
|
|
22437
|
-
const expected = path32.join(path32.dirname(canonical5(gitDir)), ".claude", "worktrees", `agent-${agentId}`);
|
|
22494
|
+
const expected = path32.join(path32.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
|
|
22438
22495
|
return path32.relative(canonical5(expected), checkout.root) === "";
|
|
22439
22496
|
} catch {
|
|
22440
22497
|
return false;
|
|
@@ -22626,17 +22683,295 @@ var LEADS = /^(?:sudo|doas|env|command|builtin|exec|nohup|time|nice|timeout|stdb
|
|
|
22626
22683
|
var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|perl|php|eval|source|\.|workit)$/;
|
|
22627
22684
|
var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/;
|
|
22628
22685
|
var VALUED = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
|
|
22629
|
-
var commonDir = (root) =>
|
|
22630
|
-
const dotGit = path32.join(root, ".git");
|
|
22631
|
-
if (!fs21.statSync(dotGit).isFile())
|
|
22632
|
-
return canonical5(dotGit);
|
|
22633
|
-
const admin = path32.resolve(root, /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "");
|
|
22634
|
-
const common = path32.join(admin, "commondir");
|
|
22635
|
-
return canonical5(fs21.existsSync(common) ? path32.resolve(admin, fs21.readFileSync(common, "utf8").trim()) : admin);
|
|
22636
|
-
};
|
|
22686
|
+
var commonDir = (root) => gitDirsAt(root, null, false)?.[1] ?? "";
|
|
22637
22687
|
var inScratch = (real, repo) => {
|
|
22638
|
-
|
|
22639
|
-
|
|
22688
|
+
for (let dir = real;path32.dirname(dir) !== dir; dir = path32.dirname(dir)) {
|
|
22689
|
+
if (path32.basename(dir) !== SCRATCH)
|
|
22690
|
+
continue;
|
|
22691
|
+
const root = path32.dirname(dir);
|
|
22692
|
+
if (checkoutOf2(root)?.root === root && (repo === null || commonDir(root) === repo))
|
|
22693
|
+
return true;
|
|
22694
|
+
}
|
|
22695
|
+
return false;
|
|
22696
|
+
};
|
|
22697
|
+
var inGitDir = (real) => real.split(/[\\/]/).includes(".git");
|
|
22698
|
+
var SAFE_KEY = /^(?:core\.(?:repositoryformatversion|filemode|bare|logallrefupdates|ignorecase|precomposeunicode|symlinks)|user\..*|init\.defaultbranch|commit\.gpgsign|extensions\.(?:objectformat|refstorage)|branch\..*\.(?:remote|merge)|remote\..*\.fetch)$/;
|
|
22699
|
+
var literalIn = (value, repo, checkout = false) => {
|
|
22700
|
+
if (/[$`]/.test(value) || !path32.isAbsolute(value))
|
|
22701
|
+
return false;
|
|
22702
|
+
const real = canonical5(value);
|
|
22703
|
+
const root = checkout ? checkoutOf2(real)?.root : undefined;
|
|
22704
|
+
return inScratch(real, repo) || root !== undefined && (repo === null || commonDir(root) === repo);
|
|
22705
|
+
};
|
|
22706
|
+
var configEntries = (text) => {
|
|
22707
|
+
const entries = [];
|
|
22708
|
+
let section = "";
|
|
22709
|
+
for (const line of text.split(`
|
|
22710
|
+
`)) {
|
|
22711
|
+
const header = /^\s*\[\s*([\w.-]+)(?:\s+"([^"]*))?/.exec(line);
|
|
22712
|
+
const entry = /^\s*([\w-]+)\s*(?:=\s*"?(.*?)"?)?\s*$/.exec(line);
|
|
22713
|
+
if (header)
|
|
22714
|
+
section = header[2] === undefined ? header[1] : `${header[1]}.${header[2]}`;
|
|
22715
|
+
else if (entry)
|
|
22716
|
+
entries.push([`${section}.${entry[1]}`.toLowerCase(), entry[2] ?? "true"]);
|
|
22717
|
+
}
|
|
22718
|
+
return entries;
|
|
22719
|
+
};
|
|
22720
|
+
function gitDirsAt(dir, repo, scan = true) {
|
|
22721
|
+
for (let at = dir;; at = path32.dirname(at)) {
|
|
22722
|
+
const dotGit = path32.join(at, ".git");
|
|
22723
|
+
let gitDir = null;
|
|
22724
|
+
try {
|
|
22725
|
+
if (fs21.statSync(dotGit).isDirectory())
|
|
22726
|
+
gitDir = canonical5(dotGit);
|
|
22727
|
+
else {
|
|
22728
|
+
const named = /^gitdir:\s*(.+?)\s*$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1];
|
|
22729
|
+
if (!named)
|
|
22730
|
+
return null;
|
|
22731
|
+
gitDir = canonical5(path32.resolve(at, named));
|
|
22732
|
+
}
|
|
22733
|
+
} catch (error) {
|
|
22734
|
+
if (error.code !== "ENOENT")
|
|
22735
|
+
return null;
|
|
22736
|
+
if (["HEAD", "objects", "refs"].every((name) => fs21.existsSync(path32.join(at, name))))
|
|
22737
|
+
gitDir = canonical5(at);
|
|
22738
|
+
}
|
|
22739
|
+
if (gitDir !== null) {
|
|
22740
|
+
const common = path32.join(gitDir, "commondir");
|
|
22741
|
+
const shared = fs21.existsSync(common) ? canonical5(path32.resolve(gitDir, fs21.readFileSync(common, "utf8").trim())) : gitDir;
|
|
22742
|
+
const dirs = [gitDir, shared];
|
|
22743
|
+
for (const config of scan ? new Set([path32.join(gitDir, "config"), path32.join(shared, "config")]) : []) {
|
|
22744
|
+
let text = "";
|
|
22745
|
+
try {
|
|
22746
|
+
text = fs21.readFileSync(config, "utf8");
|
|
22747
|
+
} catch {
|
|
22748
|
+
continue;
|
|
22749
|
+
}
|
|
22750
|
+
for (const [key, value] of configEntries(text)) {
|
|
22751
|
+
if (key === "core.worktree")
|
|
22752
|
+
dirs.push(canonical5(path32.resolve(gitDir, value)));
|
|
22753
|
+
else if (/^remote\..*\.url$/.test(key) ? !literalIn(value, repo, true) : !SAFE_KEY.test(key))
|
|
22754
|
+
return null;
|
|
22755
|
+
}
|
|
22756
|
+
}
|
|
22757
|
+
return dirs;
|
|
22758
|
+
}
|
|
22759
|
+
if (path32.dirname(at) === at)
|
|
22760
|
+
return [];
|
|
22761
|
+
}
|
|
22762
|
+
}
|
|
22763
|
+
var DIFF_S = "psuRaWwbzU:S:G:l:M?C?B?D";
|
|
22764
|
+
var DIFF_L = "stat? numstat shortstat name-only name-status summary patch no-patch raw color? no-color word-diff? color-words? unified= ignore-all-space ignore-space-change ignore-blank-lines ignore-cr-at-eol diff-filter= find-renames? find-copies? no-renames relative? abbrev? diff-algorithm= ignore-space-at-eol word-diff-regex= full-index binary exit-code quiet minimal patience histogram src-prefix= dst-prefix= no-prefix dirstat? text check function-context no-ext-diff no-textconv output=";
|
|
22765
|
+
var LOG_S = "n:iEFPgL:";
|
|
22766
|
+
var LOG_L = "oneline format= pretty? graph decorate? no-decorate all branches? tags? remotes? since= until= after= before= author= committer= grep= all-match invert-grep regexp-ignore-case extended-regexp fixed-strings perl-regexp max-count= skip= first-parent no-merges merges reverse follow date= abbrev-commit no-abbrev-commit left-right cherry-pick cherry-mark boundary not topo-order date-order source simplify-by-decoration ancestry-path full-history notes? no-notes walk-reflogs mailmap use-mailmap";
|
|
22767
|
+
var GIT_VERBS = {
|
|
22768
|
+
log: "@d@l|@d @l",
|
|
22769
|
+
show: "@d@l|@d @l",
|
|
22770
|
+
diff: "@d|@d cached staged merge-base no-index",
|
|
22771
|
+
"diff-tree": "@drtcm|@d root stdin no-commit-id",
|
|
22772
|
+
"diff-index": "@dm|@d cached merge-base",
|
|
22773
|
+
status: "sbu?zv|short branch porcelain? long untracked-files? ignored? ignore-submodules? show-stash ahead-behind no-ahead-behind renames no-renames find-renames? column? no-column null verbose",
|
|
22774
|
+
"rev-parse": "q|verify short? abbrev-ref? symbolic symbolic-full-name show-toplevel show-prefix git-dir git-common-dir absolute-git-dir is-inside-work-tree is-inside-git-dir is-bare-repository show-cdup quiet all branches? tags? remotes? since= until= default= path-format= sq-quote",
|
|
22775
|
+
"rev-list": "@l|@l count objects? left-only right-only",
|
|
22776
|
+
"ls-files": "cdmoiskuvtzfx:X:|cached deleted modified others ignored stage unmerged killed directory no-empty-directory exclude-standard exclude= exclude-from= full-name abbrev? error-unmatch with-tree= eol deduplicate format= recurse-submodules sparse",
|
|
22777
|
+
"ls-tree": "rdtlz|long name-only name-status object-only full-name full-tree abbrev? format=",
|
|
22778
|
+
"cat-file": "tsepz|batch? batch-check? batch-all-objects follow-symlinks unordered buffer allow-unknown-type mailmap use-mailmap",
|
|
22779
|
+
blame: "L:lstfnepwbcM?C?|porcelain line-porcelain incremental root show-stats show-name show-number show-email abbrev= reverse= first-parent date= ignore-rev= ignore-revs-file= minimal contents=",
|
|
22780
|
+
describe: "|tags all long abbrev= contains always dirty? broken? match= exclude= first-parent exact-match candidates= debug",
|
|
22781
|
+
"merge-base": "a|all octopus independent is-ancestor fork-point",
|
|
22782
|
+
"for-each-ref": "|count= sort= format= color? shell perl python tcl points-at= merged? no-merged? contains? no-contains? ignore-case omit-empty exclude=",
|
|
22783
|
+
shortlog: "@lsnec|@l summary numbered email committer group= format=",
|
|
22784
|
+
"show-ref": "dsq|head verify heads tags branches hash? abbrev? quiet dereference exists",
|
|
22785
|
+
"name-rev": "|tags refs= exclude= all annotate-stdin name-only no-undefined always",
|
|
22786
|
+
grep: "aiIvnhHcEGFPlLzoWqwe:A:B:C:m:f:|cached untracked no-index no-exclude-standard exclude-standard recurse-submodules text ignore-case word-regexp invert-match line-number column count full-name extended-regexp basic-regexp fixed-strings perl-regexp files-with-matches name-only files-without-match null only-matching heading break show-function function-context max-depth= threads= and or not all-match quiet after-context= before-context= context= max-count= color? no-color",
|
|
22787
|
+
"format-patch": "@do:nNks|@d stdout output-directory= numbered no-numbered start-number= subject-prefix= root cover-letter thread? signoff attach? inline? suffix= base=",
|
|
22788
|
+
reflog: "@l|@l all expire= expire-unreachable= rewrite updateref stale-fix dry-run verbose",
|
|
22789
|
+
"count-objects": "vH|verbose human-readable",
|
|
22790
|
+
"check-ignore": "qvnz|quiet verbose stdin non-matching no-index",
|
|
22791
|
+
var: "l|",
|
|
22792
|
+
version: "|build-options",
|
|
22793
|
+
"ls-remote": "htbq|heads tags branches refs quiet exit-code get-url symref sort=",
|
|
22794
|
+
remote: "v|verbose",
|
|
22795
|
+
config: "lz|get get-all get-regexp list local name-only null type= default=",
|
|
22796
|
+
worktree: "fdqvzb:B:|force detach lock reason= orphan no-checkout checkout quiet track no-track guess-remote porcelain expire= verbose",
|
|
22797
|
+
branch: "dDmMcCfvraliu:|delete move copy force list all remotes verbose contains? merged? no-merged? points-at= show-current set-upstream-to= unset-upstream track? no-track sort= format= color? column? ignore-case create-reflog",
|
|
22798
|
+
tag: "lam:dfF:n?|list annotate message= file= delete force sort= format= contains? merged? no-merged? points-at= column? create-reflog ignore-case",
|
|
22799
|
+
init: "+qb:|quiet bare initial-branch= object-format= ref-format= shared? separate-git-dir=",
|
|
22800
|
+
add: "+AunNvf|all update intent-to-add force dry-run verbose ignore-errors ignore-removal no-all renormalize chmod= sparse",
|
|
22801
|
+
commit: "+m:aqsnF:C:ouv|message= all amend no-edit allow-empty allow-empty-message author= date= signoff no-verify quiet file= reuse-message= fixup= squash= only include dry-run no-gpg-sign untracked-files? cleanup= reset-author verbose",
|
|
22802
|
+
checkout: "+b:B:fqm|detach force orphan= quiet track? no-track merge ours theirs",
|
|
22803
|
+
switch: "+c:C:dfqm|create= force-create= detach discard-changes force orphan= quiet track? no-track merge",
|
|
22804
|
+
restore: "+s:SWq|source= staged worktree ours theirs merge quiet overlay no-overlay",
|
|
22805
|
+
reset: "+qN|soft mixed hard merge keep quiet no-refresh",
|
|
22806
|
+
rm: "+rfnq|cached force dry-run quiet ignore-unmatch",
|
|
22807
|
+
mv: "+fnkv|force dry-run verbose",
|
|
22808
|
+
merge: "+m:qvnX:|no-ff ff ff-only squash no-squash commit no-commit message= no-edit abort continue quit allow-unrelated-histories stat no-stat quiet verbose no-verify signoff strategy-option=",
|
|
22809
|
+
stash: "+m:ukqa|message= include-untracked keep-index quiet all index staged",
|
|
22810
|
+
apply: "+p:C:R3qv|check stat numstat summary index cached 3way reverse reject allow-empty exclude= include= verbose quiet whitespace= recount",
|
|
22811
|
+
am: "+skq3|signoff keep 3way quiet abort continue skip quit whitespace= reject",
|
|
22812
|
+
fetch: "+fqvptn|all depth= deepen= shallow-since= unshallow tags no-tags prune force quiet verbose dry-run update-shallow refmap=",
|
|
22813
|
+
clone: "+nqlsb:o:|bare no-checkout depth= branch= origin= single-branch no-single-branch no-tags quiet shared local no-local filter= separate-git-dir=",
|
|
22814
|
+
"cherry-pick": "+nm:sxX:|no-commit mainline= signoff abort continue skip quit allow-empty keep-redundant-commits ff strategy-option=",
|
|
22815
|
+
revert: "+nm:sX:|no-commit mainline= signoff abort continue skip quit strategy-option= no-edit",
|
|
22816
|
+
rebase: "+qvfnX:|onto= root abort continue skip quit keep-base no-ff force-rebase autosquash no-autosquash autostash no-autostash update-refs signoff quiet verbose stat no-stat committer-date-is-author-date reset-author-date rebase-merges? no-rebase-merges empty= strategy-option= apply merge",
|
|
22817
|
+
clean: "+dfnqxXe:|dry-run force quiet exclude=",
|
|
22818
|
+
bisect: "+|term-old= term-new= no-checkout first-parent"
|
|
22819
|
+
};
|
|
22820
|
+
var gitOperands = (args) => {
|
|
22821
|
+
const [verb = "", ...rest] = args;
|
|
22822
|
+
const spec = Object.hasOwn(GIT_VERBS, verb) ? GIT_VERBS[verb] : null;
|
|
22823
|
+
if (spec === null)
|
|
22824
|
+
return null;
|
|
22825
|
+
const [shorts, longs] = spec.split("|");
|
|
22826
|
+
const short = shorts.replace("@d", DIFF_S).replace("@l", LOG_S);
|
|
22827
|
+
const long = longs.replace("@d", DIFF_L).replace("@l", LOG_L).split(" ");
|
|
22828
|
+
const operands = [];
|
|
22829
|
+
for (let at = 0;at < rest.length; at++) {
|
|
22830
|
+
const arg = rest[at];
|
|
22831
|
+
if (arg === "--")
|
|
22832
|
+
return [...operands, ...rest.slice(at + 1)];
|
|
22833
|
+
if (!arg.startsWith("-") || arg === "-")
|
|
22834
|
+
operands.push(arg);
|
|
22835
|
+
else if (arg.startsWith("--")) {
|
|
22836
|
+
const [name] = arg.slice(2).split("=");
|
|
22837
|
+
const valued = arg.includes("=");
|
|
22838
|
+
if (long.includes(`${name}=`))
|
|
22839
|
+
at += valued ? 0 : 1;
|
|
22840
|
+
else if (!long.includes(`${name}?`) && (valued || !long.includes(name)))
|
|
22841
|
+
return null;
|
|
22842
|
+
} else if (!/^-\d+$/.test(arg))
|
|
22843
|
+
for (let index = 1;index < arg.length; index++) {
|
|
22844
|
+
const found = /[:?+]/.test(arg[index]) ? -1 : short.indexOf(arg[index]);
|
|
22845
|
+
if (found < 0)
|
|
22846
|
+
return null;
|
|
22847
|
+
const takes = short[found + 1];
|
|
22848
|
+
if (takes === ":" && index === arg.length - 1)
|
|
22849
|
+
at++;
|
|
22850
|
+
if (takes === ":" || takes === "?")
|
|
22851
|
+
break;
|
|
22852
|
+
}
|
|
22853
|
+
}
|
|
22854
|
+
return operands;
|
|
22855
|
+
};
|
|
22856
|
+
var gitKind = (args, local = () => true) => {
|
|
22857
|
+
const named = gitOperands(args);
|
|
22858
|
+
if (!named)
|
|
22859
|
+
return null;
|
|
22860
|
+
const [verb] = args;
|
|
22861
|
+
const [first = "", second] = named;
|
|
22862
|
+
const has = (pattern) => args.some((arg) => pattern.test(arg));
|
|
22863
|
+
switch (verb) {
|
|
22864
|
+
case "reflog":
|
|
22865
|
+
return /^(?:expire|delete)$/.test(first) ? "write" : "read";
|
|
22866
|
+
case "branch":
|
|
22867
|
+
case "tag":
|
|
22868
|
+
return leadOwnedGit(args) || named.length > 0 && !has(/^(?:-l|--list|--contains|--(?:no-)?merged|--points-at)$/) ? "write" : "read";
|
|
22869
|
+
case "config": {
|
|
22870
|
+
if (has(/^(?:-l|--list|--get-regexp)$/) || first === "list")
|
|
22871
|
+
return has(/^--local$/) ? "write" : null;
|
|
22872
|
+
if (has(/^--get/) || first === "get" || named.length === 1)
|
|
22873
|
+
return "read";
|
|
22874
|
+
const [key = "", value] = first === "set" ? named.slice(1) : named;
|
|
22875
|
+
return /^(?:user\.(?:name|email)|init\.defaultbranch)$/i.test(key) || /^commit\.gpgsign$/i.test(key) && value === "false" ? "write" : null;
|
|
22876
|
+
}
|
|
22877
|
+
case "worktree":
|
|
22878
|
+
return first === "list" ? "read" : /^(?:add|remove)$/.test(first) ? "write" : null;
|
|
22879
|
+
case "remote":
|
|
22880
|
+
return !first || first === "show" && named.length === 2 && local(second, true) ? "read" : null;
|
|
22881
|
+
case "ls-remote":
|
|
22882
|
+
return local(first || "origin", true) ? "read" : null;
|
|
22883
|
+
case "bisect":
|
|
22884
|
+
return /^(?:log|terms)$/.test(first) ? "read" : /^(?:start|good|bad|new|old|skip|reset)$/.test(first) ? "write" : null;
|
|
22885
|
+
case "blame": {
|
|
22886
|
+
const contents = args.findIndex((arg) => arg.startsWith("--contents"));
|
|
22887
|
+
const file = args[contents]?.slice(11) || args[contents + 1];
|
|
22888
|
+
return contents < 0 || local(file) ? "read" : null;
|
|
22889
|
+
}
|
|
22890
|
+
case "fetch":
|
|
22891
|
+
return !first || local(first, true) ? "write" : null;
|
|
22892
|
+
case "clone":
|
|
22893
|
+
return local(first) ? "write" : null;
|
|
22894
|
+
}
|
|
22895
|
+
return GIT_VERBS[verb].startsWith("+") ? "write" : "read";
|
|
22896
|
+
};
|
|
22897
|
+
var JUDGE_GIT = `a judge runs git ${Object.keys(GIT_VERBS).join(" ")} with the options each documents (no abbreviations), writing only in a scratch repo; no -c, no wrapper but timeout, nice, time, command, no env but PAGER=cat, GIT_PAGER=cat, GIT_OPTIONAL_LOCKS=0, LC_*, LANG, TZ; status outside scratch needs --no-optional-locks`;
|
|
22898
|
+
var remoteIn = (dir, name, repo) => {
|
|
22899
|
+
const shared = path32.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo, false)?.[1] : undefined;
|
|
22900
|
+
if (!shared)
|
|
22901
|
+
return false;
|
|
22902
|
+
const url = configEntries(fs21.readFileSync(path32.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
|
|
22903
|
+
return url !== undefined && literalIn(url, repo, true);
|
|
22904
|
+
};
|
|
22905
|
+
var judgeGit = (command, repo, depth = 0) => {
|
|
22906
|
+
const runsGit = /\bgit\b/.test(command);
|
|
22907
|
+
for (const segment of segmentsOf(command)) {
|
|
22908
|
+
const words = segment.words;
|
|
22909
|
+
let why = null;
|
|
22910
|
+
let at = 0;
|
|
22911
|
+
while (/^(?:if|then|elif|else|do|while|until|!|\{|\()$/.test(words[at] ?? ""))
|
|
22912
|
+
at++;
|
|
22913
|
+
const lead = [];
|
|
22914
|
+
while (/^\w+\+?=/.test(words[at] ?? ""))
|
|
22915
|
+
lead.push(words[at++]);
|
|
22916
|
+
const name = path32.basename(words[at] ?? "");
|
|
22917
|
+
let start = words.findIndex((word) => /(?:^|[\\/])git(?:\.exe)?(?:=|$)/.test(word));
|
|
22918
|
+
if (start > at) {
|
|
22919
|
+
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] ?? ""))
|
|
22920
|
+
start = -1;
|
|
22921
|
+
else if (!/^(?:timeout|nice|time|command)$/.test(name) || words.slice(at + 1, start).some((word) => !/^(?:-[\w-]+|\d[\w.]*)$/.test(word)))
|
|
22922
|
+
why = `\`${name}\` runs git`;
|
|
22923
|
+
}
|
|
22924
|
+
if (start >= 0 && words[start].includes("="))
|
|
22925
|
+
why = "git is redefined";
|
|
22926
|
+
const run = words[start] ?? "";
|
|
22927
|
+
if (run.includes("/") && (!path32.isAbsolute(run) || literalIn(run, repo, true)))
|
|
22928
|
+
why ??= `\`${run}\` is not the system git`;
|
|
22929
|
+
if (segment.expands?.includes(at) && name !== "[" || /\{[^}]*,/.test(words[at] ?? ""))
|
|
22930
|
+
why = "the command's name is expanded by the shell";
|
|
22931
|
+
if (start >= 0 && (segment.expands?.length || words.some((word) => /\{[^}]*(?:,|\.\.)[^}]*\}|^~/.test(word))))
|
|
22932
|
+
why ??= "a word in this git command is expanded by the shell: spell it as a literal";
|
|
22933
|
+
if (/^(?:export|declare|local|readonly|typeset)$/.test(name))
|
|
22934
|
+
lead.push(...words.slice(at + 1).filter((word) => /^\w+\+?=/.test(word)));
|
|
22935
|
+
for (const word of runsGit ? lead : lead.filter((set) => /^(?:BASH_)?ENV=/.test(set)))
|
|
22936
|
+
if (!/^(?:(?:GIT_)?PAGER=cat|GIT_OPTIONAL_LOCKS=0|(?:LC_\w+|LANG|TZ)=[^$`]*)$/.test(word))
|
|
22937
|
+
why ??= `\`${word}\` is not allowed`;
|
|
22938
|
+
let index = start < 0 ? words.length : start + 1;
|
|
22939
|
+
let dir = "";
|
|
22940
|
+
let unlocked = lead.includes("GIT_OPTIONAL_LOCKS=0");
|
|
22941
|
+
for (;!why && words[index]?.startsWith("-") && words[index] !== "--version"; index++) {
|
|
22942
|
+
const word = words[index];
|
|
22943
|
+
const flag = /^--(git-dir|work-tree)(?:=([\s\S]*))?$/.exec(word);
|
|
22944
|
+
const value = flag?.[2] ?? (/^(?:-C|--git-dir|--work-tree)$/.test(word) ? words[++index] : "");
|
|
22945
|
+
if (word === "-C")
|
|
22946
|
+
dir = value;
|
|
22947
|
+
unlocked ||= word === "--no-optional-locks";
|
|
22948
|
+
if (flag ? !literalIn(value, repo) : !/^(?:-C|-P|--no-pager|--no-optional-locks)$/.test(word))
|
|
22949
|
+
why = `\`${word}\` is not allowed`;
|
|
22950
|
+
}
|
|
22951
|
+
const args = words[index] === "--version" ? ["version"] : words.slice(index);
|
|
22952
|
+
if (!why && start >= 0) {
|
|
22953
|
+
const local = (source, remote) => remote && /^[\w-][\w.-]*$/.test(source) ? remoteIn(dir, source, repo) : literalIn(source, repo, true);
|
|
22954
|
+
if (!gitKind(args, local))
|
|
22955
|
+
why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
|
|
22956
|
+
else if (args[0] === "status" && !unlocked) {
|
|
22957
|
+
const dirs = path32.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo) : null;
|
|
22958
|
+
if (!dirs?.length || !dirs.every((gitDir) => inScratch(gitDir, repo)))
|
|
22959
|
+
why = "`git status` refreshes the index outside scratch: add --no-optional-locks";
|
|
22960
|
+
}
|
|
22961
|
+
}
|
|
22962
|
+
const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path32.basename(word)));
|
|
22963
|
+
const scripts = [
|
|
22964
|
+
...words.filter((_, after) => shell >= 0 && after > shell && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(words[after - 1])),
|
|
22965
|
+
...shell < 0 ? [] : segment.stdin ?? []
|
|
22966
|
+
];
|
|
22967
|
+
if (shell > at && scripts.some((script) => /git/.test(script)) && (!/^(?:timeout|nice|time|command)$/.test(name) || words.slice(at + 1, shell).some((word) => !/^(?:-[\w-]+|\d[\w.]*)$/.test(word))))
|
|
22968
|
+
why ??= `\`${name}\` runs git`;
|
|
22969
|
+
for (const script of [...segment.subs ?? [], ...scripts])
|
|
22970
|
+
why ??= depth < 4 ? judgeGit(script, repo, depth + 1) : "scripts nest too deep for Workit to read";
|
|
22971
|
+
if (why)
|
|
22972
|
+
return why;
|
|
22973
|
+
}
|
|
22974
|
+
return null;
|
|
22640
22975
|
};
|
|
22641
22976
|
var JUDGE_VERBS = {
|
|
22642
22977
|
check: true,
|
|
@@ -22787,7 +23122,7 @@ var judgeDeny = (input, what, target) => {
|
|
|
22787
23122
|
unblock
|
|
22788
23123
|
};
|
|
22789
23124
|
};
|
|
22790
|
-
function confineJudge(input, targets) {
|
|
23125
|
+
function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
|
|
22791
23126
|
try {
|
|
22792
23127
|
if (!input.session.agentId)
|
|
22793
23128
|
return NONE5;
|
|
@@ -22797,7 +23132,12 @@ function confineJudge(input, targets) {
|
|
|
22797
23132
|
const resolved = path32.resolve(target);
|
|
22798
23133
|
if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
|
|
22799
23134
|
return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
|
|
22800
|
-
|
|
23135
|
+
const real = canonical5(target);
|
|
23136
|
+
const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path32.basename(target));
|
|
23137
|
+
const gitDirs = runsGit ? gitDirsAt(path32.dirname(real), repo) : [];
|
|
23138
|
+
if (gitDirs === null)
|
|
23139
|
+
return judgeDeny(input, `git in ${shown(target)} uses a git dir or config Workit cannot check`);
|
|
23140
|
+
if (runsGit ? gitDirs.length > 0 ? gitDirs.every((dir) => inScratch(dir, repo)) : inScratch(real, repo) : inScratch(real, repo) && !inGitDir(real))
|
|
22801
23141
|
continue;
|
|
22802
23142
|
const runner = runnerAt(target);
|
|
22803
23143
|
return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`, target);
|
|
@@ -22818,21 +23158,31 @@ function confineJudgeShell(input, command, dialect = "posix") {
|
|
|
22818
23158
|
} catch {
|
|
22819
23159
|
refused = "Workit cannot read this command: split it into simpler ones";
|
|
22820
23160
|
}
|
|
23161
|
+
if (!refused && dialect === "posix") {
|
|
23162
|
+
const judged = checkoutOf2(input.cwd);
|
|
23163
|
+
try {
|
|
23164
|
+
const why = judgeGit(command, judged ? commonDir(judged.root) : null);
|
|
23165
|
+
if (why)
|
|
23166
|
+
refused = `${why}: ${JUDGE_GIT}`;
|
|
23167
|
+
} catch {
|
|
23168
|
+
refused = "Workit cannot read this command: split it into simpler ones";
|
|
23169
|
+
}
|
|
23170
|
+
}
|
|
22821
23171
|
if (refused)
|
|
22822
23172
|
return judgeDeny(input, refused);
|
|
22823
23173
|
if (dialect === "posix" && substitutingHeredoc(command))
|
|
22824
23174
|
return judgeDeny(input, "an unquoted heredoc runs the `$(…)` or backtick command in its body: quote the delimiter (<<'EOF')");
|
|
22825
23175
|
let git = [];
|
|
22826
23176
|
try {
|
|
22827
|
-
git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args)) ? [
|
|
23177
|
+
git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args) || gitKind(args) === "write" && !/^(?:init|clone)$/.test(args[0])) ? [
|
|
22828
23178
|
path32.join(dir === undefined ? UNKNOWN_DIR : path32.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
|
|
22829
23179
|
] : []);
|
|
22830
23180
|
} catch {}
|
|
22831
|
-
|
|
22832
|
-
|
|
22833
|
-
...fed.
|
|
22834
|
-
|
|
22835
|
-
]);
|
|
23181
|
+
const lists = [
|
|
23182
|
+
shellMutationTargets(input.cwd, command, dialect, true),
|
|
23183
|
+
...fed.map((body) => shellMutationTargets(input.cwd, body, "posix", true))
|
|
23184
|
+
];
|
|
23185
|
+
return confineJudge(input, [...lists.flat(), ...git], new Set([...git, ...lists.flatMap((list) => [...placeholdersOf(list)])]));
|
|
22836
23186
|
} catch {
|
|
22837
23187
|
return NONE5;
|
|
22838
23188
|
}
|
package/dist/workit-hook.js
CHANGED
|
@@ -98,7 +98,7 @@ if (quiet) {
|
|
|
98
98
|
`);
|
|
99
99
|
} else {
|
|
100
100
|
try {
|
|
101
|
-
const { runCodexHook } = await import("./workit-hook-
|
|
101
|
+
const { runCodexHook } = await import("./workit-hook-2zdknydg.js");
|
|
102
102
|
await runCodexHook([payload]);
|
|
103
103
|
} catch (error) {
|
|
104
104
|
const { answerRuntimeFailure } = await import("./workit-hook-9k8dtngs.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/codex",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.4",
|
|
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.4.
|
|
45
|
-
"@workit-dev/mcp": "^2.4.
|
|
44
|
+
"@workit-dev/core": "^2.4.4",
|
|
45
|
+
"@workit-dev/mcp": "^2.4.4"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=24"
|