@workit-dev/codex 2.29.2 → 2.29.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "2.29.2",
3
+ "version": "2.29.4",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -24547,7 +24547,9 @@ Autonomy contract:
24547
24547
  - Continue to the requested endpoint without asking "continue?", running
24548
24548
  checks and repairs.
24549
24549
  Stop only for a new consequential choice, a host denial, a conflicting edit
24550
- or an unresolved blocker; report open gaps and uncertain workers.
24550
+ or an unresolved blocker; report open gaps and uncertain workers. A
24551
+ classifier denying a chained granted verb: rerun it once alone, verb first;
24552
+ a plain call denied: ask in chat, never a terminal hand-off.
24551
24553
  - No endpoint named: stop at a local commit on a policy-compliant branch and
24552
24554
  state the next command. If the request implies delivery (fix, implement,
24553
24555
  ship), go to the effective endpoint in \`workit grant show\`: \`pr\` stops
@@ -25323,6 +25325,46 @@ var API_VALUES = new Set(["--method", "--header", "--raw-field", "--field", "--j
25323
25325
  "--output"
25324
25326
  ]));
25325
25327
  var API_FIELDS = new Set(["-f", "-F", "--raw-field", "--field"]);
25328
+ var GH_REPO_PATH = String.raw`(?:^|\/)(?:repos\/[^/]+\/[^/]+|repositories\/[^/]+)`;
25329
+ var ghPath = (rest) => new RegExp(`${GH_REPO_PATH}\\/${rest}(?:\\/|$)`, "i");
25330
+ var called = (names) => new RegExp(String.raw`\b(?:${names})(?:[\s,\uFEFF]|#[^\n\r]*[\n\r])*\(`);
25331
+ var GRAPHQL_REF = [
25332
+ [called("createRef|updateRefs?|deleteRef"), "ref"],
25333
+ [
25334
+ called("createCommitOnBranch|createLinkedBranch|createBranch|branchDelete|commitCreate"),
25335
+ "branch"
25336
+ ],
25337
+ [called("tagCreate|tagDelete"), "tag"]
25338
+ ];
25339
+ var GRAPHQL_SETTING = called("(?:create|update|delete)(?:BranchProtectionRule|RepositoryRuleset)|branchRule(?:Create|Update|Delete)");
25340
+ var API_REF = {
25341
+ gh: [
25342
+ [ghPath(String.raw`git\/refs?`), "ref"],
25343
+ [ghPath(String.raw`(?:branches\/.+\/rename|merge-upstream|contents)`), "branch"]
25344
+ ],
25345
+ glab: [
25346
+ [/(?:^|\/)repository\/tags(?:\/|$)/i, "tag"],
25347
+ [/(?:^|\/)repository\/(?:branches|merged_branches|files|submodules)(?:\/|$)/i, "branch"],
25348
+ [/(?:^|\/)repository\/commits(?:\/[^/]+\/(?:cherry_pick|revert))?\/?$/i, "branch"]
25349
+ ]
25350
+ };
25351
+ var API_SETTING = {
25352
+ gh: [
25353
+ ghPath(String.raw`(?:branches\/.+|tags)\/protection`),
25354
+ ghPath("rulesets"),
25355
+ ghPath(String.raw`environments\/[^/]+\/deployment-branch-policies`),
25356
+ /(?:^|\/)orgs\/[^/]+\/rulesets(?:\/|$)/i
25357
+ ],
25358
+ glab: [
25359
+ /(?:^|\/)(?:projects|groups)\/[^/]+\/protected_(?:branches|tags)(?:\/|$)/i,
25360
+ /(?:^|\/)projects\/[^/]+\/push_rule(?:\/|$)/i
25361
+ ]
25362
+ };
25363
+ var API_REPOSITORY = {
25364
+ gh: new RegExp(`${GH_REPO_PATH}\\/?$`, "i"),
25365
+ glab: /(?:^|\/)projects\/[^/]+\/?$/i
25366
+ };
25367
+ var BY_ID = called("updateRefs?|deleteRef");
25326
25368
  var GIT_COMMANDS = new Set(("add am annotate apply archive bisect blame branch bugreport bundle cat-file check-attr " + "check-ignore check-mailmap check-ref-format checkout checkout-index cherry cherry-pick " + "citool clean clone column commit commit-graph commit-tree config count-objects credential " + "daemon describe diagnose diff diff-files diff-index diff-tree difftool fast-export " + "fast-import fetch fetch-pack filter-branch fmt-merge-msg for-each-ref for-each-repo " + "format-patch fsck gc get-tar-commit-id grep gui hash-object help hook index-pack init " + "instaweb interpret-trailers lfs log ls-files ls-remote ls-tree mailinfo mailsplit " + "maintenance merge merge-base merge-file merge-index merge-tree mergetool mktag mktree " + "multi-pack-index mv name-rev notes pack-objects pack-refs patch-id prune pull push " + "range-diff read-tree rebase reflog remote repack replace request-pull rerere reset " + "restore rev-list rev-parse revert rm send-email shortlog show show-branch show-ref " + "sparse-checkout stage stash status stripspace submodule subtree switch symbolic-ref tag " + "update-index update-ref var verify-commit verify-pack verify-tag version whatchanged " + "worktree write-tree").split(" "));
25327
25369
 
25328
25370
  // packages/workit-core/src/core/route-intent.ts
@@ -32636,6 +32678,7 @@ var FLAGS = {
32636
32678
  // packages/workit-core/src/approvals/inline.ts
32637
32679
  var DIR2 = "<dir>";
32638
32680
  var OPAQUE_RELEASE_FIX = `workit release --cwd ${DIR2} notes approve <version>`;
32681
+ var OPAQUE_RELEASE_FIRST = `workit release notes approve --cwd ${DIR2} <version>`;
32639
32682
 
32640
32683
  // packages/workit-core/src/hooks/hosts/claude-code.ts
32641
32684
  var CLAUDE_CODE_DESCRIPTOR = {
@@ -6156,7 +6156,9 @@ Autonomy contract:
6156
6156
  - Continue to the requested endpoint without asking "continue?", running
6157
6157
  checks and repairs.
6158
6158
  Stop only for a new consequential choice, a host denial, a conflicting edit
6159
- or an unresolved blocker; report open gaps and uncertain workers.
6159
+ or an unresolved blocker; report open gaps and uncertain workers. A
6160
+ classifier denying a chained granted verb: rerun it once alone, verb first;
6161
+ a plain call denied: ask in chat, never a terminal hand-off.
6160
6162
  - No endpoint named: stop at a local commit on a policy-compliant branch and
6161
6163
  state the next command. If the request implies delivery (fix, implement,
6162
6164
  ship), go to the effective endpoint in \`workit grant show\`: \`pr\` stops
@@ -15136,7 +15138,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
15136
15138
  for (const invocation of inside)
15137
15139
  found.push({ ...invocation, dir: rebase(dir, invocation.dir) });
15138
15140
  };
15139
- const visit = (input, stdin, hops) => {
15141
+ const visit = (input, stdin, hops, expands = "all") => {
15140
15142
  const line = /^\$[\w:]+$/.test(input[0] ?? "") && input[1] === "=" ? input.slice(2) : input;
15141
15143
  const split = splitString(line);
15142
15144
  if (split !== null)
@@ -15198,15 +15200,18 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
15198
15200
  nested(cmdScript(words), "powershell");
15199
15201
  else if (name === "xargs" || name === "find")
15200
15202
  runs(name === "xargs" ? xargsCommands(words, stdin) : findCommands(words));
15201
- else if (name === "gh" || name === "glab")
15203
+ else if (name === "gh" || name === "glab") {
15204
+ const shift = input.length - words.length + 1;
15205
+ const expanded = expands === "all" ? expands : expands.filter((at) => at >= shift).map((at) => at - shift);
15202
15206
  found.push({
15203
15207
  tool: name,
15204
15208
  dir,
15205
15209
  args: words.slice(1),
15206
15210
  ...Object.keys({ ...exported, ...env }).length ? { env: { ...exported, ...env } } : {},
15207
- ...stdin === undefined ? {} : { stdin }
15211
+ ...stdin === undefined ? {} : { stdin },
15212
+ ...expanded.length ? { expanded } : {}
15208
15213
  });
15209
- else if (name === "git") {
15214
+ } else if (name === "git") {
15210
15215
  const invocation = gitInvocation(words.slice(1), dir, { ...exported, ...env }, stdin, sessionConfig);
15211
15216
  found.push(invocation);
15212
15217
  sessionConfig.push(...configSetBy(invocation.args));
@@ -15239,7 +15244,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
15239
15244
  }
15240
15245
  const stdin = stdinOf(segment, segments[index - 1]);
15241
15246
  for (const line of substitute(segment.words, vars))
15242
- visit(line, stdin, 0);
15247
+ visit(line, stdin, 0, segment.expands ?? []);
15243
15248
  }
15244
15249
  return found;
15245
15250
  }
@@ -15534,55 +15539,232 @@ var API_VALUES = new Set(["--method", "--header", "--raw-field", "--field", "--j
15534
15539
  var API_SHORT_VALUES = "XHfFqtp";
15535
15540
  var API_FIELDS = new Set(["-f", "-F", "--raw-field", "--field"]);
15536
15541
  var API_MERGE = {
15537
- gh: /(?:^|\/)(?:pulls\/[^/?#]+\/merge|merges)\/?(?:[?#]|$)/i,
15538
- glab: /(?:^|\/)merge_requests\/[^/?#]+\/merge\/?(?:[?#]|$)/i
15542
+ gh: /(?:^|\/)(?:pulls\/[^/?#]+\/merge|merges)\/?$/i,
15543
+ glab: /(?:^|\/)merge_requests\/[^/?#]+\/merge\/?$/i
15539
15544
  };
15540
15545
  var GRAPHQL_MERGE = /\b(?:mergePullRequest|enablePullRequestAutoMerge|mergeBranch|mergeRequestAccept)\b/;
15541
- var apiAction = (tool, args, stdin) => {
15542
- const request = { method: null, body: false };
15546
+ var GH_REPO_PATH = String.raw`(?:^|\/)(?:repos\/[^/]+\/[^/]+|repositories\/[^/]+)`;
15547
+ var ghPath = (rest) => new RegExp(`${GH_REPO_PATH}\\/${rest}(?:\\/|$)`, "i");
15548
+ var called = (names) => new RegExp(String.raw`\b(?:${names})(?:[\s,\uFEFF]|#[^\n\r]*[\n\r])*\(`);
15549
+ var GRAPHQL_REF = [
15550
+ [called("createRef|updateRefs?|deleteRef"), "ref"],
15551
+ [
15552
+ called("createCommitOnBranch|createLinkedBranch|createBranch|branchDelete|commitCreate"),
15553
+ "branch"
15554
+ ],
15555
+ [called("tagCreate|tagDelete"), "tag"]
15556
+ ];
15557
+ var GRAPHQL_SETTING = called("(?:create|update|delete)(?:BranchProtectionRule|RepositoryRuleset)|branchRule(?:Create|Update|Delete)");
15558
+ var API_REF = {
15559
+ gh: [
15560
+ [ghPath(String.raw`git\/refs?`), "ref"],
15561
+ [ghPath(String.raw`(?:branches\/.+\/rename|merge-upstream|contents)`), "branch"]
15562
+ ],
15563
+ glab: [
15564
+ [/(?:^|\/)repository\/tags(?:\/|$)/i, "tag"],
15565
+ [/(?:^|\/)repository\/(?:branches|merged_branches|files|submodules)(?:\/|$)/i, "branch"],
15566
+ [/(?:^|\/)repository\/commits(?:\/[^/]+\/(?:cherry_pick|revert))?\/?$/i, "branch"]
15567
+ ]
15568
+ };
15569
+ var API_SETTING = {
15570
+ gh: [
15571
+ ghPath(String.raw`(?:branches\/.+|tags)\/protection`),
15572
+ ghPath("rulesets"),
15573
+ ghPath(String.raw`environments\/[^/]+\/deployment-branch-policies`),
15574
+ /(?:^|\/)orgs\/[^/]+\/rulesets(?:\/|$)/i
15575
+ ],
15576
+ glab: [
15577
+ /(?:^|\/)(?:projects|groups)\/[^/]+\/protected_(?:branches|tags)(?:\/|$)/i,
15578
+ /(?:^|\/)projects\/[^/]+\/push_rule(?:\/|$)/i
15579
+ ]
15580
+ };
15581
+ var API_REPOSITORY = {
15582
+ gh: new RegExp(`${GH_REPO_PATH}\\/?$`, "i"),
15583
+ glab: /(?:^|\/)projects\/[^/]+\/?$/i
15584
+ };
15585
+ var PLAIN_REF = /^refs\/(?:heads|tags)\/(?!.*\.\.)[^\s$`\\%]+$/;
15586
+ var BY_ID = called("updateRefs?|deleteRef");
15587
+ var createdRefs = (query) => {
15588
+ if (/[\\$]|"""/.test(query))
15589
+ return null;
15590
+ const tokens = query.match(/#[^\n\r]*|"[^"\n\r]*"|[_A-Za-z]\w*|[^\s,\uFEFF]/g) ?? [];
15591
+ const named = [];
15592
+ for (let at = 0;at < tokens.length; at++) {
15593
+ if (tokens[at] !== "createRef")
15594
+ continue;
15595
+ const args = tokens.slice(at + 1).filter((token) => !token.startsWith("#"));
15596
+ if (args[0] !== "(")
15597
+ continue;
15598
+ let depth = 0;
15599
+ const names = [];
15600
+ for (let index = 0;index < args.length; index++) {
15601
+ const token = args[index];
15602
+ if (token === "(" || token === "{" || token === "[")
15603
+ depth++;
15604
+ else if (token === ")" || token === "}" || token === "]") {
15605
+ if (--depth === 0)
15606
+ break;
15607
+ } else if (token === "name" && args[index + 1] === ":")
15608
+ names.push(args[index + 2] ?? "");
15609
+ }
15610
+ if (depth !== 0 || names.length !== 1 || !names[0].startsWith('"'))
15611
+ return null;
15612
+ named.push(names[0].slice(1, -1));
15613
+ }
15614
+ return named;
15615
+ };
15616
+ var provablyRead = (query) => /^[\s,\uFEFF]*(?:\{|query[\s,\uFEFF]*[({])/.test(query) && !/\b(?:mutation|subscription)\b/.test(query);
15617
+ var refWrite = (forge, shapes, named, certain) => {
15618
+ const sure = certain && named.length > 0 && named.every((ref) => PLAIN_REF.test(ref));
15619
+ const tags = !sure || named.some((ref) => ref.startsWith("refs/tags/"));
15620
+ const heads = !sure || named.some((ref) => ref.startsWith("refs/heads/"));
15621
+ const ref = shapes.has("ref");
15622
+ return {
15623
+ kind: "ref-write",
15624
+ forge,
15625
+ tag: shapes.has("tag") || ref && tags,
15626
+ branch: shapes.has("branch") || ref && heads,
15627
+ ...ref && sure ? { ref: named[0] } : {}
15628
+ };
15629
+ };
15630
+ var restRef = (route, fields, readable) => {
15631
+ const inPath = /\/git\/refs?\/(.+)$/i.exec(route)?.[1];
15632
+ if (inPath)
15633
+ return { named: [`refs/${inPath}`], certain: true };
15634
+ const refs = fields.filter((field) => field.startsWith("ref=")).map((field) => field.slice(4));
15635
+ const mentions = fields.filter((field) => /refs\//.test(field)).length;
15636
+ return { named: refs, certain: readable && refs.length === 1 && mentions === 1 };
15637
+ };
15638
+ var routeOf = (endpoint) => endpoint.replace(/(?<!:)\/{2,}/g, "/").replace(/[?#][\s\S]*$/, "").replace(/%([\da-f]{2})/gi, (escape, hex) => {
15639
+ const char = String.fromCodePoint(Number.parseInt(hex, 16));
15640
+ return /[\w.~-]/.test(char) ? char : escape;
15641
+ });
15642
+ var apiAction = (tool, args, stdin, expanded = []) => {
15643
+ const request = { method: null, body: false, input: false, unread: false };
15543
15644
  let endpoint = null;
15645
+ let endpointAt = -1;
15544
15646
  const values = [];
15545
- const take = (name, value) => {
15647
+ const fields = [];
15648
+ const queries = [];
15649
+ const field = (value, expands) => {
15650
+ fields.push(value);
15651
+ values.push(value);
15652
+ if (!value.startsWith("query="))
15653
+ return;
15654
+ const text = value.slice(6);
15655
+ const read = expanded !== "all" && (!(expands && /[$`]/.test(text)) || provablyRead(text));
15656
+ queries.push({ text, read });
15657
+ };
15658
+ const fromStdin = (name, value, text) => {
15659
+ if (name !== "--input") {
15660
+ if (text.includes("\\"))
15661
+ request.unread = true;
15662
+ return field(`${value.slice(0, value.indexOf("=") + 1)}${text}`, true);
15663
+ }
15664
+ values.push(text);
15665
+ let body;
15666
+ try {
15667
+ body = JSON.parse(text);
15668
+ } catch {
15669
+ request.unread = true;
15670
+ return;
15671
+ }
15672
+ const strings = (each) => typeof each === "string" ? [each] : each && typeof each === "object" ? Object.entries(each).flatMap(([key, inner]) => [key, ...strings(inner)]) : [];
15673
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
15674
+ values.push(...strings(body));
15675
+ return;
15676
+ }
15677
+ for (const [key, inner] of Object.entries(body)) {
15678
+ if (typeof inner === "string")
15679
+ field(`${key}=${inner}`, true);
15680
+ else
15681
+ values.push(key, ...strings(inner));
15682
+ }
15683
+ };
15684
+ const take = (name, value, at) => {
15685
+ const expands = expanded === "all" || expanded.includes(at);
15546
15686
  if (name === "-X" || name === "--method")
15547
15687
  request.method = value.toUpperCase();
15548
15688
  if (API_FIELDS.has(name) || name === "--input")
15549
15689
  request.body = true;
15550
- values.push(value);
15551
- const fromStdin = name === "--input" ? value === "-" : /^(?:[^=]*=)?@-$/.test(value);
15552
- if (fromStdin && stdin !== undefined)
15553
- values.push(stdin);
15690
+ if (name === "--input")
15691
+ request.input = true;
15692
+ const piped = name === "--input" ? value === "-" : /^(?:-F|--field)$/.test(name) && /^[^=]*=@-$/.test(value);
15693
+ if (piped && stdin !== undefined) {
15694
+ values.push(value);
15695
+ return fromStdin(name, value, stdin);
15696
+ }
15697
+ if (API_FIELDS.has(name))
15698
+ field(value, expands);
15699
+ else
15700
+ values.push(value);
15701
+ const file = name === "--input" || /^(?:-F|--field)$/.test(name) && /^[^=]*=@/.test(value);
15702
+ if (file)
15703
+ request.unread = true;
15554
15704
  };
