@workit-dev/opencode 1.9.3 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/plugin.js +609 -301
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -184,7 +184,7 @@ function define(plugin) {
184
184
  // packages/workit-core/src/core.ts
185
185
  import { spawnSync as spawnSync22 } from "node:child_process";
186
186
  import { existsSync as existsSync12, realpathSync as realpathSync8 } from "node:fs";
187
- import path34 from "node:path";
187
+ import path35 from "node:path";
188
188
 
189
189
  // packages/workit-core/src/core/task-contract.ts
190
190
  import { createHash as createHash3, randomUUID } from "node:crypto";
@@ -18556,17 +18556,17 @@ var exportDigest = (bundle) => sha256({
18556
18556
  // packages/workit-core/src/core/route-intent.ts
18557
18557
  import { spawnSync as spawnSync17 } from "node:child_process";
18558
18558
  import { existsSync as existsSync10 } from "node:fs";
18559
- import path29 from "node:path";
18559
+ import path30 from "node:path";
18560
18560
 
18561
18561
  // packages/workit-core/src/hooks/raw-git.ts
18562
18562
  import { spawnSync as spawnSync16 } from "node:child_process";
18563
- import { createHash as createHash16 } from "node:crypto";
18563
+ import { createHash as createHash17 } from "node:crypto";
18564
18564
  import fs20 from "node:fs";
18565
18565
  import os6 from "node:os";
18566
- import path28 from "node:path";
18566
+ import path29 from "node:path";
18567
18567
 
18568
18568
  // packages/workit-core/src/autonomy.ts
18569
- import path26 from "node:path";
18569
+ import path27 from "node:path";
18570
18570
 
18571
18571
  // packages/workit-core/src/core/eval-world.ts
18572
18572
  import { existsSync as existsSync9, realpathSync as realpathSync5 } from "node:fs";
@@ -18598,6 +18598,68 @@ var evalWorldEntry = (cwd) => {
18598
18598
  }
18599
18599
  };
18600
18600
 
18601
+ // packages/workit-core/src/core/grant-seal.ts
18602
+ import { createHash as createHash15 } from "node:crypto";
18603
+ import { readFileSync as readFileSync10 } from "node:fs";
18604
+ import path26 from "node:path";
18605
+ var SEAL_FILE = "workspaces.json.seal";
18606
+ var SEAL_VERSION = 1;
18607
+ var SEAL_COMMAND = "workit workspace seal";
18608
+ var pick2 = (value, keys) => {
18609
+ if (!value || typeof value !== "object" || Array.isArray(value))
18610
+ return;
18611
+ const out = Object.fromEntries(keys.flatMap((key) => {
18612
+ const item = value[key];
18613
+ return item === undefined ? [] : [[key, item]];
18614
+ }));
18615
+ return Object.keys(out).length > 0 ? out : undefined;
18616
+ };
18617
+ var ENTRY_KEYS = [
18618
+ "name",
18619
+ "glob",
18620
+ "remotes",
18621
+ "vcs",
18622
+ "autonomy",
18623
+ "autoApprove",
18624
+ "defaultEndpoint",
18625
+ "verification",
18626
+ "youtrack"
18627
+ ];
18628
+ var sealProjection = (entries) => entries.map((entry) => {
18629
+ const all = pick2(entry, ENTRY_KEYS) ?? {};
18630
+ return pick2({
18631
+ ...all,
18632
+ vcs: pick2(all.vcs, ["provider", "account"]),
18633
+ youtrack: pick2(all.youtrack, ["writes"])
18634
+ }, ENTRY_KEYS);
18635
+ });
18636
+ var canonical3 = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item);
18637
+ var sealDigest = (projection) => createHash15("sha256").update(canonical3(projection)).digest("hex");
18638
+ var broken = (reason, sealed = null) => ({
18639
+ state: "broken",
18640
+ reason,
18641
+ sealed
18642
+ });
18643
+ function checkSeal(dir) {
18644
+ const file = path26.join(dir, SEAL_FILE);
18645
+ let seal;
18646
+ try {
18647
+ seal = JSON.parse(readFileSync10(file, "utf8"));
18648
+ } catch (error) {
18649
+ if (error.code === "ENOENT")
18650
+ return { state: "none" };
18651
+ return broken(`${SEAL_FILE} cannot be read`);
18652
+ }
18653
+ if (seal?.version !== SEAL_VERSION || !Array.isArray(seal.projection) || seal.sha256 !== sealDigest(seal.projection))
18654
+ return broken(`${SEAL_FILE} is malformed`);
18655
+ const sealed = validateWorkspacesDocument({ workspaces: seal.projection }, file);
18656
+ if (sealed.status !== "valid")
18657
+ return broken(`${SEAL_FILE} is malformed`);
18658
+ const current = readWorkspacesResult(dir);
18659
+ const ok = current.status === "valid" || current.status === "missing";
18660
+ return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
18661
+ }
18662
+
18601
18663
  // packages/workit-core/src/autonomy.ts
18602
18664
  var grantsHome = { resolve: accountHome };
18603
18665
  var accountDir = () => {
@@ -18607,13 +18669,27 @@ var accountDir = () => {
18607
18669
  var grantsDir = () => accountDir() ?? resolveConfigDir();
18608
18670
  var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
18609
18671
  var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
18610
- var resolveFrom = (cwd, name) => {
18672
+ var fileSource = (dir = accountDir()) => ({
18673
+ resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
18674
+ entries: () => entriesIn(dir)
18675
+ });
18676
+ var sealedSource = (entries) => ({
18677
+ resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
18678
+ entries: () => entries
18679
+ });
18680
+ var sealOf = () => {
18611
18681
  const dir = accountDir();
18612
- return dir === null ? null : resolveWorkspaceFrom(cwd, dir, name);
18682
+ return dir === null ? { state: "none" } : checkSeal(dir);
18683
+ };
18684
+ var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
18685
+ var sealNote = (seal = sealOf()) => seal.state === "broken" ? `workspaces.json does not match its seal (${seal.reason}), so grants, endpoint, verification and youtrack.writes are the stricter of their current and last sealed values; ${SEAL_UNBLOCK}` : null;
18686
+ var youTrackWritesMode = (cwd) => {
18687
+ const youtrack = resolveRuntimeWorkspaceVcs(cwd)?.youtrack;
18688
+ return youtrack && typeof youtrack === "object" && youtrack.writes === "auto" && !sealNote() ? "auto" : "ask";
18613
18689
  };
18614
18690
  var shownGrantsDir = () => {
18615
18691
  const world = evalWorld(process.cwd());
18616
- return world ? path26.join(world, "config") : accountDir();
18692
+ return world ? path27.join(world, "config") : accountDir();
18617
18693
  };
18618
18694
  var benchWorld = (cwd) => {
18619
18695
  const entry = evalWorldEntry(cwd);
@@ -18637,8 +18713,8 @@ var grantsOverride = () => {
18637
18713
  const shown = shownGrantsDir();
18638
18714
  if (shown === null)
18639
18715
  return NO_ACCOUNT;
18640
- const configured = path26.resolve(resolveConfigDir());
18641
- return configured === path26.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path26.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
18716
+ const configured = path27.resolve(resolveConfigDir());
18717
+ return configured === path27.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path27.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
18642
18718
  };
18643
18719
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
18644
18720
  var DEFAULT_GRANTS = Object.freeze({
@@ -18758,13 +18834,13 @@ function autonomyOf(workspace) {
18758
18834
  verification: verificationOf(workspace)
18759
18835
  };
18760
18836
  }
18761
- function capAt(named, where, by, why, main = false) {
18837
+ function capAt(source, named, where, by, why, main = false) {
18762
18838
  let folder = null;
18763
18839
  let none = "";
18764
18840
  try {
18765
18841
  if (where instanceof Error)
18766
18842
  throw where;
18767
- folder = autonomyOf(typeof where === "string" ? resolveFrom(where) : where.entry);
18843
+ folder = autonomyOf(typeof where === "string" ? source.resolve(where) : where.entry);
18768
18844
  } catch (error) {
18769
18845
  none = error.message;
18770
18846
  }
@@ -18807,43 +18883,105 @@ function resolveAutonomy(cwd, target) {
18807
18883
  const override = world ? null : grantsOverride();
18808
18884
  if (override)
18809
18885
  return { ...autonomyOf(null), note: override };
18886
+ let resolved;
18887
+ const once = typeof target === "function" ? () => resolved ??= target() : target;
18888
+ const current = resolveWith(fileSource(), cwd, world, once);
18889
+ const seal = sealOf();
18890
+ if (seal.state !== "broken")
18891
+ return current;
18892
+ let sealed = autonomyOf(null);
18893
+ try {
18894
+ if (seal.sealed)
18895
+ sealed = resolveWith(sealedSource(seal.sealed), cwd, world, once);
18896
+ } catch {
18897
+ sealed = null;
18898
+ }
18899
+ return stricter(current, sealed, sealNote(seal));
18900
+ }
18901
+ function resolveWith(source, cwd, world, target) {
18810
18902
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
18811
- const real = resolveFrom(cwd, name);
18903
+ const real = source.resolve(cwd, name);
18812
18904
  let autonomy = autonomyOf(real ?? world);
18813
18905
  if (!real && world)
18814
18906
  autonomy.world = evalWorld(cwd) ?? undefined;
18815
18907
  if (name)
18816
- autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
18908
+ autonomy = capAt(source, autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
18817
18909
  const above = checkoutsAbove(cwd);
18818
18910
  for (const where of above instanceof Error ? [above] : above)
18819
- autonomy = capAt(autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
18820
- return capAtRemotes(autonomy, cwd, target);
18911
+ autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
18912
+ return capAtRemotes(source, autonomy, cwd, target);
18913
+ }
18914
+ var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
18915
+ function stricter(current, sealed, note) {
18916
+ const grants = { ...current.grants };
18917
+ const unblocks = { ...current.unblocks };
18918
+ for (const kind of GRANT_KINDS) {
18919
+ const floor = sealed ? sealed.grants[kind] : false;
18920
+ if (!raises(kind, floor, grants[kind]))
18921
+ continue;
18922
+ grants[kind] = floor;
18923
+ unblocks[kind] = SEAL_UNBLOCK;
18924
+ }
18925
+ const configured = GRANT_KINDS.filter((kind) => current.configured.includes(kind) || sealed?.configured.includes(kind));
18926
+ const accountConfigured = !needsAccount(current) && !(sealed && needsAccount(sealed)) && (current.accountConfigured || Boolean(sealed?.accountConfigured));
18927
+ const lower = (a, b) => raisesEndpoint(a, b) ? a : b;
18928
+ const defaultEndpoint = lower(current.defaultEndpoint, sealed?.defaultEndpoint ?? DEFAULT_ENDPOINT);
18929
+ const effective = effectiveEndpoint(defaultEndpoint, {
18930
+ workspace: current.workspace,
18931
+ grants,
18932
+ configured,
18933
+ accountConfigured
18934
+ });
18935
+ const endpoint = lower(lower(effective.endpoint, current.effectiveEndpoint), sealed?.effectiveEndpoint ?? DEFAULT_ENDPOINT);
18936
+ const strict = sealed?.verification ?? "independent";
18937
+ const looser = VERIFICATION_STRICTNESS.indexOf(current.verification) > VERIFICATION_STRICTNESS.indexOf(strict);
18938
+ return {
18939
+ ...current,
18940
+ grants,
18941
+ configured,
18942
+ accountConfigured,
18943
+ defaultEndpoint,
18944
+ effectiveEndpoint: endpoint,
18945
+ endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : SEAL_UNBLOCK,
18946
+ verification: looser ? strict : current.verification,
18947
+ unblocks,
18948
+ note: current.note ? `${current.note}; ${note}` : note
18949
+ };
18821
18950
  }
18822
- function capAtRemotes(autonomy, cwd, target) {
18823
- const claiming = entriesIn(accountDir()).filter((entry) => entry.remotes?.length);
18951
+ function capAtRemotes(source, autonomy, cwd, target) {
18952
+ const claiming = source.entries().filter((entry) => entry.remotes?.length);
18824
18953
  if (claiming.length === 0)
18825
18954
  return autonomy;
18826
18955
  const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
18827
18956
  if (remotes instanceof Error)
18828
- return capAt(autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
18957
+ return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
18829
18958
  let capped = autonomy;
18830
18959
  for (const remote of Array.isArray(remotes) ? remotes : remotes.remotes)
18831
18960
  for (const entry of claiming) {
18832
18961
  const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
18833
18962
  if (pattern)
18834
- capped = capAt(capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
18963
+ capped = capAt(source, capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
18835
18964
  }
18836
18965
  return capped;
18837
18966
  }
18838
- var grantsMatter = (kind) => !grantsOverride() && entriesIn(accountDir()).some((entry) => {
18839
- const autonomy = autonomyOf(entry);
18840
- return entry.remotes?.length || autonomy.grants[kind] === false || autonomy.configured.length > 0 && !autonomy.accountConfigured;
18841
- });
18842
- var remotesClaimed = (dir = accountDir()) => entriesIn(dir).some((entry) => entry.remotes?.length);
18843
- function targetClaims(target, dir = accountDir()) {
18967
+ var grantsMatter = (kind) => {
18968
+ if (grantsOverride())
18969
+ return false;
18970
+ const matters = entriesIn(accountDir()).some((entry) => {
18971
+ const autonomy = autonomyOf(entry);
18972
+ return entry.remotes?.length || autonomy.grants[kind] === false || needsAccount(autonomy);
18973
+ });
18974
+ const seal = sealOf();
18975
+ return matters || seal.state === "broken" && (seal.sealed ? seal.sealed.length > 0 : DEFAULT_GRANTS[kind] === false);
18976
+ };
18977
+ var authorityEntries = () => {
18978
+ const seal = sealOf();
18979
+ return [...entriesIn(accountDir()), ...seal.state === "broken" ? seal.sealed ?? [] : []];
18980
+ };
18981
+ function claimsIn(target, entries) {
18844
18982
  if (target instanceof Error)
18845
18983
  return target;
18846
- const claiming = entriesIn(dir).filter((entry) => entry.remotes?.length);
18984
+ const claiming = entries.filter((entry) => entry.remotes?.length);
18847
18985
  return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
18848
18986
  const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
18849
18987
  return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
@@ -18853,7 +18991,8 @@ var suggested = (kind) => kind === "merge" ? "verified" : "true";
18853
18991
  var accountHint = (workspace) => `set vcs.account for workspace "${workspace ?? "?"}" in ${configFilePath("workspaces.json")}`;
18854
18992
  var grantHint = (workspace, kind) => `ask the user to run, in their own terminal: workit grant set ${workspace ?? "<workspace>"} ${kind}=${suggested(kind)}`;
18855
18993
  function rawGrantDenial(cwd, kind, target) {
18856
- const claimed = remotesClaimed();
18994
+ const entries = authorityEntries();
18995
+ const claimed = entries.some((entry) => entry.remotes?.length);
18857
18996
  if (!grantsMatter(kind))
18858
18997
  return null;
18859
18998
  let resolved;
@@ -18878,14 +19017,10 @@ function rawGrantDenial(cwd, kind, target) {
18878
19017
  };
18879
19018
  if (!claimed || !lazy)
18880
19019
  return null;
18881
- const claims = targetClaims(lazy());
19020
+ const claims = claimsIn(lazy(), entries);
18882
19021
  if (claims instanceof Error)
18883
19022
  return { error: `${kind}: ${claims.message}`, unblock: "name a target workit can resolve" };
18884
- const entries = entriesIn(accountDir());
18885
- const strict = claims.find(({ workspace: name }) => {
18886
- const entry = entries.find((item) => item.name === name);
18887
- return entry && autonomyOf(entry).grants[kind] === false;
18888
- });
19023
+ const strict = claims.find(({ workspace: name }) => entries.some((item) => item.name === name && autonomyOf(item).grants[kind] === false));
18889
19024
  return strict ? {
18890
19025
  error: `${kind} is not granted for workspace ${strict.workspace}, which claims ${strict.url} (${strict.pattern})`,
18891
19026
  unblock: grantHint(strict.workspace, kind)
@@ -18897,9 +19032,9 @@ var raises = (kind, current, next) => {
18897
19032
  };
18898
19033
 
18899
19034
  // packages/workit-core/src/hooks/session-marker.ts
18900
- import { createHash as createHash15 } from "node:crypto";
19035
+ import { createHash as createHash16 } from "node:crypto";
18901
19036
  import fs19 from "node:fs";
18902
- import path27 from "node:path";
19037
+ import path28 from "node:path";
18903
19038
  var sessionMarkerFile = (input, session, store) => {
18904
19039
  let dir = store;
18905
19040
  if (dir === undefined) {
@@ -18908,8 +19043,8 @@ var sessionMarkerFile = (input, session, store) => {
18908
19043
  return null;
18909
19044
  dir = location.dir;
18910
19045
  }
18911
- const name = createHash15("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
18912
- return path27.join(dir, "hooks", `skills-${name}.json`);
19046
+ const name = createHash16("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
19047
+ return path28.join(dir, "hooks", `skills-${name}.json`);
18913
19048
  };
18914
19049
  var list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
18915
19050
  var EMPTY = {
@@ -18944,7 +19079,7 @@ var parseMarker = (text) => {
18944
19079
  };
18945
19080
  var readSessionMarker = (file) => parseMarker(readRaw(file));
18946
19081
  var writeAtomic = (file, marker) => {
18947
- fs19.mkdirSync(path27.dirname(file), { recursive: true });
19082
+ fs19.mkdirSync(path28.dirname(file), { recursive: true });
18948
19083
  const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
18949
19084
  try {
18950
19085
  fs19.writeFileSync(temp, JSON.stringify(marker));
@@ -19509,14 +19644,14 @@ var GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMM
19509
19644
  var ASSIGNMENT = /^([A-Za-z_]\w*)=([\s\S]*)$/;
19510
19645
  var MAX_DEPTH = 4;
19511
19646
  var MAX_EXPANSIONS = 16;
19512
- var isAbsolute = (value) => path28.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
19647
+ var isAbsolute = (value) => path29.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
19513
19648
  var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
19514
19649
  var joinDir = (base, raw) => {
19515
19650
  const next = raw.replace(HERE, ".");
19516
19651
  if (base === undefined || /[$`*?]/.test(next) || next === "-")
19517
19652
  return;
19518
- const expanded = next === "~" || next.startsWith("~/") ? path28.join(os6.homedir(), next.slice(1)) : next;
19519
- return base === null || isAbsolute(expanded) ? expanded : path28.join(base, expanded);
19653
+ const expanded = next === "~" || next.startsWith("~/") ? path29.join(os6.homedir(), next.slice(1)) : next;
19654
+ return base === null || isAbsolute(expanded) ? expanded : path29.join(base, expanded);
19520
19655
  };
19521
19656
  var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
19522
19657
  var cdTarget = (words) => {
@@ -20438,17 +20573,17 @@ var headSha2 = (repo) => {
20438
20573
  if (!git || git.reftable)
20439
20574
  return null;
20440
20575
  try {
20441
- const head = fs20.readFileSync(path28.join(git.gitDir, "HEAD"), "utf8").trim();
20576
+ const head = fs20.readFileSync(path29.join(git.gitDir, "HEAD"), "utf8").trim();
20442
20577
  if (/^[0-9a-f]{40,64}$/.test(head))
20443
20578
  return head;
20444
20579
  const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
20445
20580
  if (!ref)
20446
20581
  return null;
20447
- const common = path28.dirname(repo.location.dir);
20582
+ const common = path29.dirname(repo.location.dir);
20448
20583
  try {
20449
- return fs20.readFileSync(path28.join(common, ref), "utf8").trim() || null;
20584
+ return fs20.readFileSync(path29.join(common, ref), "utf8").trim() || null;
20450
20585
  } catch {}
20451
- const packed = fs20.readFileSync(path28.join(common, "packed-refs"), "utf8");
20586
+ const packed = fs20.readFileSync(path29.join(common, "packed-refs"), "utf8");
20452
20587
  return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
20453
20588
  } catch {
20454
20589
  return null;
@@ -20541,7 +20676,7 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
20541
20676
  const sub = invocation.args[0];
20542
20677
  if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
20543
20678
  return [invocation];
20544
- const dir = path28.resolve(root, invocation.dir ?? ".");
20679
+ const dir = path29.resolve(root, invocation.dir ?? ".");
20545
20680
  if (!fs20.existsSync(dir))
20546
20681
  return [invocation];
20547
20682
  const config = gitConfig(dir, invocation, cache);
@@ -20564,11 +20699,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
20564
20699
  var normalizedUrl = (url, dir) => {
20565
20700
  const trimmed = url.trim();
20566
20701
  if (/^file:\/\//i.test(trimmed))
20567
- return path28.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
20702
+ return path29.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
20568
20703
  const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
20569
20704
  const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
20570
20705
  if (!scheme && !scp)
20571
- return path28.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
20706
+ return path29.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
20572
20707
  const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
20573
20708
  return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
20574
20709
  };
@@ -20796,7 +20931,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
20796
20931
  const out = [];
20797
20932
  const repos = new Map;
20798
20933
  const repoFor = (relative) => {
20799
- const dir = path28.resolve(cwd, relative ?? ".");
20934
+ const dir = path29.resolve(cwd, relative ?? ".");
20800
20935
  if (!repos.has(dir)) {
20801
20936
  const repo = repoAt(dir);
20802
20937
  const workit = repo !== null && isWorkitWorkspace(repo);
@@ -20817,7 +20952,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
20817
20952
  const action = rawAction(invocation);
20818
20953
  const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
20819
20954
  repo: {
20820
- dir: path28.resolve(cwd, invocation.dir ?? "."),
20955
+ dir: path29.resolve(cwd, invocation.dir ?? "."),
20821
20956
  branch: null
20822
20957
  },
20823
20958
  workit: false
@@ -20890,13 +21025,13 @@ var messageOf = (segment, index) => {
20890
21025
  };
20891
21026
  var sameGitDir = (a, b, platform = process.platform) => {
20892
21027
  if (platform !== "win32")
20893
- return path28.posix.resolve(a) === path28.posix.resolve(b);
20894
- const fold = (value) => path28.win32.resolve(value).toLowerCase();
21028
+ return path29.posix.resolve(a) === path29.posix.resolve(b);
21029
+ const fold = (value) => path29.win32.resolve(value).toLowerCase();
20895
21030
  return fold(a) === fold(b);
20896
21031
  };
20897
21032
  var cdCommitCall = (input, command, target, repo) => {
20898
21033
  const { top, git, dir: store } = repo.location;
20899
- if (!top || !git || sameGitDir(git.gitDir, path28.dirname(store)) || repoAt(input.cwd)?.location.top === top)
21034
+ if (!top || !git || sameGitDir(git.gitDir, path29.dirname(store)) || repoAt(input.cwd)?.location.top === top)
20900
21035
  return null;
20901
21036
  const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
20902
21037
  if (/[;|&<>`$()\n\\]/u.test(bare))
@@ -20905,7 +21040,7 @@ var cdCommitCall = (input, command, target, repo) => {
20905
21040
  const commit = rest.at(-1);
20906
21041
  if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
20907
21042
  return null;
20908
- if (path28.resolve(input.cwd, cd.words[1]) !== target)
21043
+ if (path29.resolve(input.cwd, cd.words[1]) !== target)
20909
21044
  return null;
20910
21045
  if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
20911
21046
  return null;
@@ -20972,7 +21107,7 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
20972
21107
  } catch {}
20973
21108
  if (guarded && !switches)
20974
21109
  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>")}.`;
20975
- const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path28.resolve(input.cwd, invocation.dir), repo);
21110
+ const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path29.resolve(input.cwd, invocation.dir), repo);
20976
21111
  return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
20977
21112
  };
20978
21113
  function rawGitPre(input, command, options = {}) {
@@ -21070,9 +21205,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
21070
21205
  return null;
21071
21206
  };
21072
21207
  var localTag = (repo, name) => {
21073
- const common = path28.dirname(repo.location.dir);
21208
+ const common = path29.dirname(repo.location.dir);
21074
21209
  try {
21075
- return fs20.existsSync(path28.join(common, "refs/tags", name)) || fs20.readFileSync(path28.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
21210
+ return fs20.existsSync(path29.join(common, "refs/tags", name)) || fs20.readFileSync(path29.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
21076
21211
  `);
21077
21212
  } catch {
21078
21213
  return false;
@@ -21091,8 +21226,8 @@ var analysisDenial = (error) => ({
21091
21226
  unblock: SPLIT_IT
21092
21227
  });
21093
21228
  var MARKER_TTL_SECONDS = 3600;
21094
- var markerFile = (repo, session, key) => path28.join(repo.location.dir, "hooks", `commit-${createHash16("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
21095
- var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash16("sha256").update(command).digest("hex")}`;
21229
+ var markerFile = (repo, session, key) => path29.join(repo.location.dir, "hooks", `commit-${createHash17("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
21230
+ var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash17("sha256").update(command).digest("hex")}`;
21096
21231
  function noteRawCommit(input, command, key) {
21097
21232
  try {
21098
21233
  if (!input.session.id || !/\bcommit\b/.test(command))
@@ -21102,7 +21237,7 @@ function noteRawCommit(input, command, key) {
21102
21237
  if (action.kind !== "commit")
21103
21238
  continue;
21104
21239
  const file = markerFile(repo, input.session.id, key);
21105
- fs20.mkdirSync(path28.dirname(file), { recursive: true });
21240
+ fs20.mkdirSync(path29.dirname(file), { recursive: true });
21106
21241
  fs20.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
21107
21242
  `);
21108
21243
  }
@@ -21331,7 +21466,7 @@ var judgedDir = (root, dir) => {
21331
21466
  return null;
21332
21467
  if (dir === null)
21333
21468
  return root;
21334
- const resolved = path29.resolve(root, dir);
21469
+ const resolved = path30.resolve(root, dir);
21335
21470
  return existsSync10(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
21336
21471
  };
21337
21472
  var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
@@ -23328,8 +23463,8 @@ class WorkitCore {
23328
23463
  }
23329
23464
  // packages/workit-core/src/core/repo-context.ts
23330
23465
  import { spawnSync as spawnSync18 } from "node:child_process";
23331
- import { existsSync as existsSync11, readFileSync as readFileSync10, readdirSync as readdirSync4 } from "node:fs";
23332
- import path30 from "node:path";
23466
+ import { existsSync as existsSync11, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
23467
+ import path31 from "node:path";
23333
23468
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
23334
23469
  try {
23335
23470
  gitRevisionParts(value);
@@ -23473,13 +23608,13 @@ var findPrTemplate = (cwd) => {
23473
23608
  for (const rel of PR_TEMPLATE_FILES) {
23474
23609
  const parts = rel.split("/");
23475
23610
  const base = parts[parts.length - 1];
23476
- const dir = parts.length > 1 ? path30.join(cwd, ...parts.slice(0, -1)) : cwd;
23611
+ const dir = parts.length > 1 ? path31.join(cwd, ...parts.slice(0, -1)) : cwd;
23477
23612
  const actual = probeCaseInsensitive(dir, base);
23478
23613
  if (actual)
23479
23614
  return [...parts.slice(0, -1), actual].join("/");
23480
23615
  }
23481
23616
  for (const rel of PR_TEMPLATE_DIRS) {
23482
- const only = singleMarkdown(path30.join(cwd, ...rel.split("/")));
23617
+ const only = singleMarkdown(path31.join(cwd, ...rel.split("/")));
23483
23618
  if (only)
23484
23619
  return `${rel}/${only}`;
23485
23620
  }
@@ -23509,11 +23644,11 @@ var diffStatForRange = (cwd, range) => {
23509
23644
  return runGit(cwd, ["diff", "--stat", "--"]).stdout;
23510
23645
  };
23511
23646
  var packageScripts = (cwd, keys) => {
23512
- const pkgPath = path30.join(cwd, "package.json");
23647
+ const pkgPath = path31.join(cwd, "package.json");
23513
23648
  if (!existsSync11(pkgPath))
23514
23649
  return [];
23515
23650
  try {
23516
- const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
23651
+ const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
23517
23652
  return keys.filter((k) => pkg.scripts && typeof pkg.scripts[k] === "string").map((k) => `${k}: ${pkg.scripts?.[k]}`);
23518
23653
  } catch {
23519
23654
  return [];
@@ -23535,9 +23670,9 @@ var documentationFiles = (cwd) => {
23535
23670
  if (entry.isDirectory()) {
23536
23671
  if (excluded.has(entry.name))
23537
23672
  continue;
23538
- walk(path30.join(dir, entry.name), depth + 1);
23673
+ walk(path31.join(dir, entry.name), depth + 1);
23539
23674
  } else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
23540
- matches.push("./" + path30.relative(cwd, path30.join(dir, entry.name)).replaceAll("\\", "/"));
23675
+ matches.push("./" + path31.relative(cwd, path31.join(dir, entry.name)).replaceAll("\\", "/"));
23541
23676
  }
23542
23677
  }
23543
23678
  };
@@ -23547,13 +23682,13 @@ var documentationFiles = (cwd) => {
23547
23682
  var readTrimmed2 = (file, maxLines) => {
23548
23683
  if (!existsSync11(file))
23549
23684
  return "";
23550
- const lines = readFileSync10(file, "utf8").split(`
23685
+ const lines = readFileSync11(file, "utf8").split(`
23551
23686
  `);
23552
23687
  return lines.slice(0, maxLines).join(`
23553
23688
  `);
23554
23689
  };
23555
23690
  function prReadyContext(root, range) {
23556
- const cwd = path30.resolve(repoRoot(root));
23691
+ const cwd = path31.resolve(repoRoot(root));
23557
23692
  if (range !== undefined && !isResolvableContextRange(cwd, range))
23558
23693
  return invalidRange(cwd);
23559
23694
  let stdout = "";
@@ -23611,7 +23746,7 @@ ${status.stderr}` : "");
23611
23746
  stdout += `template_path: ${template}
23612
23747
 
23613
23748
  `;
23614
- stdout += readTrimmed2(path30.join(cwd, template), 220);
23749
+ stdout += readTrimmed2(path31.join(cwd, template), 220);
23615
23750
  } else {
23616
23751
  stdout += `template_path: none
23617
23752
 
@@ -23621,7 +23756,7 @@ ${status.stderr}` : "");
23621
23756
  stdout += `
23622
23757
  `;
23623
23758
  stdout += printSection("Recent Validation Signals");
23624
- if (existsSync11(path30.join(cwd, "package.json"))) {
23759
+ if (existsSync11(path31.join(cwd, "package.json"))) {
23625
23760
  stdout += `package.json detected. Common scripts:
23626
23761
  `;
23627
23762
  const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
@@ -23630,7 +23765,7 @@ ${status.stderr}` : "");
23630
23765
  `) + `
23631
23766
  `;
23632
23767
  }
23633
- if (existsSync11(path30.join(cwd, "Cargo.toml")) || existsSync11(path30.join(cwd, "src-tauri/Cargo.toml"))) {
23768
+ if (existsSync11(path31.join(cwd, "Cargo.toml")) || existsSync11(path31.join(cwd, "src-tauri/Cargo.toml"))) {
23634
23769
  stdout += `Rust project detected.
23635
23770
  `;
23636
23771
  }
@@ -23663,7 +23798,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
23663
23798
  - Apply with the host-native editor, preserving the repository changelog conventions.
23664
23799
  - If Unreleased already has duplicate category headings, normalize_only first.`;
23665
23800
  function changelogContext(root, range) {
23666
- const cwd = path30.resolve(repoRoot(root));
23801
+ const cwd = path31.resolve(repoRoot(root));
23667
23802
  if (range !== undefined && !isResolvableContextRange(cwd, range))
23668
23803
  return invalidRange(cwd);
23669
23804
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -23681,7 +23816,7 @@ function changelogContext(root, range) {
23681
23816
  stdout += CHANGELOG_RULES + `
23682
23817
  `;
23683
23818
  stdout += printSection("Existing CHANGELOG.md");
23684
- const changelogPath = path30.join(cwd, "CHANGELOG.md");
23819
+ const changelogPath = path31.join(cwd, "CHANGELOG.md");
23685
23820
  if (existsSync11(changelogPath)) {
23686
23821
  stdout += readTrimmed2(changelogPath, 260) + `
23687
23822
  `;
@@ -23701,7 +23836,7 @@ function changelogContext(root, range) {
23701
23836
  return { stdout, stderr: "", exitCode: 0, cwd };
23702
23837
  }
23703
23838
  function docsRefreshContext(root, range) {
23704
- const cwd = path30.resolve(repoRoot(root));
23839
+ const cwd = path31.resolve(repoRoot(root));
23705
23840
  if (range !== undefined && !isResolvableContextRange(cwd, range))
23706
23841
  return invalidRange(cwd);
23707
23842
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -23723,7 +23858,7 @@ function docsRefreshContext(root, range) {
23723
23858
  `) + `
23724
23859
  `;
23725
23860
  stdout += printSection("README Preview");
23726
- const readme = path30.join(cwd, "README.md");
23861
+ const readme = path31.join(cwd, "README.md");
23727
23862
  if (existsSync11(readme)) {
23728
23863
  stdout += readTrimmed2(readme, 220) + `
23729
23864
  `;
@@ -23732,10 +23867,10 @@ function docsRefreshContext(root, range) {
23732
23867
  `;
23733
23868
  }
23734
23869
  stdout += printSection("Package Scripts");
23735
- const pkgPath = path30.join(cwd, "package.json");
23870
+ const pkgPath = path31.join(cwd, "package.json");
23736
23871
  if (existsSync11(pkgPath)) {
23737
23872
  try {
23738
- const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
23873
+ const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
23739
23874
  stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
23740
23875
  `;
23741
23876
  } catch {}
@@ -23746,7 +23881,7 @@ function docsRefreshContext(root, range) {
23746
23881
  return { stdout, stderr: "", exitCode: 0, cwd };
23747
23882
  }
23748
23883
  function releaseNotesContext(root, rangeOrTag) {
23749
- const cwd = path30.resolve(repoRoot(root));
23884
+ const cwd = path31.resolve(repoRoot(root));
23750
23885
  if (!rangeOrTag) {
23751
23886
  return {
23752
23887
  stdout: "",
@@ -23789,7 +23924,7 @@ function releaseNotesContext(root, rangeOrTag) {
23789
23924
  `;
23790
23925
  stdout += printSection("Existing Release Files");
23791
23926
  for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
23792
- if (existsSync11(path30.join(cwd, rel)))
23927
+ if (existsSync11(path31.join(cwd, rel)))
23793
23928
  stdout += rel + `
23794
23929
  `;
23795
23930
  }
@@ -23821,7 +23956,7 @@ import { spawnSync as spawnSync20 } from "node:child_process";
23821
23956
 
23822
23957
  // packages/workit-core/src/core/pr-create.ts
23823
23958
  import fs21 from "node:fs";
23824
- import path31 from "node:path";
23959
+ import path32 from "node:path";
23825
23960
  import { spawnSync as spawnSync19 } from "node:child_process";
23826
23961
  import { pathToFileURL } from "node:url";
23827
23962
  // packages/workit-core/src/forge/pr-body.ts
@@ -23842,11 +23977,11 @@ var LOCAL = bounded(20000);
23842
23977
  var NETWORK = bounded(60000);
23843
23978
  function whichOnPath(tool) {
23844
23979
  const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
23845
- for (const dir of (process.env.PATH ?? "").split(path31.delimiter)) {
23980
+ for (const dir of (process.env.PATH ?? "").split(path32.delimiter)) {
23846
23981
  if (!dir)
23847
23982
  continue;
23848
23983
  for (const name of names) {
23849
- const candidate = path31.join(dir, name);
23984
+ const candidate = path32.join(dir, name);
23850
23985
  try {
23851
23986
  fs21.accessSync(candidate, fs21.constants.X_OK);
23852
23987
  return candidate;
@@ -23868,7 +24003,7 @@ var pushRemote = (cwd) => {
23868
24003
  };
23869
24004
  var safePushUrl = (remote) => {
23870
24005
  const raw = remote.trim();
23871
- if (path31.isAbsolute(raw))
24006
+ if (path32.isAbsolute(raw))
23872
24007
  return pathToFileURL(raw).href;
23873
24008
  if (!raw.includes("://")) {
23874
24009
  const scp = /^(?:([^@\s]+)@)?([^:]+):(.+)$/u.exec(raw);
@@ -24000,7 +24135,7 @@ var fetchGitLabIssueBody = async (ref, root, deps = {}) => {
24000
24135
 
24001
24136
  // packages/workit-core/src/core/youtrack.ts
24002
24137
  import fs23 from "node:fs";
24003
- import path33 from "node:path";
24138
+ import path34 from "node:path";
24004
24139
 
24005
24140
  // packages/workit-core/src/core/templates.ts
24006
24141
  var repoRoot2 = assetRoot();
@@ -24015,7 +24150,7 @@ import { spawnSync as spawnSync21 } from "node:child_process";
24015
24150
 
24016
24151
  // packages/workit-core/src/forge/exec.ts
24017
24152
  import fs22 from "node:fs";
24018
- import path32 from "node:path";
24153
+ import path33 from "node:path";
24019
24154
 
24020
24155
  // packages/workit-core/src/forge/redact.ts
24021
24156
  var KEY = String.raw`[A-Za-z0-9_.-]*?(?:token|secret|password|passwd|pwd|api[_-]?key|access[_-]?key|account[_-]?key|private[_-]?key|client[_-]?secret|credentials?|authorization|cookie|signature)[A-Za-z0-9_.-]*`;
@@ -24030,11 +24165,11 @@ var failure3 = (code, error, unblock) => ({ ok: false, code, error, ...unblock ?
24030
24165
  // packages/workit-core/src/forge/exec.ts
24031
24166
  var MAX_BUFFER2 = 64 * 1024 * 1024;
24032
24167
  function findExecutable(bin, env) {
24033
- const dirs = (env.PATH ?? env.Path ?? "").split(path32.delimiter).filter(Boolean);
24168
+ const dirs = (env.PATH ?? env.Path ?? "").split(path33.delimiter).filter(Boolean);
24034
24169
  const exts = process.platform === "win32" ? [".exe"] : [""];
24035
24170
  for (const dir of dirs)
24036
24171
  for (const ext of exts) {
24037
- const candidate = path32.join(dir, `${bin}${ext}`);
24172
+ const candidate = path33.join(dir, `${bin}${ext}`);
24038
24173
  try {
24039
24174
  const stat = fs22.statSync(candidate);
24040
24175
  if (stat.isFile())
@@ -24145,8 +24280,8 @@ function ytrackReadiness(run, host) {
24145
24280
  }
24146
24281
 
24147
24282
  // packages/workit-core/src/core/youtrack.ts
24148
- var ISSUE_RE = /^[A-Z]+-\d+$/;
24149
- var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path33.join(resolveConfigDir(), "youtrack.json");
24283
+ var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
24284
+ var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path34.join(resolveConfigDir(), "youtrack.json");
24150
24285
  var readYouTrackContextConfig = () => {
24151
24286
  const cfgPath = youTrackReadOnlyConfigPath();
24152
24287
  if (!fs23.existsSync(cfgPath))
@@ -24201,11 +24336,11 @@ function parseIssueRef(input) {
24201
24336
  if (ISSUE_RE.test(trimmed)) {
24202
24337
  return { issueId: trimmed, source: "id" };
24203
24338
  }
24204
- const fromPath = trimmed.match(/\/(?:issue|issues)\/([A-Z]+-\d+)/i);
24339
+ const fromPath = trimmed.match(/\/(?:issue|issues)\/([A-Z][A-Z0-9_]*-\d+)/i);
24205
24340
  if (fromPath && ISSUE_RE.test(fromPath[1])) {
24206
24341
  return { issueId: fromPath[1], source: "url" };
24207
24342
  }
24208
- const anywhere = trimmed.match(/([A-Z]+-\d+)/);
24343
+ const anywhere = trimmed.match(/([A-Z][A-Z0-9_]*-\d+)/);
24209
24344
  if (anywhere && ISSUE_RE.test(anywhere[1])) {
24210
24345
  return { issueId: anywhere[1], source: "url" };
24211
24346
  }
@@ -24521,15 +24656,15 @@ function resolveGitRevision(root, value) {
24521
24656
  }
24522
24657
  function resolveInside(root, candidate) {
24523
24658
  const base = realpathSync8(root);
24524
- const target = path34.resolve(base, candidate);
24525
- if (target !== base && !target.startsWith(base + path34.sep)) {
24659
+ const target = path35.resolve(base, candidate);
24660
+ if (target !== base && !target.startsWith(base + path35.sep)) {
24526
24661
  throw new Error("path must stay inside repository root");
24527
24662
  }
24528
24663
  let ancestor = target;
24529
24664
  while (!existsSync12(ancestor))
24530
- ancestor = path34.dirname(ancestor);
24665
+ ancestor = path35.dirname(ancestor);
24531
24666
  const canonicalAncestor = realpathSync8(ancestor);
24532
- if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path34.sep)) {
24667
+ if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path35.sep)) {
24533
24668
  throw new Error("path must stay inside repository root");
24534
24669
  }
24535
24670
  return target;
@@ -24590,7 +24725,7 @@ var capabilitiesFor = (descriptor, observed = {}) => descriptor.capabilities.map
24590
24725
  };
24591
24726
  });
24592
24727
  // packages/workit-core/src/hooks/context.ts
24593
- import path35 from "node:path";
24728
+ import path36 from "node:path";
24594
24729
  var MIGRATION_PENDING_NOTE = "workit migration pending — run `workit task status`";
24595
24730
  var migrationPending = (result) => !result.ok && result.code === "needs_input" && (result.error ?? "").startsWith(MIGRATION_PENDING);
24596
24731
  var boundTo = (entry, session) => entry.sessions.some((item) => item.host === session.host && item.handle === session.handle);
@@ -24678,7 +24813,7 @@ function entryCompactContext(store, entry, session, context) {
24678
24813
  current: () => recentSignal(store.root)
24679
24814
  };
24680
24815
  const observed = task?.data.evidence.some(isObservedCheck) ?? false;
24681
- const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path35.resolve(store.root, ref.path)] : []));
24816
+ const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path36.resolve(store.root, ref.path)] : []));
24682
24817
  const observedFiles = filesKey(files);
24683
24818
  const compact = compactContext(store, context, entry?.id ?? null, freshness, origin && { origin: origin.origin, taskId: origin.entry.id });
24684
24819
  if (!compact.ok || !compact.data)
@@ -24779,7 +24914,7 @@ var isAllowedWorkitCommand = (command) => {
24779
24914
  // packages/workit-core/src/core/heavy-rules.ts
24780
24915
  import fs24 from "node:fs";
24781
24916
  import os7 from "node:os";
24782
- import path36 from "node:path";
24917
+ import path37 from "node:path";
24783
24918
  var EMPTY2 = () => ({ deny: [], allow: [] });
24784
24919
  var readText3 = (file) => {
24785
24920
  try {
@@ -24820,19 +24955,19 @@ function parseJsonc(text) {
24820
24955
  return JSON.parse(out.replace(/,(\s*[}\]])/gu, "$1"));
24821
24956
  }
24822
24957
  function gitTop(cwd) {
24823
- for (let dir = path36.resolve(cwd);; dir = path36.dirname(dir)) {
24824
- if (fs24.existsSync(path36.join(dir, ".git")))
24958
+ for (let dir = path37.resolve(cwd);; dir = path37.dirname(dir)) {
24959
+ if (fs24.existsSync(path37.join(dir, ".git")))
24825
24960
  return dir;
24826
- if (path36.dirname(dir) === dir)
24961
+ if (path37.dirname(dir) === dir)
24827
24962
  return null;
24828
24963
  }
24829
24964
  }
24830
24965
  var projectDirs = (cwd) => {
24831
24966
  const top = gitTop(cwd);
24832
24967
  const dirs = [];
24833
- for (let dir = path36.resolve(cwd);; dir = path36.dirname(dir)) {
24968
+ for (let dir = path37.resolve(cwd);; dir = path37.dirname(dir)) {
24834
24969
  dirs.push(dir);
24835
- if (!top || dir === top || path36.dirname(dir) === dir)
24970
+ if (!top || dir === top || path37.dirname(dir) === dir)
24836
24971
  return dirs;
24837
24972
  }
24838
24973
  };
@@ -24844,12 +24979,12 @@ var CLAUDE_MANAGED = {
24844
24979
  };
24845
24980
  function claudeSettingsFiles(cwd, env, platform = process.platform) {
24846
24981
  const project = env.CLAUDE_PROJECT_DIR || gitTop(cwd) || cwd;
24847
- const user = env.CLAUDE_CONFIG_DIR || path36.join(homeOf(env), ".claude");
24982
+ const user = env.CLAUDE_CONFIG_DIR || path37.join(homeOf(env), ".claude");
24848
24983
  return [
24849
24984
  ...CLAUDE_MANAGED[platform] ? [CLAUDE_MANAGED[platform]] : [],
24850
- path36.join(user, "settings.json"),
24851
- path36.join(project, ".claude", "settings.json"),
24852
- path36.join(project, ".claude", "settings.local.json")
24985
+ path37.join(user, "settings.json"),
24986
+ path37.join(project, ".claude", "settings.json"),
24987
+ path37.join(project, ".claude", "settings.local.json")
24853
24988
  ];
24854
24989
  }
24855
24990
  var bashPattern = (entry) => {
@@ -24939,10 +25074,10 @@ var opencodeConfig = (value, rules) => {
24939
25074
  function opencodeRules(cwd, env = process.env) {
24940
25075
  const rules = EMPTY2();
24941
25076
  try {
24942
- const config = env.XDG_CONFIG_HOME || path36.join(homeOf(env), ".config");
25077
+ const config = env.XDG_CONFIG_HOME || path37.join(homeOf(env), ".config");
24943
25078
  const files = [
24944
- ...OPENCODE_NAMES.map((name) => path36.join(config, "opencode", name)),
24945
- ...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path36.join(dir, name), path36.join(dir, ".opencode", name)])),
25079
+ ...OPENCODE_NAMES.map((name) => path37.join(config, "opencode", name)),
25080
+ ...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path37.join(dir, name), path37.join(dir, ".opencode", name)])),
24946
25081
  ...env.OPENCODE_CONFIG ? [env.OPENCODE_CONFIG] : []
24947
25082
  ];
24948
25083
  for (const file of files) {
@@ -24986,9 +25121,9 @@ var codexRule = (body) => {
24986
25121
  function codexRules(cwd, env = process.env) {
24987
25122
  const rules = EMPTY2();
24988
25123
  try {
24989
- const home = env.CODEX_HOME || path36.join(homeOf(env), ".codex");
25124
+ const home = env.CODEX_HOME || path37.join(homeOf(env), ".codex");
24990
25125
  const top = gitTop(cwd) ?? cwd;
24991
- for (const dir of [path36.join(home, "rules"), path36.join(top, ".codex", "rules")]) {
25126
+ for (const dir of [path37.join(home, "rules"), path37.join(top, ".codex", "rules")]) {
24992
25127
  let files;
24993
25128
  try {
24994
25129
  files = fs24.readdirSync(dir).filter((name) => name.endsWith(".rules"));
@@ -24998,7 +25133,7 @@ function codexRules(cwd, env = process.env) {
24998
25133
  return "unreadable";
24999
25134
  }
25000
25135
  for (const name of files) {
25001
- const text = readText3(path36.join(dir, name)) ?? "";
25136
+ const text = readText3(path37.join(dir, name)) ?? "";
25002
25137
  for (const part of text.split(/\bprefix_rule\s*\(/u).slice(1)) {
25003
25138
  const rule = codexRule(part);
25004
25139
  if (!rule)
@@ -25017,8 +25152,8 @@ function cursorRules(cwd, env = process.env) {
25017
25152
  try {
25018
25153
  const top = gitTop(cwd) ?? cwd;
25019
25154
  for (const file of [
25020
- path36.join(homeOf(env), ".cursor", "cli-config.json"),
25021
- path36.join(top, ".cursor", "cli.json")
25155
+ path37.join(homeOf(env), ".cursor", "cli-config.json"),
25156
+ path37.join(top, ".cursor", "cli.json")
25022
25157
  ]) {
25023
25158
  const text = readText3(file);
25024
25159
  if (text === null)
@@ -25093,10 +25228,10 @@ function wrapAllowed(read, words, command, options = {}) {
25093
25228
 
25094
25229
  // packages/workit-core/src/core/heavy.ts
25095
25230
  import fs25 from "node:fs";
25096
- import path37 from "node:path";
25231
+ import path38 from "node:path";
25097
25232
  var stateDir2 = (env, platform = process.platform) => stateDir(env, platform);
25098
25233
  var HEAVY_COMMANDS_FILE = "heavy-commands.json";
25099
- var heavyCommandsFile = (env) => path37.join(stateDir2(env), HEAVY_COMMANDS_FILE);
25234
+ var heavyCommandsFile = (env) => path38.join(stateDir2(env), HEAVY_COMMANDS_FILE);
25100
25235
  var HEAVY_SCRIPT = /^(?:test|tests|t|tst|unit|integration|e2e|coverage|cov|lint|eslint|typecheck|type-check|types|tsc|check|verify|validate|build|compile|bundle|ci|sonar|cypress|playwright|jest|vitest|mocha|bench|benchmark|all)(?:$|[:_.-])/iu;
25101
25236
  var INFO_FLAGS = new Set(["--version", "-v", "-V", "--help", "-h", "help", "version"]);
25102
25237
  var WATCH_FLAG = /^(?:--watch(?:All)?(?:=.*)?|-w|--serve)$/u;
@@ -25371,7 +25506,7 @@ function machinePatterns(env) {
25371
25506
  return isRecord5(value) ? stringList(value.patterns) : [];
25372
25507
  }
25373
25508
  function repoPatterns(cwd) {
25374
- return repoHeavyCommands(gitTop(cwd) ?? path37.resolve(cwd));
25509
+ return repoHeavyCommands(gitTop(cwd) ?? path38.resolve(cwd));
25375
25510
  }
25376
25511
  function heavyLines(lines, options) {
25377
25512
  const found = [];
@@ -25449,12 +25584,12 @@ function heavyPlan(command, options) {
25449
25584
  }
25450
25585
  function workitOnPath2(env = process.env) {
25451
25586
  const names = process.platform === "win32" ? ["workit.exe", "workit.cmd", "workit"] : ["workit"];
25452
- for (const dir of (env.PATH ?? "").split(path37.delimiter))
25587
+ for (const dir of (env.PATH ?? "").split(path38.delimiter))
25453
25588
  for (const name of names) {
25454
25589
  if (!dir)
25455
25590
  continue;
25456
25591
  try {
25457
- fs25.accessSync(path37.join(dir, name), fs25.constants.X_OK);
25592
+ fs25.accessSync(path38.join(dir, name), fs25.constants.X_OK);
25458
25593
  return true;
25459
25594
  } catch {}
25460
25595
  }
@@ -25472,7 +25607,7 @@ function leaseRewrite(command) {
25472
25607
 
25473
25608
  // packages/workit-core/src/core/heavy-words.ts
25474
25609
  import fs26 from "node:fs";
25475
- import path38 from "node:path";
25610
+ import path39 from "node:path";
25476
25611
  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(" "));
25477
25612
  var wordsOf = (command) => command.split(/[\s;&|()<>`'"]+/u).map((word) => (word.split(/[\\/]/u).at(-1) ?? "").toLowerCase().replace(/\.(?:exe|cmd|bat)$/u, "")).filter(Boolean);
25478
25613
  var stateDir3 = (env) => stateDir(env);
@@ -25485,15 +25620,15 @@ var readJson2 = (file) => {
25485
25620
  };
25486
25621
  var patternWords = (cwd, env) => {
25487
25622
  const patterns = [];
25488
- const machine = readJson2(path38.join(stateDir3(env), "heavy-commands.json"));
25623
+ const machine = readJson2(path39.join(stateDir3(env), "heavy-commands.json"));
25489
25624
  if (Array.isArray(machine?.patterns))
25490
25625
  patterns.push(...machine.patterns);
25491
- for (let dir = path38.resolve(cwd);; dir = path38.dirname(dir)) {
25492
- if (fs26.existsSync(path38.join(dir, ".git"))) {
25626
+ for (let dir = path39.resolve(cwd);; dir = path39.dirname(dir)) {
25627
+ if (fs26.existsSync(path39.join(dir, ".git"))) {
25493
25628
  patterns.push(...repoHeavyCommands(dir));
25494
25629
  break;
25495
25630
  }
25496
- if (path38.dirname(dir) === dir)
25631
+ if (path39.dirname(dir) === dir)
25497
25632
  break;
25498
25633
  }
25499
25634
  const words = new Set;
@@ -25556,16 +25691,16 @@ function heavyGate(cwd, command, options) {
25556
25691
  }
25557
25692
  }
25558
25693
  // packages/workit-core/src/hooks/write-gate.ts
25559
- import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as readFileSync11, realpathSync as realpathSync9, statSync as statSync5 } from "node:fs";
25694
+ import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as readFileSync12, realpathSync as realpathSync9, statSync as statSync5 } from "node:fs";
25560
25695
  import os9 from "node:os";
25561
- import path40 from "node:path";
25696
+ import path41 from "node:path";
25562
25697
 
25563
25698
  // packages/workit-core/src/core/live-session.ts
25564
25699
  import { spawnSync as spawnSync23 } from "node:child_process";
25565
- import { createHash as createHash17 } from "node:crypto";
25700
+ import { createHash as createHash18 } from "node:crypto";
25566
25701
  import fs27 from "node:fs";
25567
25702
  import os8 from "node:os";
25568
- import path39 from "node:path";
25703
+ import path40 from "node:path";
25569
25704
  var LIVE_SESSION_TTL_MS = 15 * 60000;
25570
25705
  var HEARTBEAT_EVERY_MS = 30000;
25571
25706
  var liveProbe = {
@@ -25639,15 +25774,15 @@ var liveOwner = (input, transport, env = process.env) => {
25639
25774
  };
25640
25775
  };
25641
25776
  var checkoutOf = (target) => {
25642
- let dir = path39.resolve(target);
25643
- while (!fs27.existsSync(dir) && path39.dirname(dir) !== dir)
25644
- dir = path39.dirname(dir);
25777
+ let dir = path40.resolve(target);
25778
+ while (!fs27.existsSync(dir) && path40.dirname(dir) !== dir)
25779
+ dir = path40.dirname(dir);
25645
25780
  if (fs27.existsSync(dir) && !fs27.statSync(dir).isDirectory())
25646
- dir = path39.dirname(dir);
25647
- const parts = dir.split(path39.sep);
25781
+ dir = path40.dirname(dir);
25782
+ const parts = dir.split(path40.sep);
25648
25783
  const dotGit = parts.lastIndexOf(".git");
25649
25784
  if (dotGit > 0)
25650
- dir = parts.slice(0, dotGit).join(path39.sep) || path39.sep;
25785
+ dir = parts.slice(0, dotGit).join(path40.sep) || path40.sep;
25651
25786
  const location = resolveStore(dir);
25652
25787
  if (location instanceof Error || !location.shared || !location.top)
25653
25788
  return null;
@@ -25657,9 +25792,9 @@ var checkoutOf = (target) => {
25657
25792
  } catch {}
25658
25793
  return top;
25659
25794
  };
25660
- var markerFile2 = (top) => path39.join(resolveStateDir(), "live-sessions", `${createHash17("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
25795
+ var markerFile2 = (top) => path40.join(resolveStateDir(), "live-sessions", `${createHash18("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
25661
25796
  var checkoutKey = (top, platform = process.platform) => {
25662
- let key = path39.resolve(top);
25797
+ let key = path40.resolve(top);
25663
25798
  try {
25664
25799
  key = fs27.realpathSync.native(key);
25665
25800
  } catch {}
@@ -25754,7 +25889,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
25754
25889
  checkout,
25755
25890
  heartbeatAt: now.toISOString()
25756
25891
  };
25757
- fs27.mkdirSync(path39.dirname(file), { recursive: true });
25892
+ fs27.mkdirSync(path40.dirname(file), { recursive: true });
25758
25893
  const temp = `${file}.${process.pid}.tmp`;
25759
25894
  fs27.writeFileSync(temp, JSON.stringify(marker));
25760
25895
  fs27.renameSync(temp, file);
@@ -25764,24 +25899,24 @@ var claimLiveSession = (target, owner, deps = {}) => {
25764
25899
  // packages/workit-core/src/hooks/write-gate.ts
25765
25900
  var NONE3 = { kind: "none" };
25766
25901
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
25767
- var canonical3 = (file) => {
25902
+ var canonical4 = (file) => {
25768
25903
  let rest = "";
25769
- for (let dir = path40.resolve(file);; dir = path40.dirname(dir)) {
25904
+ for (let dir = path41.resolve(file);; dir = path41.dirname(dir)) {
25770
25905
  try {
25771
- return path40.join(realpathSync9.native(dir), rest);
25906
+ return path41.join(realpathSync9.native(dir), rest);
25772
25907
  } catch {
25773
- if (path40.dirname(dir) === dir)
25774
- return path40.resolve(file);
25775
- rest = rest ? path40.join(path40.basename(dir), rest) : path40.basename(dir);
25908
+ if (path41.dirname(dir) === dir)
25909
+ return path41.resolve(file);
25910
+ rest = rest ? path41.join(path41.basename(dir), rest) : path41.basename(dir);
25776
25911
  }
25777
25912
  }
25778
25913
  };
25779
25914
  var exempt = (cwd, root, file, plans) => {
25780
25915
  const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
25781
- const relative = path40.relative(fold(canonical3(root)), fold(canonical3(path40.resolve(cwd, file))));
25782
- if (relative.startsWith("..") || path40.isAbsolute(relative))
25916
+ const relative = path41.relative(fold(canonical4(root)), fold(canonical4(path41.resolve(cwd, file))));
25917
+ if (relative.startsWith("..") || path41.isAbsolute(relative))
25783
25918
  return true;
25784
- const posix = relative.split(path40.sep).join("/");
25919
+ const posix = relative.split(path41.sep).join("/");
25785
25920
  const segments = posix.split("/");
25786
25921
  return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
25787
25922
  };
@@ -25897,8 +26032,8 @@ var WRAPPERS2 = {
25897
26032
  bunx: "p"
25898
26033
  };
25899
26034
  var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
25900
- var isConfigDir = (file) => configDirs().some((dir) => canonical3(dir) === canonical3(file));
25901
- var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path40.relative(canonical3(resolveStateDir()), canonical3(file)));
26035
+ var isConfigDir = (file) => configDirs().some((dir) => canonical4(dir) === canonical4(file));
26036
+ var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path41.relative(canonical4(resolveStateDir()), canonical4(file)));
25902
26037
  var READ_CALLS = /^(?:print|log|info|warn|error|debug|puts|readdir(?:Sync)?|listdir|scandir|iterdir|glob|l?stat(?:Sync)?|exists(?:Sync)?|isdir|isfile|is_dir|is_file|access(?:Sync)?|realpath(?:Sync)?|dirname|basename|relative|str|repr|len)$/;
25903
26038
  var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move|copy(?:2|file|tree|File)?(?:Sync)?|cp(?:Sync)?|rm(?:tree|dir|Sync|dirSync)?|unlink(?:Sync)?|remove(?:dirs)?|mkdirs?(?:Sync)?|makedirs|mkdtemp(?:Sync)?|(?:sym|hard)?link(?:Sync|_to)?|write\w*|append\w*|truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
25904
26039
  var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
@@ -26209,10 +26344,10 @@ var linkSources = (args, at) => {
26209
26344
  const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
26210
26345
  const target = dest === undefined ? null : at(dest);
26211
26346
  const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
26212
- const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync13(target) || /[\\/]$/.test(dest ?? "") ? target : path40.dirname(target);
26347
+ const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync13(target) || /[\\/]$/.test(dest ?? "") ? target : path41.dirname(target);
26213
26348
  return sources.flatMap((source) => {
26214
- if (symbolic && base !== null && !path40.isAbsolute(homeExpanded(source)))
26215
- return [path40.resolve(base, source)];
26349
+ if (symbolic && base !== null && !path41.isAbsolute(homeExpanded(source)))
26350
+ return [path41.resolve(base, source)];
26216
26351
  const resolved = at(source);
26217
26352
  return resolved ? [resolved] : [];
26218
26353
  });
@@ -26241,7 +26376,7 @@ var shellWrites = (command, depth = 0) => {
26241
26376
  return { writes: true, targets: unknown ? null : targets };
26242
26377
  };
26243
26378
  var cache3 = new Map;
26244
- var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path40.resolve(root, file)) ?? "-").join("\x00");
26379
+ var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path41.resolve(root, file)) ?? "-").join("\x00");
26245
26380
  var gateFor = (cwd) => {
26246
26381
  const store = new TaskReader(cwd);
26247
26382
  const listed = store.listTaskIndex();
@@ -26321,13 +26456,13 @@ var gitMutationDirs = (cwd, command, dialect) => {
26321
26456
  return [];
26322
26457
  if (sub === "stash" && ["list", "show"].includes(rest[0] ?? ""))
26323
26458
  return [];
26324
- return [path40.resolve(cwd, invocation.dir ?? ".")];
26459
+ return [path41.resolve(cwd, invocation.dir ?? ".")];
26325
26460
  });
26326
26461
  };
26327
26462
  var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
26328
26463
  var PUSHD2 = new Set(["pushd", "push-location"]);
26329
26464
  var POPD2 = new Set(["popd", "pop-location"]);
26330
- var UNKNOWN_DIR = path40.resolve(path40.parse(process.cwd()).root, ".workit-unknown-dir");
26465
+ var UNKNOWN_DIR = path41.resolve(path41.parse(process.cwd()).root, ".workit-unknown-dir");
26331
26466
  var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
26332
26467
  const lost = strict ? UNKNOWN_DIR : undefined;
26333
26468
  const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
@@ -26337,7 +26472,7 @@ var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
26337
26472
  return lost;
26338
26473
  if (dir === undefined)
26339
26474
  return lost;
26340
- return target === undefined ? os9.homedir() : path40.resolve(dir, target);
26475
+ return target === undefined ? os9.homedir() : path41.resolve(dir, target);
26341
26476
  };
26342
26477
  var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
26343
26478
  var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
@@ -26472,7 +26607,7 @@ var untrustedVars = (segments) => {
26472
26607
  }
26473
26608
  return { all, names };
26474
26609
  };
26475
- var UNKNOWN_VAR = path40.resolve(path40.parse(process.cwd()).root, ".workit-unknown-var");
26610
+ var UNKNOWN_VAR = path41.resolve(path41.parse(process.cwd()).root, ".workit-unknown-var");
26476
26611
  var REFERENCE = /\$\{(\w+)[^}]*\}|\$(\w+)|\$\([^)]*\)?|`[^`]*`?/g;
26477
26612
  var unresolvedRefs = (text) => [
26478
26613
  ...new Set([...text.matchAll(REFERENCE)].map((match) => {
@@ -26482,7 +26617,7 @@ var unresolvedRefs = (text) => [
26482
26617
  ];
26483
26618
  var unknownVarTarget = (text) => {
26484
26619
  const refs = unresolvedRefs(text);
26485
- return path40.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
26620
+ return path41.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
26486
26621
  };
26487
26622
  var applyOperator = (value, operator) => {
26488
26623
  if (operator === "")
@@ -26543,12 +26678,12 @@ var mktempPath = (value, dir) => {
26543
26678
  if (base === null && (temp || template === undefined))
26544
26679
  base = os9.tmpdir();
26545
26680
  const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
26546
- if (path40.isAbsolute(name))
26681
+ if (path41.isAbsolute(name))
26547
26682
  return name;
26548
26683
  const from = base === null ? dir : homeExpanded(base);
26549
- if (from === undefined || !path40.isAbsolute(from) && dir === undefined)
26684
+ if (from === undefined || !path41.isAbsolute(from) && dir === undefined)
26550
26685
  return null;
26551
- return path40.resolve(dir ?? from, from, name);
26686
+ return path41.resolve(dir ?? from, from, name);
26552
26687
  };
26553
26688
  var homeExpanded = (file) => {
26554
26689
  const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
@@ -26569,9 +26704,9 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26569
26704
  const home = homeExpanded(text);
26570
26705
  if (strict && unresolvedRefs(home).length > 0)
26571
26706
  return [unknownVarTarget(home)];
26572
- if (path40.isAbsolute(home))
26707
+ if (path41.isAbsolute(home))
26573
26708
  return [home];
26574
- return base === undefined ? [] : [path40.resolve(base, home)];
26709
+ return base === undefined ? [] : [path41.resolve(base, home)];
26575
26710
  });
26576
26711
  const at = (file) => {
26577
26712
  const all = atAll(file);
@@ -26719,7 +26854,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26719
26854
  return [made];
26720
26855
  try {
26721
26856
  const stat = statSync5(script);
26722
- const text = stat.isFile() && stat.size <= 262144 ? readFileSync11(script, "utf8") : "\x00";
26857
+ const text = stat.isFile() && stat.size <= 262144 ? readFileSync12(script, "utf8") : "\x00";
26723
26858
  return text.includes("\x00") ? [] : [text];
26724
26859
  } catch {
26725
26860
  return [];
@@ -26762,7 +26897,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26762
26897
  index
26763
26898
  }));
26764
26899
  const homes = /homedir\(|expanduser\(|Path\.home\(|['"]HOME['"]|env\.HOME|\$HOME|~/.test(text);
26765
- const under = (word) => homes ? [path40.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
26900
+ const under = (word) => homes ? [path41.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
26766
26901
  const found = [
26767
26902
  ...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
26768
26903
  ...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
@@ -26801,7 +26936,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26801
26936
  for (const file of opaque ?? [])
26802
26937
  for (const resolved of atAll(file))
26803
26938
  if (!quiet || !isRoot(resolved))
26804
- targets.push(file === "." ? path40.join(resolved, here) : resolved);
26939
+ targets.push(file === "." ? path41.join(resolved, here) : resolved);
26805
26940
  const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
26806
26941
  const lnArgs = words.slice(ln + 1);
26807
26942
  if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
@@ -26813,7 +26948,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26813
26948
  const edits = editsOf(body);
26814
26949
  if (edits === null) {
26815
26950
  if (dir !== undefined)
26816
- targets.push(path40.join(dir, DIR_TARGET));
26951
+ targets.push(path41.join(dir, DIR_TARGET));
26817
26952
  } else
26818
26953
  for (const file of edits)
26819
26954
  targets.push(...atAll(file));
@@ -26821,7 +26956,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26821
26956
  for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
26822
26957
  const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
26823
26958
  if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
26824
- targets.push(...runsIn.map((runs) => path40.join(runs, DIR_TARGET)));
26959
+ targets.push(...runsIn.map((runs) => path41.join(runs, DIR_TARGET)));
26825
26960
  }
26826
26961
  }
26827
26962
  return targets;
@@ -26843,7 +26978,7 @@ var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) =>
26843
26978
  const env = new Map(strict === "registry" ? [...command.matchAll(/\$\{?([A-Za-z_]\w*)/g)].filter((match) => !/^(?:OLD)?PWD$/.test(match[1])).map((match) => [match[1], process.env[match[1]] ?? ""]) : []);
26844
26979
  return [
26845
26980
  ...segmentTargets(cwd, command, dialect, 0, strict, env),
26846
- ...gitMutationDirs(cwd, command, dialect).map((dir) => path40.join(dir, DIR_TARGET))
26981
+ ...gitMutationDirs(cwd, command, dialect).map((dir) => path41.join(dir, DIR_TARGET))
26847
26982
  ];
26848
26983
  } catch (error) {
26849
26984
  if (strict === "registry")
@@ -26882,7 +27017,7 @@ var liveDeny = ({ marker, checkout, ageMs, file }) => {
26882
27017
  var guarded = (targets) => {
26883
27018
  const seen = new Set;
26884
27019
  return targets.filter((target) => {
26885
- const dir = path40.dirname(target);
27020
+ const dir = path41.dirname(target);
26886
27021
  if (seen.has(dir))
26887
27022
  return false;
26888
27023
  seen.add(dir);
@@ -26903,15 +27038,16 @@ var claimAll = (owner, targets, deps) => {
26903
27038
  for (const target of guarded(targets))
26904
27039
  claimLiveSession(target, owner, deps);
26905
27040
  };
26906
- var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path40.resolve(cwd, file)) : [path40.join(cwd, DIR_TARGET)];
27041
+ var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path41.resolve(cwd, file)) : [path41.join(cwd, DIR_TARGET)];
27042
+ var CONFIG_FILES = ["workspaces.json", SEAL_FILE];
26907
27043
  var configDirs = () => [resolveConfigDir(), grantsDir()];
26908
27044
  var globbed = (cwd, target, state, configs) => {
26909
27045
  if (!/[*?[]/.test(target))
26910
27046
  return [];
26911
- const raw = path40.resolve(cwd, target).split(path40.sep);
27047
+ const raw = path41.resolve(cwd, target).split(path41.sep);
26912
27048
  const literal = raw.findIndex((part) => /[*?[]/.test(part));
26913
27049
  const pattern = [
26914
- ...canonical3(raw.slice(0, literal).join(path40.sep) || path40.sep).replace(/[\\/]+$/, "").split(path40.sep),
27050
+ ...canonical4(raw.slice(0, literal).join(path41.sep) || path41.sep).replace(/[\\/]+$/, "").split(path41.sep),
26915
27051
  ...raw.slice(literal)
26916
27052
  ];
26917
27053
  const segment = (glob, name) => {
@@ -26922,7 +27058,7 @@ var globbed = (cwd, target, state, configs) => {
26922
27058
  }
26923
27059
  };
26924
27060
  const hit = (file, below) => {
26925
- const parts = canonical3(file).split(path40.sep);
27061
+ const parts = canonical4(file).split(path41.sep);
26926
27062
  return (below ? pattern.length >= parts.length : pattern.length === parts.length) && parts.every((part, index) => segment(pattern[index], part));
26927
27063
  };
26928
27064
  let roots = [];
@@ -26930,8 +27066,8 @@ var globbed = (cwd, target, state, configs) => {
26930
27066
  roots = readdirSync5(state).filter((name) => /^(?:issued|approvals$)/.test(name));
26931
27067
  } catch {}
26932
27068
  return [
26933
- ...roots.map((name) => path40.join(state, name)).filter((root) => hit(root, true)),
26934
- ...configs.flatMap((dir) => [dir, path40.join(dir, "workspaces.json")]).filter((file) => hit(file, false))
27069
+ ...roots.map((name) => path41.join(state, name)).filter((root) => hit(root, true)),
27070
+ ...configs.flatMap((dir) => [dir, ...CONFIG_FILES.map((name) => path41.join(dir, name))]).filter((file) => hit(file, false))
26935
27071
  ];
26936
27072
  };
26937
27073
  var guardedInodes = (state, configs) => {
@@ -26945,14 +27081,15 @@ var guardedInodes = (state, configs) => {
26945
27081
  seen.set(`${stat.dev}:${stat.ino}`, registry);
26946
27082
  else if (stat?.isDirectory())
26947
27083
  for (const name of readdirSync5(file))
26948
- add(path40.join(file, name), registry);
27084
+ add(path41.join(file, name), registry);
26949
27085
  };
26950
27086
  try {
26951
27087
  for (const dir of configs)
26952
- add(path40.join(dir, "workspaces.json"), "grants");
27088
+ for (const name of CONFIG_FILES)
27089
+ add(path41.join(dir, name), "grants");
26953
27090
  for (const name of readdirSync5(state))
26954
27091
  if (/^(?:issued|approvals$)/.test(name))
26955
- add(path40.join(state, name), name === "approvals" ? "approvals" : "issued");
27092
+ add(path41.join(state, name), name === "approvals" ? "approvals" : "issued");
26956
27093
  } catch {}
26957
27094
  return seen;
26958
27095
  };
@@ -26977,7 +27114,7 @@ var registryTarget = (cwd, targets) => {
26977
27114
  const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
26978
27115
  if (viaGlob)
26979
27116
  return { file: target, registry: viaGlob.registry };
26980
- const registry = hardLinked(path40.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical3) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical3)) ? "grants" : null);
27117
+ const registry = hardLinked(path41.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical4) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical4)) ? "grants" : null);
26981
27118
  if (registry)
26982
27119
  return { file: target, registry };
26983
27120
  }
@@ -26985,7 +27122,7 @@ var registryTarget = (cwd, targets) => {
26985
27122
  };
26986
27123
  var partsUnder = (dir, cwd, target, platform, real) => {
26987
27124
  const win = platform === "win32";
26988
- const p = win ? path40.win32 : path40.posix;
27125
+ const p = win ? path41.win32 : path41.posix;
26989
27126
  const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
26990
27127
  const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
26991
27128
  const relative = p.relative(fold(real(p.resolve(dir))), fold(real(p.resolve(cwd, named))));
@@ -26999,7 +27136,7 @@ var underRegistry = (state, cwd, target, platform = process.platform, real = (fi
26999
27136
  };
27000
27137
  var underConfig = (dir, cwd, target, platform = process.platform, real = (file) => file) => {
27001
27138
  const parts = partsUnder(dir, cwd, target, platform, real);
27002
- return parts?.length === 1 && ["", "workspaces.json", DIR_TARGET].includes(parts[0]);
27139
+ return parts?.length === 1 && ["", ...CONFIG_FILES, DIR_TARGET].includes(parts[0]);
27003
27140
  };
27004
27141
  var unquotedWindowsRegistry = (command, platform = process.platform) => {
27005
27142
  if (platform !== "win32" || !command.includes("\\"))
@@ -27019,7 +27156,7 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
27019
27156
  ];
27020
27157
  const named = (target) => moved.some((dir) => {
27021
27158
  const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
27022
- return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, `${cfg}/workspaces.json`].includes(at)) : at.includes(`${state}/${registry}`);
27159
+ return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, ...CONFIG_FILES.map((name) => `${cfg}/${name}`)].includes(at)) : at.includes(`${state}/${registry}`);
27023
27160
  });
27024
27161
  return writes.writes && (writes.targets === null || writes.targets.some(named)) ? registry : null;
27025
27162
  };
@@ -27042,7 +27179,7 @@ var REGISTRY_DENY = {
27042
27179
  };
27043
27180
  var registryDeny = ({ file, registry }) => {
27044
27181
  const { label, what, unblock } = REGISTRY_DENY[registry];
27045
- const named = path40.basename(file).startsWith(".workit-") ? path40.dirname(file) : file;
27182
+ const named = path41.basename(file).startsWith(".workit-") ? path41.dirname(file) : file;
27046
27183
  return {
27047
27184
  kind: "deny",
27048
27185
  reason: `workit ${label}: ${named} is under ${what}. ${unblock}`,
@@ -27132,10 +27269,10 @@ import { spawnSync as spawnSync24 } from "node:child_process";
27132
27269
 
27133
27270
  // packages/workit-core/src/ci-waiter.ts
27134
27271
  import fs28 from "node:fs";
27135
- import path41 from "node:path";
27272
+ import path42 from "node:path";
27136
27273
  var waiterFile = (cwd, pr) => {
27137
27274
  const common = gitCommonDir(cwd);
27138
- return common ? path41.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
27275
+ return common ? path42.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
27139
27276
  };
27140
27277
  var pidAlive2 = (pid) => {
27141
27278
  if (!Number.isSafeInteger(pid) || pid <= 0)
@@ -27646,7 +27783,7 @@ var WRITE_TOOLS = new Set([
27646
27783
  ]);
27647
27784
  // packages/workit-core/src/hooks/standing.ts
27648
27785
  import fs29 from "node:fs";
27649
- import path42 from "node:path";
27786
+ import path43 from "node:path";
27650
27787
 
27651
27788
  // packages/workit-core/src/approvals/store.ts
27652
27789
  var REQUEST_TTL_MS = 30 * 60000;
@@ -28156,7 +28293,7 @@ var workitRole = (descriptor, agentType) => {
28156
28293
 
28157
28294
  // packages/workit-core/src/hooks/standing.ts
28158
28295
  var readPlans = (store) => {
28159
- const dir = path42.join(store, "fanouts");
28296
+ const dir = path43.join(store, "fanouts");
28160
28297
  let names;
28161
28298
  try {
28162
28299
  names = fs29.readdirSync(dir).filter((name) => name.endsWith(".json"));
@@ -28166,7 +28303,7 @@ var readPlans = (store) => {
28166
28303
  const plans = [];
28167
28304
  for (const name of names) {
28168
28305
  try {
28169
- const raw = JSON.parse(fs29.readFileSync(path42.join(dir, name), "utf8"));
28306
+ const raw = JSON.parse(fs29.readFileSync(path43.join(dir, name), "utf8"));
28170
28307
  if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
28171
28308
  continue;
28172
28309
  const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
@@ -28503,7 +28640,7 @@ var minutesOf = (text = "") => {
28503
28640
  });
28504
28641
  return rest.trim() || !Number.isInteger(total) || total <= 0 ? null : total;
28505
28642
  };
28506
- var VALUE = new Set(("--host --body -b --body-file --text --date --duration --type --project -p --summary -s " + "--description --description-file --field --tag --add-tag --remove-tag --assignee --comment " + "--json --jq -X --method -f -F --raw-field --input --fields -q --query --author --since --limit").split(" "));
28643
+ var VALUE = new Set(("--host --body -b --body-file --text --date --duration --type --project -p --summary -s " + "--description --description-file --field --tag --add-tag --remove-tag --assignee --comment " + "--json --jq -X --method -f -F --raw-field --input --fields -q --query --author --since --limit " + "--attach -H --header").split(" "));
28507
28644
  var BARE = new Set("--debug --no-color --paginate --include --dry-run --silent --yes --meeting --help -h".split(" "));
28508
28645
  var standsAlone = (args, at) => {
28509
28646
  const before = args[at - 1] ?? "";
@@ -28522,7 +28659,7 @@ var ASKS = /^(?:post|put|patch|delete)$/i;
28522
28659
  var BODY = /^(?:-[fF]|--(?:field|raw-field|input))(?:=|$)|^-[fF]./;
28523
28660
  var QUIET = /^--(?:debug|no-color|json|jq)$/;
28524
28661
  var CARRIES = {
28525
- note: { "--body": "body", "-b": "body", "--body-file": "file" },
28662
+ note: { "--body": "body", "-b": "body", "--body-file": "file", "--attach": "attach" },
28526
28663
  time: { "--duration": "duration", "--text": "text", "--date": "date" },
28527
28664
  create: {
28528
28665
  "--project": "project",
@@ -28534,9 +28671,60 @@ var CARRIES = {
28534
28671
  }
28535
28672
  };
28536
28673
  var gap = (part) => ({ workit: null, gap: part });
28674
+ var ISSUE = /^[A-Z][A-Z0-9_]*-\d+$/;
28675
+ var EXPANDS = /[$`*?[\]]|^~/;
28676
+ var commandFlag = (command) => {
28677
+ const state = /^State\s+(\S.*)$/u.exec(command)?.[1];
28678
+ return state ? pair("--state", state) : pair("--command", command);
28679
+ };
28680
+ var callFor = (effect) => {
28681
+ const comment = effect.markdown !== undefined || effect.file !== undefined;
28682
+ const time = effect.minutes !== undefined;
28683
+ const timeFlags = [
28684
+ effect.text === undefined ? "" : pair("--text", effect.text),
28685
+ effect.date === undefined ? "" : pair("--date", effect.date)
28686
+ ];
28687
+ const commentFlag = effect.markdown !== undefined ? pair("--markdown", effect.markdown) : effect.file !== undefined ? pair("--file", effect.file) : "";
28688
+ const only = !effect.attach?.length && effect.command === undefined;
28689
+ if (only && comment && !time)
28690
+ return `workit youtrack note ${effect.issue} ${commentFlag}`;
28691
+ if (only && time && !comment)
28692
+ return [`workit youtrack time ${effect.issue} --minutes ${effect.minutes}`, ...timeFlags].filter(Boolean).join(" ");
28693
+ return [
28694
+ `workit youtrack update ${effect.issue}`,
28695
+ commentFlag,
28696
+ ...(effect.attach ?? []).map((file) => pair("--attach", file)),
28697
+ time ? `--minutes ${effect.minutes}` : "",
28698
+ ...time ? timeFlags : [],
28699
+ effect.command === undefined ? "" : commandFlag(effect.command)
28700
+ ].filter(Boolean).join(" ");
28701
+ };
28702
+ var mapped = (effect) => ({ workit: callFor(effect), effect });
28703
+ var combine = (effects) => {
28704
+ const out = { issue: effects[0].issue };
28705
+ for (const effect of effects) {
28706
+ if (effect.issue !== out.issue)
28707
+ return null;
28708
+ const comment = effect.markdown !== undefined || effect.file !== undefined;
28709
+ if (comment && (out.markdown !== undefined || out.file !== undefined))
28710
+ return null;
28711
+ if (effect.minutes !== undefined && out.minutes !== undefined)
28712
+ return null;
28713
+ if (effect.command !== undefined && out.command !== undefined)
28714
+ return null;
28715
+ Object.assign(out, {
28716
+ ...effect,
28717
+ attach: [...out.attach ?? [], ...effect.attach ?? []]
28718
+ });
28719
+ }
28720
+ if (!out.attach?.length)
28721
+ delete out.attach;
28722
+ return out;
28723
+ };
28537
28724
  var pair = (flag, value) => value.startsWith("-") ? `${flag}=${quote2(value)}` : `${flag} ${quote2(value)}`;
28538
28725
  var mapWrite = (verb, args) => {
28539
28726
  const values = {};
28727
+ const attach = [];
28540
28728
  const operands = [];
28541
28729
  for (let at = 0;at < args.length; at++) {
28542
28730
  const arg = args[at];
@@ -28552,9 +28740,12 @@ var mapWrite = (verb, args) => {
28552
28740
  const key = CARRIES[verb][flag];
28553
28741
  if (!key || value === undefined || key in values)
28554
28742
  return gap(`\`${flag}\``);
28555
- if (/[$`]|^~/.test(value))
28743
+ if (/[$`]|^~/.test(value) || key === "attach" && EXPANDS.test(value))
28556
28744
  return gap(`the value of \`${flag}\`, which the shell expands when it runs`);
28557
- values[key] = value;
28745
+ if (key === "attach")
28746
+ attach.push(value);
28747
+ else
28748
+ values[key] = value;
28558
28749
  }
28559
28750
  const [issue, ...more] = operands.slice(2);
28560
28751
  const v = values;
@@ -28577,7 +28768,7 @@ var mapWrite = (verb, args) => {
28577
28768
  ].filter(Boolean).join(" ")
28578
28769
  };
28579
28770
  }
28580
- if (issue === undefined || more.length || !/^[A-Z]+-\d+$/.test(issue))
28771
+ if (issue === undefined || more.length || !ISSUE.test(issue))
28581
28772
  return gap("the issue, which must be one id like ABC-123");
28582
28773
  if (verb === "note") {
28583
28774
  if (v.body === undefined === (v.file === undefined))
@@ -28586,22 +28777,108 @@ var mapWrite = (verb, args) => {
28586
28777
  return gap("text read from standard input");
28587
28778
  if (v.body !== undefined && !v.body.trim())
28588
28779
  return gap("an empty --body");
28589
- return {
28590
- workit: `workit youtrack note ${issue} ${v.body === undefined ? pair("--file", v.file) : pair("--markdown", v.body)}`
28591
- };
28780
+ return mapped({
28781
+ issue,
28782
+ ...v.body === undefined ? { file: v.file } : { markdown: v.body },
28783
+ ...attach.length ? { attach } : {}
28784
+ });
28592
28785
  }
28593
28786
  const minutes = minutesOf(v.duration);
28594
28787
  if (minutes === null)
28595
28788
  return gap(`\`--duration ${v.duration ?? ""}\`, which is no whole number of minutes`);
28596
28789
  if (v.date !== undefined && !/^(?:auto|\d{4}-\d{2}-\d{2})$/.test(v.date))
28597
28790
  return gap(`\`--date ${v.date}\``);
28598
- return {
28599
- workit: [
28600
- `workit youtrack time ${issue} --minutes ${minutes}`,
28601
- v.text === undefined ? "" : pair("--text", v.text),
28602
- v.date === undefined ? "" : pair("--date", v.date)
28603
- ].filter(Boolean).join(" ")
28604
- };
28791
+ return mapped({
28792
+ issue,
28793
+ minutes,
28794
+ ...v.text === undefined ? {} : { text: v.text },
28795
+ ...v.date === undefined ? {} : { date: v.date }
28796
+ });
28797
+ };
28798
+ var mapIssueWrite = (verb, args) => {
28799
+ const operands = [];
28800
+ for (let at = 0;at < args.length; at++) {
28801
+ const arg = args[at];
28802
+ if (!arg.startsWith("-") || arg === "-") {
28803
+ operands.push(arg);
28804
+ continue;
28805
+ }
28806
+ const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
28807
+ const flag = eq > 0 ? arg.slice(0, eq) : arg;
28808
+ if (!QUIET.test(flag))
28809
+ return gap(`\`${flag}\``);
28810
+ if (eq < 0 && VALUE.has(flag))
28811
+ at++;
28812
+ }
28813
+ const [issue, ...rest] = operands.slice(2);
28814
+ if (issue === undefined || !ISSUE.test(issue))
28815
+ return gap("the issue, which must be one id like ABC-123");
28816
+ if (verb === "attach") {
28817
+ if (!rest.length)
28818
+ return gap("an attach with no file");
28819
+ const odd = rest.find((file) => file === "-" || EXPANDS.test(file));
28820
+ if (odd !== undefined)
28821
+ return gap(`the file \`${odd}\`, which the shell expands or reads from standard input`);
28822
+ return mapped({ issue, attach: rest });
28823
+ }
28824
+ if (rest.length !== 1 || !rest[0].trim())
28825
+ return gap("a command that is not one quoted word (`ytrack issue command X-1 'State Done'`)");
28826
+ if (/[$`]/.test(rest[0]))
28827
+ return gap("a command the shell expands when it runs");
28828
+ return mapped({ issue, command: rest[0].trim() });
28829
+ };
28830
+ var mapApi = (args, target) => {
28831
+ const where = /^\/?(?:api\/)?issues\/([A-Z][A-Z0-9_]*-\d+)\/(comments|attachments)\/?(?:\?.*)?$/u.exec(target);
28832
+ if (!where)
28833
+ return null;
28834
+ const [, issue, kind] = where;
28835
+ const fields = [];
28836
+ for (let at = 0;at < args.length; at++) {
28837
+ const arg = args[at];
28838
+ if (!arg.startsWith("-"))
28839
+ continue;
28840
+ const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
28841
+ const glued = /^-[fFX]./.test(arg) && !arg.startsWith("--");
28842
+ const flag = glued ? arg.slice(0, 2) : eq > 0 ? arg.slice(0, eq) : arg;
28843
+ const value = glued ? arg.slice(2) : eq > 0 ? arg.slice(eq + 1) : VALUE.has(flag) ? args[++at] : undefined;
28844
+ if (QUIET.test(flag))
28845
+ continue;
28846
+ if (/^(?:-X|--method)$/.test(flag)) {
28847
+ if (!/^=?post$/i.test(value ?? ""))
28848
+ return gap(`\`${flag} ${value ?? ""}\``);
28849
+ continue;
28850
+ }
28851
+ if (/^(?:-H|--header)$/.test(flag) && /^(?:content-type|accept)\s*:/i.test(value ?? ""))
28852
+ continue;
28853
+ if (!/^(?:-f|-F|--field|--raw-field)$/.test(flag) || value === undefined)
28854
+ return gap(`\`${flag}\``);
28855
+ const split = value.indexOf("=");
28856
+ if (split <= 0)
28857
+ return gap(`the field \`${value}\``);
28858
+ fields.push({
28859
+ typed: flag === "-F" || flag === "--field",
28860
+ key: value.slice(0, split),
28861
+ value: value.slice(split + 1)
28862
+ });
28863
+ }
28864
+ if (fields.some((field) => /[$`]/.test(field.value)))
28865
+ return gap("a field value the shell expands when it runs");
28866
+ if (kind === "comments") {
28867
+ const [field, ...more] = fields;
28868
+ if (!field || more.length || field.key !== "text")
28869
+ return gap("a comment body other than one `text` field");
28870
+ if (field.typed && field.value.startsWith("@")) {
28871
+ const file = field.value.slice(1);
28872
+ if (!file || file === "-" || EXPANDS.test(file))
28873
+ return gap(`the file \`${file}\``);
28874
+ return mapped({ issue, file });
28875
+ }
28876
+ return field.value.trim() ? mapped({ issue, markdown: field.value }) : gap("an empty `text`");
28877
+ }
28878
+ const files = fields.map((field) => field.typed && field.value.startsWith("@") ? field.value.slice(1) : null);
28879
+ if (!files.length || files.some((file) => !file || file === "-" || EXPANDS.test(file)))
28880
+ return gap("an upload other than `-F <name>=@<file>` fields");
28881
+ return mapped({ issue, attach: files });
28605
28882
  };
28606
28883
  var UNCOVERED = { workit: null, gap: "" };
28607
28884
  var classify2 = (args) => {
@@ -28616,11 +28893,12 @@ var judge = (args, words) => {
28616
28893
  const verb = words[1] ?? "";
28617
28894
  if (group === "api") {
28618
28895
  const methods = args.flatMap((arg, at) => /^(?:-X|--method)$/.test(arg) ? [{ value: args[at + 1] ?? "", alone: standsAlone(args, at) }] : /^(?:-X.|--method=)/.test(arg) ? [{ value: arg.replace(/^(?:-X=?|--method=)/, ""), alone: standsAlone(args, at) }] : []);
28896
+ const posts = methods.length > 0 && methods.every((method) => /^post$/i.test(method.value));
28619
28897
  if (methods.some((method) => ASKS.test(method.value)))
28620
- return UNCOVERED;
28898
+ return (posts ? mapApi(args, words[1] ?? "") : null) ?? UNCOVERED;
28621
28899
  if (methods.some((method) => method.alone))
28622
28900
  return null;
28623
- return args.some((a) => BODY.test(a)) ? UNCOVERED : null;
28901
+ return args.some((a) => BODY.test(a)) ? mapApi(args, words[1] ?? "") ?? UNCOVERED : null;
28624
28902
  }
28625
28903
  if (group === "work-item" && /^(?:add|create)$/.test(verb))
28626
28904
  return mapWrite("time", args);
@@ -28633,7 +28911,9 @@ var judge = (args, words) => {
28633
28911
  if (verb === "create")
28634
28912
  return mapWrite("create", args);
28635
28913
  if (verb === "command")
28636
- return flagged(args, /^--dry-run$/) ? null : UNCOVERED;
28914
+ return flagged(args, /^--dry-run$/) ? null : mapIssueWrite("command", args);
28915
+ if (verb === "attach")
28916
+ return mapIssueWrite("attach", args);
28637
28917
  return /^(?:edit|update|delete|rm)$/.test(verb) ? UNCOVERED : null;
28638
28918
  };
28639
28919
  var SHELLS3 = /^(?:sh|bash|zsh|dash|ksh|ash|mksh|yash|fish)$/;
@@ -28711,7 +28991,10 @@ var passed = (words) => {
28711
28991
  };
28712
28992
  var plainLines = (command, dialect) => {
28713
28993
  let first = null;
28994
+ const chain = [];
28714
28995
  const later = [];
28996
+ let chaining = !command.includes("||");
28997
+ let piped = false;
28715
28998
  for (const segment of segmentsOf(command, dialect)) {
28716
28999
  if (segment.group || segment.unanalyzable || segment.subs?.length)
28717
29000
  return null;
@@ -28724,10 +29007,32 @@ var plainLines = (command, dialect) => {
28724
29007
  if (!names || segment.expands?.length)
28725
29008
  return null;
28726
29009
  first = passed(segment.words);
28727
- } else if (names)
28728
- later.push(segment.words);
29010
+ chaining &&= name2(first[0]) === "ytrack";
29011
+ } else {
29012
+ const words = passed(segment.words);
29013
+ chaining &&= !piped && !segment.expands?.length && !segment.stdin?.length && !segment.inputs?.length && name2(words[0]) === "ytrack";
29014
+ if (chaining)
29015
+ chain.push(words);
29016
+ else if (names)
29017
+ later.push(segment.words);
29018
+ }
29019
+ piped = segment.pipe === true;
28729
29020
  }
28730
- return first ? { first, later } : null;
29021
+ return first ? { first, chain, later } : null;
29022
+ };
29023
+ var chained = (first, chain, depth) => {
29024
+ if (first.length !== 1 || !first[0].effect || !chain.length)
29025
+ return null;
29026
+ const found = [...first];
29027
+ for (const line of chain)
29028
+ ytrackArgs(line, found, depth, new Map, true);
29029
+ const effects = found.flatMap((write) => write.effect ? [write.effect] : []);
29030
+ if (effects.length !== found.length)
29031
+ return null;
29032
+ const effect = combine(effects);
29033
+ if (!effect)
29034
+ return null;
29035
+ return [{ command: found.map((write) => write.command).join(" && "), ...mapped(effect) }];
28731
29036
  };
28732
29037
  var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
28733
29038
  if (!namesYtrack(command))
@@ -28741,7 +29046,11 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
28741
29046
  let found = [];
28742
29047
  const lines = plain ? plainLines(command, dialect) : null;
28743
29048
  const none = new Map;
28744
- if (!lines || !ytrackArgs(lines.first, found, depth, none, true) || !lines.later.every((line) => ytrackArgs(line, found, depth, none, false))) {
29049
+ const plainFirst = lines ? ytrackArgs(lines.first, found, depth, none, true) : false;
29050
+ const joined = lines && plainFirst ? chained(found, lines.chain, depth) : null;
29051
+ if (joined)
29052
+ found = joined;
29053
+ if (!lines || !plainFirst || !(joined ? [] : lines.chain).every((line) => ytrackArgs(line, found, depth, none, false)) || !lines.later.every((line) => ytrackArgs(line, found, depth, none, false))) {
28745
29054
  found = [];
28746
29055
  for (const line of commandLines(command, dialect))
28747
29056
  ytrackArgs(line, found, depth, aliases(command), false);
@@ -28751,7 +29060,6 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
28751
29060
  READ.delete(READ.keys().next().value);
28752
29061
  return found;
28753
29062
  };
28754
- var writesMode = (cwd) => resolveRuntimeWorkspaceVcs(cwd)?.youtrack?.writes;
28755
29063
  var ytrackGate = (cwd, command, dialect, ask) => {
28756
29064
  let writes;
28757
29065
  try {
@@ -28762,7 +29070,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
28762
29070
  }
28763
29071
  writes = [...merged.values()];
28764
29072
  } catch {
28765
- if (writesMode(cwd) === "auto")
29073
+ if (youTrackWritesMode(cwd) === "auto")
28766
29074
  return null;
28767
29075
  return {
28768
29076
  kind: "deny",
@@ -28770,7 +29078,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
28770
29078
  unblock: null
28771
29079
  };
28772
29080
  }
28773
- if (!writes.length || writesMode(cwd) === "auto")
29081
+ if (!writes.length || youTrackWritesMode(cwd) === "auto")
28774
29082
  return null;
28775
29083
  const calls = writes.flatMap((write) => write.workit ? [`\`${write.workit}\``] : []);
28776
29084
  const bare = writes.filter((write) => !write.workit).map((write) => `\`${write.command}\` (${write.gap ? `Workit cannot carry ${write.gap} into a workit youtrack call` : "no workit youtrack verb covers it"})`);
@@ -28807,11 +29115,11 @@ var PROCESS_START = performance.timeOrigin;
28807
29115
  // packages/workit-core/src/hooks/run.ts
28808
29116
  if (false) {}
28809
29117
  // packages/workit-opencode/src/shared/init-apply.ts
28810
- import path47 from "node:path";
29118
+ import path48 from "node:path";
28811
29119
 
28812
29120
  // packages/workit-core/src/core/gitignore.ts
28813
- import { existsSync as existsSync14, readFileSync as readFileSync12, writeFileSync as writeFileSync5 } from "node:fs";
28814
- import path43 from "node:path";
29121
+ import { existsSync as existsSync14, readFileSync as readFileSync13, writeFileSync as writeFileSync5 } from "node:fs";
29122
+ import path44 from "node:path";
28815
29123
  var GITIGNORE_ENTRIES = [
28816
29124
  "# workit: SDD working state (never commit)",
28817
29125
  "docs/*/sdd/",
@@ -28831,8 +29139,8 @@ var GITIGNORE_ENTRIES = [
28831
29139
  var ensureProjectGitignore = (workspaceRoot, confirmed) => {
28832
29140
  if (!confirmed)
28833
29141
  return { ok: false, error: "confirmed: true required" };
28834
- const file = path43.join(workspaceRoot, ".gitignore");
28835
- const existing = existsSync14(file) ? readFileSync12(file, "utf8") : "";
29142
+ const file = path44.join(workspaceRoot, ".gitignore");
29143
+ const existing = existsSync14(file) ? readFileSync13(file, "utf8") : "";
28836
29144
  const existingLines = new Set(existing.split(`
28837
29145
  `).map((l) => l.trim()).filter(Boolean));
28838
29146
  const added = [];
@@ -28858,26 +29166,26 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
28858
29166
  };
28859
29167
 
28860
29168
  // packages/workit-core/src/core/hygiene.ts
28861
- import { existsSync as existsSync15, readFileSync as readFileSync13, readdirSync as readdirSync6, writeFileSync as writeFileSync6 } from "node:fs";
28862
- import path44 from "node:path";
29169
+ import { existsSync as existsSync15, readFileSync as readFileSync14, readdirSync as readdirSync6, writeFileSync as writeFileSync6 } from "node:fs";
29170
+ import path45 from "node:path";
28863
29171
  var repoRoot3 = assetRoot();
28864
- var templatesDir = () => path44.join(repoRoot3, "templates", "hygiene");
29172
+ var templatesDir = () => path45.join(repoRoot3, "templates", "hygiene");
28865
29173
  var packageJson = (root) => {
28866
- if (!existsSync15(path44.join(root, "package.json")))
29174
+ if (!existsSync15(path45.join(root, "package.json")))
28867
29175
  return null;
28868
29176
  try {
28869
- return JSON.parse(readFileSync13(path44.join(root, "package.json"), "utf8"));
29177
+ return JSON.parse(readFileSync14(path45.join(root, "package.json"), "utf8"));
28870
29178
  } catch {
28871
29179
  return null;
28872
29180
  }
28873
29181
  };
28874
29182
  var isOpenSource = (root) => {
28875
- if (existsSync15(path44.join(root, "LICENSE")))
29183
+ if (existsSync15(path45.join(root, "LICENSE")))
28876
29184
  return true;
28877
29185
  const pkg = packageJson(root);
28878
29186
  if (pkg && !pkg.private)
28879
29187
  return true;
28880
- return path44.basename(root) === "workit";
29188
+ return path45.basename(root) === "workit";
28881
29189
  };
28882
29190
  var licenseHolder = (root) => {
28883
29191
  const pkg = packageJson(root);
@@ -28900,13 +29208,13 @@ var planHygieneFiles = (root, opts = {}) => {
28900
29208
  files.push("LICENSE", "CONTRIBUTING.md");
28901
29209
  const planned = [];
28902
29210
  for (const file of files) {
28903
- if (existsSync15(path44.join(root, file)))
29211
+ if (existsSync15(path45.join(root, file)))
28904
29212
  continue;
28905
- const tpl = path44.join(templatesDir(), file);
29213
+ const tpl = path45.join(templatesDir(), file);
28906
29214
  if (!existsSync15(tpl))
28907
29215
  continue;
28908
- const content = readFileSync13(tpl, "utf8").replace(/<PROJECT>/g, path44.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
28909
- planned.push({ path: path44.join(root, file), content });
29216
+ const content = readFileSync14(tpl, "utf8").replace(/<PROJECT>/g, path45.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
29217
+ planned.push({ path: path45.join(root, file), content });
28910
29218
  }
28911
29219
  return planned;
28912
29220
  };
@@ -28916,30 +29224,30 @@ var ensureHygieneFiles = (root, opts) => {
28916
29224
  const created = [];
28917
29225
  for (const planned of planHygieneFiles(root, opts)) {
28918
29226
  writeFileSync6(planned.path, planned.content, "utf8");
28919
- created.push(path44.basename(planned.path));
29227
+ created.push(path45.basename(planned.path));
28920
29228
  }
28921
29229
  return { ok: true, created };
28922
29230
  };
28923
29231
 
28924
29232
  // packages/workit-core/src/core/init.ts
28925
29233
  import fs30 from "node:fs";
28926
- import path46 from "node:path";
29234
+ import path47 from "node:path";
28927
29235
  import { spawnSync as spawnSync25 } from "node:child_process";
28928
29236
 
28929
29237
  // packages/workit-core/src/core/workspace-branch-policy.ts
28930
- import { mkdirSync as mkdirSync5, readFileSync as readFileSync14, renameSync as renameSync4, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
28931
- import path45 from "node:path";
29238
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync15, renameSync as renameSync4, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
29239
+ import path46 from "node:path";
28932
29240
  import { isDeepStrictEqual } from "node:util";
28933
29241
  var readFileSafe = (p) => {
28934
29242
  try {
28935
- return readFileSync14(p, "utf8");
29243
+ return readFileSync15(p, "utf8");
28936
29244
  } catch {
28937
29245
  return null;
28938
29246
  }
28939
29247
  };
28940
29248
  function applyWorkspaceBranchPolicy(opts) {
28941
29249
  const { workspace_root, env = process.env } = opts;
28942
- const dir = path45.join(env.WORKIT_CONFIG ?? configDir2());
29250
+ const dir = path46.join(env.WORKIT_CONFIG ?? configDir2());
28943
29251
  const {
28944
29252
  status,
28945
29253
  path: wsPath,
@@ -28951,7 +29259,7 @@ function applyWorkspaceBranchPolicy(opts) {
28951
29259
  if (status === "malformed" || status === "invalid")
28952
29260
  return { ok: false, error: workspacesError ?? `invalid workspaces.json: ${wsPath}` };
28953
29261
  const detection = detectBranchPolicy(workspace_root);
28954
- const name = String(env.WORKIT_BP_NAME ?? path45.basename(workspace_root));
29262
+ const name = String(env.WORKIT_BP_NAME ?? path46.basename(workspace_root));
28955
29263
  const integration = env.WORKIT_BP_INTEGRATION ?? detection.integration;
28956
29264
  const policy = {
28957
29265
  preset: detection.preset,
@@ -29000,7 +29308,7 @@ function applyWorkspaceBranchPolicy(opts) {
29000
29308
  ok: false,
29001
29309
  error: `workspaces.json changed while applying the branch policy: ${wsPath}`
29002
29310
  };
29003
- mkdirSync5(path45.dirname(wsPath), { recursive: true });
29311
+ mkdirSync5(path46.dirname(wsPath), { recursive: true });
29004
29312
  const tmp = `${wsPath}.${process.pid}.tmp`;
29005
29313
  try {
29006
29314
  writeFileSync7(tmp, JSON.stringify({ ...document, workspaces: next }, null, 2) + `
@@ -29100,7 +29408,7 @@ function initApplyData(action, env = process.env) {
29100
29408
  fs30.mkdirSync(dir, { recursive: true });
29101
29409
  switch (action) {
29102
29410
  case "youtrack_json": {
29103
- const out = path46.join(dir, "youtrack.json");
29411
+ const out = path47.join(dir, "youtrack.json");
29104
29412
  fs30.writeFileSync(out, JSON.stringify(youtrackJsonContent(), null, 2) + `
29105
29413
  `, "utf8");
29106
29414
  return { action, ok: true, path: out };
@@ -29114,10 +29422,10 @@ function initApplyData(action, env = process.env) {
29114
29422
  };
29115
29423
  }
29116
29424
  case "youtrack_scaffold": {
29117
- const jsonOut = path46.join(dir, "youtrack.json");
29425
+ const jsonOut = path47.join(dir, "youtrack.json");
29118
29426
  fs30.writeFileSync(jsonOut, JSON.stringify(youtrackJsonContent(), null, 2) + `
29119
29427
  `, "utf8");
29120
- const configPath = path46.resolve(jsonOut);
29428
+ const configPath = path47.resolve(jsonOut);
29121
29429
  const cfg = readJson3(configPath) ?? {};
29122
29430
  const base = String(cfg.baseUrl ?? "").replace(/\/+$/, "");
29123
29431
  const meeting = String(cfg.meetingIssue ?? "");
@@ -29153,10 +29461,10 @@ function initApplyData(action, env = process.env) {
29153
29461
  };
29154
29462
  }
29155
29463
  case "vcs_scaffold": {
29156
- const jsonOut = path46.join(dir, "vcs.json");
29464
+ const jsonOut = path47.join(dir, "vcs.json");
29157
29465
  fs30.writeFileSync(jsonOut, JSON.stringify(vcsJsonContent(), null, 2) + `
29158
29466
  `, "utf8");
29159
- const configPath = path46.resolve(jsonOut);
29467
+ const configPath = path47.resolve(jsonOut);
29160
29468
  const prev = process.env.WORKIT_VCS_CONFIG;
29161
29469
  process.env.WORKIT_VCS_CONFIG = configPath;
29162
29470
  try {
@@ -29275,7 +29583,7 @@ var executeInitApply = (args, directory, runtime) => {
29275
29583
  protectedNames: args.branch_policy_protected
29276
29584
  }, current);
29277
29585
  writeConfig(next);
29278
- return output(ok({ action: "config", path: path47.join(configDir2(), "config.json"), ...next }));
29586
+ return output(ok({ action: "config", path: path48.join(configDir2(), "config.json"), ...next }));
29279
29587
  }
29280
29588
  const env = Object.fromEntries(Object.entries({
29281
29589
  WORKIT_YT_BASE_URL: args.base_url,
@@ -29292,14 +29600,14 @@ var executeInitApply = (args, directory, runtime) => {
29292
29600
 
29293
29601
  // packages/workit-opencode/src/shared/session.ts
29294
29602
  import { realpathSync as realpathSync10 } from "node:fs";
29295
- import path48 from "node:path";
29603
+ import path49 from "node:path";
29296
29604
  var sameWorkspace = (expected, observed) => {
29297
29605
  if (typeof observed !== "string" || !observed)
29298
29606
  return false;
29299
29607
  try {
29300
29608
  return realpathSync10(expected) === realpathSync10(observed);
29301
29609
  } catch {
29302
- return path48.resolve(expected) === path48.resolve(observed);
29610
+ return path49.resolve(expected) === path49.resolve(observed);
29303
29611
  }
29304
29612
  };
29305
29613
 
@@ -29371,7 +29679,7 @@ var workitFamilyOf = (toolName) => {
29371
29679
 
29372
29680
  // packages/workit-opencode/src/tools/context.ts
29373
29681
  import { realpathSync as realpathSync11 } from "node:fs";
29374
- import path49 from "node:path";
29682
+ import path50 from "node:path";
29375
29683
  var createContextTool = () => ({
29376
29684
  description: "Read Git, pull request, YouTrack, issue, changelog, release, or affected-file context.",
29377
29685
  execute: async (args, context) => {
@@ -29381,7 +29689,7 @@ var createContextTool = () => ({
29381
29689
  let root;
29382
29690
  try {
29383
29691
  const cwd = parsed.data.cwd;
29384
- root = realpathSync11(cwd ? path49.resolve(context.directory, cwd) : context.directory);
29692
+ root = realpathSync11(cwd ? path50.resolve(context.directory, cwd) : context.directory);
29385
29693
  } catch {
29386
29694
  return JSON.stringify(failure2("invalid_input", "context target directory cannot be resolved"), null, 2);
29387
29695
  }
@@ -29412,9 +29720,9 @@ var workerCoordinatorFor = (task, worker) => {
29412
29720
 
29413
29721
  // packages/workit-core/src/fanout.ts
29414
29722
  import { spawnSync as spawnSync29 } from "node:child_process";
29415
- import { createHash as createHash19 } from "node:crypto";
29723
+ import { createHash as createHash20 } from "node:crypto";
29416
29724
  import fs32 from "node:fs";
29417
- import path52 from "node:path";
29725
+ import path53 from "node:path";
29418
29726
 
29419
29727
  // packages/workit-core/src/fanout-landed.ts
29420
29728
  import { spawnSync as spawnSync26 } from "node:child_process";
@@ -29642,14 +29950,14 @@ var NOTICE_TTL_MS = 7 * 86400000;
29642
29950
 
29643
29951
  // packages/workit-core/src/stack.ts
29644
29952
  import { spawnSync as spawnSync28 } from "node:child_process";
29645
- import { createHash as createHash18, randomBytes as randomBytes4 } from "node:crypto";
29953
+ import { createHash as createHash19, randomBytes as randomBytes4 } from "node:crypto";
29646
29954
  import fs31 from "node:fs";
29647
- import path51 from "node:path";
29955
+ import path52 from "node:path";
29648
29956
 
29649
29957
  // packages/workit-core/src/git/ops.ts
29650
29958
  import { spawnSync as spawnSync27 } from "node:child_process";
29651
- import { copyFileSync as copyFileSync2, existsSync as existsSync16, readdirSync as readdirSync7, readFileSync as readFileSync15, rmSync as rmSync4 } from "node:fs";
29652
- import path50 from "node:path";
29959
+ import { copyFileSync as copyFileSync2, existsSync as existsSync16, readdirSync as readdirSync7, readFileSync as readFileSync16, rmSync as rmSync4 } from "node:fs";
29960
+ import path51 from "node:path";
29653
29961
  var COMMIT_TIMEOUT_MS = 10 * 60000;
29654
29962
  var git5 = (cwd, args, options = {}) => {
29655
29963
  const result = spawnSync27("git", args, {
@@ -29682,18 +29990,18 @@ function operationInProgress(cwd) {
29682
29990
  if (!run.ok)
29683
29991
  return null;
29684
29992
  const found = run.stdout.split(`
29685
- `).map((line) => path50.resolve(cwd, line.trim()));
29993
+ `).map((line) => path51.resolve(cwd, line.trim()));
29686
29994
  const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
29687
29995
  for (const [index, [, operation]] of markers.entries()) {
29688
29996
  const marker = found[index];
29689
29997
  if (!marker || !existsSync16(marker))
29690
29998
  continue;
29691
- if (index === 1 && existsSync16(path50.join(marker, "applying")))
29999
+ if (index === 1 && existsSync16(path51.join(marker, "applying")))
29692
30000
  return { operation: "am", commitAllowed: false, branch: null };
29693
- if (index === 0 && existsSync16(path50.join(marker, "amend")) && !conflicted()) {
30001
+ if (index === 0 && existsSync16(path51.join(marker, "amend")) && !conflicted()) {
29694
30002
  let headName = "";
29695
30003
  try {
29696
- headName = readFileSync15(path50.join(marker, "head-name"), "utf8").trim();
30004
+ headName = readFileSync16(path51.join(marker, "head-name"), "utf8").trim();
29697
30005
  } catch {}
29698
30006
  const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
29699
30007
  return { operation, commitAllowed: branch !== null, branch };
@@ -29821,7 +30129,7 @@ function rebaseInProgress(dir) {
29821
30129
  }
29822
30130
  var scratchDir = (cwd) => {
29823
30131
  const dir = stacksDir(cwd);
29824
- return dir.ok ? path51.join(dir.data, "worktrees") : null;
30132
+ return dir.ok ? path52.join(dir.data, "worktrees") : null;
29825
30133
  };
29826
30134
  function gitRestack(cwd, input) {
29827
30135
  const owner = worktreeOf(cwd, input.branch);
@@ -29836,7 +30144,7 @@ function gitRestack(cwd, input) {
29836
30144
  error: "no store root"
29837
30145
  };
29838
30146
  fs31.mkdirSync(scratch, { recursive: true });
29839
- dir = path51.join(scratch, `${input.branch.replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 40)}-${randomBytes4(4).toString("hex")}`);
30147
+ dir = path52.join(scratch, `${input.branch.replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 40)}-${randomBytes4(4).toString("hex")}`);
29840
30148
  const added = gitRun4(cwd, ["worktree", "add", "-q", dir, input.branch], GIT_TIMEOUTS.worktree);
29841
30149
  if (!added.ok)
29842
30150
  return {
@@ -29890,12 +30198,12 @@ function gitRestack(cwd, input) {
29890
30198
  var firstLine = (run) => (`${run.stderr}
29891
30199
  ${run.stdout}`.split(`
29892
30200
  `).find((line) => line.trim()) ?? "git failed").trim().slice(0, 300);
29893
- var stackFileName = (name) => `${name.replace(/[^A-Za-z0-9._-]+/gu, "_").replace(/^[._]+/u, "").slice(0, 48).toLowerCase()}-${createHash18("sha256").update(name).digest("hex").slice(0, 12)}.json`;
30201
+ var stackFileName = (name) => `${name.replace(/[^A-Za-z0-9._-]+/gu, "_").replace(/^[._]+/u, "").slice(0, 48).toLowerCase()}-${createHash19("sha256").update(name).digest("hex").slice(0, 12)}.json`;
29894
30202
  function stacksDir(cwd) {
29895
30203
  const root = storeRoot(cwd);
29896
30204
  if (!root.ok)
29897
30205
  return stackFail(root.code, root.error, root.unblock);
29898
- return { ok: true, data: path51.join(root.value.root, "stacks") };
30206
+ return { ok: true, data: path52.join(root.value.root, "stacks") };
29899
30207
  }
29900
30208
  var HEARTBEAT_STALE_MS = 2 * 60000;
29901
30209
  var SETTLED_BY_RESTACK = new Set(["checks_pending", "behind_base_required"]);
@@ -30036,13 +30344,13 @@ function sliceHash(slice) {
30036
30344
  issues: _issues,
30037
30345
  ...definition
30038
30346
  } = slice;
30039
- return createHash19("sha256").update(JSON.stringify(definition)).digest("hex").slice(0, 16);
30347
+ return createHash20("sha256").update(JSON.stringify(definition)).digest("hex").slice(0, 16);
30040
30348
  }
30041
30349
  function fanoutsDir(cwd) {
30042
30350
  const root = storeRoot(cwd);
30043
30351
  if (!root.ok)
30044
30352
  return fanoutFail(root.code, root.error, root.unblock);
30045
- return { ok: true, data: path52.join(root.value.root, "fanouts") };
30353
+ return { ok: true, data: path53.join(root.value.root, "fanouts") };
30046
30354
  }
30047
30355
  function parseStored(raw) {
30048
30356
  if (!isRecord7(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
@@ -30110,7 +30418,7 @@ function readFanout(cwd, name) {
30110
30418
  const dir = fanoutsDir(cwd);
30111
30419
  if (!dir.ok)
30112
30420
  return dir;
30113
- const file = path52.join(dir.data, stackFileName(name));
30421
+ const file = path53.join(dir.data, stackFileName(name));
30114
30422
  let parsed = null;
30115
30423
  try {
30116
30424
  parsed = parseStored(JSON.parse(fs32.readFileSync(file, "utf8")));
@@ -30135,7 +30443,7 @@ function listFanouts(cwd) {
30135
30443
  for (const entry of names) {
30136
30444
  let parsed = null;
30137
30445
  try {
30138
- parsed = parseStored(JSON.parse(fs32.readFileSync(path52.join(dir.data, entry), "utf8")));
30446
+ parsed = parseStored(JSON.parse(fs32.readFileSync(path53.join(dir.data, entry), "utf8")));
30139
30447
  } catch {
30140
30448
  parsed = null;
30141
30449
  }
@@ -30983,14 +31291,14 @@ var childTaskMissing = (store, input) => {
30983
31291
  var childDenial = (identity) => `OpenCode child session has no validated Workit worker: as ${identity} it may only inspect the task summary (workit_task action "inspect") or record evidence or findings (workit_evidence/workit_finding action "record") on an existing task; for anything else the lead assigns it a worker with workit_worker before launching it`;
30984
31292
 
30985
31293
  // packages/workit-opencode/src/v2/shell.ts
30986
- import path53 from "node:path";
31294
+ import path54 from "node:path";
30987
31295
 
30988
31296
  // packages/workit-core/src/hooks/repeat-failure.ts
30989
- import { createHash as createHash20 } from "node:crypto";
31297
+ import { createHash as createHash21 } from "node:crypto";
30990
31298
  var SAME_CALL_FAILED = "Same call failed twice:";
30991
31299
  var MAX_SESSIONS = 256;
30992
31300
  var stable = (value) => JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).toSorted(([a], [b]) => a.localeCompare(b))) : entry) ?? "null";
30993
- var hashOf = (call) => createHash20("sha256").update(call).digest("hex").slice(0, 32);
31301
+ var hashOf = (call) => createHash21("sha256").update(call).digest("hex").slice(0, 32);
30994
31302
  var record3 = (memo, sessionId, call, failed, next) => {
30995
31303
  const previous = memo.get(sessionId);
30996
31304
  memo.delete(sessionId);
@@ -31046,7 +31354,7 @@ var commandOf = (input) => {
31046
31354
  };
31047
31355
  var hookInput = (root, sessionID, id, shell) => ({
31048
31356
  host: "opencode",
31049
- cwd: shell.workdir ? path53.resolve(root, shell.workdir) : root,
31357
+ cwd: shell.workdir ? path54.resolve(root, shell.workdir) : root,
31050
31358
  session: { id: sessionID, agentId: null, agentType: null, parentId: null },
31051
31359
  permissionMode: null,
31052
31360
  transcriptPath: null,
@@ -31322,38 +31630,38 @@ var createStopControl = (root, port) => {
31322
31630
  };
31323
31631
 
31324
31632
  // packages/workit-opencode/src/v2/registry.ts
31325
- import { existsSync as existsSync18, readFileSync as readFileSync16 } from "node:fs";
31326
- import path55 from "node:path";
31633
+ import { existsSync as existsSync18, readFileSync as readFileSync17 } from "node:fs";
31634
+ import path56 from "node:path";
31327
31635
 
31328
31636
  // packages/workit-opencode/src/shared/assets.ts
31329
31637
  import { existsSync as existsSync17, realpathSync as realpathSync12 } from "node:fs";
31330
- import path54 from "node:path";
31638
+ import path55 from "node:path";
31331
31639
  import { fileURLToPath as fileURLToPath2 } from "node:url";
31332
31640
  var moduleDir = () => {
31333
31641
  try {
31334
- return realpathSync12(path54.dirname(fileURLToPath2(import.meta.url)));
31642
+ return realpathSync12(path55.dirname(fileURLToPath2(import.meta.url)));
31335
31643
  } catch {
31336
- return path54.dirname(fileURLToPath2(import.meta.url));
31644
+ return path55.dirname(fileURLToPath2(import.meta.url));
31337
31645
  }
31338
31646
  };
31339
31647
  var packageRoot2 = () => {
31340
31648
  const dir = moduleDir();
31341
31649
  for (const candidate of [
31342
- path54.resolve(dir, ".."),
31343
- path54.resolve(dir, "..", ".."),
31344
- path54.resolve(dir, "..", "..", "..")
31650
+ path55.resolve(dir, ".."),
31651
+ path55.resolve(dir, "..", ".."),
31652
+ path55.resolve(dir, "..", "..", "..")
31345
31653
  ]) {
31346
- if (existsSync17(path54.join(candidate, "package.json")))
31654
+ if (existsSync17(path55.join(candidate, "package.json")))
31347
31655
  return candidate;
31348
31656
  }
31349
- return path54.resolve(dir, "..");
31657
+ return path55.resolve(dir, "..");
31350
31658
  };
31351
31659
  var skillsRoot = () => {
31352
31660
  const root = packageRoot2();
31353
- const canonical = path54.resolve(root, "..", "workit-core", "skills");
31354
- if (existsSync17(path54.join(root, "src")) && existsSync17(canonical))
31661
+ const canonical = path55.resolve(root, "..", "workit-core", "skills");
31662
+ if (existsSync17(path55.join(root, "src")) && existsSync17(canonical))
31355
31663
  return canonical;
31356
- return path54.join(root, "assets", "skills");
31664
+ return path55.join(root, "assets", "skills");
31357
31665
  };
31358
31666
 
31359
31667
  // packages/workit-opencode/src/v2/registry.ts
@@ -31380,11 +31688,11 @@ var registerSkills = async (ctx) => {
31380
31688
  if (!existsSync18(skillsDir))
31381
31689
  return new Set;
31382
31690
  const listed = await ctx.skill.list().catch(() => ({ data: [] }));
31383
- const own = (skill) => typeof skill.path === "string" && path55.resolve(skill.path).startsWith(skillsDir + path55.sep);
31691
+ const own = (skill) => typeof skill.path === "string" && path56.resolve(skill.path).startsWith(skillsDir + path56.sep);
31384
31692
  const userSkills = new Set((listed?.data ?? []).filter((skill) => !own(skill)).map((skill) => skill.id));
31385
31693
  const packaged = new Map;
31386
31694
  for (const id of WORKIT_METHOD_SKILLS) {
31387
- const file = path55.join(skillsDir, id, "SKILL.md");
31695
+ const file = path56.join(skillsDir, id, "SKILL.md");
31388
31696
  if (!userSkills.has(id) && existsSync18(file))
31389
31697
  packaged.set(id, file);
31390
31698
  }
@@ -31393,7 +31701,7 @@ var registerSkills = async (ctx) => {
31393
31701
  for (const [id, file] of packaged) {
31394
31702
  if (existing.has(id))
31395
31703
  continue;
31396
- const parsed = parseFrontmatter(readFileSync16(file, "utf8"));
31704
+ const parsed = parseFrontmatter(readFileSync17(file, "utf8"));
31397
31705
  editor.add({
31398
31706
  id,
31399
31707
  name: parsed.name || id,
@@ -31432,38 +31740,38 @@ var registerCommands = async (ctx, registeredSkills) => {
31432
31740
 
31433
31741
  // packages/workit-opencode/src/stale-sources.ts
31434
31742
  import { existsSync as existsSync19, readdirSync as readdirSync8 } from "node:fs";
31435
- import path56 from "node:path";
31743
+ import path57 from "node:path";
31436
31744
  import { fileURLToPath as fileURLToPath3 } from "node:url";
31437
31745
  var typescriptFiles = (directory) => {
31438
31746
  if (!existsSync19(directory))
31439
31747
  return [];
31440
31748
  return readdirSync8(directory, { withFileTypes: true }).flatMap((entry) => {
31441
- const file = path56.join(directory, entry.name);
31749
+ const file = path57.join(directory, entry.name);
31442
31750
  return entry.isDirectory() ? typescriptFiles(file) : entry.isFile() && file.endsWith(".ts") ? [file] : [];
31443
31751
  });
31444
31752
  };
31445
31753
  var pluginSourceFiles = [
31446
31754
  ...new Set([
31447
31755
  fileURLToPath3(import.meta.url),
31448
- ...typescriptFiles(path56.join(packageRoot2(), "src")),
31449
- path56.join(packageRoot2(), "..", "workit-core", "src", "core.ts"),
31450
- ...typescriptFiles(path56.join(packageRoot2(), "..", "workit-core", "src", "core"))
31756
+ ...typescriptFiles(path57.join(packageRoot2(), "src")),
31757
+ path57.join(packageRoot2(), "..", "workit-core", "src", "core.ts"),
31758
+ ...typescriptFiles(path57.join(packageRoot2(), "..", "workit-core", "src", "core"))
31451
31759
  ])
31452
31760
  ].filter((file) => existsSync19(file)).toSorted();
31453
31761
 
31454
31762
  // packages/workit-core/src/core/cli-locate.ts
31455
31763
  import { closeSync as closeSync2, existsSync as existsSync20, openSync as openSync2, readSync } from "node:fs";
31456
- import path57 from "node:path";
31764
+ import path58 from "node:path";
31457
31765
  var LAUNCHER_MARKER = "workit-owned-launcher";
31458
31766
  var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
31459
31767
  var installRoot = (env, platform = process.platform) => {
31460
31768
  if (env.WORKIT_INSTALL_ROOT)
31461
31769
  return env.WORKIT_INSTALL_ROOT;
31462
31770
  const data = dataDir(env, platform);
31463
- return platform === "win32" ? path57.join(data, "install") : data;
31771
+ return platform === "win32" ? path58.join(data, "install") : data;
31464
31772
  };
31465
- var ownedLauncherPath = (env, platform = process.platform) => path57.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
31466
- var ownedCurrentEntry = (env, platform = process.platform) => path57.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
31773
+ var ownedLauncherPath = (env, platform = process.platform) => path58.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
31774
+ var ownedCurrentEntry = (env, platform = process.platform) => path58.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
31467
31775
  var head = (file) => {
31468
31776
  let fd;
31469
31777
  try {
@@ -31490,7 +31798,7 @@ var locateWorkitCli = (options = {}) => {
31490
31798
  source: "owned-launcher",
31491
31799
  command: launcher,
31492
31800
  args: [],
31493
- binDir: path57.dirname(launcher)
31801
+ binDir: path58.dirname(launcher)
31494
31802
  };
31495
31803
  const current = ownedCurrentEntry(env, platform);
31496
31804
  if (exists(current))
@@ -31519,7 +31827,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
31519
31827
  if (located.binDir) {
31520
31828
  const key = pathKey(env);
31521
31829
  const delimiter = platform === "win32" ? ";" : ":";
31522
- const same = (dir) => platform === "win32" ? path57.win32.normalize(dir).toLowerCase() === path57.win32.normalize(located.binDir).toLowerCase() : path57.posix.normalize(dir) === path57.posix.normalize(located.binDir);
31830
+ const same = (dir) => platform === "win32" ? path58.win32.normalize(dir).toLowerCase() === path58.win32.normalize(located.binDir).toLowerCase() : path58.posix.normalize(dir) === path58.posix.normalize(located.binDir);
31523
31831
  const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
31524
31832
  patch[key] = [located.binDir, ...rest].join(delimiter);
31525
31833
  }