@workit-dev/codex 2.4.3 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "2.4.3",
3
+ "version": "2.5.0",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -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"]);
@@ -30859,6 +30860,17 @@ var writeTargets = (input) => {
30859
30860
  var REQUEST_TTL_MS = 30 * 60000;
30860
30861
  var GRANT_TTL_MS = 15 * 60000;
30861
30862
  var ASKING_HOSTS = new Set(["claude_code", "pi"]);
30863
+ var INLINE_ASK_TTL_MS = 2 * 60000;
30864
+
30865
+ // packages/workit-core/src/approvals/youtrack-ask.ts
30866
+ var TIME = "markdown file minutes text date";
30867
+ var FLAGS = {
30868
+ note: TIME,
30869
+ time: TIME,
30870
+ meeting: TIME,
30871
+ update: `${TIME} attach state command`,
30872
+ create: "project summary description file attach command"
30873
+ };
30862
30874
 
30863
30875
  // packages/workit-core/src/hooks/hosts/claude-code.ts
30864
30876
  var CLAUDE_CODE_DESCRIPTOR = {
@@ -30967,7 +30979,7 @@ var CONTEXT_EVENTS = new Set([
30967
30979
  "PreToolUse",
30968
30980
  "PostToolUse"
30969
30981
  ]);
30970
- var ASKING_MODES = new Set(["default", "acceptEdits", "plan"]);
30982
+ var ASKING_MODES = new Set(["default", "acceptEdits", "plan", "auto"]);
30971
30983
 
30972
30984
  // packages/workit-core/src/hooks/hosts/codex.ts
30973
30985
  function detectCodexSurface(env) {
@@ -31150,7 +31162,8 @@ var protocolEvent = (input) => {
31150
31162
  kind: "write.pre",
31151
31163
  tool: input.tool_name,
31152
31164
  paths: writeTargets(input.tool_input),
31153
- toolUseId
31165
+ toolUseId,
31166
+ text: JSON.stringify(input.tool_input)
31154
31167
  };
31155
31168
  return { kind: "tool.pre", tool: input.tool_name, toolUseId };
31156
31169
  }
@@ -31498,6 +31511,60 @@ var MUTATING_REMOTE = new Set([
31498
31511
  "set-branches",
31499
31512
  "prune"
31500
31513
  ]);
31514
+ var GIT_VERBS = {
31515
+ log: "@d@l|@d @l",
31516
+ show: "@d@l|@d @l",
31517
+ diff: "@d|@d cached staged merge-base no-index",
31518
+ "diff-tree": "@drtcm|@d root stdin no-commit-id",
31519
+ "diff-index": "@dm|@d cached merge-base",
31520
+ 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",
31521
+ "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",
31522
+ "rev-list": "@l|@l count objects? left-only right-only",
31523
+ "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",
31524
+ "ls-tree": "rdtlz|long name-only name-status object-only full-name full-tree abbrev? format=",
31525
+ "cat-file": "tsepz|batch? batch-check? batch-all-objects follow-symlinks unordered buffer allow-unknown-type mailmap use-mailmap",
31526
+ 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=",
31527
+ describe: "|tags all long abbrev= contains always dirty? broken? match= exclude= first-parent exact-match candidates= debug",
31528
+ "merge-base": "a|all octopus independent is-ancestor fork-point",
31529
+ "for-each-ref": "|count= sort= format= color? shell perl python tcl points-at= merged? no-merged? contains? no-contains? ignore-case omit-empty exclude=",
31530
+ shortlog: "@lsnec|@l summary numbered email committer group= format=",
31531
+ "show-ref": "dsq|head verify heads tags branches hash? abbrev? quiet dereference exists",
31532
+ "name-rev": "|tags refs= exclude= all annotate-stdin name-only no-undefined always",
31533
+ 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",
31534
+ "format-patch": "@do:nNks|@d stdout output-directory= numbered no-numbered start-number= subject-prefix= root cover-letter thread? signoff attach? inline? suffix= base=",
31535
+ reflog: "@l|@l all expire= expire-unreachable= rewrite updateref stale-fix dry-run verbose",
31536
+ "count-objects": "vH|verbose human-readable",
31537
+ "check-ignore": "qvnz|quiet verbose stdin non-matching no-index",
31538
+ var: "l|",
31539
+ version: "|build-options",
31540
+ "ls-remote": "htbq|heads tags branches refs quiet exit-code get-url symref sort=",
31541
+ remote: "v|verbose",
31542
+ config: "lz|get get-all get-regexp list local name-only null type= default=",
31543
+ worktree: "fdqvzb:B:|force detach lock reason= orphan no-checkout checkout quiet track no-track guess-remote porcelain expire= verbose",
31544
+ 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",
31545
+ tag: "lam:dfF:n?|list annotate message= file= delete force sort= format= contains? merged? no-merged? points-at= column? create-reflog ignore-case",
31546
+ init: "+qb:|quiet bare initial-branch= object-format= ref-format= shared? separate-git-dir=",
31547
+ add: "+AunNvf|all update intent-to-add force dry-run verbose ignore-errors ignore-removal no-all renormalize chmod= sparse",
31548
+ 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",
31549
+ checkout: "+b:B:fqm|detach force orphan= quiet track? no-track merge ours theirs",
31550
+ switch: "+c:C:dfqm|create= force-create= detach discard-changes force orphan= quiet track? no-track merge",
31551
+ restore: "+s:SWq|source= staged worktree ours theirs merge quiet overlay no-overlay",
31552
+ reset: "+qN|soft mixed hard merge keep quiet no-refresh",
31553
+ rm: "+rfnq|cached force dry-run quiet ignore-unmatch",
31554
+ mv: "+fnkv|force dry-run verbose",
31555
+ 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=",
31556
+ stash: "+m:ukqa|message= include-untracked keep-index quiet all index staged",
31557
+ apply: "+p:C:R3qv|check stat numstat summary index cached 3way reverse reject allow-empty exclude= include= verbose quiet whitespace= recount",
31558
+ am: "+skq3|signoff keep 3way quiet abort continue skip quit whitespace= reject",
31559
+ fetch: "+fqvptn|all depth= deepen= shallow-since= unshallow tags no-tags prune force quiet verbose dry-run update-shallow refmap=",
31560
+ 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=",
31561
+ "cherry-pick": "+nm:sxX:|no-commit mainline= signoff abort continue skip quit allow-empty keep-redundant-commits ff strategy-option=",
31562
+ revert: "+nm:sX:|no-commit mainline= signoff abort continue skip quit strategy-option= no-edit",
31563
+ 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",
31564
+ clean: "+dfnqxXe:|dry-run force quiet exclude=",
31565
+ bisect: "+|term-old= term-new= no-checkout first-parent"
31566
+ };
31567
+ 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
31568
  var JUDGE_VERBS = {
31502
31569
  check: true,
31503
31570
  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 ? [] : [path29.resolve(base, home)];
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.join(resolved, here) : resolved);
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(path29.join(dir, DIR_TARGET));
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) => path29.join(runs, DIR_TARGET)));
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) => path29.join(dir, DIR_TARGET))
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 liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path29.resolve(cwd, file)) : [path29.join(cwd, DIR_TARGET)];
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) => {
@@ -21652,6 +21689,9 @@ var GRANT_TTL_MS = 15 * 60000;
21652
21689
  var ID_PATTERN = /^ap_[a-z2-7]{8}$/u;
21653
21690
  var isApprovalId = (word) => ID_PATTERN.test(word);
21654
21691
  var ASKING_HOSTS = new Set(["claude_code", "pi"]);
21692
+ var INLINE_ASK_TTL_MS = 2 * 60000;
21693
+ var namesTicket = (text) => /WORKIT_APPROVAL_(?:TICKET|UNASKED)/u.test(text.replace(/['"\\]/gu, ""));
21694
+ var TICKET_DENY = "Only the host's prompt adds an approval ticket.";
21655
21695
 
21656
21696
  // packages/workit-core/src/approvals/call.ts
21657
21697
  var isWorkitWord2 = (word) => /^(?:.*[\\/])?workit(?:-cli)?$/u.test(word);
@@ -21694,6 +21734,16 @@ var approveCallIn = (command, dialect = "posix") => {
21694
21734
  };
21695
21735
  var approveCallDeny = (fix) => `Run \`${fix}\` as its own call: no chain, pipe, substitution, leading cd, env prefix or redirect around it, so the host can show the request and record the user's answer.`;
21696
21736
 
21737
+ // packages/workit-core/src/approvals/youtrack-ask.ts
21738
+ var TIME = "markdown file minutes text date";
21739
+ var FLAGS = {
21740
+ note: TIME,
21741
+ time: TIME,
21742
+ meeting: TIME,
21743
+ update: `${TIME} attach state command`,
21744
+ create: "project summary description file attach command"
21745
+ };
21746
+
21697
21747
  // packages/workit-core/src/hooks/hosts/claude-code.ts
21698
21748
  var CLAUDE_CODE_DESCRIPTOR = {
21699
21749
  host: "claude_code",
@@ -21801,7 +21851,7 @@ var CONTEXT_EVENTS = new Set([
21801
21851
  "PreToolUse",
21802
21852
  "PostToolUse"
21803
21853
  ]);
21804
- var ASKING_MODES = new Set(["default", "acceptEdits", "plan"]);
21854
+ var ASKING_MODES = new Set(["default", "acceptEdits", "plan", "auto"]);
21805
21855
 
21806
21856
  // packages/workit-core/src/hooks/hosts/codex.ts
21807
21857
  function detectCodexSurface(env) {
@@ -21984,7 +22034,8 @@ var protocolEvent = (input) => {
21984
22034
  kind: "write.pre",
21985
22035
  tool: input.tool_name,
21986
22036
  paths: writeTargets(input.tool_input),
21987
- toolUseId
22037
+ toolUseId,
22038
+ text: JSON.stringify(input.tool_input)
21988
22039
  };
21989
22040
  return { kind: "tool.pre", tool: input.tool_name, toolUseId };
21990
22041
  }
@@ -22336,18 +22387,48 @@ import path32 from "node:path";
22336
22387
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
22337
22388
  var NONE5 = { kind: "none" };
22338
22389
  var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
22339
- var canonical5 = (file) => {
22390
+ var realOf = (file) => {
22340
22391
  let rest = "";
22341
- for (let dir = path32.resolve(file);; dir = path32.dirname(dir)) {
22392
+ for (let dir = file;; dir = path32.dirname(dir)) {
22342
22393
  try {
22343
22394
  return path32.join(fs21.realpathSync.native(dir), rest);
22344
22395
  } catch {
22345
22396
  if (path32.dirname(dir) === dir)
22346
- return path32.resolve(file);
22397
+ return file;
22347
22398
  rest = rest ? path32.join(path32.basename(dir), rest) : path32.basename(dir);
22348
22399
  }
22349
22400
  }
22350
22401
  };
22402
+ var canonical5 = (file, hops = { chain: 40, total: 1000 }) => {
22403
+ const start = path32.isAbsolute(file) ? file : `${process.cwd()}${path32.sep}${file}`;
22404
+ const { root } = path32.parse(start);
22405
+ let at = root;
22406
+ let missing = false;
22407
+ for (const part of start.slice(root.length).split(/[\\/]+/)) {
22408
+ if (part === "" || part === ".")
22409
+ continue;
22410
+ if (part === "..") {
22411
+ at = path32.dirname(at);
22412
+ continue;
22413
+ }
22414
+ const next = path32.join(at, part);
22415
+ let link = null;
22416
+ if (!missing)
22417
+ try {
22418
+ link = fs21.readlinkSync(next);
22419
+ } catch (error) {
22420
+ missing = error.code !== "EINVAL";
22421
+ }
22422
+ if (link === null) {
22423
+ at = next;
22424
+ hops.chain = 40;
22425
+ } else if (hops.chain-- > 0 && hops.total-- > 0)
22426
+ at = canonical5(path32.isAbsolute(link) ? link : `${at}${path32.sep}${link}`, hops);
22427
+ else
22428
+ return path32.resolve(file);
22429
+ }
22430
+ return realOf(at);
22431
+ };
22351
22432
  var within = (child, parent) => {
22352
22433
  const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
22353
22434
  const relative = path32.relative(fold(parent), fold(child));
@@ -22357,13 +22438,8 @@ var checkoutOf2 = (file) => {
22357
22438
  for (let dir = canonical5(file);; dir = path32.dirname(dir)) {
22358
22439
  const dotGit = path32.join(dir, ".git");
22359
22440
  if (fs21.existsSync(dotGit)) {
22360
- if (!fs21.statSync(dotGit).isFile())
22361
- return { root: dir, workit: false };
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
- };
22441
+ const admin = fs21.statSync(dotGit).isFile() ? gitDirsAt(dir, null, false)?.[0] : undefined;
22442
+ return { root: dir, workit: !!admin && fs21.existsSync(path32.join(admin, FANOUT_TOKEN_FILE)) };
22367
22443
  }
22368
22444
  if (path32.dirname(dir) === dir)
22369
22445
  return null;
@@ -22425,16 +22501,11 @@ var hostIsolated = (cwd, agentId) => {
22425
22501
  const dotGit = path32.join(checkout.root, ".git");
22426
22502
  if (!fs21.statSync(dotGit).isFile())
22427
22503
  return false;
22428
- const admin = /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim();
22429
- if (!admin)
22430
- return false;
22431
- const adminDir = path32.resolve(checkout.root, admin);
22504
+ const [adminDir, gitDir] = gitDirsAt(checkout.root, null, false) ?? [];
22432
22505
  const back = fs21.readFileSync(path32.join(adminDir, "gitdir"), "utf8").trim();
22433
22506
  if (path32.relative(canonical5(path32.resolve(adminDir, back)), canonical5(dotGit)) !== "")
22434
22507
  return false;
22435
- const common = path32.join(adminDir, "commondir");
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}`);
22508
+ const expected = path32.join(path32.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
22438
22509
  return path32.relative(canonical5(expected), checkout.root) === "";
22439
22510
  } catch {
22440
22511
  return false;
@@ -22626,17 +22697,295 @@ var LEADS = /^(?:sudo|doas|env|command|builtin|exec|nohup|time|nice|timeout|stdb
22626
22697
  var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|perl|php|eval|source|\.|workit)$/;
22627
22698
  var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/;
22628
22699
  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
- };
22700
+ var commonDir = (root) => gitDirsAt(root, null, false)?.[1] ?? "";
22637
22701
  var inScratch = (real, repo) => {
22638
- const checkout = checkoutOf2(real);
22639
- return checkout !== null && within(real, path32.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
22702
+ for (let dir = real;path32.dirname(dir) !== dir; dir = path32.dirname(dir)) {
22703
+ if (path32.basename(dir) !== SCRATCH)
22704
+ continue;
22705
+ const root = path32.dirname(dir);
22706
+ if (checkoutOf2(root)?.root === root && (repo === null || commonDir(root) === repo))
22707
+ return true;
22708
+ }
22709
+ return false;
22710
+ };
22711
+ var inGitDir = (real) => real.split(/[\\/]/).includes(".git");
22712
+ var SAFE_KEY = /^(?:core\.(?:repositoryformatversion|filemode|bare|logallrefupdates|ignorecase|precomposeunicode|symlinks)|user\..*|init\.defaultbranch|commit\.gpgsign|extensions\.(?:objectformat|refstorage)|branch\..*\.(?:remote|merge)|remote\..*\.fetch)$/;
22713
+ var literalIn = (value, repo, checkout = false) => {
22714
+ if (/[$`]/.test(value) || !path32.isAbsolute(value))
22715
+ return false;
22716
+ const real = canonical5(value);
22717
+ const root = checkout ? checkoutOf2(real)?.root : undefined;
22718
+ return inScratch(real, repo) || root !== undefined && (repo === null || commonDir(root) === repo);
22719
+ };
22720
+ var configEntries = (text) => {
22721
+ const entries = [];
22722
+ let section = "";
22723
+ for (const line of text.split(`
22724
+ `)) {
22725
+ const header = /^\s*\[\s*([\w.-]+)(?:\s+"([^"]*))?/.exec(line);
22726
+ const entry = /^\s*([\w-]+)\s*(?:=\s*"?(.*?)"?)?\s*$/.exec(line);
22727
+ if (header)
22728
+ section = header[2] === undefined ? header[1] : `${header[1]}.${header[2]}`;
22729
+ else if (entry)
22730
+ entries.push([`${section}.${entry[1]}`.toLowerCase(), entry[2] ?? "true"]);
22731
+ }
22732
+ return entries;
22733
+ };
22734
+ function gitDirsAt(dir, repo, scan = true) {
22735
+ for (let at = dir;; at = path32.dirname(at)) {
22736
+ const dotGit = path32.join(at, ".git");
22737
+ let gitDir = null;
22738
+ try {
22739
+ if (fs21.statSync(dotGit).isDirectory())
22740
+ gitDir = canonical5(dotGit);
22741
+ else {
22742
+ const named = /^gitdir:\s*(.+?)\s*$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1];
22743
+ if (!named)
22744
+ return null;
22745
+ gitDir = canonical5(path32.resolve(at, named));
22746
+ }
22747
+ } catch (error) {
22748
+ if (error.code !== "ENOENT")
22749
+ return null;
22750
+ if (["HEAD", "objects", "refs"].every((name) => fs21.existsSync(path32.join(at, name))))
22751
+ gitDir = canonical5(at);
22752
+ }
22753
+ if (gitDir !== null) {
22754
+ const common = path32.join(gitDir, "commondir");
22755
+ const shared = fs21.existsSync(common) ? canonical5(path32.resolve(gitDir, fs21.readFileSync(common, "utf8").trim())) : gitDir;
22756
+ const dirs = [gitDir, shared];
22757
+ for (const config of scan ? new Set([path32.join(gitDir, "config"), path32.join(shared, "config")]) : []) {
22758
+ let text = "";
22759
+ try {
22760
+ text = fs21.readFileSync(config, "utf8");
22761
+ } catch {
22762
+ continue;
22763
+ }
22764
+ for (const [key, value] of configEntries(text)) {
22765
+ if (key === "core.worktree")
22766
+ dirs.push(canonical5(path32.resolve(gitDir, value)));
22767
+ else if (/^remote\..*\.url$/.test(key) ? !literalIn(value, repo, true) : !SAFE_KEY.test(key))
22768
+ return null;
22769
+ }
22770
+ }
22771
+ return dirs;
22772
+ }
22773
+ if (path32.dirname(at) === at)
22774
+ return [];
22775
+ }
22776
+ }
22777
+ var DIFF_S = "psuRaWwbzU:S:G:l:M?C?B?D";
22778
+ 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=";
22779
+ var LOG_S = "n:iEFPgL:";
22780
+ 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";
22781
+ var GIT_VERBS = {
22782
+ log: "@d@l|@d @l",
22783
+ show: "@d@l|@d @l",
22784
+ diff: "@d|@d cached staged merge-base no-index",
22785
+ "diff-tree": "@drtcm|@d root stdin no-commit-id",
22786
+ "diff-index": "@dm|@d cached merge-base",
22787
+ 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",
22788
+ "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",
22789
+ "rev-list": "@l|@l count objects? left-only right-only",
22790
+ "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",
22791
+ "ls-tree": "rdtlz|long name-only name-status object-only full-name full-tree abbrev? format=",
22792
+ "cat-file": "tsepz|batch? batch-check? batch-all-objects follow-symlinks unordered buffer allow-unknown-type mailmap use-mailmap",
22793
+ 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=",
22794
+ describe: "|tags all long abbrev= contains always dirty? broken? match= exclude= first-parent exact-match candidates= debug",
22795
+ "merge-base": "a|all octopus independent is-ancestor fork-point",
22796
+ "for-each-ref": "|count= sort= format= color? shell perl python tcl points-at= merged? no-merged? contains? no-contains? ignore-case omit-empty exclude=",
22797
+ shortlog: "@lsnec|@l summary numbered email committer group= format=",
22798
+ "show-ref": "dsq|head verify heads tags branches hash? abbrev? quiet dereference exists",
22799
+ "name-rev": "|tags refs= exclude= all annotate-stdin name-only no-undefined always",
22800
+ 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",
22801
+ "format-patch": "@do:nNks|@d stdout output-directory= numbered no-numbered start-number= subject-prefix= root cover-letter thread? signoff attach? inline? suffix= base=",
22802
+ reflog: "@l|@l all expire= expire-unreachable= rewrite updateref stale-fix dry-run verbose",
22803
+ "count-objects": "vH|verbose human-readable",
22804
+ "check-ignore": "qvnz|quiet verbose stdin non-matching no-index",
22805
+ var: "l|",
22806
+ version: "|build-options",
22807
+ "ls-remote": "htbq|heads tags branches refs quiet exit-code get-url symref sort=",
22808
+ remote: "v|verbose",
22809
+ config: "lz|get get-all get-regexp list local name-only null type= default=",
22810
+ worktree: "fdqvzb:B:|force detach lock reason= orphan no-checkout checkout quiet track no-track guess-remote porcelain expire= verbose",
22811
+ 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",
22812
+ tag: "lam:dfF:n?|list annotate message= file= delete force sort= format= contains? merged? no-merged? points-at= column? create-reflog ignore-case",
22813
+ init: "+qb:|quiet bare initial-branch= object-format= ref-format= shared? separate-git-dir=",
22814
+ add: "+AunNvf|all update intent-to-add force dry-run verbose ignore-errors ignore-removal no-all renormalize chmod= sparse",
22815
+ 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",
22816
+ checkout: "+b:B:fqm|detach force orphan= quiet track? no-track merge ours theirs",
22817
+ switch: "+c:C:dfqm|create= force-create= detach discard-changes force orphan= quiet track? no-track merge",
22818
+ restore: "+s:SWq|source= staged worktree ours theirs merge quiet overlay no-overlay",
22819
+ reset: "+qN|soft mixed hard merge keep quiet no-refresh",
22820
+ rm: "+rfnq|cached force dry-run quiet ignore-unmatch",
22821
+ mv: "+fnkv|force dry-run verbose",
22822
+ 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=",
22823
+ stash: "+m:ukqa|message= include-untracked keep-index quiet all index staged",
22824
+ apply: "+p:C:R3qv|check stat numstat summary index cached 3way reverse reject allow-empty exclude= include= verbose quiet whitespace= recount",
22825
+ am: "+skq3|signoff keep 3way quiet abort continue skip quit whitespace= reject",
22826
+ fetch: "+fqvptn|all depth= deepen= shallow-since= unshallow tags no-tags prune force quiet verbose dry-run update-shallow refmap=",
22827
+ 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=",
22828
+ "cherry-pick": "+nm:sxX:|no-commit mainline= signoff abort continue skip quit allow-empty keep-redundant-commits ff strategy-option=",
22829
+ revert: "+nm:sX:|no-commit mainline= signoff abort continue skip quit strategy-option= no-edit",
22830
+ 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",
22831
+ clean: "+dfnqxXe:|dry-run force quiet exclude=",
22832
+ bisect: "+|term-old= term-new= no-checkout first-parent"
22833
+ };
22834
+ var gitOperands = (args) => {
22835
+ const [verb = "", ...rest] = args;
22836
+ const spec = Object.hasOwn(GIT_VERBS, verb) ? GIT_VERBS[verb] : null;
22837
+ if (spec === null)
22838
+ return null;
22839
+ const [shorts, longs] = spec.split("|");
22840
+ const short = shorts.replace("@d", DIFF_S).replace("@l", LOG_S);
22841
+ const long = longs.replace("@d", DIFF_L).replace("@l", LOG_L).split(" ");
22842
+ const operands = [];
22843
+ for (let at = 0;at < rest.length; at++) {
22844
+ const arg = rest[at];
22845
+ if (arg === "--")
22846
+ return [...operands, ...rest.slice(at + 1)];
22847
+ if (!arg.startsWith("-") || arg === "-")
22848
+ operands.push(arg);
22849
+ else if (arg.startsWith("--")) {
22850
+ const [name] = arg.slice(2).split("=");
22851
+ const valued = arg.includes("=");
22852
+ if (long.includes(`${name}=`))
22853
+ at += valued ? 0 : 1;
22854
+ else if (!long.includes(`${name}?`) && (valued || !long.includes(name)))
22855
+ return null;
22856
+ } else if (!/^-\d+$/.test(arg))
22857
+ for (let index = 1;index < arg.length; index++) {
22858
+ const found = /[:?+]/.test(arg[index]) ? -1 : short.indexOf(arg[index]);
22859
+ if (found < 0)
22860
+ return null;
22861
+ const takes = short[found + 1];
22862
+ if (takes === ":" && index === arg.length - 1)
22863
+ at++;
22864
+ if (takes === ":" || takes === "?")
22865
+ break;
22866
+ }
22867
+ }
22868
+ return operands;
22869
+ };
22870
+ var gitKind = (args, local = () => true) => {
22871
+ const named = gitOperands(args);
22872
+ if (!named)
22873
+ return null;
22874
+ const [verb] = args;
22875
+ const [first = "", second] = named;
22876
+ const has = (pattern) => args.some((arg) => pattern.test(arg));
22877
+ switch (verb) {
22878
+ case "reflog":
22879
+ return /^(?:expire|delete)$/.test(first) ? "write" : "read";
22880
+ case "branch":
22881
+ case "tag":
22882
+ return leadOwnedGit(args) || named.length > 0 && !has(/^(?:-l|--list|--contains|--(?:no-)?merged|--points-at)$/) ? "write" : "read";
22883
+ case "config": {
22884
+ if (has(/^(?:-l|--list|--get-regexp)$/) || first === "list")
22885
+ return has(/^--local$/) ? "write" : null;
22886
+ if (has(/^--get/) || first === "get" || named.length === 1)
22887
+ return "read";
22888
+ const [key = "", value] = first === "set" ? named.slice(1) : named;
22889
+ return /^(?:user\.(?:name|email)|init\.defaultbranch)$/i.test(key) || /^commit\.gpgsign$/i.test(key) && value === "false" ? "write" : null;
22890
+ }
22891
+ case "worktree":
22892
+ return first === "list" ? "read" : /^(?:add|remove)$/.test(first) ? "write" : null;
22893
+ case "remote":
22894
+ return !first || first === "show" && named.length === 2 && local(second, true) ? "read" : null;
22895
+ case "ls-remote":
22896
+ return local(first || "origin", true) ? "read" : null;
22897
+ case "bisect":
22898
+ return /^(?:log|terms)$/.test(first) ? "read" : /^(?:start|good|bad|new|old|skip|reset)$/.test(first) ? "write" : null;
22899
+ case "blame": {
22900
+ const contents = args.findIndex((arg) => arg.startsWith("--contents"));
22901
+ const file = args[contents]?.slice(11) || args[contents + 1];
22902
+ return contents < 0 || local(file) ? "read" : null;
22903
+ }
22904
+ case "fetch":
22905
+ return !first || local(first, true) ? "write" : null;
22906
+ case "clone":
22907
+ return local(first) ? "write" : null;
22908
+ }
22909
+ return GIT_VERBS[verb].startsWith("+") ? "write" : "read";
22910
+ };
22911
+ 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`;
22912
+ var remoteIn = (dir, name, repo) => {
22913
+ const shared = path32.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo, false)?.[1] : undefined;
22914
+ if (!shared)
22915
+ return false;
22916
+ const url = configEntries(fs21.readFileSync(path32.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
22917
+ return url !== undefined && literalIn(url, repo, true);
22918
+ };
22919
+ var judgeGit = (command, repo, depth = 0) => {
22920
+ const runsGit = /\bgit\b/.test(command);
22921
+ for (const segment of segmentsOf(command)) {
22922
+ const words = segment.words;
22923
+ let why = null;
22924
+ let at = 0;
22925
+ while (/^(?:if|then|elif|else|do|while|until|!|\{|\()$/.test(words[at] ?? ""))
22926
+ at++;
22927
+ const lead = [];
22928
+ while (/^\w+\+?=/.test(words[at] ?? ""))
22929
+ lead.push(words[at++]);
22930
+ const name = path32.basename(words[at] ?? "");
22931
+ let start = words.findIndex((word) => /(?:^|[\\/])git(?:\.exe)?(?:=|$)/.test(word));
22932
+ if (start > at) {
22933
+ 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] ?? ""))
22934
+ start = -1;
22935
+ else if (!/^(?:timeout|nice|time|command)$/.test(name) || words.slice(at + 1, start).some((word) => !/^(?:-[\w-]+|\d[\w.]*)$/.test(word)))
22936
+ why = `\`${name}\` runs git`;
22937
+ }
22938
+ if (start >= 0 && words[start].includes("="))
22939
+ why = "git is redefined";
22940
+ const run = words[start] ?? "";
22941
+ if (run.includes("/") && (!path32.isAbsolute(run) || literalIn(run, repo, true)))
22942
+ why ??= `\`${run}\` is not the system git`;
22943
+ if (segment.expands?.includes(at) && name !== "[" || /\{[^}]*,/.test(words[at] ?? ""))
22944
+ why = "the command's name is expanded by the shell";
22945
+ if (start >= 0 && (segment.expands?.length || words.some((word) => /\{[^}]*(?:,|\.\.)[^}]*\}|^~/.test(word))))
22946
+ why ??= "a word in this git command is expanded by the shell: spell it as a literal";
22947
+ if (/^(?:export|declare|local|readonly|typeset)$/.test(name))
22948
+ lead.push(...words.slice(at + 1).filter((word) => /^\w+\+?=/.test(word)));
22949
+ for (const word of runsGit ? lead : lead.filter((set) => /^(?:BASH_)?ENV=/.test(set)))
22950
+ if (!/^(?:(?:GIT_)?PAGER=cat|GIT_OPTIONAL_LOCKS=0|(?:LC_\w+|LANG|TZ)=[^$`]*)$/.test(word))
22951
+ why ??= `\`${word}\` is not allowed`;
22952
+ let index = start < 0 ? words.length : start + 1;
22953
+ let dir = "";
22954
+ let unlocked = lead.includes("GIT_OPTIONAL_LOCKS=0");
22955
+ for (;!why && words[index]?.startsWith("-") && words[index] !== "--version"; index++) {
22956
+ const word = words[index];
22957
+ const flag = /^--(git-dir|work-tree)(?:=([\s\S]*))?$/.exec(word);
22958
+ const value = flag?.[2] ?? (/^(?:-C|--git-dir|--work-tree)$/.test(word) ? words[++index] : "");
22959
+ if (word === "-C")
22960
+ dir = value;
22961
+ unlocked ||= word === "--no-optional-locks";
22962
+ if (flag ? !literalIn(value, repo) : !/^(?:-C|-P|--no-pager|--no-optional-locks)$/.test(word))
22963
+ why = `\`${word}\` is not allowed`;
22964
+ }
22965
+ const args = words[index] === "--version" ? ["version"] : words.slice(index);
22966
+ if (!why && start >= 0) {
22967
+ const local = (source, remote) => remote && /^[\w-][\w.-]*$/.test(source) ? remoteIn(dir, source, repo) : literalIn(source, repo, true);
22968
+ if (!gitKind(args, local))
22969
+ why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
22970
+ else if (args[0] === "status" && !unlocked) {
22971
+ const dirs = path32.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo) : null;
22972
+ if (!dirs?.length || !dirs.every((gitDir) => inScratch(gitDir, repo)))
22973
+ why = "`git status` refreshes the index outside scratch: add --no-optional-locks";
22974
+ }
22975
+ }
22976
+ 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)));
22977
+ const scripts = [
22978
+ ...words.filter((_, after) => shell >= 0 && after > shell && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(words[after - 1])),
22979
+ ...shell < 0 ? [] : segment.stdin ?? []
22980
+ ];
22981
+ 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))))
22982
+ why ??= `\`${name}\` runs git`;
22983
+ for (const script of [...segment.subs ?? [], ...scripts])
22984
+ why ??= depth < 4 ? judgeGit(script, repo, depth + 1) : "scripts nest too deep for Workit to read";
22985
+ if (why)
22986
+ return why;
22987
+ }
22988
+ return null;
22640
22989
  };