15555
15705
  for (let index = 1;index < args.length; index++) {
15556
15706
  const arg = args[index];
15557
15707
  if (arg === "--") {
15558
- endpoint ??= args[index + 1] ?? null;
15708
+ if (endpoint === null)
15709
+ [endpoint, endpointAt] = [args[index + 1] ?? null, index + 1];
15559
15710
  break;
15560
15711
  }
15561
15712
  if (arg.startsWith("--")) {
15562
15713
  const eq = arg.indexOf("=");
15563
15714
  const name = eq > 0 ? arg.slice(0, eq) : arg;
15564
15715
  if (API_VALUES.has(name))
15565
- take(name, eq > 0 ? arg.slice(eq + 1) : args[++index] ?? "");
15716
+ take(name, eq > 0 ? arg.slice(eq + 1) : args[++index] ?? "", index);
15566
15717
  } else if (arg.startsWith("-") && arg.length > 1) {
15567
15718
  for (let at = 1;at < arg.length; at++) {
15568
15719
  if (!API_SHORT_VALUES.includes(arg[at]))
15569
15720
  continue;
15570
- take(`-${arg[at]}`, at + 1 < arg.length ? arg.slice(at + 1) : args[++index] ?? "");
15721
+ take(`-${arg[at]}`, at + 1 < arg.length ? arg.slice(at + 1) : args[++index] ?? "", index);
15571
15722
  break;
15572
15723
  }
15573
- } else
15574
- endpoint ??= arg;
15724
+ } else if (endpoint === null)
15725
+ [endpoint, endpointAt] = [arg, index];
15575
15726
  }
