@workit-dev/opencode 2.29.2 → 2.29.3

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.
Files changed (2) hide show
  1. package/dist/plugin.js +498 -51
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -21007,7 +21007,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
21007
21007
  for (const invocation of inside)
21008
21008
  found.push({ ...invocation, dir: rebase(dir, invocation.dir) });
21009
21009
  };
21010
- const visit = (input, stdin, hops) => {
21010
+ const visit = (input, stdin, hops, expands = "all") => {
21011
21011
  const line = /^\$[\w:]+$/.test(input[0] ?? "") && input[1] === "=" ? input.slice(2) : input;
21012
21012
  const split = splitString(line);
21013
21013
  if (split !== null)
@@ -21069,15 +21069,18 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
21069
21069
  nested(cmdScript(words), "powershell");
21070
21070
  else if (name === "xargs" || name === "find")
21071
21071
  runs(name === "xargs" ? xargsCommands(words, stdin) : findCommands(words));
21072
- else if (name === "gh" || name === "glab")
21072
+ else if (name === "gh" || name === "glab") {
21073
+ const shift = input.length - words.length + 1;
21074
+ const expanded = expands === "all" ? expands : expands.filter((at) => at >= shift).map((at) => at - shift);
21073
21075
  found.push({
21074
21076
  tool: name,
21075
21077
  dir,
21076
21078
  args: words.slice(1),
21077
21079
  ...Object.keys({ ...exported, ...env }).length ? { env: { ...exported, ...env } } : {},
21078
- ...stdin === undefined ? {} : { stdin }
21080
+ ...stdin === undefined ? {} : { stdin },
21081
+ ...expanded.length ? { expanded } : {}
21079
21082
  });
21080
- else if (name === "git") {
21083
+ } else if (name === "git") {
21081
21084
  const invocation = gitInvocation(words.slice(1), dir, { ...exported, ...env }, stdin, sessionConfig);
21082
21085
  found.push(invocation);
21083
21086
  sessionConfig.push(...configSetBy(invocation.args));
@@ -21110,7 +21113,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
21110
21113
  }
21111
21114
  const stdin = stdinOf(segment, segments[index - 1]);
21112
21115
  for (const line of substitute(segment.words, vars))
21113
- visit(line, stdin, 0);
21116
+ visit(line, stdin, 0, segment.expands ?? []);
21114
21117
  }
21115
21118
  return found;
21116
21119
  }
@@ -21405,55 +21408,232 @@ var API_VALUES = new Set(["--method", "--header", "--raw-field", "--field", "--j
21405
21408
  var API_SHORT_VALUES = "XHfFqtp";
21406
21409
  var API_FIELDS = new Set(["-f", "-F", "--raw-field", "--field"]);
21407
21410
  var API_MERGE = {
21408
- gh: /(?:^|\/)(?:pulls\/[^/?#]+\/merge|merges)\/?(?:[?#]|$)/i,
21409
- glab: /(?:^|\/)merge_requests\/[^/?#]+\/merge\/?(?:[?#]|$)/i
21411
+ gh: /(?:^|\/)(?:pulls\/[^/?#]+\/merge|merges)\/?$/i,
21412
+ glab: /(?:^|\/)merge_requests\/[^/?#]+\/merge\/?$/i
21410
21413
  };
21411
21414
  var GRAPHQL_MERGE = /\b(?:mergePullRequest|enablePullRequestAutoMerge|mergeBranch|mergeRequestAccept)\b/;
21412
- var apiAction = (tool, args, stdin) => {
21413
- const request = { method: null, body: false };
21415
+ var GH_REPO_PATH = String.raw`(?:^|\/)(?:repos\/[^/]+\/[^/]+|repositories\/[^/]+)`;
21416
+ var ghPath = (rest) => new RegExp(`${GH_REPO_PATH}\\/${rest}(?:\\/|$)`, "i");
21417
+ var called = (names) => new RegExp(String.raw`\b(?:${names})(?:[\s,\uFEFF]|#[^\n\r]*[\n\r])*\(`);
21418
+ var GRAPHQL_REF = [
21419
+ [called("createRef|updateRefs?|deleteRef"), "ref"],
21420
+ [
21421
+ called("createCommitOnBranch|createLinkedBranch|createBranch|branchDelete|commitCreate"),
21422
+ "branch"
21423
+ ],
21424
+ [called("tagCreate|tagDelete"), "tag"]
21425
+ ];
21426
+ var GRAPHQL_SETTING = called("(?:create|update|delete)(?:BranchProtectionRule|RepositoryRuleset)|branchRule(?:Create|Update|Delete)");
21427
+ var API_REF = {
21428
+ gh: [
21429
+ [ghPath(String.raw`git\/refs?`), "ref"],
21430
+ [ghPath(String.raw`(?:branches\/.+\/rename|merge-upstream|contents)`), "branch"]
21431
+ ],
21432
+ glab: [
21433
+ [/(?:^|\/)repository\/tags(?:\/|$)/i, "tag"],
21434
+ [/(?:^|\/)repository\/(?:branches|merged_branches|files|submodules)(?:\/|$)/i, "branch"],
21435
+ [/(?:^|\/)repository\/commits(?:\/[^/]+\/(?:cherry_pick|revert))?\/?$/i, "branch"]
21436
+ ]
21437
+ };
21438
+ var API_SETTING = {
21439
+ gh: [
21440
+ ghPath(String.raw`(?:branches\/.+|tags)\/protection`),
21441
+ ghPath("rulesets"),
21442
+ ghPath(String.raw`environments\/[^/]+\/deployment-branch-policies`),
21443
+ /(?:^|\/)orgs\/[^/]+\/rulesets(?:\/|$)/i
21444
+ ],
21445
+ glab: [
21446
+ /(?:^|\/)(?:projects|groups)\/[^/]+\/protected_(?:branches|tags)(?:\/|$)/i,
21447
+ /(?:^|\/)projects\/[^/]+\/push_rule(?:\/|$)/i
21448
+ ]
21449
+ };
21450
+ var API_REPOSITORY = {
21451
+ gh: new RegExp(`${GH_REPO_PATH}\\/?$`, "i"),
21452
+ glab: /(?:^|\/)projects\/[^/]+\/?$/i
21453
+ };
21454
+ var PLAIN_REF = /^refs\/(?:heads|tags)\/(?!.*\.\.)[^\s$`\\%]+$/;
21455
+ var BY_ID = called("updateRefs?|deleteRef");
21456
+ var createdRefs = (query) => {
21457
+ if (/[\\$]|"""/.test(query))
21458
+ return null;
21459
+ const tokens = query.match(/#[^\n\r]*|"[^"\n\r]*"|[_A-Za-z]\w*|[^\s,\uFEFF]/g) ?? [];
21460
+ const named = [];
21461
+ for (let at = 0;at < tokens.length; at++) {
21462
+ if (tokens[at] !== "createRef")
21463
+ continue;
21464
+ const args = tokens.slice(at + 1).filter((token) => !token.startsWith("#"));
21465
+ if (args[0] !== "(")
21466
+ continue;
21467
+ let depth = 0;
21468
+ const names = [];
21469
+ for (let index = 0;index < args.length; index++) {
21470
+ const token = args[index];
21471
+ if (token === "(" || token === "{" || token === "[")
21472
+ depth++;
21473
+ else if (token === ")" || token === "}" || token === "]") {
21474
+ if (--depth === 0)
21475
+ break;
21476
+ } else if (token === "name" && args[index + 1] === ":")
21477
+ names.push(args[index + 2] ?? "");
21478
+ }
21479
+ if (depth !== 0 || names.length !== 1 || !names[0].startsWith('"'))
21480
+ return null;
21481
+ named.push(names[0].slice(1, -1));
21482
+ }
21483
+ return named;
21484
+ };
21485
+ var provablyRead = (query) => /^[\s,\uFEFF]*(?:\{|query[\s,\uFEFF]*[({])/.test(query) && !/\b(?:mutation|subscription)\b/.test(query);
21486
+ var refWrite = (forge, shapes, named, certain) => {
21487
+ const sure = certain && named.length > 0 && named.every((ref) => PLAIN_REF.test(ref));
21488
+ const tags = !sure || named.some((ref) => ref.startsWith("refs/tags/"));
21489
+ const heads = !sure || named.some((ref) => ref.startsWith("refs/heads/"));
21490
+ const ref = shapes.has("ref");
21491
+ return {
21492
+ kind: "ref-write",
21493
+ forge,
21494
+ tag: shapes.has("tag") || ref && tags,
21495
+ branch: shapes.has("branch") || ref && heads,
21496
+ ...ref && sure ? { ref: named[0] } : {}
21497
+ };
21498
+ };
21499
+ var restRef = (route, fields, readable) => {
21500
+ const inPath = /\/git\/refs?\/(.+)$/i.exec(route)?.[1];
21501
+ if (inPath)
21502
+ return { named: [`refs/${inPath}`], certain: true };
21503
+ const refs = fields.filter((field) => field.startsWith("ref=")).map((field) => field.slice(4));
21504
+ const mentions = fields.filter((field) => /refs\//.test(field)).length;
21505
+ return { named: refs, certain: readable && refs.length === 1 && mentions === 1 };
21506
+ };
21507
+ var routeOf = (endpoint) => endpoint.replace(/(?<!:)\/{2,}/g, "/").replace(/[?#][\s\S]*$/, "").replace(/%([\da-f]{2})/gi, (escape, hex) => {
21508
+ const char = String.fromCodePoint(Number.parseInt(hex, 16));
21509
+ return /[\w.~-]/.test(char) ? char : escape;
21510
+ });
21511
+ var apiAction = (tool, args, stdin, expanded = []) => {
21512
+ const request = { method: null, body: false, input: false, unread: false };
21414
21513
  let endpoint = null;
21514
+ let endpointAt = -1;
21415
21515
  const values = [];
21416
- const take = (name, value) => {
21516
+ const fields = [];
21517
+ const queries = [];
21518
+ const field = (value, expands) => {
21519
+ fields.push(value);
21520
+ values.push(value);
21521
+ if (!value.startsWith("query="))
21522
+ return;
21523
+ const text = value.slice(6);
21524
+ const read = expanded !== "all" && (!(expands && /[$`]/.test(text)) || provablyRead(text));
21525
+ queries.push({ text, read });
21526
+ };
21527
+ const fromStdin = (name, value, text) => {
21528
+ if (name !== "--input") {
21529
+ if (text.includes("\\"))
21530
+ request.unread = true;
21531
+ return field(`${value.slice(0, value.indexOf("=") + 1)}${text}`, true);
21532
+ }
21533
+ values.push(text);
21534
+ let body;
21535
+ try {
21536
+ body = JSON.parse(text);
21537
+ } catch {
21538
+ request.unread = true;
21539
+ return;
21540
+ }
21541
+ const strings = (each) => typeof each === "string" ? [each] : each && typeof each === "object" ? Object.entries(each).flatMap(([key, inner]) => [key, ...strings(inner)]) : [];
21542
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
21543
+ values.push(...strings(body));
21544
+ return;
21545
+ }
21546
+ for (const [key, inner] of Object.entries(body)) {
21547
+ if (typeof inner === "string")
21548
+ field(`${key}=${inner}`, true);
21549
+ else
21550
+ values.push(key, ...strings(inner));
21551
+ }
21552
+ };
21553
+ const take = (name, value, at) => {
21554
+ const expands = expanded === "all" || expanded.includes(at);
21417
21555
  if (name === "-X" || name === "--method")
21418
21556
  request.method = value.toUpperCase();
21419
21557
  if (API_FIELDS.has(name) || name === "--input")
21420
21558
  request.body = true;
21421
- values.push(value);
21422
- const fromStdin = name === "--input" ? value === "-" : /^(?:[^=]*=)?@-$/.test(value);
21423
- if (fromStdin && stdin !== undefined)
21424
- values.push(stdin);
21559
+ if (name === "--input")
21560
+ request.input = true;
21561
+ const piped = name === "--input" ? value === "-" : /^(?:-F|--field)$/.test(name) && /^[^=]*=@-$/.test(value);
21562
+ if (piped && stdin !== undefined) {
21563
+ values.push(value);
21564
+ return fromStdin(name, value, stdin);
21565
+ }
21566
+ if (API_FIELDS.has(name))
21567
+ field(value, expands);
21568
+ else
21569
+ values.push(value);
21570
+ const file = name === "--input" || /^(?:-F|--field)$/.test(name) && /^[^=]*=@/.test(value);
21571
+ if (file)
21572
+ request.unread = true;
21425
21573
  };
21426
21574
  for (let index = 1;index < args.length; index++) {
21427
21575
  const arg = args[index];
21428
21576
  if (arg === "--") {
21429
- endpoint ??= args[index + 1] ?? null;
21577
+ if (endpoint === null)
21578
+ [endpoint, endpointAt] = [args[index + 1] ?? null, index + 1];
21430
21579
  break;
21431
21580
  }
21432
21581
  if (arg.startsWith("--")) {
21433
21582
  const eq = arg.indexOf("=");
21434
21583
  const name = eq > 0 ? arg.slice(0, eq) : arg;
21435
21584
  if (API_VALUES.has(name))
21436
- take(name, eq > 0 ? arg.slice(eq + 1) : args[++index] ?? "");
21585
+ take(name, eq > 0 ? arg.slice(eq + 1) : args[++index] ?? "", index);
21437
21586
  } else if (arg.startsWith("-") && arg.length > 1) {
21438
21587
  for (let at = 1;at < arg.length; at++) {
21439
21588
  if (!API_SHORT_VALUES.includes(arg[at]))
21440
21589
  continue;
21441
- take(`-${arg[at]}`, at + 1 < arg.length ? arg.slice(at + 1) : args[++index] ?? "");
21590
+ take(`-${arg[at]}`, at + 1 < arg.length ? arg.slice(at + 1) : args[++index] ?? "", index);
21442
21591
  break;
21443
21592
  }
21444
- } else
21445
- endpoint ??= arg;
21593
+ } else if (endpoint === null)
21594
+ [endpoint, endpointAt] = [arg, index];
21446
21595
  }
21447
21596
  if (!endpoint)
21448
21597
  return null;
21449
- endpoint = endpoint.replace(/(?<!:)\/{2,}/g, "/");
21598
+ const atEndpoint = expanded === "all" || expanded.includes(endpointAt);
21599
+ for (const pair of /[?]([^#]*)/.exec(endpoint)?.[1].split("&") ?? []) {
21600
+ let decoded = pair;
21601
+ try {
21602
+ decoded = decodeURIComponent(pair.replaceAll("+", " "));
21603
+ } catch {
21604
+ request.unread = true;
21605
+ }
21606
+ field(decoded, atEndpoint);
21607
+ if (/refs\//i.test(decoded))
21608
+ request.input = true;
21609
+ }
21610
+ const route = routeOf(endpoint);
21450
21611
  const merge = { kind: "merge", forge: tool, via: "api" };
21451
- if (/(?:^|\/)graphql\/?$/i.test(endpoint))
21452
- return values.some((value) => GRAPHQL_MERGE.test(value)) ? merge : null;
21612
+ const setting = {
21613
+ kind: "ref-write",
21614
+ forge: tool,
21615
+ tag: false,
21616
+ branch: true,
21617
+ setting: true
21618
+ };
21619
+ if (/(?:^|\/)graphql\/?$/i.test(route)) {
21620
+ if (request.unread || queries.some((query) => !query.read))
21621
+ return { kind: "ref-write", forge: tool, tag: true, branch: true, unread: true };
21622
+ if (values.some((value) => GRAPHQL_MERGE.test(value)))
21623
+ return merge;
21624
+ if (values.some((value) => GRAPHQL_SETTING.test(value)))
21625
+ return setting;
21626
+ const shapes = new Set(GRAPHQL_REF.filter(([pattern]) => values.some((value) => pattern.test(value))).map(([, shape]) => shape));
21627
+ if (!shapes.size)
21628
+ return null;
21629
+ const created = queries.map((query) => createdRefs(query.text));
21630
+ const certain = !values.some((value) => BY_ID.test(value)) && created.every((named) => named !== null);
21631
+ return refWrite(tool, shapes, created.flatMap((named) => named ?? []), certain);
21632
+ }
21453
21633
  const verb = request.method ?? (request.body ? "POST" : "GET");
21454
21634
  if (verb === "GET" || verb === "HEAD")
21455
21635
  return null;
21456
- const named = tool === "gh" ? /(?:^|\/)repos\/([^/{]+\/[^/{]+)\//i.exec(endpoint)?.[1] : /(?:^|\/)projects\/([^/]+)\//i.exec(endpoint)?.[1];
21636
+ const named = tool === "gh" ? /(?:^|\/)repos\/([^/{]+\/[^/{]+)(?:\/|$)/i.exec(route)?.[1] ?? (/(?:^|\/)repositories\/[^/]+(?:\/|$)/i.test(route) ? "?" : undefined) : /(?:^|\/)projects\/([^/]+)(?:\/|$)/i.exec(route)?.[1];
21457
21637
  let repo;
21458
21638
  try {
21459
21639
  repo = named === undefined ? undefined : decodeURIComponent(named) || "?";
@@ -21461,9 +21641,17 @@ var apiAction = (tool, args, stdin) => {
21461
21641
  repo = "?";
21462
21642
  }
21463
21643
  const at = repo === undefined ? {} : { repo };
21464
- if (API_MERGE[tool].test(endpoint))
21644
+ if (API_MERGE[tool].test(route))
21465
21645
  return { ...merge, ...at };
21466
- const grant = /\/releases(?:\/|$|\?)/i.test(endpoint) ? "release" : (tool === "gh" ? /\/pulls(?:\/\d+)?\/?(?:\?|$)/i : /\/merge_requests(?:\/\d+)?\/?(?:\?|$)/i).test(endpoint) ? "pr" : null;
21646
+ const defaultBranch = API_REPOSITORY[tool].test(route) && (request.unread || values.some((value) => /default_branch/.test(value)));
21647
+ if (defaultBranch || API_SETTING[tool].some((pattern) => pattern.test(route)))
21648
+ return { ...setting, ...at };
21649
+ const shape = API_REF[tool].find(([pattern]) => pattern.test(route))?.[1];
21650
+ if (shape) {
21651
+ const { named: refs, certain } = restRef(route, fields, !request.unread && !request.input);
21652
+ return { ...refWrite(tool, new Set([shape]), refs, certain), ...at };
21653
+ }
21654
+ const grant = /\/releases(?:\/|$)/i.test(route) ? "release" : (tool === "gh" ? /\/pulls(?:\/\d+)?\/?$/i : /\/merge_requests(?:\/\d+)?\/?$/i).test(route) ? "pr" : null;
21467
21655
  return grant ? { kind: "forge", forge: tool, grant, ...at } : null;
21468
21656
  };
21469
21657
  var subtreePush = (args) => {
@@ -21481,7 +21669,7 @@ var subtreePush = (args) => {
21481
21669
  function rawAction(invocation) {
21482
21670
  const args = invocation.args;
21483
21671
  if (invocation.tool !== "git" && args[0] === "api")
21484
- return apiAction(invocation.tool, args, invocation.stdin);
21672
+ return apiAction(invocation.tool, args, invocation.stdin, invocation.expanded);
21485
21673
  if (asksHelp(invocation))
21486
21674
  return null;
21487
21675
  const [first] = args;
@@ -21757,6 +21945,223 @@ var refusal = (action, branch, dir) => {
21757
21945
  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")}.`;
21758
21946
  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")}.`;
21759
21947
  };
21948
+ var PLAIN_EXPANSION = /^(?:[^$`]|\$[A-Za-z_]\w*|\$\{[A-Za-z_]\w*\})*$/u;
21949
+ var shellWord = (text, expands = false) => {
21950
+ if (/^[\w@%+=:,./-]+$/u.test(text))
21951
+ return text;
21952
+ if (expands && text.includes("$") && PLAIN_EXPANSION.test(text))
21953
+ return `"${text.replaceAll(/["\\]/gu, "\\$&")}"`;
21954
+ return `'${text.replaceAll("'", "'\\''")}'`;
21955
+ };
21956
+ var expandingWords = (command, dialect, found = new Set, depth = 0) => {
21957
+ for (const segment of segmentsOf(command, dialect))
21958
+ segment.words.forEach((text, index) => {
21959
+ if (segment.expands?.includes(index))
21960
+ found.add(text);
21961
+ else if (depth < MAX_DEPTH && /\s/u.test(text))
21962
+ expandingWords(text, "posix", found, depth + 1);
21963
+ });
21964
+ return found;
21965
+ };
21966
+ var wordsOf = (command, dialect = "posix") => {
21967
+ const expands = expandsIn(command, dialect);
21968
+ return (text) => shellWord(text, expands(text));
21969
+ };
21970
+ var expandsIn = (command, dialect = "posix") => {
21971
+ let expanding;
21972
+ return (text) => (expanding ??= expandingWords(command, dialect)).has(text);
21973
+ };
21974
+ var oneCall = (command, dialect) => {
21975
+ const steps = /^(?:\s*cd\s+[^\s;&|<>()$`'"\\]+\s*&&)*([\s\S]*)$/u.exec(command);
21976
+ return !!steps && !!simpleCommand(steps[1], dialect);
21977
+ };
21978
+ var flagWord = (flag, value, asWritten) => value.startsWith("-") ? [`${flag}=${asWritten(value)}`] : [flag, asWritten(value)];
21979
+ var PR_FLAGS = {
21980
+ "gh ready": { verb: "ready", booleans: { "--undo": ["--undo"] }, values: {} },
21981
+ "gh merge": {
21982
+ verb: "merge",
21983
+ booleans: {
21984
+ "--squash": ["--squash"],
21985
+ "-s": ["--squash"],
21986
+ "--merge": ["--merge"],
21987
+ "-m": ["--merge"],
21988
+ "--rebase": ["--rebase"],
21989
+ "-r": ["--rebase"],
21990
+ "--delete-branch": ["--delete-branch"],
21991
+ "-d": ["--delete-branch"]
21992
+ },
21993
+ values: {
21994
+ "--subject": { flag: "--subject" },
21995
+ "-t": { flag: "--subject" },
21996
+ "--body": { flag: "--body" },
21997
+ "-b": { flag: "--body" },
21998
+ "--body-file": { flag: "--body-file" },
21999
+ "-F": { flag: "--body-file" }
22000
+ }
22001
+ },
22002
+ "gh edit": {
22003
+ verb: "edit",
22004
+ booleans: {},
22005
+ values: {
22006
+ "--title": { flag: "--title" },
22007
+ "-t": { flag: "--title" },
22008
+ "--body-file": { flag: "--body-file" },
22009
+ "-F": { flag: "--body-file" },
22010
+ "--add-label": { flag: "--add-label", split: true },
22011
+ "--remove-label": { flag: "--remove-label", split: true },
22012
+ "--add-reviewer": { flag: "--add-reviewer", split: true },
22013
+ "--base": { flag: "--base" },
22014
+ "-B": { flag: "--base" }
22015
+ }
22016
+ },
22017
+ "glab merge": {
22018
+ verb: "merge",
22019
+ booleans: {
22020
+ "--squash": ["--squash"],
22021
+ "-s": ["--squash"],
22022
+ "--rebase": ["--rebase"],
22023
+ "-r": ["--rebase"],
22024
+ "--remove-source-branch": ["--delete-branch"],
22025
+ "-d": ["--delete-branch"],
22026
+ "--yes": [],
22027
+ "-y": []
22028
+ },
22029
+ values: {}
22030
+ },
22031
+ "glab update": {
22032
+ verb: "edit",
22033
+ booleans: { "--ready": [], "-r": [], "--draft": ["--undo"], "--yes": [], "-y": [] },
22034
+ values: {
22035
+ "--title": { flag: "--title" },
22036
+ "-t": { flag: "--title" },
22037
+ "--label": { flag: "--add-label", split: true },
22038
+ "-l": { flag: "--add-label", split: true },
22039
+ "--unlabel": { flag: "--remove-label", split: true },
22040
+ "-u": { flag: "--remove-label", split: true },
22041
+ "--target-branch": { flag: "--base" }
22042
+ }
22043
+ }
22044
+ };
22045
+ var prRetry = (cwd, repo, invocation, cache, asWritten) => {
22046
+ const forge = invocation.tool;
22047
+ if (forge === "git")
22048
+ return null;
22049
+ const values = VALUE_OPTIONS[forge];
22050
+ const args = invocation.args;
22051
+ let verb;
22052
+ let at = 1;
22053
+ for (;at < args.length; at++) {
22054
+ if (!args[at].startsWith("-")) {
22055
+ verb = args[at];
22056
+ break;
22057
+ }
22058
+ if (values.has(args[at]))
22059
+ at++;
22060
+ }
22061
+ const table = PR_FLAGS[`${forge} ${verb}`];
22062
+ if (!table)
22063
+ return null;
22064
+ const words = [];
22065
+ const repos = [];
22066
+ let selector;
22067
+ let ready = false;
22068
+ const rest = [...args.slice(1, at), ...args.slice(at + 1)];
22069
+ for (let index = 0;index < rest.length; index++) {
22070
+ const arg = rest[index];
22071
+ const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
22072
+ const name = eq > 0 ? arg.slice(0, eq) : arg;
22073
+ const value = () => eq > 0 ? arg.slice(eq + 1) : rest[++index];
22074
+ if (name === "-R" || name === "--repo") {
22075
+ const named = value();
22076
+ if (named === undefined)
22077
+ return null;
22078
+ repos.push(named);
22079
+ } else if (/^-R./.test(arg))
22080
+ repos.push(arg.slice(2).replace(/^=/, ""));
22081
+ else if (eq < 0 && Object.hasOwn(table.booleans, arg)) {
22082
+ if (forge === "glab" && (arg === "--ready" || arg === "-r" || arg === "--draft")) {
22083
+ if (ready && words.includes("--undo") !== (arg === "--draft"))
22084
+ return null;
22085
+ ready = true;
22086
+ }
22087
+ words.push(...table.booleans[arg]);
22088
+ } else if (Object.hasOwn(table.values, name)) {
22089
+ const given = value();
22090
+ if (given === undefined)
22091
+ return null;
22092
+ const { flag, split } = table.values[name];
22093
+ if (split && given.includes(",") && /[$`]/.test(given))
22094
+ return null;
22095
+ for (const item of split ? given.split(",").filter(Boolean) : [given])
22096
+ words.push(...flagWord(flag, item, asWritten));
22097
+ } else if (arg.startsWith("-") || selector !== undefined)
22098
+ return null;
22099
+ else
22100
+ selector = arg;
22101
+ }
22102
+ const workitVerb = ready ? "ready" : table.verb;
22103
+ if (ready && words.some((word) => word !== "--undo"))
22104
+ return null;
22105
+ const pr = [];
22106
+ if (selector !== undefined) {
22107
+ const url = /^(https?:\/\/[^/]+\/.+?)\/(?:-\/)?(?:pull|merge_requests)\/(\d+)(?:[/?#].*)?$/.exec(selector);
22108
+ const number = url?.[2] ?? /^[#!]?(\d+)$/.exec(selector)?.[1];
22109
+ if (url)
22110
+ repos.push(url[1]);
22111
+ if (number)
22112
+ pr.push("--pr", number);
22113
+ else if (/\$[A-Za-z_{]/.test(selector))
22114
+ pr.push("--pr", asWritten(selector));
22115
+ else if (selector !== repo.branch)
22116
+ return null;
22117
+ }
22118
+ const env = invocation.env ?? {};
22119
+ if (forge === "gh" && (env.GH_REPO ?? process.env.GH_REPO))
22120
+ repos.push(env.GH_REPO ?? process.env.GH_REPO ?? "");
22121
+ if (repos.length) {
22122
+ const config = gitConfig(repo.dir, invocation, cache);
22123
+ const { GH_REPO: _named, ...own } = env;
22124
+ const key = (named, from) => {
22125
+ const found = forgeRepo(forge === "gh", named, from, config, repo.branch, repo.dir);
22126
+ return found instanceof Error ? null : found.remotes[0]?.key.toLowerCase() ?? null;
22127
+ };
22128
+ const checkout = key("", own);
22129
+ if (!checkout || repos.some((named) => /[$`]/.test(named) || key(named, own) !== checkout))
22130
+ return null;
22131
+ }
22132
+ const dir = path31.resolve(cwd, invocation.dir ?? ".");
22133
+ const call = [
22134
+ `workit pr ${workitVerb}`,
22135
+ ...dir === path31.resolve(cwd) ? [] : ["--cwd", shellWord(dir)],
22136
+ ...pr,
22137
+ ...words
22138
+ ].join(" ");
22139
+ return { raw: `${forge} ${forge === "gh" ? "pr" : "mr"} ${verb}`, call };
22140
+ };
22141
+ var prWriteRefusal = (writes, retry) => {
22142
+ const raws = [...new Set(writes.map((write) => quote(write.raw)))].join(", ");
22143
+ const calls = writes.map((write) => quote(write.call)).join(", ");
22144
+ const why = `workit: raw ${raws} changes the PR past workit's checks (the pr grant, and that the PR is this session's own).`;
22145
+ if (retry && writes.length === 1)
22146
+ return `${why} Run ${calls} instead.
22147
+ Retry as: ${writes[0].call}`;
22148
+ 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.`;
22149
+ };
22150
+ var refWriteRefusal = (action) => {
22151
+ if (action.unread)
22152
+ 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.`;
22153
+ if (action.setting)
22154
+ 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.`;
22155
+ const steers = [
22156
+ ...action.branch ? [
22157
+ `push a branch with ${quote("workit git push")} (it refuses protected branches and verifies the remote tip)`
22158
+ ] : [],
22159
+ ...action.tag ? [
22160
+ `tag a release with ${quote("workit release tag <vX.Y.Z>")} or ${quote("workit git push --release <tag>")}, under the ${quote("release")} grant`
22161
+ ] : []
22162
+ ];
22163
+ 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("; ")}.`;
22164
+ };
21760
22165
  var refFacts = (repo, remote) => {
21761
22166
  const facts = {
21762
22167
  heads: new Set,
@@ -21905,6 +22310,7 @@ var nudgeFor = (action, host, session) => {
21905
22310
  case "pr-read":
21906
22311
  case "forge":
21907
22312
  case "merge":
22313
+ case "ref-write":
21908
22314
  return null;
21909
22315
  }
21910
22316
  };
@@ -21922,8 +22328,10 @@ var pushRefusal = (action, repo, config) => {
21922
22328
  return offPolicy;
21923
22329
  for (const target of targets) {
21924
22330
  const guarded = guardedTarget(repo.dir, target ?? repo.branch ?? "");
21925
- if (guarded)
21926
- return refusal(action, guarded, repo.dir);
22331
+ if (!guarded)
22332
+ continue;
22333
+ 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).` : "";
22334
+ return refusal(action, guarded, repo.dir) + first;
21927
22335
  }
21928
22336
  return tagRefusal(pushed, facts, repo.dir) ?? (action.deletes ? null : offPolicyPush(pushed, repo, facts, remote));
21929
22337
  };
@@ -22105,6 +22513,8 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
22105
22513
  try {
22106
22514
  guarded = !!repo.branch && resolveBranchPolicyFor(repo.dir).protected.has(repo.branch.toLowerCase());
22107
22515
  } catch {}
22516
+ if (guarded && !switches && noRefs(repo))
22517
+ 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).`;
22108
22518
  if (guarded && !switches)
22109
22519
  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>")}.`;
22110
22520
  const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path31.resolve(input.cwd, invocation.dir), repo);
@@ -22114,6 +22524,8 @@ function rawGitPre(input, command, options = {}) {
22114
22524
  try {
22115
22525
  const dialect = dialectOf(input);
22116
22526
  const nudges = new Map;
22527
+ const prWrites = [];
22528
+ const asWritten = wordsOf(command, dialect);
22117
22529
  let store = null;
22118
22530
  const cache = new Map;
22119
22531
  const blind = rawInvocations(command, dialect).find((raw) => raw.redirect && rawAction(raw)?.kind === "push");
@@ -22134,8 +22546,19 @@ function rawGitPre(input, command, options = {}) {
22134
22546
  if (!workit)
22135
22547
  continue;
22136
22548
  store ??= repo.location.dir;
22137
- if (action.kind === "merge")
22138
- return deny(refusal(action, null));
22549
+ if (action.kind === "merge") {
22550
+ const retry = prRetry(input.cwd, repo, invocation, cache, asWritten);
22551
+ const named = !retry ? "" : oneCall(command, dialect) ? `
22552
+ 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.`;
22553
+ return deny(`${refusal(action, null)}${named}`);
22554
+ }
22555
+ if (action.kind === "ref-write")
22556
+ return deny(refWriteRefusal(action));
22557
+ if (action.kind === "forge" && action.grant === "pr") {
22558
+ const retry = prRetry(input.cwd, repo, invocation, cache, asWritten);
22559
+ if (retry)
22560
+ prWrites.push(retry);
22561
+ }
22139
22562
  if (action.kind === "push") {
22140
22563
  const refused = pushRefusal(action, repo, gitConfig(repo.dir, invocation, cache));
22141
22564
  if (refused)
@@ -22145,6 +22568,8 @@ function rawGitPre(input, command, options = {}) {
22145
22568
  if (nudge && !nudges.has(nudgeKind(action)))
22146
22569
  nudges.set(nudgeKind(action), nudge);
22147
22570
  }
22571
+ if (prWrites.length)
22572
+ return deny(prWriteRefusal(prWrites, oneCall(command, dialect)));
22148
22573
  const pkill = options.nudge === false ? null : pkillSelfMatch(command, dialect);
22149
22574
  const pkillNote = pkill ? { kind: "context", text: pkill } : NONE2;
22150
22575
  if (options.nudge === false || !store || nudges.size === 0)
@@ -22228,6 +22653,8 @@ var grantRefusal = (action, repo, invocation, cache) => {
22228
22653
  kinds.push("pr");
22229
22654
  else if (action.kind === "forge")
22230
22655
  kinds.push(action.grant);
22656
+ else if (action.kind === "ref-write")
22657
+ kinds.push(...action.branch ? ["push"] : [], ...action.tag ? ["release"] : [], ...action.unread ? ["merge"] : []);
22231
22658
  for (const kind of kinds) {
22232
22659
  const denied = rawGrantDenial(repo.dir, kind, target);
22233
22660
  if (denied)
@@ -22235,6 +22662,21 @@ var grantRefusal = (action, repo, invocation, cache) => {
22235
22662
  }
22236
22663
  return null;
22237
22664
  };
22665
+ var noRefs = (repo) => {
22666
+ const common = path31.dirname(repo.location.dir);
22667
+ const holds = (dir) => {
22668
+ try {
22669
+ return fs22.readdirSync(dir, { withFileTypes: true }).some((entry) => entry.isFile() || entry.isDirectory() && holds(path31.join(dir, entry.name)));
22670
+ } catch {
22671
+ return false;
22672
+ }
22673
+ };
22674
+ try {
22675
+ if (/ refs\//.test(fs22.readFileSync(path31.join(common, "packed-refs"), "utf8")))
22676
+ return false;
22677
+ } catch {}
22678
+ return fs22.existsSync(path31.join(common, "refs")) && !holds(path31.join(common, "refs"));
22679
+ };
22238
22680
  var localTag = (repo, name) => {
22239
22681
  const common = path31.dirname(repo.location.dir);
22240
22682
  try {
@@ -27445,8 +27887,7 @@ var linesOf = (command, dialect) => {
27445
27887
  return null;
27446
27888
  }
27447
27889
  };
27448
- var quoteWord = (word) => /^[\w@%+=:,./-]+$/u.test(word) ? word : `'${word.replaceAll("'", `'\\''`)}'`;
27449
- var leaseCommand = (words) => `workit check --heavy -- ${words.map(quoteWord).join(" ")}`;
27890
+ var leaseCommand = (words, word) => `workit check --heavy -- ${words.map(word).join(" ")}`;
27450
27891
  function heavyPlan(command, options) {
27451
27892
  const dialect = options.dialect ?? "posix";
27452
27893
  if (dialect !== "posix" || !gitTop(options.cwd))
@@ -27479,7 +27920,8 @@ function heavyPlan(command, options) {
27479
27920
  }));
27480
27921
  return rewrite ? { kind: "rewrite", command: rewrite, reason: single.reason } : { kind: "none" };
27481
27922
  }
27482
- const parts = heavy.map((match) => leaseCommand(match.line));
27923
+ const word = wordsOf(command, dialect);
27924
+ const parts = heavy.map((match) => leaseCommand(match.line, word));
27483
27925
  return {
27484
27926
  kind: "split",
27485
27927
  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" : ""}.`,
@@ -27501,7 +27943,7 @@ function serverPlan(command, options) {
27501
27943
  const rewrite = leaseRewrite(command)?.replace("workit check --heavy --", "workit run --bg --");
27502
27944
  return rewrite ? { kind: "rewrite", command: rewrite, reason: single, server: true } : { kind: "none" };
27503
27945
  }
27504
- const start = `workit run --bg -- ${found.line.map(quoteWord).join(" ")}`;
27946
+ const start = `workit run --bg -- ${found.line.map(wordsOf(command, dialect)).join(" ")}`;
27505
27947
  return {
27506
27948
  kind: "split",
27507
27949
  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.`,
@@ -27536,7 +27978,7 @@ function leaseRewrite(command) {
27536
27978
  import fs27 from "node:fs";
27537
27979
  import path40 from "node:path";
27538
27980
  var HEAVY_WORDS = new Set(("npm npx pnpm pnpx yarn bun bunx deno corepack make gmake docker podman nerdctl " + "python python3 py uv poetry pdm pipenv hatch rye bundle rake nx " + "jest vitest mocha ava tap karma jasmine nyc c8 tsc vue-tsc svelte-check eslint stylelint " + "tslint webpack webpack-cli rollup parcel tsup vite next nuxt nuxi astro ng react-scripts " + "playwright cypress wdio testcafe turbo lerna sonar-scanner sonarless sonarless-mcp go " + "golangci-lint gotestsum staticcheck cargo mvn mvnw gradle gradlew ant sbt bazel bazelisk " + "buck2 dotnet msbuild pytest py.test tox nox mypy pyright pylint coverage maturin pip pip3 " + "rspec rails phpunit pest phpstan psalm composer mix swift xcodebuild flutter dart pod cmake " + "ninja meson ctest scons docker-compose buildah earthly").split(" "));
27539
- var wordsOf = (command) => command.split(/[\s;&|()<>`'"]+/u).map((word) => (word.split(/[\\/]/u).at(-1) ?? "").toLowerCase().replace(/\.(?:exe|cmd|bat)$/u, "")).filter(Boolean);
27981
+ var wordsOf2 = (command) => command.split(/[\s;&|()<>`'"]+/u).map((word) => (word.split(/[\\/]/u).at(-1) ?? "").toLowerCase().replace(/\.(?:exe|cmd|bat)$/u, "")).filter(Boolean);
27540
27982
  var stateDir3 = (env) => stateDir(env);
27541
27983
  var readJson2 = (file) => {
27542
27984
  try {
@@ -27562,7 +28004,7 @@ var patternWords = (cwd, env) => {
27562
28004
  for (const pattern of patterns) {
27563
28005
  if (typeof pattern !== "string")
27564
28006
  continue;
27565
- const first = wordsOf(pattern)[0];
28007
+ const first = wordsOf2(pattern)[0];
27566
28008
  if (!first || first.includes("*"))
27567
28009
  return null;
27568
28010
  words.add(first);
@@ -27571,7 +28013,7 @@ var patternWords = (cwd, env) => {
27571
28013
  };
27572
28014
  function maybeHeavy(command, cwd, env = process.env) {
27573
28015
  try {
27574
- const words = wordsOf(command);
28016
+ const words = wordsOf2(command);
27575
28017
  if (words.some((word) => HEAVY_WORDS.has(word) || /^python[\d.]*$/u.test(word)))
27576
28018
  return true;
27577
28019
  const extra = patternWords(cwd, env);
@@ -28279,7 +28721,7 @@ var wrappedScript = (input) => {
28279
28721
  const script = shellScript3(tail.argv);
28280
28722
  if (SCRIPT_SHELLS.has((tail.argv[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase()) && script)
28281
28723
  return script;
28282
- return tail.argv.map(quoteWord2).join(" ");
28724
+ return tail.argv.map(quoteWord).join(" ");
28283
28725
  };
28284
28726
  var editsOf = (input) => {
28285
28727
  const words = pastLead(input);
@@ -29155,7 +29597,7 @@ var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
29155
29597
  return lost;
29156
29598
  return target === undefined ? os10.homedir() : path43.resolve(dir, target);
29157
29599
  };
29158
- var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
29600
+ var quoteWord = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
29159
29601
  var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
29160
29602
  const value = vars.get(bare ?? braced ?? "");
29161
29603
  return value === undefined ? whole : value;
@@ -29553,7 +29995,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
29553
29995
  targets.push(cmd && CMD_VAR.test(file) ? placeholderIn(dir, `${OPAQUE_TARGET}cmd`) : file);
29554
29996
  const bare = strict && depth < 4 ? unwrapped2(words) : null;
29555
29997
  if (bare?.length && dir !== undefined)
29556
- targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
29998
+ targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord).join(" "), "posix", depth + 1, strict, vars));
29557
29999
  if (strict === "registry" && dir !== undefined && depth < 4) {
29558
30000
  const run = words.slice(Math.max(0, words.findIndex((word) => !PREFIXES2.has(word))));
29559
30001
  const [verb = "", ...args] = run.map((word, index) => index ? word : (word.split(/[\\/]/).at(-1) ?? "").toLowerCase());
@@ -29688,7 +30130,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
29688
30130
  if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file) && !(dialect === "powershell" && /^(?:\$null|nul)$/i.test(file)))
29689
30131
  targets.push(...atAll(file));
29690
30132
  if (dir !== undefined)
29691
- for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
30133
+ for (const invocation of workitInvocations(body.map(quoteWord).join(" "), "posix")) {
29692
30134
  const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
29693
30135
  if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
29694
30136
  targets.push(...runsIn.map((runs) => placeholderIn(runs, DIR_TARGET)));
@@ -29697,7 +30139,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
29697
30139
  return targets;
29698
30140
  };
29699
30141
  var workitRunDir = (dir, words, resolve) => {
29700
- for (const invocation of workitInvocations(words.map(quoteWord2).join(" "), "posix")) {
30142
+ for (const invocation of workitInvocations(words.map(quoteWord).join(" "), "posix")) {
29701
30143
  const { at, args } = workitCwd(dir, invocation, resolve);
29702
30144
  if (args[0] === "check" || args[0] === "lock" && args[1] === "run")
29703
30145
  return at;
@@ -32717,11 +33159,12 @@ var hinted = (write) => write.hint ? {
32717
33159
  plain: false,
32718
33160
  workit: write.hint
32719
33161
  } : write;
32720
- var ytrackArgs = (line, found, depth, names, plain) => {
33162
+ var ytrackArgs = (line, found, depth, names, plain, expands = () => false) => {
32721
33163
  const inner = (script) => void found.push(...ytrackWrites(script, "posix", depth + 1, plain));
32722
33164
  const tail = workitCheckTail(line);
32723
33165
  if (tail) {
32724
- inner("script" in tail ? tail.script : tail.argv.map(quote2).join(" "));
33166
+ const live = (text) => expands(text) && /[$`]/.test(text) ? `"${text.replaceAll(/["\\]/g, "\\$&")}"` : quote2(text);
33167
+ inner("script" in tail ? tail.script : tail.argv.map(live).join(" "));
32725
33168
  return true;
32726
33169
  }
32727
33170
  const flag = SHELLS3.test(name2(line[0])) ? line.findIndex((word, index) => index > 0 && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(word)) : -1;
@@ -32751,8 +33194,9 @@ var ytrackArgs = (line, found, depth, names, plain) => {
32751
33194
  const argv = [...alias ?? [], ...line.slice(at + 1)];
32752
33195
  const write = classify2(argv);
32753
33196
  if (write) {
33197
+ const word = (text) => plain ? quote2(text) : shellWord(text, expands(text));
32754
33198
  const one = {
32755
- command: ["ytrack", ...argv].map(quote2).join(" "),
33199
+ command: ["ytrack", ...argv].map(word).join(" "),
32756
33200
  ...write,
32757
33201
  ...hostsOf(argv),
32758
33202
  plain
@@ -32855,14 +33299,15 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
32855
33299
  let found = [];
32856
33300
  const lines = plain ? plainLines(command, dialect) : null;
32857
33301
  const none = new Map;
33302
+ const expands = expandsIn(command, dialect);
32858
33303
  const plainFirst = lines ? ytrackArgs(lines.first, found, depth, none, true) : false;
32859
33304
  const joined = lines && plainFirst ? chained(found, lines.chain, depth) : null;
32860
33305
  if (joined)
32861
33306
  found = joined;
32862
- if (!lines || !plainFirst || !(joined ? [] : lines.chain).every((line) => ytrackArgs(line, found, depth, none, false)) || !lines.later.every((line) => ytrackArgs(line, found, depth, none, false))) {
33307
+ 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))) {
32863
33308
  found = [];
32864
33309
  for (const line of commandLines(command, dialect))
32865
- ytrackArgs(line, found, depth, aliases(command), false);
33310
+ ytrackArgs(line, found, depth, aliases(command), false, expands);
32866
33311
  found = found.map(hinted);
32867
33312
  }
32868
33313
  READ.set(key, found);
@@ -32872,7 +33317,7 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
32872
33317
  };
32873
33318
  var RELOCATES = /(?<![$\w])YTRACK_CONFIG_DIR\b/;
32874
33319
  var reachesOnly = (allowed, write) => write.plain && !!write.hosts?.length && write.hosts.every((host) => youTrackHostAllowed(allowed, host));
32875
- var scopedGate = (allowed, command, writes) => {
33320
+ var scopedGate = (allowed, command, dialect, writes) => {
32876
33321
  const scope = `youtrack.autoHosts (${allowed.join(", ")})`;
32877
33322
  if (RELOCATES.test(command))
32878
33323
  return {
@@ -32887,8 +33332,10 @@ var scopedGate = (allowed, command, writes) => {
32887
33332
  if (!unnamed.length)
32888
33333
  return null;
32889
33334
  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";
32890
- const bare = unnamed.find((write) => write.bare)?.bare;
32891
- const retry = bare ? ["ytrack", "--host", first, ...bare].map(quote2).join(" ") : null;
33335
+ const hostless = unnamed.find((each) => each.bare);
33336
+ const expands = expandsIn(command, dialect);
33337
+ const word = (text) => hostless?.plain ? quote2(text) : shellWord(text, expands(text));
33338
+ const retry = hostless?.bare ? ["ytrack", "--host", first, ...hostless.bare].map(word).join(" ") : null;
32892
33339
  return {
32893
33340
  kind: "deny",
32894
33341
  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 ? `
@@ -32924,7 +33371,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
32924
33371
  const hosts = policy.hosts;
32925
33372
  if (hosts === null)
32926
33373
  return null;
32927
- const scoped = scopedGate(hosts, command, writes);
33374
+ const scoped = scopedGate(hosts, command, dialect, writes);
32928
33375
  if (scoped)
32929
33376
  return scoped;
32930
33377
  writes = writes.filter((write) => !reachesOnly(hosts, write));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "2.29.2",
3
+ "version": "2.29.3",
4
4
  "private": false,
5
5
  "description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
6
6
  "keywords": [
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@opencode/plugin": "2.3.2",
44
- "@workit-dev/core": "^2.29.2"
44
+ "@workit-dev/core": "^2.29.3"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"