22641
22990
  var JUDGE_VERBS = {
22642
22991
  check: true,
@@ -22787,7 +23136,7 @@ var judgeDeny = (input, what, target) => {
22787
23136
  unblock
22788
23137
  };
22789
23138
  };
22790
- function confineJudge(input, targets) {
23139
+ function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
22791
23140
  try {
22792
23141
  if (!input.session.agentId)
22793
23142
  return NONE5;
@@ -22797,7 +23146,12 @@ function confineJudge(input, targets) {
22797
23146
  const resolved = path32.resolve(target);
22798
23147
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
22799
23148
  return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
22800
- if (inScratch(canonical5(target), repo))
23149
+ const real = canonical5(target);
23150
+ const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path32.basename(target));
23151
+ const gitDirs = runsGit ? gitDirsAt(path32.dirname(real), repo) : [];
23152
+ if (gitDirs === null)
23153
+ return judgeDeny(input, `git in ${shown(target)} uses a git dir or config Workit cannot check`);
23154
+ if (runsGit ? gitDirs.length > 0 ? gitDirs.every((dir) => inScratch(dir, repo)) : inScratch(real, repo) : inScratch(real, repo) && !inGitDir(real))
22801
23155
  continue;
22802
23156
  const runner = runnerAt(target);
22803
23157
  return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`, target);
@@ -22818,21 +23172,31 @@ function confineJudgeShell(input, command, dialect = "posix") {
22818
23172
  } catch {
22819
23173
  refused = "Workit cannot read this command: split it into simpler ones";
22820
23174
  }
23175
+ if (!refused && dialect === "posix") {
23176
+ const judged = checkoutOf2(input.cwd);
23177
+ try {
23178
+ const why = judgeGit(command, judged ? commonDir(judged.root) : null);
23179
+ if (why)
23180
+ refused = `${why}: ${JUDGE_GIT}`;
23181
+ } catch {
23182
+ refused = "Workit cannot read this command: split it into simpler ones";
23183
+ }
23184
+ }
22821
23185
  if (refused)
22822
23186
  return judgeDeny(input, refused);
22823
23187
  if (dialect === "posix" && substitutingHeredoc(command))
22824
23188
  return judgeDeny(input, "an unquoted heredoc runs the `$(…)` or backtick command in its body: quote the delimiter (<<'EOF')");
22825
23189
  let git = [];
22826
23190
  try {
22827
- git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args)) ? [
23191
+ git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args) || gitKind(args) === "write" && !/^(?:init|clone)$/.test(args[0])) ? [
22828
23192
  path32.join(dir === undefined ? UNKNOWN_DIR : path32.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
22829
23193
  ] : []);
22830
23194
  } catch {}
22831
- return confineJudge(input, [
22832
- ...shellMutationTargets(input.cwd, command, dialect, true),
22833
- ...fed.flatMap((body) => shellMutationTargets(input.cwd, body, "posix", true)),
22834
- ...git
22835
- ]);
23195
+ const lists = [
23196
+ shellMutationTargets(input.cwd, command, dialect, true),
23197
+ ...fed.map((body) => shellMutationTargets(input.cwd, body, "posix", true))
23198
+ ];
23199
+ return confineJudge(input, [...lists.flat(), ...git], new Set([...git, ...lists.flatMap((list) => [...placeholdersOf(list)])]));
22836
23200
  } catch {
22837
23201
  return NONE5;
22838
23202
  }
@@ -23738,7 +24102,13 @@ var SHELLS3 = /^(?:sh|bash|zsh|dash|ksh|ash|mksh|yash|fish)$/;
23738
24102
  var MAX_DEPTH2 = 4;
23739
24103
  var READ = new Map;
23740
24104
  var NOT_PLAIN = gap("a ytrack call that is not a plain command of its own (a wrapper, loop, substitution or script around it can change or repeat it)");
23741
- var ungrant = (write) => write.workit ? { command: write.command, ...NOT_PLAIN } : write;
24105
+ var timeOnly = (effect) => effect?.minutes !== undefined && Object.keys(effect).every((key) => /^(?:issue|minutes|text|date)$/u.test(key));
24106
+ var ungrant = (write) => write.workit ? {
24107
+ command: write.command,
24108
+ ...NOT_PLAIN,
24109
+ ...timeOnly(write.effect) ? { hint: write.workit } : {}
24110
+ } : write;
24111
+ var hinted = (write) => write.hint ? { command: write.command, workit: write.hint } : write;
23742
24112
  var ytrackArgs = (line, found, depth, names, plain) => {
23743
24113
  const inner = (script) => void found.push(...ytrackWrites(script, "posix", depth + 1, plain));
23744
24114
  const tail = workitCheckTail(line);
@@ -23872,6 +24242,7 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
23872
24242
  found = [];
23873
24243
  for (const line of commandLines(command, dialect))
23874
24244
  ytrackArgs(line, found, depth, aliases(command), false);
24245
+ found = found.map(hinted);
23875
24246
  }
23876
24247
  READ.set(key, found);
23877
24248
  if (READ.size > 64)
@@ -23879,6 +24250,8 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
23879
24250
  return found;
23880
24251
  };
23881
24252
  var ytrackGate = (cwd, command, dialect, ask) => {
24253
+ if (namesTicket(command))
24254
+ return { kind: "deny", reason: TICKET_DENY, unblock: null };
23882
24255
  let writes;
23883
24256
  try {
23884
24257
  const merged = new Map;
@@ -23906,8 +24279,8 @@ var ytrackGate = (cwd, command, dialect, ask) => {
23906
24279
  reason: `${bare.join(", ")} writes to YouTrack: the user decides this call (#780).`
23907
24280
  };
23908
24281
  const why = `A raw ytrack write posts to YouTrack without the user's yes (#780).`;
23909
- const run = calls.length ? ` Run ${calls.join(", then ")} instead: it asks the user first. When it answers approval_needed, run exactly the \`workit approve <id>\` it names, now, with nothing around it (no 2>&1, pipe or echo), so the host asks the user; then rerun the workit call once.` : "";
23910
- const user = bare.length ? ` For ${bare.join(", ")}, the user decides: ask the user, and if they agree they run it in their own terminal.` : "";
24282
+ const run = calls.length ? ` Run ${calls.join(", then ")} instead, each as its own plain call: it asks the user first.` : "";
24283
+ const user = bare.length ? ask ? ` For ${bare.join(", ")}, run it as its own plain call: the host asks the user.` : ` For ${bare.join(", ")}, the user decides: ask the user, and if they agree they run it in their own terminal.` : "";
23911
24284
  const rerun = writes.some((write) => write.gap === NOT_PLAIN.gap) ? " To get the named workit youtrack call instead, rerun the ytrack call as one plain command, with no wrapper, loop, substitution or script around it." : "";
23912
24285
  return {
23913
24286
  kind: "deny",
@@ -24125,6 +24498,8 @@ function decide(input, deps) {
24125
24498
  case "write.pre": {
24126
24499
  if (!usable2(descriptor.events["write.pre"].support))
24127
24500
  return NONE6;
24501
+ if (event.text && namesTicket(event.text))
24502
+ return { kind: "deny", reason: TICKET_DENY, unblock: null };
24128
24503
  const role = agentRole(input, descriptor);
24129
24504
  if (role) {
24130
24505
  const targets = liveTargets(input.cwd, event.paths);
@@ -98,7 +98,7 @@ if (quiet) {
98
98
  `);
99
99
  } else {
100
100
  try {
101
- const { runCodexHook } = await import("./workit-hook-hqw6yaxq.js");
101
+ const { runCodexHook } = await import("./workit-hook-74basyv3.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",
3
+ "version": "2.5.0",
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.3",
45
- "@workit-dev/mcp": "^2.4.3"
44
+ "@workit-dev/core": "^2.5.0",
45
+ "@workit-dev/mcp": "^2.5.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"