15576
15727
  if (!endpoint)
15577
15728
  return null;
15578
- endpoint = endpoint.replace(/(?<!:)\/{2,}/g, "/");
15729
+ const atEndpoint = expanded === "all" || expanded.includes(endpointAt);
15730
+ for (const pair of /[?]([^#]*)/.exec(endpoint)?.[1].split("&") ?? []) {
15731
+ let decoded = pair;
15732
+ try {
15733
+ decoded = decodeURIComponent(pair.replaceAll("+", " "));
15734
+ } catch {
15735
+ request.unread = true;
15736
+ }
15737
+ field(decoded, atEndpoint);
15738
+ if (/refs\//i.test(decoded))
15739
+ request.input = true;
15740
+ }
15741
+ const route = routeOf(endpoint);
15579
15742
  const merge = { kind: "merge", forge: tool, via: "api" };
15580
- if (/(?:^|\/)graphql\/?$/i.test(endpoint))
15581
- return values.some((value) => GRAPHQL_MERGE.test(value)) ? merge : null;
15743
+ const setting = {
15744
+ kind: "ref-write",
15745
+ forge: tool,
15746
+ tag: false,
15747
+ branch: true,
15748
+ setting: true
15749
+ };
15750
+ if (/(?:^|\/)graphql\/?$/i.test(route)) {
15751
+ if (request.unread || queries.some((query) => !query.read))
15752
+ return { kind: "ref-write", forge: tool, tag: true, branch: true, unread: true };
15753
+ if (values.some((value) => GRAPHQL_MERGE.test(value)))
15754
+ return merge;
15755
+ if (values.some((value) => GRAPHQL_SETTING.test(value)))
15756
+ return setting;
15757
+ const shapes = new Set(GRAPHQL_REF.filter(([pattern]) => values.some((value) => pattern.test(value))).map(([, shape]) => shape));
15758
+ if (!shapes.size)
15759
+ return null;
15760
+ const created = queries.map((query) => createdRefs(query.text));
15761
+ const certain = !values.some((value) => BY_ID.test(value)) && created.every((named) => named !== null);
15762
+ return refWrite(tool, shapes, created.flatMap((named) => named ?? []), certain);
15763
+ }
15582
15764
  const verb = request.method ?? (request.body ? "POST" : "GET");
15583
15765
  if (verb === "GET" || verb === "HEAD")
15584
15766
  return null;
15585
- const named = tool === "gh" ? /(?:^|\/)repos\/([^/{]+\/[^/{]+)\//i.exec(endpoint)?.[1] : /(?:^|\/)projects\/([^/]+)\//i.exec(endpoint)?.[1];
15767
+ const named = tool === "gh" ? /(?:^|\/)repos\/([^/{]+\/[^/{]+)(?:\/|$)/i.exec(route)?.[1] ?? (/(?:^|\/)repositories\/[^/]+(?:\/|$)/i.test(route) ? "?" : undefined) : /(?:^|\/)projects\/([^/]+)(?:\/|$)/i.exec(route)?.[1];
15586
15768
  let repo;
15587
15769
  try {
15588
15770
  repo = named === undefined ? undefined : decodeURIComponent(named) || "?";
@@ -15590,9 +15772,17 @@ var apiAction = (tool, args, stdin) => {
15590
15772
  repo = "?";
15591
15773
  }
15592
15774
  const at = repo === undefined ? {} : { repo };
15593
- if (API_MERGE[tool].test(endpoint))
15775
+ if (API_MERGE[tool].test(route))
15594
15776
  return { ...merge, ...at };
15595
- const grant = /\/releases(?:\/|$|\?)/i.test(endpoint) ? "release" : (tool === "gh" ? /\/pulls(?:\/\d+)?\/?(?:\?|$)/i : /\/merge_requests(?:\/\d+)?\/?(?:\?|$)/i).test(endpoint) ? "pr" : null;
15777
+ const defaultBranch = API_REPOSITORY[tool].test(route) && (request.unread || values.some((value) => /default_branch/.test(value)));
15778
+ if (defaultBranch || API_SETTING[tool].some((pattern) => pattern.test(route)))
15779
+ return { ...setting, ...at };
15780
+ const shape = API_REF[tool].find(([pattern]) => pattern.test(route))?.[1];
15781
+ if (shape) {
15782
+ const { named: refs, certain } = restRef(route, fields, !request.unread && !request.input);
15783
+ return { ...refWrite(tool, new Set([shape]), refs, certain), ...at };
15784
+ }
15785
+ const grant = /\/releases(?:\/|$)/i.test(route) ? "release" : (tool === "gh" ? /\/pulls(?:\/\d+)?\/?$/i : /\/merge_requests(?:\/\d+)?\/?$/i).test(route) ? "pr" : null;
15596
15786
  return grant ? { kind: "forge", forge: tool, grant, ...at } : null;
15597
15787
  };
15598
15788
  var subtreePush = (args) => {
@@ -15610,7 +15800,7 @@ var subtreePush = (args) => {
15610
15800
  function rawAction(invocation) {
15611
15801
  const args = invocation.args;
15612
15802
  if (invocation.tool !== "git" && args[0] === "api")
15613
- return apiAction(invocation.tool, args, invocation.stdin);
15803
+ return apiAction(invocation.tool, args, invocation.stdin, invocation.expanded);
15614
15804
  if (asksHelp(invocation))
15615
15805
  return null;
15616
15806
  const [first] = args;
@@ -15886,6 +16076,223 @@ var refusal = (action, branch, dir) => {
15886
16076
  return `workit: raw ${quote("git push")} onto ${branch}, a protected release branch, bypasses workit's protected-branch check. To finish a release or hotfix, push it with ${quote(`workit git push --release ${branch} [--release ${releaseTagPrefixOf(dir)}<version>]`)}: it pushes ${branch} (fast-forward only) and the release tag, verifies the remote and records it, under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}). Feature work goes through ${quote("workit git push")} and ${quote("workit pr merge")}.`;
15887
16077
  return `workit: raw ${quote("git push")}${action.kind === "push" && action.blindForce ? " --force" : ""} onto ${branch}, a protected branch or the default target, bypasses workit's protected-branch check. Push your feature branch with ${quote("workit git push")} (${quote("workit git push --force-with-lease")} to rewrite it) and land it with ${quote("workit pr merge")}.`;
15888
16078
  };
16079
+ var PLAIN_EXPANSION = /^(?:[^$`]|\$[A-Za-z_]\w*|\$\{[A-Za-z_]\w*\})*$/u;
16080
+ var shellWord = (text, expands = false) => {
16081
+ if (/^[\w@%+=:,./-]+$/u.test(text))
16082
+ return text;
16083
+ if (expands && text.includes("$") && PLAIN_EXPANSION.test(text))
16084
+ return `"${text.replaceAll(/["\\]/gu, "\\$&")}"`;
16085
+ return `'${text.replaceAll("'", "'\\''")}'`;
16086
+ };
16087
+ var expandingWords = (command, dialect, found = new Set, depth = 0) => {
16088
+ for (const segment of segmentsOf(command, dialect))
16089
+ segment.words.forEach((text, index) => {
16090
+ if (segment.expands?.includes(index))
16091
+ found.add(text);
16092
+ else if (depth < MAX_DEPTH && /\s/u.test(text))
16093
+ expandingWords(text, "posix", found, depth + 1);
16094
+ });
16095
+ return found;
16096
+ };
16097
+ var wordsOf = (command, dialect = "posix") => {
16098
+ const expands = expandsIn(command, dialect);
16099
+ return (text) => shellWord(text, expands(text));
16100
+ };
16101
+ var expandsIn = (command, dialect = "posix") => {
16102
+ let expanding;
16103
+ return (text) => (expanding ??= expandingWords(command, dialect)).has(text);
16104
+ };
16105
+ var oneCall = (command, dialect) => {
16106
+ const steps = /^(?:\s*cd\s+[^\s;&|<>()$`'"\\]+\s*&&)*([\s\S]*)$/u.exec(command);
16107
+ return !!steps && !!simpleCommand(steps[1], dialect);
16108
+ };
16109
+ var flagWord = (flag, value, asWritten) => value.startsWith("-") ? [`${flag}=${asWritten(value)}`] : [flag, asWritten(value)];
16110
+ var PR_FLAGS = {
16111
+ "gh ready": { verb: "ready", booleans: { "--undo": ["--undo"] }, values: {} },
16112
+ "gh merge": {
16113
+ verb: "merge",
16114
+ booleans: {
16115
+ "--squash": ["--squash"],
16116
+ "-s": ["--squash"],
16117
+ "--merge": ["--merge"],
16118
+ "-m": ["--merge"],
16119
+ "--rebase": ["--rebase"],
16120
+ "-r": ["--rebase"],
16121
+ "--delete-branch": ["--delete-branch"],
16122
+ "-d": ["--delete-branch"]
16123
+ },
16124
+ values: {
16125
+ "--subject": { flag: "--subject" },
16126
+ "-t": { flag: "--subject" },
16127
+ "--body": { flag: "--body" },
16128
+ "-b": { flag: "--body" },
16129
+ "--body-file": { flag: "--body-file" },
16130
+ "-F": { flag: "--body-file" }
16131
+ }
16132
+ },
16133
+ "gh edit": {
16134
+ verb: "edit",
16135
+ booleans: {},
16136
+ values: {
16137
+ "--title": { flag: "--title" },
16138
+ "-t": { flag: "--title" },
16139
+ "--body-file": { flag: "--body-file" },
16140
+ "-F": { flag: "--body-file" },
16141
+ "--add-label": { flag: "--add-label", split: true },
16142
+ "--remove-label": { flag: "--remove-label", split: true },
16143
+ "--add-reviewer": { flag: "--add-reviewer", split: true },
16144
+ "--base": { flag: "--base" },
16145
+ "-B": { flag: "--base" }
16146
+ }
16147
+ },
16148
+ "glab merge": {
16149
+ verb: "merge",
16150
+ booleans: {
16151
+ "--squash": ["--squash"],
16152
+ "-s": ["--squash"],
16153
+ "--rebase": ["--rebase"],
16154
+ "-r": ["--rebase"],
16155
+ "--remove-source-branch": ["--delete-branch"],
16156
+ "-d": ["--delete-branch"],
16157
+ "--yes": [],
16158
+ "-y": []
16159
+ },
16160
+ values: {}
16161
+ },
16162
+ "glab update": {
16163
+ verb: "edit",
16164
+ booleans: { "--ready": [], "-r": [], "--draft": ["--undo"], "--yes": [], "-y": [] },
16165
+ values: {
16166
+ "--title": { flag: "--title" },
16167
+ "-t": { flag: "--title" },
16168
+ "--label": { flag: "--add-label", split: true },
16169
+ "-l": { flag: "--add-label", split: true },
16170
+ "--unlabel": { flag: "--remove-label", split: true },
16171
+ "-u": { flag: "--remove-label", split: true },
16172
+ "--target-branch": { flag: "--base" }
16173
+ }
16174
+ }
16175
+ };
16176
+ var prRetry = (cwd, repo, invocation, cache, asWritten) => {
16177
+ const forge = invocation.tool;
16178
+ if (forge === "git")
16179
+ return null;
16180
+ const values = VALUE_OPTIONS[forge];
16181
+ const args = invocation.args;
16182
+ let verb;
16183
+ let at = 1;
16184
+ for (;at < args.length; at++) {
16185
+ if (!args[at].startsWith("-")) {
16186
+ verb = args[at];
16187
+ break;
16188
+ }
16189
+ if (values.has(args[at]))
16190
+ at++;
16191
+ }
16192
+ const table = PR_FLAGS[`${forge} ${verb}`];
16193
+ if (!table)
16194
+ return null;
16195
+ const words = [];
16196
+ const repos = [];
16197
+ let selector;
16198
+ let ready = false;
16199
+ const rest = [...args.slice(1, at), ...args.slice(at + 1)];
16200
+ for (let index = 0;index < rest.length; index++) {
16201
+ const arg = rest[index];
16202
+ const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
16203
+ const name = eq > 0 ? arg.slice(0, eq) : arg;
16204
+ const value = () => eq > 0 ? arg.slice(eq + 1) : rest[++index];
16205
+ if (name === "-R" || name === "--repo") {
16206
+ const named = value();
16207
+ if (named === undefined)
16208
+ return null;
16209
+ repos.push(named);
16210
+ } else if (/^-R./.test(arg))
16211
+ repos.push(arg.slice(2).replace(/^=/, ""));
16212
+ else if (eq < 0 && Object.hasOwn(table.booleans, arg)) {
16213
+ if (forge === "glab" && (arg === "--ready" || arg === "-r" || arg === "--draft")) {
16214
+ if (ready && words.includes("--undo") !== (arg === "--draft"))
16215
+ return null;
16216
+ ready = true;
16217
+ }
16218
+ words.push(...table.booleans[arg]);
16219
+ } else if (Object.hasOwn(table.values, name)) {
16220
+ const given = value();
16221
+ if (given === undefined)
16222
+ return null;
16223
+ const { flag, split } = table.values[name];
16224
+ if (split && given.includes(",") && /[$`]/.test(given))
16225
+ return null;
16226
+ for (const item of split ? given.split(",").filter(Boolean) : [given])
16227
+ words.push(...flagWord(flag, item, asWritten));
16228
+ } else if (arg.startsWith("-") || selector !== undefined)
16229
+ return null;
16230
+ else
16231
+ selector = arg;
16232
+ }
16233
+ const workitVerb = ready ? "ready" : table.verb;
16234
+ if (ready && words.some((word) => word !== "--undo"))
16235
+ return null;
16236
+ const pr = [];
16237
+ if (selector !== undefined) {
16238
+ const url = /^(https?:\/\/[^/]+\/.+?)\/(?:-\/)?(?:pull|merge_requests)\/(\d+)(?:[/?#].*)?$/.exec(selector);
16239
+ const number = url?.[2] ?? /^[#!]?(\d+)$/.exec(selector)?.[1];
16240
+ if (url)
16241
+ repos.push(url[1]);
16242
+ if (number)
16243
+ pr.push("--pr", number);
16244
+ else if (/\$[A-Za-z_{]/.test(selector))
16245
+ pr.push("--pr", asWritten(selector));
16246
+ else if (selector !== repo.branch)
16247
+ return null;
16248
+ }
16249
+ const env = invocation.env ?? {};
16250
+ if (forge === "gh" && (env.GH_REPO ?? process.env.GH_REPO))
16251
+ repos.push(env.GH_REPO ?? process.env.GH_REPO ?? "");
16252
+ if (repos.length) {
16253
+ const config = gitConfig(repo.dir, invocation, cache);
16254
+ const { GH_REPO: _named, ...own } = env;
16255
+ const key = (named, from) => {
16256
+ const found = forgeRepo(forge === "gh", named, from, config, repo.branch, repo.dir);
16257
+ return found instanceof Error ? null : found.remotes[0]?.key.toLowerCase() ?? null;
16258
+ };
16259
+ const checkout = key("", own);
16260
+ if (!checkout || repos.some((named) => /[$`]/.test(named) || key(named, own) !== checkout))
16261
+ return null;
16262
+ }
16263
+ const dir = path25.resolve(cwd, invocation.dir ?? ".");
16264
+ const call = [
16265
+ `workit pr ${workitVerb}`,
16266
+ ...dir === path25.resolve(cwd) ? [] : ["--cwd", shellWord(dir)],
16267
+ ...pr,
16268
+ ...words
16269
+ ].join(" ");
16270
+ return { raw: `${forge} ${forge === "gh" ? "pr" : "mr"} ${verb}`, call };
16271
+ };
16272
+ var prWriteRefusal = (writes, retry) => {
16273
+ const raws = [...new Set(writes.map((write) => quote(write.raw)))].join(", ");
16274
+ const calls = writes.map((write) => quote(write.call)).join(", ");
16275
+ const why = `workit: raw ${raws} changes the PR past workit's checks (the pr grant, and that the PR is this session's own).`;
16276
+ if (retry && writes.length === 1)
16277
+ return `${why} Run ${calls} instead.
16278
+ Retry as: ${writes[0].call}`;
16279
+ return `${why} Run ${writes.length > 1 ? `each as its own call: ${calls}` : `${calls} as its own call`}, in place of the raw ${writes.length > 1 ? "ones" : "one"}; the rest of this command is yours to run apart.`;
16280
+ };
16281
+ var refWriteRefusal = (action) => {
16282
+ if (action.unread)
16283
+ return `workit: raw ${quote(`${action.forge} api graphql`)} sends a document the hook cannot read (a file, stdin it does not see, or a shell expansion), so it may merge, write a ref or change branch protection past workit's checks. Write the document inline in single quotes, run the change through ${quote("workit git push")}, ${quote("workit release tag <vX.Y.Z>")} or ${quote("workit pr merge")}, or ask the user to run it.`;
16284
+ if (action.setting)
16285
+ return `workit: raw ${quote(`${action.forge} api`)} changes branch protection, a ruleset or the default branch on the forge directly: that guards what ${quote("workit git push")} and ${quote("workit pr merge")} may do, and no agent call changes it. Ask the user to change it in the forge's settings.`;
16286
+ const steers = [
16287
+ ...action.branch ? [
16288
+ `push a branch with ${quote("workit git push")} (it refuses protected branches and verifies the remote tip)`
16289
+ ] : [],
16290
+ ...action.tag ? [
16291
+ `tag a release with ${quote("workit release tag <vX.Y.Z>")} or ${quote("workit git push --release <tag>")}, under the ${quote("release")} grant`
16292
+ ] : []
16293
+ ];
16294
+ return `workit: raw ${quote(`${action.forge} api`)} writes ${action.ref ?? (action.tag && !action.branch ? "a tag" : action.branch && !action.tag ? "a branch" : "a ref")} on the forge directly, past workit's protected-branch check${action.tag ? " and the release grant" : ""}. Instead, ${steers.join("; ")}.`;
16295
+ };
15889
16296
  var refFacts = (repo, remote) => {
15890
16297
  const facts = {
15891
16298
  heads: new Set,
@@ -16034,6 +16441,7 @@ var nudgeFor = (action, host, session) => {
16034
16441
  case "pr-read":
16035
16442
  case "forge":
16036
16443
  case "merge":
16444
+ case "ref-write":
16037
16445
  return null;
16038
16446
  }
16039
16447
  };
@@ -16051,8 +16459,10 @@ var pushRefusal = (action, repo, config) => {
16051
16459
  return offPolicy;
16052
16460
  for (const target of targets) {
16053
16461
  const guarded = guardedTarget(repo.dir, target ?? repo.branch ?? "");
16054
- if (guarded)
16055
- return refusal(action, guarded, repo.dir);
16462
+ if (!guarded)
16463
+ continue;
16464
+ const first = !action.blindForce && !action.deletes && !facts.remoteHeads.has(guarded) ? ` ${remote} has no ${guarded} as last fetched: if it is a new, empty remote, ${quote("workit git push")} from ${guarded} makes that first push (it checks the remote first).` : "";
16465
+ return refusal(action, guarded, repo.dir) + first;
16056
16466
  }
16057
16467
  return tagRefusal(pushed, facts, repo.dir) ?? (action.deletes ? null : offPolicyPush(pushed, repo, facts, remote));
16058
16468
  };
@@ -16234,6 +16644,8 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
16234
16644
  try {
16235
16645
  guarded = !!repo.branch && resolveBranchPolicyFor(repo.dir).protected.has(repo.branch.toLowerCase());
16236
16646
  } catch {}
16647
+ if (guarded && !switches && noRefs(repo))
16648
+ return `workit: raw ${quote("git commit")} on ${repo.branch}, a protected branch. This repository has no commit yet, so its root commit may go there: run ${quote("workit git commit -m '<msg>' [--all | -- <paths>]")} (it adds the Workit-Session trailer; later work goes on a branch).`;
16237
16649
  if (guarded && !switches)
16238
16650
  return `workit: raw ${quote("git commit")} on ${repo.branch}, a protected branch. Branch first: ${quote("workit git branch --kind feature --slug <slug>")} (uncommitted changes come along), then ${quote("workit git commit -m '<msg>' -- <paths>")}.`;
16239
16651
  const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path25.resolve(input.cwd, invocation.dir), repo);
@@ -16243,6 +16655,8 @@ function rawGitPre(input, command, options = {}) {
16243
16655
  try {
16244
16656
  const dialect = dialectOf(input);
16245
16657
  const nudges = new Map;
16658
+ const prWrites = [];
16659
+ const asWritten = wordsOf(command, dialect);
16246
16660
  let store = null;
16247
16661
  const cache = new Map;
16248
16662
  const blind = rawInvocations(command, dialect).find((raw) => raw.redirect && rawAction(raw)?.kind === "push");
@@ -16263,8 +16677,19 @@ function rawGitPre(input, command, options = {}) {
16263
16677
  if (!workit)
16264
16678
  continue;
16265
16679
  store ??= repo.location.dir;
16266
- if (action.kind === "merge")
16267
- return deny(refusal(action, null));
16680
+ if (action.kind === "merge") {
16681
+ const retry = prRetry(input.cwd, repo, invocation, cache, asWritten);
16682
+ const named = !retry ? "" : oneCall(command, dialect) ? `
16683
+ Retry as: ${retry.call}` : ` Run ${quote(retry.call)} as its own call, in place of the raw one; the rest of this command is yours to run apart.`;
16684
+ return deny(`${refusal(action, null)}${named}`);
16685
+ }
16686
+ if (action.kind === "ref-write")
16687
+ return deny(refWriteRefusal(action));
16688
+ if (action.kind === "forge" && action.grant === "pr") {
16689
+ const retry = prRetry(input.cwd, repo, invocation, cache, asWritten);
16690
+ if (retry)
16691
+ prWrites.push(retry);
16692
+ }
16268
16693
  if (action.kind === "push") {
16269
16694
  const refused = pushRefusal(action, repo, gitConfig(repo.dir, invocation, cache));
16270
16695
  if (refused)
@@ -16274,6 +16699,8 @@ function rawGitPre(input, command, options = {}) {
16274
16699
  if (nudge && !nudges.has(nudgeKind(action)))
16275
16700
  nudges.set(nudgeKind(action), nudge);
16276
16701
  }
16702
+ if (prWrites.length)
16703
+ return deny(prWriteRefusal(prWrites, oneCall(command, dialect)));
16277
16704
  const pkill = options.nudge === false ? null : pkillSelfMatch(command, dialect);
16278
16705
  const pkillNote = pkill ? { kind: "context", text: pkill } : NONE2;
16279
16706
  if (options.nudge === false || !store || nudges.size === 0)
@@ -16357,6 +16784,8 @@ var grantRefusal = (action, repo, invocation, cache) => {
16357
16784
  kinds.push("pr");
16358
16785
  else if (action.kind === "forge")
16359
16786
  kinds.push(action.grant);
16787
+ else if (action.kind === "ref-write")
16788
+ kinds.push(...action.branch ? ["push"] : [], ...action.tag ? ["release"] : [], ...action.unread ? ["merge"] : []);
16360
16789
  for (const kind of kinds) {
16361
16790
  const denied = rawGrantDenial(repo.dir, kind, target);
16362
16791
  if (denied)
@@ -16364,6 +16793,21 @@ var grantRefusal = (action, repo, invocation, cache) => {
16364
16793
  }
16365
16794
  return null;
16366
16795
  };
16796
+ var noRefs = (repo) => {
16797
+ const common = path25.dirname(repo.location.dir);
16798
+ const holds = (dir) => {
16799
+ try {
16800
+ return fs17.readdirSync(dir, { withFileTypes: true }).some((entry) => entry.isFile() || entry.isDirectory() && holds(path25.join(dir, entry.name)));
16801
+ } catch {
16802
+ return false;
16803
+ }
16804
+ };
16805
+ try {
16806
+ if (/ refs\//.test(fs17.readFileSync(path25.join(common, "packed-refs"), "utf8")))
16807
+ return false;
16808
+ } catch {}
16809
+ return fs17.existsSync(path25.join(common, "refs")) && !holds(path25.join(common, "refs"));
16810
+ };
16367
16811
  var localTag = (repo, name) => {
16368
16812
  const common = path25.dirname(repo.location.dir);
16369
16813
  try {
@@ -17574,8 +18018,7 @@ var linesOf = (command, dialect) => {
17574
18018
  return null;
17575
18019
  }
17576
18020
  };
17577
- var quoteWord = (word) => /^[\w@%+=:,./-]+$/u.test(word) ? word : `'${word.replaceAll("'", `'\\''`)}'`;
17578
- var leaseCommand = (words) => `workit check --heavy -- ${words.map(quoteWord).join(" ")}`;
18021
+ var leaseCommand = (words, word) => `workit check --heavy -- ${words.map(word).join(" ")}`;
17579
18022
  function heavyPlan(command, options) {
17580
18023
  const dialect = options.dialect ?? "posix";
17581
18024
  if (dialect !== "posix" || !gitTop(options.cwd))
@@ -17608,7 +18051,8 @@ function heavyPlan(command, options) {
17608
18051
  }));
17609
18052
  return rewrite ? { kind: "rewrite", command: rewrite, reason: single.reason } : { kind: "none" };
17610
18053
  }
17611
- const parts = heavy.map((match) => leaseCommand(match.line));
18054
+ const word = wordsOf(command, dialect);
18055
+ const parts = heavy.map((match) => leaseCommand(match.line, word));
17612
18056
  return {
17613
18057
  kind: "split",
17614
18058
  reason: `heavy_command: \`${command.trim()}\` chains heavy work (${heavy.map((match) => match.reason).join("; ")}) with other commands, and a chain cannot run under the machine-wide heavy-check lease. Run the heavy part alone, now: \`${parts[0]}\`; then run the other parts as their own commands${parts.length > 1 ? ", each heavy one the same way" : ""}.`,
@@ -17630,7 +18074,7 @@ function serverPlan(command, options) {
17630
18074
  const rewrite = leaseRewrite(command)?.replace("workit check --heavy --", "workit run --bg --");
17631
18075
  return rewrite ? { kind: "rewrite", command: rewrite, reason: single, server: true } : { kind: "none" };
17632
18076
  }
17633
- const start = `workit run --bg -- ${found.line.map(quoteWord).join(" ")}`;
18077
+ const start = `workit run --bg -- ${found.line.map(wordsOf(command, dialect)).join(" ")}`;
17634
18078
  return {
17635
18079
  kind: "split",
17636
18080
  reason: `dev_server: \`${command.trim()}\` chains a dev server (${found.reason}) with other commands. Start it alone, now: \`${start}\`; then run the other parts as their own commands.`,
@@ -18378,7 +18822,7 @@ var wrappedScript = (input) => {
18378
18822
  const script = shellScript3(tail.argv);
18379
18823
  if (SCRIPT_SHELLS.has((tail.argv[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase()) && script)
18380
18824
  return script;
18381
- return tail.argv.map(quoteWord2).join(" ");
18825
+ return tail.argv.map(quoteWord).join(" ");
18382
18826
  };
18383
18827
  var editsOf = (input) => {
18384
18828
  const words = pastLead(input);
@@ -19256,7 +19700,7 @@ var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
19256
19700
  return lost;
19257
19701
  return target === undefined ? os9.homedir() : path31.resolve(dir, target);
19258
19702
  };
19259
- var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
19703
+ var quoteWord = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
19260
19704
  var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
19261
19705
  const value = vars.get(bare ?? braced ?? "");
19262
19706
  return value === undefined ? whole : value;
@@ -19654,7 +20098,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
19654
20098
  targets.push(cmd && CMD_VAR.test(file) ? placeholderIn(dir, `${OPAQUE_TARGET}cmd`) : file);
19655
20099
  const bare = strict && depth < 4 ? unwrapped2(words) : null;
19656
20100
  if (bare?.length && dir !== undefined)
19657
- targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
20101
+ targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord).join(" "), "posix", depth + 1, strict, vars));
19658
20102
  if (strict === "registry" && dir !== undefined && depth < 4) {
19659
20103
  const run = words.slice(Math.max(0, words.findIndex((word) => !PREFIXES2.has(word))));
19660
20104
  const [verb = "", ...args] = run.map((word, index) => index ? word : (word.split(/[\\/]/).at(-1) ?? "").toLowerCase());
@@ -19789,7 +20233,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
19789
20233
  if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file) && !(dialect === "powershell" && /^(?:\$null|nul)$/i.test(file)))
19790
20234
  targets.push(...atAll(file));
19791
20235
  if (dir !== undefined)
19792
- for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
20236
+ for (const invocation of workitInvocations(body.map(quoteWord).join(" "), "posix")) {
19793
20237
  const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
19794
20238
  if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
19795
20239
  targets.push(...runsIn.map((runs) => placeholderIn(runs, DIR_TARGET)));
@@ -19798,7 +20242,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
19798
20242
  return targets;
19799
20243
  };
19800
20244
  var workitRunDir = (dir, words, resolve) => {
19801
- for (const invocation of workitInvocations(words.map(quoteWord2).join(" "), "posix")) {
20245
+ for (const invocation of workitInvocations(words.map(quoteWord).join(" "), "posix")) {
19802
20246
  const { at, args } = workitCwd(dir, invocation, resolve);
19803
20247
  if (args[0] === "check" || args[0] === "lock" && args[1] === "run")
19804
20248
  return at;
@@ -21108,6 +21552,7 @@ var FLAGS = {
21108
21552
  // packages/workit-core/src/approvals/inline.ts
21109
21553
  var DIR2 = "<dir>";
21110
21554
  var OPAQUE_RELEASE_FIX = `workit release --cwd ${DIR2} notes approve <version>`;
21555
+ var OPAQUE_RELEASE_FIRST = `workit release notes approve --cwd ${DIR2} <version>`;
21111
21556
 
21112
21557
  // packages/workit-core/src/hooks/hosts/claude-code.ts
21113
21558
  var CLAUDE_CODE_DESCRIPTOR = {
@@ -22387,7 +22832,7 @@ var workitCallDir = (command, dialect) => {
22387
22832
  const call = plainWorkitCall(command, dialect);
22388
22833
  return call?.cwd && path36.isAbsolute(call.cwd) ? call.cwd : null;
22389
22834
  };
22390
- var shellWord = (dir) => /^[\w@%+=:,./-]+$/u.test(dir) ? dir : `'${dir.replaceAll("'", `'\\''`)}'`;
22835
+ var shellWord2 = (dir) => /^[\w@%+=:,./-]+$/u.test(dir) ? dir : `'${dir.replaceAll("'", `'\\''`)}'`;
22391
22836
  var cwdAt = (words, index) => words[index] === "--cwd" && words[index + 1] !== undefined ? 2 : words[index]?.startsWith("--cwd=") ? 1 : 0;
22392
22837
  var plainRetry = (dir, command) => {
22393
22838
  const call = plainWorkitCall(command, "posix");
@@ -22436,7 +22881,7 @@ var plainRetry = (dir, command) => {
22436
22881
  if (parts.includes(null))
22437
22882
  return null;
22438
22883
  const [envText, globalText, verbText, restText] = parts;
22439
- const cwd = ["--cwd", shellWord(dir)];
22884
+ const cwd = ["--cwd", shellWord2(dir)];
22440
22885
  const body = [...globalText, ...verbText, ...cwd, ...restText];
22441
22886
  return { retry: [...envText, "workit", ...body].join(" "), dropped };
22442
22887
  };
@@ -24198,11 +24643,12 @@ var hinted = (write) => write.hint ? {
24198
24643
  plain: false,
24199
24644
  workit: write.hint
24200
24645
  } : write;
24201
- var ytrackArgs = (line, found, depth, names, plain) => {
24646
+ var ytrackArgs = (line, found, depth, names, plain, expands = () => false) => {
24202
24647
  const inner = (script) => void found.push(...ytrackWrites(script, "posix", depth + 1, plain));
24203
24648
  const tail = workitCheckTail(line);
24204
24649
  if (tail) {
24205
- inner("script" in tail ? tail.script : tail.argv.map(quote2).join(" "));
24650
+ const live = (text) => expands(text) && /[$`]/.test(text) ? `"${text.replaceAll(/["\\]/g, "\\$&")}"` : quote2(text);
24651
+ inner("script" in tail ? tail.script : tail.argv.map(live).join(" "));
24206
24652
  return true;
24207
24653
  }
24208
24654
  const flag = SHELLS3.test(name2(line[0])) ? line.findIndex((word, index) => index > 0 && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(word)) : -1;
@@ -24232,8 +24678,9 @@ var ytrackArgs = (line, found, depth, names, plain) => {
24232
24678
  const argv = [...alias ?? [], ...line.slice(at + 1)];
24233
24679
  const write = classify(argv);
24234
24680
  if (write) {
24681
+ const word = (text) => plain ? quote2(text) : shellWord(text, expands(text));
24235
24682
  const one = {
24236
- command: ["ytrack", ...argv].map(quote2).join(" "),
24683
+ command: ["ytrack", ...argv].map(word).join(" "),
24237
24684
  ...write,
24238
24685
  ...hostsOf(argv),
24239
24686
  plain
@@ -24336,14 +24783,15 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
24336
24783
  let found = [];
24337
24784
  const lines = plain ? plainLines(command, dialect) : null;
24338
24785
  const none = new Map;
24786
+ const expands = expandsIn(command, dialect);
24339
24787
  const plainFirst = lines ? ytrackArgs(lines.first, found, depth, none, true) : false;
24340
24788
  const joined = lines && plainFirst ? chained(found, lines.chain, depth) : null;
24341
24789
  if (joined)
24342
24790
  found = joined;
24343
- if (!lines || !plainFirst || !(joined ? [] : lines.chain).every((line) => ytrackArgs(line, found, depth, none, false)) || !lines.later.every((line) => ytrackArgs(line, found, depth, none, false))) {
24791
+ if (!lines || !plainFirst || !(joined ? [] : lines.chain).every((line) => ytrackArgs(line, found, depth, none, false, expands)) || !lines.later.every((line) => ytrackArgs(line, found, depth, none, false, expands))) {
24344
24792
  found = [];
24345
24793
  for (const line of commandLines(command, dialect))
24346
- ytrackArgs(line, found, depth, aliases(command), false);
24794
+ ytrackArgs(line, found, depth, aliases(command), false, expands);
24347
24795
  found = found.map(hinted);
24348
24796
  }
24349
24797
  READ.set(key, found);
@@ -24353,7 +24801,7 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
24353
24801
  };
24354
24802
  var RELOCATES = /(?<![$\w])YTRACK_CONFIG_DIR\b/;
24355
24803
  var reachesOnly = (allowed, write) => write.plain && !!write.hosts?.length && write.hosts.every((host) => youTrackHostAllowed(allowed, host));
24356
- var scopedGate = (allowed, command, writes) => {
24804
+ var scopedGate = (allowed, command, dialect, writes) => {
24357
24805
  const scope = `youtrack.autoHosts (${allowed.join(", ")})`;
24358
24806
  if (RELOCATES.test(command))
24359
24807
  return {
@@ -24368,8 +24816,10 @@ var scopedGate = (allowed, command, writes) => {
24368
24816
  if (!unnamed.length)
24369
24817
  return null;
24370
24818
  const why = (write) => write.hosts === null ? "its --host is no literal host" : !write.hosts.length ? "it names no --host" : "it is not a plain command of its own";
24371
- const bare = unnamed.find((write) => write.bare)?.bare;
24372
- const retry = bare ? ["ytrack", "--host", first, ...bare].map(quote2).join(" ") : null;
24819
+ const hostless = unnamed.find((each) => each.bare);
24820
+ const expands = expandsIn(command, dialect);
24821
+ const word = (text) => hostless?.plain ? quote2(text) : shellWord(text, expands(text));
24822
+ const retry = hostless?.bare ? ["ytrack", "--host", first, ...hostless.bare].map(word).join(" ") : null;
24373
24823
  return {
24374
24824
  kind: "deny",
24375
24825
  reason: `${scope} posts to YouTrack unasked only from a plain ytrack call that names an allowed host with --host: ${unnamed.map((write) => `\`${write.command}\` (${why(write)})`).join(", ")}. Name the host, as its own plain call.${retry ? `
@@ -24405,7 +24855,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
24405
24855
  const hosts = policy.hosts;
24406
24856
  if (hosts === null)
24407
24857
  return null;
24408
- const scoped = scopedGate(hosts, command, writes);
24858
+ const scoped = scopedGate(hosts, command, dialect, writes);
24409
24859
  if (scoped)
24410
24860
  return scoped;
24411
24861
  writes = writes.filter((write) => !reachesOnly(hosts, write));
@@ -106,7 +106,7 @@ if (quiet) {
106
106
  `);
107
107
  } else {
108
108
  try {
109
- const { runCodexHook } = await import("./workit-hook-c07bsmex.js");
109
+ const { runCodexHook } = await import("./workit-hook-3g9ncas8.js");
110
110
  await runCodexHook([payload]);
111
111
  } catch (error) {
112
112
  const { answerRuntimeFailure } = await import("./workit-hook-8kebgc9b.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/codex",
3
- "version": "2.29.2",
3
+ "version": "2.29.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.29.2",
45
- "@workit-dev/mcp": "^2.29.2"
44
+ "@workit-dev/core": "^2.29.4",
45
+ "@workit-dev/mcp": "^2.29.4"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"
@@ -53,7 +53,7 @@ the same check. Fix round and recheck both failed: the decider agent (read the `
53
53
  with `workit check`, fix the root cause, batch every fix in one push, one focused commit per fix (unrelated hunks in one file: `workit git stage --patch <file>`, then `workit git commit -m "<msg>" --staged`). A tool warning is a finding: fix it in this PR in the right layer, or record the false positive with evidence; pre-existing ones get their own PR.
54
54
  6. **Verified.** The lane in `workit pr status` decides: none, no verdict; self, your `--self` verdict; focused or full (or `verification: self|independent`), one non-author verifier per PR after the last push, never per push (read the `workit-review` skill's SKILL.md and follow it), on Claude Code with the `model` and `effort` of `workit models show --role verifier`. A docs-only push (or test-only under a unit verdict) keeps the verdict (`carried`); `reverify: focused` re-checks only the new diff, reusing green CI; one verdict at a stack's top covers its unchanged lower PRs. Land only when
55
55
  granted: `workit stack land` or `workit pr merge`; `--unverified --reason` if user-asked.
56
- Never pipe a delivery verb through `grep`, `tail` or `head`: read its exit code, or use `--json`. Trunk CI after a merge: `workit ci wait --branch <trunk>`.
56
+ Never pipe a delivery verb through `grep`, `tail` or `head`: read its exit code, or use `--json`. Trunk CI after a merge: `workit ci wait --branch <trunk>`. Run each delivery verb alone, verb first (`workit pr merge --cwd <dir> …`), never chained. A classifier denial of a chained granted verb: rerun it once alone; a plain call denied: ask the user in chat, never hand it to their terminal.
57
57
  7. **Observe it landed:** `workit verify-delivery pr` or `merge`. After a failed
58
58
  verdict or a check red 3+ times, at any endpoint: offer `/wk-retro` in one
59
59
  line of the final or stop report; never pause the babysit loop for it.